/
view.php
executable file
路211 lines (190 loc) 路 15.6 KB
/
view.php
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
<div class="row">
<div class="col-xs-12 col-sm-12">
<a href="<?php echo base_url()?>subscriptions/update/<?php echo $subscription->id;?>/view" class="btn btn-primary" data-toggle="mainmodal"><i class="fa fa-edit visible-xs"></i><span class="hidden-xs"><?php echo $this->lang->line('application_edit_subscription');?></span></a>
<a href="<?php echo base_url()?>subscriptions/item/<?php echo $subscription->id;?>" class="btn btn-primary" data-toggle="mainmodal"><i class="fa fa-plus visible-xs"></i><span class="hidden-xs"><?php echo $this->lang->line('application_add_item');?></span></a>
<?php if($subscription->end_date > $subscription->next_payment && date("Y-m-d") >= date('Y-m-d', strtotime('-3 day', strtotime ($subscription->next_payment)))){ ?>
<a href="<?php echo base_url()?>subscriptions/create_invoice/<?php echo $subscription->id;?>" class="btn btn-primary"><i class="fa fa-file-o visible-xs"></i><span class="hidden-xs"><?php echo $this->lang->line('application_create_invoice');?></span></a>
<?php } ?>
<?php if($subscription->status != "Paid" && isset($subscription->company->name)){ ?><a href="<?php echo base_url()?>subscriptions/sendsubscription/<?php echo $subscription->id;?>" class="btn btn-primary"><i class="fa fa-envelope visible-xs"></i><span class="hidden-xs"><?php echo $this->lang->line('application_send_subscription_to_client');?></span></a><?php } ?>
<?php if($core_settings->paypal == "1" && isset($subscription->subscription_has_items[0]) && $subscription->subscribed == "0"){ ?>
<a href="javascript:document.forms['paypal_subscribe'].submit();" class="btn btn-success pull-right"><?php echo $this->lang->line('application_subscribe_via_paypal');?></a>
<?php } ?>
</div>
</div>
<div class="row">
<div class="col-xs-12 col-sm-12">
<div class="table-head"><?php echo $this->lang->line('application_subscription_details');?></div>
<div class="subcont">
<ul class="details col-xs-12 col-sm-6">
<li><span><?php echo $this->lang->line('application_subscription_id');?>:</span> <?php echo $core_settings->subscription_prefix;?><?php echo $subscription->reference;?></li>
<li class="<?php echo $subscription->status;?>"><span><?php echo $this->lang->line('application_status');?>:</span>
<a class="label <?php if($subscription->status == 'Active'){ echo 'label-success';}else{echo 'label-important'; } ?>"><?php if($subscription->end_date <= date('Y-m-d') && $subscription->status != "Inactive"){ echo $this->lang->line('application_ended'); }else{ echo $this->lang->line('application_'.$subscription->status);}?></a>
<?php if($subscription->subscribed != "0"){ ?> <a class="label label-success margin-left-5 tt" title="<?php $unix = human_to_unix($subscription->subscribed.' 00:00'); echo date($core_settings->date_format, $unix);?>" ><?php echo $this->lang->line('application_subscribed_via_paypal');?></a> <?php } ?>
</li>
<li><span><?php echo $this->lang->line('application_issue_date');?>:</span> <?php $unix = human_to_unix($subscription->issue_date.' 00:00'); echo date($core_settings->date_format, $unix);?></li>
<li><span><?php echo $this->lang->line('application_end_date');?>:</span> <a class="label <?php if($subscription->end_date <= date('Y-m-d') && $subscription->status != "Inactive"){ echo 'label-success tt" title="'.$this->lang->line('application_subscription_has_ended'); } ?>"><?php $unix = human_to_unix($subscription->end_date.' 00:00'); echo date($core_settings->date_format, $unix);?></a></li>
<li><span><?php echo $this->lang->line('application_frequency');?>:</span>
<?php $freq = array('+7 day' => $this->lang->line('application_weekly'),
'+14 day' => $this->lang->line('application_every_other_week'),
'+1 month' => $this->lang->line('application_monthly'),
'+3 month' => $this->lang->line('application_quarterly'),
'+6 month' => $this->lang->line('application_semi_annually'),
'+1 year' => $this->lang->line('application_annually'));
echo $freq[$subscription->frequency];
?>
</li>
<li><span><?php echo $this->lang->line('application_next_payment');?>:</span> <a class="label <?php
if($subscription->status == "Active" && $subscription->next_payment > date('Y-m-d')){
echo 'label-success ';}
if($subscription->next_payment <= date('Y-m-d') && $subscription->end_date > $subscription->next_payment && $subscription->status != "Inactive"){
echo 'label-important tt" title="'.$this->lang->line('application_new_invoice_needed');
} ?>"><?php $unix = human_to_unix($subscription->next_payment.' 00:00');
if($subscription->end_date >= $subscription->next_payment){
echo date($core_settings->date_format, $unix);
}else{ echo "-";} ?>
</a></li>
<span class="visible-xs"></span>
</ul>
<ul class="details col-xs-12 col-sm-6">
<?php if(isset($subscription->company->name)){ ?>
<li><span><?php echo $this->lang->line('application_company');?>:</span> <a href="<?php echo base_url()?>clients/view/<?php echo $subscription->company->id;?>" class="label label-info"><?php echo $subscription->company->name;?></a></li>
<li><span><?php echo $this->lang->line('application_contact');?>:</span> <?php if(isset($subscription->company->client->firstname)){ ?> <?php echo $subscription->company->client->firstname;?> <?php echo $subscription->company->client->lastname;?> <?php }else{echo "-";} ?></li>
<li><span><?php echo $this->lang->line('application_street');?>:</span> <?php echo $subscription->company->address;?></li>
<li><span><?php echo $this->lang->line('application_city');?>:</span> <?php echo $subscription->company->zipcode;?> <?php echo $subscription->company->city;?></li>
<li><span><?php echo $this->lang->line('application_website');?>:</span> <?php echo $subscription->company->website;?></li>
<?php }else{ ?>
<li><?php echo $this->lang->line('application_no_client_assigned');?></li>
<?php } ?>
</ul>
<br clear="all">
</div>
</div>
</div>
<div class="row">
<div class="col-xs-12 col-sm-12">
<div class="table-head"><?php echo $this->lang->line('application_subscription_items');?> <span class="pull-right"><a href="<?php echo base_url()?>subscriptions/item/<?php echo $subscription->id;?>" class="btn btn-primary" data-toggle="mainmodal"><?php echo $this->lang->line('application_add_item');?></a></span></div>
<div class="table-div min-height-200">
<table id="items" class="table" rel="<?php echo base_url()?>" cellspacing="0" cellpadding="0">
<thead>
<th width="4%"><?php echo $this->lang->line('application_action');?></th>
<th><?php echo $this->lang->line('application_name');?></th>
<th class="hidden-xs"><?php echo $this->lang->line('application_description');?></th>
<th class="hidden-xs" width="8%"><?php echo $this->lang->line('application_hrs_qty');?></th>
<th class="hidden-xs" width="12%"><?php echo $this->lang->line('application_unit_price');?></th>
<th width="12%"><?php echo $this->lang->line('application_sub_total');?></th>
</thead>
<?php $i = 0; $sum = 0;?>
<?php foreach ($items as $value):?>
<tr id="<?php echo $value->id;?>" >
<td class="option" width="8%" style="text-align: left;">
<button type="button" class="btn-option delete po" data-toggle="popover" data-placement="left" data-content="<a class='btn btn-danger po-delete ajax-silent' href='<?php echo base_url()?>subscriptions/item_delete/<?php echo $subscription->subscription_has_items[$i]->id;?>/<?php echo $subscription->id;?>'><?php echo $this->lang->line('application_yes_im_sure');?></a> <button class='btn po-close'><?php echo $this->lang->line('application_no');?></button> <input type='hidden' name='td-id' class='id' value='<?php echo $value->id;?>'>" data-original-title="<b><?php echo $this->lang->line('application_really_delete');?></b>"><i class="fa fa-times"></i></button>
<a href="<?php echo base_url()?>subscriptions/item_update/<?php echo $subscription->subscription_has_items[$i]->id;?>" class="btn-option" data-toggle="mainmodal"><i class="fa fa-cog"></i></a>
</td>
<td ><?php echo $subscription->subscription_has_items[$i]->name;?></td>
<td class="hidden-xs"><?php echo $subscription->subscription_has_items[$i]->description;?></td>
<td class="hidden-xs" align="center"><?php echo $subscription->subscription_has_items[$i]->amount;?></td>
<td class="hidden-xs"><?php echo display_money(sprintf("%01.2f",$subscription->subscription_has_items[$i]->value));?></td>
<td><?php echo display_money(sprintf("%01.2f",$subscription->subscription_has_items[$i]->amount*$subscription->subscription_has_items[$i]->value));?></td>
</tr>
<?php $sum = $sum+$subscription->subscription_has_items[$i]->amount*$subscription->subscription_has_items[$i]->value; $i++;?>
<?php endforeach;
if($items == NULL){ echo "<tr><td colspan='6'>".$this->lang->line('application_no_items_yet')."</td></tr>";}
if(substr($subscription->discount, -1) == "%"){ $discount = sprintf("%01.2f", round(($sum/100)*substr($subscription->discount, 0, -1), 2)); }
else{$discount = $subscription->discount;}
$sum = $sum-$discount;
if($subscription->tax != ""){
$tax_value = $subscription->tax;
}else{
$tax_value = $core_settings->tax;
}
if($subscription->second_tax != ""){
$second_tax_value = $subscription->second_tax;
}else{
$second_tax_value = $core_settings->second_tax;
}
$tax = sprintf("%01.2f", round(($sum/100)*$tax_value, 2));
$second_tax = sprintf("%01.2f", round(($sum/100)*$second_tax_value, 2));
$sum = sprintf("%01.2f", round($sum+$tax+$second_tax, 2));
?>
<?php if ($subscription->discount != 0): ?>
<tr>
<td colspan="5" align="right"><?php echo $this->lang->line('application_discount');?></td>
<td>- <?php echo display_money($subscription->discount);?></td>
</tr>
<?php endif ?>
<?php if ($tax_value != "0"){ ?>
<tr>
<td colspan="5" align="right"><?php echo $this->lang->line('application_tax');?> (<?php echo $tax_value?>%)</td>
<td><?php echo display_money($tax)?></td>
</tr>
<?php } ?>
<?php if ($second_tax != "0"){ ?>
<tr>
<td colspan="5" align="right"><?php echo $this->lang->line('application_second_tax');?> (<?php echo $second_tax_value?>%)</td>
<td><?php echo display_money($second_tax);?></td>
</tr>
<?php } ?>
<tr class="active">
<td colspan="5" align="right"><?php echo $this->lang->line('application_total');?></td>
<td><?php echo display_money($sum, $subscription->currency);?></td>
</tr>
</table>
</div>
</div>
<?php if($core_settings->paypal == "1" && $sum != "0.00" && $subscription->subscribed == "0"){ ?><br/>
<form action="https://www.paypal.com/cgi-bin/webscr" id="paypal_subscribe" target="_blank" method="post">
<input type="hidden" name="cmd" value="_xclick-subscriptions">
<input type="hidden" name="business" value="<?php echo $core_settings->paypal_account;?>">
<input type="hidden" name="item_name" value="<?php echo $this->lang->line('application_subscription');?> #<?php echo $subscription->reference;?>">
<input type="hidden" name="item_number" value="<?php echo $subscription->reference;?>">
<input type="hidden" name="image_url" value="<?php echo base_url()?><?php echo $core_settings->invoice_logo;?>">
<input type="hidden" name="no_shipping" value="1">
<input type="hidden" name="return" value="<?php echo base_url()?>csubscriptions/view/<?php echo $subscription->id;?>">
<input type="hidden" name="cancel_return" value="<?php echo base_url()?>csubscriptions/view/<?php echo $subscription->id;?>">
<input type="hidden" name="currency_code" value="<?php echo $core_settings->paypal_currency;?>">
<input type="hidden" name="rm" value="2">
<input type="hidden" name="a3" value="<?php echo $sum;?>">
<input type="hidden" name="p3" value="<?php echo $p3;?>">
<input type="hidden" name="t3" value="<?php echo $t3;?>">
<input type="hidden" name="src" value="1">
<input type="hidden" name="sra" value="1">
<input type="hidden" name="srt" value="<?php echo $run_time;?>">
<input type="hidden" name="no_note" value="1">
<input type="hidden" name="invoice" value="<?php echo $subscription->reference;?>">
<input type="hidden" name="usr_manage" value="1">
<input type="hidden" name="notify_url" value="<?php echo base_url()?>paypalipn" />
<input type="hidden" name="custom" value="subscription-<?php echo $sum;?>">
<!-- <input class="btn btn-primary pull-right" type="submit" value="<?php echo $this->lang->line('application_subscribe_via_paypal');?>" border="0" name="send" > -->
</form>
<?php } ?>
</div>
<div class="row">
<div class="col-xs-12 col-sm-12">
<div class="table-head"><?php echo $this->lang->line('application_subscription');?> <?php echo $this->lang->line('application_invoices');?></div>
<div class="table-div">
<table class="data table" id="invoices" rel="<?php echo base_url()?>" cellspacing="0" cellpadding="0">
<thead>
<th class="hidden-xs" width="70px"><?php echo $this->lang->line('application_invoice_id');?></th>
<th class="hidden-xs"><?php echo $this->lang->line('application_client');?></th>
<th><?php echo $this->lang->line('application_issue_date');?></th>
<th><?php echo $this->lang->line('application_due_date');?></th>
<th><?php echo $this->lang->line('application_status');?></th>
<th><?php echo $this->lang->line('application_action');?></th>
</thead>
<?php foreach ($subscription->invoices as $value):?>
<tr id="<?php echo $value->id;?>" >
<td class="hidden-xs"><?php echo $core_settings->invoice_prefix;?><?php echo $value->reference;?></td>
<td class="hidden-xs"><span class="label label-info"><?php if(!isset($value->company->name)){echo $this->lang->line('application_no_client_assigned'); }else{ echo $value->company->name; }?></span></td>
<td><span><?php $unix = human_to_unix($value->issue_date.' 00:00'); echo date($core_settings->date_format, $unix);?></span></td>
<td><span class="label <?php if($value->status == "Paid"){echo 'label-success';} if($value->due_date <= date('Y-m-d') && $value->status != "Paid"){ echo 'label-important tt" title="'.$this->lang->line('application_overdue'); } ?>"><?php $unix = human_to_unix($value->due_date.' 00:00'); echo date($core_settings->date_format, $unix);?></span></td>
<td><span class="label <?php $unix = human_to_unix($value->sent_date.' 00:00'); if($value->status == "Paid"){echo 'label-success';}elseif($value->status == "Sent"){ echo 'label-warning tt" title="'.date($core_settings->date_format, $unix);} ?>"><?php echo $this->lang->line('application_'.$value->status);?></span></td>
<td class="option " width="10%">
<button type="button" class="btn-option btn-xs po" data-toggle="popover" data-placement="left" data-content="<a class='btn btn-danger po-delete ajax-silent' href='<?php echo base_url()?>invoices/delete/<?php echo $value->id;?>'><?php echo $this->lang->line('application_yes_im_sure');?></a> <button class='btn po-close'><?php echo $this->lang->line('application_no');?></button> <input type='hidden' name='td-id' class='id' value='<?php echo $value->id;?>'>" data-original-title="<b><?php echo $this->lang->line('application_really_delete');?></b>"><i class="fa fa-times"></i></button>
<a href="<?php echo base_url()?>invoices/update/<?php echo $value->id;?>" class="btn-option" data-toggle="mainmodal"><i class="fa fa-cog"></i></a>
</td>
</tr>
<?php endforeach;?>
</table>
</div>
</div>
</div>