resolve TypeError: unsupported operand types: string + int;
[civicrm-core.git] / templates / CRM / Price / Page / LineItem.tpl
1 {*
2 +--------------------------------------------------------------------+
3 | Copyright CiviCRM LLC. All rights reserved. |
4 | |
5 | This work is published under the GNU AGPLv3 license with some |
6 | permitted exceptions and without any warranty. For full license |
7 | and copyright information, see https://civicrm.org/licensing |
8 +--------------------------------------------------------------------+
9 *}
10
11 {* Displays contribution/event fees when price set is used. *}
12 {if !$currency && $fee_currency}
13 {assign var=currency value="$fee_currency"}
14 {/if}
15
16 {foreach from=$lineItem item=value key=priceset}
17 {if $value neq 'skip'}
18 {if $lineItem|@count GT 1} {* Header for multi participant registration cases. *}
19 {if $priceset GT 0}
20 <br />
21 {/if}
22 <strong>{ts}Participant {$priceset+1}{/ts}</strong> {$part.$priceset.info}
23 {/if}
24 <table>
25 <tr class="columnheader">
26 <th>{ts}Item{/ts}</th>
27 {if $displayLineItemFinancialType}
28 <th>{ts}Financial Type{/ts}</th>
29 {/if}
30 {if $context EQ "Membership"}
31 <th class="right">{ts}Fee{/ts}</th>
32 {else}
33 <th class="right">{ts}Qty{/ts}</th>
34 <th class="right">{ts}Unit Price{/ts}</th>
35 {if !$getTaxDetails}
36 <th class="right">{ts}Total Price{/ts}</th>
37 {/if}
38 {/if}
39
40 {if $getTaxDetails}
41 <th class="right">{ts}Subtotal{/ts}</th>
42 <th class="right">{ts}Tax Rate{/ts}</th>
43 <th class="right">{ts}Tax Amount{/ts}</th>
44 <th class="right">{ts}Total Amount{/ts}</th>
45 {/if}
46
47 {if $pricesetFieldsCount}
48 <th class="right">{ts}Total Participants{/ts}</th>
49 {/if}
50 </tr>
51 {foreach from=$value item=line}
52 <tr{if $line.qty EQ 0} class="cancelled"{/if}>
53 <td>{if $line.field_title && $line.html_type neq 'Text'}{$line.field_title} &ndash; {$line.label}{else}{$line.label}{/if} {if $line.description}<div class="description">{$line.description}</div>{/if}</td>
54 {if $displayLineItemFinancialType}
55 <td>{$line.financial_type}</td>
56 {/if}
57 {if $context NEQ "Membership"}
58 <td class="right">{$line.qty}</td>
59 <td class="right">{$line.unit_price|crmMoney:$currency}</td>
60 {else}
61 <td class="right">{$line.line_total|crmMoney:$currency}</td>
62 {/if}
63 {if !$getTaxDetails && $context NEQ "Membership"}
64 <td class="right">{$line.line_total|crmMoney:$currency}</td>
65 {/if}
66 {if $getTaxDetails}
67 <td class="right">{$line.line_total|crmMoney:$currency}</td>
68 {if $line.tax_rate != "" || $line.tax_amount != ""}
69 <td class="right">{$taxTerm} ({$line.tax_rate}%)</td>
70 <td class="right">{$line.tax_amount|crmMoney:$currency}</td>
71 {else}
72 <td></td>
73 <td></td>
74 {/if}
75 <td class="right">{$line.line_total+$line.tax_amount|crmMoney:$currency}</td>
76 {/if}
77 {if $pricesetFieldsCount}
78 <td class="right">{$line.participant_count}</td>
79 {/if}
80 </tr>
81 {/foreach}
82 </table>
83 {/if}
84 {/foreach}
85
86 <div class="crm-section no-label total_amount-section">
87 <div class="content bold">
88 {if $getTaxDetails && $totalTaxAmount}
89 {ts 1=$taxTerm}Total %1 Amount{/ts}: {$totalTaxAmount|crmMoney:$currency}<br />
90 {/if}
91 {if $context EQ "Contribution"}
92 {ts}Contribution Total{/ts}:
93 {elseif $context EQ "Event"}
94 {if $totalTaxAmount}
95 {ts}Event SubTotal: {$totalAmount-$totalTaxAmount|crmMoney:$currency}{/ts}<br />
96 {/if}
97 {ts}Event Total{/ts}:
98 {elseif $context EQ "Membership"}
99 {ts}Membership Fee Total{/ts}:
100 {else}
101 {ts}Total Amount{/ts}:
102 {/if}
103 {$totalAmount|crmMoney:$currency}
104 </div>
105 <div class="clear"></div>
106 <div class="content bold">
107 {if $pricesetFieldsCount}
108 {ts}Total Participants{/ts}:
109 {foreach from=$lineItem item=pcount}
110 {if $pcount neq 'skip'}
111 {assign var="lineItemCount" value=0}
112
113 {foreach from=$pcount item=p_count}
114 {assign var="intPCount" value=$p_count.participant_count|intval}
115 {assign var="lineItemCount" value=$lineItemCount+$intPCount}
116 {/foreach}
117 {if $lineItemCount < 1 }
118 {assign var="lineItemCount" value=1}
119 {/if}
120 {assign var="totalcount" value=$totalcount+$lineItemCount}
121 {/if}
122 {/foreach}
123 {$totalcount}
124 {/if}
125 </div>
126 <div class="clear"></div>
127 </div>
128
129 {if $hookDiscount && $hookDiscount.message}
130 <div class="crm-section hookDiscount-section">
131 <em>({$hookDiscount.message})</em>
132 </div>
133 {/if}
134 {literal}
135 <script type="text/javascript">
136 CRM.$(function($) {
137 {/literal}
138 var comma = '{$config->monetaryThousandSeparator}';
139 var dot = '{$config->monetaryDecimalPoint}';
140 var format = '{$config->moneyformat}';
141 var currency = '{$currency}';
142 var currencySymbol = '{$currencySymbol}';
143 {literal}
144 // Todo: This function should be a utility
145 function moneyFormat(amount) {
146 amount = parseFloat(amount).toFixed(2);
147 amount = amount.replace(',', 'comma').replace('.', 'dot');
148 amount = amount.replace('comma', comma).replace('dot', dot);
149 return format.replace('%C', currency).replace('%c', currencySymbol).replace('%a', amount);
150 }});
151 </script>
152 {/literal}