1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
<style type="text/css">
  /* DOCUMENT CSS */
  {% include 'css_document' %}
</style>

{{ # AGREEMENT }}
{% if estimate.requires_agreement? && estimate.agreed_to == false %}
  <div class="system_notice">
    <h3>
      <i>{{ account.company.name }}</i> has specified that this estimate requires agreement by you before work may continue.
    </h3>
    <div class="content_pad">
      <p>
        Please read through the terms of agreement and indicate your choice at the bottom of this page.
      </p>
    </div>
  </div>
{% endif %}

<div class="clear"></div>

<h1 id="doc_title" class="left_aligned">
  {{ account.company.name }}
</h1>

<div id="company_info" class="right_aligned">
  <p>
    {% include 'company' for account.company %}
  </p>
</div>

<div class="clear"></div>

{{ # DETAILS }}
<div class="document_details">
  {{ # LEFT DETAILS }}
  <div class="left_aligned">
    <table class="formContent">
      <tr>
        <td style="vertical-align:top;">{{ 'Client' | make_label }}</td>
        <td>
          {% include 'company' for estimate.company %}
        </td>
      </tr>
      <tr>  
        <td>{{ 'Project' | make_label }}</td>
        <td>{{ estimate.project.name }}</td>
      </tr>
      <tr>
        {{ # INVOICE DATE }}
        <td>{{ 'Estimate Date' | make_label }}</td>
        <td style="padding-right:10px;">
          {{ estimate.created_on | format_date }}
          <span class="info noprint">
            ({{ estimate.created_on | format_date_in_english }})
          </span>
        </td>
      </tr>
    </table>
  </div>
  
  {{ # RIGHT DETAILS }}
  <div class="right_aligned">
    <span class="bigger">{{ 'Estimated Cost' | make_label }}</span>
    <br/>
    <div id="total_amount">
      {% if estimate.has_worst_case_items %}
        {{ estimate.price_best | format_money }} - {{ estimate.price_worst | format_money }}
      {% else %}
        {{ estimate.price_best | format_money }}
      {% endif %}
    </div>
  </div>
  
  <div class="clear"></div>
</div>

{{ # INTRO }}
{% if estimate.intro_text != blank %}
  <h2>Introduction</h2>
  <div class="contentPad">
    {{ estimate.intro_text | format_text }}
  </div>
{% endif %}

{{ # LINE ITEMS FOR ESTIMATE }}
<table class="list" cellpadding="0" cellspacing="0" id="item_list">
  <colgroup>
    <col />
    <col style="width:250px" />
    <col style="width:80px" />
    <col style="width:180px" />
  </colgroup>
  <tr>
    <th class="first">Item Description</th>
    <th class="numeric">Estimate</th>
    <th class="numeric">Tax</th> 
    <th class="numeric last">Final Price</th>
  </tr>
  <tbody id="item_list_body">
    {% if estimate.line_items == null %}
      <tr>
        <td colspan="5" class="first last info">No items have been created yet.</td>
      </tr>
    {% else %}
      {{ # LINE ITEM LOOP }}
      {% for item in estimate.line_items %}
        <tr class="{% cycle 'parent_row': 'even', 'odd' %}">
          <td class="first">
            {{ item.title }}
            {% if item.description != blank %}
              <div class="line"></div>
              <div class="smaller">
                {{ item.description | format_text }}
              </div>              
            {% endif %}
          </td>
          {{ # ESTIMATES }}
          <td class="numeric">
            {{ # GENERIC ITEM }}
            {% if item.type == 'Generic' %}
        	    {% if item.has_worst_case %}
          		  {{ item.quantity_low }} - 
              {% endif %}
              {{ item.quantity_estimate }} {{ item.unit_label }} @ {{ item.rate | format_money }} ea
            
            {{ % TASK ITEM }}
        	  {% elsif item.type == 'Task' %}
          		{% if item.has_worst_case %}
          		  {{ item.time_best | format_hours }} - 
              {% endif %}
              {{ item.estimate_time | format_hours }} hours @ {{ item.rate | format_money }} ea
            {{ # PRODUCT ITEM }}
            {% elsif item.type == 'Product' %}
              {{ item.quantity_estimate }} {{ item.unit_label }} @ {{ item.rate | format_money }} ea
            {% endif %}

            {{ # FLAT FEE }}
            {% if item.flat_fee_in_cents > 0 %}
              <br/>
              {{ item.flat_fee | format_money }} flat fee
            {% endif %}
          </td>
          
          {{ # TAX }}
          <td class="numeric">
            {% if item.is_taxable %}
              *
            {% else %}
              &nbsp;
            {% endif %}
          </td>
          
          {{ # TOTAL PRICES }}
          {% if item.has_worst_case %}
            <td class="money_gain last">
              <table cellpadding="0" cellspacing="0" class="inner">
                <tr>
                  <td class="info">Low</td> 
                  <td class="numeric money_gain">
                    {{ item.price_best | format_money }}
                  </td>
                </tr>
                <tr>
                  <td class="info">High</td>
                  <td class="numeric money_gain">
                    {{ item.price_worst | format_money }}
                  </td>
                </tr>
              </table>
            </td>
          {% else %}
            <td class="numeric money_gain last">
              {{ item.price_best | format_money }}
            </td>
          {% endif %}
        </tr>       
      {% endfor %}
    
    {% endif %}
  </tbody>
  
  {{ # TABLE FOOTER }}
  <tbody id="item_list_footer">
    {{ # SALES TAX }}
    {% if estimate.sales_tax != null %}
      <tr class="summary">
      	<td colspan="4" class="first last numeric">
      		<b>Tax 1</b> - {{ estimate.sales_tax }}%
      	</td>
      </tr>
    {% endif %}
    {% if estimate.sales_tax_2 != null %}
    	<tr class="summary">
    	  <td colspan="4" class="first last numeric">
    			<b>Tax 2</b> - {{ estimate.sales_tax_2 }}%
    		</td>
    	</tr>
    {% endif %}
    
    
    <tr class="footer">
      <td class="first numeric">
        {% if estimate.has_worst_case_items %}Low<br/>{% endif %}
    	  {% if estimate.has_worst_case_items %}High {% endif %}
      </td>
      {{ # ESTIMATES }}
      <td class="numeric">
        Hours - 
    	  {% if estimate.has_worst_case_items %}
    	    {{ estimate.time_best | format_hours }}<br/>
    	  {% endif %}
    	  {{ estimate.time_worst | format_hours }}
      </td>
      {{ # TAXES }}
      <td class="numeric">
        {% if estimate.has_worst_case_items %}
          {{ estimate.tax_cost_total_low | format_money }}<br/>
    	  {% endif %}
    	  {{ estimate.tax_cost_total_high | format_money }}<br/>
      </td>
      {{ # COSTS }}
      <td class="last numeric">
        {% if estimate.has_worst_case_items %}
          {{ estimate.price_best | format_money }}<br/>
    	  {% endif %}
    	  {{ estimate.price_worst | format_money }}<br/>
      </td>
    </tr>
  </tbody>
</table>

<br/>

{{ # TERMS }}
<h2>Terms of Agreement</h2>
<div class="contentPad">
  {% if estimate.agreement_text != blank %}
    {{ estimate.agreement_text | format_text }}
  {% else %}
    <p>
      No agreement terms have been set for this estimate.
    </p>
  {% endif %}
</div>