-
Notifications
You must be signed in to change notification settings - Fork 2
/
Display.php
4099 lines (3606 loc) · 199 KB
/
Display.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
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
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
/*
Created by TwinCitiesTech.com
(website: twincitiestech.com email : support@twincitiestech.com)
Modified by S H Mohanjith
(website: mohanjith.com email : support@mohanjith.com)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 3 of the License, with the
exception of the JQuery JavaScript framework which is released
under it's own license. You may view the details of that license in
the prototype.js file.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
function web_invoice_default($message='')
{
global $wpdb;
//Make sure tables exist
// The error takes precedence over others being that nothing can be done w/o tables
if(!$wpdb->query("SHOW TABLES LIKE '".Web_Invoice::tablename('main')."';") || !$wpdb->query("SHOW TABLES LIKE '".Web_Invoice::tablename('log')."';")) { $warning_message = ""; }
if(get_option("web_invoice_web_invoice_page") == '') { $warning_message .= __('Invoice page not selected. ', WEB_INVOICE_TRANS_DOMAIN); }
if(get_option("web_invoice_allowed_currencies_set", 'no') == 'no') { $warning_message .= __('Currencies not reviewed. ', WEB_INVOICE_TRANS_DOMAIN); }
if(get_option("web_invoice_payment_method") == '') { $warning_message .= __('Payment method not set. ', WEB_INVOICE_TRANS_DOMAIN); }
if(get_option("web_invoice_payment_method") == '' || get_option("web_invoice_web_invoice_page") == '') {
$warning_message .= __("Visit ", WEB_INVOICE_TRANS_DOMAIN)."<a href='admin.php?page=web_invoice_settings'>settings page</a>".__(" to configure.", WEB_INVOICE_TRANS_DOMAIN);
}
if(!$wpdb->query("SHOW TABLES LIKE '".Web_Invoice::tablename('meta')."';") || !$wpdb->query("SHOW TABLES LIKE '".Web_Invoice::tablename('main')."';") || !$wpdb->query("SHOW TABLES LIKE '".Web_Invoice::tablename('log')."';")) {
$warning_message = __("The plugin database tables are gone, deactivate and reactivate plugin to re-create them.", WEB_INVOICE_TRANS_DOMAIN);
}
if(isset($warning_message) && $warning_message) echo "<div id=\"message\" class='error' ><p>$warning_message</p></div>";
if(isset($message) && $message) echo "<div id=\"message\" class='updated fade' ><p>$message</p></div>";
$all_invoices = $wpdb->get_results("SELECT * FROM ".Web_Invoice::tablename('main')." WHERE invoice_num != '' ORDER BY id ASC");
?>
<form id="invoices-filter" action="" method="post">
<h2><?php _e('Invoice Overview', WEB_INVOICE_TRANS_DOMAIN); ?> <a class="button add-new-h2" href="admin.php?page=new_web_invoice"><?php _e('Add New', WEB_INVOICE_TRANS_DOMAIN); ?></a></h2>
<div class="tablenav clearfix">
<div class="alignleft"><select name="web_invoice_action">
<option value="-1" selected="selected"><?php _e('-- Actions --', WEB_INVOICE_TRANS_DOMAIN); ?></option>
<option value="send_invoice"><?php _e('Send Invoice(s)', WEB_INVOICE_TRANS_DOMAIN); ?></option>
<option value="send_reminder"><?php _e('Send Reminder(s)', WEB_INVOICE_TRANS_DOMAIN); ?></option>
<option value="archive_invoice"><?php _e('Archive Invoice(s)', WEB_INVOICE_TRANS_DOMAIN); ?></option>
<option value="unarchive_invoice"><?php _e('Un-Archive Invoice(s)', WEB_INVOICE_TRANS_DOMAIN); ?></option>
<option value="mark_as_sent"><?php _e('Mark as Sent', WEB_INVOICE_TRANS_DOMAIN); ?></option>
<option value="mark_as_paid"><?php _e('Mark as Paid', WEB_INVOICE_TRANS_DOMAIN); ?></option>
<option value="delete_invoice"><?php _e('Delete', WEB_INVOICE_TRANS_DOMAIN); ?></option>
</select> <input type="submit" value="Apply"
class="button-secondary action" /></div>
<div class="alignright">
<ul class="subsubsub" style="margin: 0;">
<li><?php _e('Filter:', WEB_INVOICE_TRANS_DOMAIN); ?></li>
<li><a href='#' class="" id=""><?php _e('All Invoices', WEB_INVOICE_TRANS_DOMAIN); ?></a>
|</li>
<li><a href='#' class="paid" id=""><?php _e('Paid', WEB_INVOICE_TRANS_DOMAIN); ?></a>
|</li>
<li><a href='#' class="sent" id=""><?php _e('Unpaid', WEB_INVOICE_TRANS_DOMAIN); ?></a>
|</li>
<li><?php _e('Custom: ', WEB_INVOICE_TRANS_DOMAIN); ?><input
type="text" id="FilterTextBox" class="search-input"
name="FilterTextBox" /></li>
</ul>
</div>
</div>
<br class="clear" />
<table class="widefat" id="invoice_sorter_table">
<thead>
<tr>
<th class="check-column"><input type="checkbox" id="CheckAll" /></th>
<th class="invoice_id_col"><?php _e('Invoice Id', WEB_INVOICE_TRANS_DOMAIN); ?></th>
<th><?php _e('Subject', WEB_INVOICE_TRANS_DOMAIN); ?></th>
<th><?php _e('Due date', WEB_INVOICE_TRANS_DOMAIN); ?></th>
<th><?php _e('Amount', WEB_INVOICE_TRANS_DOMAIN); ?></th>
<th><?php _e('Status', WEB_INVOICE_TRANS_DOMAIN); ?></th>
<th><?php _e('User', WEB_INVOICE_TRANS_DOMAIN); ?></th>
<th></th>
</tr>
</thead>
<tbody>
<?php
$x_counter = 0;
foreach ($all_invoices as $invoice) {
$class_settings = "";
// Stop if this is a recurring bill
if(!web_invoice_meta($invoice->invoice_num,'web_invoice_recurring_billing')) {
if (isset($_REQUEST['archived']) && $_REQUEST['archived'] != 'true' && web_invoice_meta($invoice->invoice_num,'archive_status') == 'archived') continue;
$x_counter++;
unset($class_settings);
//Basic Settings
$invoice_id = $invoice->invoice_num;
$invoice_info = new Web_Invoice_GetInfo($invoice_id);
$due_date = $invoice_info->display('due_date');
$subject = $invoice->subject;
$invoice_link = web_invoice_build_invoice_link($invoice_id);
$magic_link = preg_replace('/invoice_id/', 'generate_from', $invoice_link);
$user_id = $invoice->user_id;
//Determine if unique/custom id used
$custom_id = web_invoice_meta($invoice_id,'web_invoice_custom_invoice_id');
$display_id = ($custom_id ? $custom_id : $invoice_id);
// Determine Currency
$currency_code = web_invoice_determine_currency($invoice_id);
$show_money = sprintf(web_invoice_currency_symbol_format($currency_code), web_invoice_currency_format($invoice->amount, $currency_code));
// Determine What to Call Recipient
$profileuser = get_userdata($user_id);
$first_name = (isset($profileuser->first_name))?$profileuser->first_name:'';
$last_name = (isset($profileuser->last_name))?$profileuser->last_name:'';
$user_nicename = $profileuser->user_nicename;
if(empty($first_name) || empty($last_name)) $call_me_this = $user_nicename; else $call_me_this = $first_name . " " . $last_name;
$class_settings = "";
// Color coding
if(web_invoice_paid_status($invoice_id)) $class_settings .= " alternate ";
if(web_invoice_meta($invoice_id,'archive_status') == 'archived') $class_settings .= " web_invoice_archived ";
// Days Since Sent
if(web_invoice_paid_status($invoice_id)) {
$days_since = "<span style='display:none;'>-1</span>".__(' Paid', WEB_INVOICE_TRANS_DOMAIN);
} else {
if(web_invoice_meta($invoice_id,'sent_date')) {
$date1 = web_invoice_meta($invoice_id,'sent_date');
$date2 = date("Y-m-d", time());
$difference = abs(strtotime($date2) - strtotime($date1));
$days = round(((($difference/60)/60)/24), 0);
if($days == 0) { $days_since = "<span style='display:none;'>$days</span>".__('Sent Today. ', WEB_INVOICE_TRANS_DOMAIN); }
elseif($days == 1) { $days_since = "<span style='display:none;'>$days</span>".__('Sent Yesterday. ', WEB_INVOICE_TRANS_DOMAIN); }
elseif($days > 1) { $days_since = "<span style='display:none;'>$days</span>".sprintf(__('Sent %s days ago. ', WEB_INVOICE_TRANS_DOMAIN),$days); }
} else {
$days_since ="<span style='display:none;'>999</span>".__('Not Sent', WEB_INVOICE_TRANS_DOMAIN); }
}
$output_row = "<tr class='$class_settings'>\n";
$output_row .= " <th class='check-column'><input type='checkbox' name='multiple_invoices[]' value='$invoice_id'/></th>\n";
$output_row .= " <td><a href='admin.php?page=new_web_invoice&web_invoice_action=doInvoice&invoice_id=$invoice_id'>$display_id</a></td>\n";
$output_row .= " <td><a href='admin.php?page=new_web_invoice&web_invoice_action=doInvoice&invoice_id=$invoice_id'>$subject</a></td>\n";
$output_row .= " <td>$due_date</td>\n";
$output_row .= " <td>$show_money</td>\n";
$output_row .= " <td>$days_since</td>\n";
$output_row .= " <td> <a href='user-edit.php?user_id=$user_id'>$call_me_this</a></td>\n";
$output_row .= " <td><a href='$invoice_link'>".__('View Web Invoice', WEB_INVOICE_TRANS_DOMAIN)."</a>";
if (get_option('web_invoice_self_generate_from_template') == 'yes') {
$output_row .= " | <a href='$magic_link' title='".__('Copy this link and add to a post/page/widget to allow unprivileged users create invoices for self.', WEB_INVOICE_TRANS_DOMAIN)."'".
">".__('Self service template', WEB_INVOICE_TRANS_DOMAIN)."</a>";
}
$output_row .= " </td>\n";
$output_row .= "</tr>";
echo $output_row;
} /* Recurring Billing Stop */
}
if($x_counter == 0) {
// No result
?>
<tr>
<td colspan="6" align="center">
<div style="padding: 20px;"><?php _e('You have not created any invoices yet, ', WEB_INVOICE_TRANS_DOMAIN); ?><a
href="admin.php?page=new_web_invoice"><?php _e('create one now.', WEB_INVOICE_TRANS_DOMAIN); ?></a></div>
</td>
</tr>
<?php
}
?>
</tbody>
</table>
<?php if($wpdb->query("SELECT meta_value FROM `".Web_Invoice::tablename('meta')."` WHERE meta_value = 'archived'")) { ?><a
href="admin.php?page=web-invoice/web-invoice.php&archived=true" class="<?php print ($_REQUEST['archived'] == 'true')?'expanded':'collapsed';?>" id="web_invoice_show_archived" ><?php _e('Show / Hide Archived', WEB_INVOICE_TRANS_DOMAIN); ?></a><?php }?>
</form>
<?php
// web_invoice_options_manageInvoice();
if(web_invoice_is_not_merchant()) web_invoice_cc_setup(false);
}
function web_invoice_user_default($message='')
{
global $wpdb, $current_user;
//Make sure tables exist
// The error takes precedence over others being that nothing can be done w/o tables
if(!$wpdb->query("SHOW TABLES LIKE '".Web_Invoice::tablename('main')."';") || !$wpdb->query("SHOW TABLES LIKE '".Web_Invoice::tablename('log')."';")) { $warning_message = ""; }
if($warning_message) echo "<div id=\"message\" class='error' ><p>$warning_message</p></div>";
if($message) echo "<div id=\"message\" class='updated fade' ><p>$message</p></div>";
$all_invoices = $wpdb->get_results("SELECT * FROM ".Web_Invoice::tablename('main')." WHERE invoice_num != '' AND user_id = {$current_user->ID} ORDER BY id ASC");
?>
<form id="invoices-filter" action="" method="post">
<h2><?php _e('Invoices', WEB_INVOICE_TRANS_DOMAIN); ?></h2>
<div class="tablenav clearfix">
<div class="alignleft"></div>
<div class="alignright">
<ul class="subsubsub" style="margin: 0;">
<li><?php _e('Filter:', WEB_INVOICE_TRANS_DOMAIN); ?></li>
<li><a href='#' class="" id=""><?php _e('All Invoices', WEB_INVOICE_TRANS_DOMAIN); ?></a>
|</li>
<li><a href='#' class="paid" id=""><?php _e('Paid', WEB_INVOICE_TRANS_DOMAIN); ?></a>
|</li>
<li><a href='#' class="sent" id=""><?php _e('Unpaid', WEB_INVOICE_TRANS_DOMAIN); ?></a>
|</li>
<li><?php _e('Custom: ', WEB_INVOICE_TRANS_DOMAIN); ?><input
type="text" id="FilterTextBox" class="search-input"
name="FilterTextBox" /></li>
</ul>
</div>
</div>
<br class="clear" />
<table class="widefat" id="invoice_sorter_table">
<thead>
<tr>
<th></th>
<th class="invoice_id_col"><?php _e('Invoice Id', WEB_INVOICE_TRANS_DOMAIN); ?></th>
<th><?php _e('Subject', WEB_INVOICE_TRANS_DOMAIN); ?></th>
<th><?php _e('Due date', WEB_INVOICE_TRANS_DOMAIN); ?></th>
<th><?php _e('Amount', WEB_INVOICE_TRANS_DOMAIN); ?></th>
<th><?php _e('Status', WEB_INVOICE_TRANS_DOMAIN); ?></th>
<th></th>
</tr>
</thead>
<tbody>
<?php
$x_counter = 0;
foreach ($all_invoices as $invoice) {
// Stop if this is a recurring bill
//if(!web_invoice_meta($invoice->invoice_num,'web_invoice_recurring_billing')) {
if ($_REQUEST['archived'] != 'true' && web_invoice_meta($invoice->invoice_num,'archive_status') == 'archived') continue;
$x_counter++;
unset($class_settings);
//Basic Settings
$invoice_id = $invoice->invoice_num;
$invoice_info = new Web_Invoice_GetInfo($invoice_id);
$due_date = $invoice_info->display('due_date');
$subject = $invoice->subject;
$invoice_link = web_invoice_build_invoice_link($invoice_id);
$user_id = $invoice->user_id;
//Determine if unique/custom id used
$custom_id = web_invoice_meta($invoice_id,'web_invoice_custom_invoice_id');
$display_id = ($custom_id ? $custom_id : $invoice_id);
// Determine Currency
$currency_code = web_invoice_determine_currency($invoice_id);
$show_money = sprintf(web_invoice_currency_symbol_format($currency_code), web_invoice_currency_format($invoice->amount, $currency_code));
// Determine What to Call Recipient
$profileuser = get_userdata($user_id);
$first_name = $profileuser->first_name;
$last_name = $profileuser->last_name;
$user_nicename = $profileuser->user_nicename;
if(empty($first_name) || empty($last_name)) $call_me_this = $user_nicename; else $call_me_this = $first_name . " " . $last_name;
// Color coding
if(web_invoice_paid_status($invoice_id)) $class_settings .= " alternate ";
if(web_invoice_meta($invoice_id,'archive_status') == 'archived') $class_settings .= " web_invoice_archived ";
//Days since sent
// Days Since Sent
if(web_invoice_paid_status($invoice_id)) {
$days_since = "<span style='display:none;'>-1</span>".__(' Paid', WEB_INVOICE_TRANS_DOMAIN); }
else {
if(web_invoice_meta($invoice_id,'sent_date')) {
$date1 = web_invoice_meta($invoice_id,'sent_date');
$date2 = date("Y-m-d", time());
$difference = abs(strtotime($date2) - strtotime($date1));
$days = round(((($difference/60)/60)/24), 0);
if($days == 0) { $days_since = "<span style='display:none;'>$days</span>".__('Sent Today. ', WEB_INVOICE_TRANS_DOMAIN); }
elseif($days == 1) { $days_since = "<span style='display:none;'>$days</span>".__('Sent Yesterday. ', WEB_INVOICE_TRANS_DOMAIN); }
elseif($days > 1) { $days_since = "<span style='display:none;'>$days</span>".sprintf(__('Sent %s days ago. ', WEB_INVOICE_TRANS_DOMAIN),$days); }
}
else {
$days_since ="<span style='display:none;'>999</span>".__('Not Sent', WEB_INVOICE_TRANS_DOMAIN); }
}
if (web_invoice_meta($invoice->invoice_num,'web_invoice_recurring_billing')) {
$subject .= ' (Recurring)';
}
$output_row = "<tr class='$class_settings'>\n";
$output_row .= " <th class='check-column'><input type='checkbox' class='hidden-check' name='multiple_invoices[]' value='$invoice_id'/></th>\n";
$output_row .= " <td>$display_id</td>\n";
$output_row .= " <td>$subject</td>\n";
$output_row .= " <td>$due_date</td>\n";
$output_row .= " <td>$show_money</td>\n";
$output_row .= " <td>$days_since</td>\n";
$output_row .= " <td><a href='$invoice_link'>".__('View Web Invoice', WEB_INVOICE_TRANS_DOMAIN)."</a></td>\n";
$output_row .= "</tr>";
echo $output_row;
//} /* Recurring Billing Stop */
}
if($x_counter == 0) {
// No result
?>
<tr>
<td colspan="6" align="center">
<div style="padding: 20px;"><?php _e('You do not have any invoices yet', WEB_INVOICE_TRANS_DOMAIN); ?></div>
</td>
</tr>
<?php
}
?>
</tbody>
</table>
<?php if($wpdb->query("SELECT meta_value FROM `".Web_Invoice::tablename('meta')."` WHERE meta_value = 'archived'")) { ?><a
href="users.php?page=user_invoice_overview&archived=true" class="<?php print ($_REQUEST['archived'] == 'true')?'expanded':'collapsed';?>" id="web_invoice_show_archived"><?php _e('Show / Hide Archived', WEB_INVOICE_TRANS_DOMAIN); ?></a><?php }?>
</form>
<?php
// web_invoice_options_manageInvoice();
if(web_invoice_is_not_merchant()) web_invoice_cc_setup(false);
}
function web_invoice_recurring_overview($message='')
{
global $wpdb;
// Make sure tables exist
// The error takes precedence over others being that nothing can be done w/o tables
if(!$wpdb->query("SHOW TABLES LIKE '".Web_Invoice::tablename('main')."';") || !$wpdb->query("SHOW TABLES LIKE '".Web_Invoice::tablename('log')."';")) { $warning_message = ""; }
if(isset($warning_message) && $warning_message) echo "<div id='message' class='error' ><p>$warning_message</p></div>";
if(isset($message) && $message) echo "<div id=\"message\" class='updated fade' ><p>$message</p></div>";
$all_invoices = $wpdb->get_results("SELECT * FROM ".Web_Invoice::tablename('main')." WHERE invoice_num != '' ORDER BY id ASC");
?>
<form id="invoices-filter" action="" method="post"><input type="hidden"
name="web_invoice_recurring_billing" value="true" />
<h2><?php _e('Recurring Billing Overview', WEB_INVOICE_TRANS_DOMAIN); ?> <a class="button add-new-h2" href="admin.php?page=new_web_invoice"><?php _e('Add New', WEB_INVOICE_TRANS_DOMAIN); ?></a></h2>
<?php if(web_invoice_is_not_merchant() && (get_option('web_invoice_moneybookers_merchant') == 'False')) { ?>
<div class="web_invoice_rounded_box">
<p><?php printf(__('You need a %4$s account with Merchant status, %7$s Business account, %5$s account, %6$s account or a credit card processing account to use recurring billing. You may get an ARB (Automated Recurring Billing) account from %1$s (800-546-1997), %2$s (888-845-9457) or %3$s (866-400-9706).', WEB_INVOICE_TRANS_DOMAIN),
'<a href="http://keti.ws/37281">MerchantPlus</a>', '<a href="http://keti.ws/37282">MerchantExpress.com</a>',
'<a href="http://keti.ws/36282">MerchantWarehouse</a>',
'<a href="http://keti.ws/27481" alt="moneybookers.com">Moneybookers</a>',
'<a href="https://www.paypal.com/us/mrb/pal=TW8P6LGF47FM4">PayPal Business</a>',
'<a href="https://www.paypal.com/us/mrb/pal=TW8P6LGF47FM4">PayPal Payflow Pro</a>',
'<a href="http://keti.ws/36283" alt="alertpay.com">AlertPay</a>'); ?></p>
<p><?php _e('Once you have an account, enter in your username and transaction key into the ', WEB_INVOICE_TRANS_DOMAIN); ?><a
href="admin.php?page=web_invoice_settings"><?php _e('settings page', WEB_INVOICE_TRANS_DOMAIN); ?></a>.</p>
</div>
<?php } ?>
<div class="tablenav clearfix">
<div class="alignleft"><select name="web_invoice_action">
<option value="-1" selected="selected"><?php _e('-- Actions --', WEB_INVOICE_TRANS_DOMAIN); ?></option>
<option value="send_invoice"><?php _e('Send Invoice(s)', WEB_INVOICE_TRANS_DOMAIN); ?></option>
<option value="send_reminder"><?php _e('Send Reminder(s)', WEB_INVOICE_TRANS_DOMAIN); ?></option>
<option value="mark_as_paid"><?php _e('Mark as Paid', WEB_INVOICE_TRANS_DOMAIN); ?></option>
<option value="archive_invoice"><?php _e('Archive Invoice(s)', WEB_INVOICE_TRANS_DOMAIN); ?></option>
<option value="unarchive_invoice"><?php _e('Un-Archive Invoice(s)', WEB_INVOICE_TRANS_DOMAIN); ?></option>
<option value="delete_invoice"
onClick="if(confirm('<?php _e('If you delete a recurring invoice, the subscription will be cancelled.', WEB_INVOICE_TRANS_DOMAIN); ?>')) {return true;} return false;"><?php _e('Delete', WEB_INVOICE_TRANS_DOMAIN); ?></option>
</select> <input type="submit"
value="<?php _e('Apply', WEB_INVOICE_TRANS_DOMAIN); ?>"
class="button-secondary action" /></div>
<div class="alignright">
<ul class="subsubsub" style="margin: 0;">
<li><?php _e('Filter: ', WEB_INVOICE_TRANS_DOMAIN); ?><input
type="text" id="FilterTextBox" class="search-input"
name="FilterTextBox" /></li>
</ul>
</div>
</div>
<br class="clear" />
<table class="widefat" id="invoice_sorter_table">
<thead>
<tr>
<th class="check-column"><input type="checkbox" id="CheckAll" /></th>
<th class="invoice_id_col"><?php _e('Invoice Id', WEB_INVOICE_TRANS_DOMAIN); ?></th>
<th><?php _e('Subject', WEB_INVOICE_TRANS_DOMAIN); ?></th>
<th><?php _e('Next Due date', WEB_INVOICE_TRANS_DOMAIN); ?></th>
<th><?php _e('Amount', WEB_INVOICE_TRANS_DOMAIN); ?></th>
<th><?php _e('Status', WEB_INVOICE_TRANS_DOMAIN); ?></th>
<th><?php _e('User', WEB_INVOICE_TRANS_DOMAIN); ?></th>
<th> </th>
</tr>
</thead>
<tbody>
<?php
$web_invoice_payment_link = get_option("web_invoice_payment_link");
if(!empty($web_invoice_payment_link)) { if(strpos('?',$web_invoice_payment_link)) { $web_invoice_payment_link = $web_invoice_payment_link . "&";} else {$web_invoice_payment_link = $web_invoice_payment_link . "?";} }
$x_counter = 0;
foreach ($all_invoices as $invoice) {
if(web_invoice_meta($invoice->invoice_num,'web_invoice_recurring_billing')) {
if ((!isset($_REQUEST['archived']) || $_REQUEST['archived'] != 'true') && web_invoice_meta($invoice->invoice_num,'archive_status') == 'archived') continue;
$x_counter++;
unset($class_settings);
//Basic Settings
$invoice_id = $invoice->invoice_num;
$invoice_info = new Web_Invoice_GetInfo($invoice_id);
$due_date = $invoice_info->display('nextDate');
if(web_invoice_meta($invoice_id,'web_invoice_custom_invoice_id')) $custom_id = web_invoice_meta($invoice_id,'web_invoice_custom_invoice_id'); else $custom_id = $invoice_id;
$subject = $invoice->subject;
$invoice_link = web_invoice_build_invoice_link($invoice_id);
$magic_link = preg_replace('/invoice_id/', 'generate_from', $invoice_link);
$user_id = $invoice->user_id;
// Determine Currency
$currency_code = web_invoice_determine_currency($invoice_id);
$show_money = sprintf(web_invoice_currency_symbol_format($currency_code), web_invoice_currency_format($invoice->amount, $currency_code));
// Determine What to Call Recipient
$profileuser = get_userdata($user_id);
$first_name = $profileuser->first_name;
$last_name = $profileuser->last_name;
$user_nicename = $profileuser->user_nicename;
if(empty($first_name) || empty($last_name)) $call_me_this = $user_nicename; else $call_me_this = $first_name . " " . $last_name;
$class_settings = "";
// Color coding
if(web_invoice_paid_status($invoice_id)) $class_settings .= " alternate ";
if(web_invoice_meta($invoice_id,'archive_status') == 'archived') $class_settings .= " web_invoice_archived ";
//Days since sent
// Days Since Sent
if(web_invoice_paid_status($invoice_id) == 'cancelled') {
$days_since = "<span style='display:none;'>-1</span>".__(' Cancelled', WEB_INVOICE_TRANS_DOMAIN);
} else if(web_invoice_paid_status($invoice_id)) {
$days_since = "<span style='display:none;'>-2</span>".__(' Paid', WEB_INVOICE_TRANS_DOMAIN);
} else {
if(web_invoice_meta($invoice_id,'sent_date')) {
$date1 = web_invoice_meta($invoice_id,'sent_date');
$date2 = date("Y-m-d", time());
$difference = abs(strtotime($date2) - strtotime($date1));
$days = round(((($difference/60)/60)/24), 0);
if($days == 0) { $days_since = "<span style='display:none;'>$days</span>".__('Sent Today. ', WEB_INVOICE_TRANS_DOMAIN); }
elseif($days == 1) { $days_since = "<span style='display:none;'>$days</span>".__('Sent Yesterday. ', WEB_INVOICE_TRANS_DOMAIN); }
elseif($days > 1) { $days_since = "<span style='display:none;'>$days</span>".sprintf(__('Sent %s days ago. ', WEB_INVOICE_TRANS_DOMAIN), $days); }
}
else {
$days_since ="<span style='display:none;'>999</span>".__('Not Sent', WEB_INVOICE_TRANS_DOMAIN); }
}
if(web_invoice_recurring_started($invoice_id)) $days_since = "<span style='display:none;'>-1</span>".__('Active Recurring', WEB_INVOICE_TRANS_DOMAIN);
$output_row = "<tr class='$class_settings'>\n";
$output_row .= " <th class='check-column'><input type='checkbox' name='multiple_invoices[]' value='$invoice_id'/></th>\n";
$output_row .= " <td><a href='admin.php?page=new_web_invoice&web_invoice_action=doInvoice&invoice_id=$invoice_id'>$custom_id</a></td>\n";
$output_row .= " <td><a href='admin.php?page=new_web_invoice&web_invoice_action=doInvoice&invoice_id=$invoice_id'>$subject</a></td>\n";
$output_row .= " <td>$due_date</td>\n";
$output_row .= " <td>$show_money</td>\n";
$output_row .= " <td>$days_since</td>\n";
$output_row .= " <td> <a href='user-edit.php?user_id=$user_id'>$call_me_this</a></td>\n";
$output_row .= " <td><a href='$invoice_link'>".__('View Web Invoice', WEB_INVOICE_TRANS_DOMAIN)."</a>";
if (get_option('web_invoice_self_generate_from_template') == 'yes') {
$output_row .= " | <a href='$magic_link' title='".__('Copy this link and add to a post/page/widget to allow unprivileged users create invoices for self.', WEB_INVOICE_TRANS_DOMAIN)."'".
">".__('Self service template', WEB_INVOICE_TRANS_DOMAIN)."</a>";
}
$output_row .= " </td>\n";
$output_row .= "</tr>";
echo $output_row;
} /* Recurring Billing */
}
if($x_counter == 0) {
// No result
?>
<tr>
<td colspan="6" align="center">
<div style="padding: 20px;"><?php _e('You have not created any recurring invoices yet, ', WEB_INVOICE_TRANS_DOMAIN); ?><a
href="admin.php?page=new_web_invoice"><?php _e('create one now.', WEB_INVOICE_TRANS_DOMAIN); ?></a></div>
</td>
</tr>
<?php
}
?>
</tbody>
</table>
<?php if($wpdb->query(
"SELECT meta_value FROM `".Web_Invoice::tablename('meta')."` WHERE meta_value = 'archived' ".
"AND invoice_id IN (SELECT invoice_id FROM `".Web_Invoice::tablename('meta')."` WHERE meta_key = 'web_invoice_recurring_billing')")) { ?><a
href="admin.php?page=web_invoice_recurring_billing&archived=true" class="<?php print ($_REQUEST['archived'] == 'true')?'expanded':'collapsed';?>" id="web_invoice_show_archived"><?php _e('Show / Hide Archived', WEB_INVOICE_TRANS_DOMAIN); ?></a><?php }?>
</form>
<?php
// web_invoice_options_manageInvoice();
if(web_invoice_is_not_merchant()) web_invoice_cc_setup(false);
}
function web_invoice_saved_preview($invoice_id)
{
?>
<h2><?php _e('Save and Preview', WEB_INVOICE_TRANS_DOMAIN); ?></h2>
<p><?php _e('This is what your invoice will appear like in the email message. The recipient will see the itemized list after following their link to your website.', WEB_INVOICE_TRANS_DOMAIN); ?></p>
<div id="invoice_preview"><?php echo web_invoice_show_invoice($invoice_id); ?>
</div>
<div class="invoice_horizontal_buttons">
<form method="post" action="admin.php?page=web-invoice/web-invoice.php">
<input type="hidden" value="<?php echo $invoice_id; ?>"
name="invoice_id" /> <input type="hidden" value="doInvoice"
name="web_invoice_action" /> <input type="submit"
value="Continue Editing" name="doInvoice" class="button-secondary" /></form>
<form method="post" action="admin.php?page=web-invoice/web-invoice.php">
<input type="hidden" value="<?php echo $invoice_id; ?>"
name="invoice_id" /> <input type="hidden" value="send_now"
name="web_invoice_action"> <input type="submit" value="Email To Client"
class="button-secondary" /></form>
<form method="post" action="admin.php?page=web-invoice/web-invoice.php">
<input type="hidden" value="<?php echo $invoice_id; ?>"
name="invoice_id" /> <input type="hidden" value="save_not_send"
name="web_invoice_action" /> <input type="submit"
value="Save for Later" name="save" class="button-secondary" /></form>
</div>
<?php _e('Do not use the back button or you could have duplicates.', WEB_INVOICE_TRANS_DOMAIN);
}
function web_invoice_options_manageInvoice($invoice_id = '',$message='')
{
global $wpdb;
//Load Defaults
$currency = get_option("web_invoice_default_currency_code");
if(!empty($_REQUEST['user_id'])) $user_id = $_REQUEST['user_id'];
// Need to unset these values
if(empty($_POST['copy_from_template'])) {unset($_POST['copy_from_template']);}
if($invoice_id == '') {unset($invoice_id);}
$web_invoice_tax_names = unserialize(get_option('web_invoice_tax_name'));
$web_invoice_date_day = date('d');
$web_invoice_date_month = date('m');
$web_invoice_date_year = date('Y');
// New Invoice From Template
if(isset($_POST['copy_from_template']) && $_POST['user_id']) {
$template_invoice_id = $_POST['copy_from_template'];
$invoice_info = $wpdb->get_row("SELECT * FROM ".Web_Invoice::tablename('main')." WHERE invoice_num = '".$template_invoice_id."'");
$user_id = $_REQUEST['user_id'];
$amount = $invoice_info->amount;
$subject = $invoice_info->subject;
$description = $invoice_info->description;
$itemized = $invoice_info->itemized;
$web_invoice_date_day = date('d', strtotime($invoice_info->invoice_date));
$web_invoice_date_month = date('m', strtotime($invoice_info->invoice_date));
$web_invoice_date_year = date('Y', strtotime($invoice_info->invoice_date));
$profileuser = get_user_to_edit($_POST['user_id']);
$itemized_array = unserialize(urldecode($itemized));
$web_invoice_tax = unserialize(web_invoice_meta($template_invoice_id,'tax_value'));
$web_invoice_currency_code = web_invoice_meta($template_invoice_id,'web_invoice_currency_code');
$web_invoice_due_date_day = web_invoice_meta($template_invoice_id,'web_invoice_due_date_day');
$web_invoice_due_date_month = web_invoice_meta($template_invoice_id,'web_invoice_due_date_month');
$web_invoice_due_date_year = web_invoice_meta($template_invoice_id,'web_invoice_due_date_year');
$web_invoice_subscription_name = web_invoice_meta($template_invoice_id,'web_invoice_subscription_name');
$web_invoice_subscription_unit = web_invoice_meta($template_invoice_id,'web_invoice_subscription_unit');
$web_invoice_subscription_length = web_invoice_meta($template_invoice_id,'web_invoice_subscription_length');
$web_invoice_subscription_start_month = web_invoice_meta($template_invoice_id,'web_invoice_subscription_start_month');
$web_invoice_subscription_start_day = web_invoice_meta($template_invoice_id,'web_invoice_subscription_start_day');
$web_invoice_subscription_start_year = web_invoice_meta($template_invoice_id,'web_invoice_subscription_start_year');
$web_invoice_subscription_total_occurances = web_invoice_meta($template_invoice_id,'web_invoice_subscription_total_occurances');
$web_invoice_recurring_billing = web_invoice_meta($template_invoice_id,'web_invoice_recurring_billing');
$web_invoice_payment_methods = web_invoice_meta($template_invoice_id,'web_invoice_payment_methods');
}
// Invoice Exists, we are modifying it
if(isset($invoice_id)) {
$invoice_info = $wpdb->get_row("SELECT * FROM ".Web_Invoice::tablename('main')." WHERE invoice_num = '".$invoice_id."'");
$user_id = $invoice_info->user_id;
$amount = $invoice_info->amount;
$subject = $invoice_info->subject;
$description = $invoice_info->description;
$itemized = $invoice_info->itemized;
$web_invoice_date_day = date('d', strtotime($invoice_info->invoice_date));
$web_invoice_date_month = date('m', strtotime($invoice_info->invoice_date));
$web_invoice_date_year = date('Y', strtotime($invoice_info->invoice_date));
$profileuser = get_userdata($invoice_info->user_id);
$itemized_array = unserialize(urldecode($itemized));
$web_invoice_tax = unserialize(web_invoice_meta($invoice_id,'tax_value'));
$web_invoice_custom_invoice_id = web_invoice_meta($invoice_id,'web_invoice_custom_invoice_id');
$web_invoice_due_date_day = web_invoice_meta($invoice_id,'web_invoice_due_date_day');
$web_invoice_due_date_month = web_invoice_meta($invoice_id,'web_invoice_due_date_month');
$web_invoice_due_date_year = web_invoice_meta($invoice_id,'web_invoice_due_date_year');
$web_invoice_currency_code = web_invoice_meta($invoice_id,'web_invoice_currency_code');
$web_invoice_recurring_billing = web_invoice_meta($invoice_id,'web_invoice_recurring_billing');
$web_invoice_subscription_name = web_invoice_meta($invoice_id,'web_invoice_subscription_name');
$web_invoice_subscription_unit = web_invoice_meta($invoice_id,'web_invoice_subscription_unit');
$web_invoice_subscription_length = web_invoice_meta($invoice_id,'web_invoice_subscription_length');
$web_invoice_subscription_start_month = web_invoice_meta($invoice_id,'web_invoice_subscription_start_month');
$web_invoice_subscription_start_day = web_invoice_meta($invoice_id,'web_invoice_subscription_start_day');
$web_invoice_subscription_start_year = web_invoice_meta($invoice_id,'web_invoice_subscription_start_year');
$web_invoice_subscription_total_occurances = web_invoice_meta($invoice_id,'web_invoice_subscription_total_occurances');
$web_invoice_payment_methods = web_invoice_meta($invoice_id,'web_invoice_payment_methods');
}
if (empty($web_invoice_payment_methods)) {
$web_invoice_payment_methods = get_option('web_invoice_payment_method');
}
//Whether recurring bill will start when client pays, or a date is specified
if($web_invoice_subscription_start_month && $web_invoice_subscription_start_year && $web_invoice_subscription_start_day) $recurring_auto_start = true; else $recurring_auto_start = false;
// Brand New Invoice
if(!isset($invoice_id) && isset($_REQUEST['user_id'])) {
$profileuser = get_user_to_edit($_REQUEST['user_id']);
}
// Load Userdata
$user_email = $profileuser->user_email;
$first_name = $profileuser->first_name;
$last_name = $profileuser->last_name;
$company_name = $profileuser->company_name;
$tax_id = $profileuser->tax_id;
$streetaddress = $profileuser->streetaddress;
$city = $profileuser->city;
$state = $profileuser->state;
$zip = $profileuser->zip;
$country = $profileuser->country;
//Load Invoice Specific Settings, and override default
if(!empty($web_invoice_currency_code)) $currency = $web_invoice_currency_code;
// Crreae two blank arrays for itemized list if none is set
if (!is_array($itemized_array) || count($itemized_array) == 0) {
$itemized_array[1] = "";
$itemized_array[2] = "";
}
if(get_option("web_invoice_web_invoice_page") == '') { $warning_message .= __('Invoice page not selected. ', WEB_INVOICE_TRANS_DOMAIN); }
if(get_option("web_invoice_allowed_currencies_set", 'no') == 'no') { $warning_message .= __('Currencies not reviewed. ', WEB_INVOICE_TRANS_DOMAIN); }
if(get_option("web_invoice_payment_method") == '') { $warning_message .= __('Payment method not set. ', WEB_INVOICE_TRANS_DOMAIN); }
if(get_option("web_invoice_payment_method") == '' || get_option("web_invoice_web_invoice_page") == '') {
$warning_message .= __("Visit ", WEB_INVOICE_TRANS_DOMAIN)."<a href='admin.php?page=web_invoice_settings'>settings page</a>".__(" to configure.", WEB_INVOICE_TRANS_DOMAIN);
}
if(!$wpdb->query("SHOW TABLES LIKE '".Web_Invoice::tablename('meta')."';") || !$wpdb->query("SHOW TABLES LIKE '".Web_Invoice::tablename('main')."';") || !$wpdb->query("SHOW TABLES LIKE '".Web_Invoice::tablename('log')."';")) {
$warning_message = __("The plugin database tables are gone, deactivate and reactivate plugin to re-create them.", WEB_INVOICE_TRANS_DOMAIN);
}
if($warning_message) echo "<div id=\"message\" class='error' ><p>$warning_message</p></div>";
if($message) echo "<div id=\"message\" class='updated fade' ><p>$message</p></div>";
?>
<?php if(!isset($invoice_id)) { ?>
<h2><?php _e('New Web Invoice', WEB_INVOICE_TRANS_DOMAIN); ?></h2>
<?php web_invoice_draw_user_selection_form($user_id);
} else {
$_SESSION['last_new_invoice'] = false;
} ?>
<?php if(isset($user_id) && isset($invoice_id)) { ?>
<h2><?php _e('Manage Invoice', WEB_INVOICE_TRANS_DOMAIN); ?></h2>
<?php } ?>
<?php if(isset($invoice_id) && web_invoice_paid_status($invoice_id) || web_invoice_recurring_started($invoice_id) || web_invoice_query_log($invoice_id, 'subscription_error')) { ?>
<div class="updated web_invoice_status">
<?php if (web_invoice_paid_status($invoice_id)) { ?>
<h2><?php _e('Invoice Paid', WEB_INVOICE_TRANS_DOMAIN); ?></h2>
<?php foreach(web_invoice_query_log($invoice_id, 'paid') as $info) {
echo sprintf(__('%s on ', WEB_INVOICE_TRANS_DOMAIN), $info->value) . "<span class='web_invoice_tamp_stamp'>" . $info->time_stamp . "</span><br />";
} ?>
<?php } ?>
<?php if(web_invoice_recurring_started($invoice_id)) { ?>
<h2><?php _e('Recurring Billing Initiated', WEB_INVOICE_TRANS_DOMAIN); ?></h2>
<?php foreach(web_invoice_query_log($invoice_id, 'subscription') as $info) {
echo sprintf(__('%s on ', WEB_INVOICE_TRANS_DOMAIN), $info->value) . $info->time_stamp . "<br />";
}
} ?>
<?php
$subscription_errors = web_invoice_query_log($invoice_id, 'subscription_error');
if($subscription_errors) { ?>
<h2><?php _e('Recurring Billing Problems', WEB_INVOICE_TRANS_DOMAIN); ?></h2>
<ol>
<?php
foreach($subscription_errors as $info) {
echo "<li>" . sprintf(__('%s on ', WEB_INVOICE_TRANS_DOMAIN), $info->value). $info->time_stamp . "</li>";
} ?>
</ol>
<?php } ?>
</div>
<?php } ?>
<?php if(isset($user_id)) { ?>
<div id="poststuff" class="metabox-holder">
<form id="new_web_invoice_form" action="admin.php?page=new_web_invoice&web_invoice_action=save_and_preview" method="POST">
<input type="hidden" name="user_id"
value="<?php echo $user_id; ?>" /> <input type="hidden"
name="invoice_id"
value="<?php if(isset($invoice_id)) { echo $invoice_id; } else { echo rand(10000000, 90000000);} ?>" />
<input type="hidden" name="amount" id="total_amount"
value="<?php echo $amount; ?>" />
<div class="postbox" id="web_invoice_client_info_div">
<h3><label for="link_name"><?php _e('Client Information', WEB_INVOICE_TRANS_DOMAIN); ?></label></h3>
<div class="inside">
<table class="form-table" id="add_new_web_invoice">
<?php
if(get_option('web_invoice_business_name') == '') echo "<tr><th colspan=\"2\">".__("Your business name isn't set, go to Settings page to set it.", WEB_INVOICE_TRANS_DOMAIN)."</a></th></tr>\n"; ?>
<tr>
<th><?php _e("Email Address", WEB_INVOICE_TRANS_DOMAIN) ?></th>
<td><?php echo $user_email; ?> <a class="web_invoice_click_me"
href="user-edit.php?user_id=<?php echo $user_id; ?>#billing_info"><?php _e('Go to User Profile', WEB_INVOICE_TRANS_DOMAIN); ?></a></td>
</tr>
<tr style="height: 90px;">
<th><?php _e("Billing Information", WEB_INVOICE_TRANS_DOMAIN) ?></th>
<td>
<div id="web_invoice_edit_user_from_invoice"><span
class="web_invoice_make_editable<?php if(!$first_name) echo " web_invoice_unset"; ?>"
id="web_invoice_first_name"><?php if($first_name) echo $first_name; else echo __("Set First Name", WEB_INVOICE_TRANS_DOMAIN); ?></span>
<span
class="web_invoice_make_editable<?php if(!$last_name) echo " web_invoice_unset"; ?>"
id="web_invoice_last_name"><?php if($last_name) echo $last_name; else echo __("Set Last Name", WEB_INVOICE_TRANS_DOMAIN); ?></span><br />
<span
class="web_invoice_make_editable<?php if(!$company_name) echo " web_invoice_unset"; ?>"
id="web_invoice_company_name"><?php if($company_name) echo $company_name; else echo __("Set Company", WEB_INVOICE_TRANS_DOMAIN); ?></span><br/>
<span
class="web_invoice_make_editable<?php if(!$streetaddress) echo " web_invoice_unset"; ?>"
id="web_invoice_streetaddress"><?php if($streetaddress) echo $streetaddress; else echo __("Set Street Address", WEB_INVOICE_TRANS_DOMAIN); ?></span><br />
<span
class="web_invoice_make_editable<?php if(!$city) echo " web_invoice_unset"; ?>"
id="web_invoice_city"><?php if($city) echo $city; else echo __("Set City", WEB_INVOICE_TRANS_DOMAIN); ?></span><br/>
<span
class="web_invoice_make_editable<?php if(!$state) echo " web_invoice_unset"; ?>"
id="web_invoice_state"><?php if($state) echo $state; else echo __("Set State", WEB_INVOICE_TRANS_DOMAIN); ?></span>
<span
class="web_invoice_make_editable<?php if(!$zip) echo " web_invoice_unset"; ?>"
id="web_invoice_zip"><?php if($zip) echo $zip; else echo __("Set Zip Code", WEB_INVOICE_TRANS_DOMAIN); ?></span><br/>
<span
class="web_invoice_make_editable<?php if(!$country) echo " web_invoice_unset"; ?>"
id="web_invoice_country"><?php if($country) echo $country; else echo __("Set Country", WEB_INVOICE_TRANS_DOMAIN); ?></span><br/>
</div>
</td>
</tr>
<tr>
<th><?php _e("Tax ID", WEB_INVOICE_TRANS_DOMAIN) ?></th>
<td>
<div id="web_invoice_edit_tax_form_invoice">
<span
class="web_invoice_make_editable<?php if(!$tax_id) echo " web_invoice_unset"; ?>"
id="web_invoice_tax_id"><?php if($tax_id) echo $tax_id; else echo __("Set Tax ID", WEB_INVOICE_TRANS_DOMAIN); ?></span>
</div>
</td>
</tr>
</table>
</div>
</div>
<div class="postbox" >
<h3><label for="link_name"><?php _e("Recurring Billing", WEB_INVOICE_TRANS_DOMAIN) ?></label></h3>
<div id="web_invoice_enable_recurring_billing"
class="web_invoice_click_me"
<?php if($web_invoice_recurring_billing) { ?> style="display: none;"
<?php } ?>><?php _e("Create a recurring billing schedule for this invoice.", WEB_INVOICE_TRANS_DOMAIN) ?>
</div>
<div class="web_invoice_enable_recurring_billing"
<?php if(!$web_invoice_recurring_billing) { ?> style="display: none;"
<?php } ?>>
<table class="form-table" id="add_new_web_invoice">
<tr>
<th><a class="web_invoice_tooltip"
title="<?php _e("A name to identify this subscription by in addition to the invoice id. (ex: 'standard hosting')", WEB_INVOICE_TRANS_DOMAIN) ?>"><?php _e("Subscription Name", WEB_INVOICE_TRANS_DOMAIN) ?></a></th>
<td><?php echo web_invoice_draw_inputfield('web_invoice_subscription_name',$web_invoice_subscription_name); ?></td>
</tr>
<tr>
<th><?php _e("Start Date", WEB_INVOICE_TRANS_DOMAIN) ?></th>
<td><span style="<?php if($recurring_auto_start) { ?>display:none;<?php } ?>" class="web_invoice_timestamp"><?php _e("Start automatically as soon as the customer enters their billing information. ", WEB_INVOICE_TRANS_DOMAIN) ?><span
class="web_invoice_click_me"
onclick="jQuery('.web_invoice_timestamp').toggle();"><?php _e("Specify Start Date", WEB_INVOICE_TRANS_DOMAIN) ?></span></span>
<div style="<?php if(!$recurring_auto_start) { ?>display:none;<?php } ?>" class="web_invoice_timestamp">
<?php echo web_invoice_draw_select('web_invoice_subscription_start_month', web_invoice_month_array(), $web_invoice_subscription_start_month); ?>
<?php echo web_invoice_draw_inputfield('web_invoice_subscription_start_day', $web_invoice_subscription_start_day, ' size="2" maxlength="2" autocomplete="off" '); ?>,
<?php echo web_invoice_draw_inputfield('web_invoice_subscription_start_year', $web_invoice_subscription_start_year, ' size="4" maxlength="4" autocomplete="off" '); ?>
<span onclick="web_invoice_subscription_start_time(7);"
class="web_invoice_click_me"><?php _e("In One Week", WEB_INVOICE_TRANS_DOMAIN) ?></span>
| <span onclick="web_invoice_subscription_start_time(30);"
class="web_invoice_click_me"><?php _e("In 30 Days", WEB_INVOICE_TRANS_DOMAIN) ?></span>
| <span
onclick="jQuery('.web_invoice_timestamp').toggle();web_invoice_subscription_start_time('clear');"
class="web_invoice_click_me"><?php _e("Start automatically", WEB_INVOICE_TRANS_DOMAIN) ?></span>
</div>
</td>
</tr>
<tr>
<th><a class="web_invoice_tooltip"
title="<?php _e("This will be the number of times the client will be billed. (ex: 12)", WEB_INVOICE_TRANS_DOMAIN) ?>"><?php _e("Bill Every", WEB_INVOICE_TRANS_DOMAIN) ?></a></th>
<td><?php echo web_invoice_draw_inputfield('web_invoice_subscription_length', $web_invoice_subscription_length,' size="3" maxlength="3" autocomplete="off" '); ?>
<?php echo web_invoice_draw_select('web_invoice_subscription_unit', array("years" => __("year(s)", WEB_INVOICE_TRANS_DOMAIN), "months" => __("month(s)", WEB_INVOICE_TRANS_DOMAIN), "days"=> __("days", WEB_INVOICE_TRANS_DOMAIN)), $web_invoice_subscription_unit); ?></td>
</tr>
<tr>
<th><a class="web_invoice_tooltip"
title="<?php _e("Keep it under the maximum of 9999.", WEB_INVOICE_TRANS_DOMAIN) ?>"><?php _e("Total Billing Cycles", WEB_INVOICE_TRANS_DOMAIN) ?></a></th>
<td><?php echo web_invoice_draw_inputfield('web_invoice_subscription_total_occurances', $web_invoice_subscription_total_occurances,' size="4" maxlength="4" autocomplete="off" '); ?></td>
</tr>
<tr>
<th></th>
<td><?php _e("All <b>recurring billing</b> fields must be filled out to activate recurring billing. ", WEB_INVOICE_TRANS_DOMAIN) ?>
<?php if (web_invoice_meta($invoice_id, 'pfp_status') == 'active') { ?>
<a href="admin.php?page=new_web_invoice&web_invoice_action=doPausePfp&invoice_id=<?php print $invoice_id; ?>" class="web_invoice_click_me"><?php _e("Pause Recurring Billing", WEB_INVOICE_TRANS_DOMAIN) ?></a> |
<?php } else if (web_invoice_meta($invoice_id, 'pfp_status') == 'paused') { ?>
<a href="admin.php?page=new_web_invoice&web_invoice_action=doRestartRecurringPfp&invoice_id=<?php print $invoice_id; ?>" class="web_invoice_click_me"><?php _e("Restart Recurring Billing", WEB_INVOICE_TRANS_DOMAIN) ?></a> |
<?php } ?>
<span onclick="web_invoice_cancel_recurring()" class="web_invoice_click_me"><?php _e("Cancel Recurring Billing", WEB_INVOICE_TRANS_DOMAIN) ?></span></td>
</tr>
</table>
</div>
</div>
<div id="web_invoice_main_info" class="metabox-holder">
<div id="submitdiv" class="postbox" style="">
<h3 class="hndle"><span><?php _e("Invoice Details", WEB_INVOICE_TRANS_DOMAIN) ?></span></h3>
<div class="inside">
<table class="form-table">
<tr class="">
<th><?php _e("Subject", WEB_INVOICE_TRANS_DOMAIN) ?></th>
<td><input id="invoice_subject" class="subject" name='subject'
value='<?php echo $subject; ?>' /></td>
</tr>
<tr class="">
<th><?php _e("Description / PO", WEB_INVOICE_TRANS_DOMAIN) ?></th>
<td><textarea class="invoice_description_box" name='description'><?php echo $description; ?></textarea></td>
</tr>
<tr class="">
<th><?php _e("Itemized List", WEB_INVOICE_TRANS_DOMAIN) ?></th>
<td>
<table id="invoice_list" class="itemized_list">
<tr>
<th class="id"><?php _e("ID", WEB_INVOICE_TRANS_DOMAIN) ?></th>
<th class="name"><?php _e("Name", WEB_INVOICE_TRANS_DOMAIN) ?></th>
<th class="description"><?php _e("Description", WEB_INVOICE_TRANS_DOMAIN) ?></th>
<th class="quantity"><?php _e("Quantity", WEB_INVOICE_TRANS_DOMAIN) ?></th>
<th class="price"><?php _e("Unit Price", WEB_INVOICE_TRANS_DOMAIN) ?></th>
<th class="item_total"><?php _e("Total", WEB_INVOICE_TRANS_DOMAIN) ?></th>
</tr>
<?php
$counter = 1;
foreach($itemized_array as $itemized_item){ ?>
<tr valign="top">
<td valign="top" class="id"><?php echo $counter; ?></td>
<td valign="top" class="name"><input class="item_name"
name="itemized_list[<?php echo $counter; ?>][name]"
value="<?php echo stripslashes($itemized_item[name]); ?>" /></td>
<td valign="top" class="description"><textarea style="height: 25px;"
name="itemized_list[<?php echo $counter; ?>][description]"
class="item_description autogrow"><?php echo stripslashes($itemized_item[description]); ?></textarea></td>
<td valign="top" class="quantity"><input
value="<?php echo stripslashes($itemized_item[quantity]); ?>"
name="itemized_list[<?php echo $counter; ?>][quantity]"
id="qty_item_<?php echo $counter; ?>" class="item_quantity noautocomplete" /></td>
<td valign="top" class="price"><input
value="<?php echo stripslashes($itemized_item[price]); ?>"
name="itemized_list[<?php echo $counter; ?>][price]"
id="price_item_<?php echo $counter; ?>" class="item_price noautocomplete" /></td>
<td valign="top" class="item_total"
id="total_item_<?php echo $counter; ?>"></td>
</tr>
<?php $counter++; } ?>
</table>
</td>
</tr>
<tr class="">
<th style='vertical-align: bottom; text-align: right;'>
<p><a href="#" id="add_itemized_item"><?php _e("Add Another Item", WEB_INVOICE_TRANS_DOMAIN) ?></a><br />
<span class='web_invoice_light_text'></span></p>
</th>
<td>
<table class="itemized_list">
<tr>
<td align="right"><?php _e("Invoice Total", WEB_INVOICE_TRANS_DOMAIN) ?>:</td>
<td class="item_total"><span id='amount'></span></td>
</tr>
<tr>
<td align="right"><?php _e("Recurring Invoice Total", WEB_INVOICE_TRANS_DOMAIN) ?>:</td>
<td class="item_total"><span id='recurring_total'></span></td>
</tr>
</table>
</td>
</tr>
</table>
</div>
</div>
</div>
<div id="submitdiv" class="postbox" style="">
<h3 class="hndle"><span><?php _e("Publish", WEB_INVOICE_TRANS_DOMAIN) ?></span></h3>
<div class="inside">
<div id="minor-publishing">
<div id="misc-publishing-actions">
<table class="form-table">
<tr class="">
<th><?php _e("Invoice ID ", WEB_INVOICE_TRANS_DOMAIN) ?></th>
<td style="font-size: 1.1em; padding-top: 7px;"><input
class="web_invoice_custom_invoice_id<?php if(empty($web_invoice_custom_invoice_id)) { echo " web_invoice_hidden"; } ?>"
name="web_invoice_custom_invoice_id"
value="<?php echo $web_invoice_custom_invoice_id;?>" /> <?php if(isset($invoice_id)) { echo $invoice_id; } else { echo rand(10000000, 90000000);} ?>
<a
class="web_invoice_custom_invoice_id web_invoice_click_me <?php if(!empty($web_invoice_custom_invoice_id)) { echo " web_invoice_hidden"; } ?>"
href="#"><?php _e("Custom Invoice ID", WEB_INVOICE_TRANS_DOMAIN) ?></a>
</td>
</tr>
<?php if (is_array($web_invoice_tax) || empty($web_invoice_tax)) { ?>
<?php for ($_txc=0; $_txc<get_option('web_invoice_tax_count'); $_txc++) { ?>
<tr class="">
<th><span
class="web_invoice_make_editable<?php if(!isset($web_invoice_tax_names[$_txc])) echo " web_invoice_unset"; ?>"
id="web_invoice_tax_name_<?php print $_txc; ?>"><?php print isset($web_invoice_tax_names[$_txc])?$web_invoice_tax_names[$_txc]:sprintf(__("Set Tax %s Name", WEB_INVOICE_TRANS_DOMAIN), $_txc+1); ?></span></th>
<td style="font-size: 1.1em; padding-top: 7px;"><input
style="width: 35px;" name="web_invoice_tax[]" id="web_invoice_tax_<?php print $_txc; ?>"
value="<?php echo doubleval($web_invoice_tax[$_txc]); ?>" class="noautocomplete web_invoice_tax" />%</td>
</tr>
<?php } ?>
<?php } else { ?>
<tr class="invoice_main">
<th><?php _e("Tax", WEB_INVOICE_TRANS_DOMAIN); ?></th>
<td style="font-size: 1.1em; padding-top: 7px;"><input
style="width: 35px;" name="web_invoice_tax" id="web_invoice_tax"
value="<?php echo doubleval($web_invoice_tax); ?>" class="noautocomplete web_invoice_tax" />%</td>
</tr>
<?php } ?>
<tr class="">