-
Notifications
You must be signed in to change notification settings - Fork 2
/
invoice.php
136 lines (124 loc) · 5.48 KB
/
invoice.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
<?php
class invoice extends Admin_Controller{
public function index(){
}
public function generate_invoice($ordernumber){
$this->load->model('xend_model');
$this->load->model('email_model');
$data['order_number']= $ordernumber;
foreach($this->xend_model->get_orders_by_number($ordernumber) as $rs){
$data['address1'] = $rs->ship_address1;
$data['address2'] = $rs->ship_address2;
$data['city'] = $rs->ship_city;
$data['fullname'] = $rs->ship_lastname." ". $rs->ship_firstname;
$data['lastname'] = $rs->ship_lastname;
$data['amount'] = $rs->total;
// $data['amount'] = ($rs->currency=='dollar') ? $rs->total_dollar : $rs->total;
// $data['currency'] = $rs->currency;
$data['company'] = $rs->ship_company;
$data['phone'] = $rs->ship_phone;
$data['email'] = $rs->ship_email;
$data['waybill_no'] = $rs->waybill_no;
$data['invoice_no'] = $rs->invoice_no;
$data['shipped_on'] = $rs->shipped_on;
// $data['app_id'] = $rs->app_id;
// $data['app_url']=$rs->app_url;
$data['invoice_date'] = $rs->invoice_date;
// $data['grandtotal'] = ($rs->grandtotal == '0.00') ? $rs->total : $rs->grandtotal;
$data['grandtotal'] = $rs->total;
}
// $data['invoicenum']=$this->generate_invoice_no($data['app_id'],$data['lastname']);
$data['invoicenum']=$this->generate_invoice_no();
$data['products_orders']=$this->email_model->get_order_product($ordernumber);
$this->load->view('admin/invoice_form',$data);
}
/*START-ADD-REMITTANCE OPTION (ELAINEM) 2014-03-21*/
public function view_invoice($ordernumber){
$this->load->model('xend_model');
$this->load->model('email_model');
$data['order_number']= $ordernumber;
foreach($this->xend_model->get_orders_by_number($ordernumber) as $rs){
$data['address1']=$rs->ship_address1;
$data['address2']=$rs->ship_address2;
$data['city']=$rs->ship_city;
$data['fullname']=$rs->ship_lastname." ". $rs->ship_firstname;
$data['amount'] = ($rs->currency=='dollar') ? $rs->total_dollar : $rs->total;
$data['currency'] = $rs->currency;
$data['company']=$rs->ship_company;
$data['phone']=$rs->ship_phone;
$data['email']=$rs->ship_email;
$data['waybill_no']=$rs->waybill_no;
$data['invoice_no']=$rs->invoice_no;
$data['shipped_on']=$rs->shipped_on;
$data['app_id']=$rs->app_id;
// $data['app_url']=$rs->app_url;
$data['invoice_date']=$rs->invoice_date;
$data['checkpayeename']=$rs->checkpayeename;
$data['invoicenum']=$rs->invoice_no;
$data['grandtotal']= ($rs->grandtotal == '0.00') ? $rs->total : $rs->grandtotal;
}
$data['products_orders']=$this->email_model->get_order_product($ordernumber);
$this->load->view('admin/invoice_view',$data);
}
/*END-ADD-REMITTANCE OPTION (ELAINEM) 2014-03-21*/
public function insert_invoice(){
$this->load->model('xend_model');
$this->load->model('email_model');
$invoiceno= $this->input->post('invoiceno');
$order_num=$this->input->post('order_num');
/*START-ADD-REMITTANCE OPTION (ELAINEM) 2014-03-21*/
$chkpayeename=$this->input->post('chkpayeename');
/*END-ADD-REMITTANCE OPTION (ELAINEM) 2014-03-21*/
$invoice_date = date('Y-m-d H:i:s', strtotime($this->input->post('invoicedate')));
/*START-REV-REMITTANCE OPTION (ELAINEM) 2014-03-21*/
//$this->xend_model->update_invoice($order_num,$invoiceno,$invoice_date);
$this->xend_model->update_invoice($order_num,$invoiceno,$invoice_date,$chkpayeename);
/*END-REV-REMITTANCE OPTION (ELAINEM) 2014-03-21*/
// header("Location: ".base_url("index.php/invoice/thankyou_invoice"));
$this->thankyou_invoice();
}
public function thankyou_invoice(){
/*$this->load->model('xend_model');
$this->load->model('email_model');
$invoice= $this->input->post('invoiceno');
$order_num=$this->input->post('order_num');
$invoice_date= date('Y-m-d H:i:s', strtotime($this->input->post('invoice_date')));
$this->xend_model->update_invoice($order_num,$invoice,$invoice_date);*/
$this->load->view('admin/invoice_thankyou');
}
// public function generate_invoice_no($app_id,$lastname){
// if (function_exists('com_create_guid') === true) {
// return trim(com_create_guid(), '{}');
// }
// foreach($this->xend_model->get_totalorders_by_id($app_id) as $rs){
// $data['lastname']=strtolower($rs->ship_lastname);
// $data['totalorders']=$rs->totalorders;
// }
// if ($data['totalorders'] == 0){
// $count = 1;
// } else {
// $count = $data['totalorders'] + 1;
// }
// $invoicenum = strtolower($lastname)."-".str_pad((string)$count, 5, "0", STR_PAD_LEFT);
// //return sprintf('%04X%04X%04', mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(16384, 20479), mt_rand(32768, 49151), mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(0, 65535));
// return $invoicenum;
// }
public function generate_invoice_no(){
if (function_exists('com_create_guid') === true) {
return trim(com_create_guid(), '{}');
}
// foreach($this->xend_model->get_totalorders_by_id($app_id) as $rs){
// $data['lastname']=strtolower($rs->ship_lastname);
// $data['totalorders']=$rs->totalorders;
// }
// if ($data['totalorders'] == 0){
// $count = 1;
// } else {
// $count = $data['totalorders'] + 1;
// }
// $invoicenum = strtolower($lastname)."-".str_pad((string)$count, 5, "0", STR_PAD_LEFT);
return 'NXLIVN'.sprintf('%04X%04X%04', mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(16384, 20479), mt_rand(32768, 49151), mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(0, 65535));
// return $invoicenum;
}
}
?>