@@ -24,613 +24,613 @@ discard block |
||
24 | 24 | |
25 | 25 | class Reports extends MX_Controller { |
26 | 26 | |
27 | - function Reports() { |
|
28 | - parent::__construct(); |
|
29 | - |
|
30 | - $this->load->helper('template_inheritance'); |
|
31 | - |
|
32 | - $this->load->library('session'); |
|
33 | - $this->load->library("reports_form"); |
|
34 | - $this->load->library('astpp/form'); |
|
35 | - $this->load->model('reports_model'); |
|
36 | - $this->load->library('fpdf'); |
|
37 | - $this->load->library('pdf'); |
|
38 | - $this->fpdf = new PDF('P', 'pt'); |
|
39 | - $this->fpdf->initialize('P', 'mm', 'A4'); |
|
40 | - |
|
41 | - if ($this->session->userdata('user_login') == FALSE) |
|
42 | - redirect(base_url() . '/astpp/login'); |
|
43 | - } |
|
44 | - |
|
45 | - function customerReport() { |
|
46 | - $data['page_title'] = 'Customer CDRs Report'; |
|
47 | - $data['search_flag'] = true; |
|
48 | - $this->session->set_userdata('advance_search', 0); |
|
49 | - $data['grid_fields'] = $this->reports_form->build_report_list_for_customer(); |
|
50 | - $data["grid_buttons"] = $this->reports_form->build_grid_customer(); |
|
51 | - $data['form_search'] = $this->form->build_serach_form($this->reports_form->get_customer_cdr_form()); |
|
52 | - $this->load->view('view_cdr_customer_list', $data); |
|
53 | - } |
|
54 | - |
|
55 | - /* * **** |
|
27 | + function Reports() { |
|
28 | + parent::__construct(); |
|
29 | + |
|
30 | + $this->load->helper('template_inheritance'); |
|
31 | + |
|
32 | + $this->load->library('session'); |
|
33 | + $this->load->library("reports_form"); |
|
34 | + $this->load->library('astpp/form'); |
|
35 | + $this->load->model('reports_model'); |
|
36 | + $this->load->library('fpdf'); |
|
37 | + $this->load->library('pdf'); |
|
38 | + $this->fpdf = new PDF('P', 'pt'); |
|
39 | + $this->fpdf->initialize('P', 'mm', 'A4'); |
|
40 | + |
|
41 | + if ($this->session->userdata('user_login') == FALSE) |
|
42 | + redirect(base_url() . '/astpp/login'); |
|
43 | + } |
|
44 | + |
|
45 | + function customerReport() { |
|
46 | + $data['page_title'] = 'Customer CDRs Report'; |
|
47 | + $data['search_flag'] = true; |
|
48 | + $this->session->set_userdata('advance_search', 0); |
|
49 | + $data['grid_fields'] = $this->reports_form->build_report_list_for_customer(); |
|
50 | + $data["grid_buttons"] = $this->reports_form->build_grid_customer(); |
|
51 | + $data['form_search'] = $this->form->build_serach_form($this->reports_form->get_customer_cdr_form()); |
|
52 | + $this->load->view('view_cdr_customer_list', $data); |
|
53 | + } |
|
54 | + |
|
55 | + /* * **** |
|
56 | 56 | ASTPP 3.0 |
57 | 57 | Add recording file value in json |
58 | 58 | * **** */ |
59 | 59 | |
60 | - function customerReport_json() { |
|
61 | - $count_res = $this->reports_model->getcustomer_cdrs(false, "", ""); |
|
62 | - $count_all = (array) $count_res->first_row(); |
|
63 | - $paging_data = $this->form->load_grid_config($count_all['count'], $_GET['rp'], $_GET['page']); |
|
64 | - $json_data = $paging_data["json_paging"]; |
|
65 | - $query = $this->reports_model->getcustomer_cdrs(true, $paging_data["paging"]["start"], $paging_data["paging"]["page_no"]); |
|
66 | - if ($query->num_rows() > 0) { |
|
67 | - //Initialization of Rategroup and Trunk Array |
|
68 | - $pricelist_arr = array(); |
|
69 | - $trunk_arr = array(); |
|
70 | - // Get search information from session. |
|
71 | - $search_arr = $this->session->userdata('customer_cdr_list_search'); |
|
72 | - $show_seconds = (!empty($search_arr['search_in'])) ? $search_arr['search_in'] : 'minutes'; |
|
73 | - $query = $query->result_array(); |
|
74 | - |
|
75 | - $where = "id IN (" . $count_all['pricelist_ids'] . ")"; |
|
76 | - $this->db->where($where); |
|
77 | - $this->db->select('id,name'); |
|
78 | - $pricelist_res = $this->db->get('pricelists'); |
|
79 | - $pricelist_res = $pricelist_res->result_array(); |
|
80 | - foreach ($pricelist_res as $value) { |
|
81 | - $pricelist_arr[$value['id']] = $value['name']; |
|
82 | - } |
|
83 | - $where = "id IN (" . $count_all['trunk_ids'] . ")"; |
|
84 | - $this->db->where($where); |
|
85 | - $this->db->select('id,name'); |
|
86 | - $trunk_res = $this->db->get('trunks'); |
|
87 | - $trunk_res = $trunk_res->result_array(); |
|
88 | - foreach ($trunk_res as $value) { |
|
89 | - $trunk_arr[$value['id']] = $value['name']; |
|
90 | - } |
|
91 | - $where = "id IN (" . $count_all['accounts_ids'] . ")"; |
|
92 | - $this->db->where($where); |
|
93 | - $this->db->select('id,number,first_name,last_name'); |
|
94 | - $account_res = $this->db->get('accounts'); |
|
95 | - foreach ($account_res->result_array() as $value) { |
|
96 | - $account_arr[$value['id']] =$value['first_name'] . " " . $value['last_name'] . ' (' . $value['number'] . ')'; |
|
97 | - } |
|
60 | + function customerReport_json() { |
|
61 | + $count_res = $this->reports_model->getcustomer_cdrs(false, "", ""); |
|
62 | + $count_all = (array) $count_res->first_row(); |
|
63 | + $paging_data = $this->form->load_grid_config($count_all['count'], $_GET['rp'], $_GET['page']); |
|
64 | + $json_data = $paging_data["json_paging"]; |
|
65 | + $query = $this->reports_model->getcustomer_cdrs(true, $paging_data["paging"]["start"], $paging_data["paging"]["page_no"]); |
|
66 | + if ($query->num_rows() > 0) { |
|
67 | + //Initialization of Rategroup and Trunk Array |
|
68 | + $pricelist_arr = array(); |
|
69 | + $trunk_arr = array(); |
|
70 | + // Get search information from session. |
|
71 | + $search_arr = $this->session->userdata('customer_cdr_list_search'); |
|
72 | + $show_seconds = (!empty($search_arr['search_in'])) ? $search_arr['search_in'] : 'minutes'; |
|
73 | + $query = $query->result_array(); |
|
74 | + |
|
75 | + $where = "id IN (" . $count_all['pricelist_ids'] . ")"; |
|
76 | + $this->db->where($where); |
|
77 | + $this->db->select('id,name'); |
|
78 | + $pricelist_res = $this->db->get('pricelists'); |
|
79 | + $pricelist_res = $pricelist_res->result_array(); |
|
80 | + foreach ($pricelist_res as $value) { |
|
81 | + $pricelist_arr[$value['id']] = $value['name']; |
|
82 | + } |
|
83 | + $where = "id IN (" . $count_all['trunk_ids'] . ")"; |
|
84 | + $this->db->where($where); |
|
85 | + $this->db->select('id,name'); |
|
86 | + $trunk_res = $this->db->get('trunks'); |
|
87 | + $trunk_res = $trunk_res->result_array(); |
|
88 | + foreach ($trunk_res as $value) { |
|
89 | + $trunk_arr[$value['id']] = $value['name']; |
|
90 | + } |
|
91 | + $where = "id IN (" . $count_all['accounts_ids'] . ")"; |
|
92 | + $this->db->where($where); |
|
93 | + $this->db->select('id,number,first_name,last_name'); |
|
94 | + $account_res = $this->db->get('accounts'); |
|
95 | + foreach ($account_res->result_array() as $value) { |
|
96 | + $account_arr[$value['id']] =$value['first_name'] . " " . $value['last_name'] . ' (' . $value['number'] . ')'; |
|
97 | + } |
|
98 | 98 | |
99 | - //Get Decimal points,system currency and user currency. |
|
100 | - $currency_info = $this->common->get_currency_info(); |
|
101 | - foreach ($query as $value) { |
|
102 | - $duration = ($show_seconds == 'minutes') ? ($value['billseconds'] > 0 ) ? |
|
103 | - sprintf('%02d',$value['billseconds'] / 60) . ":" . sprintf('%02d', $value['billseconds'] % 60) : "00:00" : $value['billseconds']; |
|
104 | - $account=isset($account_arr[$value['accountid']]) ? $account_arr[$value['accountid']] : 'Anonymous'; |
|
105 | - $uid = $value['uniqueid']; |
|
106 | - $recording = ($value['is_recording'] == 0) ? '<a title="Recording file" href="../customerReport_recording_download/demo.wav"><img src="' . base_url() . 'assets/images/play_file.png" height="20px" width="20px"/></a>' : '<img src="' . base_url() . 'assets/images/false.png" height="20px" alt="file not found" width="20px"/>'; |
|
107 | - $json_data['rows'][] = array('cell' => array( |
|
108 | - $this->common->convert_GMT_to('', '', $value['callstart']), |
|
109 | - $value['callerid'], |
|
110 | - $value['callednum'], |
|
111 | - filter_var($value['pattern'], FILTER_SANITIZE_NUMBER_INT), |
|
112 | - $value['notes'], |
|
113 | - $duration, |
|
114 | - $this->common->calculate_currency_manually($currency_info, $value['debit'],false), |
|
115 | - $this->common->calculate_currency_manually($currency_info, $value['cost'],false), |
|
116 | - $value['disposition'], |
|
117 | - $account, |
|
118 | - isset($trunk_arr[$value['trunk_id']]) ? $trunk_arr[$value['trunk_id']] : '', |
|
119 | - isset($pricelist_arr[$value['pricelist_id']]) ? $pricelist_arr[$value['pricelist_id']] : '', |
|
120 | - $value['calltype'], |
|
121 | - $recording, |
|
122 | - )); |
|
123 | - } |
|
124 | - $duration = ($show_seconds == 'minutes') ? ($count_all['billseconds'] > 0 ) ? |
|
125 | - floor($count_all['billseconds'] / 60) . ":" . sprintf('%02d', $count_all['billseconds'] % 60) : "00:00" : $count_all['billseconds']; |
|
126 | - $json_data['rows'][] = array("cell" => array( |
|
127 | - "<b>Grand Total</b>", |
|
128 | - "", |
|
129 | - "", |
|
130 | - "", |
|
131 | - "", |
|
132 | - "<b>$duration</b>", |
|
99 | + //Get Decimal points,system currency and user currency. |
|
100 | + $currency_info = $this->common->get_currency_info(); |
|
101 | + foreach ($query as $value) { |
|
102 | + $duration = ($show_seconds == 'minutes') ? ($value['billseconds'] > 0 ) ? |
|
103 | + sprintf('%02d',$value['billseconds'] / 60) . ":" . sprintf('%02d', $value['billseconds'] % 60) : "00:00" : $value['billseconds']; |
|
104 | + $account=isset($account_arr[$value['accountid']]) ? $account_arr[$value['accountid']] : 'Anonymous'; |
|
105 | + $uid = $value['uniqueid']; |
|
106 | + $recording = ($value['is_recording'] == 0) ? '<a title="Recording file" href="../customerReport_recording_download/demo.wav"><img src="' . base_url() . 'assets/images/play_file.png" height="20px" width="20px"/></a>' : '<img src="' . base_url() . 'assets/images/false.png" height="20px" alt="file not found" width="20px"/>'; |
|
107 | + $json_data['rows'][] = array('cell' => array( |
|
108 | + $this->common->convert_GMT_to('', '', $value['callstart']), |
|
109 | + $value['callerid'], |
|
110 | + $value['callednum'], |
|
111 | + filter_var($value['pattern'], FILTER_SANITIZE_NUMBER_INT), |
|
112 | + $value['notes'], |
|
113 | + $duration, |
|
114 | + $this->common->calculate_currency_manually($currency_info, $value['debit'],false), |
|
115 | + $this->common->calculate_currency_manually($currency_info, $value['cost'],false), |
|
116 | + $value['disposition'], |
|
117 | + $account, |
|
118 | + isset($trunk_arr[$value['trunk_id']]) ? $trunk_arr[$value['trunk_id']] : '', |
|
119 | + isset($pricelist_arr[$value['pricelist_id']]) ? $pricelist_arr[$value['pricelist_id']] : '', |
|
120 | + $value['calltype'], |
|
121 | + $recording, |
|
122 | + )); |
|
123 | + } |
|
124 | + $duration = ($show_seconds == 'minutes') ? ($count_all['billseconds'] > 0 ) ? |
|
125 | + floor($count_all['billseconds'] / 60) . ":" . sprintf('%02d', $count_all['billseconds'] % 60) : "00:00" : $count_all['billseconds']; |
|
126 | + $json_data['rows'][] = array("cell" => array( |
|
127 | + "<b>Grand Total</b>", |
|
128 | + "", |
|
129 | + "", |
|
130 | + "", |
|
131 | + "", |
|
132 | + "<b>$duration</b>", |
|
133 | 133 | //$count_all['total_debit'], |
134 | - "<b>".$this->common->calculate_currency_manually($currency_info, $count_all['total_debit'],false)."</b>", |
|
135 | - "<b>".$this->common->calculate_currency_manually($currency_info, $count_all['total_cost'],false)."</b>", |
|
136 | - "", |
|
137 | - "", |
|
138 | - "", |
|
139 | - "", |
|
140 | - "", |
|
141 | - "", |
|
142 | - "", |
|
143 | - "", |
|
144 | - )); |
|
145 | - } |
|
146 | - echo json_encode($json_data); |
|
147 | - } |
|
148 | - |
|
149 | - /* * **** |
|
134 | + "<b>".$this->common->calculate_currency_manually($currency_info, $count_all['total_debit'],false)."</b>", |
|
135 | + "<b>".$this->common->calculate_currency_manually($currency_info, $count_all['total_cost'],false)."</b>", |
|
136 | + "", |
|
137 | + "", |
|
138 | + "", |
|
139 | + "", |
|
140 | + "", |
|
141 | + "", |
|
142 | + "", |
|
143 | + "", |
|
144 | + )); |
|
145 | + } |
|
146 | + echo json_encode($json_data); |
|
147 | + } |
|
148 | + |
|
149 | + /* * **** |
|
150 | 150 | ASTPP 3.0 |
151 | 151 | Recording file download |
152 | 152 | * **** */ |
153 | 153 | |
154 | - function customerReport_recording_download($file_name) { |
|
155 | - $file_name = getcwd() . "/recording/" . $file_name; |
|
156 | - header('Content-Description: File Transfer'); |
|
157 | - header('Content-Type: application/octet-stream'); |
|
158 | - header('Content-Disposition: attachment; filename=' . basename($file_name)); |
|
159 | - header('Content-Transfer-Encoding: binary'); |
|
160 | - header('Expires: 0'); |
|
161 | - header('Cache-Control: must-revalidate'); |
|
162 | - header('Pragma: public'); |
|
163 | - ob_clean(); |
|
164 | - flush(); |
|
165 | - readfile($file_name); |
|
166 | - exit(); |
|
167 | - } |
|
168 | - |
|
169 | - function customerReport_search() { |
|
170 | - $ajax_search = $this->input->post('ajax_search', 0); |
|
171 | - if ($this->input->post('advance_search', TRUE) == 1) { |
|
172 | - $this->session->set_userdata('advance_search', $this->input->post('advance_search')); |
|
173 | - $action = $this->input->post(); |
|
174 | - unset($action['action']); |
|
175 | - unset($action['advance_search']); |
|
176 | - $this->session->set_userdata('customer_cdr_list_search', $action); |
|
177 | - } |
|
178 | - if (@$ajax_search != 1) { |
|
179 | - redirect(base_url() . 'reports/customerReport/'); |
|
180 | - } |
|
181 | - } |
|
182 | - |
|
183 | - function customerReport_clearsearchfilter() { |
|
184 | - $this->session->set_userdata('advance_search', 0); |
|
185 | - $this->session->set_userdata('customer_cdr_list_search', ""); |
|
186 | - } |
|
187 | - |
|
188 | - /** |
|
154 | + function customerReport_recording_download($file_name) { |
|
155 | + $file_name = getcwd() . "/recording/" . $file_name; |
|
156 | + header('Content-Description: File Transfer'); |
|
157 | + header('Content-Type: application/octet-stream'); |
|
158 | + header('Content-Disposition: attachment; filename=' . basename($file_name)); |
|
159 | + header('Content-Transfer-Encoding: binary'); |
|
160 | + header('Expires: 0'); |
|
161 | + header('Cache-Control: must-revalidate'); |
|
162 | + header('Pragma: public'); |
|
163 | + ob_clean(); |
|
164 | + flush(); |
|
165 | + readfile($file_name); |
|
166 | + exit(); |
|
167 | + } |
|
168 | + |
|
169 | + function customerReport_search() { |
|
170 | + $ajax_search = $this->input->post('ajax_search', 0); |
|
171 | + if ($this->input->post('advance_search', TRUE) == 1) { |
|
172 | + $this->session->set_userdata('advance_search', $this->input->post('advance_search')); |
|
173 | + $action = $this->input->post(); |
|
174 | + unset($action['action']); |
|
175 | + unset($action['advance_search']); |
|
176 | + $this->session->set_userdata('customer_cdr_list_search', $action); |
|
177 | + } |
|
178 | + if (@$ajax_search != 1) { |
|
179 | + redirect(base_url() . 'reports/customerReport/'); |
|
180 | + } |
|
181 | + } |
|
182 | + |
|
183 | + function customerReport_clearsearchfilter() { |
|
184 | + $this->session->set_userdata('advance_search', 0); |
|
185 | + $this->session->set_userdata('customer_cdr_list_search', ""); |
|
186 | + } |
|
187 | + |
|
188 | + /** |
|
189 | 189 | ASTPP 3.0 |
190 | 190 | For Customer CDRs export |
191 | - * */ |
|
192 | - function customerReport_export() { |
|
193 | - $account_info = $accountinfo = $this->session->userdata('accountinfo'); |
|
191 | + * */ |
|
192 | + function customerReport_export() { |
|
193 | + $account_info = $accountinfo = $this->session->userdata('accountinfo'); |
|
194 | 194 | $currency_id=$account_info['currency_id']; |
195 | 195 | $currency=$this->common->get_field_name('currency', 'currency', $currency_id); |
196 | - $count_res = $this->reports_model->getcustomer_cdrs(false, "", ""); |
|
197 | - $count_all = (array) $count_res->first_row(); |
|
198 | - ob_clean(); |
|
199 | - if ($count_all['count'] > 0) { |
|
200 | - //Initialization of Rategroup and Trunk Array |
|
201 | - $pricelist_arr = array(); |
|
202 | - $trunk_arr = array(); |
|
203 | - $account_arr=array(); |
|
204 | - $query = $this->reports_model->getcustomer_cdrs(true, '', '', true); |
|
205 | - //Get Decimal points,system currency and user currency. |
|
206 | - $currency_info = $this->common->get_currency_info(); |
|
207 | - //Get search information from session. |
|
208 | - $search_arr = $this->session->userdata('customer_cdr_list_search'); |
|
209 | - $show_seconds = (!empty($search_arr['search_in'])) ? $search_arr['search_in'] : 'minutes'; |
|
210 | - $where = "id IN (" . $count_all['pricelist_ids'] . ")"; |
|
211 | - $this->db->where($where); |
|
212 | - $this->db->select('id,name'); |
|
213 | - $pricelist_res = $this->db->get('pricelists'); |
|
214 | - $pricelist_res = $pricelist_res->result_array(); |
|
215 | - foreach ($pricelist_res as $value) { |
|
216 | - $pricelist_arr[$value['id']] = $value['name']; |
|
217 | - } |
|
218 | - $where = "id IN (" . $count_all['accounts_ids'] . ")"; |
|
219 | - $this->db->where($where); |
|
220 | - $this->db->select('id,number,first_name,last_name'); |
|
221 | - $account_res = $this->db->get('accounts'); |
|
222 | - foreach ($account_res->result_array() as $value) { |
|
223 | - $account_arr[$value['id']] =$value['first_name'] . " " . $value['last_name'] . ' (' . $value['number'] . ')'; |
|
224 | - } |
|
196 | + $count_res = $this->reports_model->getcustomer_cdrs(false, "", ""); |
|
197 | + $count_all = (array) $count_res->first_row(); |
|
198 | + ob_clean(); |
|
199 | + if ($count_all['count'] > 0) { |
|
200 | + //Initialization of Rategroup and Trunk Array |
|
201 | + $pricelist_arr = array(); |
|
202 | + $trunk_arr = array(); |
|
203 | + $account_arr=array(); |
|
204 | + $query = $this->reports_model->getcustomer_cdrs(true, '', '', true); |
|
205 | + //Get Decimal points,system currency and user currency. |
|
206 | + $currency_info = $this->common->get_currency_info(); |
|
207 | + //Get search information from session. |
|
208 | + $search_arr = $this->session->userdata('customer_cdr_list_search'); |
|
209 | + $show_seconds = (!empty($search_arr['search_in'])) ? $search_arr['search_in'] : 'minutes'; |
|
210 | + $where = "id IN (" . $count_all['pricelist_ids'] . ")"; |
|
211 | + $this->db->where($where); |
|
212 | + $this->db->select('id,name'); |
|
213 | + $pricelist_res = $this->db->get('pricelists'); |
|
214 | + $pricelist_res = $pricelist_res->result_array(); |
|
215 | + foreach ($pricelist_res as $value) { |
|
216 | + $pricelist_arr[$value['id']] = $value['name']; |
|
217 | + } |
|
218 | + $where = "id IN (" . $count_all['accounts_ids'] . ")"; |
|
219 | + $this->db->where($where); |
|
220 | + $this->db->select('id,number,first_name,last_name'); |
|
221 | + $account_res = $this->db->get('accounts'); |
|
222 | + foreach ($account_res->result_array() as $value) { |
|
223 | + $account_arr[$value['id']] =$value['first_name'] . " " . $value['last_name'] . ' (' . $value['number'] . ')'; |
|
224 | + } |
|
225 | 225 | |
226 | - if($accountinfo['type'] !=1){ |
|
227 | - $customer_array[] = array("Date", "CallerID", "Called Number", "Code", "Destination", "Duration", "Debit($currency)", "Cost($currency)", "Disposition", "Account", "Trunk", "Rate Group", "Call Type"); |
|
228 | - $where = "id IN (" . $count_all['trunk_ids'] . ")"; |
|
229 | - $this->db->where($where); |
|
230 | - $this->db->select('id,name'); |
|
231 | - $trunk_res = $this->db->get('trunks'); |
|
232 | - $trunk_res = $trunk_res->result_array(); |
|
233 | - foreach ($trunk_res as $value) { |
|
234 | - $trunk_arr[$value['id']] = $value['name']; |
|
235 | - } |
|
226 | + if($accountinfo['type'] !=1){ |
|
227 | + $customer_array[] = array("Date", "CallerID", "Called Number", "Code", "Destination", "Duration", "Debit($currency)", "Cost($currency)", "Disposition", "Account", "Trunk", "Rate Group", "Call Type"); |
|
228 | + $where = "id IN (" . $count_all['trunk_ids'] . ")"; |
|
229 | + $this->db->where($where); |
|
230 | + $this->db->select('id,name'); |
|
231 | + $trunk_res = $this->db->get('trunks'); |
|
232 | + $trunk_res = $trunk_res->result_array(); |
|
233 | + foreach ($trunk_res as $value) { |
|
234 | + $trunk_arr[$value['id']] = $value['name']; |
|
235 | + } |
|
236 | 236 | foreach ($query->result_array() as $value) { |
237 | - $duration = ($show_seconds == 'minutes') ? ($value['billseconds'] > 0 ) ? |
|
238 | - floor($value['billseconds'] / 60) . ":" . sprintf('%02d', $value['billseconds'] % 60) : "00:00" : $value['billseconds']; |
|
239 | - $account=isset($account_arr[$value['accountid']]) ? $account_arr[$value['accountid']] : 'Anonymous'; |
|
240 | - $customer_array[] = array( |
|
241 | - $this->common->convert_GMT_to('', '', $value['callstart']), |
|
242 | - $value['callerid'], |
|
243 | - $value['callednum'], |
|
244 | - filter_var($value['pattern'], FILTER_SANITIZE_NUMBER_INT), |
|
245 | - $value['notes'], |
|
246 | - $duration, |
|
247 | - $this->common->calculate_currency_manually($currency_info, $value['debit'],false,false), |
|
248 | - $this->common->calculate_currency_manually($currency_info, $value['cost'],false,false), |
|
249 | - $value['disposition'], |
|
250 | - $account, |
|
251 | - isset($trunk_arr[$value['trunk_id']]) ? $trunk_arr[$value['trunk_id']] : '', |
|
252 | - isset($pricelist_arr[$value['pricelist_id']]) ? $pricelist_arr[$value['pricelist_id']] : '', |
|
253 | - $value['calltype'], |
|
254 | - ); |
|
255 | - } |
|
256 | - $duration = ($show_seconds == 'minutes') ? ($count_all['billseconds'] > 0 ) ? |
|
257 | - floor($count_all['billseconds'] / 60) . ":" . sprintf('%02d', $count_all['billseconds'] % 60) : "00:00" : $count_all['billseconds']; |
|
258 | - $customer_array[] = array("Grand Total", |
|
259 | - "", |
|
260 | - "", |
|
261 | - "", |
|
262 | - "", |
|
263 | - $duration, |
|
264 | - $this->common->calculate_currency_manually($currency_info, $count_all['total_debit'],false,false), |
|
265 | - $this->common->calculate_currency_manually($currency_info, $count_all['total_cost'],false,false), |
|
266 | - "", |
|
267 | - "", |
|
268 | - "", |
|
269 | - "", |
|
270 | - "", |
|
271 | - "", |
|
272 | - "", |
|
273 | - "", |
|
274 | - ); |
|
275 | - }else{ |
|
276 | - $customer_array[] = array("Date", "CallerID", "Called Number", "Code", "Destination", "Duration", "Debit($currency)", "Cost($currency)", "Disposition", "Account","Rate Group", "Call Type"); |
|
277 | - foreach ($query->result_array() as $value) { |
|
278 | - $duration = ($show_seconds == 'minutes') ? ($value['billseconds'] > 0 ) ? |
|
279 | - floor($value['billseconds'] / 60) . ":" . sprintf('%02d', $value['billseconds'] % 60) : "00:00" : $value['billseconds']; |
|
280 | - $account=isset($account_arr[$value['accountid']]) ? $account_arr[$value['accountid']] : 'Anonymous'; |
|
281 | - $customer_array[] = array( |
|
282 | - $this->common->convert_GMT_to('', '', $value['callstart']), |
|
283 | - $value['callerid'], |
|
284 | - $value['callednum'], |
|
285 | - filter_var($value['pattern'], FILTER_SANITIZE_NUMBER_INT), |
|
286 | - $value['notes'], |
|
287 | - $duration, |
|
288 | - $this->common->calculate_currency_manually($currency_info, $value['debit'],false,false), |
|
289 | - $this->common->calculate_currency_manually($currency_info, $value['cost'],false,false), |
|
290 | - $value['disposition'], |
|
291 | - $account, |
|
292 | - isset($pricelist_arr[$value['pricelist_id']]) ? $pricelist_arr[$value['pricelist_id']] : '', |
|
293 | - $value['calltype'], |
|
294 | - ); |
|
295 | - } |
|
296 | - $duration = ($show_seconds == 'minutes') ? ($count_all['billseconds'] > 0 ) ? |
|
297 | - floor($count_all['billseconds'] / 60) . ":" . sprintf('%02d', $count_all['billseconds'] % 60) : "00:00" : $count_all['billseconds']; |
|
298 | - $customer_array[] = array("Grand Total", |
|
299 | - "", |
|
300 | - "", |
|
301 | - "", |
|
302 | - "", |
|
303 | - $duration, |
|
304 | - $this->common->calculate_currency_manually($currency_info, $count_all['total_debit'],false,false), |
|
305 | - $this->common->calculate_currency_manually($currency_info, $count_all['total_cost'],false,false), |
|
306 | - "", |
|
307 | - "", |
|
308 | - "", |
|
309 | - "", |
|
310 | - "", |
|
311 | - "", |
|
312 | - "", |
|
313 | - ); |
|
314 | - } |
|
315 | - } |
|
316 | - $this->load->helper('csv'); |
|
317 | - if(isset($customer_array)){ |
|
237 | + $duration = ($show_seconds == 'minutes') ? ($value['billseconds'] > 0 ) ? |
|
238 | + floor($value['billseconds'] / 60) . ":" . sprintf('%02d', $value['billseconds'] % 60) : "00:00" : $value['billseconds']; |
|
239 | + $account=isset($account_arr[$value['accountid']]) ? $account_arr[$value['accountid']] : 'Anonymous'; |
|
240 | + $customer_array[] = array( |
|
241 | + $this->common->convert_GMT_to('', '', $value['callstart']), |
|
242 | + $value['callerid'], |
|
243 | + $value['callednum'], |
|
244 | + filter_var($value['pattern'], FILTER_SANITIZE_NUMBER_INT), |
|
245 | + $value['notes'], |
|
246 | + $duration, |
|
247 | + $this->common->calculate_currency_manually($currency_info, $value['debit'],false,false), |
|
248 | + $this->common->calculate_currency_manually($currency_info, $value['cost'],false,false), |
|
249 | + $value['disposition'], |
|
250 | + $account, |
|
251 | + isset($trunk_arr[$value['trunk_id']]) ? $trunk_arr[$value['trunk_id']] : '', |
|
252 | + isset($pricelist_arr[$value['pricelist_id']]) ? $pricelist_arr[$value['pricelist_id']] : '', |
|
253 | + $value['calltype'], |
|
254 | + ); |
|
255 | + } |
|
256 | + $duration = ($show_seconds == 'minutes') ? ($count_all['billseconds'] > 0 ) ? |
|
257 | + floor($count_all['billseconds'] / 60) . ":" . sprintf('%02d', $count_all['billseconds'] % 60) : "00:00" : $count_all['billseconds']; |
|
258 | + $customer_array[] = array("Grand Total", |
|
259 | + "", |
|
260 | + "", |
|
261 | + "", |
|
262 | + "", |
|
263 | + $duration, |
|
264 | + $this->common->calculate_currency_manually($currency_info, $count_all['total_debit'],false,false), |
|
265 | + $this->common->calculate_currency_manually($currency_info, $count_all['total_cost'],false,false), |
|
266 | + "", |
|
267 | + "", |
|
268 | + "", |
|
269 | + "", |
|
270 | + "", |
|
271 | + "", |
|
272 | + "", |
|
273 | + "", |
|
274 | + ); |
|
275 | + }else{ |
|
276 | + $customer_array[] = array("Date", "CallerID", "Called Number", "Code", "Destination", "Duration", "Debit($currency)", "Cost($currency)", "Disposition", "Account","Rate Group", "Call Type"); |
|
277 | + foreach ($query->result_array() as $value) { |
|
278 | + $duration = ($show_seconds == 'minutes') ? ($value['billseconds'] > 0 ) ? |
|
279 | + floor($value['billseconds'] / 60) . ":" . sprintf('%02d', $value['billseconds'] % 60) : "00:00" : $value['billseconds']; |
|
280 | + $account=isset($account_arr[$value['accountid']]) ? $account_arr[$value['accountid']] : 'Anonymous'; |
|
281 | + $customer_array[] = array( |
|
282 | + $this->common->convert_GMT_to('', '', $value['callstart']), |
|
283 | + $value['callerid'], |
|
284 | + $value['callednum'], |
|
285 | + filter_var($value['pattern'], FILTER_SANITIZE_NUMBER_INT), |
|
286 | + $value['notes'], |
|
287 | + $duration, |
|
288 | + $this->common->calculate_currency_manually($currency_info, $value['debit'],false,false), |
|
289 | + $this->common->calculate_currency_manually($currency_info, $value['cost'],false,false), |
|
290 | + $value['disposition'], |
|
291 | + $account, |
|
292 | + isset($pricelist_arr[$value['pricelist_id']]) ? $pricelist_arr[$value['pricelist_id']] : '', |
|
293 | + $value['calltype'], |
|
294 | + ); |
|
295 | + } |
|
296 | + $duration = ($show_seconds == 'minutes') ? ($count_all['billseconds'] > 0 ) ? |
|
297 | + floor($count_all['billseconds'] / 60) . ":" . sprintf('%02d', $count_all['billseconds'] % 60) : "00:00" : $count_all['billseconds']; |
|
298 | + $customer_array[] = array("Grand Total", |
|
299 | + "", |
|
300 | + "", |
|
301 | + "", |
|
302 | + "", |
|
303 | + $duration, |
|
304 | + $this->common->calculate_currency_manually($currency_info, $count_all['total_debit'],false,false), |
|
305 | + $this->common->calculate_currency_manually($currency_info, $count_all['total_cost'],false,false), |
|
306 | + "", |
|
307 | + "", |
|
308 | + "", |
|
309 | + "", |
|
310 | + "", |
|
311 | + "", |
|
312 | + "", |
|
313 | + ); |
|
314 | + } |
|
315 | + } |
|
316 | + $this->load->helper('csv'); |
|
317 | + if(isset($customer_array)){ |
|
318 | 318 | array_to_csv($customer_array, 'Customer_CDR_' . date("Y-m-d") . '.csv'); |
319 | 319 | }else{ |
320 | 320 | $customer_array[] = array("Date", "CallerID", "Called Number", "Code", "Destination", "Duration", "Debit($currency)", "Cost($currency)", "Disposition", "Account","Rate Group", "Call Type"); |
321 | 321 | array_to_csv($customer_array, 'Customer_CDR_' . date("Y-m-d") . '.csv'); |
322 | 322 | } |
323 | - } |
|
323 | + } |
|
324 | 324 | |
325 | - /* * *************************** */ |
|
325 | + /* * *************************** */ |
|
326 | 326 | |
327 | - function resellerReport() { |
|
328 | - $data['page_title'] = 'Resellers CDRs Report'; |
|
329 | - $data['search_flag'] = true; |
|
330 | - $this->session->set_userdata('advance_search', 0); |
|
331 | - $data['grid_fields'] = $this->reports_form->build_report_list_for_reseller(); |
|
332 | - $data["grid_buttons"] = $this->reports_form->build_grid_buttons_reseller(); |
|
333 | - $data['form_search'] = $this->form->build_serach_form($this->reports_form->get_reseller_cdr_form()); |
|
334 | - $this->load->view('view_cdr_reseller_list', $data); |
|
335 | - } |
|
327 | + function resellerReport() { |
|
328 | + $data['page_title'] = 'Resellers CDRs Report'; |
|
329 | + $data['search_flag'] = true; |
|
330 | + $this->session->set_userdata('advance_search', 0); |
|
331 | + $data['grid_fields'] = $this->reports_form->build_report_list_for_reseller(); |
|
332 | + $data["grid_buttons"] = $this->reports_form->build_grid_buttons_reseller(); |
|
333 | + $data['form_search'] = $this->form->build_serach_form($this->reports_form->get_reseller_cdr_form()); |
|
334 | + $this->load->view('view_cdr_reseller_list', $data); |
|
335 | + } |
|
336 | 336 | |
337 | - /** |
|
338 | - * -------Here we write code for controller accounts functions account_list------ |
|
339 | - * Listing of Accounts table data through php function json_encode |
|
340 | - */ |
|
341 | - function resellerReport_json() { |
|
342 | - |
|
343 | - //Get Total Count,Total debit,Total cost information |
|
344 | - $count_res = $this->reports_model->getreseller_cdrs(false, "", ""); |
|
345 | - $count_all = (array) $count_res->first_row(); |
|
346 | - $paging_data = $this->form->load_grid_config($count_all['count'], $_GET['rp'], $_GET['page']); |
|
347 | - $json_data = $paging_data["json_paging"]; |
|
348 | - $query = $this->reports_model->getreseller_cdrs(true, $paging_data["paging"]["start"], $paging_data["paging"]["page_no"]); |
|
349 | - $grid_fields = json_decode($this->reports_form->build_report_list_for_reseller()); |
|
350 | - $json_data['rows'] = $this->form->build_grid($query, $grid_fields); |
|
351 | - if ($count_all['count'] > 0) { |
|
352 | - $search_arr = $this->session->userdata('reseller_cdr_list_search'); |
|
353 | - $show_seconds = (!empty($search_arr['search_in'])) ? $search_arr['search_in'] : 'minutes'; |
|
354 | - $duration = ($show_seconds == 'minutes') ? ($count_all['billseconds'] > 0 ) ? |
|
355 | - sprintf('%02d', $count_all['billseconds'] / 60) . ":" . sprintf('%02d', $count_all['billseconds'] % 60) : "00:00" : sprintf('%02d', $count_all['billseconds'] ); |
|
356 | - $json_data['rows'][] = array("cell" => array( |
|
357 | - "<b>Grand Total</b>", |
|
358 | - "", |
|
359 | - "", |
|
360 | - "", |
|
361 | - "", |
|
362 | - "<b>$duration</b>", |
|
363 | - "<b>".$this->common_model->calculate_currency($count_all['total_debit'],'','',true,false)."</b>", |
|
364 | - "<b>".$this->common_model->calculate_currency($count_all['total_cost'],'','',true,false)."</b>", |
|
365 | - "", |
|
366 | - "", |
|
367 | - "", |
|
368 | - "", |
|
369 | - "", |
|
370 | - "", |
|
371 | - "", |
|
372 | - "", |
|
373 | - )); |
|
374 | - } |
|
375 | - echo json_encode($json_data); |
|
376 | - } |
|
377 | - |
|
378 | - function resellerReport_search() { |
|
379 | - $ajax_search = $this->input->post('ajax_search', 0); |
|
380 | - if ($this->input->post('advance_search', TRUE) == 1) { |
|
381 | - $this->session->set_userdata('advance_search', $this->input->post('advance_search')); |
|
382 | - $action = $this->input->post(); |
|
383 | - unset($action['action']); |
|
384 | - unset($action['advance_search']); |
|
385 | - $this->session->set_userdata('reseller_cdr_list_search', $action); |
|
386 | - } |
|
387 | - if (@$ajax_search != 1) { |
|
388 | - redirect(base_url() . 'reports/resellerReport/'); |
|
389 | - } |
|
390 | - } |
|
391 | - |
|
392 | - function resellerReport_clearsearchfilter() { |
|
393 | - $this->session->set_userdata('advance_search', 0); |
|
394 | - $this->session->set_userdata('account_search', ""); |
|
395 | - } |
|
396 | - |
|
397 | - function resellerReport_export() { |
|
398 | - //Get All count related information. |
|
399 | - $account_info = $accountinfo = $this->session->userdata('accountinfo'); |
|
337 | + /** |
|
338 | + * -------Here we write code for controller accounts functions account_list------ |
|
339 | + * Listing of Accounts table data through php function json_encode |
|
340 | + */ |
|
341 | + function resellerReport_json() { |
|
342 | + |
|
343 | + //Get Total Count,Total debit,Total cost information |
|
344 | + $count_res = $this->reports_model->getreseller_cdrs(false, "", ""); |
|
345 | + $count_all = (array) $count_res->first_row(); |
|
346 | + $paging_data = $this->form->load_grid_config($count_all['count'], $_GET['rp'], $_GET['page']); |
|
347 | + $json_data = $paging_data["json_paging"]; |
|
348 | + $query = $this->reports_model->getreseller_cdrs(true, $paging_data["paging"]["start"], $paging_data["paging"]["page_no"]); |
|
349 | + $grid_fields = json_decode($this->reports_form->build_report_list_for_reseller()); |
|
350 | + $json_data['rows'] = $this->form->build_grid($query, $grid_fields); |
|
351 | + if ($count_all['count'] > 0) { |
|
352 | + $search_arr = $this->session->userdata('reseller_cdr_list_search'); |
|
353 | + $show_seconds = (!empty($search_arr['search_in'])) ? $search_arr['search_in'] : 'minutes'; |
|
354 | + $duration = ($show_seconds == 'minutes') ? ($count_all['billseconds'] > 0 ) ? |
|
355 | + sprintf('%02d', $count_all['billseconds'] / 60) . ":" . sprintf('%02d', $count_all['billseconds'] % 60) : "00:00" : sprintf('%02d', $count_all['billseconds'] ); |
|
356 | + $json_data['rows'][] = array("cell" => array( |
|
357 | + "<b>Grand Total</b>", |
|
358 | + "", |
|
359 | + "", |
|
360 | + "", |
|
361 | + "", |
|
362 | + "<b>$duration</b>", |
|
363 | + "<b>".$this->common_model->calculate_currency($count_all['total_debit'],'','',true,false)."</b>", |
|
364 | + "<b>".$this->common_model->calculate_currency($count_all['total_cost'],'','',true,false)."</b>", |
|
365 | + "", |
|
366 | + "", |
|
367 | + "", |
|
368 | + "", |
|
369 | + "", |
|
370 | + "", |
|
371 | + "", |
|
372 | + "", |
|
373 | + )); |
|
374 | + } |
|
375 | + echo json_encode($json_data); |
|
376 | + } |
|
377 | + |
|
378 | + function resellerReport_search() { |
|
379 | + $ajax_search = $this->input->post('ajax_search', 0); |
|
380 | + if ($this->input->post('advance_search', TRUE) == 1) { |
|
381 | + $this->session->set_userdata('advance_search', $this->input->post('advance_search')); |
|
382 | + $action = $this->input->post(); |
|
383 | + unset($action['action']); |
|
384 | + unset($action['advance_search']); |
|
385 | + $this->session->set_userdata('reseller_cdr_list_search', $action); |
|
386 | + } |
|
387 | + if (@$ajax_search != 1) { |
|
388 | + redirect(base_url() . 'reports/resellerReport/'); |
|
389 | + } |
|
390 | + } |
|
391 | + |
|
392 | + function resellerReport_clearsearchfilter() { |
|
393 | + $this->session->set_userdata('advance_search', 0); |
|
394 | + $this->session->set_userdata('account_search', ""); |
|
395 | + } |
|
396 | + |
|
397 | + function resellerReport_export() { |
|
398 | + //Get All count related information. |
|
399 | + $account_info = $accountinfo = $this->session->userdata('accountinfo'); |
|
400 | 400 | $currency_id=$account_info['currency_id']; |
401 | 401 | $currency=$this->common->get_field_name('currency', 'currency', $currency_id); |
402 | - $count_res = $this->reports_model->getreseller_cdrs(false, "", ""); |
|
403 | - $count_all = (array) $count_res->first_row(); |
|
404 | - ob_clean(); |
|
405 | - $reseller_array[] = array("Date", "CallerID", "Called Number", "Code", "Destination", "Duration", "Debit($currency)", "Cost($currency)", "Disposition", "Account", "Rate Group", "Call Type"); |
|
406 | - if ($count_all['count'] > 0) { |
|
407 | - //Initialization of Rategroup array |
|
408 | - $pricelist_arr = array(); |
|
409 | - $query = $this->reports_model->getreseller_cdrs(true, '', '', true); |
|
410 | - //Get Decimal points,system currency and user currency. |
|
411 | - $currency_info = $this->common->get_currency_info(); |
|
412 | - // Get search information from session. |
|
413 | - $search_arr = $this->session->userdata('reseller_cdr_list_search'); |
|
414 | - $show_seconds = (!empty($search_arr['search_in'])) ? $search_arr['search_in'] : 'minutes'; |
|
415 | - $where = "id IN (" . $count_all['pricelist_ids'] . ")"; |
|
416 | - $this->db->where($where); |
|
417 | - $this->db->select('id,name'); |
|
418 | - $pricelist_res = $this->db->get('pricelists'); |
|
419 | - $pricelist_res = $pricelist_res->result_array(); |
|
420 | - foreach ($pricelist_res as $value) { |
|
421 | - $pricelist_arr[$value['id']] = $value['name']; |
|
422 | - } |
|
423 | - foreach ($query->result_array() as $value) { |
|
424 | - $duration = ($show_seconds == 'minutes') ? ($value['billseconds'] > 0 ) ? |
|
425 | - sprintf('%02d',$value['billseconds'] / 60) . ":" . sprintf('%02d', $value['billseconds'] % 60) : "00:00" : $value['billseconds']; |
|
426 | - $reseller_array[] = array( |
|
427 | - $this->common->convert_GMT_to('', '', $value['callstart']), |
|
428 | - $value['callerid'], |
|
429 | - $value['callednum'], |
|
430 | - filter_var($value['pattern'], FILTER_SANITIZE_NUMBER_INT), |
|
431 | - $value['notes'], |
|
432 | - $duration, |
|
433 | - $this->common->calculate_currency_manually($currency_info, $value['debit'],false,false), |
|
434 | - $this->common->calculate_currency_manually($currency_info, $value['cost'],false,false), |
|
435 | - $value['disposition'], |
|
436 | - $this->common->build_concat_string("first_name,last_name,number", "accounts", $value['accountid']), |
|
437 | - isset($pricelist_arr[$value['pricelist_id']]) ? $pricelist_arr[$value['pricelist_id']] : '', |
|
438 | - $value['calltype'], |
|
439 | - ); |
|
440 | - } |
|
441 | - $duration = ($show_seconds == 'minutes') ? ($count_all['billseconds'] > 0 ) ? |
|
442 | - floor($count_all['billseconds'] / 60) . ":" . sprintf('%02d', $count_all['billseconds'] % 60) : "00:00" : $count_all['billseconds']; |
|
443 | - $reseller_array[] = array("Grand Total", |
|
444 | - "", |
|
445 | - "", |
|
446 | - "", |
|
447 | - "", |
|
448 | - $duration, |
|
449 | - $this->common->calculate_currency_manually($currency_info, $count_all['total_debit'],false,false), |
|
450 | - $this->common->calculate_currency_manually($currency_info, $count_all['total_cost'],false,false), |
|
451 | - "", |
|
452 | - "", |
|
453 | - "", |
|
454 | - "", |
|
455 | - "", |
|
456 | - "", |
|
457 | - "", |
|
458 | - "", |
|
459 | - ); |
|
460 | - } |
|
461 | - $this->load->helper('csv'); |
|
462 | - array_to_csv($reseller_array, 'Reseller_CDR_' . date("Y-m-d") . '.csv'); |
|
463 | - } |
|
464 | - |
|
465 | - function providerReport() { |
|
466 | - $data['page_title'] = 'Provider CDRs Report'; |
|
467 | - $data['search_flag'] = true; |
|
468 | - $this->session->set_userdata('advance_search', 0); |
|
469 | - $data['grid_fields'] = $this->reports_form->build_report_list_for_provider(); |
|
470 | - $data["grid_buttons"] = $this->reports_form->build_grid_buttons_provider(); |
|
471 | - $data['form_search'] = $this->form->build_serach_form($this->reports_form->get_provider_cdr_form()); |
|
472 | - $this->load->view('view_cdr_provider_list', $data); |
|
473 | - } |
|
474 | - |
|
475 | - function providerReport_json() { |
|
476 | - //Get All count related information. |
|
477 | - $count_res = $this->reports_model->getprovider_cdrs(false, "", ""); |
|
478 | - $count_all = (array) $count_res->first_row(); |
|
479 | - $paging_data = $this->form->load_grid_config($count_all['count'], $_GET['rp'], $_GET['page']); |
|
480 | - $json_data = $paging_data["json_paging"]; |
|
481 | - |
|
482 | - $query = $this->reports_model->getprovider_cdrs(true, $paging_data["paging"]["start"], $paging_data["paging"]["page_no"]); |
|
483 | - $grid_fields = json_decode($this->reports_form->build_report_list_for_provider()); |
|
484 | - $json_data['rows'] = $this->form->build_grid($query, $grid_fields); |
|
485 | - if ($count_all['count'] > 0) { |
|
486 | - $search_arr = $this->session->userdata('provider_cdr_list_search'); |
|
487 | - $show_seconds = (!empty($search_arr['search_in'])) ? $search_arr['search_in'] : 'minutes'; |
|
488 | - $duration = ($show_seconds == 'minutes') ? ($count_all['billseconds'] > 0 ) ? |
|
489 | - floor($count_all['billseconds'] / 60) . ":" . sprintf("%02d", $count_all['billseconds'] % 60) : "00:00" : $count_all['billseconds']; |
|
490 | - $json_data['rows'][] = array("cell" => array( |
|
491 | - "<b>Grand Total</b>", |
|
492 | - "", |
|
493 | - "", |
|
494 | - "", |
|
495 | - "", |
|
496 | - "<b>$duration</b>", |
|
497 | - "<b>".$this->common_model->calculate_currency($count_all['total_cost'],'','',true,false)."</b>", |
|
498 | - "", |
|
499 | - "", |
|
500 | - )); |
|
501 | - } |
|
502 | - echo json_encode($json_data); |
|
503 | - } |
|
504 | - |
|
505 | - function providerReport_search() { |
|
506 | - $ajax_search = $this->input->post('ajax_search', 0); |
|
507 | - if ($this->input->post('advance_search', TRUE) == 1) { |
|
508 | - $this->session->set_userdata('advance_search', $this->input->post('advance_search')); |
|
509 | - $action = $this->input->post(); |
|
510 | - unset($action['action']); |
|
511 | - unset($action['advance_search']); |
|
512 | - $this->session->set_userdata('provider_cdr_list_search', $action); |
|
513 | - } |
|
514 | - if (@$ajax_search != 1) { |
|
515 | - redirect(base_url() . 'reports/providerReport/'); |
|
516 | - } |
|
517 | - } |
|
518 | - |
|
519 | - function providerReport_clearsearchfilter() { |
|
520 | - $this->session->set_userdata('advance_search', 0); |
|
521 | - $this->session->set_userdata('account_search', ""); |
|
522 | - } |
|
523 | - |
|
524 | - function providerReport_export() { |
|
525 | - /* ASTPP 3.0 |
|
402 | + $count_res = $this->reports_model->getreseller_cdrs(false, "", ""); |
|
403 | + $count_all = (array) $count_res->first_row(); |
|
404 | + ob_clean(); |
|
405 | + $reseller_array[] = array("Date", "CallerID", "Called Number", "Code", "Destination", "Duration", "Debit($currency)", "Cost($currency)", "Disposition", "Account", "Rate Group", "Call Type"); |
|
406 | + if ($count_all['count'] > 0) { |
|
407 | + //Initialization of Rategroup array |
|
408 | + $pricelist_arr = array(); |
|
409 | + $query = $this->reports_model->getreseller_cdrs(true, '', '', true); |
|
410 | + //Get Decimal points,system currency and user currency. |
|
411 | + $currency_info = $this->common->get_currency_info(); |
|
412 | + // Get search information from session. |
|
413 | + $search_arr = $this->session->userdata('reseller_cdr_list_search'); |
|
414 | + $show_seconds = (!empty($search_arr['search_in'])) ? $search_arr['search_in'] : 'minutes'; |
|
415 | + $where = "id IN (" . $count_all['pricelist_ids'] . ")"; |
|
416 | + $this->db->where($where); |
|
417 | + $this->db->select('id,name'); |
|
418 | + $pricelist_res = $this->db->get('pricelists'); |
|
419 | + $pricelist_res = $pricelist_res->result_array(); |
|
420 | + foreach ($pricelist_res as $value) { |
|
421 | + $pricelist_arr[$value['id']] = $value['name']; |
|
422 | + } |
|
423 | + foreach ($query->result_array() as $value) { |
|
424 | + $duration = ($show_seconds == 'minutes') ? ($value['billseconds'] > 0 ) ? |
|
425 | + sprintf('%02d',$value['billseconds'] / 60) . ":" . sprintf('%02d', $value['billseconds'] % 60) : "00:00" : $value['billseconds']; |
|
426 | + $reseller_array[] = array( |
|
427 | + $this->common->convert_GMT_to('', '', $value['callstart']), |
|
428 | + $value['callerid'], |
|
429 | + $value['callednum'], |
|
430 | + filter_var($value['pattern'], FILTER_SANITIZE_NUMBER_INT), |
|
431 | + $value['notes'], |
|
432 | + $duration, |
|
433 | + $this->common->calculate_currency_manually($currency_info, $value['debit'],false,false), |
|
434 | + $this->common->calculate_currency_manually($currency_info, $value['cost'],false,false), |
|
435 | + $value['disposition'], |
|
436 | + $this->common->build_concat_string("first_name,last_name,number", "accounts", $value['accountid']), |
|
437 | + isset($pricelist_arr[$value['pricelist_id']]) ? $pricelist_arr[$value['pricelist_id']] : '', |
|
438 | + $value['calltype'], |
|
439 | + ); |
|
440 | + } |
|
441 | + $duration = ($show_seconds == 'minutes') ? ($count_all['billseconds'] > 0 ) ? |
|
442 | + floor($count_all['billseconds'] / 60) . ":" . sprintf('%02d', $count_all['billseconds'] % 60) : "00:00" : $count_all['billseconds']; |
|
443 | + $reseller_array[] = array("Grand Total", |
|
444 | + "", |
|
445 | + "", |
|
446 | + "", |
|
447 | + "", |
|
448 | + $duration, |
|
449 | + $this->common->calculate_currency_manually($currency_info, $count_all['total_debit'],false,false), |
|
450 | + $this->common->calculate_currency_manually($currency_info, $count_all['total_cost'],false,false), |
|
451 | + "", |
|
452 | + "", |
|
453 | + "", |
|
454 | + "", |
|
455 | + "", |
|
456 | + "", |
|
457 | + "", |
|
458 | + "", |
|
459 | + ); |
|
460 | + } |
|
461 | + $this->load->helper('csv'); |
|
462 | + array_to_csv($reseller_array, 'Reseller_CDR_' . date("Y-m-d") . '.csv'); |
|
463 | + } |
|
464 | + |
|
465 | + function providerReport() { |
|
466 | + $data['page_title'] = 'Provider CDRs Report'; |
|
467 | + $data['search_flag'] = true; |
|
468 | + $this->session->set_userdata('advance_search', 0); |
|
469 | + $data['grid_fields'] = $this->reports_form->build_report_list_for_provider(); |
|
470 | + $data["grid_buttons"] = $this->reports_form->build_grid_buttons_provider(); |
|
471 | + $data['form_search'] = $this->form->build_serach_form($this->reports_form->get_provider_cdr_form()); |
|
472 | + $this->load->view('view_cdr_provider_list', $data); |
|
473 | + } |
|
474 | + |
|
475 | + function providerReport_json() { |
|
476 | + //Get All count related information. |
|
477 | + $count_res = $this->reports_model->getprovider_cdrs(false, "", ""); |
|
478 | + $count_all = (array) $count_res->first_row(); |
|
479 | + $paging_data = $this->form->load_grid_config($count_all['count'], $_GET['rp'], $_GET['page']); |
|
480 | + $json_data = $paging_data["json_paging"]; |
|
481 | + |
|
482 | + $query = $this->reports_model->getprovider_cdrs(true, $paging_data["paging"]["start"], $paging_data["paging"]["page_no"]); |
|
483 | + $grid_fields = json_decode($this->reports_form->build_report_list_for_provider()); |
|
484 | + $json_data['rows'] = $this->form->build_grid($query, $grid_fields); |
|
485 | + if ($count_all['count'] > 0) { |
|
486 | + $search_arr = $this->session->userdata('provider_cdr_list_search'); |
|
487 | + $show_seconds = (!empty($search_arr['search_in'])) ? $search_arr['search_in'] : 'minutes'; |
|
488 | + $duration = ($show_seconds == 'minutes') ? ($count_all['billseconds'] > 0 ) ? |
|
489 | + floor($count_all['billseconds'] / 60) . ":" . sprintf("%02d", $count_all['billseconds'] % 60) : "00:00" : $count_all['billseconds']; |
|
490 | + $json_data['rows'][] = array("cell" => array( |
|
491 | + "<b>Grand Total</b>", |
|
492 | + "", |
|
493 | + "", |
|
494 | + "", |
|
495 | + "", |
|
496 | + "<b>$duration</b>", |
|
497 | + "<b>".$this->common_model->calculate_currency($count_all['total_cost'],'','',true,false)."</b>", |
|
498 | + "", |
|
499 | + "", |
|
500 | + )); |
|
501 | + } |
|
502 | + echo json_encode($json_data); |
|
503 | + } |
|
504 | + |
|
505 | + function providerReport_search() { |
|
506 | + $ajax_search = $this->input->post('ajax_search', 0); |
|
507 | + if ($this->input->post('advance_search', TRUE) == 1) { |
|
508 | + $this->session->set_userdata('advance_search', $this->input->post('advance_search')); |
|
509 | + $action = $this->input->post(); |
|
510 | + unset($action['action']); |
|
511 | + unset($action['advance_search']); |
|
512 | + $this->session->set_userdata('provider_cdr_list_search', $action); |
|
513 | + } |
|
514 | + if (@$ajax_search != 1) { |
|
515 | + redirect(base_url() . 'reports/providerReport/'); |
|
516 | + } |
|
517 | + } |
|
518 | + |
|
519 | + function providerReport_clearsearchfilter() { |
|
520 | + $this->session->set_userdata('advance_search', 0); |
|
521 | + $this->session->set_userdata('account_search', ""); |
|
522 | + } |
|
523 | + |
|
524 | + function providerReport_export() { |
|
525 | + /* ASTPP 3.0 |
|
526 | 526 | Get All count information as well All total information |
527 | 527 | */ |
528 | - $account_info = $accountinfo = $this->session->userdata('accountinfo'); |
|
528 | + $account_info = $accountinfo = $this->session->userdata('accountinfo'); |
|
529 | 529 | $currency_id=$account_info['currency_id']; |
530 | 530 | $currency=$this->common->get_field_name('currency', 'currency', $currency_id); |
531 | - $count_res = $this->reports_model->getprovider_cdrs(false, "", ""); |
|
532 | - $count_all = (array) $count_res->first_row(); |
|
533 | - ob_clean(); |
|
534 | - $provider_array[] = array("Date", "CallerID", "Called Number", "Code", "Destination", "Duration", "Cost($currency)", "Disposition", "Account"); |
|
535 | - if ($count_all['count'] > 0) { |
|
536 | - $query = $this->reports_model->getprovider_cdrs(true, '', '', true); |
|
537 | - //Get Decimal points,system currency and user currency. |
|
538 | - $currency_info = $this->common->get_currency_info(); |
|
539 | - // Get search information from session. |
|
540 | - $search_arr = $this->session->userdata('provider_cdr_list_search'); |
|
541 | - $show_seconds = (!empty($search_arr['search_in'])) ? $search_arr['search_in'] : 'minutes'; |
|
542 | - foreach ($query->result_array() as $value) { |
|
531 | + $count_res = $this->reports_model->getprovider_cdrs(false, "", ""); |
|
532 | + $count_all = (array) $count_res->first_row(); |
|
533 | + ob_clean(); |
|
534 | + $provider_array[] = array("Date", "CallerID", "Called Number", "Code", "Destination", "Duration", "Cost($currency)", "Disposition", "Account"); |
|
535 | + if ($count_all['count'] > 0) { |
|
536 | + $query = $this->reports_model->getprovider_cdrs(true, '', '', true); |
|
537 | + //Get Decimal points,system currency and user currency. |
|
538 | + $currency_info = $this->common->get_currency_info(); |
|
539 | + // Get search information from session. |
|
540 | + $search_arr = $this->session->userdata('provider_cdr_list_search'); |
|
541 | + $show_seconds = (!empty($search_arr['search_in'])) ? $search_arr['search_in'] : 'minutes'; |
|
542 | + foreach ($query->result_array() as $value) { |
|
543 | 543 | // echo"<pre>";print_r($value);exit; |
544 | - $duration = ($show_seconds == 'minutes') ? ($value['billseconds'] > 0 ) ? |
|
545 | - floor($value['billseconds'] / 60) . ":" . sprintf("%02d", $value['billseconds'] % 60) : "00:00" : $value['billseconds']; |
|
546 | - $account_arr = $this->db_model->getSelect('*', 'accounts', array('id' => $value['provider_id'])); |
|
547 | - if ($account_arr->num_rows() > 0) { |
|
548 | - $account_array = $account_arr->result_array(); |
|
549 | - $account = $account_array[0]['first_name'] . " " . $account_array[0]['last_name'] . ' (' . $account_array[0]['number'] . ')'; |
|
550 | - } else { |
|
551 | - $account = "Anonymous"; |
|
552 | - } |
|
553 | - $provider_array[] = array( |
|
554 | - $this->common->convert_GMT_to('', '', $value['callstart']), |
|
555 | - $value['callerid'], |
|
556 | - $value['callednum'], |
|
557 | - filter_var($value['pattern'], FILTER_SANITIZE_NUMBER_INT), |
|
558 | - $value['notes'], |
|
559 | - $duration, |
|
560 | - $this->common->calculate_currency_manually($currency_info, $value['cost'],false,false), |
|
561 | - $value['disposition'], |
|
562 | - $account, |
|
563 | - ); |
|
564 | - } |
|
565 | - $duration = ($show_seconds == 'minutes') ? ($count_all['billseconds'] > 0 ) ? |
|
566 | - floor($count_all['billseconds'] / 60) . ":" . sprintf("%02d", $count_all['billseconds'] % 60) : "00:00" : $count_all['billseconds']; |
|
567 | - $provider_array[] = array("Grand Total", |
|
568 | - "", |
|
569 | - "", |
|
570 | - "", |
|
571 | - "", |
|
572 | - $duration, |
|
573 | - //$this->common->calculate_currency_manually($currency_info, $count_all['total_debit']), |
|
574 | - $this->common->calculate_currency_manually($currency_info, $count_all['total_cost'],false,false), |
|
575 | - "", |
|
576 | - "", |
|
577 | - "", |
|
578 | - "", |
|
579 | - "", |
|
580 | - "", |
|
581 | - "", |
|
582 | - "", |
|
583 | - ); |
|
584 | - } |
|
585 | - //echo "<pre>";print_r($provider_array);exit; |
|
586 | - $this->load->helper('csv'); |
|
587 | - array_to_csv($provider_array, 'Provider_CDR_' . date("Y-m-d") . '.csv'); |
|
588 | - } |
|
589 | - |
|
590 | - |
|
591 | - /* * **** |
|
544 | + $duration = ($show_seconds == 'minutes') ? ($value['billseconds'] > 0 ) ? |
|
545 | + floor($value['billseconds'] / 60) . ":" . sprintf("%02d", $value['billseconds'] % 60) : "00:00" : $value['billseconds']; |
|
546 | + $account_arr = $this->db_model->getSelect('*', 'accounts', array('id' => $value['provider_id'])); |
|
547 | + if ($account_arr->num_rows() > 0) { |
|
548 | + $account_array = $account_arr->result_array(); |
|
549 | + $account = $account_array[0]['first_name'] . " " . $account_array[0]['last_name'] . ' (' . $account_array[0]['number'] . ')'; |
|
550 | + } else { |
|
551 | + $account = "Anonymous"; |
|
552 | + } |
|
553 | + $provider_array[] = array( |
|
554 | + $this->common->convert_GMT_to('', '', $value['callstart']), |
|
555 | + $value['callerid'], |
|
556 | + $value['callednum'], |
|
557 | + filter_var($value['pattern'], FILTER_SANITIZE_NUMBER_INT), |
|
558 | + $value['notes'], |
|
559 | + $duration, |
|
560 | + $this->common->calculate_currency_manually($currency_info, $value['cost'],false,false), |
|
561 | + $value['disposition'], |
|
562 | + $account, |
|
563 | + ); |
|
564 | + } |
|
565 | + $duration = ($show_seconds == 'minutes') ? ($count_all['billseconds'] > 0 ) ? |
|
566 | + floor($count_all['billseconds'] / 60) . ":" . sprintf("%02d", $count_all['billseconds'] % 60) : "00:00" : $count_all['billseconds']; |
|
567 | + $provider_array[] = array("Grand Total", |
|
568 | + "", |
|
569 | + "", |
|
570 | + "", |
|
571 | + "", |
|
572 | + $duration, |
|
573 | + //$this->common->calculate_currency_manually($currency_info, $count_all['total_debit']), |
|
574 | + $this->common->calculate_currency_manually($currency_info, $count_all['total_cost'],false,false), |
|
575 | + "", |
|
576 | + "", |
|
577 | + "", |
|
578 | + "", |
|
579 | + "", |
|
580 | + "", |
|
581 | + "", |
|
582 | + "", |
|
583 | + ); |
|
584 | + } |
|
585 | + //echo "<pre>";print_r($provider_array);exit; |
|
586 | + $this->load->helper('csv'); |
|
587 | + array_to_csv($provider_array, 'Provider_CDR_' . date("Y-m-d") . '.csv'); |
|
588 | + } |
|
589 | + |
|
590 | + |
|
591 | + /* * **** |
|
592 | 592 | ASTPP 3.0 |
593 | 593 | Payment to refill |
594 | 594 | * **** */ |
595 | 595 | |
596 | - function user_refillreport() { |
|
597 | - $json_data = array(); |
|
598 | - $count_all = $this->reports_model->getuser_refill_list(false, "", ""); |
|
599 | - $paging_data = $this->form->load_grid_config($count_all, $_GET['rp'], $_GET['page']); |
|
600 | - $json_data = $paging_data["json_paging"]; |
|
601 | - |
|
602 | - $query = $this->reports_model->getuser_refill_list(true, $paging_data["paging"]["start"], $paging_data["paging"]["page_no"]); |
|
603 | - $grid_fields = json_decode($this->reports_form->build_refill_report_for_user()); |
|
604 | - $json_data['rows'] = $this->form->build_grid($query, $grid_fields); |
|
605 | - |
|
606 | - echo json_encode($json_data); |
|
607 | - } |
|
608 | - |
|
609 | - function user_refillreport_search() { |
|
610 | - $ajax_search = $this->input->post('ajax_search', 0); |
|
611 | - if ($this->input->post('advance_search', TRUE) == 1) { |
|
612 | - $this->session->set_userdata('advance_search', $this->input->post('advance_search')); |
|
613 | - $action = $this->input->post(); |
|
614 | - unset($action['action']); |
|
615 | - unset($action['advance_search']); |
|
616 | - $this->session->set_userdata('cdr_refill_search', $action); |
|
617 | - } |
|
618 | - if (@$ajax_search != 1) { |
|
619 | - redirect(base_url() . 'user/user_cdrs_report/'); |
|
620 | - } |
|
621 | - } |
|
622 | - |
|
623 | - function user_refillreport_clearsearchfilter() { |
|
624 | - $this->session->set_userdata('advance_search', 0); |
|
625 | - $this->session->set_userdata('account_search', ""); |
|
626 | - } |
|
627 | - |
|
628 | - /* * ************************** */ |
|
629 | - |
|
630 | - function customer_cdrreport($accountid, $accounttype) { |
|
631 | - $instant_search=$this->session->userdata('left_panel_search_'.$accounttype.'_cdrs'); |
|
632 | - $instant_search_currency = $this->common_model->add_calculate_currency($instant_search, "", '', true, false); |
|
633 | - $like_str=!empty($instant_search) ? "(callstart like '%$instant_search%' |
|
596 | + function user_refillreport() { |
|
597 | + $json_data = array(); |
|
598 | + $count_all = $this->reports_model->getuser_refill_list(false, "", ""); |
|
599 | + $paging_data = $this->form->load_grid_config($count_all, $_GET['rp'], $_GET['page']); |
|
600 | + $json_data = $paging_data["json_paging"]; |
|
601 | + |
|
602 | + $query = $this->reports_model->getuser_refill_list(true, $paging_data["paging"]["start"], $paging_data["paging"]["page_no"]); |
|
603 | + $grid_fields = json_decode($this->reports_form->build_refill_report_for_user()); |
|
604 | + $json_data['rows'] = $this->form->build_grid($query, $grid_fields); |
|
605 | + |
|
606 | + echo json_encode($json_data); |
|
607 | + } |
|
608 | + |
|
609 | + function user_refillreport_search() { |
|
610 | + $ajax_search = $this->input->post('ajax_search', 0); |
|
611 | + if ($this->input->post('advance_search', TRUE) == 1) { |
|
612 | + $this->session->set_userdata('advance_search', $this->input->post('advance_search')); |
|
613 | + $action = $this->input->post(); |
|
614 | + unset($action['action']); |
|
615 | + unset($action['advance_search']); |
|
616 | + $this->session->set_userdata('cdr_refill_search', $action); |
|
617 | + } |
|
618 | + if (@$ajax_search != 1) { |
|
619 | + redirect(base_url() . 'user/user_cdrs_report/'); |
|
620 | + } |
|
621 | + } |
|
622 | + |
|
623 | + function user_refillreport_clearsearchfilter() { |
|
624 | + $this->session->set_userdata('advance_search', 0); |
|
625 | + $this->session->set_userdata('account_search', ""); |
|
626 | + } |
|
627 | + |
|
628 | + /* * ************************** */ |
|
629 | + |
|
630 | + function customer_cdrreport($accountid, $accounttype) { |
|
631 | + $instant_search=$this->session->userdata('left_panel_search_'.$accounttype.'_cdrs'); |
|
632 | + $instant_search_currency = $this->common_model->add_calculate_currency($instant_search, "", '', true, false); |
|
633 | + $like_str=!empty($instant_search) ? "(callstart like '%$instant_search%' |
|
634 | 634 | OR callerid like '%$instant_search%' |
635 | 635 | OR callednum like '%$instant_search%' |
636 | 636 | OR notes like '%$instant_search%' |
@@ -639,135 +639,135 @@ discard block |
||
639 | 639 | OR debit like '%$instant_search_currency%' |
640 | 640 | OR cost like '%$instant_search_currency%' |
641 | 641 | )" |
642 | - :null; |
|
642 | + :null; |
|
643 | 643 | |
644 | - $json_data = array(); |
|
645 | - if(!empty($like_str)) |
|
646 | - $this->db->where($like_str); |
|
647 | - $count_all = $this->reports_model->users_cdrs_list(false, $accountid, $accounttype, "", ""); |
|
648 | - $paging_data = $this->form->load_grid_config($count_all, $_GET['rp'], $_GET['page']); |
|
649 | - $json_data = $paging_data["json_paging"]; |
|
650 | - if(!empty($like_str)) |
|
651 | - $this->db->where($like_str); |
|
652 | - $query = $this->reports_model->users_cdrs_list(true, $accountid, $accounttype, $paging_data["paging"]["start"], $paging_data["paging"]["page_no"]); |
|
653 | - $grid_fields = json_decode($this->reports_form->build_report_list_for_user($accounttype)); |
|
654 | - $json_data['rows'] = $this->form->build_grid($query, $grid_fields); |
|
655 | - echo json_encode($json_data); |
|
656 | - } |
|
657 | - |
|
658 | - /* * **** |
|
644 | + $json_data = array(); |
|
645 | + if(!empty($like_str)) |
|
646 | + $this->db->where($like_str); |
|
647 | + $count_all = $this->reports_model->users_cdrs_list(false, $accountid, $accounttype, "", ""); |
|
648 | + $paging_data = $this->form->load_grid_config($count_all, $_GET['rp'], $_GET['page']); |
|
649 | + $json_data = $paging_data["json_paging"]; |
|
650 | + if(!empty($like_str)) |
|
651 | + $this->db->where($like_str); |
|
652 | + $query = $this->reports_model->users_cdrs_list(true, $accountid, $accounttype, $paging_data["paging"]["start"], $paging_data["paging"]["page_no"]); |
|
653 | + $grid_fields = json_decode($this->reports_form->build_report_list_for_user($accounttype)); |
|
654 | + $json_data['rows'] = $this->form->build_grid($query, $grid_fields); |
|
655 | + echo json_encode($json_data); |
|
656 | + } |
|
657 | + |
|
658 | + /* * **** |
|
659 | 659 | ASTPP 3.0 |
660 | 660 | Payment to refill |
661 | 661 | * **** */ |
662 | 662 | |
663 | - function refillreport() { |
|
664 | - $data['page_title'] = 'Refill Report'; |
|
665 | - $data['search_flag'] = true; |
|
666 | - $this->session->set_userdata('advance_search', 0); |
|
667 | - $data['grid_buttons']=$this->reports_form->build_refillreport_buttons(); |
|
668 | - $data['grid_fields'] = $this->reports_form->build_refill_report_for_admin(); |
|
669 | - $data['form_search'] = $this->form->build_serach_form($this->reports_form->build_search_refill_report_for_admin()); |
|
670 | - $this->load->view('view_refill_report', $data); |
|
671 | - } |
|
672 | - |
|
673 | - function refillreport_json() { |
|
674 | - $json_data = array(); |
|
675 | - $count_all = $this->reports_model->get_refill_list(false, "", ""); |
|
676 | - $paging_data = $this->form->load_grid_config($count_all, $_GET['rp'], $_GET['page']); |
|
677 | - $json_data = $paging_data["json_paging"]; |
|
678 | - $query = $this->reports_model->get_refill_list(true, $paging_data["paging"]["start"], $paging_data["paging"]["page_no"]); |
|
679 | - $grid_fields = json_decode($this->reports_form->build_refill_report_for_admin()); |
|
680 | - $json_data['rows'] = $this->form->build_grid($query, $grid_fields); |
|
681 | - echo json_encode($json_data); |
|
682 | - } |
|
663 | + function refillreport() { |
|
664 | + $data['page_title'] = 'Refill Report'; |
|
665 | + $data['search_flag'] = true; |
|
666 | + $this->session->set_userdata('advance_search', 0); |
|
667 | + $data['grid_buttons']=$this->reports_form->build_refillreport_buttons(); |
|
668 | + $data['grid_fields'] = $this->reports_form->build_refill_report_for_admin(); |
|
669 | + $data['form_search'] = $this->form->build_serach_form($this->reports_form->build_search_refill_report_for_admin()); |
|
670 | + $this->load->view('view_refill_report', $data); |
|
671 | + } |
|
672 | + |
|
673 | + function refillreport_json() { |
|
674 | + $json_data = array(); |
|
675 | + $count_all = $this->reports_model->get_refill_list(false, "", ""); |
|
676 | + $paging_data = $this->form->load_grid_config($count_all, $_GET['rp'], $_GET['page']); |
|
677 | + $json_data = $paging_data["json_paging"]; |
|
678 | + $query = $this->reports_model->get_refill_list(true, $paging_data["paging"]["start"], $paging_data["paging"]["page_no"]); |
|
679 | + $grid_fields = json_decode($this->reports_form->build_refill_report_for_admin()); |
|
680 | + $json_data['rows'] = $this->form->build_grid($query, $grid_fields); |
|
681 | + echo json_encode($json_data); |
|
682 | + } |
|
683 | 683 | |
684 | - function refillreport_export() { |
|
685 | - $account_info = $accountinfo = $this->session->userdata('accountinfo'); |
|
686 | - $currency_id=$account_info['currency_id']; |
|
687 | - $reseller_id=$accountinfo['reseller_id'] > 0 ? $accountinfo['reseller_id'] : 0; |
|
688 | - $account_arr=array(); |
|
689 | - $currency_info = $this->common->get_currency_info(); |
|
690 | - $currency=$this->common->get_field_name('currency', 'currency', $currency_id); |
|
691 | - ob_clean(); |
|
692 | - $customer_array[] = array("Date", "Account", "Amount($currency)", "Refill By", "Note"); |
|
693 | - $query = $this->reports_model->get_refill_list(true,"","",true); |
|
694 | - $this->db->select("concat(first_name,' ',last_name,' ','(',number,')') as first_name,id",false); |
|
695 | - $this->db->where('reseller_id',$reseller_id); |
|
696 | - $this->db->where_not_in('type',array("-1,2,4")); |
|
697 | - $account_res=$this->db->get('accounts'); |
|
698 | - if($account_res->num_rows() > 0){ |
|
684 | + function refillreport_export() { |
|
685 | + $account_info = $accountinfo = $this->session->userdata('accountinfo'); |
|
686 | + $currency_id=$account_info['currency_id']; |
|
687 | + $reseller_id=$accountinfo['reseller_id'] > 0 ? $accountinfo['reseller_id'] : 0; |
|
688 | + $account_arr=array(); |
|
689 | + $currency_info = $this->common->get_currency_info(); |
|
690 | + $currency=$this->common->get_field_name('currency', 'currency', $currency_id); |
|
691 | + ob_clean(); |
|
692 | + $customer_array[] = array("Date", "Account", "Amount($currency)", "Refill By", "Note"); |
|
693 | + $query = $this->reports_model->get_refill_list(true,"","",true); |
|
694 | + $this->db->select("concat(first_name,' ',last_name,' ','(',number,')') as first_name,id",false); |
|
695 | + $this->db->where('reseller_id',$reseller_id); |
|
696 | + $this->db->where_not_in('type',array("-1,2,4")); |
|
697 | + $account_res=$this->db->get('accounts'); |
|
698 | + if($account_res->num_rows() > 0){ |
|
699 | 699 | $account_res=$account_res->result_array(); |
700 | 700 | foreach($account_res as $key=>$value){ |
701 | 701 | $account_arr[$value['id']]=$value['first_name']; |
702 | 702 | } |
703 | - } |
|
704 | - if ($query->num_rows() > 0) { |
|
705 | - foreach ($query->result_array() as $row) { |
|
706 | - $customer_array[] = array( |
|
707 | - $row['payment_date'], |
|
708 | - isset($account_arr[$row['accountid']]) ? $account_arr[$row['accountid']] : 'Anonymous', |
|
709 | - number_format((float) (($row['credit'] * $currency_info['user_currency']['currencyrate']) / $currency_info['base_currency']['currencyrate']), $currency_info['decimalpoints'],".",""), |
|
710 | - $this->common->get_refill_by("","",$row['payment_by']), |
|
711 | - $row['notes'] |
|
712 | - ); |
|
713 | - } |
|
714 | - } |
|
715 | - $this->load->helper('csv'); |
|
716 | - array_to_csv($customer_array, 'Refill_Report_' . date("Y-m-d") . '.csv'); |
|
717 | - } |
|
718 | - |
|
719 | - function customer_refillreport_search() { |
|
720 | - $ajax_search = $this->input->post('ajax_search', 0); |
|
721 | - if ($this->input->post('advance_search', TRUE) == 1) { |
|
722 | - $this->session->set_userdata('advance_search', $this->input->post('advance_search')); |
|
723 | - $action = $this->input->post(); |
|
724 | - unset($action['action']); |
|
725 | - unset($action['advance_search']); |
|
726 | - $this->session->set_userdata('cdr_refill_search', $action); |
|
727 | - } |
|
728 | - if (@$ajax_search != 1) { |
|
729 | - redirect(base_url() . 'user/user_cdrs_report/'); |
|
730 | - } |
|
731 | - } |
|
732 | - |
|
733 | - function customer_refillreport_clearsearchfilter() { |
|
734 | - $this->session->set_userdata('advance_search', 0); |
|
735 | - $this->session->set_userdata('account_search', ""); |
|
736 | - } |
|
737 | - |
|
738 | - /******** |
|
703 | + } |
|
704 | + if ($query->num_rows() > 0) { |
|
705 | + foreach ($query->result_array() as $row) { |
|
706 | + $customer_array[] = array( |
|
707 | + $row['payment_date'], |
|
708 | + isset($account_arr[$row['accountid']]) ? $account_arr[$row['accountid']] : 'Anonymous', |
|
709 | + number_format((float) (($row['credit'] * $currency_info['user_currency']['currencyrate']) / $currency_info['base_currency']['currencyrate']), $currency_info['decimalpoints'],".",""), |
|
710 | + $this->common->get_refill_by("","",$row['payment_by']), |
|
711 | + $row['notes'] |
|
712 | + ); |
|
713 | + } |
|
714 | + } |
|
715 | + $this->load->helper('csv'); |
|
716 | + array_to_csv($customer_array, 'Refill_Report_' . date("Y-m-d") . '.csv'); |
|
717 | + } |
|
718 | + |
|
719 | + function customer_refillreport_search() { |
|
720 | + $ajax_search = $this->input->post('ajax_search', 0); |
|
721 | + if ($this->input->post('advance_search', TRUE) == 1) { |
|
722 | + $this->session->set_userdata('advance_search', $this->input->post('advance_search')); |
|
723 | + $action = $this->input->post(); |
|
724 | + unset($action['action']); |
|
725 | + unset($action['advance_search']); |
|
726 | + $this->session->set_userdata('cdr_refill_search', $action); |
|
727 | + } |
|
728 | + if (@$ajax_search != 1) { |
|
729 | + redirect(base_url() . 'user/user_cdrs_report/'); |
|
730 | + } |
|
731 | + } |
|
732 | + |
|
733 | + function customer_refillreport_clearsearchfilter() { |
|
734 | + $this->session->set_userdata('advance_search', 0); |
|
735 | + $this->session->set_userdata('account_search', ""); |
|
736 | + } |
|
737 | + |
|
738 | + /******** |
|
739 | 739 | ASTPP 3.0 |
740 | 740 | Charge History |
741 | 741 | * ****** */ |
742 | 742 | |
743 | - function charges_history() { |
|
744 | - $data['page_title'] = 'Charges History'; |
|
745 | - $data['search_flag'] = true; |
|
746 | - $this->session->set_userdata('advance_search', 0); |
|
747 | - $data['grid_fields'] = $this->reports_form->build_charge_list_for_admin(); |
|
748 | - $data['form_search'] = $this->form->build_serach_form($this->reports_form->get_charges_search_form()); |
|
749 | - $this->load->view('view_charges_list', $data); |
|
750 | - } |
|
751 | - |
|
752 | - function charges_history_json() { |
|
753 | - $json_data = array(); |
|
754 | - $count_all = $this->reports_model->getcharges_list(false); |
|
755 | - $paging_data = $this->form->load_grid_config($count_all, $_GET['rp'], $_GET['page']); |
|
756 | - $json_data = $paging_data["json_paging"]; |
|
757 | - $query = $this->reports_model->getcharges_list(true, $paging_data["paging"]["start"], $paging_data["paging"]["page_no"]); |
|
743 | + function charges_history() { |
|
744 | + $data['page_title'] = 'Charges History'; |
|
745 | + $data['search_flag'] = true; |
|
746 | + $this->session->set_userdata('advance_search', 0); |
|
747 | + $data['grid_fields'] = $this->reports_form->build_charge_list_for_admin(); |
|
748 | + $data['form_search'] = $this->form->build_serach_form($this->reports_form->get_charges_search_form()); |
|
749 | + $this->load->view('view_charges_list', $data); |
|
750 | + } |
|
751 | + |
|
752 | + function charges_history_json() { |
|
753 | + $json_data = array(); |
|
754 | + $count_all = $this->reports_model->getcharges_list(false); |
|
755 | + $paging_data = $this->form->load_grid_config($count_all, $_GET['rp'], $_GET['page']); |
|
756 | + $json_data = $paging_data["json_paging"]; |
|
757 | + $query = $this->reports_model->getcharges_list(true, $paging_data["paging"]["start"], $paging_data["paging"]["page_no"]); |
|
758 | 758 | $result= $query->result_array(); |
759 | - $query1 = $this->reports_model->getcharges_list(true,'',''); |
|
759 | + $query1 = $this->reports_model->getcharges_list(true,'',''); |
|
760 | 760 | $res= $query1->result_array(); |
761 | 761 | $debit=0; |
762 | 762 | $credit=0; |
763 | 763 | $before_balance=0; |
764 | 764 | $after_balance=0; |
765 | 765 | $i=0; |
766 | - foreach ($result as $key => $value) { |
|
767 | - $date=$this->common->convert_GMT_to('','',$value['created_date']); |
|
768 | - $cust_type = $this->common->get_field_name('posttoexternal', 'accounts', $value['accountid']); |
|
769 | - $invoice_prefix= $entity_type =$this->common->get_field_name('invoice_prefix','invoices',array('id'=>$value['invoiceid'])); |
|
770 | - $invoiceid= $entity_type =$this->common->get_field_name('invoiceid','invoices',array('id'=>$value['invoiceid'])); |
|
766 | + foreach ($result as $key => $value) { |
|
767 | + $date=$this->common->convert_GMT_to('','',$value['created_date']); |
|
768 | + $cust_type = $this->common->get_field_name('posttoexternal', 'accounts', $value['accountid']); |
|
769 | + $invoice_prefix= $entity_type =$this->common->get_field_name('invoice_prefix','invoices',array('id'=>$value['invoiceid'])); |
|
770 | + $invoiceid= $entity_type =$this->common->get_field_name('invoiceid','invoices',array('id'=>$value['invoiceid'])); |
|
771 | 771 | $invoice_num=$invoice_prefix.$invoiceid; |
772 | 772 | $account=$this->common->get_field_name_coma_new('first_name,last_name,number','accounts',$value['accountid']); |
773 | 773 | $reseller=$this->common->reseller_select_value('first_name,last_name,number','accounts',$value['reseller_id']); |
@@ -783,18 +783,18 @@ discard block |
||
783 | 783 | $debit=$this->common->convert_to_currency('','',$value['debit']); |
784 | 784 | } |
785 | 785 | $credit=$this->common->convert_to_currency('','',$value['credit']); |
786 | - if($cust_type == 0 && $value['item_type'] == 'INVPAY'){ |
|
786 | + if($cust_type == 0 && $value['item_type'] == 'INVPAY'){ |
|
787 | 787 | $credit = '(-) '.$credit; |
788 | - } |
|
788 | + } |
|
789 | 789 | if($value['after_balance'] == '-'){ |
790 | 790 | $after_balance='-'; |
791 | 791 | }else{ |
792 | 792 | $after_balance=$this->common->convert_to_currency('','',$value['after_balance']); |
793 | 793 | } |
794 | 794 | $description=$value['description']; |
795 | - $cust_type = $this->common->get_field_name('posttoexternal', 'accounts', $value['accountid']); |
|
796 | - if ($this->session->userdata('logintype') == 1) { |
|
797 | - $json_data['rows'][] = array('cell' => array( |
|
795 | + $cust_type = $this->common->get_field_name('posttoexternal', 'accounts', $value['accountid']); |
|
796 | + if ($this->session->userdata('logintype') == 1) { |
|
797 | + $json_data['rows'][] = array('cell' => array( |
|
798 | 798 | $date, |
799 | 799 | $invoice_num, |
800 | 800 | $account, |
@@ -805,9 +805,9 @@ discard block |
||
805 | 805 | $credit, |
806 | 806 | $after_balance, |
807 | 807 | $description, |
808 | - )); |
|
808 | + )); |
|
809 | 809 | }else{ |
810 | - $json_data['rows'][] = array('cell' => array( |
|
810 | + $json_data['rows'][] = array('cell' => array( |
|
811 | 811 | $date, |
812 | 812 | $invoice_num, |
813 | 813 | $account, |
@@ -817,70 +817,70 @@ discard block |
||
817 | 817 | $credit, |
818 | 818 | $after_balance, |
819 | 819 | $description, |
820 | - )); |
|
820 | + )); |
|
821 | 821 | |
822 | 822 | } |
823 | - } |
|
823 | + } |
|
824 | 824 | $debit_sum = 0; |
825 | 825 | $credit_sum = 0; |
826 | 826 | foreach($res as $value){ |
827 | - $cust_type = $this->common->get_field_name('posttoexternal', 'accounts', $value['accountid']); |
|
828 | - $cust_type = $this->common->get_field_name('posttoexternal', 'accounts', $value['accountid']); |
|
827 | + $cust_type = $this->common->get_field_name('posttoexternal', 'accounts', $value['accountid']); |
|
828 | + $cust_type = $this->common->get_field_name('posttoexternal', 'accounts', $value['accountid']); |
|
829 | 829 | $debit_sum += $value['debit']; |
830 | 830 | $credit_sum += $value['credit']; |
831 | 831 | $before_balance += $value['before_balance']; |
832 | 832 | $after_balance += $value['after_balance']; |
833 | 833 | } |
834 | - if ($this->session->userdata('logintype') == 1) { |
|
835 | - $json_data['rows'][$count_all]['cell']=array('<b>Total</b>','-','-','-','-','<b>'.$this->common->convert_to_currency('','',$debit_sum).'</b>','<b>'.$this->common->convert_to_currency('','',$credit_sum).'</b>','-','-'); |
|
834 | + if ($this->session->userdata('logintype') == 1) { |
|
835 | + $json_data['rows'][$count_all]['cell']=array('<b>Total</b>','-','-','-','-','<b>'.$this->common->convert_to_currency('','',$debit_sum).'</b>','<b>'.$this->common->convert_to_currency('','',$credit_sum).'</b>','-','-'); |
|
836 | 836 | }else{ |
837 | - $json_data['rows'][$count_all]['cell']=array('<b>Total</b>','-','-','-','-','<b>'.$this->common->convert_to_currency('','',$debit_sum).'</b>','<b>'.$this->common->convert_to_currency('','',$credit_sum).'</b>','-','-'); |
|
838 | - |
|
839 | - } |
|
840 | - echo json_encode($json_data); |
|
841 | - } |
|
842 | - function charges_history_search() { |
|
843 | - $ajax_search = $this->input->post('ajax_search', 0); |
|
844 | - if ($this->input->post('advance_search', TRUE) == 1) { |
|
845 | - $this->session->set_userdata('advance_search', $this->input->post('advance_search')); |
|
846 | - $action = $this->input->post(); |
|
847 | - unset($action['action']); |
|
848 | - unset($action['advance_search']); |
|
849 | - $this->session->set_userdata('charges_list_search', $action); |
|
850 | - } |
|
851 | - if (@$ajax_search != 1) { |
|
852 | - redirect(base_url() . 'accounts/admin_list/'); |
|
853 | - } |
|
854 | - } |
|
855 | - |
|
856 | - function charges_history_clearsearchfilter() { |
|
857 | - $this->session->set_userdata('advance_search', 0); |
|
858 | - $this->session->set_userdata('charges_list_search', ""); |
|
859 | - } |
|
860 | - /* * ******************************** */ |
|
861 | - /* ASTPP 3.0 |
|
837 | + $json_data['rows'][$count_all]['cell']=array('<b>Total</b>','-','-','-','-','<b>'.$this->common->convert_to_currency('','',$debit_sum).'</b>','<b>'.$this->common->convert_to_currency('','',$credit_sum).'</b>','-','-'); |
|
838 | + |
|
839 | + } |
|
840 | + echo json_encode($json_data); |
|
841 | + } |
|
842 | + function charges_history_search() { |
|
843 | + $ajax_search = $this->input->post('ajax_search', 0); |
|
844 | + if ($this->input->post('advance_search', TRUE) == 1) { |
|
845 | + $this->session->set_userdata('advance_search', $this->input->post('advance_search')); |
|
846 | + $action = $this->input->post(); |
|
847 | + unset($action['action']); |
|
848 | + unset($action['advance_search']); |
|
849 | + $this->session->set_userdata('charges_list_search', $action); |
|
850 | + } |
|
851 | + if (@$ajax_search != 1) { |
|
852 | + redirect(base_url() . 'accounts/admin_list/'); |
|
853 | + } |
|
854 | + } |
|
855 | + |
|
856 | + function charges_history_clearsearchfilter() { |
|
857 | + $this->session->set_userdata('advance_search', 0); |
|
858 | + $this->session->set_userdata('charges_list_search', ""); |
|
859 | + } |
|
860 | + /* * ******************************** */ |
|
861 | + /* ASTPP 3.0 |
|
862 | 862 | * This function using for customer edit |
863 | 863 | */ |
864 | - function customer_charge_history($accountid,$accounttype){ |
|
865 | - $json_data = array(); |
|
866 | - $instant_search=$this->session->userdata('left_panel_search_'.$accounttype.'_charges'); |
|
867 | - $like_str=!empty($instant_search) ? "(created_date like '%$instant_search%' |
|
864 | + function customer_charge_history($accountid,$accounttype){ |
|
865 | + $json_data = array(); |
|
866 | + $instant_search=$this->session->userdata('left_panel_search_'.$accounttype.'_charges'); |
|
867 | + $like_str=!empty($instant_search) ? "(created_date like '%$instant_search%' |
|
868 | 868 | OR item_type like '%$instant_search%' |
869 | 869 | OR 'debit' like '%$instant_search%' |
870 | 870 | OR 'credit' like '%$instant_search%' |
871 | 871 | OR 'description' like '%$instant_search%')" |
872 | - :null; |
|
873 | - if(!empty($like_str)) |
|
874 | - $this->db->where($like_str); |
|
875 | - $count_all = $this->reports_model->get_customer_charge_list(false,$accountid); |
|
876 | - |
|
877 | - $paging_data = $this->form->load_grid_config($count_all, $_GET['rp'], $_GET['page']); |
|
878 | - $json_data = $paging_data["json_paging"]; |
|
879 | - if(!empty($like_str)) |
|
880 | - $this->db->where($like_str); |
|
881 | - $query = $this->reports_model->get_customer_charge_list(true,$accountid,$paging_data["paging"]["start"], $paging_data["paging"]["page_no"]); |
|
872 | + :null; |
|
873 | + if(!empty($like_str)) |
|
874 | + $this->db->where($like_str); |
|
875 | + $count_all = $this->reports_model->get_customer_charge_list(false,$accountid); |
|
876 | + |
|
877 | + $paging_data = $this->form->load_grid_config($count_all, $_GET['rp'], $_GET['page']); |
|
878 | + $json_data = $paging_data["json_paging"]; |
|
879 | + if(!empty($like_str)) |
|
880 | + $this->db->where($like_str); |
|
881 | + $query = $this->reports_model->get_customer_charge_list(true,$accountid,$paging_data["paging"]["start"], $paging_data["paging"]["page_no"]); |
|
882 | 882 | $result= $query->result_array(); |
883 | - $query1 = $this->reports_model->get_customer_charge_list(true,$accountid,'',''); |
|
883 | + $query1 = $this->reports_model->get_customer_charge_list(true,$accountid,'',''); |
|
884 | 884 | $res= $query1->result_array(); |
885 | 885 | |
886 | 886 | $debit=0; |
@@ -888,11 +888,11 @@ discard block |
||
888 | 888 | $before_balance=0; |
889 | 889 | $after_balance=0; |
890 | 890 | $i=0; |
891 | - foreach ($result as $key => $value) { |
|
892 | - $date=$this->common->convert_GMT_to('','',$value['created_date']); |
|
893 | - $cust_type = $this->common->get_field_name('posttoexternal', 'accounts', $value['accountid']); |
|
894 | - $invoice_prefix= $entity_type =$this->common->get_field_name('invoice_prefix','invoices',array('id'=>$value['invoiceid'])); |
|
895 | - $invoiceid= $entity_type =$this->common->get_field_name('invoiceid','invoices',array('id'=>$value['invoiceid'])); |
|
891 | + foreach ($result as $key => $value) { |
|
892 | + $date=$this->common->convert_GMT_to('','',$value['created_date']); |
|
893 | + $cust_type = $this->common->get_field_name('posttoexternal', 'accounts', $value['accountid']); |
|
894 | + $invoice_prefix= $entity_type =$this->common->get_field_name('invoice_prefix','invoices',array('id'=>$value['invoiceid'])); |
|
895 | + $invoiceid= $entity_type =$this->common->get_field_name('invoiceid','invoices',array('id'=>$value['invoiceid'])); |
|
896 | 896 | $invoice_num=$invoice_prefix.$invoiceid; |
897 | 897 | $account=$this->common->get_field_name_coma_new('first_name,last_name,number','accounts',$value['accountid']); |
898 | 898 | $reseller=$this->common->reseller_select_value('first_name,last_name,number','accounts',$value['reseller_id']); |
@@ -908,18 +908,18 @@ discard block |
||
908 | 908 | $debit=$this->common->convert_to_currency('','',$value['debit']); |
909 | 909 | } |
910 | 910 | $credit=$this->common->convert_to_currency('','',$value['credit']); |
911 | - if($cust_type == 0 && $value['item_type'] == 'INVPAY'){ |
|
911 | + if($cust_type == 0 && $value['item_type'] == 'INVPAY'){ |
|
912 | 912 | $credit = '(-) '.$credit; |
913 | - } |
|
913 | + } |
|
914 | 914 | if($value['after_balance'] == '-'){ |
915 | 915 | $after_balance='-'; |
916 | 916 | }else{ |
917 | 917 | $after_balance=$this->common->convert_to_currency('','',$value['after_balance']); |
918 | 918 | } |
919 | 919 | $description=$value['description']; |
920 | - $cust_type = $this->common->get_field_name('posttoexternal', 'accounts', $value['accountid']); |
|
921 | - if ($this->session->userdata('logintype') == 1) { |
|
922 | - $json_data['rows'][] = array('cell' => array( |
|
920 | + $cust_type = $this->common->get_field_name('posttoexternal', 'accounts', $value['accountid']); |
|
921 | + if ($this->session->userdata('logintype') == 1) { |
|
922 | + $json_data['rows'][] = array('cell' => array( |
|
923 | 923 | $date, |
924 | 924 | $invoice_num, |
925 | 925 | $item_type, |
@@ -928,9 +928,9 @@ discard block |
||
928 | 928 | $credit, |
929 | 929 | $after_balance, |
930 | 930 | $description, |
931 | - )); |
|
931 | + )); |
|
932 | 932 | }else{ |
933 | - $json_data['rows'][] = array('cell' => array( |
|
933 | + $json_data['rows'][] = array('cell' => array( |
|
934 | 934 | $date, |
935 | 935 | $invoice_num, |
936 | 936 | $item_type, |
@@ -939,51 +939,51 @@ discard block |
||
939 | 939 | $credit, |
940 | 940 | $after_balance, |
941 | 941 | $description, |
942 | - )); |
|
942 | + )); |
|
943 | 943 | |
944 | 944 | } |
945 | - } |
|
945 | + } |
|
946 | 946 | $debit_sum = 0; |
947 | 947 | $credit_sum = 0; |
948 | 948 | foreach($res as $value){ |
949 | - $cust_type = $this->common->get_field_name('posttoexternal', 'accounts', $value['accountid']); |
|
950 | - $cust_type = $this->common->get_field_name('posttoexternal', 'accounts', $value['accountid']); |
|
949 | + $cust_type = $this->common->get_field_name('posttoexternal', 'accounts', $value['accountid']); |
|
950 | + $cust_type = $this->common->get_field_name('posttoexternal', 'accounts', $value['accountid']); |
|
951 | 951 | $debit_sum += $value['debit']; |
952 | 952 | $credit_sum += $value['credit']; |
953 | 953 | $before_balance += $value['before_balance']; |
954 | 954 | $after_balance += $value['after_balance']; |
955 | 955 | } |
956 | - if ($this->session->userdata('logintype') == 1) { |
|
957 | - $json_data['rows'][$count_all]['cell']=array('<b>Total</b>','-','-','-','<b>'.$this->common->convert_to_currency('','',$debit_sum).'</b>','<b>'.$this->common->convert_to_currency('','',$credit_sum).'</b>','-','-'); |
|
956 | + if ($this->session->userdata('logintype') == 1) { |
|
957 | + $json_data['rows'][$count_all]['cell']=array('<b>Total</b>','-','-','-','<b>'.$this->common->convert_to_currency('','',$debit_sum).'</b>','<b>'.$this->common->convert_to_currency('','',$credit_sum).'</b>','-','-'); |
|
958 | 958 | }else{ |
959 | - $json_data['rows'][$count_all]['cell']=array('<b>Total</b>','-','-','-','<b>'.$this->common->convert_to_currency('','',$debit_sum).'</b>','<b>'.$this->common->convert_to_currency('','',$credit_sum).'</b>','-','-'); |
|
959 | + $json_data['rows'][$count_all]['cell']=array('<b>Total</b>','-','-','-','<b>'.$this->common->convert_to_currency('','',$debit_sum).'</b>','<b>'.$this->common->convert_to_currency('','',$credit_sum).'</b>','-','-'); |
|
960 | 960 | |
961 | 961 | } |
962 | - echo json_encode($json_data); |
|
963 | - } |
|
962 | + echo json_encode($json_data); |
|
963 | + } |
|
964 | 964 | |
965 | - function customer_refillreport($accountid,$accounttype){ |
|
966 | - $json_data = array(); |
|
967 | - $instant_search=$this->session->userdata('left_panel_search_'.$accounttype.'_refill'); |
|
968 | - $like_str=!empty($instant_search) ? "(payment_date like '%$instant_search%' |
|
965 | + function customer_refillreport($accountid,$accounttype){ |
|
966 | + $json_data = array(); |
|
967 | + $instant_search=$this->session->userdata('left_panel_search_'.$accounttype.'_refill'); |
|
968 | + $like_str=!empty($instant_search) ? "(payment_date like '%$instant_search%' |
|
969 | 969 | OR credit like '%$instant_search%' |
970 | 970 | OR payment_by like '%$instant_search%' |
971 | 971 | OR notes like '%$instant_search%' |
972 | 972 | )" |
973 | - :null; |
|
974 | - if(!empty($like_str)) |
|
975 | - $this->db->where($like_str); |
|
976 | - $count_all = $this->reports_model->get_customer_refillreport(false,$accountid); |
|
977 | - $paging_data = $this->form->load_grid_config($count_all, $_GET['rp'], $_GET['page']); |
|
978 | - $json_data = $paging_data["json_paging"]; |
|
979 | - if(!empty($like_str)) |
|
980 | - $this->db->where($like_str); |
|
981 | - $query = $this->reports_model->get_customer_refillreport(true,$accountid,$paging_data["paging"]["start"], $paging_data["paging"]["page_no"]); |
|
982 | - $grid_fields = json_decode($this->reports_form->build_refillreport_for_customer()); |
|
983 | - $json_data['rows'] = $this->form->build_grid($query, $grid_fields); |
|
984 | - echo json_encode($json_data); |
|
985 | - } |
|
986 | - /***********************************************************/ |
|
973 | + :null; |
|
974 | + if(!empty($like_str)) |
|
975 | + $this->db->where($like_str); |
|
976 | + $count_all = $this->reports_model->get_customer_refillreport(false,$accountid); |
|
977 | + $paging_data = $this->form->load_grid_config($count_all, $_GET['rp'], $_GET['page']); |
|
978 | + $json_data = $paging_data["json_paging"]; |
|
979 | + if(!empty($like_str)) |
|
980 | + $this->db->where($like_str); |
|
981 | + $query = $this->reports_model->get_customer_refillreport(true,$accountid,$paging_data["paging"]["start"], $paging_data["paging"]["page_no"]); |
|
982 | + $grid_fields = json_decode($this->reports_form->build_refillreport_for_customer()); |
|
983 | + $json_data['rows'] = $this->form->build_grid($query, $grid_fields); |
|
984 | + echo json_encode($json_data); |
|
985 | + } |
|
986 | + /***********************************************************/ |
|
987 | 987 | } |
988 | 988 | ?> |
989 | 989 |
@@ -21,64 +21,64 @@ discard block |
||
21 | 21 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
22 | 22 | ############################################################################### |
23 | 23 | if (!defined('BASEPATH')) |
24 | - exit('No direct script access allowed'); |
|
24 | + exit('No direct script access allowed'); |
|
25 | 25 | |
26 | 26 | class Reports_form { |
27 | - function __construct() { |
|
28 | - $this->CI = & get_instance(); |
|
29 | - } |
|
30 | - function get_customer_cdr_form() { |
|
27 | + function __construct() { |
|
28 | + $this->CI = & get_instance(); |
|
29 | + } |
|
30 | + function get_customer_cdr_form() { |
|
31 | 31 | $logintype = $this->CI->session->userdata('userlevel_logintype'); |
32 | 32 | if($logintype != 1){ |
33 | - if ($this->CI->session->userdata('logintype') == 1 || $this->CI->session->userdata('logintype') == 5) { |
|
34 | - $accountinfo = $this->CI->session->userdata['accountinfo']; |
|
35 | - $reseller_id = $accountinfo["id"]; |
|
36 | - } else { |
|
37 | - $reseller_id = "0"; |
|
38 | - } |
|
39 | - $form['forms'] = array("", array('id' => "cdr_customer_search")); |
|
40 | - $form['Search'] = array( |
|
41 | - array('From Date', 'INPUT', array('name' => 'callstart[]', 'id' => 'customer_cdr_from_date', 'size' => '20', 'class' => "text field "), '', 'tOOL TIP', '', 'start_date[start_date-date]'), |
|
42 | - array('To Date', 'INPUT', array('name' => 'callstart[]', 'id' => 'customer_cdr_to_date', 'size' => '20', 'class' => "text field "), '', 'tOOL TIP', '', 'end_date[end_date-date]'), |
|
43 | - array('Caller ID', 'INPUT', array('name' => 'callerid[callerid]', '', 'id' => 'first_name', 'size' => '15', 'class' => "text field "), '', 'tOOL TIP', '1', 'callerid[callerid-string]', '', '', '', 'search_string_type', ''), |
|
44 | - array('Called Number', 'INPUT', array('name' => 'callednum[callednum]', 'value' => '', 'size' => '20', 'class' => "text field "), '', 'Tool tips info', '1', 'callednum[callednum-string]', '', '', '', 'search_string_type', ''), |
|
45 | - array('Code ', 'INPUT', array('name' => 'pattern[pattern]', 'value' => '', 'size' => '20', 'class' => "text field "), '', 'Tool tips info', '1', 'pattern[pattern-string]', '', '', '', 'search_string_type', ''), |
|
46 | - array('Destination ', 'INPUT', array('name' => 'notes[notes]', 'value' => '', 'size' => '20', 'class' => "text field "), '', 'Tool tips info', '1', 'notes[notes-string]', '', '', '', 'search_string_type', ''), |
|
47 | - array('Duration ', 'INPUT', array('name' => 'billseconds[billseconds]', 'value' => '', 'size' => '20', 'class' => "text field "), '', 'Tool tips info', '1', 'billseconds[billseconds-integer]', '', '', '', 'search_int_type', ''), |
|
48 | - array('Debit ', 'INPUT', array('name' => 'debit[debit]', 'value' => '', 'size' => '20', 'class' => "text field "), '', 'Tool tips info', '1', 'debit[debit-integer]', '', '', '', 'search_int_type', ''), |
|
49 | - array('Cost ', 'INPUT', array('name' => 'cost[cost]', 'value' => '', 'size' => '20', 'class' => "text field "), '', 'Tool tips info', '1', 'cost[cost-integer]', '', '', '', 'search_int_type', ''), |
|
50 | - array('Disposition', 'disposition', 'SELECT', '', '', 'tOOL TIP', 'Please Enter account number', '', '', '', 'set_despostion'), |
|
51 | - array('Account', 'accountid', 'SELECT', '', '', 'tOOL TIP', 'Please Enter account number', 'id', 'IF(`deleted`=1,concat( first_name, " ", last_name, " ", "(", number, ")^" ),concat( first_name, " ", last_name, " ", "(", number, ")" )) as number', 'accounts', 'build_dropdown_deleted', 'where_arr', array("reseller_id" => "0","type"=>"GLOBAL")), |
|
33 | + if ($this->CI->session->userdata('logintype') == 1 || $this->CI->session->userdata('logintype') == 5) { |
|
34 | + $accountinfo = $this->CI->session->userdata['accountinfo']; |
|
35 | + $reseller_id = $accountinfo["id"]; |
|
36 | + } else { |
|
37 | + $reseller_id = "0"; |
|
38 | + } |
|
39 | + $form['forms'] = array("", array('id' => "cdr_customer_search")); |
|
40 | + $form['Search'] = array( |
|
41 | + array('From Date', 'INPUT', array('name' => 'callstart[]', 'id' => 'customer_cdr_from_date', 'size' => '20', 'class' => "text field "), '', 'tOOL TIP', '', 'start_date[start_date-date]'), |
|
42 | + array('To Date', 'INPUT', array('name' => 'callstart[]', 'id' => 'customer_cdr_to_date', 'size' => '20', 'class' => "text field "), '', 'tOOL TIP', '', 'end_date[end_date-date]'), |
|
43 | + array('Caller ID', 'INPUT', array('name' => 'callerid[callerid]', '', 'id' => 'first_name', 'size' => '15', 'class' => "text field "), '', 'tOOL TIP', '1', 'callerid[callerid-string]', '', '', '', 'search_string_type', ''), |
|
44 | + array('Called Number', 'INPUT', array('name' => 'callednum[callednum]', 'value' => '', 'size' => '20', 'class' => "text field "), '', 'Tool tips info', '1', 'callednum[callednum-string]', '', '', '', 'search_string_type', ''), |
|
45 | + array('Code ', 'INPUT', array('name' => 'pattern[pattern]', 'value' => '', 'size' => '20', 'class' => "text field "), '', 'Tool tips info', '1', 'pattern[pattern-string]', '', '', '', 'search_string_type', ''), |
|
46 | + array('Destination ', 'INPUT', array('name' => 'notes[notes]', 'value' => '', 'size' => '20', 'class' => "text field "), '', 'Tool tips info', '1', 'notes[notes-string]', '', '', '', 'search_string_type', ''), |
|
47 | + array('Duration ', 'INPUT', array('name' => 'billseconds[billseconds]', 'value' => '', 'size' => '20', 'class' => "text field "), '', 'Tool tips info', '1', 'billseconds[billseconds-integer]', '', '', '', 'search_int_type', ''), |
|
48 | + array('Debit ', 'INPUT', array('name' => 'debit[debit]', 'value' => '', 'size' => '20', 'class' => "text field "), '', 'Tool tips info', '1', 'debit[debit-integer]', '', '', '', 'search_int_type', ''), |
|
49 | + array('Cost ', 'INPUT', array('name' => 'cost[cost]', 'value' => '', 'size' => '20', 'class' => "text field "), '', 'Tool tips info', '1', 'cost[cost-integer]', '', '', '', 'search_int_type', ''), |
|
50 | + array('Disposition', 'disposition', 'SELECT', '', '', 'tOOL TIP', 'Please Enter account number', '', '', '', 'set_despostion'), |
|
51 | + array('Account', 'accountid', 'SELECT', '', '', 'tOOL TIP', 'Please Enter account number', 'id', 'IF(`deleted`=1,concat( first_name, " ", last_name, " ", "(", number, ")^" ),concat( first_name, " ", last_name, " ", "(", number, ")" )) as number', 'accounts', 'build_dropdown_deleted', 'where_arr', array("reseller_id" => "0","type"=>"GLOBAL")), |
|
52 | 52 | |
53 | 53 | array('Trunk', 'trunk_id', 'SELECT', '', '', 'tOOL TIP', 'Please Enter account number', 'id', 'IF(`status`=2, concat(name,"","^"),name) as name', 'trunks', 'build_dropdown_deleted', '', array("status" => "1")), |
54 | 54 | |
55 | - array('Rate Group', 'pricelist_id', 'SELECT', '', '', 'tOOL TIP', 'Please Enter account number', 'id', 'IF(`status`=2, concat(name,"","^"),name) as name', 'pricelists', 'build_dropdown_deleted', 'where_arr', array("reseller_id" => "0")), |
|
56 | - array('Call Type', 'calltype', 'SELECT', '', '', 'tOOL TIP', 'Please Enter account number', '', '', '', 'set_calltype'), |
|
57 | - array('', 'HIDDEN', 'ajax_search', '1', '', '', ''), |
|
58 | - array('', 'HIDDEN', 'advance_search', '1', '', '', '')); |
|
59 | - } |
|
55 | + array('Rate Group', 'pricelist_id', 'SELECT', '', '', 'tOOL TIP', 'Please Enter account number', 'id', 'IF(`status`=2, concat(name,"","^"),name) as name', 'pricelists', 'build_dropdown_deleted', 'where_arr', array("reseller_id" => "0")), |
|
56 | + array('Call Type', 'calltype', 'SELECT', '', '', 'tOOL TIP', 'Please Enter account number', '', '', '', 'set_calltype'), |
|
57 | + array('', 'HIDDEN', 'ajax_search', '1', '', '', ''), |
|
58 | + array('', 'HIDDEN', 'advance_search', '1', '', '', '')); |
|
59 | + } |
|
60 | 60 | else |
61 | 61 | { |
62 | 62 | $form['forms'] = array("", array('id' => "cdr_customer_search")); |
63 | - $form['Search'] = array( |
|
64 | - array('From Date', 'INPUT', array('name' => 'callstart[]', 'id' => 'customer_cdr_from_date', 'size' => '20', 'class' => "text field "), '', 'tOOL TIP', '', 'start_date[start_date-date]'), |
|
65 | - array('To Date', 'INPUT', array('name' => 'callstart[]', 'id' => 'customer_cdr_to_date', 'size' => '20', 'class' => "text field "), '', 'tOOL TIP', '', 'end_date[end_date-date]'), |
|
66 | - array('Caller ID', 'INPUT', array('name' => 'callerid[callerid]', '', 'id' => 'first_name', 'size' => '15', 'class' => "text field "), '', 'tOOL TIP', '1', 'callerid[callerid-string]', '', '', '', 'search_string_type', ''), |
|
67 | - array('Called Number', 'INPUT', array('name' => 'callednum[callednum]', 'value' => '', 'size' => '20', 'class' => "text field "), '', 'Tool tips info', '1', 'callednum[callednum-string]', '', '', '', 'search_string_type', ''), |
|
68 | - array('Code ', 'INPUT', array('name' => 'pattern[pattern]', 'value' => '', 'size' => '20', 'class' => "text field "), '', 'Tool tips info', '1', 'pattern[pattern-string]', '', '', '', 'search_string_type', ''), |
|
69 | - array('Destination ', 'INPUT', array('name' => 'notes[notes]', 'value' => '', 'size' => '20', 'class' => "text field "), '', 'Tool tips info', '1', 'notes[notes-string]', '', '', '', 'search_string_type', ''), |
|
70 | - array('Duration ', 'INPUT', array('name' => 'billseconds[billseconds]', 'value' => '', 'size' => '20', 'class' => "text field "), '', 'Tool tips info', '1', 'billseconds[billseconds-integer]', '', '', '', 'search_int_type', ''), |
|
71 | - array('Debit ', 'INPUT', array('name' => 'debit[debit]', 'value' => '', 'size' => '20', 'class' => "text field "), '', 'Tool tips info', '1', 'debit[debit-integer]', '', '', '', 'search_int_type', ''), |
|
72 | - array('Cost ', 'INPUT', array('name' => 'cost[cost]', 'value' => '', 'size' => '20', 'class' => "text field "), '', 'Tool tips info', '1', 'cost[cost-integer]', '', '', '', 'search_int_type', ''), |
|
73 | - array('Disposition', 'disposition', 'SELECT', '', '', 'tOOL TIP', 'Please Enter account number', '', '', '', 'set_despostion'), |
|
74 | - array('Account', 'accountid', 'SELECT', '', '', 'tOOL TIP', 'Please Enter account number', 'id', 'IF(`deleted`=1,concat( first_name, " ", last_name, " ", "(", number, ")^" ),concat( first_name, " ", last_name, " ", "(", number, ")" )) as number', 'accounts', 'build_dropdown_deleted', 'where_arr', array("reseller_id" => "0","type"=>"GLOBAL")), |
|
63 | + $form['Search'] = array( |
|
64 | + array('From Date', 'INPUT', array('name' => 'callstart[]', 'id' => 'customer_cdr_from_date', 'size' => '20', 'class' => "text field "), '', 'tOOL TIP', '', 'start_date[start_date-date]'), |
|
65 | + array('To Date', 'INPUT', array('name' => 'callstart[]', 'id' => 'customer_cdr_to_date', 'size' => '20', 'class' => "text field "), '', 'tOOL TIP', '', 'end_date[end_date-date]'), |
|
66 | + array('Caller ID', 'INPUT', array('name' => 'callerid[callerid]', '', 'id' => 'first_name', 'size' => '15', 'class' => "text field "), '', 'tOOL TIP', '1', 'callerid[callerid-string]', '', '', '', 'search_string_type', ''), |
|
67 | + array('Called Number', 'INPUT', array('name' => 'callednum[callednum]', 'value' => '', 'size' => '20', 'class' => "text field "), '', 'Tool tips info', '1', 'callednum[callednum-string]', '', '', '', 'search_string_type', ''), |
|
68 | + array('Code ', 'INPUT', array('name' => 'pattern[pattern]', 'value' => '', 'size' => '20', 'class' => "text field "), '', 'Tool tips info', '1', 'pattern[pattern-string]', '', '', '', 'search_string_type', ''), |
|
69 | + array('Destination ', 'INPUT', array('name' => 'notes[notes]', 'value' => '', 'size' => '20', 'class' => "text field "), '', 'Tool tips info', '1', 'notes[notes-string]', '', '', '', 'search_string_type', ''), |
|
70 | + array('Duration ', 'INPUT', array('name' => 'billseconds[billseconds]', 'value' => '', 'size' => '20', 'class' => "text field "), '', 'Tool tips info', '1', 'billseconds[billseconds-integer]', '', '', '', 'search_int_type', ''), |
|
71 | + array('Debit ', 'INPUT', array('name' => 'debit[debit]', 'value' => '', 'size' => '20', 'class' => "text field "), '', 'Tool tips info', '1', 'debit[debit-integer]', '', '', '', 'search_int_type', ''), |
|
72 | + array('Cost ', 'INPUT', array('name' => 'cost[cost]', 'value' => '', 'size' => '20', 'class' => "text field "), '', 'Tool tips info', '1', 'cost[cost-integer]', '', '', '', 'search_int_type', ''), |
|
73 | + array('Disposition', 'disposition', 'SELECT', '', '', 'tOOL TIP', 'Please Enter account number', '', '', '', 'set_despostion'), |
|
74 | + array('Account', 'accountid', 'SELECT', '', '', 'tOOL TIP', 'Please Enter account number', 'id', 'IF(`deleted`=1,concat( first_name, " ", last_name, " ", "(", number, ")^" ),concat( first_name, " ", last_name, " ", "(", number, ")" )) as number', 'accounts', 'build_dropdown_deleted', 'where_arr', array("reseller_id" => "0","type"=>"GLOBAL")), |
|
75 | 75 | |
76 | 76 | //array('Trunk', 'trunk_id', 'SELECT', '', '', 'tOOL TIP', 'Please Enter account number', 'id', 'IF(`status`=2, concat(name,"","^"),name) as name', 'trunks', 'build_dropdown_deleted', '', array("status" => "1")), |
77 | 77 | |
78 | - array('Rate Group', 'pricelist_id', 'SELECT', '', '', 'tOOL TIP', 'Please Enter account number', 'id', 'IF(`status`=2, concat(name,"","^"),name) as name', 'pricelists', 'build_dropdown_deleted', 'where_arr', array("reseller_id" => "0")), |
|
79 | - array('Call Type', 'calltype', 'SELECT', '', '', 'tOOL TIP', 'Please Enter account number', '', '', '', 'set_calltype'), |
|
80 | - array('', 'HIDDEN', 'ajax_search', '1', '', '', ''), |
|
81 | - array('', 'HIDDEN', 'advance_search', '1', '', '', '')); |
|
78 | + array('Rate Group', 'pricelist_id', 'SELECT', '', '', 'tOOL TIP', 'Please Enter account number', 'id', 'IF(`status`=2, concat(name,"","^"),name) as name', 'pricelists', 'build_dropdown_deleted', 'where_arr', array("reseller_id" => "0")), |
|
79 | + array('Call Type', 'calltype', 'SELECT', '', '', 'tOOL TIP', 'Please Enter account number', '', '', '', 'set_calltype'), |
|
80 | + array('', 'HIDDEN', 'ajax_search', '1', '', '', ''), |
|
81 | + array('', 'HIDDEN', 'advance_search', '1', '', '', '')); |
|
82 | 82 | |
83 | 83 | } |
84 | 84 | |
@@ -86,94 +86,94 @@ discard block |
||
86 | 86 | $form['display_in']=array('name' => 'search_in',"id"=>"search_in","function"=>"search_report_in", "content"=>"Display records in",'label_class' => "search_label col-md-3 no-padding","dropdown_class"=>"form-control","label_style"=>"font-size:13px;","dropdown_style"=>"background: #ddd; width: 21% !important;"); |
87 | 87 | |
88 | 88 | /****************************************/ |
89 | - $form['button_search'] = array('name' => 'action', 'id' => "cusotmer_cdr_search_btn", 'content' => 'Search', 'value' => 'save', 'type' => 'button', 'class' => 'btn btn-line-parrot pull-right'); |
|
90 | - $form['button_reset'] = array('name' => 'action', 'id' => "id_reset", 'content' => 'Clear', 'value' => 'cancel', 'type' => 'reset', 'class' => 'btn btn-line-sky pull-right margin-x-10'); |
|
89 | + $form['button_search'] = array('name' => 'action', 'id' => "cusotmer_cdr_search_btn", 'content' => 'Search', 'value' => 'save', 'type' => 'button', 'class' => 'btn btn-line-parrot pull-right'); |
|
90 | + $form['button_reset'] = array('name' => 'action', 'id' => "id_reset", 'content' => 'Clear', 'value' => 'cancel', 'type' => 'reset', 'class' => 'btn btn-line-sky pull-right margin-x-10'); |
|
91 | 91 | |
92 | - return $form; |
|
93 | - } |
|
92 | + return $form; |
|
93 | + } |
|
94 | 94 | |
95 | - function get_reseller_cdr_form() { |
|
96 | - $form['forms'] = array("", array('id' => "cdr_reseller_search")); |
|
97 | - $form['Search'] = array( |
|
98 | - array('From Date', 'INPUT', array('name' => 'callstart[]', 'id' => 'customer_cdr_from_date', 'size' => '20', 'class' => "text field "), '', 'tOOL TIP', '', 'number[number-string]'), |
|
99 | - array('To Date', 'INPUT', array('name' => 'callstart[]', 'id' => 'customer_cdr_to_date', 'size' => '20', 'class' => "text field "), '', 'tOOL TIP', '', 'number[number-string]'), |
|
100 | - array('Caller ID', 'INPUT', array('name' => 'callerid[callerid]', '', 'id' => 'first_name', 'size' => '15', 'class' => "text field "), '', 'tOOL TIP', '1', 'callerid[callerid-string]', '', '', '', 'search_string_type', ''), |
|
101 | - array('Called Number', 'INPUT', array('name' => 'callednum[callednum]', 'value' => '', 'size' => '20', 'class' => "text field "), '', 'Tool tips info', '1', 'callednum[callednum-string]', '', '', '', 'search_string_type', ''), |
|
95 | + function get_reseller_cdr_form() { |
|
96 | + $form['forms'] = array("", array('id' => "cdr_reseller_search")); |
|
97 | + $form['Search'] = array( |
|
98 | + array('From Date', 'INPUT', array('name' => 'callstart[]', 'id' => 'customer_cdr_from_date', 'size' => '20', 'class' => "text field "), '', 'tOOL TIP', '', 'number[number-string]'), |
|
99 | + array('To Date', 'INPUT', array('name' => 'callstart[]', 'id' => 'customer_cdr_to_date', 'size' => '20', 'class' => "text field "), '', 'tOOL TIP', '', 'number[number-string]'), |
|
100 | + array('Caller ID', 'INPUT', array('name' => 'callerid[callerid]', '', 'id' => 'first_name', 'size' => '15', 'class' => "text field "), '', 'tOOL TIP', '1', 'callerid[callerid-string]', '', '', '', 'search_string_type', ''), |
|
101 | + array('Called Number', 'INPUT', array('name' => 'callednum[callednum]', 'value' => '', 'size' => '20', 'class' => "text field "), '', 'Tool tips info', '1', 'callednum[callednum-string]', '', '', '', 'search_string_type', ''), |
|
102 | 102 | |
103 | - array('Code ', 'INPUT', array('name' => 'pattern[pattern]', 'value' => '', 'size' => '20', 'class' => "text field "), '', 'Tool tips info', '1', 'pattern[pattern-string]', '', '', '', 'search_string_type', ''), |
|
104 | - array('Destination ', 'INPUT', array('name' => 'notes[notes]', 'value' => '', 'size' => '20', 'class' => "text field "), '', 'Tool tips info', '1', 'notes[notes-string]', '', '', '', 'search_string_type', ''), |
|
103 | + array('Code ', 'INPUT', array('name' => 'pattern[pattern]', 'value' => '', 'size' => '20', 'class' => "text field "), '', 'Tool tips info', '1', 'pattern[pattern-string]', '', '', '', 'search_string_type', ''), |
|
104 | + array('Destination ', 'INPUT', array('name' => 'notes[notes]', 'value' => '', 'size' => '20', 'class' => "text field "), '', 'Tool tips info', '1', 'notes[notes-string]', '', '', '', 'search_string_type', ''), |
|
105 | 105 | |
106 | 106 | |
107 | - array('Duration ', 'INPUT', array('name' => 'billseconds[billseconds]', 'value' => '', 'size' => '20', 'class' => "text field "), '', 'Tool tips info', '1', 'billseconds[billseconds-integer]', '', '', '', 'search_int_type', ''), |
|
108 | - array('Debit ', 'INPUT', array('name' => 'debit[debit]', 'value' => '', 'size' => '20', 'class' => "text field "), '', 'Tool tips info', '1', 'debit[debit-integer]', '', '', '', 'search_int_type', ''), |
|
109 | - array('Cost ', 'INPUT', array('name' => 'cost[cost]', 'value' => '', 'size' => '20', 'class' => "text field "), '', 'Tool tips info', '1', 'cost[cost-integer]', '', '', '', 'search_int_type', ''), |
|
107 | + array('Duration ', 'INPUT', array('name' => 'billseconds[billseconds]', 'value' => '', 'size' => '20', 'class' => "text field "), '', 'Tool tips info', '1', 'billseconds[billseconds-integer]', '', '', '', 'search_int_type', ''), |
|
108 | + array('Debit ', 'INPUT', array('name' => 'debit[debit]', 'value' => '', 'size' => '20', 'class' => "text field "), '', 'Tool tips info', '1', 'debit[debit-integer]', '', '', '', 'search_int_type', ''), |
|
109 | + array('Cost ', 'INPUT', array('name' => 'cost[cost]', 'value' => '', 'size' => '20', 'class' => "text field "), '', 'Tool tips info', '1', 'cost[cost-integer]', '', '', '', 'search_int_type', ''), |
|
110 | 110 | |
111 | - array('Disposition', 'disposition', 'SELECT', '', '', 'tOOL TIP', 'Please Enter account number', '', '', '', 'set_despostion'), |
|
112 | - array('Account', 'accountid', 'SELECT', '', '', 'tOOL TIP', 'Please Enter account number', 'id', 'IF(`deleted`=1,concat( first_name, " ", last_name, " ", "(", number, ")^" ),concat( first_name, " ", last_name, " ", "(", number, ")" )) as number', 'accounts', 'build_dropdown_deleted', 'where_arr', array("reseller_id" => "0","type"=>"1")), |
|
113 | - array('Rate Group', 'pricelist_id', 'SELECT', '', '', 'tOOL TIP', 'Please Enter account number', 'id', 'IF(`status`=2, concat(name,"","^"),name) as name', 'pricelists', 'build_dropdown_deleted', 'where_arr', array("reseller_id" => "0")), |
|
114 | - array('Call Type', 'calltype', 'SELECT', '', '', 'tOOL TIP', 'Please Enter account number', '', '', '', 'set_calltype'), |
|
111 | + array('Disposition', 'disposition', 'SELECT', '', '', 'tOOL TIP', 'Please Enter account number', '', '', '', 'set_despostion'), |
|
112 | + array('Account', 'accountid', 'SELECT', '', '', 'tOOL TIP', 'Please Enter account number', 'id', 'IF(`deleted`=1,concat( first_name, " ", last_name, " ", "(", number, ")^" ),concat( first_name, " ", last_name, " ", "(", number, ")" )) as number', 'accounts', 'build_dropdown_deleted', 'where_arr', array("reseller_id" => "0","type"=>"1")), |
|
113 | + array('Rate Group', 'pricelist_id', 'SELECT', '', '', 'tOOL TIP', 'Please Enter account number', 'id', 'IF(`status`=2, concat(name,"","^"),name) as name', 'pricelists', 'build_dropdown_deleted', 'where_arr', array("reseller_id" => "0")), |
|
114 | + array('Call Type', 'calltype', 'SELECT', '', '', 'tOOL TIP', 'Please Enter account number', '', '', '', 'set_calltype'), |
|
115 | 115 | |
116 | - array('', 'HIDDEN', 'ajax_search', '1', '', '', ''), |
|
117 | - array('', 'HIDDEN', 'advance_search', '1', '', '', '')); |
|
118 | - if ($this->CI->session->userdata('logintype') != 1 && $this->CI->session->userdata('logintype') != 5) { |
|
116 | + array('', 'HIDDEN', 'ajax_search', '1', '', '', ''), |
|
117 | + array('', 'HIDDEN', 'advance_search', '1', '', '', '')); |
|
118 | + if ($this->CI->session->userdata('logintype') != 1 && $this->CI->session->userdata('logintype') != 5) { |
|
119 | 119 | $new_Array=array('Trunk', 'trunk_id', 'SELECT', '', '', 'tOOL TIP', 'Please Enter account number', 'id', 'name', 'trunks', 'build_dropdown', 'where_arr', array("status" => "1")); |
120 | 120 | } |
121 | 121 | |
122 | 122 | $form['display_in']=array('name' => 'search_in',"id"=>"search_in","function"=>"search_report_in", "content"=>"Display records in ",'label_class' => "search_label col-md-3 no-padding","dropdown_class"=>"form-control","label_style"=>"font-size:13px;text-align:right;","dropdown_style"=>"background: #ddd; width: 23% !important;"); |
123 | 123 | |
124 | 124 | /****************************************/ |
125 | - $form['button_search'] = array('name' => 'action', 'id' => "reseller_cdr_search_btn", 'content' => 'Search', 'value' => 'save', 'type' => 'button', 'class' => 'btn btn-line-parrot pull-right'); |
|
126 | - $form['button_reset'] = array('name' => 'action', 'id' => "id_reset", 'content' => 'Clear', 'value' => 'cancel', 'type' => 'reset', 'class' => 'btn btn-line-sky pull-right margin-x-10'); |
|
125 | + $form['button_search'] = array('name' => 'action', 'id' => "reseller_cdr_search_btn", 'content' => 'Search', 'value' => 'save', 'type' => 'button', 'class' => 'btn btn-line-parrot pull-right'); |
|
126 | + $form['button_reset'] = array('name' => 'action', 'id' => "id_reset", 'content' => 'Clear', 'value' => 'cancel', 'type' => 'reset', 'class' => 'btn btn-line-sky pull-right margin-x-10'); |
|
127 | 127 | |
128 | - return $form; |
|
129 | - } |
|
128 | + return $form; |
|
129 | + } |
|
130 | 130 | |
131 | - function get_provider_cdr_form() { |
|
132 | - $form['forms'] = array("", array('id' => "cdr_provider_search")); |
|
133 | - $form['Search'] = array( |
|
134 | - array('From Date', 'INPUT', array('name' => 'callstart[]', 'id' => 'customer_cdr_from_date', 'size' => '20', 'class' => "text field "), '', 'tOOL TIP', '', 'number[number-string]'), |
|
135 | - array('To Date', 'INPUT', array('name' => 'callstart[]', 'id' => 'customer_cdr_to_date', 'size' => '20', 'class' => "text field "), '', 'tOOL TIP', '', 'number[number-string]'), |
|
136 | - array('Caller ID', 'INPUT', array('name' => 'callerid[callerid]', '', 'id' => 'first_name', 'size' => '15', 'class' => "text field "), '', 'tOOL TIP', '1', 'callerid[callerid-string]', '', '', '', 'search_string_type', ''), |
|
137 | - array('Called Number', 'INPUT', array('name' => 'callednum[callednum]', 'value' => '', 'size' => '20', 'class' => "text field "), '', 'Tool tips info', '1', 'callednum[callednum-string]', '', '', '', 'search_string_type', ''), |
|
138 | - array('Code ', 'INPUT', array('name' => 'pattern[pattern]', 'value' => '', 'size' => '20', 'class' => "text field "), '', 'Tool tips info', '1', 'pattern[pattern-string]', '', '', '', 'search_string_type', ''), |
|
139 | - array('Destination ', 'INPUT', array('name' => 'notes[notes]', 'value' => '', 'size' => '20', 'class' => "text field "), '', 'Tool tips info', '1', 'notes[notes-string]', '', '', '', 'search_string_type', ''), |
|
140 | - array('Duration', 'INPUT', array('name' => 'billseconds[billseconds]', 'value' => '', 'size' => '20', 'class' => "text field "), '', 'Tool tips info', '1', 'billseconds[billseconds-integer]', '', '', '', 'search_int_type', ''), |
|
141 | - array('Cost ', 'INPUT', array('name' => 'provider_call_cost[provider_call_cost]', 'value' => '', 'size' => '20', 'class' => "text field "), '', 'Tool tips info', '1', 'provider_call_cost[provider_call_cost-integer]', '', '', '', 'search_int_type', ''), |
|
131 | + function get_provider_cdr_form() { |
|
132 | + $form['forms'] = array("", array('id' => "cdr_provider_search")); |
|
133 | + $form['Search'] = array( |
|
134 | + array('From Date', 'INPUT', array('name' => 'callstart[]', 'id' => 'customer_cdr_from_date', 'size' => '20', 'class' => "text field "), '', 'tOOL TIP', '', 'number[number-string]'), |
|
135 | + array('To Date', 'INPUT', array('name' => 'callstart[]', 'id' => 'customer_cdr_to_date', 'size' => '20', 'class' => "text field "), '', 'tOOL TIP', '', 'number[number-string]'), |
|
136 | + array('Caller ID', 'INPUT', array('name' => 'callerid[callerid]', '', 'id' => 'first_name', 'size' => '15', 'class' => "text field "), '', 'tOOL TIP', '1', 'callerid[callerid-string]', '', '', '', 'search_string_type', ''), |
|
137 | + array('Called Number', 'INPUT', array('name' => 'callednum[callednum]', 'value' => '', 'size' => '20', 'class' => "text field "), '', 'Tool tips info', '1', 'callednum[callednum-string]', '', '', '', 'search_string_type', ''), |
|
138 | + array('Code ', 'INPUT', array('name' => 'pattern[pattern]', 'value' => '', 'size' => '20', 'class' => "text field "), '', 'Tool tips info', '1', 'pattern[pattern-string]', '', '', '', 'search_string_type', ''), |
|
139 | + array('Destination ', 'INPUT', array('name' => 'notes[notes]', 'value' => '', 'size' => '20', 'class' => "text field "), '', 'Tool tips info', '1', 'notes[notes-string]', '', '', '', 'search_string_type', ''), |
|
140 | + array('Duration', 'INPUT', array('name' => 'billseconds[billseconds]', 'value' => '', 'size' => '20', 'class' => "text field "), '', 'Tool tips info', '1', 'billseconds[billseconds-integer]', '', '', '', 'search_int_type', ''), |
|
141 | + array('Cost ', 'INPUT', array('name' => 'provider_call_cost[provider_call_cost]', 'value' => '', 'size' => '20', 'class' => "text field "), '', 'Tool tips info', '1', 'provider_call_cost[provider_call_cost-integer]', '', '', '', 'search_int_type', ''), |
|
142 | 142 | // array('Cost ', 'INPUT', array('name' => 'cost[cost]', 'value' => '', 'size' => '20', 'class' => "text field "), '', 'Tool tips info', '1', 'cost[cost-integer]', '', '', '', 'search_int_type', ''), |
143 | - array('Disposition', 'disposition', 'SELECT', '', '', 'tOOL TIP', 'Please Enter account number', '', '', '', 'set_despostion'), |
|
143 | + array('Disposition', 'disposition', 'SELECT', '', '', 'tOOL TIP', 'Please Enter account number', '', '', '', 'set_despostion'), |
|
144 | 144 | array('Account', 'provider_id', 'SELECT', '', '', 'tOOL TIP', 'Please Enter account number', 'id', 'IF(`deleted`=1,concat( first_name, " ", last_name, " ", "(", number, ")^" ),concat( first_name, " ", last_name, " ", "(", number, ")" )) as number', 'accounts', 'build_dropdown_deleted', 'where_arr', array("reseller_id" => "0","type"=>"3")), |
145 | - array('', 'HIDDEN', 'ajax_search', '1', '', '', ''),array('', 'HIDDEN', 'advance_search', '1', '', '', '') |
|
145 | + array('', 'HIDDEN', 'ajax_search', '1', '', '', ''),array('', 'HIDDEN', 'advance_search', '1', '', '', '') |
|
146 | 146 | |
147 | 147 | // array('Trunk', 'trunk_id', 'SELECT', '', '', 'tOOL TIP', 'Please Enter account number', 'id', 'name', 'trunks', 'build_dropdown', '', ''), |
148 | 148 | |
149 | 149 | |
150 | - ); |
|
150 | + ); |
|
151 | 151 | $form['display_in']=array('name' => 'search_in',"id"=>"search_in","function"=>"search_report_in", "content"=>"Display records in",'label_class' => "search_label col-md-3 no-padding","dropdown_class"=>"form-control","label_style"=>"font-size:13px;","dropdown_style"=>"background: #ddd; width: 21% !important;"); |
152 | 152 | |
153 | 153 | /****************************************/ |
154 | - $form['button_search'] = array('name' => 'action', 'id' => "provider_cdr_search_btn", 'content' => 'Search', 'value' => 'save', 'type' => 'button', 'class' => 'btn btn-line-parrot pull-right'); |
|
155 | - $form['button_reset'] = array('name' => 'action', 'id' => "id_reset", 'content' => 'Clear', 'value' => 'cancel', 'type' => 'reset', 'class' => 'btn btn-line-sky pull-right margin-x-10'); |
|
154 | + $form['button_search'] = array('name' => 'action', 'id' => "provider_cdr_search_btn", 'content' => 'Search', 'value' => 'save', 'type' => 'button', 'class' => 'btn btn-line-parrot pull-right'); |
|
155 | + $form['button_reset'] = array('name' => 'action', 'id' => "id_reset", 'content' => 'Clear', 'value' => 'cancel', 'type' => 'reset', 'class' => 'btn btn-line-sky pull-right margin-x-10'); |
|
156 | 156 | |
157 | - return $form; |
|
158 | - } |
|
157 | + return $form; |
|
158 | + } |
|
159 | 159 | |
160 | 160 | /****** |
161 | 161 | ASTPP 3.0 |
162 | 162 | Addrecording field in grid |
163 | 163 | ******/ |
164 | - function build_report_list_for_customer() { |
|
164 | + function build_report_list_for_customer() { |
|
165 | 165 | $logintype = $this->CI->session->userdata('userlevel_logintype'); |
166 | 166 | if($logintype != 1){ |
167 | 167 | $account_info = $accountinfo = $this->CI->session->userdata('accountinfo'); |
168 | 168 | $currency_id=$account_info['currency_id']; |
169 | 169 | $currency=$this->CI->common->get_field_name('currency', 'currency', $currency_id); |
170 | 170 | |
171 | - $recording=array(); |
|
172 | - $account_data = $this->CI->session->userdata("accountinfo"); |
|
173 | - if($account_data['type'] == 1){ |
|
174 | - $recording=array("Recording", "127", "recording", "", "", ""); |
|
175 | - } |
|
176 | - $grid_field_arr = json_encode(array( |
|
171 | + $recording=array(); |
|
172 | + $account_data = $this->CI->session->userdata("accountinfo"); |
|
173 | + if($account_data['type'] == 1){ |
|
174 | + $recording=array("Recording", "127", "recording", "", "", ""); |
|
175 | + } |
|
176 | + $grid_field_arr = json_encode(array( |
|
177 | 177 | array(gettext("Date"), "100", "callstart","callstart", "callstart", "convert_GMT_to","","true","center"), |
178 | 178 | array("Caller ID", "120", "callerid", "", "", "","","true","center"), |
179 | 179 | array("Called Number", "103", "callednum", "", "", "","","true","center"), |
@@ -184,14 +184,14 @@ discard block |
||
184 | 184 | array("Cost($currency)", "75", "cost", "cost", "cost", "convert_to_currency","","true","right"), |
185 | 185 | array("Disposition", "150", "disposition", "", "", "","","true","center"), |
186 | 186 | array("Account", "110", "accountid", "first_name,last_name,number", "accounts", "build_concat_string","","true","center"), |
187 | - array("Trunk", "90", "trunk_id", "name", "trunks", "get_field_name","","true","center"), |
|
187 | + array("Trunk", "90", "trunk_id", "name", "trunks", "get_field_name","","true","center"), |
|
188 | 188 | array("Rate Group", "90", "pricelist_id", "name", "pricelists", "get_field_name","","true","center"), |
189 | 189 | array("Call Type", "112", "calltype", "", "", ""), |
190 | - $recording, |
|
191 | - )); |
|
190 | + $recording, |
|
191 | + )); |
|
192 | 192 | |
193 | - } |
|
194 | - else{ |
|
193 | + } |
|
194 | + else{ |
|
195 | 195 | $account_info = $accountinfo = $this->CI->session->userdata('accountinfo'); |
196 | 196 | $currency_id=$account_info['currency_id']; |
197 | 197 | $currency=$this->CI->common->get_field_name('currency', 'currency', $currency_id); |
@@ -207,51 +207,51 @@ discard block |
||
207 | 207 | array("Cost($currency)", "75", "cost", "cost", "cost", "convert_to_currency","","true","right"), |
208 | 208 | array("Disposition", "130", "disposition", "", "", "","","true","center"), |
209 | 209 | array("Account", "110", "accountid", "first_name,last_name,number", "accounts", "build_concat_string","","true","center"), |
210 | - //array("Trunk", "90", "trunk_id", "name", "trunks", "get_field_name","","true","center"), |
|
210 | + //array("Trunk", "90", "trunk_id", "name", "trunks", "get_field_name","","true","center"), |
|
211 | 211 | array("Rate Group", "90", "pricelist_id", "name", "pricelists", "get_field_name","","true","center"), |
212 | 212 | array("Call Type", "112", "calltype", "", "", ""), |
213 | - $recording, |
|
214 | - )); |
|
213 | + $recording, |
|
214 | + )); |
|
215 | 215 | |
216 | - } |
|
216 | + } |
|
217 | 217 | |
218 | - return $grid_field_arr; |
|
219 | - } |
|
218 | + return $grid_field_arr; |
|
219 | + } |
|
220 | 220 | /******************************/ |
221 | 221 | |
222 | - function build_report_list_for_reseller() { |
|
222 | + function build_report_list_for_reseller() { |
|
223 | 223 | |
224 | 224 | $account_info = $accountinfo = $this->CI->session->userdata('accountinfo'); |
225 | 225 | $currency_id=$account_info['currency_id']; |
226 | 226 | $currency=$this->CI->common->get_field_name('currency', 'currency', $currency_id); |
227 | 227 | |
228 | - // array(display name, width, db_field_parent_table,feidname, db_field_child_table,function name); |
|
229 | - $grid_field_arr = json_encode(array( |
|
230 | - array("Date", "100", "callstart", "callstart", "callstart", "convert_GMT_to","","true","center"), |
|
231 | - array("Caller ID", "100", "callerid", "", "", "","","true","center"), |
|
232 | - array("Called Number", "120", "callednum", "", "", "","","true","center"), |
|
233 | - array("Code", "80", "pattern", "pattern", "", "get_only_numeric_val","","true","center"), |
|
234 | - array("Destination", "120", "notes", "", "", "","","true","center"), |
|
235 | - array("Duration", "107", "billseconds", "reseller_cdr_list_search", "billseconds", "convert_to_show_in","","true","center"), |
|
236 | - array("Debit($currency)", "105", "debit", "debit", "debit", "convert_to_currency","","true","right"), |
|
237 | - array("Cost($currency)", "104", "cost", "cost", "cost", "convert_to_currency","","true","right"), |
|
238 | - array("Disposition", "100", "disposition", "", "", "","","true","center"), |
|
239 | - array("Account", "120", "accountid", "first_name,last_name,number", "accounts", "build_concat_string","","true","center"), |
|
240 | - array("Rate Group", "90", "pricelist_id", "name", "pricelists", "get_field_name","","true","center"), |
|
241 | - array("Call Type", "120", "calltype", "", "", "","","true","center"), |
|
228 | + // array(display name, width, db_field_parent_table,feidname, db_field_child_table,function name); |
|
229 | + $grid_field_arr = json_encode(array( |
|
230 | + array("Date", "100", "callstart", "callstart", "callstart", "convert_GMT_to","","true","center"), |
|
231 | + array("Caller ID", "100", "callerid", "", "", "","","true","center"), |
|
232 | + array("Called Number", "120", "callednum", "", "", "","","true","center"), |
|
233 | + array("Code", "80", "pattern", "pattern", "", "get_only_numeric_val","","true","center"), |
|
234 | + array("Destination", "120", "notes", "", "", "","","true","center"), |
|
235 | + array("Duration", "107", "billseconds", "reseller_cdr_list_search", "billseconds", "convert_to_show_in","","true","center"), |
|
236 | + array("Debit($currency)", "105", "debit", "debit", "debit", "convert_to_currency","","true","right"), |
|
237 | + array("Cost($currency)", "104", "cost", "cost", "cost", "convert_to_currency","","true","right"), |
|
238 | + array("Disposition", "100", "disposition", "", "", "","","true","center"), |
|
239 | + array("Account", "120", "accountid", "first_name,last_name,number", "accounts", "build_concat_string","","true","center"), |
|
240 | + array("Rate Group", "90", "pricelist_id", "name", "pricelists", "get_field_name","","true","center"), |
|
241 | + array("Call Type", "120", "calltype", "", "", "","","true","center"), |
|
242 | 242 | |
243 | - )); |
|
244 | - return $grid_field_arr; |
|
245 | - } |
|
243 | + )); |
|
244 | + return $grid_field_arr; |
|
245 | + } |
|
246 | 246 | |
247 | - function build_report_list_for_provider() { |
|
247 | + function build_report_list_for_provider() { |
|
248 | 248 | |
249 | 249 | $account_info = $accountinfo = $this->CI->session->userdata('accountinfo'); |
250 | 250 | $currency_id=$account_info['currency_id']; |
251 | 251 | $currency=$this->CI->common->get_field_name('currency', 'currency', $currency_id); |
252 | 252 | |
253 | - // array(display name, width, db_field_parent_table,feidname, db_field_child_table,function name); |
|
254 | - $grid_field_arr = json_encode(array(array("Date", "100", "callstart", "callstart", "callstart", "convert_GMT_to","","true","center"), |
|
253 | + // array(display name, width, db_field_parent_table,feidname, db_field_child_table,function name); |
|
254 | + $grid_field_arr = json_encode(array(array("Date", "100", "callstart", "callstart", "callstart", "convert_GMT_to","","true","center"), |
|
255 | 255 | array("Caller ID", "120", "callerid", "", "", "","","true","center"), |
256 | 256 | array("Called Number", "160", "callednum", "", "", "","","true","center"), |
257 | 257 | array("Code", "117", "pattern", "pattern", "", "get_only_numeric_val","","true","center"), |
@@ -260,356 +260,356 @@ discard block |
||
260 | 260 | array("Cost($currency)", "150", "provider_call_cost", "provider_cost", "provider_cost", "convert_to_currency","","true","right"), |
261 | 261 | array("Disposition", "200", "disposition", "", "", "","","true","center"), |
262 | 262 | array("Account", "181", "provider_id", "first_name,last_name,number", "accounts", "build_concat_string","","true","center"), |
263 | - )); |
|
264 | - return $grid_field_arr; |
|
265 | - } |
|
263 | + )); |
|
264 | + return $grid_field_arr; |
|
265 | + } |
|
266 | 266 | |
267 | - function build_grid_customer() { |
|
268 | - $buttons_json = json_encode(array(array("Export","btn btn-xing" ," fa fa-download fa-lg", "button_action", "/reports/customerReport_export/", 'single'))); |
|
269 | - return $buttons_json; |
|
270 | - } |
|
267 | + function build_grid_customer() { |
|
268 | + $buttons_json = json_encode(array(array("Export","btn btn-xing" ," fa fa-download fa-lg", "button_action", "/reports/customerReport_export/", 'single'))); |
|
269 | + return $buttons_json; |
|
270 | + } |
|
271 | 271 | /** |
272 | 272 | ASTPP 3.0 |
273 | 273 | For Customer CDRs export |
274 | 274 | **/ |
275 | 275 | |
276 | - function build_grid_buttons_user() { |
|
277 | - $buttons_json = json_encode(array(array("Export","btn btn-xing" ," fa fa-download fa-lg", "button_action", "/user/user_report_export/", 'single'))); |
|
278 | - return $buttons_json; |
|
279 | - } |
|
276 | + function build_grid_buttons_user() { |
|
277 | + $buttons_json = json_encode(array(array("Export","btn btn-xing" ," fa fa-download fa-lg", "button_action", "/user/user_report_export/", 'single'))); |
|
278 | + return $buttons_json; |
|
279 | + } |
|
280 | 280 | /*****************************************************************/ |
281 | - function build_grid_buttons_reseller() { |
|
282 | - $buttons_json = json_encode(array( array("Export","btn btn-xing" ," fa fa-download fa-lg", "button_action", "/reports/resellerReport_export/", 'single'))); |
|
283 | - return $buttons_json; |
|
284 | - } |
|
285 | - function build_grid_buttons_provider() { |
|
286 | - $buttons_json = json_encode(array(array("Export","btn btn-xing" ," fa fa-download fa-lg", "button_action", "/reports/providerReport_export/", 'single'))); |
|
287 | - return $buttons_json; |
|
288 | - } |
|
281 | + function build_grid_buttons_reseller() { |
|
282 | + $buttons_json = json_encode(array( array("Export","btn btn-xing" ," fa fa-download fa-lg", "button_action", "/reports/resellerReport_export/", 'single'))); |
|
283 | + return $buttons_json; |
|
284 | + } |
|
285 | + function build_grid_buttons_provider() { |
|
286 | + $buttons_json = json_encode(array(array("Export","btn btn-xing" ," fa fa-download fa-lg", "button_action", "/reports/providerReport_export/", 'single'))); |
|
287 | + return $buttons_json; |
|
288 | + } |
|
289 | 289 | |
290 | - function build_report_list_for_user($accounttype = 'customer') { |
|
290 | + function build_report_list_for_user($accounttype = 'customer') { |
|
291 | 291 | |
292 | 292 | $account_info = $accountinfo = $this->CI->session->userdata('accountinfo'); |
293 | 293 | $currency_id=$account_info['currency_id']; |
294 | 294 | $currency=$this->CI->common->get_field_name('currency', 'currency', $currency_id); |
295 | 295 | |
296 | 296 | |
297 | - if($accounttype == 'customer' || $accounttype =='reseller'){ |
|
298 | - $cost_array=array("Debit($currency)", "100", "debit", "debit", "debit", "convert_to_currency","","true","right"); |
|
299 | - } |
|
300 | - if(strtolower($accounttype)=='provider'){ |
|
301 | - $cost_array=array("Debit($currency)", "140", "cost", "cost", "cost", "convert_to_currency"); |
|
302 | - } |
|
303 | - // array(display name, width, db_field_parent_table,feidname, db_field_child_table,function name); |
|
304 | - $grid_field_arr = json_encode(array( |
|
305 | - array("Date", "130", "callstart", "callstart", "callstart", "convert_GMT_to","","true","center"), |
|
306 | - array("Caller ID", "100", "callerid", "", "", "","","true","center"), |
|
307 | - array("Called Number", "120", "callednum", "", "", "","","true","center"), |
|
308 | - array("Destination", "135", "notes", "", "", "","","true","center"), |
|
297 | + if($accounttype == 'customer' || $accounttype =='reseller'){ |
|
298 | + $cost_array=array("Debit($currency)", "100", "debit", "debit", "debit", "convert_to_currency","","true","right"); |
|
299 | + } |
|
300 | + if(strtolower($accounttype)=='provider'){ |
|
301 | + $cost_array=array("Debit($currency)", "140", "cost", "cost", "cost", "convert_to_currency"); |
|
302 | + } |
|
303 | + // array(display name, width, db_field_parent_table,feidname, db_field_child_table,function name); |
|
304 | + $grid_field_arr = json_encode(array( |
|
305 | + array("Date", "130", "callstart", "callstart", "callstart", "convert_GMT_to","","true","center"), |
|
306 | + array("Caller ID", "100", "callerid", "", "", "","","true","center"), |
|
307 | + array("Called Number", "120", "callednum", "", "", "","","true","center"), |
|
308 | + array("Destination", "135", "notes", "", "", "","","true","center"), |
|
309 | 309 | // array("Account Number", "120", "accountid", "number", "accounts", "get_field_name"), |
310 | - array("Duration", "120", "billseconds", "user_cdrs_report_search", "billseconds", "convert_to_show_in","","true","center"), |
|
311 | - $cost_array, |
|
312 | - array("Disposition", "160", "disposition", "", "", "","","true","center"), |
|
313 | - array("Call Type", "140", "calltype", "", "", "","","true","center"), |
|
314 | - )); |
|
315 | - return $grid_field_arr; |
|
316 | - } |
|
310 | + array("Duration", "120", "billseconds", "user_cdrs_report_search", "billseconds", "convert_to_show_in","","true","center"), |
|
311 | + $cost_array, |
|
312 | + array("Disposition", "160", "disposition", "", "", "","","true","center"), |
|
313 | + array("Call Type", "140", "calltype", "", "", "","","true","center"), |
|
314 | + )); |
|
315 | + return $grid_field_arr; |
|
316 | + } |
|
317 | 317 | |
318 | 318 | /****** |
319 | 319 | ASTPP 3.0 |
320 | 320 | Payment to refill |
321 | 321 | ******/ |
322 | - function build_refill_report_for_admin() { |
|
322 | + function build_refill_report_for_admin() { |
|
323 | 323 | |
324 | 324 | $account_info = $accountinfo = $this->CI->session->userdata('accountinfo'); |
325 | - $currency_id=$account_info['currency_id']; |
|
326 | - $currency=$this->CI->common->get_field_name('currency', 'currency', $currency_id); |
|
327 | - $grid_field_arr = json_encode(array( |
|
328 | - array(gettext("Date"), "225", "payment_date", "", "", "","","true","center"), |
|
329 | - array(gettext("Account"), "240", "accountid", "first_name,last_name,number", "accounts", "build_concat_string","","true","center"), |
|
330 | - array("Amount($currency)", "250", "credit", "credit", "credit", "convert_to_currency","","true","right"), |
|
331 | - array(gettext("Refill By"), "230", "payment_by", "payment_by", "payment_by", "get_refill_by","","true","center"), |
|
332 | - array(gettext("Note"), "327", "notes", "", "", "","","true","center") |
|
333 | - )); |
|
334 | - return $grid_field_arr; |
|
335 | - } |
|
336 | - function build_refillreport_buttons() { |
|
337 | - $buttons_json = json_encode(array(array("Export","btn btn-xing" ," fa fa-download fa-lg", "button_action", "/reports/refillreport_export/", 'single'))); |
|
338 | - return $buttons_json; |
|
339 | - } |
|
340 | - function build_search_refill_report_for_admin() { |
|
341 | - $accountinfo=$this->CI->session->userdata('accountinfo'); |
|
342 | - $reseller_id=$accountinfo['type']==1 ? $accountinfo['id'] : 0 ; |
|
343 | - $form['forms'] = array("", array('id' => "cdr_refill_search")); |
|
344 | - $account_data = $this->CI->session->userdata("accountinfo"); |
|
345 | - $acc_arr= array('Account', 'accountid', 'SELECT', '', '', 'tOOL TIP', 'Please Enter account number', 'id', 'IF(`deleted`=1,concat( first_name, " ", last_name, " ", "(", number, ")^" ),concat( first_name, " ", last_name, " ", "(", number, ")" )) as number', 'accounts', 'build_dropdown_deleted', 'where_arr', array("reseller_id" => $reseller_id,"type"=>"0,1,3")); |
|
346 | - $logintype = $this->CI->session->userdata('logintype'); |
|
347 | - if ($logintype == 1 || $logintype == 5) { |
|
348 | - $account_data = $this->CI->session->userdata("accountinfo"); |
|
349 | - $loginid = $account_data['id']; |
|
325 | + $currency_id=$account_info['currency_id']; |
|
326 | + $currency=$this->CI->common->get_field_name('currency', 'currency', $currency_id); |
|
327 | + $grid_field_arr = json_encode(array( |
|
328 | + array(gettext("Date"), "225", "payment_date", "", "", "","","true","center"), |
|
329 | + array(gettext("Account"), "240", "accountid", "first_name,last_name,number", "accounts", "build_concat_string","","true","center"), |
|
330 | + array("Amount($currency)", "250", "credit", "credit", "credit", "convert_to_currency","","true","right"), |
|
331 | + array(gettext("Refill By"), "230", "payment_by", "payment_by", "payment_by", "get_refill_by","","true","center"), |
|
332 | + array(gettext("Note"), "327", "notes", "", "", "","","true","center") |
|
333 | + )); |
|
334 | + return $grid_field_arr; |
|
335 | + } |
|
336 | + function build_refillreport_buttons() { |
|
337 | + $buttons_json = json_encode(array(array("Export","btn btn-xing" ," fa fa-download fa-lg", "button_action", "/reports/refillreport_export/", 'single'))); |
|
338 | + return $buttons_json; |
|
339 | + } |
|
340 | + function build_search_refill_report_for_admin() { |
|
341 | + $accountinfo=$this->CI->session->userdata('accountinfo'); |
|
342 | + $reseller_id=$accountinfo['type']==1 ? $accountinfo['id'] : 0 ; |
|
343 | + $form['forms'] = array("", array('id' => "cdr_refill_search")); |
|
344 | + $account_data = $this->CI->session->userdata("accountinfo"); |
|
345 | + $acc_arr= array('Account', 'accountid', 'SELECT', '', '', 'tOOL TIP', 'Please Enter account number', 'id', 'IF(`deleted`=1,concat( first_name, " ", last_name, " ", "(", number, ")^" ),concat( first_name, " ", last_name, " ", "(", number, ")" )) as number', 'accounts', 'build_dropdown_deleted', 'where_arr', array("reseller_id" => $reseller_id,"type"=>"0,1,3")); |
|
346 | + $logintype = $this->CI->session->userdata('logintype'); |
|
347 | + if ($logintype == 1 || $logintype == 5) { |
|
348 | + $account_data = $this->CI->session->userdata("accountinfo"); |
|
349 | + $loginid = $account_data['id']; |
|
350 | 350 | |
351 | - }else{ |
|
352 | - $loginid = "0"; |
|
353 | - } |
|
354 | - if($logintype==0 || $logintype==3){ |
|
355 | - $acc_arr=null; |
|
356 | - } |
|
357 | - $form['Search'] = array( |
|
358 | - array('From Date', 'INPUT', array('name' => 'payment_date[]', 'id' => 'refill_from_date', 'size' => '20', |
|
351 | + }else{ |
|
352 | + $loginid = "0"; |
|
353 | + } |
|
354 | + if($logintype==0 || $logintype==3){ |
|
355 | + $acc_arr=null; |
|
356 | + } |
|
357 | + $form['Search'] = array( |
|
358 | + array('From Date', 'INPUT', array('name' => 'payment_date[]', 'id' => 'refill_from_date', 'size' => '20', |
|
359 | 359 | 'class' => "text field "), '', 'tOOL TIP', '', 'payment_date[payment_date-date]'), |
360 | - array('To Date', 'INPUT', array('name' => 'payment_date[]', 'id' => 'refill_to_date', 'size' => '20', 'class' => "text field "), '', 'tOOL TIP', '', 'payment_date[payment_date-date]'), |
|
361 | - $acc_arr, |
|
360 | + array('To Date', 'INPUT', array('name' => 'payment_date[]', 'id' => 'refill_to_date', 'size' => '20', 'class' => "text field "), '', 'tOOL TIP', '', 'payment_date[payment_date-date]'), |
|
361 | + $acc_arr, |
|
362 | 362 | // array('Account', 'accountid', 'SELECT', '', '', 'tOOL TIP', 'Please Enter account number', 'id', 'first_name,last_name,number', 'accounts', 'build_concat_dropdown', 'where_arr', array("reseller_id" => "0","type"=>"0")), |
363 | - array('Amount ', 'INPUT', array('name' => 'credit[credit]', 'value' => '', 'size' => '20', 'class' => "text field"), '', 'Tool tips info', '1', 'credit[credit-integer]', '', '', '', 'search_int_type', ''), |
|
364 | - // array('', 'HIDDEN', 'ajax_search', '1', '', '', ''),array('', 'HIDDEN', 'advance_search', '1', '', '', ''), |
|
365 | - array('', 'HIDDEN', 'ajax_search', '1', '', '', ''),array('', 'HIDDEN', 'advance_search', '1', '', '', '')); |
|
363 | + array('Amount ', 'INPUT', array('name' => 'credit[credit]', 'value' => '', 'size' => '20', 'class' => "text field"), '', 'Tool tips info', '1', 'credit[credit-integer]', '', '', '', 'search_int_type', ''), |
|
364 | + // array('', 'HIDDEN', 'ajax_search', '1', '', '', ''),array('', 'HIDDEN', 'advance_search', '1', '', '', ''), |
|
365 | + array('', 'HIDDEN', 'ajax_search', '1', '', '', ''),array('', 'HIDDEN', 'advance_search', '1', '', '', '')); |
|
366 | 366 | |
367 | - $form['button_search'] = array('name' => 'action', 'id' => "cusotmer_cdr_refill_search_btn", 'content' => 'Search', 'value' => 'save', 'type' => 'button', 'class' => 'btn btn-line-parrot pull-right'); |
|
368 | - $form['button_reset'] = array('name' => 'action', 'id' => "id_reset", 'content' => 'Clear', 'value' => 'cancel', 'type' => 'reset', 'class' => 'btn btn-line-sky pull-right margin-x-10'); |
|
367 | + $form['button_search'] = array('name' => 'action', 'id' => "cusotmer_cdr_refill_search_btn", 'content' => 'Search', 'value' => 'save', 'type' => 'button', 'class' => 'btn btn-line-parrot pull-right'); |
|
368 | + $form['button_reset'] = array('name' => 'action', 'id' => "id_reset", 'content' => 'Clear', 'value' => 'cancel', 'type' => 'reset', 'class' => 'btn btn-line-sky pull-right margin-x-10'); |
|
369 | 369 | //echo '<pre>'; print_r($form); exit; |
370 | - return $form; |
|
371 | - } |
|
370 | + return $form; |
|
371 | + } |
|
372 | 372 | /***************************/ |
373 | - function build_commission_report_for_admin() { |
|
374 | - $grid_field_arr = json_encode(array( |
|
375 | - array("Account", "150", "accountid", "first_name,last_name,number", "accounts", "build_concat_string"), |
|
376 | - array("Amount", "150", "amount", "credit", "credit", "convert_to_currency"), |
|
377 | - array("Description", "150", "description", "", "", ""), |
|
378 | - array("Reseller", "150", "reseller_id", "first_name,last_name,number", "accounts", "build_concat_string"), |
|
379 | - array("Commission Rate(%)", "150", "commission_percent", "", "", ""), |
|
380 | - array("Date", "150", "date", "", "", "") |
|
381 | - )); |
|
382 | - return $grid_field_arr; |
|
383 | - } |
|
384 | - function reseller_commission_search_form() { |
|
385 | - $form['forms'] = array("", array('id' => "reseller_commission_search")); |
|
373 | + function build_commission_report_for_admin() { |
|
374 | + $grid_field_arr = json_encode(array( |
|
375 | + array("Account", "150", "accountid", "first_name,last_name,number", "accounts", "build_concat_string"), |
|
376 | + array("Amount", "150", "amount", "credit", "credit", "convert_to_currency"), |
|
377 | + array("Description", "150", "description", "", "", ""), |
|
378 | + array("Reseller", "150", "reseller_id", "first_name,last_name,number", "accounts", "build_concat_string"), |
|
379 | + array("Commission Rate(%)", "150", "commission_percent", "", "", ""), |
|
380 | + array("Date", "150", "date", "", "", "") |
|
381 | + )); |
|
382 | + return $grid_field_arr; |
|
383 | + } |
|
384 | + function reseller_commission_search_form() { |
|
385 | + $form['forms'] = array("", array('id' => "reseller_commission_search")); |
|
386 | 386 | /****** |
387 | 387 | ASTPP 3.0 |
388 | 388 | Payment to refill |
389 | 389 | ******/ |
390 | - $form['User Refill Report'] = array( |
|
390 | + $form['User Refill Report'] = array( |
|
391 | 391 | /*************************/ |
392 | - array('', 'HIDDEN', 'ajax_search', '1', '', '', ''), |
|
393 | - array('', 'HIDDEN', 'advance_search', '1', '', '', ''), |
|
394 | - array('From Date', 'INPUT', array('name' => 'date[]', 'id' => 'commission_from_date', 'size' => '20', 'class' => "text field "), '', 'tOOL TIP', '', 'start_date[start_date-date]'), |
|
395 | - array('To Date', 'INPUT', array('name' => 'date[]', 'id' => 'commission_to_date', 'size' => '20', 'class' => "text field "), '', 'tOOL TIP', '', 'end_date[end_date-date]'), |
|
396 | - array('Account', 'accountid', 'SELECT', '', '', 'tOOL TIP', 'Please Enter account number', 'id', 'first_name,last_name,number', 'accounts', 'build_concat_dropdown', 'where_arr', array("reseller_id" => "0","type"=>"1", "deleted" => "0")), |
|
397 | - array('Amount', 'INPUT', array('name' => 'amount[amount]', 'value' => '', 'size' => '20', 'class' => "text field"), '', 'Tool tips info', '1', 'amount[amount-integer]', '', '', '', 'search_int_type', ''), |
|
398 | - ); |
|
392 | + array('', 'HIDDEN', 'ajax_search', '1', '', '', ''), |
|
393 | + array('', 'HIDDEN', 'advance_search', '1', '', '', ''), |
|
394 | + array('From Date', 'INPUT', array('name' => 'date[]', 'id' => 'commission_from_date', 'size' => '20', 'class' => "text field "), '', 'tOOL TIP', '', 'start_date[start_date-date]'), |
|
395 | + array('To Date', 'INPUT', array('name' => 'date[]', 'id' => 'commission_to_date', 'size' => '20', 'class' => "text field "), '', 'tOOL TIP', '', 'end_date[end_date-date]'), |
|
396 | + array('Account', 'accountid', 'SELECT', '', '', 'tOOL TIP', 'Please Enter account number', 'id', 'first_name,last_name,number', 'accounts', 'build_concat_dropdown', 'where_arr', array("reseller_id" => "0","type"=>"1", "deleted" => "0")), |
|
397 | + array('Amount', 'INPUT', array('name' => 'amount[amount]', 'value' => '', 'size' => '20', 'class' => "text field"), '', 'Tool tips info', '1', 'amount[amount-integer]', '', '', '', 'search_int_type', ''), |
|
398 | + ); |
|
399 | 399 | |
400 | - $form['button_search'] = array('name' => 'action', 'id' => "commission_search_btn", 'content' => 'Search', 'value' => 'save', 'type' => 'button', 'class' => 'ui-state-default float-right ui-corner-all ui-button'); |
|
401 | - $form['button_reset'] = array('name' => 'action', 'id' => "id_reset", 'content' => 'Clear Search Filter', 'value' => 'cancel', 'type' => 'reset', 'class' => 'ui-state-default float-right ui-corner-all ui-button'); |
|
400 | + $form['button_search'] = array('name' => 'action', 'id' => "commission_search_btn", 'content' => 'Search', 'value' => 'save', 'type' => 'button', 'class' => 'ui-state-default float-right ui-corner-all ui-button'); |
|
401 | + $form['button_reset'] = array('name' => 'action', 'id' => "id_reset", 'content' => 'Clear Search Filter', 'value' => 'cancel', 'type' => 'reset', 'class' => 'ui-state-default float-right ui-corner-all ui-button'); |
|
402 | 402 | |
403 | - return $form; |
|
404 | - } |
|
405 | - function get_providersummary_search_form() { |
|
406 | - $form['forms'] = array('', array('id' => "providersummary_search")); |
|
407 | - $form['Search'] = array( |
|
403 | + return $form; |
|
404 | + } |
|
405 | + function get_providersummary_search_form() { |
|
406 | + $form['forms'] = array('', array('id' => "providersummary_search")); |
|
407 | + $form['Search'] = array( |
|
408 | 408 | array('From Date', 'INPUT', array('name' => 'callstart[]', 'id' => 'customer_from_date', 'size' => '20', 'class' => "text field "), '', 'tOOL TIP', '', 'start_date[start_date-date]'), |
409 | - array('To Date', 'INPUT', array('name' => 'callstart[]', 'id' => 'customer_to_date', 'size' => '20', 'class' => "text field "), '', 'tOOL TIP', '', 'end_date[end_date-date]'), |
|
410 | - array('Account', 'provider_id', 'SELECT', '', '', 'tOOL TIP', 'Please Enter account number', 'id', 'IF(`deleted`=1,concat( first_name, " ", last_name, " ", "(", number, ")^" ),concat( first_name, " ", last_name, " ", "(", number, ")" )) as number', 'accounts', 'build_dropdown_deleted', 'where_arr', array("reseller_id" => "0","type"=>"3")), |
|
411 | - array('Code ', 'INPUT', array('name' => 'pattern[pattern]', 'value' => '', 'size' => '20', 'class' => "text field "), '', 'Tool tips info', '1', 'pattern[pattern-string]', '', '', '', 'search_string_type', ''), |
|
409 | + array('To Date', 'INPUT', array('name' => 'callstart[]', 'id' => 'customer_to_date', 'size' => '20', 'class' => "text field "), '', 'tOOL TIP', '', 'end_date[end_date-date]'), |
|
410 | + array('Account', 'provider_id', 'SELECT', '', '', 'tOOL TIP', 'Please Enter account number', 'id', 'IF(`deleted`=1,concat( first_name, " ", last_name, " ", "(", number, ")^" ),concat( first_name, " ", last_name, " ", "(", number, ")" )) as number', 'accounts', 'build_dropdown_deleted', 'where_arr', array("reseller_id" => "0","type"=>"3")), |
|
411 | + array('Code ', 'INPUT', array('name' => 'pattern[pattern]', 'value' => '', 'size' => '20', 'class' => "text field "), '', 'Tool tips info', '1', 'pattern[pattern-string]', '', '', '', 'search_string_type', ''), |
|
412 | 412 | |
413 | - array('Destination ', 'INPUT', array('name' => 'notes[notes]', 'value' => '', 'size' => '20', 'class' => "text field "), '', 'Tool tips info', '1', 'notes[notes-string]', '', '', '', 'search_string_type', ''), |
|
413 | + array('Destination ', 'INPUT', array('name' => 'notes[notes]', 'value' => '', 'size' => '20', 'class' => "text field "), '', 'Tool tips info', '1', 'notes[notes-string]', '', '', '', 'search_string_type', ''), |
|
414 | 414 | // array('Account Number', 'number', 'SELECT', '', '', 'tOOL TIP', 'Please Enter account number', 'id', 'first_name,last_name,number', 'accounts', 'build_concat_dropdown', 'where_arr', array("type"=>"3", "deleted" => "0")), |
415 | - array('', 'HIDDEN', 'ajax_search', '1', '', '', ''), |
|
416 | - array('', 'HIDDEN', 'advance_search', '1', '', '', '')); |
|
417 | - $form['button_search'] = array('name' => 'action', 'id' => "providersummary_search_btn", 'content' => 'Search', 'value' => 'save', 'type' => 'button', 'class' => 'btn btn-line-parrot pull-right'); |
|
418 | - $form['button_reset'] = array('name' => 'action', 'id' => "id_reset", 'content' => 'Clear', 'value' => 'cancel', 'type' => 'reset', 'class' => 'btn btn-line-sky pull-right margin-x-10'); |
|
415 | + array('', 'HIDDEN', 'ajax_search', '1', '', '', ''), |
|
416 | + array('', 'HIDDEN', 'advance_search', '1', '', '', '')); |
|
417 | + $form['button_search'] = array('name' => 'action', 'id' => "providersummary_search_btn", 'content' => 'Search', 'value' => 'save', 'type' => 'button', 'class' => 'btn btn-line-parrot pull-right'); |
|
418 | + $form['button_reset'] = array('name' => 'action', 'id' => "id_reset", 'content' => 'Clear', 'value' => 'cancel', 'type' => 'reset', 'class' => 'btn btn-line-sky pull-right margin-x-10'); |
|
419 | 419 | |
420 | - return $form; |
|
421 | - } |
|
422 | - function build_providersummary(){ |
|
423 | - $grid_field_arr = json_encode(array( |
|
424 | - array("Provider", "220", "provider_id", "first_name,last_name,number", "accounts", "build_concat_string"), |
|
425 | - array("Code", "120", "pattern", "pattern", "", "get_only_numeric_val"), |
|
426 | - array("Destination", "150", "notes", "", "", ""), |
|
427 | - array("Attempted Calls", "130", "attempted_calls", "", "", ""), |
|
428 | - array("Completed Calls", "150", "description", "", "", ""), |
|
429 | - array("ASR","95","asr",'','',''), |
|
430 | - array("ACD","95","acd ",'','',''), |
|
431 | - array("MCD","95","mcd",'','',''), |
|
432 | - array("Bilable","100","billable",'','',''), |
|
433 | - array("Cost","115","cost",'','',''), |
|
420 | + return $form; |
|
421 | + } |
|
422 | + function build_providersummary(){ |
|
423 | + $grid_field_arr = json_encode(array( |
|
424 | + array("Provider", "220", "provider_id", "first_name,last_name,number", "accounts", "build_concat_string"), |
|
425 | + array("Code", "120", "pattern", "pattern", "", "get_only_numeric_val"), |
|
426 | + array("Destination", "150", "notes", "", "", ""), |
|
427 | + array("Attempted Calls", "130", "attempted_calls", "", "", ""), |
|
428 | + array("Completed Calls", "150", "description", "", "", ""), |
|
429 | + array("ASR","95","asr",'','',''), |
|
430 | + array("ACD","95","acd ",'','',''), |
|
431 | + array("MCD","95","mcd",'','',''), |
|
432 | + array("Bilable","100","billable",'','',''), |
|
433 | + array("Cost","115","cost",'','',''), |
|
434 | 434 | // array("Profit", "95", "profit", "", "", ""), |
435 | - )); |
|
436 | - return $grid_field_arr; |
|
437 | - } |
|
438 | - function build_grid_buttons_providersummary() { |
|
439 | - $buttons_json = json_encode(array(array("Export","btn btn-xing" ," fa fa-download fa-lg", "button_action", "/reports/providersummary_export_cdr_xls", 'single'))); |
|
440 | - return $buttons_json; |
|
441 | - } |
|
442 | - function get_resellersummary_search_form() { |
|
443 | - $form['forms'] = array("",array('id' => "resellersummary_search")); |
|
444 | - $form['Search'] = array( |
|
445 | - array('From Date', 'INPUT', array('name' => 'callstart[]', 'id' => 'customer_from_date', 'size' => '20', 'class' => "text field "), '', 'tOOL TIP', '', 'start_date[start_date-date]'), |
|
446 | - array('To Date', 'INPUT', array('name' => 'callstart[]', 'id' => 'customer_to_date', 'size' => '20', 'class' => "text field "), '', 'tOOL TIP', '', 'end_date[end_date-date]'), |
|
447 | - array('Account', 'reseller_id', 'SELECT', '', '', 'tOOL TIP', 'Please Enter account number', 'id', 'IF(`deleted`=1,concat( first_name, " ", last_name, " ", "(", number, ")^" ),concat( first_name, " ", last_name, " ", "(", number, ")" )) as number', 'accounts', 'build_dropdown_deleted', 'where_arr', array("reseller_id" => "0","type"=>"1")), |
|
448 | - array('Code ', 'INPUT', array('name' => 'pattern[pattern]', 'value' => '', 'size' => '20', 'class' => "text field "), '', 'Tool tips info', '1', 'pattern[pattern-string]', '', '', '', 'search_string_type', ''), |
|
435 | + )); |
|
436 | + return $grid_field_arr; |
|
437 | + } |
|
438 | + function build_grid_buttons_providersummary() { |
|
439 | + $buttons_json = json_encode(array(array("Export","btn btn-xing" ," fa fa-download fa-lg", "button_action", "/reports/providersummary_export_cdr_xls", 'single'))); |
|
440 | + return $buttons_json; |
|
441 | + } |
|
442 | + function get_resellersummary_search_form() { |
|
443 | + $form['forms'] = array("",array('id' => "resellersummary_search")); |
|
444 | + $form['Search'] = array( |
|
445 | + array('From Date', 'INPUT', array('name' => 'callstart[]', 'id' => 'customer_from_date', 'size' => '20', 'class' => "text field "), '', 'tOOL TIP', '', 'start_date[start_date-date]'), |
|
446 | + array('To Date', 'INPUT', array('name' => 'callstart[]', 'id' => 'customer_to_date', 'size' => '20', 'class' => "text field "), '', 'tOOL TIP', '', 'end_date[end_date-date]'), |
|
447 | + array('Account', 'reseller_id', 'SELECT', '', '', 'tOOL TIP', 'Please Enter account number', 'id', 'IF(`deleted`=1,concat( first_name, " ", last_name, " ", "(", number, ")^" ),concat( first_name, " ", last_name, " ", "(", number, ")" )) as number', 'accounts', 'build_dropdown_deleted', 'where_arr', array("reseller_id" => "0","type"=>"1")), |
|
448 | + array('Code ', 'INPUT', array('name' => 'pattern[pattern]', 'value' => '', 'size' => '20', 'class' => "text field "), '', 'Tool tips info', '1', 'pattern[pattern-string]', '', '', '', 'search_string_type', ''), |
|
449 | 449 | |
450 | - array('Destination ', 'INPUT', array('name' => 'notes[notes]', 'value' => '', 'size' => '20', 'class' => "text field "), '', 'Tool tips info', '1', 'notes[notes-string]', '', '', '', 'search_string_type', ''), |
|
451 | - // array('Account Number', 'number', 'SELECT', '', '', 'tOOL TIP', 'Please Enter account number', 'id', 'first_name,last_name,number', 'accounts', 'build_concat_dropdown', 'where_arr', array("type"=>"1", "deleted" => "0")), |
|
450 | + array('Destination ', 'INPUT', array('name' => 'notes[notes]', 'value' => '', 'size' => '20', 'class' => "text field "), '', 'Tool tips info', '1', 'notes[notes-string]', '', '', '', 'search_string_type', ''), |
|
451 | + // array('Account Number', 'number', 'SELECT', '', '', 'tOOL TIP', 'Please Enter account number', 'id', 'first_name,last_name,number', 'accounts', 'build_concat_dropdown', 'where_arr', array("type"=>"1", "deleted" => "0")), |
|
452 | 452 | array('', 'HIDDEN', 'ajax_search', '1', '', '', ''),array('', 'HIDDEN', 'advance_search', '1', '', '', '')); |
453 | - $form['button_search'] = array('name' => 'action', 'id' => "resellersummary_search_btn", 'content' => 'Search', 'value' => 'save', 'type' => 'button', 'class' => 'btn btn-line-parrot pull-right'); |
|
454 | - $form['button_reset'] = array('name' => 'action', 'id' => "id_reset", 'content' => 'Clear', 'value' => 'cancel', 'type' => 'reset', 'class' => 'btn btn-line-sky pull-right margin-x-10'); |
|
453 | + $form['button_search'] = array('name' => 'action', 'id' => "resellersummary_search_btn", 'content' => 'Search', 'value' => 'save', 'type' => 'button', 'class' => 'btn btn-line-parrot pull-right'); |
|
454 | + $form['button_reset'] = array('name' => 'action', 'id' => "id_reset", 'content' => 'Clear', 'value' => 'cancel', 'type' => 'reset', 'class' => 'btn btn-line-sky pull-right margin-x-10'); |
|
455 | 455 | |
456 | - return $form; |
|
457 | - } |
|
458 | - function build_resellersummary(){ |
|
459 | - $grid_field_arr = json_encode(array( |
|
460 | - array("Account", "148", "accountid", "first_name,last_name,number", "accounts", "build_concat_string"), |
|
461 | - array("Code", "120", "pattern", "pattern", "", "get_only_numeric_val"), |
|
462 | - array("Destination", "150", "notes", "", "", ""), |
|
463 | - array("Attempted Calls", "120", "attempted_calls", "", "", ""), |
|
464 | - array("Completed Calls", "120", "description", "", "", ""), |
|
465 | - array("ASR","80","asr",'','',''), |
|
466 | - array("ACD","80","acd ",'','',''), |
|
467 | - array("MCD","80","mcd",'','',''), |
|
468 | - array("Bilable","90","billable",'','',''), |
|
469 | - array("Price","90","price",'','',''), |
|
470 | - array("Cost","90","cost",'','',''), |
|
471 | - array("Profit", "100", "profit", "", "", ""), |
|
472 | - )); |
|
473 | - return $grid_field_arr; |
|
474 | - } |
|
475 | - function build_grid_buttons_resellersummary() { |
|
476 | - $buttons_json = json_encode(array(array("Export","btn btn-xing" ," fa fa-download fa-lg", "button_action", "/reports/resellersummary_export_cdr_xls", 'single'))); |
|
477 | - return $buttons_json; |
|
478 | - } |
|
479 | - function get_customersummary_search_form() { |
|
480 | - $form['forms'] = array("",array('id' => "customersummary_search")); |
|
481 | - $form['Search'] = array( |
|
482 | - array('From Date', 'INPUT', array('name' => 'callstart[]', 'id' => 'customer_from_date', 'size' => '20', 'class' => "text field "), '', 'tOOL TIP', '', 'start_date[start_date-date]'), |
|
483 | - array('To Date', 'INPUT', array('name' => 'callstart[]', 'id' => 'customer_to_date', 'size' => '20', 'class' => "text field "), '', 'tOOL TIP', '', 'end_date[end_date-date]'), |
|
484 | - array('Account', 'accountid', 'SELECT', '', '', 'tOOL TIP', 'Please Enter account number', 'id', 'IF(`deleted`=1,concat( first_name, " ", last_name, " ", "(", number, ")^" ),concat( first_name, " ", last_name, " ", "(", number, ")" )) as number', 'accounts', 'build_dropdown_deleted', 'where_arr', array("reseller_id" => "0","type"=>"GLOBAL")), |
|
485 | - array('Code ', 'INPUT', array('name' => 'pattern[pattern]', 'value' => '', 'size' => '20', 'class' => "text field "), '', 'Tool tips info', '1', 'pattern[pattern-string]', '', '', '', 'search_string_type', ''), |
|
456 | + return $form; |
|
457 | + } |
|
458 | + function build_resellersummary(){ |
|
459 | + $grid_field_arr = json_encode(array( |
|
460 | + array("Account", "148", "accountid", "first_name,last_name,number", "accounts", "build_concat_string"), |
|
461 | + array("Code", "120", "pattern", "pattern", "", "get_only_numeric_val"), |
|
462 | + array("Destination", "150", "notes", "", "", ""), |
|
463 | + array("Attempted Calls", "120", "attempted_calls", "", "", ""), |
|
464 | + array("Completed Calls", "120", "description", "", "", ""), |
|
465 | + array("ASR","80","asr",'','',''), |
|
466 | + array("ACD","80","acd ",'','',''), |
|
467 | + array("MCD","80","mcd",'','',''), |
|
468 | + array("Bilable","90","billable",'','',''), |
|
469 | + array("Price","90","price",'','',''), |
|
470 | + array("Cost","90","cost",'','',''), |
|
471 | + array("Profit", "100", "profit", "", "", ""), |
|
472 | + )); |
|
473 | + return $grid_field_arr; |
|
474 | + } |
|
475 | + function build_grid_buttons_resellersummary() { |
|
476 | + $buttons_json = json_encode(array(array("Export","btn btn-xing" ," fa fa-download fa-lg", "button_action", "/reports/resellersummary_export_cdr_xls", 'single'))); |
|
477 | + return $buttons_json; |
|
478 | + } |
|
479 | + function get_customersummary_search_form() { |
|
480 | + $form['forms'] = array("",array('id' => "customersummary_search")); |
|
481 | + $form['Search'] = array( |
|
482 | + array('From Date', 'INPUT', array('name' => 'callstart[]', 'id' => 'customer_from_date', 'size' => '20', 'class' => "text field "), '', 'tOOL TIP', '', 'start_date[start_date-date]'), |
|
483 | + array('To Date', 'INPUT', array('name' => 'callstart[]', 'id' => 'customer_to_date', 'size' => '20', 'class' => "text field "), '', 'tOOL TIP', '', 'end_date[end_date-date]'), |
|
484 | + array('Account', 'accountid', 'SELECT', '', '', 'tOOL TIP', 'Please Enter account number', 'id', 'IF(`deleted`=1,concat( first_name, " ", last_name, " ", "(", number, ")^" ),concat( first_name, " ", last_name, " ", "(", number, ")" )) as number', 'accounts', 'build_dropdown_deleted', 'where_arr', array("reseller_id" => "0","type"=>"GLOBAL")), |
|
485 | + array('Code ', 'INPUT', array('name' => 'pattern[pattern]', 'value' => '', 'size' => '20', 'class' => "text field "), '', 'Tool tips info', '1', 'pattern[pattern-string]', '', '', '', 'search_string_type', ''), |
|
486 | 486 | |
487 | - array('Destination ', 'INPUT', array('name' => 'notes[notes]', 'value' => '', 'size' => '20', 'class' => "text field "), '', 'Tool tips info', '1', 'notes[notes-string]', '', '', '', 'search_string_type', ''), |
|
488 | - // array('Account Number', 'number', 'SELECT', '', '', 'tOOL TIP', 'Please Enter account number', 'id', 'first_name,last_name,number', 'accounts', 'build_concat_dropdown', 'where_arr', array("type"=>"0", "deleted" => "0")), |
|
487 | + array('Destination ', 'INPUT', array('name' => 'notes[notes]', 'value' => '', 'size' => '20', 'class' => "text field "), '', 'Tool tips info', '1', 'notes[notes-string]', '', '', '', 'search_string_type', ''), |
|
488 | + // array('Account Number', 'number', 'SELECT', '', '', 'tOOL TIP', 'Please Enter account number', 'id', 'first_name,last_name,number', 'accounts', 'build_concat_dropdown', 'where_arr', array("type"=>"0", "deleted" => "0")), |
|
489 | 489 | array('', 'HIDDEN', 'ajax_search', '1', '', '', ''),array('', 'HIDDEN', 'advance_search', '1', '', '', '') |
490 | - ); |
|
491 | - $form['button_search'] = array('name' => 'action', 'id' => "customersummary_search_btn", 'content' => 'Search', 'value' => 'save', 'type' => 'button', 'class' => 'btn btn-line-parrot pull-right'); |
|
492 | - $form['button_reset'] = array('name' => 'action', 'id' => "id_reset", 'content' => 'Clear', 'value' => 'cancel', 'type' => 'reset', 'class' => 'btn btn-line-sky pull-right margin-x-10'); |
|
490 | + ); |
|
491 | + $form['button_search'] = array('name' => 'action', 'id' => "customersummary_search_btn", 'content' => 'Search', 'value' => 'save', 'type' => 'button', 'class' => 'btn btn-line-parrot pull-right'); |
|
492 | + $form['button_reset'] = array('name' => 'action', 'id' => "id_reset", 'content' => 'Clear', 'value' => 'cancel', 'type' => 'reset', 'class' => 'btn btn-line-sky pull-right margin-x-10'); |
|
493 | 493 | |
494 | - return $form; |
|
495 | - } |
|
496 | - function build_customersummary(){ |
|
497 | - $grid_field_arr = json_encode(array( |
|
498 | - array("Account", "190", "accountid", "first_name,last_name,number", "accounts", "build_concat_string"), |
|
499 | - array("Code", "80", "pattern", "pattern", "", "get_only_numeric_val"), |
|
500 | - array("Destination", "110", "notes", "", "", ""), |
|
501 | - array("Attempted Calls", "140", "attempted_calls", "", "", ""), |
|
502 | - array("Completed Calls", "130", "description", "", "", ""), |
|
503 | - array("ASR","70","asr",'','',''), |
|
504 | - array("ACD","70","acd ",'','',''), |
|
505 | - array("MCD","80","mcd",'','',''), |
|
506 | - array("Bilable","80","billable",'','',''), |
|
507 | - array("Debit","85","cost",'','',''), |
|
508 | - array("Cost","110","price",'','',''), |
|
509 | - array("Profit", "123", "profit", "", "", ""), |
|
510 | - )); |
|
511 | - return $grid_field_arr; |
|
512 | - } |
|
513 | - function build_grid_buttons_customersummary() { |
|
514 | - $buttons_json = json_encode(array(array("Export","btn btn-xing" ," fa fa-download fa-lg", "button_action", "/reports/customersummary_export_cdr_xls", 'single'))); |
|
515 | - return $buttons_json; |
|
516 | - } |
|
494 | + return $form; |
|
495 | + } |
|
496 | + function build_customersummary(){ |
|
497 | + $grid_field_arr = json_encode(array( |
|
498 | + array("Account", "190", "accountid", "first_name,last_name,number", "accounts", "build_concat_string"), |
|
499 | + array("Code", "80", "pattern", "pattern", "", "get_only_numeric_val"), |
|
500 | + array("Destination", "110", "notes", "", "", ""), |
|
501 | + array("Attempted Calls", "140", "attempted_calls", "", "", ""), |
|
502 | + array("Completed Calls", "130", "description", "", "", ""), |
|
503 | + array("ASR","70","asr",'','',''), |
|
504 | + array("ACD","70","acd ",'','',''), |
|
505 | + array("MCD","80","mcd",'','',''), |
|
506 | + array("Bilable","80","billable",'','',''), |
|
507 | + array("Debit","85","cost",'','',''), |
|
508 | + array("Cost","110","price",'','',''), |
|
509 | + array("Profit", "123", "profit", "", "", ""), |
|
510 | + )); |
|
511 | + return $grid_field_arr; |
|
512 | + } |
|
513 | + function build_grid_buttons_customersummary() { |
|
514 | + $buttons_json = json_encode(array(array("Export","btn btn-xing" ," fa fa-download fa-lg", "button_action", "/reports/customersummary_export_cdr_xls", 'single'))); |
|
515 | + return $buttons_json; |
|
516 | + } |
|
517 | 517 | /********* |
518 | 518 | ASTPP 3.0 .1 |
519 | 519 | Charges History |
520 | 520 | *********/ |
521 | - function build_charge_list_for_admin() { |
|
521 | + function build_charge_list_for_admin() { |
|
522 | 522 | $account_info = $accountinfo = $this->CI->session->userdata('accountinfo'); |
523 | 523 | $currency_id=$account_info['currency_id']; |
524 | 524 | $currency=$this->CI->common->get_field_name('currency', 'currency', $currency_id); |
525 | - if ($this->CI->session->userdata("logintype") == '1') { |
|
526 | - $grid_field_arr = json_encode(array( |
|
527 | - array(gettext("Created Date"), "120", "created_date", "", "", "","","true","center"), |
|
528 | - array(gettext("Invoice Number"), "120", "created_date", "", "", "","","true","center"), |
|
529 | - array(gettext("Account"), "120", "accountid", "first_name,last_name,number", "accounts", "build_concat_string","","true","center"), |
|
525 | + if ($this->CI->session->userdata("logintype") == '1') { |
|
526 | + $grid_field_arr = json_encode(array( |
|
527 | + array(gettext("Created Date"), "120", "created_date", "", "", "","","true","center"), |
|
528 | + array(gettext("Invoice Number"), "120", "created_date", "", "", "","","true","center"), |
|
529 | + array(gettext("Account"), "120", "accountid", "first_name,last_name,number", "accounts", "build_concat_string","","true","center"), |
|
530 | 530 | // array("Reseller", "120", "reseller_id", "first_name,last_name,number", "accounts", "reseller_select_value"), |
531 | - array(gettext("Charge Type"), "120", "item_type", "", "", "","","true","center"), |
|
532 | - array("Before Balance<br/>($currency)", "120", "before_balance", "before_balance", "before_balance", "convert_to_currency","","true","right"), |
|
533 | - array("Debit (-)<br/>($currency)", "110", "debit", "debit", "debit", "convert_to_currency","","true","right"), |
|
534 | - array("Credit (+)<br/>($currency)", "110", "credit", "credit", "credit", "convert_to_currency","","true","right"), |
|
535 | - array("After Balance<br/>($currency)", "120", "after_balance", "after_balance", "after_balance", "convert_to_currency","","true","right"), |
|
536 | - array(gettext("Description"), "300", "description", "", "", "","","true","center"), |
|
537 | - )); |
|
531 | + array(gettext("Charge Type"), "120", "item_type", "", "", "","","true","center"), |
|
532 | + array("Before Balance<br/>($currency)", "120", "before_balance", "before_balance", "before_balance", "convert_to_currency","","true","right"), |
|
533 | + array("Debit (-)<br/>($currency)", "110", "debit", "debit", "debit", "convert_to_currency","","true","right"), |
|
534 | + array("Credit (+)<br/>($currency)", "110", "credit", "credit", "credit", "convert_to_currency","","true","right"), |
|
535 | + array("After Balance<br/>($currency)", "120", "after_balance", "after_balance", "after_balance", "convert_to_currency","","true","right"), |
|
536 | + array(gettext("Description"), "300", "description", "", "", "","","true","center"), |
|
537 | + )); |
|
538 | 538 | }else{ |
539 | - $grid_field_arr = json_encode(array( |
|
540 | - array("Created Date", "120", "created_date", "", "", "","","true","center"), |
|
541 | - array("Invoice Number", "120", "created_date", "", "", "","","true","center"), |
|
542 | - array("Account", "120", "accountid", "first_name,last_name,number", "accounts", "build_concat_string","","true","center"), |
|
543 | - array("Charge Type", "120", "item_type", "", "", "","","true","center"), |
|
544 | - array("Before Balance<br/>($currency)", "120", "before_balance", "before_balance", "before_balance", "convert_to_currency","","true","right"), |
|
545 | - array("Debit (-)<br/>($currency)", "110", "debit", "debit", "debit", "convert_to_currency","","true","right"), |
|
546 | - array("Credit (+)<br/>($currency)", "110", "credit", "credit", "credit", "convert_to_currency","","true","right"), |
|
547 | - array("After Balance<br/>($currency)", "120", "after_balance", "after_balance", "after_balance", "convert_to_currency","","true","right"), |
|
548 | - array("Description", "300", "description", "", "", "","","true","center"), |
|
549 | - )); |
|
539 | + $grid_field_arr = json_encode(array( |
|
540 | + array("Created Date", "120", "created_date", "", "", "","","true","center"), |
|
541 | + array("Invoice Number", "120", "created_date", "", "", "","","true","center"), |
|
542 | + array("Account", "120", "accountid", "first_name,last_name,number", "accounts", "build_concat_string","","true","center"), |
|
543 | + array("Charge Type", "120", "item_type", "", "", "","","true","center"), |
|
544 | + array("Before Balance<br/>($currency)", "120", "before_balance", "before_balance", "before_balance", "convert_to_currency","","true","right"), |
|
545 | + array("Debit (-)<br/>($currency)", "110", "debit", "debit", "debit", "convert_to_currency","","true","right"), |
|
546 | + array("Credit (+)<br/>($currency)", "110", "credit", "credit", "credit", "convert_to_currency","","true","right"), |
|
547 | + array("After Balance<br/>($currency)", "120", "after_balance", "after_balance", "after_balance", "convert_to_currency","","true","right"), |
|
548 | + array("Description", "300", "description", "", "", "","","true","center"), |
|
549 | + )); |
|
550 | 550 | |
551 | 551 | } |
552 | - return $grid_field_arr; |
|
553 | - } |
|
554 | - function get_charges_search_form() { |
|
555 | - $accountinfo=$this->CI->session->userdata('accountinfo'); |
|
556 | - $reseller_id=$accountinfo['type']==1 ? $accountinfo['id'] : 0; |
|
557 | - $form['forms'] = array("", array('id' => "charges_search")); |
|
558 | - $form['Search'] = array( |
|
559 | - array('From Date', 'INPUT', array('name' => 'created_date[]', 'id' => 'charge_from_date', 'size' => '20', 'class' => "text field "), '', 'tOOL TIP', '', 'start_date[start_date-date]'), |
|
560 | - array('To Date', 'INPUT', array('name' => 'created_date[]', 'id' => 'charge_to_date', 'size' => '20', 'class' => "text field "), '', 'tOOL TIP', '', 'end_date[end_date-date]'), |
|
561 | - array('Account', 'accountid', 'SELECT', '', '', 'tOOL TIP', 'Please Enter account number', 'id', 'IF(`deleted`=1,concat( first_name, " ", last_name, " ", "(", number, ")^" ),concat( first_name, " ", last_name, " ", "(", number, ")" )) as number', 'accounts', 'build_dropdown_deleted', 'where_arr', array("reseller_id" => $reseller_id,"type"=>"GLOBAL")), |
|
562 | - array('Debit ', 'INPUT', array('name' => 'debit[debit]', 'value' => '', 'size' => '20', 'class' => "text field "), '', 'Tool tips info', '1', 'debit[debit-integer]', '', '', '', 'search_int_type', ''), |
|
563 | - array('Credit ', 'INPUT', array('name' => 'credit[credit]', 'value' => '', 'size' => '20', 'class' => "text field "), '', 'Tool tips info', '1', 'credit[credit-integer]', '', '', '', 'search_int_type', ''), |
|
552 | + return $grid_field_arr; |
|
553 | + } |
|
554 | + function get_charges_search_form() { |
|
555 | + $accountinfo=$this->CI->session->userdata('accountinfo'); |
|
556 | + $reseller_id=$accountinfo['type']==1 ? $accountinfo['id'] : 0; |
|
557 | + $form['forms'] = array("", array('id' => "charges_search")); |
|
558 | + $form['Search'] = array( |
|
559 | + array('From Date', 'INPUT', array('name' => 'created_date[]', 'id' => 'charge_from_date', 'size' => '20', 'class' => "text field "), '', 'tOOL TIP', '', 'start_date[start_date-date]'), |
|
560 | + array('To Date', 'INPUT', array('name' => 'created_date[]', 'id' => 'charge_to_date', 'size' => '20', 'class' => "text field "), '', 'tOOL TIP', '', 'end_date[end_date-date]'), |
|
561 | + array('Account', 'accountid', 'SELECT', '', '', 'tOOL TIP', 'Please Enter account number', 'id', 'IF(`deleted`=1,concat( first_name, " ", last_name, " ", "(", number, ")^" ),concat( first_name, " ", last_name, " ", "(", number, ")" )) as number', 'accounts', 'build_dropdown_deleted', 'where_arr', array("reseller_id" => $reseller_id,"type"=>"GLOBAL")), |
|
562 | + array('Debit ', 'INPUT', array('name' => 'debit[debit]', 'value' => '', 'size' => '20', 'class' => "text field "), '', 'Tool tips info', '1', 'debit[debit-integer]', '', '', '', 'search_int_type', ''), |
|
563 | + array('Credit ', 'INPUT', array('name' => 'credit[credit]', 'value' => '', 'size' => '20', 'class' => "text field "), '', 'Tool tips info', '1', 'credit[credit-integer]', '', '', '', 'search_int_type', ''), |
|
564 | 564 | |
565 | - array('', 'HIDDEN', 'ajax_search', '1', '', '', ''), |
|
566 | - array('', 'HIDDEN', 'advance_search', '1', '', '', '') |
|
567 | - ); |
|
568 | - $form['button_search'] = array('name' => 'action', 'id' => "charges_search_btn", 'content' => 'Search', 'value' => 'save', 'type' => 'button', 'class' => 'btn btn-line-parrot pull-right'); |
|
569 | - $form['button_reset'] = array('name' => 'action', 'id' => "id_reset", 'content' => 'Clear', 'value' => 'cancel', 'type' => 'reset', 'class' => 'btn btn-line-sky pull-right margin-x-10'); |
|
565 | + array('', 'HIDDEN', 'ajax_search', '1', '', '', ''), |
|
566 | + array('', 'HIDDEN', 'advance_search', '1', '', '', '') |
|
567 | + ); |
|
568 | + $form['button_search'] = array('name' => 'action', 'id' => "charges_search_btn", 'content' => 'Search', 'value' => 'save', 'type' => 'button', 'class' => 'btn btn-line-parrot pull-right'); |
|
569 | + $form['button_reset'] = array('name' => 'action', 'id' => "id_reset", 'content' => 'Clear', 'value' => 'cancel', 'type' => 'reset', 'class' => 'btn btn-line-sky pull-right margin-x-10'); |
|
570 | 570 | |
571 | - return $form; |
|
572 | - } |
|
573 | - /*******************************/ |
|
574 | - /********* |
|
571 | + return $form; |
|
572 | + } |
|
573 | + /*******************************/ |
|
574 | + /********* |
|
575 | 575 | ASTPP 3.0 |
576 | 576 | Charges History |
577 | 577 | *********/ |
578 | - function build_charge_list_for_customer(){ |
|
578 | + function build_charge_list_for_customer(){ |
|
579 | 579 | $account_info = $accountinfo = $this->CI->session->userdata('accountinfo'); |
580 | 580 | $currency_id=$account_info['currency_id']; |
581 | 581 | $currency=$this->CI->common->get_field_name('currency', 'currency', $currency_id); |
582 | 582 | |
583 | - $grid_field_arr = json_encode(array( |
|
584 | - array("Created Date", "100", "created_date", "", "", "","","true","center"), |
|
585 | - array("Invoice Number", "110", "created_date", "", "", "","","true","center"), |
|
586 | - array("Charge Type", "100", "item_type", "", "", "","","true","center"), |
|
587 | - array("Before Balance<br/>($currency)", "120", "before_balance", "before_balance", "before_balance", "convert_to_currency","","true","right"), |
|
588 | - array("Debit (-)<br/>($currency)", "110", "debit", "debit", "debit", "convert_to_currency","","true","right"), |
|
589 | - array("Credit (+)<br/>($currency)", "110", "credit", "credit", "credit", "convert_to_currency","","true","right"), |
|
590 | - array("After Balance<br/>($currency)", "120", "after_balance", "after_balance", "after_balance", "convert_to_currency","","true","right"), |
|
591 | - array("Description", "270", "description", "", "", "","","true","center"), |
|
592 | - )); |
|
593 | - return $grid_field_arr; |
|
594 | - } |
|
595 | - /********* |
|
583 | + $grid_field_arr = json_encode(array( |
|
584 | + array("Created Date", "100", "created_date", "", "", "","","true","center"), |
|
585 | + array("Invoice Number", "110", "created_date", "", "", "","","true","center"), |
|
586 | + array("Charge Type", "100", "item_type", "", "", "","","true","center"), |
|
587 | + array("Before Balance<br/>($currency)", "120", "before_balance", "before_balance", "before_balance", "convert_to_currency","","true","right"), |
|
588 | + array("Debit (-)<br/>($currency)", "110", "debit", "debit", "debit", "convert_to_currency","","true","right"), |
|
589 | + array("Credit (+)<br/>($currency)", "110", "credit", "credit", "credit", "convert_to_currency","","true","right"), |
|
590 | + array("After Balance<br/>($currency)", "120", "after_balance", "after_balance", "after_balance", "convert_to_currency","","true","right"), |
|
591 | + array("Description", "270", "description", "", "", "","","true","center"), |
|
592 | + )); |
|
593 | + return $grid_field_arr; |
|
594 | + } |
|
595 | + /********* |
|
596 | 596 | ASTPP 3.0 |
597 | 597 | Refill History |
598 | 598 | *********/ |
599 | - function build_refillreport_for_customer(){ |
|
599 | + function build_refillreport_for_customer(){ |
|
600 | 600 | |
601 | 601 | $account_info = $accountinfo = $this->CI->session->userdata('accountinfo'); |
602 | 602 | $currency_id=$account_info['currency_id']; |
603 | 603 | $currency=$this->CI->common->get_field_name('currency', 'currency', $currency_id); |
604 | 604 | |
605 | - $grid_field_arr = json_encode(array( |
|
606 | - array("Date", "225", "payment_date", "", "", "","","true","center"), |
|
607 | - array("Amount($currency)", "250", "credit", "credit", "credit", "convert_to_currency","","true","right"), |
|
608 | - array("Refill By", "230", "payment_by", "payment_by", "payment_by", "get_refill_by","","true","center"), |
|
609 | - array("Note", "325", "notes", "", "", "","","true","center") |
|
610 | - )); |
|
611 | - return $grid_field_arr; |
|
612 | - } |
|
605 | + $grid_field_arr = json_encode(array( |
|
606 | + array("Date", "225", "payment_date", "", "", "","","true","center"), |
|
607 | + array("Amount($currency)", "250", "credit", "credit", "credit", "convert_to_currency","","true","right"), |
|
608 | + array("Refill By", "230", "payment_by", "payment_by", "payment_by", "get_refill_by","","true","center"), |
|
609 | + array("Note", "325", "notes", "", "", "","","true","center") |
|
610 | + )); |
|
611 | + return $grid_field_arr; |
|
612 | + } |
|
613 | 613 | |
614 | 614 | |
615 | 615 | } |
@@ -22,176 +22,176 @@ discard block |
||
22 | 22 | ############################################################################### |
23 | 23 | class Reports_model extends CI_Model { |
24 | 24 | |
25 | - function Reports_model() { |
|
26 | - parent::__construct(); |
|
27 | - } |
|
25 | + function Reports_model() { |
|
26 | + parent::__construct(); |
|
27 | + } |
|
28 | 28 | /** |
29 | 29 | ASTPP 3.0 |
30 | 30 | For Detail Customer Report List,Export |
31 | 31 | **/ |
32 | - function getcustomer_cdrs($flag, $start, $limit,$export =false) { |
|
33 | - $this->db_model->build_search('customer_cdr_list_search'); |
|
34 | - $account_data = $this->session->userdata("accountinfo"); |
|
35 | - $where['reseller_id']=$account_data['type']== 1 ? $account_data['id']:0; |
|
36 | - //$where['type']=0; |
|
37 | - if($this->session->userdata('advance_search') != 1){ |
|
38 | - $where['callstart >= ']=date("Y-m-d")." 00:00:00"; |
|
39 | - $where['callstart <=']=date("Y-m-d")." 23:59:59"; |
|
40 | - } |
|
32 | + function getcustomer_cdrs($flag, $start, $limit,$export =false) { |
|
33 | + $this->db_model->build_search('customer_cdr_list_search'); |
|
34 | + $account_data = $this->session->userdata("accountinfo"); |
|
35 | + $where['reseller_id']=$account_data['type']== 1 ? $account_data['id']:0; |
|
36 | + //$where['type']=0; |
|
37 | + if($this->session->userdata('advance_search') != 1){ |
|
38 | + $where['callstart >= ']=date("Y-m-d")." 00:00:00"; |
|
39 | + $where['callstart <=']=date("Y-m-d")." 23:59:59"; |
|
40 | + } |
|
41 | 41 | |
42 | - $types = array('0','3'); |
|
43 | - //$this->db->or_where_in('type', $types); |
|
42 | + $types = array('0','3'); |
|
43 | + //$this->db->or_where_in('type', $types); |
|
44 | 44 | $this->db->where_in('type', $types); |
45 | 45 | |
46 | - $this->db->where($where); |
|
47 | - if (isset($_GET['sortname']) && $_GET['sortname'] != 'undefined'){ |
|
48 | - $this->db->order_by($_GET['sortname'], ($_GET['sortorder']=='undefined')?'desc':$_GET['sortorder']); |
|
49 | - }else{ |
|
50 | - $this->db->order_by("callstart desc"); |
|
51 | - } |
|
52 | - if ($flag) { |
|
53 | - if (!$export) |
|
54 | - $this->db->limit($limit, $start); |
|
55 | - $this->db->select('callstart,callerid,callednum,pattern,notes,billseconds,disposition,debit,cost,accountid,pricelist_id,calltype,is_recording,trunk_id,uniqueid'); |
|
56 | - }else { |
|
57 | - $this->db->select('count(*) as count,sum(billseconds) as billseconds,sum(debit) as total_debit,sum(cost) as total_cost,group_concat(distinct(pricelist_id)) as pricelist_ids,group_concat(distinct(trunk_id)) as trunk_ids,group_concat(distinct(accountid)) as accounts_ids'); |
|
58 | - } |
|
59 | - $result = $this->db->get('cdrs'); |
|
60 | - return $result; |
|
61 | - } |
|
46 | + $this->db->where($where); |
|
47 | + if (isset($_GET['sortname']) && $_GET['sortname'] != 'undefined'){ |
|
48 | + $this->db->order_by($_GET['sortname'], ($_GET['sortorder']=='undefined')?'desc':$_GET['sortorder']); |
|
49 | + }else{ |
|
50 | + $this->db->order_by("callstart desc"); |
|
51 | + } |
|
52 | + if ($flag) { |
|
53 | + if (!$export) |
|
54 | + $this->db->limit($limit, $start); |
|
55 | + $this->db->select('callstart,callerid,callednum,pattern,notes,billseconds,disposition,debit,cost,accountid,pricelist_id,calltype,is_recording,trunk_id,uniqueid'); |
|
56 | + }else { |
|
57 | + $this->db->select('count(*) as count,sum(billseconds) as billseconds,sum(debit) as total_debit,sum(cost) as total_cost,group_concat(distinct(pricelist_id)) as pricelist_ids,group_concat(distinct(trunk_id)) as trunk_ids,group_concat(distinct(accountid)) as accounts_ids'); |
|
58 | + } |
|
59 | + $result = $this->db->get('cdrs'); |
|
60 | + return $result; |
|
61 | + } |
|
62 | 62 | /* |
63 | 63 | * Below function using by Detail reseller report |
64 | 64 | */ |
65 | - function getreseller_cdrs($flag, $start, $limit,$export=false) { |
|
66 | - $this->db_model->build_search('reseller_cdr_list_search'); |
|
67 | - $account_data = $this->session->userdata("accountinfo"); |
|
68 | - $where['reseller_id']=$account_data['type']== 1 ? $account_data['id']:0; |
|
69 | - $where["accountid <>"]=$account_data['type']== 1 ? $account_data['id']:0; |
|
65 | + function getreseller_cdrs($flag, $start, $limit,$export=false) { |
|
66 | + $this->db_model->build_search('reseller_cdr_list_search'); |
|
67 | + $account_data = $this->session->userdata("accountinfo"); |
|
68 | + $where['reseller_id']=$account_data['type']== 1 ? $account_data['id']:0; |
|
69 | + $where["accountid <>"]=$account_data['type']== 1 ? $account_data['id']:0; |
|
70 | 70 | if($this->session->userdata('advance_search') != 1){ |
71 | - $where['callstart >= ']=date("Y-m-d")." 00:00:00"; |
|
72 | - $where['callstart <=']=date("Y-m-d")." 23:59:59"; |
|
73 | - } |
|
74 | - $this->db->where($where); |
|
75 | - if (isset($_GET['sortname']) && $_GET['sortname'] != 'undefined'){ |
|
76 | - $this->db->order_by($_GET['sortname'], ($_GET['sortorder']=='undefined')?'desc':$_GET['sortorder']); |
|
77 | - }else{ |
|
78 | - $this->db->order_by("callstart desc"); |
|
79 | - } |
|
80 | - if ($flag) { |
|
81 | - if (!$export) |
|
82 | - $this->db->limit($limit, $start); |
|
83 | - $this->db->select('callstart,callerid,callednum,pattern,notes,billseconds,disposition,debit,cost,accountid,pricelist_id,calltype'); |
|
84 | - } else { |
|
85 | - $this->db->select('count(*) as count,sum(billseconds) as billseconds,sum(debit) as total_debit,sum(cost) as total_cost,group_concat(distinct(pricelist_id)) as pricelist_ids'); |
|
86 | - } |
|
87 | - $result = $this->db->get('reseller_cdrs'); |
|
88 | - return $result; |
|
89 | - } |
|
90 | - /*Below function using by Detail provider report |
|
71 | + $where['callstart >= ']=date("Y-m-d")." 00:00:00"; |
|
72 | + $where['callstart <=']=date("Y-m-d")." 23:59:59"; |
|
73 | + } |
|
74 | + $this->db->where($where); |
|
75 | + if (isset($_GET['sortname']) && $_GET['sortname'] != 'undefined'){ |
|
76 | + $this->db->order_by($_GET['sortname'], ($_GET['sortorder']=='undefined')?'desc':$_GET['sortorder']); |
|
77 | + }else{ |
|
78 | + $this->db->order_by("callstart desc"); |
|
79 | + } |
|
80 | + if ($flag) { |
|
81 | + if (!$export) |
|
82 | + $this->db->limit($limit, $start); |
|
83 | + $this->db->select('callstart,callerid,callednum,pattern,notes,billseconds,disposition,debit,cost,accountid,pricelist_id,calltype'); |
|
84 | + } else { |
|
85 | + $this->db->select('count(*) as count,sum(billseconds) as billseconds,sum(debit) as total_debit,sum(cost) as total_cost,group_concat(distinct(pricelist_id)) as pricelist_ids'); |
|
86 | + } |
|
87 | + $result = $this->db->get('reseller_cdrs'); |
|
88 | + return $result; |
|
89 | + } |
|
90 | + /*Below function using by Detail provider report |
|
91 | 91 | */ |
92 | - function getprovider_cdrs($flag, $start, $limit,$export=false) { |
|
93 | - $this->db_model->build_search('provider_cdr_list_search'); |
|
94 | - $account_data = $this->session->userdata("accountinfo"); |
|
95 | - $where=array(); |
|
96 | - if($account_data['type']== 3 ){ |
|
97 | - $where['provider_id']= $account_data['id']; |
|
98 | - } |
|
92 | + function getprovider_cdrs($flag, $start, $limit,$export=false) { |
|
93 | + $this->db_model->build_search('provider_cdr_list_search'); |
|
94 | + $account_data = $this->session->userdata("accountinfo"); |
|
95 | + $where=array(); |
|
96 | + if($account_data['type']== 3 ){ |
|
97 | + $where['provider_id']= $account_data['id']; |
|
98 | + } |
|
99 | 99 | |
100 | - if($this->session->userdata('advance_search') != 1){ |
|
101 | - $where['callstart >= ']=date("Y-m-d")." 00:00:00"; |
|
102 | - $where['callstart <=']=date("Y-m-d")." 23:59:59"; |
|
103 | - } |
|
104 | - $this->db->where('trunk_id !=', ''); |
|
105 | - $this->db->where($where); |
|
106 | - if (isset($_GET['sortname']) && $_GET['sortname'] != 'undefined'){ |
|
107 | - $this->db->order_by($_GET['sortname'], ($_GET['sortorder']=='undefined')?'desc':$_GET['sortorder']); |
|
108 | - }else{ |
|
109 | - $this->db->order_by("callstart desc"); |
|
110 | - } |
|
111 | - if ($flag) { |
|
112 | - if (!$export) |
|
113 | - $this->db->limit($limit, $start); |
|
114 | - $this->db->select('callstart,callerid,callednum,pattern,notes,billseconds,provider_call_cost,disposition,provider_id,cost'); |
|
115 | - }else { |
|
116 | - $this->db->select('count(*) as count,sum(billseconds) as billseconds,sum(cost) as total_cost'); |
|
117 | - } |
|
118 | - $result = $this->db->get('cdrs'); |
|
119 | - // echo $this->db->last_query(); |
|
120 | - return $result; |
|
121 | - } |
|
122 | - function users_cdrs_list($flag,$accountid,$entity_type,$start,$limit) { |
|
100 | + if($this->session->userdata('advance_search') != 1){ |
|
101 | + $where['callstart >= ']=date("Y-m-d")." 00:00:00"; |
|
102 | + $where['callstart <=']=date("Y-m-d")." 23:59:59"; |
|
103 | + } |
|
104 | + $this->db->where('trunk_id !=', ''); |
|
105 | + $this->db->where($where); |
|
106 | + if (isset($_GET['sortname']) && $_GET['sortname'] != 'undefined'){ |
|
107 | + $this->db->order_by($_GET['sortname'], ($_GET['sortorder']=='undefined')?'desc':$_GET['sortorder']); |
|
108 | + }else{ |
|
109 | + $this->db->order_by("callstart desc"); |
|
110 | + } |
|
111 | + if ($flag) { |
|
112 | + if (!$export) |
|
113 | + $this->db->limit($limit, $start); |
|
114 | + $this->db->select('callstart,callerid,callednum,pattern,notes,billseconds,provider_call_cost,disposition,provider_id,cost'); |
|
115 | + }else { |
|
116 | + $this->db->select('count(*) as count,sum(billseconds) as billseconds,sum(cost) as total_cost'); |
|
117 | + } |
|
118 | + $result = $this->db->get('cdrs'); |
|
119 | + // echo $this->db->last_query(); |
|
120 | + return $result; |
|
121 | + } |
|
122 | + function users_cdrs_list($flag,$accountid,$entity_type,$start,$limit) { |
|
123 | 123 | $where = "callstart >= '".date('Y-m-d 00:00:00')."' AND callstart <='".date('Y-m-d 23:59:59')."' AND "; |
124 | - $account_type= $entity_type =='provider' ? 'provider_id' :'accountid'; |
|
125 | - $where.="accountid = '".$accountid."' "; |
|
126 | - //~ if($entity_type == 'provider'){ |
|
127 | - //~ $where.="OR provider_id = '".$accountid."'"; |
|
128 | - //~ } |
|
129 | - $table=$entity_type=='reseller'?'reseller_cdrs' : 'cdrs'; |
|
130 | - if ($flag) { |
|
131 | - $query = $this->db_model->select("*", $table, $where, "callstart", "DESC", $limit, $start); |
|
132 | - } else { |
|
133 | - $query = $this->db_model->countQuery("*",$table, $where); |
|
134 | - } |
|
135 | - return $query; |
|
124 | + $account_type= $entity_type =='provider' ? 'provider_id' :'accountid'; |
|
125 | + $where.="accountid = '".$accountid."' "; |
|
126 | + //~ if($entity_type == 'provider'){ |
|
127 | + //~ $where.="OR provider_id = '".$accountid."'"; |
|
128 | + //~ } |
|
129 | + $table=$entity_type=='reseller'?'reseller_cdrs' : 'cdrs'; |
|
130 | + if ($flag) { |
|
131 | + $query = $this->db_model->select("*", $table, $where, "callstart", "DESC", $limit, $start); |
|
132 | + } else { |
|
133 | + $query = $this->db_model->countQuery("*",$table, $where); |
|
134 | + } |
|
135 | + return $query; |
|
136 | 136 | |
137 | - } |
|
137 | + } |
|
138 | 138 | |
139 | 139 | |
140 | 140 | /****** |
141 | 141 | ASTPP 3.0 |
142 | 142 | Payment to refill |
143 | 143 | ******/ |
144 | - function getuser_refill_list($flag, $start, $limit) { |
|
145 | - $this->db_model->build_search('cdr_refill_search'); |
|
146 | - $account_data = $this->session->userdata("accountinfo"); |
|
147 | - $this->db_model->build_search('customer_cdr_list_search'); |
|
148 | - $where = array("accountid" => $account_data["id"]); |
|
149 | - if ($flag) { |
|
150 | - $query = $this->db_model->select("*", "payments", $where, "payment_date", "DESC", $limit, $start); |
|
151 | - } else { |
|
152 | - $query = $this->db_model->countQuery("*", "payments", $where); |
|
153 | - } |
|
154 | - return $query; |
|
155 | - } |
|
144 | + function getuser_refill_list($flag, $start, $limit) { |
|
145 | + $this->db_model->build_search('cdr_refill_search'); |
|
146 | + $account_data = $this->session->userdata("accountinfo"); |
|
147 | + $this->db_model->build_search('customer_cdr_list_search'); |
|
148 | + $where = array("accountid" => $account_data["id"]); |
|
149 | + if ($flag) { |
|
150 | + $query = $this->db_model->select("*", "payments", $where, "payment_date", "DESC", $limit, $start); |
|
151 | + } else { |
|
152 | + $query = $this->db_model->countQuery("*", "payments", $where); |
|
153 | + } |
|
154 | + return $query; |
|
155 | + } |
|
156 | 156 | |
157 | - function get_refill_list($flag, $start, $limit,$export=false) { |
|
158 | - $this->db_model->build_search('cdr_refill_search'); |
|
159 | - $accountinfo = $this->session->userdata('accountinfo'); |
|
160 | - $where['payment_by']=$accountinfo['type']==1 ? $accountinfo['id']:-1; |
|
161 | - if ($flag) { |
|
162 | - if($export) |
|
163 | - $query = $this->db_model->select("*", "payments", $where, "payment_date", "DESC","",""); |
|
164 | - else |
|
165 | - $query = $this->db_model->select("*", "payments", $where, "payment_date", "DESC", $limit, $start); |
|
166 | - } else { |
|
167 | - $query = $this->db_model->countQuery("*", "payments", $where); |
|
168 | - } |
|
157 | + function get_refill_list($flag, $start, $limit,$export=false) { |
|
158 | + $this->db_model->build_search('cdr_refill_search'); |
|
159 | + $accountinfo = $this->session->userdata('accountinfo'); |
|
160 | + $where['payment_by']=$accountinfo['type']==1 ? $accountinfo['id']:-1; |
|
161 | + if ($flag) { |
|
162 | + if($export) |
|
163 | + $query = $this->db_model->select("*", "payments", $where, "payment_date", "DESC","",""); |
|
164 | + else |
|
165 | + $query = $this->db_model->select("*", "payments", $where, "payment_date", "DESC", $limit, $start); |
|
166 | + } else { |
|
167 | + $query = $this->db_model->countQuery("*", "payments", $where); |
|
168 | + } |
|
169 | 169 | |
170 | - return $query; |
|
171 | - } |
|
170 | + return $query; |
|
171 | + } |
|
172 | 172 | /******************/ |
173 | - function getreseller_commission_list($flag, $start, $limit) { |
|
174 | - $this->db_model->build_search('reseller_commission_search'); |
|
175 | - if ($this->session->userdata('logintype') == 1 || $this->session->userdata('logintype') == 5) { |
|
176 | - $accountinfo = $this->session->userdata['accountinfo']; |
|
177 | - $reseller_id = $accountinfo["id"]; |
|
178 | - } else { |
|
179 | - $reseller_id = "0"; |
|
180 | - } |
|
181 | - if ($flag) { |
|
182 | - $query = $this->db_model->select_by_in("*", "commission","" , "date", "DESC", $limit, $start,"","reseller_id",$reseller_id); |
|
173 | + function getreseller_commission_list($flag, $start, $limit) { |
|
174 | + $this->db_model->build_search('reseller_commission_search'); |
|
175 | + if ($this->session->userdata('logintype') == 1 || $this->session->userdata('logintype') == 5) { |
|
176 | + $accountinfo = $this->session->userdata['accountinfo']; |
|
177 | + $reseller_id = $accountinfo["id"]; |
|
178 | + } else { |
|
179 | + $reseller_id = "0"; |
|
180 | + } |
|
181 | + if ($flag) { |
|
182 | + $query = $this->db_model->select_by_in("*", "commission","" , "date", "DESC", $limit, $start,"","reseller_id",$reseller_id); |
|
183 | 183 | |
184 | - } else { |
|
185 | - $query = $this->db_model->countQuery_by_in("*", "commission", "","reseller_id",$reseller_id); |
|
186 | - } |
|
184 | + } else { |
|
185 | + $query = $this->db_model->countQuery_by_in("*", "commission", "","reseller_id",$reseller_id); |
|
186 | + } |
|
187 | 187 | |
188 | - return $query; |
|
189 | - } |
|
188 | + return $query; |
|
189 | + } |
|
190 | 190 | /*********** |
191 | 191 | ASTPP 3.0 |
192 | 192 | Charge History |
193 | 193 | ***********/ |
194 | - function getcharges_list($flag, $start = 0, $limit = 0) { |
|
194 | + function getcharges_list($flag, $start = 0, $limit = 0) { |
|
195 | 195 | $accountinfo=$this->session->userdata('accountinfo'); |
196 | 196 | $reseller_id=$accountinfo['id']; |
197 | 197 | if($accountinfo['type'] == 1){ |
@@ -214,38 +214,38 @@ discard block |
||
214 | 214 | $query = $this->db_model->countQuery("*", "invoice_details", ""); |
215 | 215 | } |
216 | 216 | return $query; |
217 | - } |
|
217 | + } |
|
218 | 218 | |
219 | 219 | /************************************/ |
220 | - /* ASTPP 3.0 |
|
220 | + /* ASTPP 3.0 |
|
221 | 221 | * This function using for customer edit |
222 | 222 | */ |
223 | 223 | function get_customer_charge_list($flag,$accountid,$start = 0, $limit = 0){ |
224 | - $this->db_model->build_search('charges_list_search'); |
|
225 | - $accountinfo=$this->session->userdata('accountinfo'); |
|
226 | - $reseller_id=$accountinfo['type']==1 ? $accountinfo['id'] : 0; |
|
227 | - $where['reseller_id']=$reseller_id; |
|
228 | - $where['accountid']=$accountid; |
|
229 | - if($this->session->userdata('advance_search') != 1){ |
|
230 | - $where['created_date >=']=gmdate("Y-m-1 00:00:00"); |
|
231 | - $where['created_date <=']=gmdate("Y-m-d 23:59:59"); |
|
232 | - } |
|
233 | - if ($flag) { |
|
234 | - $query = $this->db_model->select("*", "invoice_details", $where, "id", "DESC", $limit, $start); |
|
235 | - } else { |
|
236 | - $query = $this->db_model->countQuery("*", "invoice_details", $where); |
|
237 | - } |
|
238 | - return $query; |
|
239 | - } |
|
240 | - function get_customer_refillreport($flag,$accountid,$start = 0, $limit = 0){ |
|
241 | - $where = array("accountid"=>$accountid); |
|
242 | - if ($flag) { |
|
243 | - $query = $this->db_model->select("*", "payments", $where, "payment_date", "DESC", $limit, $start); |
|
244 | - } else { |
|
245 | - $query = $this->db_model->countQuery("*", "payments", $where); |
|
246 | - } |
|
224 | + $this->db_model->build_search('charges_list_search'); |
|
225 | + $accountinfo=$this->session->userdata('accountinfo'); |
|
226 | + $reseller_id=$accountinfo['type']==1 ? $accountinfo['id'] : 0; |
|
227 | + $where['reseller_id']=$reseller_id; |
|
228 | + $where['accountid']=$accountid; |
|
229 | + if($this->session->userdata('advance_search') != 1){ |
|
230 | + $where['created_date >=']=gmdate("Y-m-1 00:00:00"); |
|
231 | + $where['created_date <=']=gmdate("Y-m-d 23:59:59"); |
|
232 | + } |
|
233 | + if ($flag) { |
|
234 | + $query = $this->db_model->select("*", "invoice_details", $where, "id", "DESC", $limit, $start); |
|
235 | + } else { |
|
236 | + $query = $this->db_model->countQuery("*", "invoice_details", $where); |
|
237 | + } |
|
238 | + return $query; |
|
239 | + } |
|
240 | + function get_customer_refillreport($flag,$accountid,$start = 0, $limit = 0){ |
|
241 | + $where = array("accountid"=>$accountid); |
|
242 | + if ($flag) { |
|
243 | + $query = $this->db_model->select("*", "payments", $where, "payment_date", "DESC", $limit, $start); |
|
244 | + } else { |
|
245 | + $query = $this->db_model->countQuery("*", "payments", $where); |
|
246 | + } |
|
247 | 247 | |
248 | - return $query; |
|
249 | - } |
|
250 | - /*************************************************************************/ |
|
248 | + return $query; |
|
249 | + } |
|
250 | + /*************************************************************************/ |
|
251 | 251 | } |
@@ -22,151 +22,151 @@ discard block |
||
22 | 22 | ############################################################################### |
23 | 23 | class Invoices extends MX_Controller { |
24 | 24 | |
25 | - function Invoices() { |
|
26 | - parent::__construct(); |
|
25 | + function Invoices() { |
|
26 | + parent::__construct(); |
|
27 | 27 | |
28 | - $this->load->helper('template_inheritance'); |
|
28 | + $this->load->helper('template_inheritance'); |
|
29 | 29 | |
30 | - $this->load->library('session'); |
|
31 | - $this->load->library('invoices_form'); |
|
32 | - $this->load->library('astpp/form'); |
|
33 | - $this->load->model('invoices_model'); |
|
34 | - $this->load->model('Astpp_common'); |
|
35 | - $this->load->model('common_model'); |
|
36 | - $this->load->library("astpp/email_lib"); |
|
37 | - $this->load->library('fpdf'); |
|
38 | - $this->load->library('pdf'); |
|
30 | + $this->load->library('session'); |
|
31 | + $this->load->library('invoices_form'); |
|
32 | + $this->load->library('astpp/form'); |
|
33 | + $this->load->model('invoices_model'); |
|
34 | + $this->load->model('Astpp_common'); |
|
35 | + $this->load->model('common_model'); |
|
36 | + $this->load->library("astpp/email_lib"); |
|
37 | + $this->load->library('fpdf'); |
|
38 | + $this->load->library('pdf'); |
|
39 | 39 | |
40 | - if ($this->session->userdata('user_login') == FALSE) |
|
41 | - redirect(base_url() . '/astpp/login'); |
|
42 | - } |
|
40 | + if ($this->session->userdata('user_login') == FALSE) |
|
41 | + redirect(base_url() . '/astpp/login'); |
|
42 | + } |
|
43 | 43 | |
44 | 44 | |
45 | - function invoice_list() { |
|
45 | + function invoice_list() { |
|
46 | 46 | |
47 | - $data['username'] = $this->session->userdata('user_name'); |
|
48 | - $data['page_title'] = 'Invoices'; |
|
49 | - $data['login_type'] = $this->session->userdata['userlevel_logintype']; |
|
50 | - $data['search_flag'] = true; |
|
51 | - $this->session->set_userdata('advance_search',0); |
|
52 | - $data['grid_fields']= $this->invoices_form->build_invoices_list_for_admin(); |
|
53 | - $data["grid_buttons"] = $this->invoices_form->build_grid_buttons(); |
|
54 | - $data['form_search']=$this->form->build_serach_form($this->invoices_form->get_invoice_search_form()); |
|
55 | - $account=$this->db_model->getSelect('id,first_name,last_name,number', 'accounts', array('status'=>0,'type'=>'0,3','deleted'=>0)) ; |
|
56 | - $data['account_value']=$account->result_array(); |
|
57 | - $this->load->view('view_invoices_list',$data); |
|
58 | - } |
|
59 | - function invoice_list_json() { |
|
60 | - $login_info = $this->session->userdata('accountinfo'); |
|
61 | - $logintype = $this->session->userdata('logintype'); |
|
62 | - $json_data = array(); |
|
63 | - $count_all = $this->invoices_model->get_invoice_list(false); |
|
64 | - $paging_data = $this->form->load_grid_config($count_all, $_GET['rp'], $_GET['page']); |
|
65 | - $json_data = $paging_data["json_paging"]; |
|
66 | - $result_query = $this->invoices_model->get_invoice_list(true,$paging_data["paging"]["start"], $paging_data["paging"]["page_no"]); |
|
67 | - if($logintype == -1){ |
|
68 | - $currency_id = Common_model::$global_config['system_config']['base_currency']; |
|
69 | - }else{ |
|
47 | + $data['username'] = $this->session->userdata('user_name'); |
|
48 | + $data['page_title'] = 'Invoices'; |
|
49 | + $data['login_type'] = $this->session->userdata['userlevel_logintype']; |
|
50 | + $data['search_flag'] = true; |
|
51 | + $this->session->set_userdata('advance_search',0); |
|
52 | + $data['grid_fields']= $this->invoices_form->build_invoices_list_for_admin(); |
|
53 | + $data["grid_buttons"] = $this->invoices_form->build_grid_buttons(); |
|
54 | + $data['form_search']=$this->form->build_serach_form($this->invoices_form->get_invoice_search_form()); |
|
55 | + $account=$this->db_model->getSelect('id,first_name,last_name,number', 'accounts', array('status'=>0,'type'=>'0,3','deleted'=>0)) ; |
|
56 | + $data['account_value']=$account->result_array(); |
|
57 | + $this->load->view('view_invoices_list',$data); |
|
58 | + } |
|
59 | + function invoice_list_json() { |
|
60 | + $login_info = $this->session->userdata('accountinfo'); |
|
61 | + $logintype = $this->session->userdata('logintype'); |
|
62 | + $json_data = array(); |
|
63 | + $count_all = $this->invoices_model->get_invoice_list(false); |
|
64 | + $paging_data = $this->form->load_grid_config($count_all, $_GET['rp'], $_GET['page']); |
|
65 | + $json_data = $paging_data["json_paging"]; |
|
66 | + $result_query = $this->invoices_model->get_invoice_list(true,$paging_data["paging"]["start"], $paging_data["paging"]["page_no"]); |
|
67 | + if($logintype == -1){ |
|
68 | + $currency_id = Common_model::$global_config['system_config']['base_currency']; |
|
69 | + }else{ |
|
70 | 70 | $accountdata["currency_id"] = $this->common->get_field_name('currency', 'currency', $login_info["currency_id"]); |
71 | - $currency_id = $accountdata["currency_id"]; |
|
72 | - } |
|
73 | - $grid_fields= json_decode($this->invoices_form->build_invoices_list_for_admin()); |
|
74 | - $url= ($logintype==0 ||$logintype==3 ) ? "/user/user_invoice_download/":'/invoices/invoice_download/'; |
|
75 | - if($result_query->num_rows > 0 ){ |
|
76 | - $query=$result_query->result_array(); |
|
77 | - $total_value = 0; |
|
78 | - $ountstanding_value = 0; |
|
79 | - foreach ($query as $key => $value) { |
|
71 | + $currency_id = $accountdata["currency_id"]; |
|
72 | + } |
|
73 | + $grid_fields= json_decode($this->invoices_form->build_invoices_list_for_admin()); |
|
74 | + $url= ($logintype==0 ||$logintype==3 ) ? "/user/user_invoice_download/":'/invoices/invoice_download/'; |
|
75 | + if($result_query->num_rows > 0 ){ |
|
76 | + $query=$result_query->result_array(); |
|
77 | + $total_value = 0; |
|
78 | + $ountstanding_value = 0; |
|
79 | + foreach ($query as $key => $value) { |
|
80 | 80 | $delete_button=''; |
81 | - $date = strtotime($value['invoice_date']); |
|
82 | - $invoice_date =date("Y-m-d",$date); |
|
83 | - $fromdate = strtotime($value['from_date']); |
|
84 | - $from_date =date("Y-m-d",$fromdate); |
|
85 | - $duedate = strtotime($value['due_date']); |
|
86 | - if($value['type'] == 'I'){ |
|
87 | - $due_date =date("Y-m-d",$duedate); |
|
88 | - }else{ |
|
89 | - $due_date=''; |
|
90 | - } |
|
91 | - $outstanding = $value['amount']; |
|
92 | - $last_payment_date = ''; |
|
93 | - $invoice_total_query = $this->db_model->select("sum(debit) as debit,sum(credit) as credit,created_date", "invoice_details", array("invoiceid"=> $value['id'],"item_type"=>"INVPAY"),"created_date","DESC","1","0"); |
|
94 | - // echo $this->db->last_query(); exit; |
|
95 | - if ($invoice_total_query ->num_rows() > 0){ |
|
96 | - $invoice_total_query= $invoice_total_query->result_array(); |
|
97 | - //echo '<pre>'; print_r($invoice_total_query); |
|
98 | - if($value['type'] == 'I'){ |
|
99 | - $outstanding -= $this->common->currency_decimal($invoice_total_query[0]['credit']); |
|
100 | - }else{ |
|
101 | - $outstanding=''; |
|
102 | - } |
|
103 | - $last_payment_date = $invoice_total_query[0]['created_date']; |
|
104 | - if($value['type'] == 'I'){ |
|
105 | - if($last_payment_date ){ |
|
106 | - $payment_date=strtotime( $last_payment_date); |
|
107 | - $payment_last=date("Y-m-d",$payment_date); |
|
108 | - }else{ |
|
109 | - $payment_last=''; |
|
110 | - } |
|
111 | - }else{ |
|
112 | - $payment_last=''; |
|
113 | - } |
|
81 | + $date = strtotime($value['invoice_date']); |
|
82 | + $invoice_date =date("Y-m-d",$date); |
|
83 | + $fromdate = strtotime($value['from_date']); |
|
84 | + $from_date =date("Y-m-d",$fromdate); |
|
85 | + $duedate = strtotime($value['due_date']); |
|
86 | + if($value['type'] == 'I'){ |
|
87 | + $due_date =date("Y-m-d",$duedate); |
|
88 | + }else{ |
|
89 | + $due_date=''; |
|
90 | + } |
|
91 | + $outstanding = $value['amount']; |
|
92 | + $last_payment_date = ''; |
|
93 | + $invoice_total_query = $this->db_model->select("sum(debit) as debit,sum(credit) as credit,created_date", "invoice_details", array("invoiceid"=> $value['id'],"item_type"=>"INVPAY"),"created_date","DESC","1","0"); |
|
94 | + // echo $this->db->last_query(); exit; |
|
95 | + if ($invoice_total_query ->num_rows() > 0){ |
|
96 | + $invoice_total_query= $invoice_total_query->result_array(); |
|
97 | + //echo '<pre>'; print_r($invoice_total_query); |
|
98 | + if($value['type'] == 'I'){ |
|
99 | + $outstanding -= $this->common->currency_decimal($invoice_total_query[0]['credit']); |
|
100 | + }else{ |
|
101 | + $outstanding=''; |
|
102 | + } |
|
103 | + $last_payment_date = $invoice_total_query[0]['created_date']; |
|
104 | + if($value['type'] == 'I'){ |
|
105 | + if($last_payment_date ){ |
|
106 | + $payment_date=strtotime( $last_payment_date); |
|
107 | + $payment_last=date("Y-m-d",$payment_date); |
|
108 | + }else{ |
|
109 | + $payment_last=''; |
|
110 | + } |
|
111 | + }else{ |
|
112 | + $payment_last=''; |
|
113 | + } |
|
114 | 114 | |
115 | - } |
|
115 | + } |
|
116 | 116 | |
117 | - $invoice_total=''; |
|
118 | - $accountinfo=$this->session->userdata('accountinfo'); |
|
119 | - $id=$accountinfo['id']; |
|
120 | - if($accountinfo['type'] == 1){ |
|
121 | - $query ="select sum(amount) as grand_total from invoices where reseller_id='$id'"; |
|
122 | - }else{ |
|
123 | - $query ="select sum(amount) as grand_total from invoices where reseller_id='0'"; |
|
124 | - } |
|
125 | - $ext_query=$this->db->query($query); |
|
126 | - if($ext_query->num_rows() > 0){ |
|
127 | - $result_total=$ext_query->result_array(); |
|
128 | - $grandtotal=$result_total[0]['grand_total']; |
|
129 | - $grand_total=$this->common->currency_decimal($grandtotal).' '.$currency_id; |
|
130 | - } |
|
117 | + $invoice_total=''; |
|
118 | + $accountinfo=$this->session->userdata('accountinfo'); |
|
119 | + $id=$accountinfo['id']; |
|
120 | + if($accountinfo['type'] == 1){ |
|
121 | + $query ="select sum(amount) as grand_total from invoices where reseller_id='$id'"; |
|
122 | + }else{ |
|
123 | + $query ="select sum(amount) as grand_total from invoices where reseller_id='0'"; |
|
124 | + } |
|
125 | + $ext_query=$this->db->query($query); |
|
126 | + if($ext_query->num_rows() > 0){ |
|
127 | + $result_total=$ext_query->result_array(); |
|
128 | + $grandtotal=$result_total[0]['grand_total']; |
|
129 | + $grand_total=$this->common->currency_decimal($grandtotal).' '.$currency_id; |
|
130 | + } |
|
131 | 131 | |
132 | 132 | |
133 | - if($accountinfo['type'] == 1){ |
|
134 | - $invoice_query ="select sum(credit) as grand_credit from invoice_details where reseller_id='$id'"; |
|
135 | - }else{ |
|
136 | - $invoice_query ="select sum(credit) as grand_credit from invoice_details where reseller_id='0'"; |
|
137 | - } |
|
138 | - $credit_query=$this->db->query($invoice_query); |
|
139 | - if($credit_query->num_rows() > 0){ |
|
140 | - $credit_total=$credit_query->result_array(); |
|
141 | - $grand_credit_total=$credit_total[0]['grand_credit']; |
|
142 | - $grandcredit=$grand_total-$grand_credit_total; |
|
143 | - $grand_credit=$this->common->currency_decimal($grandcredit).' '.$currency_id; |
|
144 | - } |
|
145 | - $download="<a href=" . $url .$value['id'].'/00_'.$value['invoice_prefix'].$value['invoiceid']. " class='btn btn-royelblue btn-sm' title='Download Invoice' ><i class='fa fa-cloud-download fa-fw'></i></a> "; |
|
146 | - if($value['type'] == 'I'){ |
|
133 | + if($accountinfo['type'] == 1){ |
|
134 | + $invoice_query ="select sum(credit) as grand_credit from invoice_details where reseller_id='$id'"; |
|
135 | + }else{ |
|
136 | + $invoice_query ="select sum(credit) as grand_credit from invoice_details where reseller_id='0'"; |
|
137 | + } |
|
138 | + $credit_query=$this->db->query($invoice_query); |
|
139 | + if($credit_query->num_rows() > 0){ |
|
140 | + $credit_total=$credit_query->result_array(); |
|
141 | + $grand_credit_total=$credit_total[0]['grand_credit']; |
|
142 | + $grandcredit=$grand_total-$grand_credit_total; |
|
143 | + $grand_credit=$this->common->currency_decimal($grandcredit).' '.$currency_id; |
|
144 | + } |
|
145 | + $download="<a href=" . $url .$value['id'].'/00_'.$value['invoice_prefix'].$value['invoiceid']. " class='btn btn-royelblue btn-sm' title='Download Invoice' ><i class='fa fa-cloud-download fa-fw'></i></a> "; |
|
146 | + if($value['type'] == 'I'){ |
|
147 | 147 | if($value['confirm'] ==0){ |
148 | 148 | if($value['generate_type'] ==1){ |
149 | - $payment = '<a href="'. base_url() .'invoices/invoice_manually_edit/' . $value['id'] . '" class="btn btn-royelblue btn-sm" title="Edit"><i class="fa fa-pencil-square-o fa-fw"></i></a>'; |
|
149 | + $payment = '<a href="'. base_url() .'invoices/invoice_manually_edit/' . $value['id'] . '" class="btn btn-royelblue btn-sm" title="Edit"><i class="fa fa-pencil-square-o fa-fw"></i></a>'; |
|
150 | 150 | }else{ |
151 | - $payment = '<a href="'. base_url() .'invoices/invoice_automatically_edit/' . $value['id'] . '" class="btn btn-royelblue btn-sm" title="Edit"><i class="fa fa-pencil-square-o fa-fw"></i></a>'; |
|
151 | + $payment = '<a href="'. base_url() .'invoices/invoice_automatically_edit/' . $value['id'] . '" class="btn btn-royelblue btn-sm" title="Edit"><i class="fa fa-pencil-square-o fa-fw"></i></a>'; |
|
152 | 152 | } |
153 | - $id=$value['id']; |
|
154 | - $delete_button="<a onclick='invoice_delete($id)' class='btn btn-royelblue btn-sm' title='Delete' ><i class='fa fa-trash fa-fw'></i></a> "; |
|
153 | + $id=$value['id']; |
|
154 | + $delete_button="<a onclick='invoice_delete($id)' class='btn btn-royelblue btn-sm' title='Delete' ><i class='fa fa-trash fa-fw'></i></a> "; |
|
155 | 155 | |
156 | 156 | }else{ |
157 | - if($outstanding > 0){ |
|
158 | - $payment = '<a style="padding: 0 8px;" href="'. base_url() .'invoices/invoice_summary/' . $value['id'] . '" class="btn btn-warning" title="Payment">Unpaid</i></a>'; |
|
159 | - }else{ |
|
160 | - $payment = '<button style="padding: 0 17px;" type="button" class="btn btn-success">Paid</button>'; |
|
161 | - } |
|
162 | - $delete_button=" "; |
|
163 | - } |
|
164 | - }else{ |
|
165 | - $payment = ''; |
|
166 | - } |
|
167 | - $account_arr = $this->db_model->getSelect('first_name,number,last_name','accounts', array('id'=>$value['accountid'])); |
|
168 | - $account_array = $account_arr->result_array(); |
|
169 | - if($value['generate_type'] == 1){ |
|
157 | + if($outstanding > 0){ |
|
158 | + $payment = '<a style="padding: 0 8px;" href="'. base_url() .'invoices/invoice_summary/' . $value['id'] . '" class="btn btn-warning" title="Payment">Unpaid</i></a>'; |
|
159 | + }else{ |
|
160 | + $payment = '<button style="padding: 0 17px;" type="button" class="btn btn-success">Paid</button>'; |
|
161 | + } |
|
162 | + $delete_button=" "; |
|
163 | + } |
|
164 | + }else{ |
|
165 | + $payment = ''; |
|
166 | + } |
|
167 | + $account_arr = $this->db_model->getSelect('first_name,number,last_name','accounts', array('id'=>$value['accountid'])); |
|
168 | + $account_array = $account_arr->result_array(); |
|
169 | + if($value['generate_type'] == 1){ |
|
170 | 170 | $invoice_type='Manually'; |
171 | 171 | }else{ |
172 | 172 | $invoice_type='Automatically'; |
@@ -191,110 +191,110 @@ discard block |
||
191 | 191 | |
192 | 192 | } |
193 | 193 | |
194 | - $json_data['rows'][] = array('cell' => array( |
|
194 | + $json_data['rows'][] = array('cell' => array( |
|
195 | 195 | |
196 | 196 | $value['invoice_prefix'].$value['invoiceid'].$icon, |
197 | - //$value['invoice_prefix'].$value['invoiceid'].'('.$value['type'].')', |
|
197 | + //$value['invoice_prefix'].$value['invoiceid'].'('.$value['type'].')', |
|
198 | 198 | $invoice_type, |
199 | - $account_array[0]['first_name'].' '.$account_array[0]['last_name'].'</br>'.$account_array[0]['number'], |
|
200 | - $invoice_date, |
|
201 | - $from_date, |
|
202 | - $due_date, |
|
203 | - $payment_last, |
|
204 | - $this->common->currency_decimal($this->common_model->calculate_currency($value['amount'])), |
|
205 | - $this->common->currency_decimal($this->common_model->calculate_currency($outstanding)), |
|
206 | - $download.''.$payment.' '.$delete_button, |
|
199 | + $account_array[0]['first_name'].' '.$account_array[0]['last_name'].'</br>'.$account_array[0]['number'], |
|
200 | + $invoice_date, |
|
201 | + $from_date, |
|
202 | + $due_date, |
|
203 | + $payment_last, |
|
204 | + $this->common->currency_decimal($this->common_model->calculate_currency($value['amount'])), |
|
205 | + $this->common->currency_decimal($this->common_model->calculate_currency($outstanding)), |
|
206 | + $download.''.$payment.' '.$delete_button, |
|
207 | 207 | |
208 | - )); |
|
209 | - $total_value=$total_value + $value['amount']; |
|
210 | - $ountstanding_value=$ountstanding_value + $outstanding; |
|
211 | - } |
|
212 | - } |
|
213 | - echo json_encode($json_data); |
|
208 | + )); |
|
209 | + $total_value=$total_value + $value['amount']; |
|
210 | + $ountstanding_value=$ountstanding_value + $outstanding; |
|
211 | + } |
|
212 | + } |
|
213 | + echo json_encode($json_data); |
|
214 | 214 | |
215 | - } |
|
216 | - function invoice_manually_edit($id){ |
|
217 | - $confirm = $this->common->get_field_name('confirm', 'invoices', $id); |
|
218 | - $deleted = $this->common->get_field_name('deleted', 'invoices', $id); |
|
215 | + } |
|
216 | + function invoice_manually_edit($id){ |
|
217 | + $confirm = $this->common->get_field_name('confirm', 'invoices', $id); |
|
218 | + $deleted = $this->common->get_field_name('deleted', 'invoices', $id); |
|
219 | 219 | if($confirm == 1 || $deleted == 1){ |
220 | - redirect(base_url() . 'invoices/invoice_list/'); |
|
220 | + redirect(base_url() . 'invoices/invoice_list/'); |
|
221 | 221 | } |
222 | 222 | $data['total_tax_dis']=0; |
223 | 223 | $data['total_credit_dis']=0; |
224 | - $query="SELECT * from invoice_details where generate_type=1 AND invoiceid='$id' "; |
|
225 | - $invoice_total_query=$this->db->query($query); |
|
224 | + $query="SELECT * from invoice_details where generate_type=1 AND invoiceid='$id' "; |
|
225 | + $invoice_total_query=$this->db->query($query); |
|
226 | 226 | $data['count']=0; |
227 | 227 | $data['row_count']=5; |
228 | - if ($invoice_total_query->num_rows() > 0) { |
|
229 | - $count=$invoice_total_query ->num_rows(); |
|
230 | - $data['count']=$count; |
|
231 | - $invoice_total_query= $invoice_total_query->result_array(); |
|
232 | - $i=1; |
|
233 | - $taxi=0; |
|
234 | - $get_data=array(); |
|
235 | - $data['total_tax_dis']=array(); |
|
236 | - foreach($invoice_total_query as $value){ |
|
228 | + if ($invoice_total_query->num_rows() > 0) { |
|
229 | + $count=$invoice_total_query ->num_rows(); |
|
230 | + $data['count']=$count; |
|
231 | + $invoice_total_query= $invoice_total_query->result_array(); |
|
232 | + $i=1; |
|
233 | + $taxi=0; |
|
234 | + $get_data=array(); |
|
235 | + $data['total_tax_dis']=array(); |
|
236 | + foreach($invoice_total_query as $value){ |
|
237 | 237 | if($value['item_type'] == 'TAX'){ |
238 | 238 | $data['total_tax_dis'][$taxi]=$value['debit']; |
239 | 239 | $taxi++; |
240 | 240 | }else{ |
241 | - if($i >= 5){ |
|
242 | - $data['row_count']=$i+1; |
|
243 | - } |
|
244 | - $get_data['invoice_from_date_'.$i]=$value['created_date']; |
|
245 | - $get_data['invoice_description_'.$i]=$value['description']; |
|
246 | - $get_data['invoice_amount_'.$i]=$value['debit']; |
|
247 | - $i++; |
|
248 | - $data['total_credit_dis'] += $value['debit']; |
|
241 | + if($i >= 5){ |
|
242 | + $data['row_count']=$i+1; |
|
243 | + } |
|
244 | + $get_data['invoice_from_date_'.$i]=$value['created_date']; |
|
245 | + $get_data['invoice_description_'.$i]=$value['description']; |
|
246 | + $get_data['invoice_amount_'.$i]=$value['debit']; |
|
247 | + $i++; |
|
248 | + $data['total_credit_dis'] += $value['debit']; |
|
249 | + } |
|
249 | 250 | } |
250 | - } |
|
251 | - $data['get_data']=$get_data; |
|
251 | + $data['get_data']=$get_data; |
|
252 | 252 | } |
253 | - $account_data = $this->session->userdata("accountinfo"); |
|
254 | - $logintype = $this->session->userdata('logintype'); |
|
255 | - $invoice_total=''; |
|
256 | - $query="SELECT * from invoice_details where item_type='INVPAY' AND invoiceid='$id' ORDER BY created_date ASC"; |
|
257 | - $invoice = $this->db_model->getSelect("*", "invoices", array("id"=> $id)); |
|
258 | - if ($invoice ->num_rows() > 0) { |
|
259 | - $invoice= $invoice->result_array(); |
|
260 | - $result=$invoice[0]; |
|
261 | - $data['payment_due_date']=$result['due_date']; |
|
262 | - } |
|
253 | + $account_data = $this->session->userdata("accountinfo"); |
|
254 | + $logintype = $this->session->userdata('logintype'); |
|
255 | + $invoice_total=''; |
|
256 | + $query="SELECT * from invoice_details where item_type='INVPAY' AND invoiceid='$id' ORDER BY created_date ASC"; |
|
257 | + $invoice = $this->db_model->getSelect("*", "invoices", array("id"=> $id)); |
|
258 | + if ($invoice ->num_rows() > 0) { |
|
259 | + $invoice= $invoice->result_array(); |
|
260 | + $result=$invoice[0]; |
|
261 | + $data['payment_due_date']=$result['due_date']; |
|
262 | + } |
|
263 | 263 | |
264 | - $accountdata = $this->db_model->getSelect("*","accounts",array("id"=> $result['accountid'])); |
|
265 | - if ($accountdata ->num_rows() > 0) { |
|
266 | - $accountdata = $accountdata->result_array(); |
|
267 | - $accountdata = $accountdata[0]; |
|
268 | - } |
|
264 | + $accountdata = $this->db_model->getSelect("*","accounts",array("id"=> $result['accountid'])); |
|
265 | + if ($accountdata ->num_rows() > 0) { |
|
266 | + $accountdata = $accountdata->result_array(); |
|
267 | + $accountdata = $accountdata[0]; |
|
268 | + } |
|
269 | 269 | $data['taxes_count']= 0; |
270 | - $taxes = $this->db_model->getSelect("*","taxes_to_accounts",array("accountid"=> $result['accountid'])); |
|
271 | - $total_tax=0; |
|
270 | + $taxes = $this->db_model->getSelect("*","taxes_to_accounts",array("accountid"=> $result['accountid'])); |
|
271 | + $total_tax=0; |
|
272 | 272 | $data['taxes_count']= $taxes->num_rows(); |
273 | - if ($taxes ->num_rows() > 0) { |
|
274 | - $taxes = $taxes->result_array(); |
|
273 | + if ($taxes ->num_rows() > 0) { |
|
274 | + $taxes = $taxes->result_array(); |
|
275 | 275 | foreach($taxes as $tax_value){ |
276 | - $taxe_res = $this->db_model->getSelect("*","taxes",array("id"=> $tax_value['taxes_id'])); |
|
277 | - $taxe_res = $taxe_res->result_array(); |
|
278 | - foreach($taxe_res as $taxe_res_val){ |
|
279 | - $data['taxes_to_accounts'][]= $taxe_res_val; |
|
280 | - $total_tax +=$taxe_res_val['taxes_rate']; |
|
281 | - } |
|
276 | + $taxe_res = $this->db_model->getSelect("*","taxes",array("id"=> $tax_value['taxes_id'])); |
|
277 | + $taxe_res = $taxe_res->result_array(); |
|
278 | + foreach($taxe_res as $taxe_res_val){ |
|
279 | + $data['taxes_to_accounts'][]= $taxe_res_val; |
|
280 | + $total_tax +=$taxe_res_val['taxes_rate']; |
|
281 | + } |
|
282 | 282 | } |
283 | - } |
|
283 | + } |
|
284 | 284 | |
285 | - $system_config = common_model::$global_config['system_config']; |
|
286 | - if($system_config["paypal_mode"]==0){ |
|
287 | - $data["paypal_url"] = $system_config["paypal_url"]; |
|
288 | - $data["paypal_email_id"] = $system_config["paypal_id"]; |
|
289 | - }else{ |
|
290 | - $data["paypal_url"] = $system_config["paypal_sandbox_url"]; |
|
291 | - $data["paypal_email_id"] = $system_config["paypal_sandbox_id"]; |
|
292 | - } |
|
293 | - $date = strtotime($result['invoice_date']); |
|
294 | - $data['time'] = date("Y-m-d h:i:s ",$date); |
|
295 | - $data["paypal_tax"] = $system_config["paypal_tax"]; |
|
296 | - $data["from_currency"] = $this->common->get_field_name('currency', 'currency', $account_data["currency_id"]); |
|
297 | - $data["to_currency"] = Common_model::$global_config['system_config']['base_currency']; |
|
285 | + $system_config = common_model::$global_config['system_config']; |
|
286 | + if($system_config["paypal_mode"]==0){ |
|
287 | + $data["paypal_url"] = $system_config["paypal_url"]; |
|
288 | + $data["paypal_email_id"] = $system_config["paypal_id"]; |
|
289 | + }else{ |
|
290 | + $data["paypal_url"] = $system_config["paypal_sandbox_url"]; |
|
291 | + $data["paypal_email_id"] = $system_config["paypal_sandbox_id"]; |
|
292 | + } |
|
293 | + $date = strtotime($result['invoice_date']); |
|
294 | + $data['time'] = date("Y-m-d h:i:s ",$date); |
|
295 | + $data["paypal_tax"] = $system_config["paypal_tax"]; |
|
296 | + $data["from_currency"] = $this->common->get_field_name('currency', 'currency', $account_data["currency_id"]); |
|
297 | + $data["to_currency"] = Common_model::$global_config['system_config']['base_currency']; |
|
298 | 298 | if($account_data['type'] == -1){ |
299 | 299 | $data["to_currency"] = $data["to_currency"]; |
300 | 300 | }elseif($account_data['type'] == 1){ |
@@ -327,112 +327,112 @@ discard block |
||
327 | 327 | $data['response_url'] = base_url() . "user/user_list_responce/"; |
328 | 328 | } |
329 | 329 | $data['sucess_url'] = base_url() . "invoices/invoice_list_sucess"; |
330 | - $this->load->view('view_invoice_edit_manually',$data); |
|
331 | - } |
|
332 | - function invoice_automatically_edit($id){ |
|
333 | - $confirm = $this->common->get_field_name('confirm', 'invoices', $id); |
|
334 | - $deleted = $this->common->get_field_name('deleted', 'invoices', $id); |
|
330 | + $this->load->view('view_invoice_edit_manually',$data); |
|
331 | + } |
|
332 | + function invoice_automatically_edit($id){ |
|
333 | + $confirm = $this->common->get_field_name('confirm', 'invoices', $id); |
|
334 | + $deleted = $this->common->get_field_name('deleted', 'invoices', $id); |
|
335 | 335 | if($confirm == 1 || $deleted == 1){ |
336 | - redirect(base_url() . 'invoices/invoice_list/'); |
|
336 | + redirect(base_url() . 'invoices/invoice_list/'); |
|
337 | 337 | } |
338 | 338 | $data['total_tax_dis']=0; |
339 | 339 | $data['total_credit_dis']=0; |
340 | - $query="SELECT * from invoice_details where invoiceid='$id' "; |
|
341 | - $invoice_total_query=$this->db->query($query); |
|
340 | + $query="SELECT * from invoice_details where invoiceid='$id' "; |
|
341 | + $invoice_total_query=$this->db->query($query); |
|
342 | 342 | $data['count']=0; |
343 | 343 | $data['row_count']=5; |
344 | - if ($invoice_total_query->num_rows() > 0) { |
|
345 | - $count=$invoice_total_query ->num_rows(); |
|
346 | - $data['count']=$count; |
|
347 | - $invoice_total_query= $invoice_total_query->result_array(); |
|
348 | - $i=1;$taxi=0; |
|
349 | - $get_data=array(); |
|
350 | - $data['total_tax_dis']=array(); |
|
351 | - $data['total_credit_sum']=0; |
|
352 | - foreach($invoice_total_query as $value){ |
|
344 | + if ($invoice_total_query->num_rows() > 0) { |
|
345 | + $count=$invoice_total_query ->num_rows(); |
|
346 | + $data['count']=$count; |
|
347 | + $invoice_total_query= $invoice_total_query->result_array(); |
|
348 | + $i=1;$taxi=0; |
|
349 | + $get_data=array(); |
|
350 | + $data['total_tax_dis']=array(); |
|
351 | + $data['total_credit_sum']=0; |
|
352 | + foreach($invoice_total_query as $value){ |
|
353 | 353 | if($value['item_type'] == 'TAX'){ |
354 | 354 | $data['total_tax_dis'][$taxi]=$value['debit']; |
355 | 355 | $taxi++; |
356 | 356 | }else{ |
357 | 357 | if($value['generate_type'] == 1){ |
358 | - if($i >= 5){ |
|
359 | - $data['row_count']=$i+1; |
|
360 | - } |
|
361 | - $get_data['invoice_from_date_'.$i]=$value['created_date']; |
|
362 | - $get_data['invoice_description_'.$i]=$value['description']; |
|
363 | - $get_data['invoice_amount_'.$i]=$value['debit']; |
|
364 | - $i++; |
|
365 | - $data['total_credit_dis'] += $value['debit']; |
|
358 | + if($i >= 5){ |
|
359 | + $data['row_count']=$i+1; |
|
360 | + } |
|
361 | + $get_data['invoice_from_date_'.$i]=$value['created_date']; |
|
362 | + $get_data['invoice_description_'.$i]=$value['description']; |
|
363 | + $get_data['invoice_amount_'.$i]=$value['debit']; |
|
364 | + $i++; |
|
365 | + $data['total_credit_dis'] += $value['debit']; |
|
366 | 366 | } |
367 | - $data['total_credit_sum'] += $value['debit']; |
|
367 | + $data['total_credit_sum'] += $value['debit']; |
|
368 | + } |
|
368 | 369 | } |
369 | - } |
|
370 | - $data['get_data']=$get_data; |
|
370 | + $data['get_data']=$get_data; |
|
371 | 371 | } |
372 | - $account_data = $this->session->userdata("accountinfo"); |
|
373 | - $logintype = $this->session->userdata('logintype'); |
|
374 | - $invoice_total=''; |
|
375 | - $query="SELECT * from invoice_details where invoiceid='$id' and generate_type=0 and item_type != 'TAX' ORDER BY id ASC"; |
|
376 | - $invoice_total_query=$this->db->query($query); |
|
372 | + $account_data = $this->session->userdata("accountinfo"); |
|
373 | + $logintype = $this->session->userdata('logintype'); |
|
374 | + $invoice_total=''; |
|
375 | + $query="SELECT * from invoice_details where invoiceid='$id' and generate_type=0 and item_type != 'TAX' ORDER BY id ASC"; |
|
376 | + $invoice_total_query=$this->db->query($query); |
|
377 | 377 | $data['auto_count']=0; |
378 | - if ($invoice_total_query ->num_rows() > 0) { |
|
378 | + if ($invoice_total_query ->num_rows() > 0) { |
|
379 | 379 | $data['auto_count']=$invoice_total_query ->num_rows(); |
380 | - $invoice_total_query= $invoice_total_query->result_array(); |
|
380 | + $invoice_total_query= $invoice_total_query->result_array(); |
|
381 | 381 | |
382 | - $data['invoice_total_query']=$invoice_total_query; |
|
383 | - } |
|
384 | - $invoice = $this->db_model->getSelect("*", "invoices", array("id"=> $id)); |
|
385 | - if ($invoice ->num_rows() > 0) { |
|
386 | - $invoice= $invoice->result_array(); |
|
387 | - $result=$invoice[0]; |
|
388 | - $data['payment_due_date']=$result['due_date']; |
|
389 | - } |
|
390 | - $invoice_auto_res = $this->db_model->getSelect("sum(debit) as debit", "invoice_details", array("invoiceid"=> $id,'generate_type'=>0)); |
|
382 | + $data['invoice_total_query']=$invoice_total_query; |
|
383 | + } |
|
384 | + $invoice = $this->db_model->getSelect("*", "invoices", array("id"=> $id)); |
|
385 | + if ($invoice ->num_rows() > 0) { |
|
386 | + $invoice= $invoice->result_array(); |
|
387 | + $result=$invoice[0]; |
|
388 | + $data['payment_due_date']=$result['due_date']; |
|
389 | + } |
|
390 | + $invoice_auto_res = $this->db_model->getSelect("sum(debit) as debit", "invoice_details", array("invoiceid"=> $id,'generate_type'=>0)); |
|
391 | 391 | $data['invoice_auto_res']=0; |
392 | - if ($invoice_auto_res ->num_rows() > 0) { |
|
393 | - $invoice_auto_res= $invoice_auto_res->result_array(); |
|
394 | - $result_auto_res=$invoice_auto_res[0]; |
|
395 | - $data['invoice_auto_res'] =$result_auto_res['debit']; |
|
396 | - } |
|
392 | + if ($invoice_auto_res ->num_rows() > 0) { |
|
393 | + $invoice_auto_res= $invoice_auto_res->result_array(); |
|
394 | + $result_auto_res=$invoice_auto_res[0]; |
|
395 | + $data['invoice_auto_res'] =$result_auto_res['debit']; |
|
396 | + } |
|
397 | 397 | |
398 | - $accountdata = $this->db_model->getSelect("*","accounts",array("id"=> $result['accountid'])); |
|
399 | - if ($accountdata ->num_rows() > 0) { |
|
400 | - $accountdata = $accountdata->result_array(); |
|
401 | - $accountdata = $accountdata[0]; |
|
402 | - } |
|
398 | + $accountdata = $this->db_model->getSelect("*","accounts",array("id"=> $result['accountid'])); |
|
399 | + if ($accountdata ->num_rows() > 0) { |
|
400 | + $accountdata = $accountdata->result_array(); |
|
401 | + $accountdata = $accountdata[0]; |
|
402 | + } |
|
403 | 403 | $data['taxes_count']= 0; |
404 | - $taxes = $this->db_model->getSelect("*","taxes_to_accounts",array("accountid"=> $result['accountid'])); |
|
404 | + $taxes = $this->db_model->getSelect("*","taxes_to_accounts",array("accountid"=> $result['accountid'])); |
|
405 | 405 | $data['taxes_count']= $taxes->num_rows(); |
406 | - $total_tax=0; |
|
407 | - if ($taxes ->num_rows() > 0) { |
|
408 | - $taxes = $taxes->result_array(); |
|
406 | + $total_tax=0; |
|
407 | + if ($taxes ->num_rows() > 0) { |
|
408 | + $taxes = $taxes->result_array(); |
|
409 | 409 | foreach($taxes as $tax_value){ |
410 | - $taxe_res = $this->db_model->getSelect("*","taxes",array("id"=> $tax_value['taxes_id'])); |
|
411 | - $taxe_res = $taxe_res->result_array(); |
|
412 | - foreach($taxe_res as $taxe_res_val){ |
|
413 | - $data['taxes_to_accounts'][]= $taxe_res_val; |
|
414 | - $total_tax +=$taxe_res_val['taxes_rate']; |
|
415 | - } |
|
410 | + $taxe_res = $this->db_model->getSelect("*","taxes",array("id"=> $tax_value['taxes_id'])); |
|
411 | + $taxe_res = $taxe_res->result_array(); |
|
412 | + foreach($taxe_res as $taxe_res_val){ |
|
413 | + $data['taxes_to_accounts'][]= $taxe_res_val; |
|
414 | + $total_tax +=$taxe_res_val['taxes_rate']; |
|
415 | + } |
|
416 | 416 | } |
417 | - } |
|
417 | + } |
|
418 | 418 | |
419 | - $system_config = common_model::$global_config['system_config']; |
|
420 | - if($system_config["paypal_mode"]==0){ |
|
421 | - $data["paypal_url"] = $system_config["paypal_url"]; |
|
422 | - $data["paypal_email_id"] = $system_config["paypal_id"]; |
|
423 | - }else{ |
|
424 | - $data["paypal_url"] = $system_config["paypal_sandbox_url"]; |
|
425 | - $data["paypal_email_id"] = $system_config["paypal_sandbox_id"]; |
|
426 | - } |
|
427 | - $date = strtotime($result['invoice_date']); |
|
419 | + $system_config = common_model::$global_config['system_config']; |
|
420 | + if($system_config["paypal_mode"]==0){ |
|
421 | + $data["paypal_url"] = $system_config["paypal_url"]; |
|
422 | + $data["paypal_email_id"] = $system_config["paypal_id"]; |
|
423 | + }else{ |
|
424 | + $data["paypal_url"] = $system_config["paypal_sandbox_url"]; |
|
425 | + $data["paypal_email_id"] = $system_config["paypal_sandbox_id"]; |
|
426 | + } |
|
427 | + $date = strtotime($result['invoice_date']); |
|
428 | 428 | $data['total_tax']=$total_tax; |
429 | - $data['time'] = date("Y-m-d h:i:s ",$date); |
|
430 | - $data["paypal_tax"] = $system_config["paypal_tax"]; |
|
431 | - $data["from_currency"] = $this->common->get_field_name('currency', 'currency', $account_data["currency_id"]); |
|
432 | - $data["to_currency"] = Common_model::$global_config['system_config']['base_currency']; |
|
429 | + $data['time'] = date("Y-m-d h:i:s ",$date); |
|
430 | + $data["paypal_tax"] = $system_config["paypal_tax"]; |
|
431 | + $data["from_currency"] = $this->common->get_field_name('currency', 'currency', $account_data["currency_id"]); |
|
432 | + $data["to_currency"] = Common_model::$global_config['system_config']['base_currency']; |
|
433 | 433 | if($account_data['type'] == -1){ |
434 | 434 | $accountdata["currency_id"] = $this->common->get_field_name('currency', 'currency', $account_data["currency_id"]); |
435 | - $data["to_currency"] = $accountdata["currency_id"]; |
|
435 | + $data["to_currency"] = $accountdata["currency_id"]; |
|
436 | 436 | }elseif($account_data['type'] == 1){ |
437 | 437 | $accountdata["currency_id"] = $this->common->get_field_name('currency', 'currency', $account_data["currency_id"]); |
438 | 438 | $data["to_currency"] = $accountdata["currency_id"]; |
@@ -463,9 +463,9 @@ discard block |
||
463 | 463 | } |
464 | 464 | $data['sucess_url'] = base_url() . "invoices/invoice_list_sucess"; |
465 | 465 | |
466 | - $this->load->view('view_invoice_edit_automatically',$data); |
|
467 | - } |
|
468 | - function invoice_manually_payment_edit_save(){ |
|
466 | + $this->load->view('view_invoice_edit_automatically',$data); |
|
467 | + } |
|
468 | + function invoice_manually_payment_edit_save(){ |
|
469 | 469 | $response_arr=$_POST; |
470 | 470 | if(isset($response_arr['save'])){ |
471 | 471 | $confirm=0; |
@@ -473,11 +473,11 @@ discard block |
||
473 | 473 | $confirm=1; |
474 | 474 | } |
475 | 475 | $where=array('invoiceid'=>$response_arr['invoiceid'],'generate_type'=>1); |
476 | - $this->db->where($where); |
|
477 | - $this->db->delete("invoice_details"); |
|
476 | + $this->db->where($where); |
|
477 | + $this->db->delete("invoice_details"); |
|
478 | 478 | $final_bal=0; |
479 | 479 | $final_tax_bal=0; |
480 | - $account_balance = $this->common->get_field_name('balance', 'accounts', $response_arr['accountid']); |
|
480 | + $account_balance = $this->common->get_field_name('balance', 'accounts', $response_arr['accountid']); |
|
481 | 481 | if($response_arr['taxes_count'] > 0){ |
482 | 482 | for($a=0 ;$a < $response_arr['taxes_count'];$a++){ |
483 | 483 | $add_arr=array( |
@@ -492,7 +492,7 @@ discard block |
||
492 | 492 | 'created_date'=>gmdate("Y-m-d H:i:s"), |
493 | 493 | ); |
494 | 494 | $final_tax_bal +=$this->common_model->add_calculate_currency($response_arr['abc_total_tax_input_'.$a],"","",true,false); |
495 | - $this->db->insert("invoice_details",$add_arr); |
|
495 | + $this->db->insert("invoice_details",$add_arr); |
|
496 | 496 | } |
497 | 497 | } |
498 | 498 | for ($i = 1; $i <= $response_arr['row_count']; $i++) { |
@@ -508,16 +508,16 @@ discard block |
||
508 | 508 | 'debit'=>$this->common_model->add_calculate_currency($response_arr['invoice_amount_'.$i],"","",true,false), |
509 | 509 | 'created_date'=>$response_arr['invoice_from_date_'.$i], |
510 | 510 | ); |
511 | - $this->db->insert("invoice_details",$add_arr); |
|
511 | + $this->db->insert("invoice_details",$add_arr); |
|
512 | 512 | } |
513 | 513 | $final_bal += $this->common_model->add_calculate_currency($response_arr['invoice_amount_'.$i],"","",true,false); |
514 | 514 | } |
515 | - $query="select sum(debit) as credit from invoice_details where invoiceid = ".$response_arr['invoiceid']; |
|
516 | - $invoice_total_query=$this->db->query($query); |
|
517 | - $invoice_total_query= $invoice_total_query->result_array(); |
|
518 | - $data = array('amount' =>$this->common_model->add_calculate_currency($response_arr['total_val_final'],"","",true,false),'confirm'=>$confirm,'notes'=>$response_arr['invoice_notes']); |
|
519 | - $this->db->where("id", $response_arr['invoiceid']); |
|
520 | - $this->db->update("invoices", $data); |
|
515 | + $query="select sum(debit) as credit from invoice_details where invoiceid = ".$response_arr['invoiceid']; |
|
516 | + $invoice_total_query=$this->db->query($query); |
|
517 | + $invoice_total_query= $invoice_total_query->result_array(); |
|
518 | + $data = array('amount' =>$this->common_model->add_calculate_currency($response_arr['total_val_final'],"","",true,false),'confirm'=>$confirm,'notes'=>$response_arr['invoice_notes']); |
|
519 | + $this->db->where("id", $response_arr['invoiceid']); |
|
520 | + $this->db->update("invoices", $data); |
|
521 | 521 | if($confirm == 1){ |
522 | 522 | $invoice_details = $this->db_model->getSelect("*", "invoice_details", array("invoiceid" => $response_arr["invoiceid"])); |
523 | 523 | if($invoice_details->num_rows >0){ |
@@ -544,11 +544,11 @@ discard block |
||
544 | 544 | }else{ |
545 | 545 | $payment=$response_arr['reseller_id']; |
546 | 546 | } |
547 | - $invoice_prefix = $this->common->get_field_name('invoice_prefix', 'invoices', $response_arr['invoiceid']); |
|
548 | - $invoice_prefix_id = $this->common->get_field_name('invoiceid', 'invoices', $response_arr['invoiceid']); |
|
549 | - $payment_arr = array("accountid"=> $response_arr["accountid"],"payment_mode"=>"1","credit"=>$this->common_model->add_calculate_currency($response_arr['total_val_final'],"","",true,false),"type"=>"invoice","payment_by"=>$payment,"notes"=>"Payment made by ".$account_data[0]['first_name']." ".$account_data[0]['last_name'].", invoices No: ".$invoice_prefix ."_".$invoice_prefix_id." ","paypalid"=>'',"txn_id"=>'','payment_date'=>gmdate('Y-m-d H:i:s')); |
|
550 | - $this->db->insert('payments', $payment_arr); |
|
551 | - $account_balance = $this->common->get_field_name('balance', 'accounts', $response_arr['accountid']); |
|
547 | + $invoice_prefix = $this->common->get_field_name('invoice_prefix', 'invoices', $response_arr['invoiceid']); |
|
548 | + $invoice_prefix_id = $this->common->get_field_name('invoiceid', 'invoices', $response_arr['invoiceid']); |
|
549 | + $payment_arr = array("accountid"=> $response_arr["accountid"],"payment_mode"=>"1","credit"=>$this->common_model->add_calculate_currency($response_arr['total_val_final'],"","",true,false),"type"=>"invoice","payment_by"=>$payment,"notes"=>"Payment made by ".$account_data[0]['first_name']." ".$account_data[0]['last_name'].", invoices No: ".$invoice_prefix ."_".$invoice_prefix_id." ","paypalid"=>'',"txn_id"=>'','payment_date'=>gmdate('Y-m-d H:i:s')); |
|
550 | + $this->db->insert('payments', $payment_arr); |
|
551 | + $account_balance = $this->common->get_field_name('balance', 'accounts', $response_arr['accountid']); |
|
552 | 552 | $add_arr=array( |
553 | 553 | 'accountid'=>$response_arr['accountid'], |
554 | 554 | 'reseller_id'=>$response_arr['reseller_id'], |
@@ -562,7 +562,7 @@ discard block |
||
562 | 562 | 'before_balance'=>$account_balance, |
563 | 563 | 'after_balance'=>$account_balance-$this->common_model->add_calculate_currency($response_arr['total_val_final'],"","",true,false), |
564 | 564 | ); |
565 | - $this->db->insert("invoice_details",$add_arr); |
|
565 | + $this->db->insert("invoice_details",$add_arr); |
|
566 | 566 | } |
567 | 567 | $this->db->where("id", $response_arr['accountid']); |
568 | 568 | $act_status=0; |
@@ -575,10 +575,10 @@ discard block |
||
575 | 575 | $this->invoice_send_notification($response_arr['invoiceid'],$account_data[0],'manually'); |
576 | 576 | /***** ***/ |
577 | 577 | } |
578 | - $this->session->set_flashdata('astpp_errormsg', 'Invoice updated successfully!'); |
|
579 | - redirect(base_url() . 'invoices/invoice_list/'); |
|
580 | - } |
|
581 | - function invoice_automatically_payment_edit_save(){ |
|
578 | + $this->session->set_flashdata('astpp_errormsg', 'Invoice updated successfully!'); |
|
579 | + redirect(base_url() . 'invoices/invoice_list/'); |
|
580 | + } |
|
581 | + function invoice_automatically_payment_edit_save(){ |
|
582 | 582 | $response_arr=$_POST; |
583 | 583 | if(isset($response_arr['save'])){ |
584 | 584 | $confirm=0; |
@@ -586,17 +586,17 @@ discard block |
||
586 | 586 | $confirm=1; |
587 | 587 | } |
588 | 588 | foreach($response_arr['auto_invoice_date'] as $key=>$val){ |
589 | - $data = array('debit' => $this->common_model->add_calculate_currency($response_arr['auto_invoice_amount'][$key],"","",true,false),'created_date'=>$response_arr['auto_invoice_date'][$key],'description'=>$response_arr['auto_invoice_description'][$key],'generate_type'=>0); |
|
590 | - $this->db->where("id", $key); |
|
591 | - $this->db->update("invoice_details", $data); |
|
589 | + $data = array('debit' => $this->common_model->add_calculate_currency($response_arr['auto_invoice_amount'][$key],"","",true,false),'created_date'=>$response_arr['auto_invoice_date'][$key],'description'=>$response_arr['auto_invoice_description'][$key],'generate_type'=>0); |
|
590 | + $this->db->where("id", $key); |
|
591 | + $this->db->update("invoice_details", $data); |
|
592 | 592 | |
593 | 593 | } |
594 | 594 | $where=array('invoiceid'=>$response_arr['invoiceid'],'generate_type'=>1); |
595 | - $this->db->where($where); |
|
596 | - $this->db->delete("invoice_details"); |
|
595 | + $this->db->where($where); |
|
596 | + $this->db->delete("invoice_details"); |
|
597 | 597 | $final_bal=0; |
598 | 598 | $final_tax_bal=0; |
599 | - $account_balance = $this->common->get_field_name('balance', 'accounts', $response_arr['accountid']); |
|
599 | + $account_balance = $this->common->get_field_name('balance', 'accounts', $response_arr['accountid']); |
|
600 | 600 | if($response_arr['taxes_count'] > 0){ |
601 | 601 | for($a=0 ;$a < $response_arr['row_count'];$a++){ |
602 | 602 | $arr_update=array('item_type'=>'TAX','id'=>$response_arr['description_total_tax_id_'.$a]); |
@@ -605,10 +605,10 @@ discard block |
||
605 | 605 | 'debit'=>$this->common_model->add_calculate_currency($response_arr['abc_total_tax_input_'.$a],"","",true,false), |
606 | 606 | ); |
607 | 607 | $final_tax_bal +=$this->common_model->add_calculate_currency($response_arr['abc_total_tax_input_'.$a],"","",true,false); |
608 | - $this->db->update("invoice_details",$update_arr); |
|
608 | + $this->db->update("invoice_details",$update_arr); |
|
609 | 609 | } |
610 | 610 | } |
611 | - for ($i = 1; $i <=$response_arr['row_count']; $i++) { |
|
611 | + for ($i = 1; $i <=$response_arr['row_count']; $i++) { |
|
612 | 612 | if($response_arr['invoice_amount_'.$i] != ''){ |
613 | 613 | $add_arr=array( |
614 | 614 | 'accountid'=>$response_arr['accountid'], |
@@ -621,15 +621,15 @@ discard block |
||
621 | 621 | 'debit'=>$this->common_model->add_calculate_currency($response_arr['invoice_amount_'.$i],"","",true,false), |
622 | 622 | 'created_date'=>$response_arr['invoice_from_date_'.$i], |
623 | 623 | ); |
624 | - $this->db->insert("invoice_details",$add_arr); |
|
624 | + $this->db->insert("invoice_details",$add_arr); |
|
625 | + } |
|
625 | 626 | } |
626 | - } |
|
627 | - $query="select sum(debit) as credit from invoice_details where invoiceid = ".$response_arr['invoiceid']; |
|
628 | - $invoice_total_query=$this->db->query($query); |
|
629 | - $invoice_total_query= $invoice_total_query->result_array(); |
|
630 | - $data = array('amount' => $this->common_model->add_calculate_currency($response_arr['total_val_final'],"","",true,false),'confirm'=>$confirm,'notes'=>$response_arr['invoice_notes']); |
|
631 | - $this->db->where("id", $response_arr['invoiceid']); |
|
632 | - $this->db->update("invoices", $data); |
|
627 | + $query="select sum(debit) as credit from invoice_details where invoiceid = ".$response_arr['invoiceid']; |
|
628 | + $invoice_total_query=$this->db->query($query); |
|
629 | + $invoice_total_query= $invoice_total_query->result_array(); |
|
630 | + $data = array('amount' => $this->common_model->add_calculate_currency($response_arr['total_val_final'],"","",true,false),'confirm'=>$confirm,'notes'=>$response_arr['invoice_notes']); |
|
631 | + $this->db->where("id", $response_arr['invoiceid']); |
|
632 | + $this->db->update("invoices", $data); |
|
633 | 633 | if($confirm == 1){ |
634 | 634 | $invoice_details = $this->db_model->getSelect("*", "invoice_details", array("invoiceid" => $response_arr["invoiceid"])); |
635 | 635 | if($invoice_details->num_rows >0){ |
@@ -667,14 +667,14 @@ discard block |
||
667 | 667 | $this->invoice_send_notification($response_arr['invoiceid'],$account_data[0],'auto'); |
668 | 668 | /***** ***/ |
669 | 669 | } |
670 | - $this->session->set_flashdata('astpp_errormsg', 'Invoice updated successfully!'); |
|
670 | + $this->session->set_flashdata('astpp_errormsg', 'Invoice updated successfully!'); |
|
671 | 671 | redirect(base_url() . 'invoices/invoice_list/'); |
672 | - } |
|
673 | - function invoice_send_notification($invoice_id,$accountdata,$inv_flag){ |
|
672 | + } |
|
673 | + function invoice_send_notification($invoice_id,$accountdata,$inv_flag){ |
|
674 | 674 | $invoicedata = $this->db_model->getSelect("*", "invoices", array("id" => $invoice_id)); |
675 | 675 | $invoicedata = $invoicedata->result_array(); |
676 | 676 | $invoicedata =$invoicedata[0]; |
677 | - //$res = $this->common->get_invoice_template($invoicedata,$accountdata,"False"); |
|
677 | + //$res = $this->common->get_invoice_template($invoicedata,$accountdata,"False"); |
|
678 | 678 | $invoice_conf = array(); |
679 | 679 | if($accountdata['reseller_id'] == 0){ |
680 | 680 | $where = array("accountid"=> 1); |
@@ -691,492 +691,492 @@ discard block |
||
691 | 691 | $invoice_conf = $invoice_conf[0]; |
692 | 692 | } |
693 | 693 | $template_config=$this->config->item('invoice_screen'); |
694 | - include($template_config.'generateInvoice.php'); |
|
695 | - $generateInvoice = new generateInvoice(); |
|
696 | - $generateInvoice->download_invoice($invoicedata['id'],$accountdata,$invoice_conf,$inv_flag); |
|
694 | + include($template_config.'generateInvoice.php'); |
|
695 | + $generateInvoice = new generateInvoice(); |
|
696 | + $generateInvoice->download_invoice($invoicedata['id'],$accountdata,$invoice_conf,$inv_flag); |
|
697 | 697 | return true; |
698 | 698 | } |
699 | - function currency_decimal($amount){ |
|
700 | - $decimal_amount=Common_model::$global_config['system_config']['decimalpoints_total']; |
|
701 | - $number_convert=number_format((float)$amount,$decimal_amount, '.', ''); |
|
702 | - return $number_convert; |
|
703 | - } |
|
704 | - function invoice_summary($id){ |
|
705 | - $query="SELECT * from invoice_details where invoiceid='$id' "; |
|
699 | + function currency_decimal($amount){ |
|
700 | + $decimal_amount=Common_model::$global_config['system_config']['decimalpoints_total']; |
|
701 | + $number_convert=number_format((float)$amount,$decimal_amount, '.', ''); |
|
702 | + return $number_convert; |
|
703 | + } |
|
704 | + function invoice_summary($id){ |
|
705 | + $query="SELECT * from invoice_details where invoiceid='$id' "; |
|
706 | 706 | |
707 | - $invoice_total_query=$this->db->query($query); |
|
708 | - if ($invoice_total_query ->num_rows() > 0) { |
|
709 | - $invoice_final_query = $invoice_total_query->result_array(); |
|
710 | - $data['invoice_final_query']=$invoice_final_query; |
|
707 | + $invoice_total_query=$this->db->query($query); |
|
708 | + if ($invoice_total_query ->num_rows() > 0) { |
|
709 | + $invoice_final_query = $invoice_total_query->result_array(); |
|
710 | + $data['invoice_final_query']=$invoice_final_query; |
|
711 | 711 | |
712 | - $account_data = $this->session->userdata("accountinfo"); |
|
713 | - $logintype = $this->session->userdata('logintype'); |
|
714 | - $invoice_total=''; |
|
715 | - $query="SELECT * from invoice_details where item_type='INVPAY' AND invoiceid='$id' ORDER BY created_date ASC"; |
|
716 | - $invoice_total_query=$this->db->query($query); |
|
717 | - if ($invoice_total_query ->num_rows() > 0) { |
|
718 | - $invoice_total_query= $invoice_total_query->result_array(); |
|
712 | + $account_data = $this->session->userdata("accountinfo"); |
|
713 | + $logintype = $this->session->userdata('logintype'); |
|
714 | + $invoice_total=''; |
|
715 | + $query="SELECT * from invoice_details where item_type='INVPAY' AND invoiceid='$id' ORDER BY created_date ASC"; |
|
716 | + $invoice_total_query=$this->db->query($query); |
|
717 | + if ($invoice_total_query ->num_rows() > 0) { |
|
718 | + $invoice_total_query= $invoice_total_query->result_array(); |
|
719 | 719 | |
720 | - $data['invoice_total_query']=$invoice_total_query; |
|
721 | - } |
|
722 | - $invoice = $this->db_model->getSelect("*", "invoices", array("id"=> $id)); |
|
723 | - if ($invoice ->num_rows() > 0) { |
|
724 | - $invoice= $invoice->result_array(); |
|
725 | - $result=$invoice[0]; |
|
726 | - $data['payment_due_date']=$result['due_date']; |
|
727 | - } |
|
720 | + $data['invoice_total_query']=$invoice_total_query; |
|
721 | + } |
|
722 | + $invoice = $this->db_model->getSelect("*", "invoices", array("id"=> $id)); |
|
723 | + if ($invoice ->num_rows() > 0) { |
|
724 | + $invoice= $invoice->result_array(); |
|
725 | + $result=$invoice[0]; |
|
726 | + $data['payment_due_date']=$result['due_date']; |
|
727 | + } |
|
728 | 728 | |
729 | - $accountdata = $this->db_model->getSelect("*","accounts",array("id"=> $result['accountid'])); |
|
730 | - if ($accountdata ->num_rows() > 0) { |
|
731 | - $accountdata = $accountdata->result_array(); |
|
732 | - $accountdata = $accountdata[0]; |
|
733 | - } |
|
729 | + $accountdata = $this->db_model->getSelect("*","accounts",array("id"=> $result['accountid'])); |
|
730 | + if ($accountdata ->num_rows() > 0) { |
|
731 | + $accountdata = $accountdata->result_array(); |
|
732 | + $accountdata = $accountdata[0]; |
|
733 | + } |
|
734 | 734 | |
735 | - $system_config = common_model::$global_config['system_config']; |
|
736 | - if($system_config["paypal_mode"]==0){ |
|
737 | - $data["paypal_url"] = $system_config["paypal_url"]; |
|
738 | - $data["paypal_email_id"] = $system_config["paypal_id"]; |
|
739 | - }else{ |
|
740 | - $data["paypal_url"] = $system_config["paypal_sandbox_url"]; |
|
741 | - $data["paypal_email_id"] = $system_config["paypal_sandbox_id"]; |
|
742 | - } |
|
743 | - $date = strtotime($result['invoice_date']); |
|
744 | - $data['time'] = date("Y-m-d h:i:s ",$date); |
|
745 | - $data["paypal_tax"] = $system_config["paypal_tax"]; |
|
746 | - $data["from_currency"] = $this->common->get_field_name('currency', 'currency', $account_data["currency_id"]); |
|
747 | - $data["to_currency"] = Common_model::$global_config['system_config']['base_currency']; |
|
748 | - if($account_data['type'] == -1){ |
|
735 | + $system_config = common_model::$global_config['system_config']; |
|
736 | + if($system_config["paypal_mode"]==0){ |
|
737 | + $data["paypal_url"] = $system_config["paypal_url"]; |
|
738 | + $data["paypal_email_id"] = $system_config["paypal_id"]; |
|
739 | + }else{ |
|
740 | + $data["paypal_url"] = $system_config["paypal_sandbox_url"]; |
|
741 | + $data["paypal_email_id"] = $system_config["paypal_sandbox_id"]; |
|
742 | + } |
|
743 | + $date = strtotime($result['invoice_date']); |
|
744 | + $data['time'] = date("Y-m-d h:i:s ",$date); |
|
745 | + $data["paypal_tax"] = $system_config["paypal_tax"]; |
|
746 | + $data["from_currency"] = $this->common->get_field_name('currency', 'currency', $account_data["currency_id"]); |
|
747 | + $data["to_currency"] = Common_model::$global_config['system_config']['base_currency']; |
|
748 | + if($account_data['type'] == -1){ |
|
749 | 749 | $accountdata["currency_id"] = $this->common->get_field_name('currency', 'currency', $account_data["currency_id"]); |
750 | - $data["to_currency"] = $accountdata["currency_id"]; |
|
751 | - }elseif($account_data['type'] == 1){ |
|
750 | + $data["to_currency"] = $accountdata["currency_id"]; |
|
751 | + }elseif($account_data['type'] == 1){ |
|
752 | 752 | $accountdata["currency_id"] = $this->common->get_field_name('currency', 'currency', $account_data["currency_id"]); |
753 | - $data["to_currency"] = $accountdata["currency_id"]; |
|
754 | - }else{ |
|
753 | + $data["to_currency"] = $accountdata["currency_id"]; |
|
754 | + }else{ |
|
755 | 755 | $accountdata["currency_id"] = $this->common->get_field_name('currency', 'currency', $account_data["currency_id"]); |
756 | - $data["to_currency"] = $accountdata["currency_id"]; |
|
757 | - } |
|
758 | - $data["system_currency"] = Common_model::$global_config['system_config']['base_currency']; |
|
759 | - foreach($invoice_total_query as $value){ |
|
760 | - $data['from_date']=$result['from_date']; |
|
761 | - $data['to_date']=$result['to_date']; |
|
762 | - $data['invoice_date']=$result['invoice_date']; |
|
763 | - $data['amount'] = $this->common_model->calculate_currency($result['amount']); |
|
764 | - $data['invoice_prefix'] = $result['invoice_prefix']; |
|
765 | - $data['page_title'] = 'Invoice Summary'; |
|
766 | - $data['invoice_date']=$result['invoice_date']; |
|
767 | - $data['return'] =base_url() . "invoices/invoice_list_modified"; |
|
768 | - $data['cancel_return'] =base_url()."invoice/invoice_list_cancel"; |
|
769 | - $data['paypal_mode'] = 1; |
|
770 | - $data['prefix_id']=$result['invoiceid']; |
|
771 | - $data['logintype']=$logintype; |
|
772 | - $data['accountdata'] = $accountdata; |
|
773 | - $data['value']=$value; |
|
774 | - $data['id']=$id; |
|
775 | - $data['notify_url'] = base_url() . "invoices/invoice_list_get_data/"; |
|
776 | - if($account_data['type'] =='1'){ |
|
777 | - $data['response_url'] = base_url() . "invoices/invoice_list_responce/"; |
|
778 | - }else{ |
|
779 | - $data['response_url'] = base_url() . "user/user_list_responce/"; |
|
780 | - } |
|
781 | - $data['sucess_url'] = base_url() . "invoices/invoice_list_sucess/"; |
|
782 | - } |
|
756 | + $data["to_currency"] = $accountdata["currency_id"]; |
|
757 | + } |
|
758 | + $data["system_currency"] = Common_model::$global_config['system_config']['base_currency']; |
|
759 | + foreach($invoice_total_query as $value){ |
|
760 | + $data['from_date']=$result['from_date']; |
|
761 | + $data['to_date']=$result['to_date']; |
|
762 | + $data['invoice_date']=$result['invoice_date']; |
|
763 | + $data['amount'] = $this->common_model->calculate_currency($result['amount']); |
|
764 | + $data['invoice_prefix'] = $result['invoice_prefix']; |
|
765 | + $data['page_title'] = 'Invoice Summary'; |
|
766 | + $data['invoice_date']=$result['invoice_date']; |
|
767 | + $data['return'] =base_url() . "invoices/invoice_list_modified"; |
|
768 | + $data['cancel_return'] =base_url()."invoice/invoice_list_cancel"; |
|
769 | + $data['paypal_mode'] = 1; |
|
770 | + $data['prefix_id']=$result['invoiceid']; |
|
771 | + $data['logintype']=$logintype; |
|
772 | + $data['accountdata'] = $accountdata; |
|
773 | + $data['value']=$value; |
|
774 | + $data['id']=$id; |
|
775 | + $data['notify_url'] = base_url() . "invoices/invoice_list_get_data/"; |
|
776 | + if($account_data['type'] =='1'){ |
|
777 | + $data['response_url'] = base_url() . "invoices/invoice_list_responce/"; |
|
778 | + }else{ |
|
779 | + $data['response_url'] = base_url() . "user/user_list_responce/"; |
|
780 | + } |
|
781 | + $data['sucess_url'] = base_url() . "invoices/invoice_list_sucess/"; |
|
782 | + } |
|
783 | 783 | |
784 | - }else{ |
|
784 | + }else{ |
|
785 | 785 | |
786 | - redirect(base_url() . 'dashboard/'); |
|
787 | - } |
|
788 | - $this->load->view('view_invoice_payment',$data); |
|
789 | - } |
|
790 | - function invoice_list_get_data(){ |
|
791 | - redirect(base_url().'invoices/invoice_list/'); |
|
792 | - } |
|
793 | - function convert_amount($amount){ |
|
794 | - $amount = $this->common_model->add_calculate_currency($amount,"","",true,false); |
|
795 | - echo number_format($amount,2); |
|
796 | - } |
|
797 | - function invoice_list_responce(){ |
|
798 | - $response_arr=$_POST; |
|
799 | - $logintype = $this->session->userdata('logintype'); |
|
800 | - if( ($response_arr["payment_status"] == "Pending" || $response_arr["payment_status"] == "Complete" || $response_arr["payment_status"] == "Completed" ) ){ |
|
801 | - $invoice_id=$response_arr['item_number']; |
|
802 | - $amount=$response_arr['payment_gross']; |
|
803 | - $description=$response_arr['item_name']; |
|
804 | - $debit=''; |
|
786 | + redirect(base_url() . 'dashboard/'); |
|
787 | + } |
|
788 | + $this->load->view('view_invoice_payment',$data); |
|
789 | + } |
|
790 | + function invoice_list_get_data(){ |
|
791 | + redirect(base_url().'invoices/invoice_list/'); |
|
792 | + } |
|
793 | + function convert_amount($amount){ |
|
794 | + $amount = $this->common_model->add_calculate_currency($amount,"","",true,false); |
|
795 | + echo number_format($amount,2); |
|
796 | + } |
|
797 | + function invoice_list_responce(){ |
|
798 | + $response_arr=$_POST; |
|
799 | + $logintype = $this->session->userdata('logintype'); |
|
800 | + if( ($response_arr["payment_status"] == "Pending" || $response_arr["payment_status"] == "Complete" || $response_arr["payment_status"] == "Completed" ) ){ |
|
801 | + $invoice_id=$response_arr['item_number']; |
|
802 | + $amount=$response_arr['payment_gross']; |
|
803 | + $description=$response_arr['item_name']; |
|
804 | + $debit=''; |
|
805 | 805 | |
806 | - $paypal_tax = $this->db_model->getSelect("value", "system", array("name" => "paypal_tax","group_title"=>"paypal")); |
|
807 | - $paypal_tax = $paypal_tax->result(); |
|
808 | - $paypal_tax = $paypal_tax[0]->value; |
|
809 | - $balance_amt = $actual_amount = $response_arr["custom"]; |
|
806 | + $paypal_tax = $this->db_model->getSelect("value", "system", array("name" => "paypal_tax","group_title"=>"paypal")); |
|
807 | + $paypal_tax = $paypal_tax->result(); |
|
808 | + $paypal_tax = $paypal_tax[0]->value; |
|
809 | + $balance_amt = $actual_amount = $response_arr["custom"]; |
|
810 | 810 | |
811 | - $paypal_fee = $this->db_model->getSelect("value", "system", array("name" => "paypal_fee","group_title"=>"paypal")); |
|
812 | - $paypal_fee = $paypal_fee->result(); |
|
813 | - $paypal_fee = $paypal_fee[0]->value; |
|
811 | + $paypal_fee = $this->db_model->getSelect("value", "system", array("name" => "paypal_fee","group_title"=>"paypal")); |
|
812 | + $paypal_fee = $paypal_fee->result(); |
|
813 | + $paypal_fee = $paypal_fee[0]->value; |
|
814 | 814 | |
815 | - $paypalfee = ($paypal_fee == 0)?'0':$response_arr["mc_gross"]; |
|
815 | + $paypalfee = ($paypal_fee == 0)?'0':$response_arr["mc_gross"]; |
|
816 | 816 | |
817 | - $account_data = $this->db_model->getSelect("*", "accounts", array("id" => $response_arr["custom"])); |
|
818 | - $account_data = $account_data->result_array(); |
|
819 | - $account_data = $account_data[0]; |
|
820 | - $currency = $this->db_model->getSelect('currency,currencyrate', 'currency', array("id"=>$account_data["currency_id"])); |
|
821 | - $currency = $currency->result_array(); |
|
822 | - $currency =$currency[0]; |
|
823 | - $date = date('Y-m-d H:i:s'); |
|
824 | - $invoice_total_query = $this->db_model->getSelect("*", "invoices", array("id"=> $invoice_id)); |
|
825 | - if ( $invoice_total_query ->num_rows() > 0) { |
|
826 | - $invoice_total_query= $invoice_total_query->result_array(); |
|
827 | - $debit=$invoice_total_query[0]['amount']; |
|
828 | - } |
|
829 | - $query="select sum(credit) as credit from invoice_details where invoiceid = ".$invoice_id." AND item_type !='PAYMENT' Group By invoiceid"; |
|
830 | - //echo $query; exit; |
|
831 | - $invoice_total_query=$this->db->query($query); |
|
832 | - if ($invoice_total_query ->num_rows() > 0) { |
|
833 | - $invoice_total_query= $invoice_total_query->result_array(); |
|
834 | - $total_debit=$invoice_total_query[0]['credit']; |
|
835 | - } |
|
836 | - $credit_total=$total_debit+$amount; |
|
837 | - // echo $debit; exit; |
|
838 | - if($debit >= $credit_total) { |
|
817 | + $account_data = $this->db_model->getSelect("*", "accounts", array("id" => $response_arr["custom"])); |
|
818 | + $account_data = $account_data->result_array(); |
|
819 | + $account_data = $account_data[0]; |
|
820 | + $currency = $this->db_model->getSelect('currency,currencyrate', 'currency', array("id"=>$account_data["currency_id"])); |
|
821 | + $currency = $currency->result_array(); |
|
822 | + $currency =$currency[0]; |
|
823 | + $date = date('Y-m-d H:i:s'); |
|
824 | + $invoice_total_query = $this->db_model->getSelect("*", "invoices", array("id"=> $invoice_id)); |
|
825 | + if ( $invoice_total_query ->num_rows() > 0) { |
|
826 | + $invoice_total_query= $invoice_total_query->result_array(); |
|
827 | + $debit=$invoice_total_query[0]['amount']; |
|
828 | + } |
|
829 | + $query="select sum(credit) as credit from invoice_details where invoiceid = ".$invoice_id." AND item_type !='PAYMENT' Group By invoiceid"; |
|
830 | + //echo $query; exit; |
|
831 | + $invoice_total_query=$this->db->query($query); |
|
832 | + if ($invoice_total_query ->num_rows() > 0) { |
|
833 | + $invoice_total_query= $invoice_total_query->result_array(); |
|
834 | + $total_debit=$invoice_total_query[0]['credit']; |
|
835 | + } |
|
836 | + $credit_total=$total_debit+$amount; |
|
837 | + // echo $debit; exit; |
|
838 | + if($debit >= $credit_total) { |
|
839 | 839 | |
840 | 840 | |
841 | - if($debit == $credit_total){ |
|
841 | + if($debit == $credit_total){ |
|
842 | 842 | |
843 | - $this->db->where("id", $invoice_id); |
|
844 | - $data = array('status' => '0'); |
|
845 | - $this->db->update("invoices", $data); |
|
846 | - // echo $this->db->last_query(); exit; |
|
847 | - }else{ |
|
848 | - $this->db->where("id", $invoice_id); |
|
849 | - $data = array('status' => '2'); |
|
850 | - $this->db->update("invoices", $data); |
|
851 | - // echo $this->db->last_query(); exit; |
|
852 | - } |
|
843 | + $this->db->where("id", $invoice_id); |
|
844 | + $data = array('status' => '0'); |
|
845 | + $this->db->update("invoices", $data); |
|
846 | + // echo $this->db->last_query(); exit; |
|
847 | + }else{ |
|
848 | + $this->db->where("id", $invoice_id); |
|
849 | + $data = array('status' => '2'); |
|
850 | + $this->db->update("invoices", $data); |
|
851 | + // echo $this->db->last_query(); exit; |
|
852 | + } |
|
853 | 853 | |
854 | - if($amount > $debit){ |
|
855 | - $this->session->set_flashdata('astpp_notification', 'Invoice payment amount should be higher then the invoice amount.'); |
|
856 | - redirect(base_url().'invoices/invoice_summary/'.$invoice_id); |
|
857 | - } |
|
858 | - $payment_trans_array = array("accountid"=>$response_arr["custom"],"amount"=>$response_arr["payment_gross"], |
|
859 | - "tax"=>"1","payment_method"=>"Paypal","actual_amount"=> $amount,"paypal_fee"=> $paypalfee, |
|
860 | - "user_currency"=>$currency["currency"],"currency_rate"=>$currency["currencyrate"],"transaction_details"=>json_encode($response_arr),"date"=>$date); |
|
861 | - $this->db->insert('payment_transaction',$payment_trans_array); |
|
862 | - $transaction_details_id= $this->db->insert_id(); |
|
854 | + if($amount > $debit){ |
|
855 | + $this->session->set_flashdata('astpp_notification', 'Invoice payment amount should be higher then the invoice amount.'); |
|
856 | + redirect(base_url().'invoices/invoice_summary/'.$invoice_id); |
|
857 | + } |
|
858 | + $payment_trans_array = array("accountid"=>$response_arr["custom"],"amount"=>$response_arr["payment_gross"], |
|
859 | + "tax"=>"1","payment_method"=>"Paypal","actual_amount"=> $amount,"paypal_fee"=> $paypalfee, |
|
860 | + "user_currency"=>$currency["currency"],"currency_rate"=>$currency["currencyrate"],"transaction_details"=>json_encode($response_arr),"date"=>$date); |
|
861 | + $this->db->insert('payment_transaction',$payment_trans_array); |
|
862 | + $transaction_details_id= $this->db->insert_id(); |
|
863 | 863 | |
864 | 864 | |
865 | - if($transaction_details_id == ''){ |
|
866 | - $transaction_details_id == 0; |
|
867 | - } |
|
865 | + if($transaction_details_id == ''){ |
|
866 | + $transaction_details_id == 0; |
|
867 | + } |
|
868 | 868 | |
869 | - $accountdata = $this->db_model->getSelect("*","payment_transaction",array()); |
|
870 | - if($accountdata->num_rows() > 0){ |
|
871 | - foreach($accountdata->result_array() as $payment_value){ |
|
872 | - $payment_transaction=$payment_value['transaction_details']; |
|
873 | - $payment_result=json_decode($payment_transaction,true); |
|
874 | - $transaction_id= $payment_result['txn_id']; |
|
875 | - } |
|
876 | - } |
|
877 | - $invoice_total_history = $this->db_model->getSelect("*", "invoice_details", array("invoiceid"=> $invoice_id,'item_type'=>'INVPAY')); |
|
869 | + $accountdata = $this->db_model->getSelect("*","payment_transaction",array()); |
|
870 | + if($accountdata->num_rows() > 0){ |
|
871 | + foreach($accountdata->result_array() as $payment_value){ |
|
872 | + $payment_transaction=$payment_value['transaction_details']; |
|
873 | + $payment_result=json_decode($payment_transaction,true); |
|
874 | + $transaction_id= $payment_result['txn_id']; |
|
875 | + } |
|
876 | + } |
|
877 | + $invoice_total_history = $this->db_model->getSelect("*", "invoice_details", array("invoiceid"=> $invoice_id,'item_type'=>'INVPAY')); |
|
878 | 878 | $account_balance=$account_data['balance']; |
879 | - if ($invoice_total_history ->num_rows() > 0) { |
|
880 | - // echo 'if'; exit; |
|
881 | - $invoice_main= $invoice_total_history->result_array(); |
|
882 | - // echo '<pre>'; print_r($invoice_main); exit; |
|
883 | - $debit_amount = "0.00"; |
|
884 | - foreach($invoice_main as $value){ |
|
885 | - $debit_amount = $value['debit']; |
|
886 | - } |
|
879 | + if ($invoice_total_history ->num_rows() > 0) { |
|
880 | + // echo 'if'; exit; |
|
881 | + $invoice_main= $invoice_total_history->result_array(); |
|
882 | + // echo '<pre>'; print_r($invoice_main); exit; |
|
883 | + $debit_amount = "0.00"; |
|
884 | + foreach($invoice_main as $value){ |
|
885 | + $debit_amount = $value['debit']; |
|
886 | + } |
|
887 | 887 | |
888 | - $actual_amount= $debit_amount-$amount; |
|
889 | - // echo $actual_amount; exit; |
|
890 | - $tax_array = array("accountid"=>$response_arr["custom"],"invoiceid"=>$invoice_id,"item_id"=> $transaction_details_id,"description"=>$description,"debit"=>$this->common->currency_decimal(0),"credit"=> $this->common->currency_decimal($amount),"item_type"=>"INVPAY","created_date"=> $date,"reseller_id"=>$account_data['reseller_id'],'before_balance'=>$account_balance,'after_balance'=>$account_balance+$amount, |
|
888 | + $actual_amount= $debit_amount-$amount; |
|
889 | + // echo $actual_amount; exit; |
|
890 | + $tax_array = array("accountid"=>$response_arr["custom"],"invoiceid"=>$invoice_id,"item_id"=> $transaction_details_id,"description"=>$description,"debit"=>$this->common->currency_decimal(0),"credit"=> $this->common->currency_decimal($amount),"item_type"=>"INVPAY","created_date"=> $date,"reseller_id"=>$account_data['reseller_id'],'before_balance'=>$account_balance,'after_balance'=>$account_balance+$amount, |
|
891 | 891 | ); // echo '<pre>'; print_r( $tax_array); exit; |
892 | - $this->db->insert("invoice_details",$tax_array); |
|
892 | + $this->db->insert("invoice_details",$tax_array); |
|
893 | 893 | |
894 | - }else{ |
|
894 | + }else{ |
|
895 | 895 | |
896 | - // echo 'else'; exit; |
|
897 | - $actual_amount=$debit-$amount; |
|
898 | - $tax_array = array("accountid"=>$response_arr["custom"],"invoiceid"=>$invoice_id,"item_id"=> $transaction_details_id,"description"=>$description,"debit"=> $this->common->currency_decimal(0),"credit"=> $this->common->currency_decimal($amount),"item_type"=>"INVPAY","created_date"=> $date,"reseller_id"=>$account_data['reseller_id'],'before_balance'=>$account_balance,'after_balance'=>$account_balance+$amount); |
|
896 | + // echo 'else'; exit; |
|
897 | + $actual_amount=$debit-$amount; |
|
898 | + $tax_array = array("accountid"=>$response_arr["custom"],"invoiceid"=>$invoice_id,"item_id"=> $transaction_details_id,"description"=>$description,"debit"=> $this->common->currency_decimal(0),"credit"=> $this->common->currency_decimal($amount),"item_type"=>"INVPAY","created_date"=> $date,"reseller_id"=>$account_data['reseller_id'],'before_balance'=>$account_balance,'after_balance'=>$account_balance+$amount); |
|
899 | 899 | |
900 | - $this->db->insert("invoice_details",$tax_array); |
|
901 | - } |
|
900 | + $this->db->insert("invoice_details",$tax_array); |
|
901 | + } |
|
902 | 902 | }else{ |
903 | 903 | if($logintype = 0){ |
904 | - $this->session->set_flashdata('astpp_notification', 'Invoice payment amount should be higher then the invoice amount.'); |
|
905 | - redirect(base_url().'user/user_invoice_payment/'.$invoice_id); |
|
906 | - }else{ |
|
907 | - $this->session->set_flashdata('astpp_notification', 'Invoice payment amount should be higher then the invoice amount.'); |
|
908 | - redirect(base_url().'invoices/invoice_summary/'.$invoice_id); |
|
909 | - } |
|
904 | + $this->session->set_flashdata('astpp_notification', 'Invoice payment amount should be higher then the invoice amount.'); |
|
905 | + redirect(base_url().'user/user_invoice_payment/'.$invoice_id); |
|
906 | + }else{ |
|
907 | + $this->session->set_flashdata('astpp_notification', 'Invoice payment amount should be higher then the invoice amount.'); |
|
908 | + redirect(base_url().'invoices/invoice_summary/'.$invoice_id); |
|
909 | + } |
|
910 | 910 | |
911 | 911 | } |
912 | 912 | |
913 | - $this->load->module('accounts/accounts'); |
|
914 | - $reseller_debit=0; |
|
915 | - $reseller_debit=$this->common->get_field_name('reseller_id', 'accounts', array('id'=>$response_arr["custom"],'status'=>0,'deleted'=>0)); |
|
916 | - // echo '<pre>'; print_r($reseller_debit); exit; |
|
917 | - if($reseller_debit > 0){ |
|
913 | + $this->load->module('accounts/accounts'); |
|
914 | + $reseller_debit=0; |
|
915 | + $reseller_debit=$this->common->get_field_name('reseller_id', 'accounts', array('id'=>$response_arr["custom"],'status'=>0,'deleted'=>0)); |
|
916 | + // echo '<pre>'; print_r($reseller_debit); exit; |
|
917 | + if($reseller_debit > 0){ |
|
918 | 918 | $this->accounts_model->update_balance($amount,$response_arr["custom"], "debit"); |
919 | 919 | $this->accounts_model->update_balance($amount,$reseller_debit, "debit"); |
920 | 920 | }else{ |
921 | 921 | $this->accounts_model->update_balance($amount,$response_arr["custom"], "debit"); |
922 | 922 | } |
923 | 923 | $account_data['accountid']=$account_data['id']; |
924 | - $this->email_lib->send_email('email_payment_notification',$account_data ,'','',0,0,0); |
|
924 | + $this->email_lib->send_email('email_payment_notification',$account_data ,'','',0,0,0); |
|
925 | 925 | if($logintype = '1'){ |
926 | - $this->session->set_flashdata('astpp_errormsg', 'Invoice payment done successfully!'); |
|
927 | - redirect(base_url() . 'invoices/invoice_list/'); |
|
928 | - }else{ |
|
929 | - $this->session->set_flashdata('astpp_errormsg', 'Invoice payment done successfully!'); |
|
930 | - redirect(base_url() . 'user/user_invoices_list/'); |
|
931 | - } |
|
926 | + $this->session->set_flashdata('astpp_errormsg', 'Invoice payment done successfully!'); |
|
927 | + redirect(base_url() . 'invoices/invoice_list/'); |
|
928 | + }else{ |
|
929 | + $this->session->set_flashdata('astpp_errormsg', 'Invoice payment done successfully!'); |
|
930 | + redirect(base_url() . 'user/user_invoices_list/'); |
|
931 | + } |
|
932 | 932 | } |
933 | - } |
|
934 | - function invoice_admin_payment(){ |
|
933 | + } |
|
934 | + function invoice_admin_payment(){ |
|
935 | 935 | |
936 | - $response_arr=$_POST; |
|
936 | + $response_arr=$_POST; |
|
937 | 937 | |
938 | - if(!empty($response_arr)){ |
|
938 | + if(!empty($response_arr)){ |
|
939 | 939 | |
940 | - $amount=$response_arr['amount']; |
|
941 | - $description=$response_arr['item_name']; |
|
942 | - $invoice_id=$response_arr['item_number']; |
|
943 | - $date = date('Y-m-d H:i:s'); |
|
940 | + $amount=$response_arr['amount']; |
|
941 | + $description=$response_arr['item_name']; |
|
942 | + $invoice_id=$response_arr['item_number']; |
|
943 | + $date = date('Y-m-d H:i:s'); |
|
944 | 944 | |
945 | - $invoice_total_query = $this->db_model->getSelect("*", "invoices", array("id"=> $invoice_id)); |
|
946 | - if ( $invoice_total_query ->num_rows() > 0) { |
|
947 | - $invoice_total_query= $invoice_total_query->result_array(); |
|
948 | - $debit=$invoice_total_query[0]['amount']; |
|
949 | - } |
|
945 | + $invoice_total_query = $this->db_model->getSelect("*", "invoices", array("id"=> $invoice_id)); |
|
946 | + if ( $invoice_total_query ->num_rows() > 0) { |
|
947 | + $invoice_total_query= $invoice_total_query->result_array(); |
|
948 | + $debit=$invoice_total_query[0]['amount']; |
|
949 | + } |
|
950 | 950 | |
951 | - $query="select sum(credit) as credit from invoice_details where invoiceid = ".$invoice_id." AND item_type !='PAYMENT' Group By invoiceid"; |
|
952 | - //echo $query; exit; |
|
953 | - $invoice_total_query=$this->db->query($query); |
|
954 | - if ($invoice_total_query ->num_rows() > 0) { |
|
955 | - $invoice_total_query= $invoice_total_query->result_array(); |
|
956 | - $total_debit=$invoice_total_query[0]['credit']; |
|
957 | - } |
|
958 | - $credit_total=$total_debit+$amount; |
|
959 | - // echo $credit_total; exit; |
|
960 | - if($debit >= $credit_total) { |
|
951 | + $query="select sum(credit) as credit from invoice_details where invoiceid = ".$invoice_id." AND item_type !='PAYMENT' Group By invoiceid"; |
|
952 | + //echo $query; exit; |
|
953 | + $invoice_total_query=$this->db->query($query); |
|
954 | + if ($invoice_total_query ->num_rows() > 0) { |
|
955 | + $invoice_total_query= $invoice_total_query->result_array(); |
|
956 | + $total_debit=$invoice_total_query[0]['credit']; |
|
957 | + } |
|
958 | + $credit_total=$total_debit+$amount; |
|
959 | + // echo $credit_total; exit; |
|
960 | + if($debit >= $credit_total) { |
|
961 | 961 | |
962 | 962 | |
963 | - if($debit == $credit_total){ |
|
963 | + if($debit == $credit_total){ |
|
964 | 964 | |
965 | - $this->db->where("id", $invoice_id); |
|
966 | - $data = array('status' => '0'); |
|
967 | - $this->db->update("invoices", $data); |
|
968 | - // echo $this->db->last_query(); exit; |
|
969 | - }else{ |
|
970 | - $this->db->where("id", $invoice_id); |
|
971 | - $data = array('status' => '2'); |
|
972 | - $this->db->update("invoices", $data); |
|
973 | - // echo $this->db->last_query(); exit; |
|
974 | - } |
|
965 | + $this->db->where("id", $invoice_id); |
|
966 | + $data = array('status' => '0'); |
|
967 | + $this->db->update("invoices", $data); |
|
968 | + // echo $this->db->last_query(); exit; |
|
969 | + }else{ |
|
970 | + $this->db->where("id", $invoice_id); |
|
971 | + $data = array('status' => '2'); |
|
972 | + $this->db->update("invoices", $data); |
|
973 | + // echo $this->db->last_query(); exit; |
|
974 | + } |
|
975 | 975 | |
976 | - if($amount > $debit){ |
|
977 | - $this->session->set_flashdata('astpp_notification', 'Invoice payment amount should be higher then the invoice amount.'); |
|
978 | - redirect(base_url().'invoices/invoice_summary/'.$invoice_id); |
|
979 | - } |
|
976 | + if($amount > $debit){ |
|
977 | + $this->session->set_flashdata('astpp_notification', 'Invoice payment amount should be higher then the invoice amount.'); |
|
978 | + redirect(base_url().'invoices/invoice_summary/'.$invoice_id); |
|
979 | + } |
|
980 | 980 | |
981 | 981 | |
982 | - $debit_amount = "0.00"; |
|
983 | - $account_balance = $this->common->get_field_name('balance', 'accounts', $response_arr['custom']); |
|
984 | - $tax_array = array("accountid"=>$response_arr["custom"],"invoiceid"=>$invoice_id,"item_id"=> '',"description"=>$description,"debit"=>"0.00","credit"=> $amount,"item_type"=>"INVPAY","created_date"=> $date,"reseller_id"=>"0",'before_balance'=>$account_balance,'after_balance'=>$account_balance+$amount); |
|
985 | - $this->db->insert("invoice_details",$tax_array); |
|
982 | + $debit_amount = "0.00"; |
|
983 | + $account_balance = $this->common->get_field_name('balance', 'accounts', $response_arr['custom']); |
|
984 | + $tax_array = array("accountid"=>$response_arr["custom"],"invoiceid"=>$invoice_id,"item_id"=> '',"description"=>$description,"debit"=>"0.00","credit"=> $amount,"item_type"=>"INVPAY","created_date"=> $date,"reseller_id"=>"0",'before_balance'=>$account_balance,'after_balance'=>$account_balance+$amount); |
|
985 | + $this->db->insert("invoice_details",$tax_array); |
|
986 | 986 | |
987 | 987 | |
988 | - }else{ |
|
988 | + }else{ |
|
989 | 989 | |
990 | - $this->session->set_flashdata('astpp_notification', 'Invoice payment amount should be higher then the invoice amount.'); |
|
991 | - redirect(base_url().'invoices/invoice_summary/'.$invoice_id); |
|
992 | - } |
|
990 | + $this->session->set_flashdata('astpp_notification', 'Invoice payment amount should be higher then the invoice amount.'); |
|
991 | + redirect(base_url().'invoices/invoice_summary/'.$invoice_id); |
|
992 | + } |
|
993 | 993 | |
994 | - $this->load->module('accounts/accounts'); |
|
994 | + $this->load->module('accounts/accounts'); |
|
995 | 995 | $this->accounts_model->update_balance($amount,$response_arr["custom"], "debit"); |
996 | - $this->session->set_flashdata('astpp_errormsg', 'Invoice payment done successfully!'); |
|
996 | + $this->session->set_flashdata('astpp_errormsg', 'Invoice payment done successfully!'); |
|
997 | 997 | |
998 | - } |
|
999 | - $account_data = $this->db_model->getSelect("*", "accounts", array("id" => $response_arr["custom"])); |
|
1000 | - $account_data = $account_data->result_array(); |
|
1001 | - $account_data = $account_data[0]; |
|
1002 | - $account_data['accountid']=$account_data['id']; |
|
998 | + } |
|
999 | + $account_data = $this->db_model->getSelect("*", "accounts", array("id" => $response_arr["custom"])); |
|
1000 | + $account_data = $account_data->result_array(); |
|
1001 | + $account_data = $account_data[0]; |
|
1002 | + $account_data['accountid']=$account_data['id']; |
|
1003 | 1003 | // $this->email_lib->send_email('email_payment_notification',$account_data ,'','',0,0,0); |
1004 | - redirect(base_url() . 'invoices/invoice_list/'); |
|
1004 | + redirect(base_url() . 'invoices/invoice_list/'); |
|
1005 | 1005 | |
1006 | - } |
|
1006 | + } |
|
1007 | 1007 | |
1008 | - function invoice_list_sucess(){ |
|
1009 | - echo 'sucess'; exit; |
|
1008 | + function invoice_list_sucess(){ |
|
1009 | + echo 'sucess'; exit; |
|
1010 | 1010 | |
1011 | - } |
|
1012 | - function invoice_list_modified(){ |
|
1013 | - echo 'sucess'; exit; |
|
1011 | + } |
|
1012 | + function invoice_list_modified(){ |
|
1013 | + echo 'sucess'; exit; |
|
1014 | 1014 | |
1015 | - } |
|
1015 | + } |
|
1016 | 1016 | |
1017 | - function invoice_delete(){ |
|
1017 | + function invoice_delete(){ |
|
1018 | 1018 | $ids = $this->input->post("selected_ids", true); |
1019 | - $where = "id IN ($ids)"; |
|
1020 | - $this->db->where($where); |
|
1021 | - echo $this->db->delete("invoices"); |
|
1022 | - } |
|
1019 | + $where = "id IN ($ids)"; |
|
1020 | + $this->db->where($where); |
|
1021 | + echo $this->db->delete("invoices"); |
|
1022 | + } |
|
1023 | 1023 | |
1024 | - function invoice_conf() { |
|
1025 | - $data['page_title'] = 'Company Profile'; |
|
1026 | - $post_array = $this->input->post(); |
|
1027 | - $accountinfo=$this->session->userdata('accountinfo'); |
|
1028 | - unset($post_array['action']); |
|
1029 | - unset($post_array['button']); |
|
1030 | - unset($post_array['file']); |
|
1024 | + function invoice_conf() { |
|
1025 | + $data['page_title'] = 'Company Profile'; |
|
1026 | + $post_array = $this->input->post(); |
|
1027 | + $accountinfo=$this->session->userdata('accountinfo'); |
|
1028 | + unset($post_array['action']); |
|
1029 | + unset($post_array['button']); |
|
1030 | + unset($post_array['file']); |
|
1031 | 1031 | |
1032 | - if (!empty($post_array)) { |
|
1033 | - $invoice_prefix = trim($post_array['invoice_prefix']); |
|
1034 | - if ($_FILES['file']['name'] == '') { |
|
1035 | - $invoiceconf = $this->invoices_model->get_invoiceconf($post_array['accountid']); |
|
1036 | - $file_name=($invoiceconf['logo'] != '') ? $invoiceconf['logo'] : ''; |
|
1037 | - } |
|
1038 | - if ($invoice_prefix == '') { |
|
1039 | - $this->session->set_flashdata('astpp_notification', 'Invoice Prefix is required.'); |
|
1040 | - redirect(base_url() . 'invoices/invoice_conf/'); |
|
1041 | - } |
|
1032 | + if (!empty($post_array)) { |
|
1033 | + $invoice_prefix = trim($post_array['invoice_prefix']); |
|
1034 | + if ($_FILES['file']['name'] == '') { |
|
1035 | + $invoiceconf = $this->invoices_model->get_invoiceconf($post_array['accountid']); |
|
1036 | + $file_name=($invoiceconf['logo'] != '') ? $invoiceconf['logo'] : ''; |
|
1037 | + } |
|
1038 | + if ($invoice_prefix == '') { |
|
1039 | + $this->session->set_flashdata('astpp_notification', 'Invoice Prefix is required.'); |
|
1040 | + redirect(base_url() . 'invoices/invoice_conf/'); |
|
1041 | + } |
|
1042 | 1042 | |
1043 | - if (isset($_FILES['file']['name']) && $_FILES['file']['name'] != '') { |
|
1044 | - $files = $_FILES['file']; |
|
1045 | - if ($files['size'] < 0) { |
|
1046 | - $this->session->set_flashdata('astpp_notification', 'PLease upload maximum file'); |
|
1047 | - redirect(base_url() . 'invoices/invoice_conf/'); |
|
1048 | - } |
|
1049 | - $file = $_FILES['file']; |
|
1050 | - $uploadedFile = $file["tmp_name"]; |
|
1051 | - $file_name = $file['name']; |
|
1052 | - $file_type = $file['type']; |
|
1053 | - if ($file_type == 'image/jpg' || $file_type == 'image/png' || $file_type == 'image/jpeg') { |
|
1054 | - $dir_path = FCPATH. "upload/"; |
|
1055 | - $path = $dir_path . $accountinfo['id']."_".$file['name']; |
|
1056 | - if (move_uploaded_file($uploadedFile, $path)) { |
|
1057 | - $this->session->set_flashdata('astpp_errormsg', gettext('files added successfully!')); |
|
1058 | - } else { |
|
1059 | - $this->session->set_flashdata('astpp_notification', "File Uploading Fail Please Try Again"); |
|
1060 | - redirect(base_url() . 'invoices/invoice_conf/'); |
|
1061 | - } |
|
1062 | - } else { |
|
1063 | - $this->session->set_flashdata('astpp_notification', 'Please upload only image!'); |
|
1064 | - redirect(base_url() . 'invoices/invoice_conf/'); |
|
1065 | - } |
|
1066 | - } |
|
1067 | - $post_array['logo'] = $file_name; |
|
1043 | + if (isset($_FILES['file']['name']) && $_FILES['file']['name'] != '') { |
|
1044 | + $files = $_FILES['file']; |
|
1045 | + if ($files['size'] < 0) { |
|
1046 | + $this->session->set_flashdata('astpp_notification', 'PLease upload maximum file'); |
|
1047 | + redirect(base_url() . 'invoices/invoice_conf/'); |
|
1048 | + } |
|
1049 | + $file = $_FILES['file']; |
|
1050 | + $uploadedFile = $file["tmp_name"]; |
|
1051 | + $file_name = $file['name']; |
|
1052 | + $file_type = $file['type']; |
|
1053 | + if ($file_type == 'image/jpg' || $file_type == 'image/png' || $file_type == 'image/jpeg') { |
|
1054 | + $dir_path = FCPATH. "upload/"; |
|
1055 | + $path = $dir_path . $accountinfo['id']."_".$file['name']; |
|
1056 | + if (move_uploaded_file($uploadedFile, $path)) { |
|
1057 | + $this->session->set_flashdata('astpp_errormsg', gettext('files added successfully!')); |
|
1058 | + } else { |
|
1059 | + $this->session->set_flashdata('astpp_notification', "File Uploading Fail Please Try Again"); |
|
1060 | + redirect(base_url() . 'invoices/invoice_conf/'); |
|
1061 | + } |
|
1062 | + } else { |
|
1063 | + $this->session->set_flashdata('astpp_notification', 'Please upload only image!'); |
|
1064 | + redirect(base_url() . 'invoices/invoice_conf/'); |
|
1065 | + } |
|
1066 | + } |
|
1067 | + $post_array['logo'] = $file_name; |
|
1068 | 1068 | |
1069 | - $this->invoices_model->save_invoiceconf($post_array); |
|
1070 | - $this->session->set_flashdata('astpp_errormsg', 'Invoice configuration updated sucessfully!'); |
|
1071 | - redirect(base_url() . 'invoices/invoice_conf/'); |
|
1072 | - } else { |
|
1069 | + $this->invoices_model->save_invoiceconf($post_array); |
|
1070 | + $this->session->set_flashdata('astpp_errormsg', 'Invoice configuration updated sucessfully!'); |
|
1071 | + redirect(base_url() . 'invoices/invoice_conf/'); |
|
1072 | + } else { |
|
1073 | 1073 | |
1074 | - $invoiceconf = $this->invoices_model->get_invoiceconf($accountinfo['id']); |
|
1074 | + $invoiceconf = $this->invoices_model->get_invoiceconf($accountinfo['id']); |
|
1075 | 1075 | |
1076 | - if (!empty($invoiceconf)) { |
|
1077 | - $data['file_name'] = $accountinfo['id']."_".$invoiceconf['logo']; |
|
1078 | - $invoiceconf['file']=$accountinfo['id']."_".$invoiceconf['logo']; |
|
1079 | - } |
|
1076 | + if (!empty($invoiceconf)) { |
|
1077 | + $data['file_name'] = $accountinfo['id']."_".$invoiceconf['logo']; |
|
1078 | + $invoiceconf['file']=$accountinfo['id']."_".$invoiceconf['logo']; |
|
1079 | + } |
|
1080 | 1080 | |
1081 | - $data['form'] = $this->form->build_form($this->invoices_form->get_invoiceconf_form_fields($invoiceconf), $invoiceconf); |
|
1081 | + $data['form'] = $this->form->build_form($this->invoices_form->get_invoiceconf_form_fields($invoiceconf), $invoiceconf); |
|
1082 | 1082 | |
1083 | - $this->load->view('view_invoiceconf', $data); |
|
1084 | - } |
|
1085 | - } |
|
1086 | - function incr($inteval){ |
|
1087 | - $inteval++; // $a is undefined |
|
1088 | - return $inteval; |
|
1089 | - } |
|
1083 | + $this->load->view('view_invoiceconf', $data); |
|
1084 | + } |
|
1085 | + } |
|
1086 | + function incr($inteval){ |
|
1087 | + $inteval++; // $a is undefined |
|
1088 | + return $inteval; |
|
1089 | + } |
|
1090 | 1090 | |
1091 | 1091 | |
1092 | - function customer_invoices($accountid){ |
|
1093 | - // echo '<pre>'; print_r($accountid); exit; |
|
1094 | - $json_data = array(); |
|
1092 | + function customer_invoices($accountid){ |
|
1093 | + // echo '<pre>'; print_r($accountid); exit; |
|
1094 | + $json_data = array(); |
|
1095 | 1095 | /**** |
1096 | 1096 | Invoice manually |
1097 | 1097 | **/ |
1098 | - $where = array('accountid' => $accountid,'confirm'=>1); |
|
1099 | - $count_all = $this->db_model->countQuery("*","invoices",$where); |
|
1100 | - $currency_id = Common_model::$global_config['system_config']['base_currency']; |
|
1101 | - $paging_data = $this->form->load_grid_config($count_all, $_GET['rp'], $_GET['page']); |
|
1102 | - $json_data = $paging_data["json_paging"]; |
|
1098 | + $where = array('accountid' => $accountid,'confirm'=>1); |
|
1099 | + $count_all = $this->db_model->countQuery("*","invoices",$where); |
|
1100 | + $currency_id = Common_model::$global_config['system_config']['base_currency']; |
|
1101 | + $paging_data = $this->form->load_grid_config($count_all, $_GET['rp'], $_GET['page']); |
|
1102 | + $json_data = $paging_data["json_paging"]; |
|
1103 | 1103 | |
1104 | - $Invoice_grid_data = $this->db_model->select("*","invoices",$where,"invoice_date","desc",$paging_data["paging"]["page_no"],$paging_data["paging"]["start"]); |
|
1105 | - // echo $this->db->last_query(); exit; |
|
1106 | - $grid_fields= json_decode($this->invoices_form->build_invoices_list_for_admin()); |
|
1104 | + $Invoice_grid_data = $this->db_model->select("*","invoices",$where,"invoice_date","desc",$paging_data["paging"]["page_no"],$paging_data["paging"]["start"]); |
|
1105 | + // echo $this->db->last_query(); exit; |
|
1106 | + $grid_fields= json_decode($this->invoices_form->build_invoices_list_for_admin()); |
|
1107 | 1107 | |
1108 | - // $json_data['rows'] = $this->form->build_grid($Invoice_grid_data,$grid_fields); |
|
1109 | - $logintype = $this->session->userdata('logintype'); |
|
1110 | - $url= ($logintype==0 ||$logintype==3 ) ? "/user/user_invoice_download/":'/invoices/invoice_download/'; |
|
1111 | - if($Invoice_grid_data->num_rows > 0 ){ |
|
1112 | - $query=$Invoice_grid_data->result_array(); |
|
1113 | - $total_value = 0; |
|
1114 | - $ountstanding_value = 0; |
|
1108 | + // $json_data['rows'] = $this->form->build_grid($Invoice_grid_data,$grid_fields); |
|
1109 | + $logintype = $this->session->userdata('logintype'); |
|
1110 | + $url= ($logintype==0 ||$logintype==3 ) ? "/user/user_invoice_download/":'/invoices/invoice_download/'; |
|
1111 | + if($Invoice_grid_data->num_rows > 0 ){ |
|
1112 | + $query=$Invoice_grid_data->result_array(); |
|
1113 | + $total_value = 0; |
|
1114 | + $ountstanding_value = 0; |
|
1115 | 1115 | |
1116 | - foreach ($query as $key => $value) { |
|
1117 | - $date = strtotime($value['invoice_date']); |
|
1118 | - $invoice_date =date("Y-m-d",$date); |
|
1119 | - $fromdate = strtotime($value['from_date']); |
|
1120 | - $from_date =date("Y-m-d",$fromdate); |
|
1121 | - $duedate = strtotime($value['due_date']); |
|
1122 | - $due_date =date("Y-m-d",$duedate); |
|
1123 | - $outstanding = $value['amount']; |
|
1124 | - $last_payment_date = ''; |
|
1125 | - $invoice_total_query = $this->db_model->select("sum(debit) as debit,sum(credit) as credit,created_date", "invoice_details", array("invoiceid"=> $value['id'],"item_type"=>"INVPAY"),"created_date","DESC","1","0"); |
|
1126 | - // echo $this->db->last_query(); exit; |
|
1127 | - if ($invoice_total_query ->num_rows() > 0){ |
|
1128 | - $invoice_total_query= $invoice_total_query->result_array(); |
|
1129 | - //echo '<pre>'; print_r($invoice_total_query); |
|
1130 | - $outstanding -= $invoice_total_query[0]['credit']; |
|
1116 | + foreach ($query as $key => $value) { |
|
1117 | + $date = strtotime($value['invoice_date']); |
|
1118 | + $invoice_date =date("Y-m-d",$date); |
|
1119 | + $fromdate = strtotime($value['from_date']); |
|
1120 | + $from_date =date("Y-m-d",$fromdate); |
|
1121 | + $duedate = strtotime($value['due_date']); |
|
1122 | + $due_date =date("Y-m-d",$duedate); |
|
1123 | + $outstanding = $value['amount']; |
|
1124 | + $last_payment_date = ''; |
|
1125 | + $invoice_total_query = $this->db_model->select("sum(debit) as debit,sum(credit) as credit,created_date", "invoice_details", array("invoiceid"=> $value['id'],"item_type"=>"INVPAY"),"created_date","DESC","1","0"); |
|
1126 | + // echo $this->db->last_query(); exit; |
|
1127 | + if ($invoice_total_query ->num_rows() > 0){ |
|
1128 | + $invoice_total_query= $invoice_total_query->result_array(); |
|
1129 | + //echo '<pre>'; print_r($invoice_total_query); |
|
1130 | + $outstanding -= $invoice_total_query[0]['credit']; |
|
1131 | 1131 | |
1132 | - $last_payment_date = $invoice_total_query[0]['created_date']; |
|
1133 | - if($last_payment_date ){ |
|
1134 | - $payment_date=strtotime( $last_payment_date); |
|
1135 | - $payment_last=date("d/m/Y",$payment_date); |
|
1136 | - }else{ |
|
1137 | - $payment_last=''; |
|
1138 | - } |
|
1132 | + $last_payment_date = $invoice_total_query[0]['created_date']; |
|
1133 | + if($last_payment_date ){ |
|
1134 | + $payment_date=strtotime( $last_payment_date); |
|
1135 | + $payment_last=date("d/m/Y",$payment_date); |
|
1136 | + }else{ |
|
1137 | + $payment_last=''; |
|
1138 | + } |
|
1139 | 1139 | |
1140 | 1140 | |
1141 | - } |
|
1142 | - $invoice_total=''; |
|
1143 | - $accountinfo=$this->session->userdata('accountinfo'); |
|
1144 | - $id=$accountinfo['id']; |
|
1145 | - $query ="select sum(amount) as grand_total from invoices where confirm=1 and accountid=$accountid"; |
|
1141 | + } |
|
1142 | + $invoice_total=''; |
|
1143 | + $accountinfo=$this->session->userdata('accountinfo'); |
|
1144 | + $id=$accountinfo['id']; |
|
1145 | + $query ="select sum(amount) as grand_total from invoices where confirm=1 and accountid=$accountid"; |
|
1146 | 1146 | |
1147 | - $ext_query=$this->db->query($query); |
|
1148 | - if($ext_query->num_rows() > 0){ |
|
1149 | - $result_total=$ext_query->result_array(); |
|
1150 | - $grandtotal=$result_total[0]['grand_total']; |
|
1151 | - $grand_total=$this->common->currency_decimal($grandtotal).' '.$currency_id; |
|
1152 | - } |
|
1147 | + $ext_query=$this->db->query($query); |
|
1148 | + if($ext_query->num_rows() > 0){ |
|
1149 | + $result_total=$ext_query->result_array(); |
|
1150 | + $grandtotal=$result_total[0]['grand_total']; |
|
1151 | + $grand_total=$this->common->currency_decimal($grandtotal).' '.$currency_id; |
|
1152 | + } |
|
1153 | 1153 | |
1154 | - $invoice_query ="select sum(credit) as grand_credit from invoice_details where accountid=$accountid"; |
|
1155 | - $credit_query=$this->db->query($invoice_query); |
|
1156 | - if($credit_query->num_rows() > 0){ |
|
1157 | - $credit_total=$credit_query->result_array(); |
|
1158 | - $grand_credit_total=$credit_total[0]['grand_credit']; |
|
1159 | - $grandcredit=$grand_total-$grand_credit_total; |
|
1160 | - $grand_credit=$this->common->currency_decimal($grandcredit).' '.$currency_id; |
|
1161 | - } |
|
1154 | + $invoice_query ="select sum(credit) as grand_credit from invoice_details where accountid=$accountid"; |
|
1155 | + $credit_query=$this->db->query($invoice_query); |
|
1156 | + if($credit_query->num_rows() > 0){ |
|
1157 | + $credit_total=$credit_query->result_array(); |
|
1158 | + $grand_credit_total=$credit_total[0]['grand_credit']; |
|
1159 | + $grandcredit=$grand_total-$grand_credit_total; |
|
1160 | + $grand_credit=$this->common->currency_decimal($grandcredit).' '.$currency_id; |
|
1161 | + } |
|
1162 | 1162 | |
1163 | 1163 | |
1164 | 1164 | |
1165 | - $download="<a href=" . $url .$value['id']. " class='btn btn-royelblue btn-sm' title='Download Invoice' ><i class='fa fa-cloud-download fa-fw'></i></a> "; |
|
1166 | - if($value['type'] == 'R'){ |
|
1165 | + $download="<a href=" . $url .$value['id']. " class='btn btn-royelblue btn-sm' title='Download Invoice' ><i class='fa fa-cloud-download fa-fw'></i></a> "; |
|
1166 | + if($value['type'] == 'R'){ |
|
1167 | 1167 | $payment =''; |
1168 | 1168 | $outstanding=0; |
1169 | - }else{ |
|
1170 | - if($outstanding > 0){ |
|
1171 | - $payment = '<a style="padding: 0 8px;" href="'. base_url() .'invoices/invoice_summary/' . $value['id'] . '" class="btn btn-warning" title="Payment">Unpaid</i></a>'; |
|
1172 | - }else{ |
|
1173 | - $payment = ' <button style="padding: 0 8px;" type="button" class="btn btn-success">Paid</button>'; |
|
1174 | - } |
|
1175 | - } |
|
1169 | + }else{ |
|
1170 | + if($outstanding > 0){ |
|
1171 | + $payment = '<a style="padding: 0 8px;" href="'. base_url() .'invoices/invoice_summary/' . $value['id'] . '" class="btn btn-warning" title="Payment">Unpaid</i></a>'; |
|
1172 | + }else{ |
|
1173 | + $payment = ' <button style="padding: 0 8px;" type="button" class="btn btn-success">Paid</button>'; |
|
1174 | + } |
|
1175 | + } |
|
1176 | 1176 | |
1177 | - $account_arr = $this->db_model->getSelect('first_name,number,last_name','accounts', array('id'=>$value['accountid'])); |
|
1178 | - $account_array = $account_arr->result_array(); |
|
1179 | - if($value['generate_type'] == 1){ |
|
1177 | + $account_arr = $this->db_model->getSelect('first_name,number,last_name','accounts', array('id'=>$value['accountid'])); |
|
1178 | + $account_array = $account_arr->result_array(); |
|
1179 | + if($value['generate_type'] == 1){ |
|
1180 | 1180 | $invoice_type='Manually'; |
1181 | 1181 | }else{ |
1182 | 1182 | $invoice_type='Automatically'; |
@@ -1192,7 +1192,7 @@ discard block |
||
1192 | 1192 | } |
1193 | 1193 | |
1194 | 1194 | |
1195 | - $json_data['rows'][] = array('cell' => array( |
|
1195 | + $json_data['rows'][] = array('cell' => array( |
|
1196 | 1196 | $value['invoice_prefix'].$value['invoiceid'].$icon, |
1197 | 1197 | //$value['invoice_prefix'].$value['invoiceid'].' ('.$value['type'].')', |
1198 | 1198 | $invoice_type, |
@@ -1205,220 +1205,220 @@ discard block |
||
1205 | 1205 | $this->common_model->to_calculate_currency($outstanding, '', '', true, false), |
1206 | 1206 | $download.''.$payment, |
1207 | 1207 | )); |
1208 | - $total_value=$total_value + $value['amount']; |
|
1209 | - $ountstanding_value=$ountstanding_value + $outstanding; |
|
1210 | - } |
|
1211 | - } |
|
1208 | + $total_value=$total_value + $value['amount']; |
|
1209 | + $ountstanding_value=$ountstanding_value + $outstanding; |
|
1210 | + } |
|
1211 | + } |
|
1212 | 1212 | |
1213 | - echo json_encode($json_data); |
|
1214 | - } |
|
1215 | - function user_invoices($accountid){ |
|
1216 | - $json_data = array(); |
|
1213 | + echo json_encode($json_data); |
|
1214 | + } |
|
1215 | + function user_invoices($accountid){ |
|
1216 | + $json_data = array(); |
|
1217 | 1217 | $count_all = $this->invoices_model->get_user_invoice_list(false); |
1218 | - $paging_data = $this->form->load_grid_config($count_all, $_GET['rp'], $_GET['page']); |
|
1219 | - $json_data = $paging_data["json_paging"]; |
|
1220 | - $currency_id = Common_model::$global_config['system_config']['base_currency']; |
|
1221 | - $query = $this->invoices_model->get_user_invoice_list(true,$paging_data["paging"]["start"], $paging_data["paging"]["page_no"]); |
|
1222 | - $grid_fields= json_decode($this->invoices_form->build_invoices_list_for_customer()); |
|
1223 | - $query=$query->result_array(); |
|
1224 | - $account_arr = ''; |
|
1225 | - $created_date=''; |
|
1226 | - foreach ($query as $key => $value) { |
|
1227 | - $date = strtotime($value['invoice_date']); |
|
1228 | - $invoice_date =date("d/m/Y",$date); |
|
1229 | - $fromdate = strtotime($value['from_date']); |
|
1230 | - $from_date =date("d/m/Y",$fromdate); |
|
1231 | - $duedate = strtotime($value['due_date']); |
|
1232 | - $due_date =date("d/m/Y",$duedate); |
|
1233 | - $outstanding = $value['amount']; |
|
1234 | - $invoice_total_query = $this->db_model->select("sum(debit) as debit,sum(credit) as credit,created_date", "invoice_details", array("invoiceid"=> $value['id'],"item_type"=>"INVPAY"),"created_date","DESC","1","0"); |
|
1235 | - // echo $this->db->last_query(); exit; |
|
1236 | - if ($invoice_total_query ->num_rows() > 0){ |
|
1237 | - $invoice_total_query= $invoice_total_query->result_array(); |
|
1238 | - //echo '<pre>'; print_r($invoice_total_query); |
|
1239 | - $outstanding -= $invoice_total_query[0]['credit']; |
|
1218 | + $paging_data = $this->form->load_grid_config($count_all, $_GET['rp'], $_GET['page']); |
|
1219 | + $json_data = $paging_data["json_paging"]; |
|
1220 | + $currency_id = Common_model::$global_config['system_config']['base_currency']; |
|
1221 | + $query = $this->invoices_model->get_user_invoice_list(true,$paging_data["paging"]["start"], $paging_data["paging"]["page_no"]); |
|
1222 | + $grid_fields= json_decode($this->invoices_form->build_invoices_list_for_customer()); |
|
1223 | + $query=$query->result_array(); |
|
1224 | + $account_arr = ''; |
|
1225 | + $created_date=''; |
|
1226 | + foreach ($query as $key => $value) { |
|
1227 | + $date = strtotime($value['invoice_date']); |
|
1228 | + $invoice_date =date("d/m/Y",$date); |
|
1229 | + $fromdate = strtotime($value['from_date']); |
|
1230 | + $from_date =date("d/m/Y",$fromdate); |
|
1231 | + $duedate = strtotime($value['due_date']); |
|
1232 | + $due_date =date("d/m/Y",$duedate); |
|
1233 | + $outstanding = $value['amount']; |
|
1234 | + $invoice_total_query = $this->db_model->select("sum(debit) as debit,sum(credit) as credit,created_date", "invoice_details", array("invoiceid"=> $value['id'],"item_type"=>"INVPAY"),"created_date","DESC","1","0"); |
|
1235 | + // echo $this->db->last_query(); exit; |
|
1236 | + if ($invoice_total_query ->num_rows() > 0){ |
|
1237 | + $invoice_total_query= $invoice_total_query->result_array(); |
|
1238 | + //echo '<pre>'; print_r($invoice_total_query); |
|
1239 | + $outstanding -= $invoice_total_query[0]['credit']; |
|
1240 | 1240 | |
1241 | - $last_payment_date = $invoice_total_query[0]['created_date']; |
|
1242 | - if($last_payment_date ){ |
|
1243 | - $payment_date=strtotime( $last_payment_date); |
|
1244 | - $payment_last=date("d/m/Y",$payment_date); |
|
1245 | - }else{ |
|
1246 | - $payment_last=''; |
|
1247 | - } |
|
1241 | + $last_payment_date = $invoice_total_query[0]['created_date']; |
|
1242 | + if($last_payment_date ){ |
|
1243 | + $payment_date=strtotime( $last_payment_date); |
|
1244 | + $payment_last=date("d/m/Y",$payment_date); |
|
1245 | + }else{ |
|
1246 | + $payment_last=''; |
|
1247 | + } |
|
1248 | 1248 | |
1249 | 1249 | |
1250 | - } |
|
1251 | - $invoice_total_query = $this->db_model->select("debit,created_date", "invoice_details", array("invoiceid"=> $value['id'],"item_type"=>"INVPAY"),"created_date","DESC","1","0"); |
|
1252 | - if ( $invoice_total_query ->num_rows() > 0) { |
|
1253 | - $invoice_total_query= $invoice_total_query->result_array(); |
|
1254 | - // $outstanding = $invoice_total_query[0]['debit']; |
|
1255 | - $created_date = $invoice_total_query[0]['created_date']; |
|
1256 | - } |
|
1257 | - $accountinfo=$this->session->userdata('accountinfo'); |
|
1258 | - $query ="select sum(amount) as grand_total from invoices where confirm=1 and accountid=$accountid"; |
|
1250 | + } |
|
1251 | + $invoice_total_query = $this->db_model->select("debit,created_date", "invoice_details", array("invoiceid"=> $value['id'],"item_type"=>"INVPAY"),"created_date","DESC","1","0"); |
|
1252 | + if ( $invoice_total_query ->num_rows() > 0) { |
|
1253 | + $invoice_total_query= $invoice_total_query->result_array(); |
|
1254 | + // $outstanding = $invoice_total_query[0]['debit']; |
|
1255 | + $created_date = $invoice_total_query[0]['created_date']; |
|
1256 | + } |
|
1257 | + $accountinfo=$this->session->userdata('accountinfo'); |
|
1258 | + $query ="select sum(amount) as grand_total from invoices where confirm=1 and accountid=$accountid"; |
|
1259 | 1259 | |
1260 | - $ext_query=$this->db->query($query); |
|
1261 | - if($ext_query->num_rows() > 0){ |
|
1262 | - $result_total=$ext_query->result_array(); |
|
1263 | - $grandtotal=$result_total[0]['grand_total']; |
|
1264 | - $grand_total=$this->common->currency_decimal($grandtotal).' '.$currency_id; |
|
1265 | - } |
|
1260 | + $ext_query=$this->db->query($query); |
|
1261 | + if($ext_query->num_rows() > 0){ |
|
1262 | + $result_total=$ext_query->result_array(); |
|
1263 | + $grandtotal=$result_total[0]['grand_total']; |
|
1264 | + $grand_total=$this->common->currency_decimal($grandtotal).' '.$currency_id; |
|
1265 | + } |
|
1266 | 1266 | |
1267 | - $invoice_query ="select sum(credit) as grand_credit from invoice_details where accountid=$accountid"; |
|
1268 | - $credit_query=$this->db->query($invoice_query); |
|
1269 | - if($credit_query->num_rows() > 0){ |
|
1270 | - $credit_total=$credit_query->result_array(); |
|
1271 | - $grand_credit_total=$credit_total[0]['grand_credit']; |
|
1272 | - $grandcredit=$grand_total-$grand_credit_total; |
|
1273 | - $grand_credit=$this->common->currency_decimal($grandcredit).' '.$currency_id; |
|
1274 | - } |
|
1275 | - $download='<a href="'. base_url() .'/user/user_invoice_download/' . $value['id'].'/00'.$value['invoice_prefix'].$value['invoiceid'].'" class="btn btn-royelblue btn-sm" title="Download Invoice" ><i class="fa fa-cloud-download fa-fw"></i></a> '; |
|
1276 | - if($outstanding > 0){ |
|
1277 | - $payment = ' <a style="padding: 0 8px;" href="'. base_url() .'user/user_invoice_payment/' . $value['id'] . '" class="btn btn-warning" title="Payment">Unpaid</a>'; |
|
1267 | + $invoice_query ="select sum(credit) as grand_credit from invoice_details where accountid=$accountid"; |
|
1268 | + $credit_query=$this->db->query($invoice_query); |
|
1269 | + if($credit_query->num_rows() > 0){ |
|
1270 | + $credit_total=$credit_query->result_array(); |
|
1271 | + $grand_credit_total=$credit_total[0]['grand_credit']; |
|
1272 | + $grandcredit=$grand_total-$grand_credit_total; |
|
1273 | + $grand_credit=$this->common->currency_decimal($grandcredit).' '.$currency_id; |
|
1274 | + } |
|
1275 | + $download='<a href="'. base_url() .'/user/user_invoice_download/' . $value['id'].'/00'.$value['invoice_prefix'].$value['invoiceid'].'" class="btn btn-royelblue btn-sm" title="Download Invoice" ><i class="fa fa-cloud-download fa-fw"></i></a> '; |
|
1276 | + if($outstanding > 0){ |
|
1277 | + $payment = ' <a style="padding: 0 8px;" href="'. base_url() .'user/user_invoice_payment/' . $value['id'] . '" class="btn btn-warning" title="Payment">Unpaid</a>'; |
|
1278 | 1278 | }else{ |
1279 | 1279 | |
1280 | 1280 | $payment = ' <button style="padding: 0 8px;" class="btn btn-success" type="button">Paid</button>'; |
1281 | 1281 | } $account_arr = $this->db_model->getSelect('first_name,number,last_name','accounts', array('id'=>$value['accountid'])); |
1282 | 1282 | $account_array = $account_arr->result_array(); |
1283 | 1283 | $date = strtotime($value['invoice_date']); |
1284 | - $date = strtotime("+7 day", $date); |
|
1285 | - $time = date("Y-m-d h:i:s ",$date); |
|
1286 | - $json_data['rows'][] = array('cell' => array( |
|
1287 | - $value['invoice_prefix'].$value['invoiceid'].' ('.$value['type'].')', |
|
1284 | + $date = strtotime("+7 day", $date); |
|
1285 | + $time = date("Y-m-d h:i:s ",$date); |
|
1286 | + $json_data['rows'][] = array('cell' => array( |
|
1287 | + $value['invoice_prefix'].$value['invoiceid'].' ('.$value['type'].')', |
|
1288 | 1288 | $account_array[0]['first_name'].' '.$account_array[0]['last_name'].'</br>'.$account_array[0]['number'], |
1289 | - $invoice_date, |
|
1289 | + $invoice_date, |
|
1290 | 1290 | $from_date, |
1291 | 1291 | $due_date, |
1292 | 1292 | $payment_last, |
1293 | 1293 | $this->common->currency_decimal($value['amount']).' '.$currency_id, |
1294 | - $this->common->currency_decimal($outstanding).' '.$currency_id, |
|
1295 | - $download.$payment, |
|
1294 | + $this->common->currency_decimal($outstanding).' '.$currency_id, |
|
1295 | + $download.$payment, |
|
1296 | 1296 | |
1297 | 1297 | )); |
1298 | 1298 | |
1299 | 1299 | |
1300 | - } |
|
1300 | + } |
|
1301 | 1301 | |
1302 | - $json_data['rows'][] = array('cell' => array( |
|
1303 | - //$date.'- 0'.$value['id'].'('.$value['type'].')', |
|
1304 | - '<b>Grand Total</b>', |
|
1305 | - '', |
|
1306 | - '', |
|
1307 | - '', |
|
1308 | - '', |
|
1309 | - '', |
|
1310 | - "<b>". $grand_total."</b>", |
|
1311 | - "<b>".$grand_credit."<b>", |
|
1312 | - '', |
|
1302 | + $json_data['rows'][] = array('cell' => array( |
|
1303 | + //$date.'- 0'.$value['id'].'('.$value['type'].')', |
|
1304 | + '<b>Grand Total</b>', |
|
1305 | + '', |
|
1306 | + '', |
|
1307 | + '', |
|
1308 | + '', |
|
1309 | + '', |
|
1310 | + "<b>". $grand_total."</b>", |
|
1311 | + "<b>".$grand_credit."<b>", |
|
1312 | + '', |
|
1313 | 1313 | |
1314 | - )); |
|
1315 | - echo json_encode($json_data); |
|
1316 | - } |
|
1314 | + )); |
|
1315 | + echo json_encode($json_data); |
|
1316 | + } |
|
1317 | 1317 | |
1318 | - function invoice_logo_delete($accountid){ |
|
1318 | + function invoice_logo_delete($accountid){ |
|
1319 | 1319 | |
1320 | - $invoiceconf = $this->db_model->getSelect("*", "invoice_conf", array("id"=> $accountid)); |
|
1321 | - $result=$invoiceconf->result_array(); |
|
1322 | - $logo=$result[0]['logo']; |
|
1323 | - $post_arr=array('logo'=>''); |
|
1324 | - $where_arr=array('logo'=>$logo); |
|
1325 | - $this->db->where($where_arr); |
|
1326 | - $this->db->update('invoice_conf',$post_arr); |
|
1327 | - // redirect(base_url() . 'invoices/invoice_conf/'); |
|
1320 | + $invoiceconf = $this->db_model->getSelect("*", "invoice_conf", array("id"=> $accountid)); |
|
1321 | + $result=$invoiceconf->result_array(); |
|
1322 | + $logo=$result[0]['logo']; |
|
1323 | + $post_arr=array('logo'=>''); |
|
1324 | + $where_arr=array('logo'=>$logo); |
|
1325 | + $this->db->where($where_arr); |
|
1326 | + $this->db->update('invoice_conf',$post_arr); |
|
1327 | + // redirect(base_url() . 'invoices/invoice_conf/'); |
|
1328 | 1328 | |
1329 | - } |
|
1330 | - function invoice_list_view_invoice($invoiceid=false) { |
|
1329 | + } |
|
1330 | + function invoice_list_view_invoice($invoiceid=false) { |
|
1331 | 1331 | |
1332 | - $data['username'] = $this->session->userdata('user_name'); |
|
1333 | - $data['page_title'] = 'Invoice Detail'; |
|
1332 | + $data['username'] = $this->session->userdata('user_name'); |
|
1333 | + $data['page_title'] = 'Invoice Detail'; |
|
1334 | 1334 | |
1335 | - $cdrs_query = $this->invoices_model->getCdrs_invoice($invoiceid); |
|
1335 | + $cdrs_query = $this->invoices_model->getCdrs_invoice($invoiceid); |
|
1336 | 1336 | |
1337 | - $invoice_cdr_list = array(); |
|
1338 | - $cdr_list = array(); |
|
1339 | - if ($cdrs_query->num_rows() > 0) { |
|
1340 | - foreach ($cdrs_query->result_array() as $cdr) { |
|
1341 | - $cdr['charge'] = $this->common_model->calculate_currency($cdr['debit'] - $cdr['credit']); |
|
1342 | - array_push($cdr_list, $cdr); |
|
1343 | - } |
|
1344 | - } |
|
1345 | - $data['invoice_cdr_list'] = $cdr_list; |
|
1337 | + $invoice_cdr_list = array(); |
|
1338 | + $cdr_list = array(); |
|
1339 | + if ($cdrs_query->num_rows() > 0) { |
|
1340 | + foreach ($cdrs_query->result_array() as $cdr) { |
|
1341 | + $cdr['charge'] = $this->common_model->calculate_currency($cdr['debit'] - $cdr['credit']); |
|
1342 | + array_push($cdr_list, $cdr); |
|
1343 | + } |
|
1344 | + } |
|
1345 | + $data['invoice_cdr_list'] = $cdr_list; |
|
1346 | 1346 | |
1347 | - $invoice_total_query = $this->Astpp_common->get_invoice_total($invoiceid); |
|
1347 | + $invoice_total_query = $this->Astpp_common->get_invoice_total($invoiceid); |
|
1348 | 1348 | |
1349 | - $total_list = array(); |
|
1350 | - $invoice_total_list = array(); |
|
1349 | + $total_list = array(); |
|
1350 | + $invoice_total_list = array(); |
|
1351 | 1351 | |
1352 | - if ($invoice_total_query->num_rows() > 0) { |
|
1353 | - foreach ($invoice_total_query->result_array() as $total) { |
|
1354 | - array_push($total_list, $total); |
|
1355 | - } |
|
1356 | - } |
|
1357 | - $data['invoice_total_list'] = $total_list; |
|
1358 | - $invoicedata = $this->Astpp_common->get_invoice($invoiceid); |
|
1359 | - $data['invoiceid'] = @$invoicedata[0]['invoiceid']; |
|
1360 | - $data['invoicedate'] = @$invoicedata[0]['date']; |
|
1361 | - $data['accountid'] = @$invoicedata[0]['accountid']; |
|
1362 | - if(!empty($invoicedata)){ |
|
1352 | + if ($invoice_total_query->num_rows() > 0) { |
|
1353 | + foreach ($invoice_total_query->result_array() as $total) { |
|
1354 | + array_push($total_list, $total); |
|
1355 | + } |
|
1356 | + } |
|
1357 | + $data['invoice_total_list'] = $total_list; |
|
1358 | + $invoicedata = $this->Astpp_common->get_invoice($invoiceid); |
|
1359 | + $data['invoiceid'] = @$invoicedata[0]['invoiceid']; |
|
1360 | + $data['invoicedate'] = @$invoicedata[0]['date']; |
|
1361 | + $data['accountid'] = @$invoicedata[0]['accountid']; |
|
1362 | + if(!empty($invoicedata)){ |
|
1363 | 1363 | $accountinfo = $this->invoices_model->get_account_including_closed(@$invoicedata[0]['accountid']); |
1364 | 1364 | $data['accountinfo'] = $accountinfo; |
1365 | - } |
|
1366 | - $invoiceconf = $this->invoices_model->get_invoiceconf($accountinfo['reseller']); |
|
1367 | - $data['invoiceconf'] = $invoiceconf; |
|
1368 | - $this->load->view('view_account_invoice_detail', $data); |
|
1369 | - } |
|
1365 | + } |
|
1366 | + $invoiceconf = $this->invoices_model->get_invoiceconf($accountinfo['reseller']); |
|
1367 | + $data['invoiceconf'] = $invoiceconf; |
|
1368 | + $this->load->view('view_account_invoice_detail', $data); |
|
1369 | + } |
|
1370 | 1370 | |
1371 | - function invoice_download($invoiceid){ |
|
1372 | - $this->db->where('id',$invoiceid); |
|
1373 | - $this->db->select('type'); |
|
1374 | - $this->db->from('invoices'); |
|
1375 | - $result=$this->db->get(); |
|
1376 | - if($result->num_rows() > 0 ){ |
|
1377 | - $result=$result->result_array(); |
|
1378 | - $type= $result[0]['type']; |
|
1379 | - if($type=='I'){ |
|
1380 | - $this->invoice_main_download($invoiceid); |
|
1381 | - } |
|
1382 | - if($type=='R'){ |
|
1383 | - $this->receipt_download($invoiceid); |
|
1384 | - } |
|
1385 | - }else{ |
|
1386 | - redirect(base_url() . 'invoices/invoice_list/'); |
|
1387 | - } |
|
1388 | - } |
|
1371 | + function invoice_download($invoiceid){ |
|
1372 | + $this->db->where('id',$invoiceid); |
|
1373 | + $this->db->select('type'); |
|
1374 | + $this->db->from('invoices'); |
|
1375 | + $result=$this->db->get(); |
|
1376 | + if($result->num_rows() > 0 ){ |
|
1377 | + $result=$result->result_array(); |
|
1378 | + $type= $result[0]['type']; |
|
1379 | + if($type=='I'){ |
|
1380 | + $this->invoice_main_download($invoiceid); |
|
1381 | + } |
|
1382 | + if($type=='R'){ |
|
1383 | + $this->receipt_download($invoiceid); |
|
1384 | + } |
|
1385 | + }else{ |
|
1386 | + redirect(base_url() . 'invoices/invoice_list/'); |
|
1387 | + } |
|
1388 | + } |
|
1389 | 1389 | |
1390 | 1390 | function invoice_screen(){ |
1391 | 1391 | $login_type = $this->session->userdata['userlevel_logintype']; |
1392 | 1392 | if($login_type == -1 || $login_type == 2 ||$login_type == 1 || $login_type == 4){ |
1393 | - if($this->input->post()){ |
|
1394 | - $data = $this->input->post(); |
|
1395 | - if($data['accountid'] == '' || $data['accountid'] == '-Select-' ){ |
|
1396 | - $this->session->set_flashdata('astpp_notification', 'Please select accounts'); |
|
1397 | - redirect(base_url()."invoices/invoice_list/"); |
|
1398 | - } |
|
1399 | - if(!empty($data)){ |
|
1393 | + if($this->input->post()){ |
|
1394 | + $data = $this->input->post(); |
|
1395 | + if($data['accountid'] == '' || $data['accountid'] == '-Select-' ){ |
|
1396 | + $this->session->set_flashdata('astpp_notification', 'Please select accounts'); |
|
1397 | + redirect(base_url()."invoices/invoice_list/"); |
|
1398 | + } |
|
1399 | + if(!empty($data)){ |
|
1400 | 1400 | if(isset($data['notes']) && $data['notes'] !=''){ |
1401 | - $this->session->set_userdata('invoice_note',$data['notes']); |
|
1401 | + $this->session->set_userdata('invoice_note',$data['notes']); |
|
1402 | 1402 | } |
1403 | - $date=date('Y-m-d'); |
|
1404 | - $feture_date=date('Y-m-d', strtotime($date)); |
|
1405 | - $from_date=$data['fromdate']; |
|
1406 | - $genrated_date=$data['todate']; |
|
1407 | - $to_date=date('Y-m-d', strtotime($genrated_date)); |
|
1408 | - if( $to_date > $feture_date){ |
|
1409 | - $this->session->set_flashdata('astpp_notification', 'To date should not be greater than current date.'); |
|
1410 | - redirect(base_url()."invoices/invoice_list/"); |
|
1411 | - }else{ |
|
1412 | - $todate=$data['todate'].' '.'23:59:59'; |
|
1413 | - $from_date=$data['fromdate'].' '.'00:00:01'; |
|
1414 | - $accountid=$data['accountid']; |
|
1415 | - $acc_query = $this->db_model->getSelect("*", "accounts", array("id" => $accountid)); |
|
1403 | + $date=date('Y-m-d'); |
|
1404 | + $feture_date=date('Y-m-d', strtotime($date)); |
|
1405 | + $from_date=$data['fromdate']; |
|
1406 | + $genrated_date=$data['todate']; |
|
1407 | + $to_date=date('Y-m-d', strtotime($genrated_date)); |
|
1408 | + if( $to_date > $feture_date){ |
|
1409 | + $this->session->set_flashdata('astpp_notification', 'To date should not be greater than current date.'); |
|
1410 | + redirect(base_url()."invoices/invoice_list/"); |
|
1411 | + }else{ |
|
1412 | + $todate=$data['todate'].' '.'23:59:59'; |
|
1413 | + $from_date=$data['fromdate'].' '.'00:00:01'; |
|
1414 | + $accountid=$data['accountid']; |
|
1415 | + $acc_query = $this->db_model->getSelect("*", "accounts", array("id" => $accountid)); |
|
1416 | 1416 | $accountdata = $acc_query->result_array(); |
1417 | 1417 | $accountdata=$accountdata[0]; |
1418 | 1418 | $screen_path = getcwd()."/cron"; |
1419 | - $screen_filename = "Email_Broadcast_".strtotime('now'); |
|
1420 | - $command = "cd ".$screen_path." && /usr/bin/screen -d -m -S $screen_filename php cron.php BroadcastEmail"; |
|
1421 | - exec($command); |
|
1419 | + $screen_filename = "Email_Broadcast_".strtotime('now'); |
|
1420 | + $command = "cd ".$screen_path." && /usr/bin/screen -d -m -S $screen_filename php cron.php BroadcastEmail"; |
|
1421 | + exec($command); |
|
1422 | 1422 | $invoice_data_count = 0; |
1423 | 1423 | $invoice_conf = array(); |
1424 | 1424 | if($accountdata['reseller_id'] == 0){ |
@@ -1443,9 +1443,9 @@ discard block |
||
1443 | 1443 | } |
1444 | 1444 | $last_invoice_ID =str_pad($last_invoice_ID,(strlen($last_invoice_ID)+4),'0',STR_PAD_LEFT); |
1445 | 1445 | if($accountdata['posttoexternal'] == 1){ |
1446 | - $balance = ($accountdata['credit_limit']-$accountdata['balance']); |
|
1446 | + $balance = ($accountdata['credit_limit']-$accountdata['balance']); |
|
1447 | 1447 | }else{ |
1448 | - $balance = $accountdata['balance']; |
|
1448 | + $balance = $accountdata['balance']; |
|
1449 | 1449 | } |
1450 | 1450 | if($accountdata['invoice_interval'] > 0){ |
1451 | 1451 | $due_date = gmdate("Y-m-d H:i:s",strtotime(gmdate("Y-m-d H:i:s")." +".$accountdata['invoice_interval']." days")); |
@@ -1460,16 +1460,16 @@ discard block |
||
1460 | 1460 | $invoice_data['invoice_note']=$invoice_note; |
1461 | 1461 | $this->db->insert("invoices",$invoice_data); |
1462 | 1462 | $invoiceid = $this->db->insert_id(); |
1463 | - //$generateInvoice->process_invoice($accountdata,$from_date,$todate); |
|
1464 | - $this->session->set_flashdata('astpp_errormsg', 'Invoice generation completed .'); |
|
1465 | - redirect(base_url()."invoices/invoice_manually_edit/".$invoiceid); |
|
1463 | + //$generateInvoice->process_invoice($accountdata,$from_date,$todate); |
|
1464 | + $this->session->set_flashdata('astpp_errormsg', 'Invoice generation completed .'); |
|
1465 | + redirect(base_url()."invoices/invoice_manually_edit/".$invoiceid); |
|
1466 | 1466 | |
1467 | - } |
|
1468 | - } |
|
1469 | - } else{ |
|
1470 | - $this->session->set_flashdata('astpp_errormsg', 'No data found.....'); |
|
1471 | - redirect(base_url()."invoices/invoice_list/"); |
|
1472 | - } |
|
1467 | + } |
|
1468 | + } |
|
1469 | + } else{ |
|
1470 | + $this->session->set_flashdata('astpp_errormsg', 'No data found.....'); |
|
1471 | + redirect(base_url()."invoices/invoice_list/"); |
|
1472 | + } |
|
1473 | 1473 | |
1474 | 1474 | } |
1475 | 1475 | else |
@@ -1477,100 +1477,100 @@ discard block |
||
1477 | 1477 | $this->session->set_flashdata('astpp_notification', 'Permission Denied.'); |
1478 | 1478 | redirect(base_url()."invoices/invoice_list/"); |
1479 | 1479 | } |
1480 | - } |
|
1481 | - function get_invoice_date($select,$accountid=false){ |
|
1480 | + } |
|
1481 | + function get_invoice_date($select,$accountid=false){ |
|
1482 | 1482 | if($accountid){ |
1483 | - $where = array('type'=>"I","accountid"=>$accountid); |
|
1484 | - $query = $this->db_model->select($select, "invoices", $where,"to_date","DESC","1","0"); |
|
1483 | + $where = array('type'=>"I","accountid"=>$accountid); |
|
1484 | + $query = $this->db_model->select($select, "invoices", $where,"to_date","DESC","1","0"); |
|
1485 | 1485 | }else{ |
1486 | 1486 | $where = array('type'=>"I"); |
1487 | - $query = $this->db_model->select($select, "invoices", $where,"id","DESC","1","0"); |
|
1487 | + $query = $this->db_model->select($select, "invoices", $where,"id","DESC","1","0"); |
|
1488 | 1488 | } |
1489 | - if($query->num_rows >0){ |
|
1490 | - $invoiceid = $query->result_array(); |
|
1491 | - $invoice_date=$invoiceid[0][$select]; |
|
1492 | - return $invoice_date; |
|
1493 | - } |
|
1494 | - return false; |
|
1495 | - } |
|
1496 | - function invoice_main_download($invoiceid) { |
|
1489 | + if($query->num_rows >0){ |
|
1490 | + $invoiceid = $query->result_array(); |
|
1491 | + $invoice_date=$invoiceid[0][$select]; |
|
1492 | + return $invoice_date; |
|
1493 | + } |
|
1494 | + return false; |
|
1495 | + } |
|
1496 | + function invoice_main_download($invoiceid) { |
|
1497 | 1497 | |
1498 | - $invoicedata = $this->db_model->getSelect("*", "invoices", array("id"=> $invoiceid)); |
|
1499 | - $invoicedata = $invoicedata->result_array(); |
|
1500 | - $invoicedata=$invoicedata[0]; |
|
1498 | + $invoicedata = $this->db_model->getSelect("*", "invoices", array("id"=> $invoiceid)); |
|
1499 | + $invoicedata = $invoicedata->result_array(); |
|
1500 | + $invoicedata=$invoicedata[0]; |
|
1501 | 1501 | $invoice_path=''; |
1502 | - $accountid = $invoicedata['accountid']; |
|
1503 | - $acc_file=$invoice_path.$accountid.'/'.$invoiceid; |
|
1504 | - $accountdata = $this->db_model->getSelect("*","accounts",array("id"=>$accountid)); |
|
1505 | - $accountdata = $accountdata->result_array(); |
|
1506 | - $accountdata = $accountdata[0]; |
|
1502 | + $accountid = $invoicedata['accountid']; |
|
1503 | + $acc_file=$invoice_path.$accountid.'/'.$invoiceid; |
|
1504 | + $accountdata = $this->db_model->getSelect("*","accounts",array("id"=>$accountid)); |
|
1505 | + $accountdata = $accountdata->result_array(); |
|
1506 | + $accountdata = $accountdata[0]; |
|
1507 | 1507 | |
1508 | - $login_type = $this->session->userdata['userlevel_logintype']; |
|
1509 | - $query="select item_type,credit from invoice_details where invoiceid = ".$invoicedata['id']." and item_type='INVPAY' Group By id order by item_type desc"; |
|
1510 | - // echo $query; exit; |
|
1511 | - $invoice_total_query=$this->db->query($query); |
|
1512 | - if($invoice_total_query->num_rows() > 0){ |
|
1513 | - $total=$invoice_total_query->result_array(); |
|
1514 | - foreach($total as $key => $value){ |
|
1515 | - $debit=$value['credit']; |
|
1516 | - } |
|
1517 | - if($debit){ |
|
1518 | - // echo 'debit'; exit; |
|
1519 | - $invoice_path=$this->config->item('invoices_path'); |
|
1520 | - $download_path = $invoice_path.$accountdata["id"].'/'.$invoicedata['invoice_prefix'].$invoicedata['invoiceid']."_invoice.pdf"; |
|
1521 | - unlink($download_path); |
|
1522 | - $res = $this->common->get_invoice_template($invoicedata,$accountdata,"TRUE"); |
|
1523 | - } |
|
1524 | - } |
|
1525 | - $invoice_path=$this->config->item('invoices_path'); |
|
1526 | - $download_path = $invoice_path.$accountdata["id"].'/'.$invoicedata['invoice_prefix'].$invoicedata['invoiceid']."_invoice.pdf"; |
|
1527 | - $res = $this->common->get_invoice_template($invoicedata,$accountdata,"TRUE"); |
|
1528 | - } |
|
1508 | + $login_type = $this->session->userdata['userlevel_logintype']; |
|
1509 | + $query="select item_type,credit from invoice_details where invoiceid = ".$invoicedata['id']." and item_type='INVPAY' Group By id order by item_type desc"; |
|
1510 | + // echo $query; exit; |
|
1511 | + $invoice_total_query=$this->db->query($query); |
|
1512 | + if($invoice_total_query->num_rows() > 0){ |
|
1513 | + $total=$invoice_total_query->result_array(); |
|
1514 | + foreach($total as $key => $value){ |
|
1515 | + $debit=$value['credit']; |
|
1516 | + } |
|
1517 | + if($debit){ |
|
1518 | + // echo 'debit'; exit; |
|
1519 | + $invoice_path=$this->config->item('invoices_path'); |
|
1520 | + $download_path = $invoice_path.$accountdata["id"].'/'.$invoicedata['invoice_prefix'].$invoicedata['invoiceid']."_invoice.pdf"; |
|
1521 | + unlink($download_path); |
|
1522 | + $res = $this->common->get_invoice_template($invoicedata,$accountdata,"TRUE"); |
|
1523 | + } |
|
1524 | + } |
|
1525 | + $invoice_path=$this->config->item('invoices_path'); |
|
1526 | + $download_path = $invoice_path.$accountdata["id"].'/'.$invoicedata['invoice_prefix'].$invoicedata['invoiceid']."_invoice.pdf"; |
|
1527 | + $res = $this->common->get_invoice_template($invoicedata,$accountdata,"TRUE"); |
|
1528 | + } |
|
1529 | 1529 | function Sec2Minutes( $seconds ) |
1530 | 1530 | { |
1531 | - return sprintf( "%02.2d:%02.2d", floor( $seconds / 60 ), $seconds % 60 ); |
|
1531 | + return sprintf( "%02.2d:%02.2d", floor( $seconds / 60 ), $seconds % 60 ); |
|
1532 | 1532 | } |
1533 | 1533 | function receipt_download($invoiceid) { |
1534 | - $login_info = $this->session->userdata('accountinfo'); |
|
1535 | - ob_start(); |
|
1536 | - $this->load->library('/html2pdf/html2pdf'); |
|
1537 | - $template_config=$this->config->item('invoice_template'); |
|
1538 | - include($template_config.'invoice_template_receipt.php'); |
|
1539 | - $content = ob_get_clean(); |
|
1540 | - ob_clean(); |
|
1541 | - $accountid = $this->common->get_field_name('accountid', 'invoices', $invoiceid); |
|
1542 | - $accountdata = $this->db_model->getSelect("*","accounts",array("id"=>$accountid)); |
|
1543 | - $accountdata = $accountdata->result_array(); |
|
1544 | - $accountdata = $accountdata[0]; |
|
1534 | + $login_info = $this->session->userdata('accountinfo'); |
|
1535 | + ob_start(); |
|
1536 | + $this->load->library('/html2pdf/html2pdf'); |
|
1537 | + $template_config=$this->config->item('invoice_template'); |
|
1538 | + include($template_config.'invoice_template_receipt.php'); |
|
1539 | + $content = ob_get_clean(); |
|
1540 | + ob_clean(); |
|
1541 | + $accountid = $this->common->get_field_name('accountid', 'invoices', $invoiceid); |
|
1542 | + $accountdata = $this->db_model->getSelect("*","accounts",array("id"=>$accountid)); |
|
1543 | + $accountdata = $accountdata->result_array(); |
|
1544 | + $accountdata = $accountdata[0]; |
|
1545 | 1545 | // $accountdata["currency_id"] = $this->common->get_field_name('currency', 'currency', $accountdata["currency_id"]); |
1546 | 1546 | //$currency = $accountdata["currency_id"]; |
1547 | - if($login_info['type'] == -1){ |
|
1547 | + if($login_info['type'] == -1){ |
|
1548 | 1548 | $data["to_currency"] = Common_model::$global_config['system_config']['base_currency']; |
1549 | - $currency = $data["to_currency"]; |
|
1550 | - }elseif($login_info['type'] == 1){ |
|
1549 | + $currency = $data["to_currency"]; |
|
1550 | + }elseif($login_info['type'] == 1){ |
|
1551 | 1551 | $accountdata["currency_id"] = $this->common->get_field_name('currency', 'currency', $login_info["currency_id"]); |
1552 | - $currency = $accountdata["currency_id"]; |
|
1553 | - }else{ |
|
1552 | + $currency = $accountdata["currency_id"]; |
|
1553 | + }else{ |
|
1554 | 1554 | $accountdata["currency_id"] = $this->common->get_field_name('currency', 'currency', $login_info["currency_id"]); |
1555 | - $currency = $accountdata["currency_id"]; |
|
1556 | - } |
|
1557 | - $invoice_cdr_list = array(); |
|
1558 | - $invoicedata = $this->db_model->getSelect("*", "invoices", array("id"=> $invoiceid)); |
|
1559 | - $invoicedata = $invoicedata->result_array(); |
|
1560 | - $invoicedata=$invoicedata[0]; |
|
1555 | + $currency = $accountdata["currency_id"]; |
|
1556 | + } |
|
1557 | + $invoice_cdr_list = array(); |
|
1558 | + $invoicedata = $this->db_model->getSelect("*", "invoices", array("id"=> $invoiceid)); |
|
1559 | + $invoicedata = $invoicedata->result_array(); |
|
1560 | + $invoicedata=$invoicedata[0]; |
|
1561 | 1561 | |
1562 | - $data['invoiceid'] = @$invoicedata[0]['id']; |
|
1563 | - $data['id'] = @$invoicedata['invoiceid']; |
|
1562 | + $data['invoiceid'] = @$invoicedata[0]['id']; |
|
1563 | + $data['id'] = @$invoicedata['invoiceid']; |
|
1564 | 1564 | |
1565 | - $data['invoice_date'] = @$invoicedata[0]['invoice_date']; |
|
1566 | - $data['accountid'] = @$invoicedata[0]['accountid']; |
|
1565 | + $data['invoice_date'] = @$invoicedata[0]['invoice_date']; |
|
1566 | + $data['accountid'] = @$invoicedata[0]['accountid']; |
|
1567 | 1567 | $data['from_date'] = @$invoicedata[0]['from_date']; |
1568 | 1568 | $data['to_date'] = @$invoicedata[0]['to_date']; |
1569 | - $total_list = array(); |
|
1570 | - $data['description']=''; |
|
1571 | - $data['item_type']=''; |
|
1572 | - $data['debit']=''; |
|
1573 | - $invoice_total_list = array(); |
|
1569 | + $total_list = array(); |
|
1570 | + $data['description']=''; |
|
1571 | + $data['item_type']=''; |
|
1572 | + $data['debit']=''; |
|
1573 | + $invoice_total_list = array(); |
|
1574 | 1574 | $query="select item_type,description,created_date,invoiceid,debit,credit from invoice_details where invoiceid = ".$invoiceid." And ( item_type='POSTCHARG' Or item_type='Refill') Group By item_type"; |
1575 | 1575 | $invoice_total_query=$this->db->query($query); |
1576 | 1576 | if($invoice_total_query ->num_rows() > 0) { |
@@ -1586,7 +1586,7 @@ discard block |
||
1586 | 1586 | $created_date=$value['created_date']; |
1587 | 1587 | $invoicedata['invoiceid']=$value['invoiceid']; |
1588 | 1588 | } |
1589 | - }else{ |
|
1589 | + }else{ |
|
1590 | 1590 | $query="select item_type,description,created_date,invoiceid,debit,credit from invoice_details where invoiceid = ".$invoiceid." And item_type='SUBCHRG' Group By item_type"; |
1591 | 1591 | $invoice_total_query=$this->db->query($query); |
1592 | 1592 | if($invoice_total_query ->num_rows() > 0) { |
@@ -1604,88 +1604,88 @@ discard block |
||
1604 | 1604 | } |
1605 | 1605 | } |
1606 | 1606 | } |
1607 | - $data['accountinfo'] = $accountdata; |
|
1608 | - //Get invoice header information |
|
1609 | - if($accountdata['reseller_id']=='0') |
|
1610 | - $accountid = '1'; |
|
1611 | - else |
|
1612 | - $accountid = $accountdata['reseller_id']; |
|
1613 | - $invoiceconf = $this->db_model->getSelect("*", "invoice_conf", array("accountid"=> $accountid)); |
|
1614 | - $invoiceconf = $invoiceconf->result_array(); |
|
1615 | - if(!empty($invoiceconf)){ |
|
1616 | - $data['invoiceconf'] = $invoiceconf[0]; |
|
1617 | - }else{ |
|
1618 | - $invoiceconf = $this->db_model->getSelect("*", "invoice_conf", array("accountid"=> "1")); |
|
1619 | - $invoiceconf = $invoiceconf->result_array(); |
|
1620 | - $data['invoiceconf'] = $invoiceconf[0]; |
|
1621 | - } |
|
1607 | + $data['accountinfo'] = $accountdata; |
|
1608 | + //Get invoice header information |
|
1609 | + if($accountdata['reseller_id']=='0') |
|
1610 | + $accountid = '1'; |
|
1611 | + else |
|
1612 | + $accountid = $accountdata['reseller_id']; |
|
1613 | + $invoiceconf = $this->db_model->getSelect("*", "invoice_conf", array("accountid"=> $accountid)); |
|
1614 | + $invoiceconf = $invoiceconf->result_array(); |
|
1615 | + if(!empty($invoiceconf)){ |
|
1616 | + $data['invoiceconf'] = $invoiceconf[0]; |
|
1617 | + }else{ |
|
1618 | + $invoiceconf = $this->db_model->getSelect("*", "invoice_conf", array("accountid"=> "1")); |
|
1619 | + $invoiceconf = $invoiceconf->result_array(); |
|
1620 | + $data['invoiceconf'] = $invoiceconf[0]; |
|
1621 | + } |
|
1622 | 1622 | |
1623 | 1623 | |
1624 | 1624 | |
1625 | - // echo '<pre>'; print_r($accountdata); exit; |
|
1626 | - //FOR the Customer Address |
|
1627 | - $customer_address="<div style='font-size:12px;' >"; |
|
1628 | - if ( $accountdata['company_name'] != "") |
|
1629 | - $customer_address .= $accountdata['company_name'] . "<br/>"; |
|
1630 | - if ( $accountdata['address_1'] != "") |
|
1631 | - $customer_address .= $accountdata['address_1'] . "," .$accountdata['address_2'] .",". "<br/>"; |
|
1632 | - if ( $accountdata['city'] != "") |
|
1633 | - $customer_address .= $accountdata['city'] . "<br/>"; |
|
1634 | - if ( $accountdata['province'] != "") |
|
1635 | - $customer_address .= $accountdata['province']."<br/>"; |
|
1636 | - if ( $accountdata['country_id'] != "") |
|
1637 | - $customer_address .= $this->common->get_field_name('country', 'countrycode', $accountdata['country_id'])."<br/>"; |
|
1638 | - if ( $accountdata['postal_code'] != "") |
|
1639 | - $customer_address .= "Pincode - " . $accountdata['postal_code'] . "<br/>"; |
|
1640 | - else |
|
1641 | - $customer_address .= "\n"; |
|
1642 | - // $customer_address .= "Date of Invoice: " .date('d/m/Y', strtotime($invoicedata['invoice_date']))."<br/>"; |
|
1625 | + // echo '<pre>'; print_r($accountdata); exit; |
|
1626 | + //FOR the Customer Address |
|
1627 | + $customer_address="<div style='font-size:12px;' >"; |
|
1628 | + if ( $accountdata['company_name'] != "") |
|
1629 | + $customer_address .= $accountdata['company_name'] . "<br/>"; |
|
1630 | + if ( $accountdata['address_1'] != "") |
|
1631 | + $customer_address .= $accountdata['address_1'] . "," .$accountdata['address_2'] .",". "<br/>"; |
|
1632 | + if ( $accountdata['city'] != "") |
|
1633 | + $customer_address .= $accountdata['city'] . "<br/>"; |
|
1634 | + if ( $accountdata['province'] != "") |
|
1635 | + $customer_address .= $accountdata['province']."<br/>"; |
|
1636 | + if ( $accountdata['country_id'] != "") |
|
1637 | + $customer_address .= $this->common->get_field_name('country', 'countrycode', $accountdata['country_id'])."<br/>"; |
|
1638 | + if ( $accountdata['postal_code'] != "") |
|
1639 | + $customer_address .= "Pincode - " . $accountdata['postal_code'] . "<br/>"; |
|
1640 | + else |
|
1641 | + $customer_address .= "\n"; |
|
1642 | + // $customer_address .= "Date of Invoice: " .date('d/m/Y', strtotime($invoicedata['invoice_date']))."<br/>"; |
|
1643 | 1643 | $customer_address .= "</div>"; |
1644 | 1644 | |
1645 | - $reseller_id=$accountdata['reseller_id']; |
|
1646 | - $logo=''; |
|
1647 | - if(!empty($invoiceconf) && $invoiceconf != ''){ |
|
1648 | - $logo= $invoiceconf[0]['logo']; |
|
1649 | - $dir_path= getcwd()."/assets/Logo/"; |
|
1650 | - // echo $dir_path; exit; |
|
1651 | - $path =$dir_path. $logo; |
|
1652 | - if($logo != ''){ |
|
1653 | - $src=$path; |
|
1654 | - $logo = "<img style='height:50px; width:180px; margin-left:70px;' alt='logo' src='".$src."'>"; |
|
1655 | - }else{ |
|
1656 | - $path = getcwd()."/assets/images/logo.png"; |
|
1657 | - $src=$path; |
|
1658 | - $logo = "<img style='height:50px; width:180px; margin-left:70px;' alt='logo' src='".$src."'>"; |
|
1659 | - } |
|
1660 | - } |
|
1645 | + $reseller_id=$accountdata['reseller_id']; |
|
1646 | + $logo=''; |
|
1647 | + if(!empty($invoiceconf) && $invoiceconf != ''){ |
|
1648 | + $logo= $invoiceconf[0]['logo']; |
|
1649 | + $dir_path= getcwd()."/assets/Logo/"; |
|
1650 | + // echo $dir_path; exit; |
|
1651 | + $path =$dir_path. $logo; |
|
1652 | + if($logo != ''){ |
|
1653 | + $src=$path; |
|
1654 | + $logo = "<img style='height:50px; width:180px; margin-left:70px;' alt='logo' src='".$src."'>"; |
|
1655 | + }else{ |
|
1656 | + $path = getcwd()."/assets/images/logo.png"; |
|
1657 | + $src=$path; |
|
1658 | + $logo = "<img style='height:50px; width:180px; margin-left:70px;' alt='logo' src='".$src."'>"; |
|
1659 | + } |
|
1660 | + } |
|
1661 | 1661 | |
1662 | 1662 | |
1663 | - $CALL_DETAILS_TABLE=null; |
|
1664 | - $CALL_DETAILS_TABLE .= "<tr style='font-family:arial;'>"; |
|
1665 | - $CALL_DETAILS_TABLE .= "<td style='font-size:12px;padding:7px 5px;width: 35%;text-align:right;border-bottom:1px solid black;border-left:1px solid #000;border-right:1px solid #000;'>".$accountdata['number']."</td>"; |
|
1666 | - $CALL_DETAILS_TABLE .= "<td style='font-size:12px;padding:7px 5px;width: 25%;border-bottom:1px solid black;text-align:right;border-right:1px solid #000;'>".$invoicedata['invoice_prefix'].$data['id']."</td>"; |
|
1667 | - $CALL_DETAILS_TABLE .= "<td style='font-size:12px;padding:7px 5px;width: 20%;border-bottom:1px solid black;text-align:right;border-right:1px solid #000;'>".date('Y-m-d', strtotime($invoicedata['from_date']))."</td>"; |
|
1668 | - $CALL_DETAILS_TABLE .= "<td style='font-size:12px;padding:7px 5px;width: 20%;border-bottom:1px solid black;text-align:right;border-right:1px solid #000;'>".date('Y-m-d', strtotime($invoicedata['from_date']))."</td>"; |
|
1669 | - $CALL_DETAILS_TABLE .='</tr>'; |
|
1663 | + $CALL_DETAILS_TABLE=null; |
|
1664 | + $CALL_DETAILS_TABLE .= "<tr style='font-family:arial;'>"; |
|
1665 | + $CALL_DETAILS_TABLE .= "<td style='font-size:12px;padding:7px 5px;width: 35%;text-align:right;border-bottom:1px solid black;border-left:1px solid #000;border-right:1px solid #000;'>".$accountdata['number']."</td>"; |
|
1666 | + $CALL_DETAILS_TABLE .= "<td style='font-size:12px;padding:7px 5px;width: 25%;border-bottom:1px solid black;text-align:right;border-right:1px solid #000;'>".$invoicedata['invoice_prefix'].$data['id']."</td>"; |
|
1667 | + $CALL_DETAILS_TABLE .= "<td style='font-size:12px;padding:7px 5px;width: 20%;border-bottom:1px solid black;text-align:right;border-right:1px solid #000;'>".date('Y-m-d', strtotime($invoicedata['from_date']))."</td>"; |
|
1668 | + $CALL_DETAILS_TABLE .= "<td style='font-size:12px;padding:7px 5px;width: 20%;border-bottom:1px solid black;text-align:right;border-right:1px solid #000;'>".date('Y-m-d', strtotime($invoicedata['from_date']))."</td>"; |
|
1669 | + $CALL_DETAILS_TABLE .='</tr>'; |
|
1670 | 1670 | |
1671 | 1671 | |
1672 | - $RECEIPT_DETAILS_TABLE=null; |
|
1673 | - $RECEIPT_DETAILS_TABLE .= "<tr style='font-family:arial;'>"; |
|
1674 | - $RECEIPT_DETAILS_TABLE .= "<td style='font-size:12px;padding:7px 5px;width: 35%;text-align:right;border-bottom:1px solid black;border-left:1px solid #000;border-right:1px solid #000;'>".date('Y-m-d', strtotime($invoicedata['from_date']))."</td>"; |
|
1675 | - $RECEIPT_DETAILS_TABLE .= "<td style='font-size:12px;padding:7px 5px;width: 25%;border-bottom:1px solid black;text-align:right;border-right:1px solid #000;'>".$data['description']."</td>"; |
|
1676 | - $RECEIPT_DETAILS_TABLE .= "<td style='font-size:12px;padding:7px 5px;width: 20%;border-bottom:1px solid black;text-align:right;border-right:1px solid #000;'>".$data['item_type']."</td>"; |
|
1677 | - $RECEIPT_DETAILS_TABLE .= "<td style='font-size:12px;padding:7px 5px;width: 20%;border-bottom:1px solid black;text-align:right;border-right:1px solid #000;'>".$this->common->currency_decimal($this->common_model->calculate_currency($data['debit']))."</td>"; |
|
1678 | - $RECEIPT_DETAILS_TABLE .='</tr>'; |
|
1672 | + $RECEIPT_DETAILS_TABLE=null; |
|
1673 | + $RECEIPT_DETAILS_TABLE .= "<tr style='font-family:arial;'>"; |
|
1674 | + $RECEIPT_DETAILS_TABLE .= "<td style='font-size:12px;padding:7px 5px;width: 35%;text-align:right;border-bottom:1px solid black;border-left:1px solid #000;border-right:1px solid #000;'>".date('Y-m-d', strtotime($invoicedata['from_date']))."</td>"; |
|
1675 | + $RECEIPT_DETAILS_TABLE .= "<td style='font-size:12px;padding:7px 5px;width: 25%;border-bottom:1px solid black;text-align:right;border-right:1px solid #000;'>".$data['description']."</td>"; |
|
1676 | + $RECEIPT_DETAILS_TABLE .= "<td style='font-size:12px;padding:7px 5px;width: 20%;border-bottom:1px solid black;text-align:right;border-right:1px solid #000;'>".$data['item_type']."</td>"; |
|
1677 | + $RECEIPT_DETAILS_TABLE .= "<td style='font-size:12px;padding:7px 5px;width: 20%;border-bottom:1px solid black;text-align:right;border-right:1px solid #000;'>".$this->common->currency_decimal($this->common_model->calculate_currency($data['debit']))."</td>"; |
|
1678 | + $RECEIPT_DETAILS_TABLE .='</tr>'; |
|
1679 | 1679 | |
1680 | 1680 | |
1681 | - //echo '<pre>'; print_r($data['id']); exit; |
|
1681 | + //echo '<pre>'; print_r($data['id']); exit; |
|
1682 | 1682 | |
1683 | - $MONTHLY_DESC=null; |
|
1684 | - $MONTHLY_DESC .= "<div style='font-size:12px;' ><b>Account Number :</b> " . $accountdata['number']."<br/>"; |
|
1685 | - $MONTHLY_DESC .= "<b>Receipt Number :</b> " .$invoicedata['invoice_prefix'].$data['id']."<br/>"; |
|
1686 | - $MONTHLY_DESC .= "<b>Receipt Date :</b> " .date('Y-m-d', strtotime($invoicedata['from_date']))."<br/></div>"; |
|
1683 | + $MONTHLY_DESC=null; |
|
1684 | + $MONTHLY_DESC .= "<div style='font-size:12px;' ><b>Account Number :</b> " . $accountdata['number']."<br/>"; |
|
1685 | + $MONTHLY_DESC .= "<b>Receipt Number :</b> " .$invoicedata['invoice_prefix'].$data['id']."<br/>"; |
|
1686 | + $MONTHLY_DESC .= "<b>Receipt Date :</b> " .date('Y-m-d', strtotime($invoicedata['from_date']))."<br/></div>"; |
|
1687 | 1687 | |
1688 | - $COMPANY_DETAILS_TABLE = null; |
|
1688 | + $COMPANY_DETAILS_TABLE = null; |
|
1689 | 1689 | $COMPANY_DETAILS_SET=null; |
1690 | 1690 | $COMPANY_DETAILS_SET.= $data['invoiceconf']['company_name']."<br/>"; |
1691 | 1691 | $COMPANY_DETAILS_SET.= $data['invoiceconf']['address'].",<br/>"; |
@@ -1699,12 +1699,12 @@ discard block |
||
1699 | 1699 | $COMPANY_DETAILS_SET.= $data['invoiceconf']['emailaddress']."<br/>"; |
1700 | 1700 | $COMPANY_DETAILS_SET.= $data['invoiceconf']['website']."<br/>"; |
1701 | 1701 | |
1702 | - if(!empty($data['invoiceconf']) && $data['invoiceconf'] != ''){ |
|
1703 | - $logo= $data['invoiceconf']['logo']; |
|
1702 | + if(!empty($data['invoiceconf']) && $data['invoiceconf'] != ''){ |
|
1703 | + $logo= $data['invoiceconf']['logo']; |
|
1704 | 1704 | |
1705 | - $dir_path= base_url()."upload/"; |
|
1706 | - // echo $dir_path; exit; |
|
1707 | - $path =$dir_path.$data['invoiceconf']['accountid']."_".$data['invoiceconf']['logo']; |
|
1705 | + $dir_path= base_url()."upload/"; |
|
1706 | + // echo $dir_path; exit; |
|
1707 | + $path =$dir_path.$data['invoiceconf']['accountid']."_".$data['invoiceconf']['logo']; |
|
1708 | 1708 | if(file_exists($path)){ |
1709 | 1709 | if($logo != ''){ |
1710 | 1710 | $src=$path; |
@@ -1719,151 +1719,151 @@ discard block |
||
1719 | 1719 | $src=$dir_path; |
1720 | 1720 | $logo = "<img style='height:50px; width:180px; margin-left:70px;' alt='logo' src='".$src."'>"; |
1721 | 1721 | } |
1722 | - } |
|
1722 | + } |
|
1723 | 1723 | $content = str_replace("<CURRENCY>",$currency,$content); |
1724 | 1724 | $content = str_replace("<LOGO>",$src,$content); |
1725 | 1725 | $content = str_replace("<MONTHLY_DESC>",$MONTHLY_DESC,$content); |
1726 | - $content = str_replace("<COMPANY_ADD>",$customer_address,$content); |
|
1727 | - $content = str_replace("<RECEIPT_DETAILS_TABLE>",rtrim($RECEIPT_DETAILS_TABLE,""),$content); |
|
1728 | - $content = str_replace("<COMPANY_DETAILS_TABLE>",$COMPANY_DETAILS_TABLE,$content); |
|
1729 | - $content = str_replace("<COMPANY_DETAILS_SET>",$COMPANY_DETAILS_SET,$content); |
|
1730 | - $content = str_replace("<CALL_DETAILS_TABLE>",$CALL_DETAILS_TABLE,$content); |
|
1726 | + $content = str_replace("<COMPANY_ADD>",$customer_address,$content); |
|
1727 | + $content = str_replace("<RECEIPT_DETAILS_TABLE>",rtrim($RECEIPT_DETAILS_TABLE,""),$content); |
|
1728 | + $content = str_replace("<COMPANY_DETAILS_TABLE>",$COMPANY_DETAILS_TABLE,$content); |
|
1729 | + $content = str_replace("<COMPANY_DETAILS_SET>",$COMPANY_DETAILS_SET,$content); |
|
1730 | + $content = str_replace("<CALL_DETAILS_TABLE>",$CALL_DETAILS_TABLE,$content); |
|
1731 | 1731 | |
1732 | 1732 | |
1733 | - // echo $content ; exit; |
|
1734 | - $invoice_path=$this->config->item('invoices_path'); |
|
1735 | - $download_path = $invoicedata['invoice_prefix'].$data['id'].".pdf"; |
|
1736 | - $this->html2pdf->pdf->SetDisplayMode('fullpage'); |
|
1737 | - $this->html2pdf->writeHTML($content); |
|
1733 | + // echo $content ; exit; |
|
1734 | + $invoice_path=$this->config->item('invoices_path'); |
|
1735 | + $download_path = $invoicedata['invoice_prefix'].$data['id'].".pdf"; |
|
1736 | + $this->html2pdf->pdf->SetDisplayMode('fullpage'); |
|
1737 | + $this->html2pdf->writeHTML($content); |
|
1738 | 1738 | |
1739 | - $this->html2pdf->Output($download_path,"D"); |
|
1739 | + $this->html2pdf->Output($download_path,"D"); |
|
1740 | 1740 | |
1741 | 1741 | |
1742 | - } |
|
1742 | + } |
|
1743 | 1743 | |
1744 | - function calculate_currency($amount,$accountdata){ |
|
1745 | - $base_currency=Common_model::$global_config['system_config']['base_currency']; |
|
1746 | - $from_currency=Common_model::$global_config['currency_list'][$base_currency]; |
|
1747 | - $to_currency = $this->db_model->getSelect("currencyrate", "currency", array("currency"=> $accountdata["currency_id"])); |
|
1748 | - if($to_currency->num_rows() > 0){ |
|
1749 | - $to_currency_arr = $to_currency->result_array(); |
|
1750 | - $to_currency = $to_currency_arr[0]["currencyrate"]; |
|
1751 | - } |
|
1752 | - else{ |
|
1753 | - $to_currency= $from_currency; |
|
1754 | - } |
|
1744 | + function calculate_currency($amount,$accountdata){ |
|
1745 | + $base_currency=Common_model::$global_config['system_config']['base_currency']; |
|
1746 | + $from_currency=Common_model::$global_config['currency_list'][$base_currency]; |
|
1747 | + $to_currency = $this->db_model->getSelect("currencyrate", "currency", array("currency"=> $accountdata["currency_id"])); |
|
1748 | + if($to_currency->num_rows() > 0){ |
|
1749 | + $to_currency_arr = $to_currency->result_array(); |
|
1750 | + $to_currency = $to_currency_arr[0]["currencyrate"]; |
|
1751 | + } |
|
1752 | + else{ |
|
1753 | + $to_currency= $from_currency; |
|
1754 | + } |
|
1755 | 1755 | |
1756 | - $cal_amount = ($amount * $to_currency) / $from_currency; |
|
1757 | - return $cal_amount; |
|
1758 | - } |
|
1756 | + $cal_amount = ($amount * $to_currency) / $from_currency; |
|
1757 | + return $cal_amount; |
|
1758 | + } |
|
1759 | 1759 | |
1760 | - function format_currency($amount) { |
|
1760 | + function format_currency($amount) { |
|
1761 | 1761 | $dp = $this->db_model->getSelect("value", "system", array("name"=> "decimalpoints")); |
1762 | - $dp = $dp->result_array(); |
|
1763 | - $dp = $dp[0]["value"]; |
|
1762 | + $dp = $dp->result_array(); |
|
1763 | + $dp = $dp[0]["value"]; |
|
1764 | 1764 | |
1765 | - return money_format('%.' . $dp . 'n', $amount); |
|
1766 | - } |
|
1765 | + return money_format('%.' . $dp . 'n', $amount); |
|
1766 | + } |
|
1767 | 1767 | |
1768 | - function date_diff_custom($end='2020-06-09 10:30:00', $out_in_array=false){ |
|
1769 | - $intervalo = date_diff(date_create(), date_create($end)); |
|
1770 | - $out = $intervalo->format("Years:%Y,Months:%M,Days:%d,Hours:%H,Minutes:%i,Seconds:%s"); |
|
1771 | - if(!$out_in_array) |
|
1772 | - return $out; |
|
1773 | - $a_out = array(); |
|
1774 | - array_walk(explode(',',$out), |
|
1775 | - function($val,$key) use(&$a_out){ |
|
1776 | - $v=explode(':',$val); |
|
1777 | - $a_out[$v[0]] = $v[1]; |
|
1778 | - }); |
|
1779 | - return $a_out; |
|
1780 | - } |
|
1781 | - function invoice_list_search() { |
|
1782 | - $ajax_search = $this->input->post('ajax_search', 0); |
|
1768 | + function date_diff_custom($end='2020-06-09 10:30:00', $out_in_array=false){ |
|
1769 | + $intervalo = date_diff(date_create(), date_create($end)); |
|
1770 | + $out = $intervalo->format("Years:%Y,Months:%M,Days:%d,Hours:%H,Minutes:%i,Seconds:%s"); |
|
1771 | + if(!$out_in_array) |
|
1772 | + return $out; |
|
1773 | + $a_out = array(); |
|
1774 | + array_walk(explode(',',$out), |
|
1775 | + function($val,$key) use(&$a_out){ |
|
1776 | + $v=explode(':',$val); |
|
1777 | + $a_out[$v[0]] = $v[1]; |
|
1778 | + }); |
|
1779 | + return $a_out; |
|
1780 | + } |
|
1781 | + function invoice_list_search() { |
|
1782 | + $ajax_search = $this->input->post('ajax_search', 0); |
|
1783 | 1783 | |
1784 | - if ($this->input->post('advance_search', TRUE) == 1) { |
|
1785 | - $this->session->set_userdata('advance_search', $this->input->post('advance_search')); |
|
1786 | - $action = $this->input->post(); |
|
1784 | + if ($this->input->post('advance_search', TRUE) == 1) { |
|
1785 | + $this->session->set_userdata('advance_search', $this->input->post('advance_search')); |
|
1786 | + $action = $this->input->post(); |
|
1787 | 1787 | |
1788 | 1788 | echo '<pre>'; |
1789 | 1789 | print_r($action); |
1790 | - unset($action['action']); |
|
1791 | - unset($action['advance_search']); |
|
1792 | - $action['from_date'][0]=$action['from_date'][0] ? $action['from_date'][0]." 00:00:00" :''; |
|
1793 | - $action['invoice_date'][0]=$action['invoice_date'][0] ? $action['invoice_date'][0]." 00:00:00" : ''; |
|
1794 | - $this->session->set_userdata('invoice_list_search', $action); |
|
1795 | - } |
|
1796 | - if (@$ajax_search != 1) { |
|
1797 | - redirect(base_url() . 'invoices/invoice_list/'); |
|
1798 | - } |
|
1799 | - } |
|
1790 | + unset($action['action']); |
|
1791 | + unset($action['advance_search']); |
|
1792 | + $action['from_date'][0]=$action['from_date'][0] ? $action['from_date'][0]." 00:00:00" :''; |
|
1793 | + $action['invoice_date'][0]=$action['invoice_date'][0] ? $action['invoice_date'][0]." 00:00:00" : ''; |
|
1794 | + $this->session->set_userdata('invoice_list_search', $action); |
|
1795 | + } |
|
1796 | + if (@$ajax_search != 1) { |
|
1797 | + redirect(base_url() . 'invoices/invoice_list/'); |
|
1798 | + } |
|
1799 | + } |
|
1800 | 1800 | function invoice_list_clearsearchfilter() { |
1801 | - $this->session->set_userdata('advance_search', 0); |
|
1802 | - $this->session->set_userdata('invoice_list_search', ""); |
|
1803 | - } |
|
1804 | - /**============ From below code developed for ASTPP version 2.0 ======================================**/ |
|
1805 | - function generate_receipt($accountid,$amount,$accountinfo,$last_invoice_ID,$invoice_prefix,$due_date){ |
|
1806 | - $invoice_data = array("accountid"=>$accountid,"invoice_prefix" =>$invoice_prefix,"invoiceid"=>'0000'.$last_invoice_ID,"reseller_id"=>$accountinfo['reseller_id'],"invoice_date"=>gmdate("Y-m-d H:i:s"),"from_date"=> gmdate("Y-m-d H:i:s"),"to_date"=>gmdate("Y-m-d H:i:s"),"due_date"=>$due_date,"status"=>1,"balance"=>$accountinfo['balance'],"amount"=>$amount,"type"=>'R',"confirm"=>'1'); |
|
1807 | - $this->db->insert("invoices",$invoice_data); |
|
1808 | - $invoiceid = $this->db->insert_id(); |
|
1809 | - return $invoiceid; |
|
1810 | - } |
|
1811 | - function insert_invoice_total_data($invoiceid,$sub_total,$sort_order){ |
|
1812 | - $invoice_total_arr = array("invoiceid"=>$invoiceid,"sort_order"=>$sort_order, |
|
1813 | - "value"=>$sub_total, "title"=>"Sub Total","text"=>"Sub Total","class"=>"1"); |
|
1814 | - $this->db->insert("invoices_total",$invoice_total_arr); |
|
1815 | - return $sort_order++; |
|
1816 | - } |
|
1801 | + $this->session->set_userdata('advance_search', 0); |
|
1802 | + $this->session->set_userdata('invoice_list_search', ""); |
|
1803 | + } |
|
1804 | + /**============ From below code developed for ASTPP version 2.0 ======================================**/ |
|
1805 | + function generate_receipt($accountid,$amount,$accountinfo,$last_invoice_ID,$invoice_prefix,$due_date){ |
|
1806 | + $invoice_data = array("accountid"=>$accountid,"invoice_prefix" =>$invoice_prefix,"invoiceid"=>'0000'.$last_invoice_ID,"reseller_id"=>$accountinfo['reseller_id'],"invoice_date"=>gmdate("Y-m-d H:i:s"),"from_date"=> gmdate("Y-m-d H:i:s"),"to_date"=>gmdate("Y-m-d H:i:s"),"due_date"=>$due_date,"status"=>1,"balance"=>$accountinfo['balance'],"amount"=>$amount,"type"=>'R',"confirm"=>'1'); |
|
1807 | + $this->db->insert("invoices",$invoice_data); |
|
1808 | + $invoiceid = $this->db->insert_id(); |
|
1809 | + return $invoiceid; |
|
1810 | + } |
|
1811 | + function insert_invoice_total_data($invoiceid,$sub_total,$sort_order){ |
|
1812 | + $invoice_total_arr = array("invoiceid"=>$invoiceid,"sort_order"=>$sort_order, |
|
1813 | + "value"=>$sub_total, "title"=>"Sub Total","text"=>"Sub Total","class"=>"1"); |
|
1814 | + $this->db->insert("invoices_total",$invoice_total_arr); |
|
1815 | + return $sort_order++; |
|
1816 | + } |
|
1817 | 1817 | |
1818 | - function apply_invoice_taxes($invoiceid,$accountid,$sort_order){ |
|
1819 | - $tax_priority=""; |
|
1820 | - $where = array("accountid"=>$accountid); |
|
1821 | - $accounttax_query = $this->db_model->getSelectWithOrder("*", "taxes_to_accounts", $where,"ASC","taxes_priority"); |
|
1822 | - if($accounttax_query->num_rows > 0){ |
|
1823 | - $accounttax_query = $accounttax_query->result_array(); |
|
1824 | - foreach($accounttax_query as $tax_key => $tax_value){ |
|
1825 | - $taxes_info=$this->db->get_where('taxes',array('id'=>$tax_value['taxes_id'])); |
|
1826 | - if($taxes_info->num_rows() > 0 ){ |
|
1827 | - $tax_value=$taxes_info->result_array(); |
|
1828 | - $tax_value=$tax_value[0]; |
|
1829 | - if($tax_value["taxes_priority"] == ""){ |
|
1830 | - $tax_priority = $tax_value["taxes_priority"]; |
|
1831 | - }else if($tax_value["taxes_priority"] > $tax_priority){ |
|
1832 | - $query = $this->db_model->getSelect("SUM(value) as total", "invoices_total", array("invoiceid"=> $invoiceid)); |
|
1833 | - $query = $query->result_array(); |
|
1834 | - $sub_total = $query["0"]["total"]; |
|
1835 | - } |
|
1836 | - $tax_total = (($sub_total * ( $tax_value['taxes_rate'] / 100 )) + $tax_value['taxes_amount'] ); |
|
1837 | - $tax_array = array("invoiceid"=>$invoiceid,"title"=>"TAX","text"=>$tax_value['taxes_description'], |
|
1838 | - "value"=>$tax_total,"class"=>"2","sort_order"=>$sort_order); |
|
1839 | - $this->db->insert("invoices_total",$tax_array); |
|
1840 | - $sort_order++; |
|
1841 | - } |
|
1842 | - } |
|
1843 | - } |
|
1844 | - return $sort_order; |
|
1845 | - } |
|
1846 | - function set_invoice_total($invoiceid,$sort_order){ |
|
1847 | - $query = $this->db_model->getSelect("SUM(value) as total", "invoices_total", array("invoiceid"=> $invoiceid)); |
|
1848 | - $query = $query->result_array(); |
|
1849 | - $sub_total = $query["0"]["total"]; |
|
1818 | + function apply_invoice_taxes($invoiceid,$accountid,$sort_order){ |
|
1819 | + $tax_priority=""; |
|
1820 | + $where = array("accountid"=>$accountid); |
|
1821 | + $accounttax_query = $this->db_model->getSelectWithOrder("*", "taxes_to_accounts", $where,"ASC","taxes_priority"); |
|
1822 | + if($accounttax_query->num_rows > 0){ |
|
1823 | + $accounttax_query = $accounttax_query->result_array(); |
|
1824 | + foreach($accounttax_query as $tax_key => $tax_value){ |
|
1825 | + $taxes_info=$this->db->get_where('taxes',array('id'=>$tax_value['taxes_id'])); |
|
1826 | + if($taxes_info->num_rows() > 0 ){ |
|
1827 | + $tax_value=$taxes_info->result_array(); |
|
1828 | + $tax_value=$tax_value[0]; |
|
1829 | + if($tax_value["taxes_priority"] == ""){ |
|
1830 | + $tax_priority = $tax_value["taxes_priority"]; |
|
1831 | + }else if($tax_value["taxes_priority"] > $tax_priority){ |
|
1832 | + $query = $this->db_model->getSelect("SUM(value) as total", "invoices_total", array("invoiceid"=> $invoiceid)); |
|
1833 | + $query = $query->result_array(); |
|
1834 | + $sub_total = $query["0"]["total"]; |
|
1835 | + } |
|
1836 | + $tax_total = (($sub_total * ( $tax_value['taxes_rate'] / 100 )) + $tax_value['taxes_amount'] ); |
|
1837 | + $tax_array = array("invoiceid"=>$invoiceid,"title"=>"TAX","text"=>$tax_value['taxes_description'], |
|
1838 | + "value"=>$tax_total,"class"=>"2","sort_order"=>$sort_order); |
|
1839 | + $this->db->insert("invoices_total",$tax_array); |
|
1840 | + $sort_order++; |
|
1841 | + } |
|
1842 | + } |
|
1843 | + } |
|
1844 | + return $sort_order; |
|
1845 | + } |
|
1846 | + function set_invoice_total($invoiceid,$sort_order){ |
|
1847 | + $query = $this->db_model->getSelect("SUM(value) as total", "invoices_total", array("invoiceid"=> $invoiceid)); |
|
1848 | + $query = $query->result_array(); |
|
1849 | + $sub_total = $query["0"]["total"]; |
|
1850 | 1850 | |
1851 | - $invoice_total_arr = array("invoiceid"=>$invoiceid,"sort_order"=>$sort_order, |
|
1852 | - "value"=>$sub_total,"title"=>"Total","text"=>"Total","class"=>"9"); |
|
1853 | - $this->db->insert("invoices_total",$invoice_total_arr); |
|
1854 | - return true; |
|
1855 | - } |
|
1856 | - function invoice_delete_statically($inv_id){ |
|
1851 | + $invoice_total_arr = array("invoiceid"=>$invoiceid,"sort_order"=>$sort_order, |
|
1852 | + "value"=>$sub_total,"title"=>"Total","text"=>"Total","class"=>"9"); |
|
1853 | + $this->db->insert("invoices_total",$invoice_total_arr); |
|
1854 | + return true; |
|
1855 | + } |
|
1856 | + function invoice_delete_statically($inv_id){ |
|
1857 | 1857 | $data=array('deleted'=>1); |
1858 | - $this->db->where('id',$inv_id); |
|
1859 | - $this->db->update("invoices",$data); |
|
1858 | + $this->db->where('id',$inv_id); |
|
1859 | + $this->db->update("invoices",$data); |
|
1860 | 1860 | $this->session->set_flashdata('astpp_notification', 'Invoices removed successfully'); |
1861 | 1861 | redirect(base_url() . 'invoices/invoice_list/'); |
1862 | - } |
|
1863 | - function invoice_delete_massege(){ |
|
1862 | + } |
|
1863 | + function invoice_delete_massege(){ |
|
1864 | 1864 | $this->session->set_flashdata('astpp_notification', 'Invoices removed successfully'); |
1865 | 1865 | redirect(base_url() . 'invoices/invoice_list/'); |
1866 | - } |
|
1866 | + } |
|
1867 | 1867 | } |
1868 | 1868 | |
1869 | 1869 | ?> |
@@ -23,179 +23,179 @@ |
||
23 | 23 | |
24 | 24 | if ( ! defined('BASEPATH')) exit('No direct script access allowed'); |
25 | 25 | class invoices_form{ |
26 | - function __construct($library_name = '') { |
|
27 | - $this->CI = & get_instance(); |
|
28 | - } |
|
29 | - function build_invoices_list_for_admin(){ |
|
30 | - $account_info = $accountinfo = $this->CI->session->userdata('accountinfo'); |
|
31 | - $currency_id=$account_info['currency_id']; |
|
32 | - $currency=$this->CI->common->get_field_name('currency', 'currency', $currency_id); |
|
26 | + function __construct($library_name = '') { |
|
27 | + $this->CI = & get_instance(); |
|
28 | + } |
|
29 | + function build_invoices_list_for_admin(){ |
|
30 | + $account_info = $accountinfo = $this->CI->session->userdata('accountinfo'); |
|
31 | + $currency_id=$account_info['currency_id']; |
|
32 | + $currency=$this->CI->common->get_field_name('currency', 'currency', $currency_id); |
|
33 | 33 | |
34 | - $logintype = $this->CI->session->userdata('logintype'); |
|
35 | - $url= ($logintype==0 ||$logintype==3 ) ? "/user/user_invoice_download/":'/invoices/invoice_main_download/'; |
|
36 | - $grid_field_arr = json_encode(array( |
|
37 | - array("Number","110","id","id,'',type","invoices","build_concat_string","","true","center"), |
|
38 | - array("Type","130","id","id,'',type","invoices","build_concat_string","","true","center"), |
|
39 | - array("Account","130","accountid","first_name,last_name,number","accounts","build_concat_string","","true","center"), |
|
40 | - array("Generated<br/> Date","140","invoice_date","invoice_date","","get_invoice_date","","true","center"), |
|
34 | + $logintype = $this->CI->session->userdata('logintype'); |
|
35 | + $url= ($logintype==0 ||$logintype==3 ) ? "/user/user_invoice_download/":'/invoices/invoice_main_download/'; |
|
36 | + $grid_field_arr = json_encode(array( |
|
37 | + array("Number","110","id","id,'',type","invoices","build_concat_string","","true","center"), |
|
38 | + array("Type","130","id","id,'',type","invoices","build_concat_string","","true","center"), |
|
39 | + array("Account","130","accountid","first_name,last_name,number","accounts","build_concat_string","","true","center"), |
|
40 | + array("Generated<br/> Date","140","invoice_date","invoice_date","","get_invoice_date","","true","center"), |
|
41 | 41 | array("From Date","120","from_date","from_date","","get_from_date","","true","center"), |
42 | 42 | array("Due Date","130","","","","","","true","center"), |
43 | 43 | array("Last <br/>Pay Date","100","","","","","","true","center"), |
44 | - array("Amount($currency)","120","id","id","id","get_invoice_total","","true","right"), |
|
44 | + array("Amount($currency)","120","id","id","id","get_invoice_total","","true","right"), |
|
45 | 45 | |
46 | - array("Outstanding <br/>Amount($currency)","140","","","","","","true","right"), |
|
46 | + array("Outstanding <br/>Amount($currency)","140","","","","","","true","right"), |
|
47 | 47 | // array("Payment", "110", "payment", "", "", ""), |
48 | - array("Action","120","","","",array( |
|
49 | - "DOWNLOAD"=>array("url"=>$url,"mode"=>"single"), |
|
50 | - // "VIEW" => array("url" => "invoices/invoice_summary_payment/", "mode" => "popup") |
|
48 | + array("Action","120","","","",array( |
|
49 | + "DOWNLOAD"=>array("url"=>$url,"mode"=>"single"), |
|
50 | + // "VIEW" => array("url" => "invoices/invoice_summary_payment/", "mode" => "popup") |
|
51 | 51 | )) |
52 | - )); |
|
53 | - return $grid_field_arr; |
|
54 | - } |
|
55 | - function build_invoices_list_for_customer_admin(){ |
|
56 | - $account_info = $accountinfo = $this->CI->session->userdata('accountinfo'); |
|
57 | - $currency_id=$account_info['currency_id']; |
|
58 | - $currency=$this->CI->common->get_field_name('currency', 'currency', $currency_id); |
|
52 | + )); |
|
53 | + return $grid_field_arr; |
|
54 | + } |
|
55 | + function build_invoices_list_for_customer_admin(){ |
|
56 | + $account_info = $accountinfo = $this->CI->session->userdata('accountinfo'); |
|
57 | + $currency_id=$account_info['currency_id']; |
|
58 | + $currency=$this->CI->common->get_field_name('currency', 'currency', $currency_id); |
|
59 | 59 | |
60 | - $logintype = $this->CI->session->userdata('logintype'); |
|
61 | - $url= ($logintype==0 ||$logintype==3 ) ? "/user/user_invoice_download/":'/invoices/invoice_main_download/'; |
|
62 | - $grid_field_arr = json_encode(array( |
|
63 | - array("Number","110","id","id,'',type","invoices","build_concat_string","","true","center"), |
|
64 | - array("Type","110","id","id,'',type","invoices","build_concat_string","","true","center"), |
|
65 | - array("Generated<br/> Date","120","invoice_date","invoice_date","","get_invoice_date","","true","center"), |
|
60 | + $logintype = $this->CI->session->userdata('logintype'); |
|
61 | + $url= ($logintype==0 ||$logintype==3 ) ? "/user/user_invoice_download/":'/invoices/invoice_main_download/'; |
|
62 | + $grid_field_arr = json_encode(array( |
|
63 | + array("Number","110","id","id,'',type","invoices","build_concat_string","","true","center"), |
|
64 | + array("Type","110","id","id,'',type","invoices","build_concat_string","","true","center"), |
|
65 | + array("Generated<br/> Date","120","invoice_date","invoice_date","","get_invoice_date","","true","center"), |
|
66 | 66 | array("From Date","120","from_date","from_date","","get_from_date","","true","center"), |
67 | 67 | array("Due Date","130","","","","","","true","center"), |
68 | 68 | array("Last <br/>Pay Date","100","","","","","","true","center"), |
69 | - array("Amount($currency)","100","id","id","id","get_invoice_total","","true","right"), |
|
69 | + array("Amount($currency)","100","id","id","id","get_invoice_total","","true","right"), |
|
70 | 70 | |
71 | - array("Outstanding <br/>Amount($currency)","100","","","","","","true","right"), |
|
72 | - array("Action","120","","","",array( |
|
73 | - "DOWNLOAD"=>array("url"=>$url,"mode"=>"single"), |
|
71 | + array("Outstanding <br/>Amount($currency)","100","","","","","","true","right"), |
|
72 | + array("Action","120","","","",array( |
|
73 | + "DOWNLOAD"=>array("url"=>$url,"mode"=>"single"), |
|
74 | 74 | )) |
75 | - )); |
|
76 | - return $grid_field_arr; |
|
77 | - } |
|
78 | - function build_invoices_list_for_customer(){ |
|
79 | - $url=($this->CI->session->userdata('logintype')==0 )?"/user/user_invoice_download/":'/invoices/invoice_main_download/'; |
|
80 | - // array(display name, width, db_field_parent_table,feidname, db_field_child_table,function name); |
|
81 | - $grid_field_arr = json_encode(array( |
|
82 | - array("Number","100","id","id,'',type","invoices","build_concat_string","","true","center"), |
|
83 | - array("Account","110","accountid","first_name,last_name,number","accounts","build_concat_string","","true","center"), |
|
84 | - array("Generated Date","140","invoice_date","invoice_date","","get_invoice_date","","true","center"), |
|
75 | + )); |
|
76 | + return $grid_field_arr; |
|
77 | + } |
|
78 | + function build_invoices_list_for_customer(){ |
|
79 | + $url=($this->CI->session->userdata('logintype')==0 )?"/user/user_invoice_download/":'/invoices/invoice_main_download/'; |
|
80 | + // array(display name, width, db_field_parent_table,feidname, db_field_child_table,function name); |
|
81 | + $grid_field_arr = json_encode(array( |
|
82 | + array("Number","100","id","id,'',type","invoices","build_concat_string","","true","center"), |
|
83 | + array("Account","110","accountid","first_name,last_name,number","accounts","build_concat_string","","true","center"), |
|
84 | + array("Generated Date","140","invoice_date","invoice_date","","get_invoice_date","","true","center"), |
|
85 | 85 | array("From Date","140","from_date","from_date","","get_from_date","","true","center"), |
86 | 86 | array("Due Date","150","","","","","","true","center"), |
87 | 87 | array("Last Pay Date","150","","","","","","true","center"), |
88 | - array("Amount","150","id","id","id","get_invoice_total","","true","center"), |
|
88 | + array("Amount","150","id","id","id","get_invoice_total","","true","center"), |
|
89 | 89 | array("Outstanding Amount","150","","","",""), |
90 | 90 | // array("Payment", "110", "payment", "", "", ""), |
91 | - array("Action","160","","","",array( |
|
92 | - "DOWNLOAD"=>array("url"=>$url,"mode"=>"single"), |
|
93 | - // "VIEW" => array("url" => "invoices/invoice_summary_payment/", "mode" => "popup") |
|
91 | + array("Action","160","","","",array( |
|
92 | + "DOWNLOAD"=>array("url"=>$url,"mode"=>"single"), |
|
93 | + // "VIEW" => array("url" => "invoices/invoice_summary_payment/", "mode" => "popup") |
|
94 | 94 | )) |
95 | 95 | )); |
96 | - return $grid_field_arr; |
|
97 | - } |
|
96 | + return $grid_field_arr; |
|
97 | + } |
|
98 | 98 | function get_invoice_search_form() |
99 | - { |
|
99 | + { |
|
100 | 100 | $account_data = $this->CI->session->userdata("accountinfo"); |
101 | - $reseller_id=$account_data['type']==1 ? $account_data['id']:0; |
|
102 | - $form['forms'] = array("",array('id'=>"invoice_search")); |
|
103 | - $form['Search'] = array( |
|
104 | - array('Number', 'INPUT', array('name' => 'invoiceid[invoiceid]','','size' => '20', 'class' => "text field"), '', 'tOOL TIP', '1', 'id[invoiceid-string]', '', '','', 'search_string_type', ''), |
|
105 | - array('From Date', 'INPUT', array('name' => 'from_date[0]','id'=>'invoice_from_date','size' => '20', 'class' => "text field"), '', 'tOOL TIP', '', 'from_date[from_date-date]'), |
|
106 | - array('To Date', 'INPUT', array('name' => 'to_date[0]','id'=>'invoice_to_date','size' => '20', 'class' => "text field"), '', 'tOOL TIP', '', 'from_date[from_date-date]'), |
|
101 | + $reseller_id=$account_data['type']==1 ? $account_data['id']:0; |
|
102 | + $form['forms'] = array("",array('id'=>"invoice_search")); |
|
103 | + $form['Search'] = array( |
|
104 | + array('Number', 'INPUT', array('name' => 'invoiceid[invoiceid]','','size' => '20', 'class' => "text field"), '', 'tOOL TIP', '1', 'id[invoiceid-string]', '', '','', 'search_string_type', ''), |
|
105 | + array('From Date', 'INPUT', array('name' => 'from_date[0]','id'=>'invoice_from_date','size' => '20', 'class' => "text field"), '', 'tOOL TIP', '', 'from_date[from_date-date]'), |
|
106 | + array('To Date', 'INPUT', array('name' => 'to_date[0]','id'=>'invoice_to_date','size' => '20', 'class' => "text field"), '', 'tOOL TIP', '', 'from_date[from_date-date]'), |
|
107 | 107 | |
108 | - array('Amount', 'INPUT', array('name' => 'amount[amount]', 'value' => '', 'size' => '20', 'class' => "text field "), '', 'Tool tips info', '1', 'amount[amount-string]', '', '', '', 'search_string_type', ''), |
|
109 | - array('Generated Date', 'INPUT', array('name' => 'invoice_date[0]','','size' => '20', 'class' => "text field",'id'=>'invoice_date'), '', 'tOOL TIP', '', 'invoice_date[invoice_date-date]'), |
|
110 | - array('Invoice', 'deleted', 'SELECT', '', '', 'tOOL TIP', 'Please Enter account number', '', '', '', 'set_invoice_details'), |
|
111 | - array('Account', 'accountid', 'SELECT', '', '', 'tOOL TIP', 'Please Enter account number', 'id', 'IF(`deleted`=1,concat( first_name, " ", last_name, " ", "(", number, ")^" ),concat( first_name, " ", last_name, " ", "(", number, ")" )) as number', 'accounts', 'build_dropdown_deleted', 'where_arr', array("reseller_id" => $reseller_id,"type"=>"GLOBAL")), |
|
112 | - array('', 'HIDDEN', 'ajax_search','1', '', '', ''), |
|
113 | - array('', 'HIDDEN', 'advance_search','1', '', '', '')); |
|
108 | + array('Amount', 'INPUT', array('name' => 'amount[amount]', 'value' => '', 'size' => '20', 'class' => "text field "), '', 'Tool tips info', '1', 'amount[amount-string]', '', '', '', 'search_string_type', ''), |
|
109 | + array('Generated Date', 'INPUT', array('name' => 'invoice_date[0]','','size' => '20', 'class' => "text field",'id'=>'invoice_date'), '', 'tOOL TIP', '', 'invoice_date[invoice_date-date]'), |
|
110 | + array('Invoice', 'deleted', 'SELECT', '', '', 'tOOL TIP', 'Please Enter account number', '', '', '', 'set_invoice_details'), |
|
111 | + array('Account', 'accountid', 'SELECT', '', '', 'tOOL TIP', 'Please Enter account number', 'id', 'IF(`deleted`=1,concat( first_name, " ", last_name, " ", "(", number, ")^" ),concat( first_name, " ", last_name, " ", "(", number, ")" )) as number', 'accounts', 'build_dropdown_deleted', 'where_arr', array("reseller_id" => $reseller_id,"type"=>"GLOBAL")), |
|
112 | + array('', 'HIDDEN', 'ajax_search','1', '', '', ''), |
|
113 | + array('', 'HIDDEN', 'advance_search','1', '', '', '')); |
|
114 | 114 | |
115 | - $form['button_search'] = array('name' => 'action', 'id'=>"invoice_search_btn",'content' => 'Search', 'value' => 'save', 'type' => 'button', 'class' => 'btn btn-line-parrot pull-right'); |
|
116 | - $form['button_reset'] = array('name' => 'action','id'=>"id_reset", 'content' => 'Clear', 'value' => 'cancel', 'type' => 'reset', 'class' => 'btn btn-line-sky pull-right margin-x-10'); |
|
115 | + $form['button_search'] = array('name' => 'action', 'id'=>"invoice_search_btn",'content' => 'Search', 'value' => 'save', 'type' => 'button', 'class' => 'btn btn-line-parrot pull-right'); |
|
116 | + $form['button_reset'] = array('name' => 'action','id'=>"id_reset", 'content' => 'Clear', 'value' => 'cancel', 'type' => 'reset', 'class' => 'btn btn-line-sky pull-right margin-x-10'); |
|
117 | 117 | |
118 | - return $form; |
|
119 | - } |
|
118 | + return $form; |
|
119 | + } |
|
120 | 120 | |
121 | - function build_grid_buttons(){ |
|
121 | + function build_grid_buttons(){ |
|
122 | 122 | $buttons_json = json_encode(array( |
123 | - )); |
|
123 | + )); |
|
124 | 124 | return $buttons_json; |
125 | - } |
|
126 | - function get_invoiceconf_form_fields($invoiceconf = '0'){ |
|
127 | - if(!empty($invoiceconf)){ |
|
125 | + } |
|
126 | + function get_invoiceconf_form_fields($invoiceconf = '0'){ |
|
127 | + if(!empty($invoiceconf)){ |
|
128 | 128 | if($invoiceconf['logo'] != ''){ |
129 | - $logo=$invoiceconf['file']; |
|
129 | + $logo=$invoiceconf['file']; |
|
130 | 130 | }else{ |
131 | - $logo=$invoiceconf['logo']; |
|
131 | + $logo=$invoiceconf['logo']; |
|
132 | 132 | } |
133 | - $accountid=$invoiceconf['accountid']; |
|
134 | - if($logo != ''){ |
|
135 | - $file_name= base_url()."upload/$logo"; |
|
136 | - $image_path= array('Existing Image', 'IMAGE', array('type'=>'image','name' => 'image' ,'style'=>'width:100%;margin-top:20px;','src'=> $file_name), '', 'tOOL TIP', ''); |
|
137 | - $delete_logo=array('Delete logo', 'DEL_BUTTON', array('value'=>'ankit','style'=>'margin-top:20px;','name' => 'button','id'=>'logo_delete','size' => '20', 'class' => "btn btn-line-parrot"), '', 'tOOL TIP', 'Please Enter account number'); |
|
138 | - }else{ |
|
139 | - $image_path= array('Existing Image', 'HIDDEN', array('type'=>'','name' => '' ,'style'=>'width:250px;'), '', 'tOOL TIP', ''); |
|
140 | - $delete_logo= array('Delete logo', 'HIDDEN', array('value'=>'ankit','style'=>'margin-top:0px;','name' => 'button','id'=>'logo_delete','size' => '20', 'maxlength' => '100', 'class' => "btn btn-line-parrot"), '', 'tOOL TIP', 'Please Enter account number'); |
|
141 | - // $image_path=array(); |
|
142 | - } |
|
133 | + $accountid=$invoiceconf['accountid']; |
|
134 | + if($logo != ''){ |
|
135 | + $file_name= base_url()."upload/$logo"; |
|
136 | + $image_path= array('Existing Image', 'IMAGE', array('type'=>'image','name' => 'image' ,'style'=>'width:100%;margin-top:20px;','src'=> $file_name), '', 'tOOL TIP', ''); |
|
137 | + $delete_logo=array('Delete logo', 'DEL_BUTTON', array('value'=>'ankit','style'=>'margin-top:20px;','name' => 'button','id'=>'logo_delete','size' => '20', 'class' => "btn btn-line-parrot"), '', 'tOOL TIP', 'Please Enter account number'); |
|
138 | + }else{ |
|
139 | + $image_path= array('Existing Image', 'HIDDEN', array('type'=>'','name' => '' ,'style'=>'width:250px;'), '', 'tOOL TIP', ''); |
|
140 | + $delete_logo= array('Delete logo', 'HIDDEN', array('value'=>'ankit','style'=>'margin-top:0px;','name' => 'button','id'=>'logo_delete','size' => '20', 'maxlength' => '100', 'class' => "btn btn-line-parrot"), '', 'tOOL TIP', 'Please Enter account number'); |
|
141 | + // $image_path=array(); |
|
142 | + } |
|
143 | 143 | |
144 | - }else{ |
|
145 | - $logo = ''; |
|
146 | - $file_name = ''; |
|
147 | - $accountid=0; |
|
148 | - $image_path= array('Existing Image', 'HIDDEN', array('type'=>'','name' => '' ), '', 'tOOL TIP', ''); |
|
149 | - $delete_logo= array('Delete logo', 'HIDDEN', array('value'=>'','style'=>'margin-top:0px;','name' => 'button','onclick'=>'return image_delete('.$accountid.')','size' => '20', 'maxlength' => '100', 'class' => "btn btn-line-parrot"), '', 'tOOL TIP', 'Please Enter account number'); |
|
150 | - //$image_path=array(); |
|
144 | + }else{ |
|
145 | + $logo = ''; |
|
146 | + $file_name = ''; |
|
147 | + $accountid=0; |
|
148 | + $image_path= array('Existing Image', 'HIDDEN', array('type'=>'','name' => '' ), '', 'tOOL TIP', ''); |
|
149 | + $delete_logo= array('Delete logo', 'HIDDEN', array('value'=>'','style'=>'margin-top:0px;','name' => 'button','onclick'=>'return image_delete('.$accountid.')','size' => '20', 'maxlength' => '100', 'class' => "btn btn-line-parrot"), '', 'tOOL TIP', 'Please Enter account number'); |
|
150 | + //$image_path=array(); |
|
151 | 151 | |
152 | 152 | |
153 | - } |
|
153 | + } |
|
154 | 154 | $form['forms'] = array(base_url() . 'invoices/invoice_conf/',array('id'=>'invoice_conf_form','method'=>'POST','name'=>'invoice_conf_form','enctype'=>'multipart/form-data')); |
155 | - $form['Configuration '] = array( |
|
156 | - array('', 'HIDDEN', array('name'=>'id'),'', '', '', ''), |
|
157 | - array('', 'HIDDEN', array('name'=>'accountid'),'', '', '', ''), |
|
158 | - // array('', 'HIDDEN', array('name' => 'start_name','value' => '1'), '', '', ''), |
|
159 | - array('Company name', 'INPUT', array('name' => 'company_name','size' => '20', 'class' => "text field medium"), '', 'tOOL TIP', 'Please Enter account number'), |
|
160 | - array('Address', 'INPUT', array('name' => 'address','size' => '20', 'class' => "text field medium"), '', 'tOOL TIP', 'Please Enter account number'), |
|
161 | - array('City', 'INPUT', array('name' => 'city','size' => '20', 'class' => "text field medium"), '', 'tOOL TIP', 'Please Enter account number'), |
|
162 | - array('Province', 'INPUT', array('name' => 'province','size' => '20', 'class' => "text field medium"), '', 'tOOL TIP', 'Please Enter account number'), |
|
163 | - array('Country', 'INPUT', array('name' => 'country','size' => '20', 'class' => "text field medium"), '', 'tOOL TIP', 'Please Enter account number'), |
|
164 | - array('Zipcode', 'INPUT', array('name' => 'zipcode','size' => '20', 'class' => "text field medium"), '', 'tOOL TIP', 'Please Enter account number'), |
|
165 | - array('Telephone', 'INPUT', array('name' => 'telephone','size' => '20', 'class' => "text field medium"), '', 'tOOL TIP', 'Please Enter account number'), |
|
166 | - array('Fax', 'INPUT', array('name' => 'fax','size' => '20', 'class' => "text field medium"), '', 'tOOL TIP', 'Please Enter account number'), |
|
167 | - array('Email Address', 'INPUT', array('name' => 'emailaddress','size' => '20', 'class' => "text field medium"), '', 'tOOL TIP', 'Please Enter account number'), |
|
168 | - array('Website', 'INPUT', array('name' => 'website','size' => '20', 'class' => "text field medium"), '', 'tOOL TIP', 'Please Enter account number'), |
|
155 | + $form['Configuration '] = array( |
|
156 | + array('', 'HIDDEN', array('name'=>'id'),'', '', '', ''), |
|
157 | + array('', 'HIDDEN', array('name'=>'accountid'),'', '', '', ''), |
|
158 | + // array('', 'HIDDEN', array('name' => 'start_name','value' => '1'), '', '', ''), |
|
159 | + array('Company name', 'INPUT', array('name' => 'company_name','size' => '20', 'class' => "text field medium"), '', 'tOOL TIP', 'Please Enter account number'), |
|
160 | + array('Address', 'INPUT', array('name' => 'address','size' => '20', 'class' => "text field medium"), '', 'tOOL TIP', 'Please Enter account number'), |
|
161 | + array('City', 'INPUT', array('name' => 'city','size' => '20', 'class' => "text field medium"), '', 'tOOL TIP', 'Please Enter account number'), |
|
162 | + array('Province', 'INPUT', array('name' => 'province','size' => '20', 'class' => "text field medium"), '', 'tOOL TIP', 'Please Enter account number'), |
|
163 | + array('Country', 'INPUT', array('name' => 'country','size' => '20', 'class' => "text field medium"), '', 'tOOL TIP', 'Please Enter account number'), |
|
164 | + array('Zipcode', 'INPUT', array('name' => 'zipcode','size' => '20', 'class' => "text field medium"), '', 'tOOL TIP', 'Please Enter account number'), |
|
165 | + array('Telephone', 'INPUT', array('name' => 'telephone','size' => '20', 'class' => "text field medium"), '', 'tOOL TIP', 'Please Enter account number'), |
|
166 | + array('Fax', 'INPUT', array('name' => 'fax','size' => '20', 'class' => "text field medium"), '', 'tOOL TIP', 'Please Enter account number'), |
|
167 | + array('Email Address', 'INPUT', array('name' => 'emailaddress','size' => '20', 'class' => "text field medium"), '', 'tOOL TIP', 'Please Enter account number'), |
|
168 | + array('Website', 'INPUT', array('name' => 'website','size' => '20', 'class' => "text field medium"), '', 'tOOL TIP', 'Please Enter account number'), |
|
169 | 169 | |
170 | 170 | |
171 | - ); |
|
172 | - $form['Invoice Configuration '] = array( |
|
173 | - array('', 'HIDDEN', array('name'=>'id'),'', '', '', ''), |
|
174 | - array('', 'HIDDEN', array('name'=>'accountid'),'', '', '', ''), |
|
175 | - array('Invoice Notification', 'invoice_notification', 'SELECT', '', '', 'tOOL TIP', '', '', '', '', 'set_allow_invoice'), |
|
176 | - array('Invoice Due Notification', 'invoice_due_notification', 'SELECT', '', '', 'tOOL TIP', '', '', '', '', 'set_allow_invoice'), |
|
177 | - array('Invoice Date Interval', 'INPUT', array('name' => 'interval','size' => '20', 'class' => "text field medium"), '', 'tOOL TIP', 'Please Enter account number'), |
|
178 | - array('Notify before days', 'INPUT', array('name' => 'notify_before_day','size' => '20', 'class' => "text field medium"), '', 'tOOL TIP', 'Please Enter account number'), |
|
179 | - array('Invoice Prefix', 'INPUT', array('name' => 'invoice_prefix','size' => '20', 'class' => "text field medium"), '', 'tOOL TIP', 'Please Enter account number'), |
|
180 | - array('Invoice Start Form', 'INPUT', array('name' => 'invoice_start_from','size' => '20', 'class' => "text field medium"), '', 'tOOL TIP', 'Please Enter account number'), |
|
181 | - array('Invoice Taxes number', 'INPUT', array('name' => 'invoice_taxes_number','size' => '20', 'class' => "text field medium"), '', 'tOOL TIP', 'Please Enter account number'), |
|
182 | - array('', 'HIDDEN', array('name'=>''),'', '', '', ''), |
|
183 | - array('', 'HIDDEN', array('name'=>''),'', '', '', ''), |
|
184 | - ); |
|
171 | + ); |
|
172 | + $form['Invoice Configuration '] = array( |
|
173 | + array('', 'HIDDEN', array('name'=>'id'),'', '', '', ''), |
|
174 | + array('', 'HIDDEN', array('name'=>'accountid'),'', '', '', ''), |
|
175 | + array('Invoice Notification', 'invoice_notification', 'SELECT', '', '', 'tOOL TIP', '', '', '', '', 'set_allow_invoice'), |
|
176 | + array('Invoice Due Notification', 'invoice_due_notification', 'SELECT', '', '', 'tOOL TIP', '', '', '', '', 'set_allow_invoice'), |
|
177 | + array('Invoice Date Interval', 'INPUT', array('name' => 'interval','size' => '20', 'class' => "text field medium"), '', 'tOOL TIP', 'Please Enter account number'), |
|
178 | + array('Notify before days', 'INPUT', array('name' => 'notify_before_day','size' => '20', 'class' => "text field medium"), '', 'tOOL TIP', 'Please Enter account number'), |
|
179 | + array('Invoice Prefix', 'INPUT', array('name' => 'invoice_prefix','size' => '20', 'class' => "text field medium"), '', 'tOOL TIP', 'Please Enter account number'), |
|
180 | + array('Invoice Start Form', 'INPUT', array('name' => 'invoice_start_from','size' => '20', 'class' => "text field medium"), '', 'tOOL TIP', 'Please Enter account number'), |
|
181 | + array('Invoice Taxes number', 'INPUT', array('name' => 'invoice_taxes_number','size' => '20', 'class' => "text field medium"), '', 'tOOL TIP', 'Please Enter account number'), |
|
182 | + array('', 'HIDDEN', array('name'=>''),'', '', '', ''), |
|
183 | + array('', 'HIDDEN', array('name'=>''),'', '', '', ''), |
|
184 | + ); |
|
185 | 185 | $form['Company personalization'] = array( |
186 | 186 | |
187 | 187 | |
188 | 188 | array('Website Domain', 'INPUT', array('name' => 'domain', 'size' => '20', 'maxlength' => '100', 'class' => "text field medium"), '', 'tOOL TIP', ''), |
189 | - array('Website Header', 'INPUT', array('name' => 'website_title', 'size' => '100', 'maxlength' => '100', 'class' => "text field medium"), '', 'tOOL TIP', ''), |
|
190 | - array('Website Footer', 'INPUT', array('name' => 'website_footer', 'size' => '200', 'maxlength' => '200', 'class' => "text field medium"), '', 'tOOL TIP', ''), |
|
191 | - array('Company logo', 'IMAGE', array('name' => 'file','size' => '20', 'maxlength' => '100', 'class' => "",'id'=>'uploadFile','type'=>'file'),'class' => '', 'tOOL TIP', 'Please Enter account number'), |
|
189 | + array('Website Header', 'INPUT', array('name' => 'website_title', 'size' => '100', 'maxlength' => '100', 'class' => "text field medium"), '', 'tOOL TIP', ''), |
|
190 | + array('Website Footer', 'INPUT', array('name' => 'website_footer', 'size' => '200', 'maxlength' => '200', 'class' => "text field medium"), '', 'tOOL TIP', ''), |
|
191 | + array('Company logo', 'IMAGE', array('name' => 'file','size' => '20', 'maxlength' => '100', 'class' => "",'id'=>'uploadFile','type'=>'file'),'class' => '', 'tOOL TIP', 'Please Enter account number'), |
|
192 | 192 | //array('', 'BLANL_DIV', array('name'=>'accountid','id'=>'imagePreview'),'', '', '', ''), |
193 | 193 | $delete_logo,$image_path, |
194 | - ); |
|
195 | - $form['button_save'] = array('name' => 'action', 'content' =>'Save' , 'value' => 'save', 'type' => 'submit', 'class' => 'btn btn-line-parrot'); |
|
194 | + ); |
|
195 | + $form['button_save'] = array('name' => 'action', 'content' =>'Save' , 'value' => 'save', 'type' => 'submit', 'class' => 'btn btn-line-parrot'); |
|
196 | 196 | |
197 | - return $form; |
|
197 | + return $form; |
|
198 | 198 | |
199 | - } |
|
199 | + } |
|
200 | 200 | } |
201 | 201 | ?> |
@@ -165,7 +165,7 @@ |
||
165 | 165 | </div> |
166 | 166 | <div class="col-md-5"><label style="text-align:left;float:left;" class="col-md-3"><?php echo gettext('Accounts'); ?> </label> |
167 | 167 | <?php |
168 | - if($login_type == -1){ |
|
168 | + if($login_type == -1){ |
|
169 | 169 | $where="deleted = '0' AND reseller_id = '0' AND status = '0' AND (type= '0' OR type= '3' OR type= '1')"; |
170 | 170 | }if($login_type == 1){ |
171 | 171 | $where="deleted = '0' AND reseller_id = '$id' AND status = '0' AND (type= '0' OR type= '3' OR type='1')"; |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | <tr> |
107 | 107 | <td> |
108 | 108 | <b>Due Date : </b><span style="color:#a09d9d;"><?php |
109 | - echo date('Y-m-d', strtotime($payment_due_date)) ; |
|
109 | + echo date('Y-m-d', strtotime($payment_due_date)) ; |
|
110 | 110 | ?></span> |
111 | 111 | </td> |
112 | 112 | </tr> |
@@ -143,14 +143,14 @@ discard block |
||
143 | 143 | $paypal=0; |
144 | 144 | foreach($invoice_final_query as $value){ |
145 | 145 | |
146 | - if($value['item_type'] != 'INVPAY' && $value['item_type'] != 'PAYMENT') { |
|
147 | - $debit=$value['debit']; |
|
148 | - $credit=$value['credit']; |
|
149 | - $paypal+=$credit; |
|
150 | - $created_date=$value['created_date']; |
|
151 | - $paypalid=$value['item_id']; |
|
152 | - $outstanding=$amount-$paypal; |
|
153 | - $amount_visible='0000'; |
|
146 | + if($value['item_type'] != 'INVPAY' && $value['item_type'] != 'PAYMENT') { |
|
147 | + $debit=$value['debit']; |
|
148 | + $credit=$value['credit']; |
|
149 | + $paypal+=$credit; |
|
150 | + $created_date=$value['created_date']; |
|
151 | + $paypalid=$value['item_id']; |
|
152 | + $outstanding=$amount-$paypal; |
|
153 | + $amount_visible='0000'; |
|
154 | 154 | |
155 | 155 | |
156 | 156 | |
@@ -201,13 +201,13 @@ discard block |
||
201 | 201 | foreach($invoice_total_query as $value){ |
202 | 202 | |
203 | 203 | |
204 | - $debit=$value['debit']; |
|
205 | - $credit=$value['credit']; |
|
206 | - $paypal+=$credit; |
|
207 | - $created_date=$value['created_date']; |
|
208 | - $paypalid=$value['item_id']; |
|
209 | - $outstanding=$amount-$paypal; |
|
210 | - $amount_visible='0000'; |
|
204 | + $debit=$value['debit']; |
|
205 | + $credit=$value['credit']; |
|
206 | + $paypal+=$credit; |
|
207 | + $created_date=$value['created_date']; |
|
208 | + $paypalid=$value['item_id']; |
|
209 | + $outstanding=$amount-$paypal; |
|
210 | + $amount_visible='0000'; |
|
211 | 211 | |
212 | 212 | |
213 | 213 | |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | </tr> |
223 | 223 | |
224 | 224 | <?php } |
225 | - } ?> |
|
225 | + } ?> |
|
226 | 226 | <tr style="background-color:#f6f6f6;"> |
227 | 227 | <th colspan="2" width="30%" > |
228 | 228 | <span class="pull-right" style="color:#474747;">Paid Amount</span> |
@@ -164,7 +164,7 @@ |
||
164 | 164 | <tr> |
165 | 165 | <td> |
166 | 166 | <b>Due Date : </b><span style="color:#a09d9d;"><?php |
167 | - echo date('Y-m-d', strtotime($payment_due_date)) ; |
|
167 | + echo date('Y-m-d', strtotime($payment_due_date)) ; |
|
168 | 168 | ?></span> |
169 | 169 | </td> |
170 | 170 | </tr> |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | <tr> |
188 | 188 | <td> |
189 | 189 | <b>Due Date : </b><span style="color:#a09d9d;"><?php |
190 | - echo date('Y-m-d', strtotime($payment_due_date)) ; |
|
190 | + echo date('Y-m-d', strtotime($payment_due_date)) ; |
|
191 | 191 | ?></span> |
192 | 192 | </td> |
193 | 193 | </tr> |
@@ -221,9 +221,9 @@ discard block |
||
221 | 221 | $j=1; |
222 | 222 | |
223 | 223 | foreach($invoice_total_query as $value){ |
224 | - $id=$value['id']; |
|
225 | - $debit=$value['debit']; |
|
226 | - $created_date=$value['created_date']; |
|
224 | + $id=$value['id']; |
|
225 | + $debit=$value['debit']; |
|
226 | + $created_date=$value['created_date']; |
|
227 | 227 | ?> |
228 | 228 | <tr> |
229 | 229 | <td width="20" align="center"> |