@@ -23,33 +23,33 @@ discard block |
||
23 | 23 | // ############################################################################## |
24 | 24 | class Dashboard_model extends CI_Model { |
25 | 25 | function Dashboard_model() { |
26 | - parent::__construct (); |
|
26 | + parent::__construct(); |
|
27 | 27 | } |
28 | 28 | function get_recent_recharge() { |
29 | - $accountinfo = $this->session->userdata ( 'accountinfo' ); |
|
30 | - $userlevel_logintype = $this->session->userdata ( 'userlevel_logintype' ); |
|
29 | + $accountinfo = $this->session->userdata('accountinfo'); |
|
30 | + $userlevel_logintype = $this->session->userdata('userlevel_logintype'); |
|
31 | 31 | |
32 | - $where_arr = array ( |
|
33 | - 'payment_by' => - 1 |
|
32 | + $where_arr = array( |
|
33 | + 'payment_by' => -1 |
|
34 | 34 | ); |
35 | 35 | if ($userlevel_logintype == 1) { |
36 | - $where_arr = array ( |
|
36 | + $where_arr = array( |
|
37 | 37 | 'payment_by' => $accountinfo ['id'] |
38 | 38 | ); |
39 | 39 | } |
40 | 40 | if ($userlevel_logintype == 0 || $userlevel_logintype == 3) { |
41 | - $where_arr = array ( |
|
41 | + $where_arr = array( |
|
42 | 42 | 'accountid' => $accountinfo ['id'] |
43 | 43 | ); |
44 | 44 | } |
45 | - $this->db->where ( $where_arr ); |
|
46 | - $this->db->select ( 'id,accountid,credit,payment_date' ); |
|
47 | - $this->db->limit ( 12 ); |
|
48 | - $this->db->order_by ( 'payment_date', 'desc' ); |
|
49 | - return $this->db->get ( 'payments' ); |
|
45 | + $this->db->where($where_arr); |
|
46 | + $this->db->select('id,accountid,credit,payment_date'); |
|
47 | + $this->db->limit(12); |
|
48 | + $this->db->order_by('payment_date', 'desc'); |
|
49 | + return $this->db->get('payments'); |
|
50 | 50 | } |
51 | 51 | function get_call_statistics($table, $parent_id, $start_date = '', $end_date = '', $group_flag = true) { |
52 | - $this->db->select ( "count(uniqueid) as sum, |
|
52 | + $this->db->select("count(uniqueid) as sum, |
|
53 | 53 | count(CASE WHEN billseconds > 0 THEN 1 END) as answered, |
54 | 54 | MAX(billseconds) AS mcd, |
55 | 55 | SUM(billseconds) AS duration, |
@@ -59,48 +59,48 @@ discard block |
||
59 | 59 | sum(debit) as debit, |
60 | 60 | sum(cost) as cost, |
61 | 61 | SUM(CASE WHEN billseconds > 0 THEN 1 ELSE 0 END) as completed, |
62 | - DAY(callstart) as day", false ); |
|
63 | - $this->db->where ( 'callstart >=', $start_date . " 00:00:00" ); |
|
64 | - $this->db->where ( 'callstart <=', $end_date . " 23:59:59" ); |
|
65 | - $this->db->where ( 'reseller_id', $parent_id ); |
|
62 | + DAY(callstart) as day", false); |
|
63 | + $this->db->where('callstart >=', $start_date." 00:00:00"); |
|
64 | + $this->db->where('callstart <=', $end_date." 23:59:59"); |
|
65 | + $this->db->where('reseller_id', $parent_id); |
|
66 | 66 | if ($group_flag) |
67 | - $this->db->group_by ( "DAY(callstart)" ); |
|
68 | - $result = $this->db->get ( $table ); |
|
67 | + $this->db->group_by("DAY(callstart)"); |
|
68 | + $result = $this->db->get($table); |
|
69 | 69 | return $result; |
70 | 70 | } |
71 | 71 | function get_customer_maximum_callminutes($start_date, $end_date) { |
72 | - $start_date = $start_date . " 00:00:00"; |
|
73 | - $end_date = $end_date . " 23:59:59"; |
|
74 | - $accountinfo = $this->session->userdata ( 'accountinfo' ); |
|
72 | + $start_date = $start_date." 00:00:00"; |
|
73 | + $end_date = $end_date." 23:59:59"; |
|
74 | + $accountinfo = $this->session->userdata('accountinfo'); |
|
75 | 75 | $parent_id = ($accountinfo ['type'] == 1) ? $accountinfo ['id'] : 0; |
76 | - if ($this->session->userdata ( 'userlevel_logintype' ) != 0 && $this->session->userdata ( 'userlevel_logintype' ) != 3) { |
|
76 | + if ($this->session->userdata('userlevel_logintype') != 0 && $this->session->userdata('userlevel_logintype') != 3) { |
|
77 | 77 | $where = "reseller_id ='$parent_id'"; |
78 | 78 | } else { |
79 | 79 | $where = "accountid ='$parent_id'"; |
80 | 80 | } |
81 | - $where = $where . " AND callstart >= '" . $start_date . "' AND callstart <= '" . $end_date . "'"; |
|
81 | + $where = $where." AND callstart >= '".$start_date."' AND callstart <= '".$end_date."'"; |
|
82 | 82 | $select_query = "(SELECT sum( billseconds ) AS billseconds,accountid FROM (cdrs) WHERE $where group by accountid order by sum(billseconds) desc limit 10) |
83 | 83 | union |
84 | 84 | (SELECT sum( billseconds ) AS billseconds,accountid FROM (reseller_cdrs) WHERE $where |
85 | 85 | group by accountid order by sum(billseconds) desc limit 10 ) ORDER BY billseconds DESC LIMIT 10 "; |
86 | - return $this->db->query ( $select_query ); |
|
86 | + return $this->db->query($select_query); |
|
87 | 87 | } |
88 | 88 | function get_customer_maximum_callcount($start_date, $end_date) { |
89 | - $start_date = $start_date . " 00:00:00"; |
|
90 | - $end_date = $end_date . " 23:59:59"; |
|
91 | - $accountinfo = $this->session->userdata ( 'accountinfo' ); |
|
89 | + $start_date = $start_date." 00:00:00"; |
|
90 | + $end_date = $end_date." 23:59:59"; |
|
91 | + $accountinfo = $this->session->userdata('accountinfo'); |
|
92 | 92 | $parent_id = ($accountinfo ['type'] == 1) ? $accountinfo ['id'] : 0; |
93 | - if ($this->session->userdata ( 'userlevel_logintype' ) != 0 && $this->session->userdata ( 'userlevel_logintype' ) != 3) { |
|
93 | + if ($this->session->userdata('userlevel_logintype') != 0 && $this->session->userdata('userlevel_logintype') != 3) { |
|
94 | 94 | $where = "reseller_id ='$parent_id'"; |
95 | 95 | } else { |
96 | 96 | $where = "accountid ='$parent_id'"; |
97 | 97 | } |
98 | - $where = $where . " AND callstart >= '" . $start_date . "' AND callstart <= '" . $end_date . "'"; |
|
98 | + $where = $where." AND callstart >= '".$start_date."' AND callstart <= '".$end_date."'"; |
|
99 | 99 | $select_query = "(SELECT count(uniqueid) as call_count, `accountid` FROM (`cdrs`) WHERE $where GROUP BY `accountid` ORDER BY `call_count` desc LIMIT 10) |
100 | 100 | UNION |
101 | 101 | (SELECT count(uniqueid) as call_count,accountid FROM (reseller_cdrs) WHERE $where GROUP BY `accountid` ORDER BY `call_count` desc LIMIT 10) |
102 | 102 | ORDER BY call_count desc limit 10"; |
103 | - return $this->db->query ( $select_query ); |
|
103 | + return $this->db->query($select_query); |
|
104 | 104 | } |
105 | 105 | } |
106 | 106 | ?> |
@@ -63,8 +63,9 @@ |
||
63 | 63 | $this->db->where ( 'callstart >=', $start_date . " 00:00:00" ); |
64 | 64 | $this->db->where ( 'callstart <=', $end_date . " 23:59:59" ); |
65 | 65 | $this->db->where ( 'reseller_id', $parent_id ); |
66 | - if ($group_flag) |
|
67 | - $this->db->group_by ( "DAY(callstart)" ); |
|
66 | + if ($group_flag) { |
|
67 | + $this->db->group_by ( "DAY(callstart)" ); |
|
68 | + } |
|
68 | 69 | $result = $this->db->get ( $table ); |
69 | 70 | return $result; |
70 | 71 | } |
@@ -23,79 +23,79 @@ discard block |
||
23 | 23 | // ############################################################################## |
24 | 24 | class dashboard extends CI_Controller { |
25 | 25 | function dashboard() { |
26 | - parent::__construct (); |
|
27 | - $this->load->helper ( 'form' ); |
|
28 | - $this->load->model ( 'Auth_model' ); |
|
29 | - $this->load->library ( "astpp/form" ); |
|
30 | - $this->load->model ( 'Astpp_common' ); |
|
31 | - $this->load->model ( 'dashboard_model' ); |
|
32 | - $this->load->library ( 'freeswitch_lib' ); |
|
26 | + parent::__construct(); |
|
27 | + $this->load->helper('form'); |
|
28 | + $this->load->model('Auth_model'); |
|
29 | + $this->load->library("astpp/form"); |
|
30 | + $this->load->model('Astpp_common'); |
|
31 | + $this->load->model('dashboard_model'); |
|
32 | + $this->load->library('freeswitch_lib'); |
|
33 | 33 | } |
34 | 34 | function index() { |
35 | - if ($this->session->userdata ( 'user_login' ) == FALSE) |
|
36 | - redirect ( base_url () . 'login/login' ); |
|
37 | - $data ['page_title'] = gettext ( 'Dashboard' ); |
|
38 | - if ($this->session->userdata ( 'logintype' ) == 0) { |
|
39 | - $this->load->view ( 'view_user_dashboard', $data ); |
|
35 | + if ($this->session->userdata('user_login') == FALSE) |
|
36 | + redirect(base_url().'login/login'); |
|
37 | + $data ['page_title'] = gettext('Dashboard'); |
|
38 | + if ($this->session->userdata('logintype') == 0) { |
|
39 | + $this->load->view('view_user_dashboard', $data); |
|
40 | 40 | } else { |
41 | - $gmtoffset = $this->common->get_timezone_offset (); |
|
42 | - $this->load->view ( 'view_dashboard', $data ); |
|
41 | + $gmtoffset = $this->common->get_timezone_offset(); |
|
42 | + $this->load->view('view_dashboard', $data); |
|
43 | 43 | } |
44 | 44 | } |
45 | 45 | function user_recent_payments() { |
46 | - $this->customerReport_recent_payments (); |
|
46 | + $this->customerReport_recent_payments(); |
|
47 | 47 | } |
48 | 48 | function customerReport_recent_payments() { |
49 | - $accountinfo = $this->session->userdata ( 'accountinfo' ); |
|
50 | - $currency = $this->common->get_field_name ( 'currency', 'currency', array ( |
|
49 | + $accountinfo = $this->session->userdata('accountinfo'); |
|
50 | + $currency = $this->common->get_field_name('currency', 'currency', array( |
|
51 | 51 | "id" => $accountinfo ['currency_id'] |
52 | - ) ); |
|
53 | - $json_data = array (); |
|
52 | + )); |
|
53 | + $json_data = array(); |
|
54 | 54 | $i = 1; |
55 | - $result = $this->dashboard_model->get_recent_recharge (); |
|
56 | - $gmtoffset = $this->common->get_timezone_offset (); |
|
57 | - if ($result->num_rows () > 0) { |
|
58 | - $account_arr = $this->common->get_array ( 'id,number,first_name,last_name', 'accounts', '' ); |
|
55 | + $result = $this->dashboard_model->get_recent_recharge(); |
|
56 | + $gmtoffset = $this->common->get_timezone_offset(); |
|
57 | + if ($result->num_rows() > 0) { |
|
58 | + $account_arr = $this->common->get_array('id,number,first_name,last_name', 'accounts', ''); |
|
59 | 59 | $json_data [0] ['accountid'] = 'Accounts'; |
60 | - $json_data [0] ['credit'] = 'Amount(' . $currency . ")"; |
|
60 | + $json_data [0] ['credit'] = 'Amount('.$currency.")"; |
|
61 | 61 | $json_data [0] ['payment_date'] = 'Date'; |
62 | - foreach ( $result->result_array () as $key => $data ) { |
|
63 | - $current_timestamp = strtotime ( $data ['payment_date'] ); |
|
62 | + foreach ($result->result_array() as $key => $data) { |
|
63 | + $current_timestamp = strtotime($data ['payment_date']); |
|
64 | 64 | $modified_date = $current_timestamp + $gmtoffset; |
65 | - $data ['accountid'] = ($data ['accountid'] != '' && isset ( $account_arr [$data ['accountid']] )) ? $account_arr [$data ['accountid']] : "Anonymous"; |
|
65 | + $data ['accountid'] = ($data ['accountid'] != '' && isset ($account_arr [$data ['accountid']])) ? $account_arr [$data ['accountid']] : "Anonymous"; |
|
66 | 66 | $json_data [$i] ['accountid'] = $data ['accountid']; |
67 | - $json_data [$i] ['credit'] = $this->common_model->calculate_currency ( $data ['credit'], '', '', true, false ); |
|
68 | - $json_data [$i] ['payment_date'] = date ( 'Y-m-d H:i:s', strtotime ( $data ['payment_date'] ) + $gmtoffset ); |
|
69 | - $i ++; |
|
67 | + $json_data [$i] ['credit'] = $this->common_model->calculate_currency($data ['credit'], '', '', true, false); |
|
68 | + $json_data [$i] ['payment_date'] = date('Y-m-d H:i:s', strtotime($data ['payment_date']) + $gmtoffset); |
|
69 | + $i++; |
|
70 | 70 | } |
71 | 71 | } |
72 | - echo json_encode ( $json_data ); |
|
72 | + echo json_encode($json_data); |
|
73 | 73 | } |
74 | 74 | function user_call_statistics_with_profit() { |
75 | - $this->customerReport_call_statistics_with_profit (); |
|
75 | + $this->customerReport_call_statistics_with_profit(); |
|
76 | 76 | } |
77 | 77 | function customerReport_call_statistics_with_profit() { |
78 | - $post=$this->input->post(); |
|
79 | - $year=isset($post['year']) && $post['year'] >0 ? $post['year']:date("Y"); |
|
80 | - $month=isset($post['month'])&& $post['month'] >0 ? $post['month']:date("m"); |
|
78 | + $post = $this->input->post(); |
|
79 | + $year = isset($post['year']) && $post['year'] > 0 ? $post['year'] : date("Y"); |
|
80 | + $month = isset($post['month']) && $post['month'] > 0 ? $post['month'] : date("m"); |
|
81 | 81 | $json_data = array(); |
82 | - $start_date=date($year.'-'.$month.'-01'); |
|
83 | - $end_day= $year==date("Y") && $month ==date("m") ? date("d") :cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
84 | - $gmtoffset=$this->common->get_timezone_offset(); |
|
85 | - $end_date=date($year."-".$month."-".$end_day.' H:i:s'); |
|
86 | - $end_date=date('Y-m-d',strtotime($end_date)+$gmtoffset); |
|
87 | - $current_date=(int)date("d"); |
|
88 | - $count=0; |
|
89 | - $i=0; |
|
82 | + $start_date = date($year.'-'.$month.'-01'); |
|
83 | + $end_day = $year == date("Y") && $month == date("m") ? date("d") : cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
84 | + $gmtoffset = $this->common->get_timezone_offset(); |
|
85 | + $end_date = date($year."-".$month."-".$end_day.' H:i:s'); |
|
86 | + $end_date = date('Y-m-d', strtotime($end_date) + $gmtoffset); |
|
87 | + $current_date = (int)date("d"); |
|
88 | + $count = 0; |
|
89 | + $i = 0; |
|
90 | 90 | $begin = new DateTime($start_date); |
91 | 91 | $end = new DateTime($end_date); |
92 | - $end=$end->modify('+1 day'); |
|
92 | + $end = $end->modify('+1 day'); |
|
93 | 93 | $daterange = new DatePeriod($begin, new DateInterval('P1D'), $end); |
94 | - $records_date=array(); |
|
95 | - $accountinfo=$this->session->userdata('accountinfo'); |
|
96 | - $parent_id= ($accountinfo['type'] == 1) ? $accountinfo['id'] : 0; |
|
97 | - $customerresult = $this->dashboard_model->get_call_statistics('cdrs',$parent_id,$start_date,$end_date); |
|
98 | - $resellerresult = $this->dashboard_model->get_call_statistics('reseller_cdrs',$parent_id,$start_date,$end_date); |
|
94 | + $records_date = array(); |
|
95 | + $accountinfo = $this->session->userdata('accountinfo'); |
|
96 | + $parent_id = ($accountinfo['type'] == 1) ? $accountinfo['id'] : 0; |
|
97 | + $customerresult = $this->dashboard_model->get_call_statistics('cdrs', $parent_id, $start_date, $end_date); |
|
98 | + $resellerresult = $this->dashboard_model->get_call_statistics('reseller_cdrs', $parent_id, $start_date, $end_date); |
|
99 | 99 | $acc_arr = array(); |
100 | 100 | /*Date: 08-Mar-2017 |
101 | 101 | Reason: Improvement of Dashboard Performance*/ |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | $acc_arr[$data['day']] = $data; |
128 | 128 | $customer_total_result['sum'] += $data['sum']; |
129 | 129 | $customer_total_result['answered'] += $data['answered']; |
130 | - if($data['mcd'] > $mcd){ |
|
130 | + if ($data['mcd'] > $mcd) { |
|
131 | 131 | $mcd = $data['mcd']; |
132 | 132 | } |
133 | 133 | $customer_total_result['mcd'] = $mcd; |
@@ -139,22 +139,22 @@ discard block |
||
139 | 139 | $customer_total_result['cost'] += $data['cost']; |
140 | 140 | $customer_total_result['completed'] += $data['completed']; |
141 | 141 | } |
142 | - foreach($resellerresult->result_array() as $data){ |
|
143 | - $reseller_arr[$data['day']]=$data; |
|
144 | - if(isset($acc_arr[$data['day']])){ |
|
145 | - $acc_arr[$data['day']]['sum']= $data['sum']+$acc_arr[$data['day']]['sum']; |
|
146 | - $acc_arr[$data['day']]['answered']= $data['answered']+$acc_arr[$data['day']]['answered']; |
|
147 | - $acc_arr[$data['day']]['failed']= $data['failed']+$acc_arr[$data['day']]['failed']; |
|
148 | - $acc_arr[$data['day']]['profit']= $data['profit']+$acc_arr[$data['day']]['profit']; |
|
149 | - $acc_arr[$data['day']]['completed']= $data['completed']+$acc_arr[$data['day']]['completed']; |
|
150 | - $acc_arr[$data['day']]['duration'] = $data['duration']+$acc_arr[$data['day']]['duration']; |
|
151 | - $acc_arr[$data['day']]['mcd'] =$data['mcd'] > $acc_arr[$data['day']]['mcd'] ? $data['mcd']: $acc_arr[$data['day']]['mcd']; |
|
152 | - }else{ |
|
153 | - $acc_arr[$data['day']]=$data; |
|
142 | + foreach ($resellerresult->result_array() as $data) { |
|
143 | + $reseller_arr[$data['day']] = $data; |
|
144 | + if (isset($acc_arr[$data['day']])) { |
|
145 | + $acc_arr[$data['day']]['sum'] = $data['sum'] + $acc_arr[$data['day']]['sum']; |
|
146 | + $acc_arr[$data['day']]['answered'] = $data['answered'] + $acc_arr[$data['day']]['answered']; |
|
147 | + $acc_arr[$data['day']]['failed'] = $data['failed'] + $acc_arr[$data['day']]['failed']; |
|
148 | + $acc_arr[$data['day']]['profit'] = $data['profit'] + $acc_arr[$data['day']]['profit']; |
|
149 | + $acc_arr[$data['day']]['completed'] = $data['completed'] + $acc_arr[$data['day']]['completed']; |
|
150 | + $acc_arr[$data['day']]['duration'] = $data['duration'] + $acc_arr[$data['day']]['duration']; |
|
151 | + $acc_arr[$data['day']]['mcd'] = $data['mcd'] > $acc_arr[$data['day']]['mcd'] ? $data['mcd'] : $acc_arr[$data['day']]['mcd']; |
|
152 | + } else { |
|
153 | + $acc_arr[$data['day']] = $data; |
|
154 | 154 | } |
155 | - $reseller_total_result['sum']+= $data['sum']; |
|
155 | + $reseller_total_result['sum'] += $data['sum']; |
|
156 | 156 | $reseller_total_result['answered'] += $acc_arr[$data['day']]['answered']; |
157 | - if($data['mcd'] > $res_mcd){ |
|
157 | + if ($data['mcd'] > $res_mcd) { |
|
158 | 158 | $res_mcd = $data['mcd']; |
159 | 159 | } |
160 | 160 | $reseller_total_result['mcd'] = $res_mcd; |
@@ -166,132 +166,132 @@ discard block |
||
166 | 166 | $reseller_total_result['completed'] += $data['completed']; |
167 | 167 | $reseller_total_result['billable'] += $data['billable']; |
168 | 168 | } |
169 | - if(!empty($acc_arr)){ |
|
170 | - foreach($daterange as $date){ |
|
171 | - $json_data['date'][]=$date->format("d"); |
|
172 | - $day = (int) $date->format("d"); |
|
173 | - if(isset($acc_arr[$day])){ |
|
174 | - $asr= ($acc_arr[$day]['sum'] > 0 ) ? (round(($acc_arr[$day]['completed'] / $acc_arr[$day]['sum']) * 100,2)) : 0; |
|
175 | - $acd= ($acc_arr[$day]['completed'] > 0 ) ? round($acc_arr[$day]['billable'] / $acc_arr[$day]['completed'],2) : 0; |
|
176 | - $json_data['total'][]= array((string)$acc_arr[$day]['day'],(int) $acc_arr[$day]['sum']); |
|
177 | - $json_data['answered'][]= array((string)$acc_arr[$day]['day'],(int) $acc_arr[$day]['answered']); |
|
178 | - $json_data['failed'][]= array((string)$acc_arr[$day]['day'],(int) $acc_arr[$day]['failed']); |
|
179 | - $json_data['profit'][]= array((string)$acc_arr[$day]['day'],(float) str_replace(",", "", $this->common_model->calculate_currency($acc_arr[$day]['profit']))); |
|
180 | - $json_data['acd'][]=array((string)$acc_arr[$day]['day'],(float)$acd); |
|
181 | - $json_data['mcd'][]=array((string)$acc_arr[$day]['day'],(float)$acc_arr[$day]['mcd']); |
|
182 | - $json_data['asr'][]=array((string)$acc_arr[$day]['day'],(float)$asr); |
|
183 | - }else{ |
|
184 | - $json_data['total'][]= array($date->format("d"), 0); |
|
185 | - $json_data['answered'][]= array($date->format("d"), 0); |
|
186 | - $json_data['failed'][]= array($date->format("d"), 0); |
|
187 | - $json_data['profit'][]= array($date->format("d"), 0); |
|
188 | - $json_data['acd'][]=array($date->format("d"), 0); |
|
189 | - $json_data['mcd'][]=array($date->format("d"), 0); |
|
190 | - $json_data['asr'][]=array($date->format("d"),0); |
|
169 | + if ( ! empty($acc_arr)) { |
|
170 | + foreach ($daterange as $date) { |
|
171 | + $json_data['date'][] = $date->format("d"); |
|
172 | + $day = (int)$date->format("d"); |
|
173 | + if (isset($acc_arr[$day])) { |
|
174 | + $asr = ($acc_arr[$day]['sum'] > 0) ? (round(($acc_arr[$day]['completed'] / $acc_arr[$day]['sum']) * 100, 2)) : 0; |
|
175 | + $acd = ($acc_arr[$day]['completed'] > 0) ? round($acc_arr[$day]['billable'] / $acc_arr[$day]['completed'], 2) : 0; |
|
176 | + $json_data['total'][] = array((string)$acc_arr[$day]['day'], (int)$acc_arr[$day]['sum']); |
|
177 | + $json_data['answered'][] = array((string)$acc_arr[$day]['day'], (int)$acc_arr[$day]['answered']); |
|
178 | + $json_data['failed'][] = array((string)$acc_arr[$day]['day'], (int)$acc_arr[$day]['failed']); |
|
179 | + $json_data['profit'][] = array((string)$acc_arr[$day]['day'], (float)str_replace(",", "", $this->common_model->calculate_currency($acc_arr[$day]['profit']))); |
|
180 | + $json_data['acd'][] = array((string)$acc_arr[$day]['day'], (float)$acd); |
|
181 | + $json_data['mcd'][] = array((string)$acc_arr[$day]['day'], (float)$acc_arr[$day]['mcd']); |
|
182 | + $json_data['asr'][] = array((string)$acc_arr[$day]['day'], (float)$asr); |
|
183 | + } else { |
|
184 | + $json_data['total'][] = array($date->format("d"), 0); |
|
185 | + $json_data['answered'][] = array($date->format("d"), 0); |
|
186 | + $json_data['failed'][] = array($date->format("d"), 0); |
|
187 | + $json_data['profit'][] = array($date->format("d"), 0); |
|
188 | + $json_data['acd'][] = array($date->format("d"), 0); |
|
189 | + $json_data['mcd'][] = array($date->format("d"), 0); |
|
190 | + $json_data['asr'][] = array($date->format("d"), 0); |
|
191 | 191 | } |
192 | 192 | } |
193 | - } else{ |
|
194 | - foreach($daterange as $date){ |
|
195 | - $json_data['date'][]=$date->format("d"); |
|
196 | - $day = (int) $date->format("d"); |
|
197 | - $json_data['total'][]= array($date->format("d"), 0); |
|
198 | - $json_data['answered'][]= array($date->format("d"), 0); |
|
199 | - $json_data['failed'][]= array($date->format("d"), 0); |
|
200 | - $json_data['profit'][]= array($date->format("d"), 0); |
|
201 | - $json_data['acd'][]=array($date->format("d"), 0); |
|
202 | - $json_data['mcd'][]=array($date->format("d"), 0); |
|
203 | - $json_data['asr'][]=array($date->format("d"), 0); |
|
193 | + } else { |
|
194 | + foreach ($daterange as $date) { |
|
195 | + $json_data['date'][] = $date->format("d"); |
|
196 | + $day = (int)$date->format("d"); |
|
197 | + $json_data['total'][] = array($date->format("d"), 0); |
|
198 | + $json_data['answered'][] = array($date->format("d"), 0); |
|
199 | + $json_data['failed'][] = array($date->format("d"), 0); |
|
200 | + $json_data['profit'][] = array($date->format("d"), 0); |
|
201 | + $json_data['acd'][] = array($date->format("d"), 0); |
|
202 | + $json_data['mcd'][] = array($date->format("d"), 0); |
|
203 | + $json_data['asr'][] = array($date->format("d"), 0); |
|
204 | 204 | } |
205 | 205 | } |
206 | - $json_data['total_count']['sum']=$reseller_total_result['sum']+$customer_total_result['sum']; |
|
207 | - $json_data['total_count']['debit']=$this->common_model->to_calculate_currency($reseller_total_result['debit']+$customer_total_result['debit'],'','',true,true); |
|
208 | - $json_data['total_count']['cost']=$this->common_model->to_calculate_currency($reseller_total_result['cost']+$customer_total_result['cost'],'','',true,true); |
|
209 | - $json_data['total_count']['profit']=$this->common_model->to_calculate_currency($reseller_total_result['profit']+$customer_total_result['profit'],'','',true,true); |
|
210 | - $json_data['total_count']['completed']=$reseller_total_result['completed']+$customer_total_result['completed']; |
|
211 | - $json_data['total_count']['duration']=$reseller_total_result['duration']+$customer_total_result['duration']; |
|
212 | - $json_data['total_count']['billable']=$reseller_total_result['billable']+$customer_total_result['billable']; |
|
206 | + $json_data['total_count']['sum'] = $reseller_total_result['sum'] + $customer_total_result['sum']; |
|
207 | + $json_data['total_count']['debit'] = $this->common_model->to_calculate_currency($reseller_total_result['debit'] + $customer_total_result['debit'], '', '', true, true); |
|
208 | + $json_data['total_count']['cost'] = $this->common_model->to_calculate_currency($reseller_total_result['cost'] + $customer_total_result['cost'], '', '', true, true); |
|
209 | + $json_data['total_count']['profit'] = $this->common_model->to_calculate_currency($reseller_total_result['profit'] + $customer_total_result['profit'], '', '', true, true); |
|
210 | + $json_data['total_count']['completed'] = $reseller_total_result['completed'] + $customer_total_result['completed']; |
|
211 | + $json_data['total_count']['duration'] = $reseller_total_result['duration'] + $customer_total_result['duration']; |
|
212 | + $json_data['total_count']['billable'] = $reseller_total_result['billable'] + $customer_total_result['billable']; |
|
213 | 213 | //print_r($json_data); |
214 | - $json_data['total_count']['acd']=$json_data['total_count']['completed'] > 0 ? round($json_data['total_count']['billable']/$json_data['total_count']['completed'],2):0; |
|
215 | - $json_data['total_count']['mcd']=($customer_total_result['mcd'] > 0 || $reseller_total_result['mcd'] > 0 ) ? ($customer_total_result['mcd'] > $reseller_total_result['mcd'] ? $customer_total_result['mcd']:$reseller_total_result['mcd']) : 0; |
|
216 | - $json_data['total_count']['asr']=($json_data['total_count']['sum'] > 0 ) ? (round(($json_data['total_count']['completed'] / $json_data['total_count']['sum']) * 100,2)) : 0; |
|
217 | - $json_data['total_count']['asr']=$this->common_model->format_currency($json_data['total_count']['asr']); |
|
214 | + $json_data['total_count']['acd'] = $json_data['total_count']['completed'] > 0 ? round($json_data['total_count']['billable'] / $json_data['total_count']['completed'], 2) : 0; |
|
215 | + $json_data['total_count']['mcd'] = ($customer_total_result['mcd'] > 0 || $reseller_total_result['mcd'] > 0) ? ($customer_total_result['mcd'] > $reseller_total_result['mcd'] ? $customer_total_result['mcd'] : $reseller_total_result['mcd']) : 0; |
|
216 | + $json_data['total_count']['asr'] = ($json_data['total_count']['sum'] > 0) ? (round(($json_data['total_count']['completed'] / $json_data['total_count']['sum']) * 100, 2)) : 0; |
|
217 | + $json_data['total_count']['asr'] = $this->common_model->format_currency($json_data['total_count']['asr']); |
|
218 | 218 | echo json_encode($json_data); |
219 | 219 | } |
220 | 220 | function user_maximum_callminutes() { |
221 | - $this->customerReport_maximum_callminutes (); |
|
221 | + $this->customerReport_maximum_callminutes(); |
|
222 | 222 | } |
223 | 223 | function customerReport_maximum_callminutes() { |
224 | - $post = $this->input->post (); |
|
225 | - $year = isset ( $post ['year'] ) && $post ['year'] > 0 ? $post ['year'] : date ( "Y" ); |
|
226 | - $month = isset ( $post ['month'] ) && $post ['month'] > 0 ? $post ['month'] : date ( "m" ); |
|
227 | - $start_date = date ( $year . '-' . $month . '-01' ); |
|
228 | - $end_day = $year == date ( "Y" ) && $month == date ( "m" ) ? date ( "d" ) : cal_days_in_month ( CAL_GREGORIAN, $month, $year ); |
|
229 | - $gmtoffset = $this->common->get_timezone_offset (); |
|
230 | - $end_date = date ( $year . "-" . $month . "-" . $end_day . ' H:i:s' ); |
|
231 | - $end_date = date ( 'Y-m-d', strtotime ( $end_date ) + $gmtoffset ); |
|
232 | - $json_data = array (); |
|
233 | - $result = $this->dashboard_model->get_customer_maximum_callminutes ( $start_date, $end_date ); |
|
224 | + $post = $this->input->post(); |
|
225 | + $year = isset ($post ['year']) && $post ['year'] > 0 ? $post ['year'] : date("Y"); |
|
226 | + $month = isset ($post ['month']) && $post ['month'] > 0 ? $post ['month'] : date("m"); |
|
227 | + $start_date = date($year.'-'.$month.'-01'); |
|
228 | + $end_day = $year == date("Y") && $month == date("m") ? date ("d") : cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
229 | + $gmtoffset = $this->common->get_timezone_offset(); |
|
230 | + $end_date = date($year."-".$month."-".$end_day.' H:i:s'); |
|
231 | + $end_date = date('Y-m-d', strtotime($end_date) + $gmtoffset); |
|
232 | + $json_data = array(); |
|
233 | + $result = $this->dashboard_model->get_customer_maximum_callminutes($start_date, $end_date); |
|
234 | 234 | $i = 0; |
235 | - $accountinfo = $this->session->userdata ( 'accountinfo' ); |
|
235 | + $accountinfo = $this->session->userdata('accountinfo'); |
|
236 | 236 | $reseller_id = ($accountinfo ['type'] == - 1 or $accountinfo ['type'] == 2) ? 0 : $accountinfo ['id']; |
237 | - if ($this->session->userdata ( 'userlevel_logintype' ) != 0 && $this->session->userdata ( 'userlevel_logintype' ) != 3) { |
|
238 | - $account_arr = $this->common->get_array ( 'id,number,first_name,last_name', 'accounts', array ( |
|
237 | + if ($this->session->userdata('userlevel_logintype') != 0 && $this->session->userdata('userlevel_logintype') != 3) { |
|
238 | + $account_arr = $this->common->get_array('id,number,first_name,last_name', 'accounts', array( |
|
239 | 239 | 'reseller_id' => $reseller_id |
240 | - ) ); |
|
240 | + )); |
|
241 | 241 | } else { |
242 | - $account_arr = $this->common->get_array ( 'id,number,first_name,last_name', 'accounts', array ( |
|
242 | + $account_arr = $this->common->get_array('id,number,first_name,last_name', 'accounts', array( |
|
243 | 243 | 'id' => $reseller_id |
244 | - ) ); |
|
244 | + )); |
|
245 | 245 | } |
246 | - if ($result->num_rows () > 0) { |
|
247 | - foreach ( $result->result_array () as $data ) { |
|
248 | - $data ['accountid'] = ($data ['accountid'] != '' && isset ( $account_arr [$data ['accountid']] )) ? $account_arr [$data ['accountid']] : "Anonymous"; |
|
246 | + if ($result->num_rows() > 0) { |
|
247 | + foreach ($result->result_array() as $data) { |
|
248 | + $data ['accountid'] = ($data ['accountid'] != '' && isset ($account_arr [$data ['accountid']])) ? $account_arr [$data ['accountid']] : "Anonymous"; |
|
249 | 249 | $json_data [$i] [] = $data ['accountid']; |
250 | - $json_data [$i] [] = round ( $data ['billseconds'] / 60, 0 ); |
|
251 | - $i ++; |
|
250 | + $json_data [$i] [] = round($data ['billseconds'] / 60, 0); |
|
251 | + $i++; |
|
252 | 252 | } |
253 | 253 | } else { |
254 | - $json_data [] = array (); |
|
254 | + $json_data [] = array(); |
|
255 | 255 | } |
256 | - echo json_encode ( $json_data ); |
|
256 | + echo json_encode($json_data); |
|
257 | 257 | } |
258 | 258 | function user_maximum_callcount() { |
259 | - $this->customerReport_maximum_callcount (); |
|
259 | + $this->customerReport_maximum_callcount(); |
|
260 | 260 | } |
261 | 261 | function customerReport_maximum_callcount() { |
262 | - $post = $this->input->post (); |
|
263 | - $year = isset ( $post ['year'] ) && $post ['year'] > 0 ? $post ['year'] : date ( "Y" ); |
|
264 | - $month = isset ( $post ['month'] ) && $post ['month'] > 0 ? $post ['month'] : date ( "m" ); |
|
265 | - $start_date = date ( $year . '-' . $month . '-01' ); |
|
266 | - $end_day = $year == date ( "Y" ) && $month == date ( "m" ) ? date ( "d" ) : cal_days_in_month ( CAL_GREGORIAN, $month, $year ); |
|
267 | - $gmtoffset = $this->common->get_timezone_offset (); |
|
268 | - $end_date = date ( $year . "-" . $month . "-" . $end_day . ' H:i:s' ); |
|
269 | - $end_date = date ( 'Y-m-d', strtotime ( $end_date ) + $gmtoffset ); |
|
270 | - $json_data = array (); |
|
271 | - $result = $this->dashboard_model->get_customer_maximum_callcount ( $start_date, $end_date ); |
|
272 | - $accountinfo = $this->session->userdata ( 'accountinfo' ); |
|
262 | + $post = $this->input->post(); |
|
263 | + $year = isset ($post ['year']) && $post ['year'] > 0 ? $post ['year'] : date("Y"); |
|
264 | + $month = isset ($post ['month']) && $post ['month'] > 0 ? $post ['month'] : date("m"); |
|
265 | + $start_date = date($year.'-'.$month.'-01'); |
|
266 | + $end_day = $year == date("Y") && $month == date("m") ? date ("d") : cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
267 | + $gmtoffset = $this->common->get_timezone_offset(); |
|
268 | + $end_date = date($year."-".$month."-".$end_day.' H:i:s'); |
|
269 | + $end_date = date('Y-m-d', strtotime($end_date) + $gmtoffset); |
|
270 | + $json_data = array(); |
|
271 | + $result = $this->dashboard_model->get_customer_maximum_callcount($start_date, $end_date); |
|
272 | + $accountinfo = $this->session->userdata('accountinfo'); |
|
273 | 273 | $reseller_id = ($accountinfo ['type'] == - 1 or $accountinfo ['type'] == 2) ? 0 : $accountinfo ['id']; |
274 | - if ($this->session->userdata ( 'userlevel_logintype' ) != 0 && $this->session->userdata ( 'userlevel_logintype' ) != 3) { |
|
275 | - $account_arr = $this->common->get_array ( 'id,number,first_name,last_name', 'accounts', array ( |
|
274 | + if ($this->session->userdata('userlevel_logintype') != 0 && $this->session->userdata('userlevel_logintype') != 3) { |
|
275 | + $account_arr = $this->common->get_array('id,number,first_name,last_name', 'accounts', array( |
|
276 | 276 | 'reseller_id' => $reseller_id |
277 | - ) ); |
|
277 | + )); |
|
278 | 278 | } else { |
279 | - $account_arr = $this->common->get_array ( 'id,number,first_name,last_name', 'accounts', array ( |
|
279 | + $account_arr = $this->common->get_array('id,number,first_name,last_name', 'accounts', array( |
|
280 | 280 | 'id' => $reseller_id |
281 | - ) ); |
|
281 | + )); |
|
282 | 282 | } |
283 | 283 | $i = 0; |
284 | - if ($result->num_rows () > 0) { |
|
285 | - foreach ( $result->result_array () as $data ) { |
|
286 | - $data ['accountid'] = ($data ['accountid'] != '' && isset ( $account_arr [$data ['accountid']] )) ? $account_arr [$data ['accountid']] : "Anonymous"; |
|
284 | + if ($result->num_rows() > 0) { |
|
285 | + foreach ($result->result_array() as $data) { |
|
286 | + $data ['accountid'] = ($data ['accountid'] != '' && isset ($account_arr [$data ['accountid']])) ? $account_arr [$data ['accountid']] : "Anonymous"; |
|
287 | 287 | $json_data [$i] [] = $data ['accountid']; |
288 | - $json_data [$i] [] = ( int ) $data ['call_count']; |
|
289 | - $i ++; |
|
288 | + $json_data [$i] [] = (int)$data ['call_count']; |
|
289 | + $i++; |
|
290 | 290 | } |
291 | 291 | } else { |
292 | - $json_data [] = array (); |
|
292 | + $json_data [] = array(); |
|
293 | 293 | } |
294 | - echo json_encode ( $json_data ); |
|
294 | + echo json_encode($json_data); |
|
295 | 295 | } |
296 | 296 | } |
297 | 297 |
@@ -32,8 +32,9 @@ discard block |
||
32 | 32 | $this->load->library ( 'freeswitch_lib' ); |
33 | 33 | } |
34 | 34 | function index() { |
35 | - if ($this->session->userdata ( 'user_login' ) == FALSE) |
|
36 | - redirect ( base_url () . 'login/login' ); |
|
35 | + if ($this->session->userdata ( 'user_login' ) == FALSE) { |
|
36 | + redirect ( base_url () . 'login/login' ); |
|
37 | + } |
|
37 | 38 | $data ['page_title'] = gettext ( 'Dashboard' ); |
38 | 39 | if ($this->session->userdata ( 'logintype' ) == 0) { |
39 | 40 | $this->load->view ( 'view_user_dashboard', $data ); |
@@ -149,7 +150,7 @@ discard block |
||
149 | 150 | $acc_arr[$data['day']]['completed']= $data['completed']+$acc_arr[$data['day']]['completed']; |
150 | 151 | $acc_arr[$data['day']]['duration'] = $data['duration']+$acc_arr[$data['day']]['duration']; |
151 | 152 | $acc_arr[$data['day']]['mcd'] =$data['mcd'] > $acc_arr[$data['day']]['mcd'] ? $data['mcd']: $acc_arr[$data['day']]['mcd']; |
152 | - }else{ |
|
153 | + } else{ |
|
153 | 154 | $acc_arr[$data['day']]=$data; |
154 | 155 | } |
155 | 156 | $reseller_total_result['sum']+= $data['sum']; |
@@ -180,7 +181,7 @@ discard block |
||
180 | 181 | $json_data['acd'][]=array((string)$acc_arr[$day]['day'],(float)$acd); |
181 | 182 | $json_data['mcd'][]=array((string)$acc_arr[$day]['day'],(float)$acc_arr[$day]['mcd']); |
182 | 183 | $json_data['asr'][]=array((string)$acc_arr[$day]['day'],(float)$asr); |
183 | - }else{ |
|
184 | + } else{ |
|
184 | 185 | $json_data['total'][]= array($date->format("d"), 0); |
185 | 186 | $json_data['answered'][]= array($date->format("d"), 0); |
186 | 187 | $json_data['failed'][]= array($date->format("d"), 0); |
@@ -22,53 +22,53 @@ discard block |
||
22 | 22 | // ############################################################################## |
23 | 23 | class Invoices_model extends CI_Model { |
24 | 24 | function Invoices_model() { |
25 | - parent::__construct (); |
|
25 | + parent::__construct(); |
|
26 | 26 | } |
27 | 27 | function get_invoice_list($flag, $start = 100, $limit = 100) { |
28 | - $where = array (); |
|
28 | + $where = array(); |
|
29 | 29 | |
30 | - $accountinfo = $this->session->userdata ( 'accountinfo' ); |
|
30 | + $accountinfo = $this->session->userdata('accountinfo'); |
|
31 | 31 | $reseller_id = $accountinfo ['type'] == - 1 ? 0 : $accountinfo ['id']; |
32 | - $this->db->where ( 'reseller_id', $reseller_id ); |
|
33 | - $this->db->select ( 'id' ); |
|
34 | - $result = $this->db->get ( 'accounts' ); |
|
32 | + $this->db->where('reseller_id', $reseller_id); |
|
33 | + $this->db->select('id'); |
|
34 | + $result = $this->db->get('accounts'); |
|
35 | 35 | |
36 | - $this->db_model->build_search ( 'invoice_list_search' ); |
|
36 | + $this->db_model->build_search('invoice_list_search'); |
|
37 | 37 | /** |
38 | 38 | * ** |
39 | 39 | * Invoice manually |
40 | 40 | * * |
41 | 41 | */ |
42 | 42 | |
43 | - if ($this->session->userdata ( 'advance_search' ) != 1) { |
|
44 | - if ($result->num_rows () > 0) { |
|
45 | - $acc_arr = array (); |
|
46 | - $result = $result->result_array (); |
|
47 | - foreach ( $result as $data ) { |
|
43 | + if ($this->session->userdata('advance_search') != 1) { |
|
44 | + if ($result->num_rows() > 0) { |
|
45 | + $acc_arr = array(); |
|
46 | + $result = $result->result_array(); |
|
47 | + foreach ($result as $data) { |
|
48 | 48 | $acc_arr [] = $data ['id']; |
49 | 49 | } |
50 | - $this->db->where_in ( 'accountid', $acc_arr ); |
|
51 | - $this->db->where ( 'deleted', 0 ); |
|
50 | + $this->db->where_in('accountid', $acc_arr); |
|
51 | + $this->db->where('deleted', 0); |
|
52 | 52 | if ($flag) { |
53 | - $this->db->select ( '*' ); |
|
53 | + $this->db->select('*'); |
|
54 | 54 | } else { |
55 | - $this->db->select ( 'count(id) as count' ); |
|
55 | + $this->db->select('count(id) as count'); |
|
56 | 56 | } |
57 | 57 | if ($flag) { |
58 | - $this->db->order_by ( 'invoice_date', 'desc' ); |
|
59 | - $this->db->limit ( $limit, $start ); |
|
58 | + $this->db->order_by('invoice_date', 'desc'); |
|
59 | + $this->db->limit($limit, $start); |
|
60 | 60 | } |
61 | - $result = $this->db->get ( 'invoices' ); |
|
61 | + $result = $this->db->get('invoices'); |
|
62 | 62 | // echo $this->db->last_query();exit; |
63 | 63 | if ($flag) { |
64 | 64 | return $result; |
65 | 65 | } else { |
66 | - $result = $result->result_array (); |
|
66 | + $result = $result->result_array(); |
|
67 | 67 | return $result [0] ['count']; |
68 | 68 | } |
69 | 69 | } else { |
70 | 70 | if ($flag) { |
71 | - $query = ( object ) array ( |
|
71 | + $query = (object)array( |
|
72 | 72 | 'num_rows' => 0 |
73 | 73 | ); |
74 | 74 | } else { |
@@ -79,44 +79,44 @@ discard block |
||
79 | 79 | } |
80 | 80 | } else { |
81 | 81 | |
82 | - if ($result->num_rows () > 0) { |
|
82 | + if ($result->num_rows() > 0) { |
|
83 | 83 | /** |
84 | 84 | * ** |
85 | 85 | * Invoice manually |
86 | 86 | * * |
87 | 87 | */ |
88 | - $acc_arr = array (); |
|
89 | - $result = $result->result_array (); |
|
90 | - foreach ( $result as $data ) { |
|
88 | + $acc_arr = array(); |
|
89 | + $result = $result->result_array(); |
|
90 | + foreach ($result as $data) { |
|
91 | 91 | $acc_arr [] = $data ['id']; |
92 | 92 | } |
93 | - $this->db->where_in ( 'accountid', $acc_arr ); |
|
93 | + $this->db->where_in('accountid', $acc_arr); |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | if ($flag) { |
97 | - $this->db->select ( '*' ); |
|
97 | + $this->db->select('*'); |
|
98 | 98 | } else { |
99 | - $this->db->select ( 'count(id) as count' ); |
|
99 | + $this->db->select('count(id) as count'); |
|
100 | 100 | } |
101 | 101 | if ($flag) { |
102 | - $this->db->order_by ( 'invoice_date', 'desc' ); |
|
103 | - $this->db->limit ( $limit, $start ); |
|
102 | + $this->db->order_by('invoice_date', 'desc'); |
|
103 | + $this->db->limit($limit, $start); |
|
104 | 104 | } |
105 | - $result = $this->db->get ( 'invoices' ); |
|
105 | + $result = $this->db->get('invoices'); |
|
106 | 106 | // echo $this->db->last_query();exit; |
107 | - if ($result->num_rows () > 0) { |
|
107 | + if ($result->num_rows() > 0) { |
|
108 | 108 | if ($flag) { |
109 | 109 | |
110 | 110 | return $result; |
111 | 111 | } else { |
112 | - $result = $result->result_array (); |
|
112 | + $result = $result->result_array(); |
|
113 | 113 | |
114 | 114 | return $result [0] ['count']; |
115 | 115 | } |
116 | 116 | } else { |
117 | 117 | if ($flag) { |
118 | 118 | |
119 | - $query = ( object ) array ( |
|
119 | + $query = (object)array( |
|
120 | 120 | 'num_rows' => 0 |
121 | 121 | ); |
122 | 122 | // echo '<pre>'; print_r($query); |
@@ -128,110 +128,110 @@ discard block |
||
128 | 128 | } |
129 | 129 | } |
130 | 130 | function getCdrs_invoice($invoiceid) { |
131 | - $this->db->where ( 'invoiceid', $invoiceid ); |
|
132 | - $this->db->from ( 'cdrs' ); |
|
133 | - $query = $this->db->get (); |
|
131 | + $this->db->where('invoiceid', $invoiceid); |
|
132 | + $this->db->from('cdrs'); |
|
133 | + $query = $this->db->get(); |
|
134 | 134 | return $query; |
135 | 135 | } |
136 | 136 | function get_account_including_closed($accountdata) { |
137 | - $q = "SELECT * FROM accounts WHERE number = '" . $this->db->escape_str ( $accountdata ) . "'"; |
|
138 | - $query = $this->db->query ( $q ); |
|
139 | - if ($query->num_rows () > 0) { |
|
140 | - $row = $query->row_array (); |
|
137 | + $q = "SELECT * FROM accounts WHERE number = '".$this->db->escape_str($accountdata)."'"; |
|
138 | + $query = $this->db->query($q); |
|
139 | + if ($query->num_rows() > 0) { |
|
140 | + $row = $query->row_array(); |
|
141 | 141 | return $row; |
142 | 142 | } |
143 | - $q = "SELECT * FROM accounts WHERE accountid = '" . $this->db->escape_str ( $accountdata ) . "'"; |
|
144 | - $query = $this->db->query ( $q ); |
|
145 | - if ($query->num_rows () > 0) { |
|
146 | - $row = $query->row_array (); |
|
143 | + $q = "SELECT * FROM accounts WHERE accountid = '".$this->db->escape_str($accountdata)."'"; |
|
144 | + $query = $this->db->query($q); |
|
145 | + if ($query->num_rows() > 0) { |
|
146 | + $row = $query->row_array(); |
|
147 | 147 | return $row; |
148 | 148 | } |
149 | 149 | |
150 | 150 | return NULL; |
151 | 151 | } |
152 | 152 | function get_user_invoice_list($flag, $start = 0, $limit = 0) { |
153 | - $this->db_model->build_search ( 'invoice_list_search' ); |
|
154 | - $accountinfo = $this->session->userdata ( 'accountinfo' ); |
|
153 | + $this->db_model->build_search('invoice_list_search'); |
|
154 | + $accountinfo = $this->session->userdata('accountinfo'); |
|
155 | 155 | /** |
156 | 156 | * ** |
157 | 157 | * Invoice manually |
158 | 158 | * * |
159 | 159 | */ |
160 | - $where = array ( |
|
160 | + $where = array( |
|
161 | 161 | "accountid" => $accountinfo ['id'], |
162 | 162 | 'confirm' => 1 |
163 | 163 | ); |
164 | 164 | if ($flag) { |
165 | - $query = $this->db_model->select ( "*", "invoices", $where, "invoice_date", "desc", $limit, $start ); |
|
165 | + $query = $this->db_model->select("*", "invoices", $where, "invoice_date", "desc", $limit, $start); |
|
166 | 166 | } else { |
167 | - $query = $this->db_model->countQuery ( "*", "invoices", $where ); |
|
167 | + $query = $this->db_model->countQuery("*", "invoices", $where); |
|
168 | 168 | } |
169 | 169 | // echo $this->db->last_query();exit; |
170 | 170 | return $query; |
171 | 171 | } |
172 | 172 | // 22_1 |
173 | 173 | function getinvoiceconf_list($flag, $start = 0, $limit = 0) { |
174 | - $where = array (); |
|
175 | - $logintype = $this->session->userdata ( 'logintype' ); |
|
174 | + $where = array(); |
|
175 | + $logintype = $this->session->userdata('logintype'); |
|
176 | 176 | |
177 | 177 | if ($logintype == 1 || $logintype == 5) { |
178 | 178 | |
179 | - $where = array ( |
|
179 | + $where = array( |
|
180 | 180 | "accountid" => $this->session->userdata ["accountinfo"] ['id'] |
181 | 181 | ); |
182 | 182 | } |
183 | 183 | |
184 | 184 | if ($flag) { |
185 | - $query = $this->db_model->select ( "*", "invoice_conf", $where, "id", "ASC", $limit, $start ); |
|
185 | + $query = $this->db_model->select("*", "invoice_conf", $where, "id", "ASC", $limit, $start); |
|
186 | 186 | } else { |
187 | - $query = $this->db_model->countQuery ( "*", "invoice_conf", $where ); |
|
187 | + $query = $this->db_model->countQuery("*", "invoice_conf", $where); |
|
188 | 188 | } |
189 | 189 | // echo $this->db->last_query(); |
190 | 190 | return $query; |
191 | 191 | } |
192 | 192 | function get_invoiceconf($accountid) { |
193 | - $return_array = array (); |
|
194 | - $logintype = $this->session->userdata ( 'logintype' ); |
|
193 | + $return_array = array(); |
|
194 | + $logintype = $this->session->userdata('logintype'); |
|
195 | 195 | if ($logintype == 1 || $logintype == 5) { |
196 | 196 | |
197 | - $where = array ( |
|
197 | + $where = array( |
|
198 | 198 | "accountid" => $this->session->userdata ["accountinfo"] ['id'] |
199 | 199 | ); |
200 | 200 | } else { |
201 | 201 | if ($logintype == - 1 || $logintype == 2) { |
202 | 202 | $accountid = '1'; |
203 | 203 | } |
204 | - $where = array ( |
|
204 | + $where = array( |
|
205 | 205 | 'id' => $accountid |
206 | 206 | ); |
207 | 207 | } |
208 | - $query = $this->db_model->getSelect ( "*", "invoice_conf", $where ); |
|
209 | - foreach ( $query->result_array () as $key => $value ) { |
|
208 | + $query = $this->db_model->getSelect("*", "invoice_conf", $where); |
|
209 | + foreach ($query->result_array() as $key => $value) { |
|
210 | 210 | $return_array = $value; |
211 | 211 | } |
212 | 212 | return $return_array; |
213 | 213 | } |
214 | 214 | function save_invoiceconf($post_array) { |
215 | - $where_arr = array ( |
|
215 | + $where_arr = array( |
|
216 | 216 | 'id' => $post_array ['id'] |
217 | 217 | ); |
218 | - unset ( $post_array ['action'] ); |
|
218 | + unset ($post_array ['action']); |
|
219 | 219 | if ($post_array ['id'] != "") { |
220 | - $this->db->where ( $where_arr ); |
|
221 | - unset ( $post_array ['accountid'] ); |
|
222 | - unset ( $post_array ['logo_main'] ); |
|
223 | - $this->db->update ( 'invoice_conf', $post_array ); |
|
220 | + $this->db->where($where_arr); |
|
221 | + unset ($post_array ['accountid']); |
|
222 | + unset ($post_array ['logo_main']); |
|
223 | + $this->db->update('invoice_conf', $post_array); |
|
224 | 224 | } else { |
225 | - unset ( $post_array ['logo_main'] ); |
|
226 | - $logintype = $this->session->userdata ( 'logintype' ); |
|
225 | + unset ($post_array ['logo_main']); |
|
226 | + $logintype = $this->session->userdata('logintype'); |
|
227 | 227 | if ($logintype == 1 || $logintype == 5) { |
228 | - $accountdata = $this->session->userdata ( 'accountinfo' ); |
|
228 | + $accountdata = $this->session->userdata('accountinfo'); |
|
229 | 229 | $post_array ['accountid'] = $accountdata ['id']; |
230 | 230 | } |
231 | 231 | if ($post_array ['accountid'] == 0) { |
232 | 232 | $post_array ['accountid'] = 1; |
233 | 233 | } |
234 | - $this->db->insert ( 'invoice_conf', $post_array ); |
|
234 | + $this->db->insert('invoice_conf', $post_array); |
|
235 | 235 | } |
236 | 236 | return true; |
237 | 237 | } |
@@ -22,93 +22,93 @@ discard block |
||
22 | 22 | // ############################################################################## |
23 | 23 | class Invoices extends MX_Controller { |
24 | 24 | function Invoices() { |
25 | - parent::__construct (); |
|
25 | + parent::__construct(); |
|
26 | 26 | |
27 | - $this->load->helper ( 'template_inheritance' ); |
|
27 | + $this->load->helper('template_inheritance'); |
|
28 | 28 | |
29 | - $this->load->library ( 'session' ); |
|
30 | - $this->load->library ( 'invoices_form' ); |
|
31 | - $this->load->library ( 'astpp/form' ); |
|
32 | - $this->load->model ( 'invoices_model' ); |
|
33 | - $this->load->model ( 'Astpp_common' ); |
|
34 | - $this->load->model ( 'common_model' ); |
|
35 | - $this->load->library ( "astpp/email_lib" ); |
|
36 | - $this->load->library ( 'fpdf' ); |
|
37 | - $this->load->library ( 'pdf' ); |
|
29 | + $this->load->library('session'); |
|
30 | + $this->load->library('invoices_form'); |
|
31 | + $this->load->library('astpp/form'); |
|
32 | + $this->load->model('invoices_model'); |
|
33 | + $this->load->model('Astpp_common'); |
|
34 | + $this->load->model('common_model'); |
|
35 | + $this->load->library("astpp/email_lib"); |
|
36 | + $this->load->library('fpdf'); |
|
37 | + $this->load->library('pdf'); |
|
38 | 38 | |
39 | - if ($this->session->userdata ( 'user_login' ) == FALSE) |
|
40 | - redirect ( base_url () . '/astpp/login' ); |
|
39 | + if ($this->session->userdata('user_login') == FALSE) |
|
40 | + redirect(base_url().'/astpp/login'); |
|
41 | 41 | } |
42 | 42 | function invoice_list() { |
43 | - $data ['username'] = $this->session->userdata ( 'user_name' ); |
|
44 | - $data ['page_title'] = gettext ( 'Invoices' ); |
|
43 | + $data ['username'] = $this->session->userdata('user_name'); |
|
44 | + $data ['page_title'] = gettext('Invoices'); |
|
45 | 45 | $data ['login_type'] = $this->session->userdata ['userlevel_logintype']; |
46 | 46 | $data ['search_flag'] = true; |
47 | - $this->session->set_userdata ( 'advance_search', 0 ); |
|
48 | - $data ['grid_fields'] = $this->invoices_form->build_invoices_list_for_admin (); |
|
49 | - $data ["grid_buttons"] = $this->invoices_form->build_grid_buttons (); |
|
50 | - $data ['form_search'] = $this->form->build_serach_form ( $this->invoices_form->get_invoice_search_form () ); |
|
51 | - $account = $this->db_model->getSelect ( 'id,first_name,last_name,number', 'accounts', array ( |
|
47 | + $this->session->set_userdata('advance_search', 0); |
|
48 | + $data ['grid_fields'] = $this->invoices_form->build_invoices_list_for_admin(); |
|
49 | + $data ["grid_buttons"] = $this->invoices_form->build_grid_buttons(); |
|
50 | + $data ['form_search'] = $this->form->build_serach_form($this->invoices_form->get_invoice_search_form()); |
|
51 | + $account = $this->db_model->getSelect('id,first_name,last_name,number', 'accounts', array( |
|
52 | 52 | 'status' => 0, |
53 | 53 | 'type' => '0,3', |
54 | 54 | 'deleted' => 0 |
55 | - ) ); |
|
56 | - $data ['account_value'] = $account->result_array (); |
|
57 | - $this->load->view ( 'view_invoices_list', $data ); |
|
55 | + )); |
|
56 | + $data ['account_value'] = $account->result_array(); |
|
57 | + $this->load->view('view_invoices_list', $data); |
|
58 | 58 | } |
59 | 59 | // /*ASTPP_invoice_changes_05_05_start*/ |
60 | 60 | function invoice_list_json() { |
61 | - $login_info = $this->session->userdata ( 'accountinfo' ); |
|
62 | - $logintype = $this->session->userdata ( 'logintype' ); |
|
63 | - $json_data = array (); |
|
64 | - $count_all = $this->invoices_model->get_invoice_list ( false ); |
|
65 | - $paging_data = $this->form->load_grid_config ( $count_all, $_GET ['rp'], $_GET ['page'] ); |
|
61 | + $login_info = $this->session->userdata('accountinfo'); |
|
62 | + $logintype = $this->session->userdata('logintype'); |
|
63 | + $json_data = array(); |
|
64 | + $count_all = $this->invoices_model->get_invoice_list(false); |
|
65 | + $paging_data = $this->form->load_grid_config($count_all, $_GET ['rp'], $_GET ['page']); |
|
66 | 66 | $json_data = $paging_data ["json_paging"]; |
67 | - $result_query = $this->invoices_model->get_invoice_list ( true, $paging_data ["paging"] ["start"], $paging_data ["paging"] ["page_no"] ); |
|
67 | + $result_query = $this->invoices_model->get_invoice_list(true, $paging_data ["paging"] ["start"], $paging_data ["paging"] ["page_no"]); |
|
68 | 68 | if ($logintype == - 1) { |
69 | 69 | $currency_id = Common_model::$global_config ['system_config'] ['base_currency']; |
70 | 70 | } else { |
71 | - $accountdata ["currency_id"] = $this->common->get_field_name ( 'currency', 'currency', $login_info ["currency_id"] ); |
|
71 | + $accountdata ["currency_id"] = $this->common->get_field_name('currency', 'currency', $login_info ["currency_id"]); |
|
72 | 72 | $currency_id = $accountdata ["currency_id"]; |
73 | 73 | } |
74 | - $grid_fields = json_decode ( $this->invoices_form->build_invoices_list_for_admin () ); |
|
74 | + $grid_fields = json_decode($this->invoices_form->build_invoices_list_for_admin()); |
|
75 | 75 | $url = ($logintype == 0 || $logintype == 3) ? "/user/user_invoice_download/" : '/invoices/invoice_download/'; |
76 | 76 | if ($result_query->num_rows > 0) { |
77 | - $query = $result_query->result_array (); |
|
77 | + $query = $result_query->result_array(); |
|
78 | 78 | $total_value = 0; |
79 | 79 | $ountstanding_value = 0; |
80 | - foreach ( $query as $key => $value ) { |
|
80 | + foreach ($query as $key => $value) { |
|
81 | 81 | $delete_button = ''; |
82 | - $date = strtotime ( $value ['invoice_date'] ); |
|
83 | - $invoice_date = date ( "Y-m-d", $date ); |
|
84 | - $fromdate = strtotime ( $value ['from_date'] ); |
|
85 | - $from_date = date ( "Y-m-d", $fromdate ); |
|
86 | - $duedate = strtotime ( $value ['due_date'] ); |
|
82 | + $date = strtotime($value ['invoice_date']); |
|
83 | + $invoice_date = date("Y-m-d", $date); |
|
84 | + $fromdate = strtotime($value ['from_date']); |
|
85 | + $from_date = date("Y-m-d", $fromdate); |
|
86 | + $duedate = strtotime($value ['due_date']); |
|
87 | 87 | if ($value ['type'] == 'I') { |
88 | - $due_date = date ( "Y-m-d", $duedate ); |
|
88 | + $due_date = date("Y-m-d", $duedate); |
|
89 | 89 | } else { |
90 | 90 | $due_date = ''; |
91 | 91 | } |
92 | 92 | $outstanding = $value ['amount']; |
93 | 93 | $last_payment_date = ''; |
94 | - $invoice_total_query = $this->db_model->select ( "sum(debit) as debit,sum(credit) as credit,created_date", "invoice_details", array ( |
|
94 | + $invoice_total_query = $this->db_model->select("sum(debit) as debit,sum(credit) as credit,created_date", "invoice_details", array( |
|
95 | 95 | "invoiceid" => $value ['id'], |
96 | 96 | "item_type" => "INVPAY" |
97 | - ), "created_date", "DESC", "1", "0" ); |
|
97 | + ), "created_date", "DESC", "1", "0"); |
|
98 | 98 | // echo $this->db->last_query(); exit; |
99 | - if ($invoice_total_query->num_rows () > 0) { |
|
100 | - $invoice_total_query = $invoice_total_query->result_array (); |
|
99 | + if ($invoice_total_query->num_rows() > 0) { |
|
100 | + $invoice_total_query = $invoice_total_query->result_array(); |
|
101 | 101 | // echo '<pre>'; print_r($invoice_total_query); |
102 | 102 | if ($value ['type'] == 'I') { |
103 | - $outstanding -= $this->common->currency_decimal ( $invoice_total_query [0] ['credit'] ); |
|
103 | + $outstanding -= $this->common->currency_decimal($invoice_total_query [0] ['credit']); |
|
104 | 104 | } else { |
105 | 105 | $outstanding = ''; |
106 | 106 | } |
107 | 107 | $last_payment_date = $invoice_total_query [0] ['created_date']; |
108 | 108 | if ($value ['type'] == 'I') { |
109 | 109 | if ($last_payment_date) { |
110 | - $payment_date = strtotime ( $last_payment_date ); |
|
111 | - $payment_last = date ( "Y-m-d", $payment_date ); |
|
110 | + $payment_date = strtotime($last_payment_date); |
|
111 | + $payment_last = date("Y-m-d", $payment_date); |
|
112 | 112 | } else { |
113 | 113 | $payment_last = ''; |
114 | 114 | } |
@@ -118,18 +118,18 @@ discard block |
||
118 | 118 | } |
119 | 119 | |
120 | 120 | $invoice_total = ''; |
121 | - $accountinfo = $this->session->userdata ( 'accountinfo' ); |
|
121 | + $accountinfo = $this->session->userdata('accountinfo'); |
|
122 | 122 | $id = $accountinfo ['id']; |
123 | 123 | if ($accountinfo ['type'] == 1) { |
124 | 124 | $query = "select sum(amount) as grand_total from invoices where reseller_id='$id'"; |
125 | 125 | } else { |
126 | 126 | $query = "select sum(amount) as grand_total from invoices where reseller_id='0'"; |
127 | 127 | } |
128 | - $ext_query = $this->db->query ( $query ); |
|
129 | - if ($ext_query->num_rows () > 0) { |
|
130 | - $result_total = $ext_query->result_array (); |
|
128 | + $ext_query = $this->db->query($query); |
|
129 | + if ($ext_query->num_rows() > 0) { |
|
130 | + $result_total = $ext_query->result_array(); |
|
131 | 131 | $grandtotal = $result_total [0] ['grand_total']; |
132 | - $grand_total = $this->common->currency_decimal ( $grandtotal ) . ' ' . $currency_id; |
|
132 | + $grand_total = $this->common->currency_decimal($grandtotal).' '.$currency_id; |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | if ($accountinfo ['type'] == 1) { |
@@ -137,26 +137,26 @@ discard block |
||
137 | 137 | } else { |
138 | 138 | $invoice_query = "select sum(credit) as grand_credit from invoice_details where reseller_id='0'"; |
139 | 139 | } |
140 | - $credit_query = $this->db->query ( $invoice_query ); |
|
141 | - if ($credit_query->num_rows () > 0) { |
|
142 | - $credit_total = $credit_query->result_array (); |
|
140 | + $credit_query = $this->db->query($invoice_query); |
|
141 | + if ($credit_query->num_rows() > 0) { |
|
142 | + $credit_total = $credit_query->result_array(); |
|
143 | 143 | $grand_credit_total = $credit_total [0] ['grand_credit']; |
144 | 144 | $grandcredit = $grand_total - $grand_credit_total; |
145 | - $grand_credit = $this->common->currency_decimal ( $grandcredit ) . ' ' . $currency_id; |
|
145 | + $grand_credit = $this->common->currency_decimal($grandcredit).' '.$currency_id; |
|
146 | 146 | } |
147 | - $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> "; |
|
147 | + $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> "; |
|
148 | 148 | if ($value ['type'] == 'I') { |
149 | 149 | if ($value ['confirm'] == 0) { |
150 | 150 | if ($value ['generate_type'] == 1) { |
151 | - $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>'; |
|
151 | + $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>'; |
|
152 | 152 | } else { |
153 | - $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>'; |
|
153 | + $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>'; |
|
154 | 154 | } |
155 | 155 | $id = $value ['id']; |
156 | 156 | $delete_button = "<a onclick='invoice_delete($id)' class='btn btn-royelblue btn-sm' title='Delete' ><i class='fa fa-trash fa-fw'></i></a> "; |
157 | 157 | } else { |
158 | 158 | if ($outstanding > 0) { |
159 | - $payment = '<a style="padding: 0 8px;" href="' . base_url () . 'invoices/invoice_summary/' . $value ['id'] . '" class="btn btn-warning" title="Payment">Unpaid</i></a>'; |
|
159 | + $payment = '<a style="padding: 0 8px;" href="'.base_url().'invoices/invoice_summary/'.$value ['id'].'" class="btn btn-warning" title="Payment">Unpaid</i></a>'; |
|
160 | 160 | } else { |
161 | 161 | $payment = '<button style="padding: 0 17px;" type="button" class="btn btn-success">Paid</button>'; |
162 | 162 | } |
@@ -165,10 +165,10 @@ discard block |
||
165 | 165 | } else { |
166 | 166 | $payment = ''; |
167 | 167 | } |
168 | - $account_arr = $this->db_model->getSelect ( 'first_name,number,last_name', 'accounts', array ( |
|
168 | + $account_arr = $this->db_model->getSelect('first_name,number,last_name', 'accounts', array( |
|
169 | 169 | 'id' => $value ['accountid'] |
170 | - ) ); |
|
171 | - $account_array = $account_arr->result_array (); |
|
170 | + )); |
|
171 | + $account_array = $account_arr->result_array(); |
|
172 | 172 | if ($value ['generate_type'] == 1) { |
173 | 173 | $invoice_type = 'Manually'; |
174 | 174 | } else { |
@@ -191,20 +191,20 @@ discard block |
||
191 | 191 | $icon = '<div class="flx_font flx_drk_pink">I</div>'; |
192 | 192 | } |
193 | 193 | |
194 | - $json_data ['rows'] [] = array ( |
|
195 | - 'cell' => array ( |
|
194 | + $json_data ['rows'] [] = array( |
|
195 | + 'cell' => array( |
|
196 | 196 | |
197 | - $value ['invoice_prefix'] . $value ['invoiceid'] . $icon, |
|
197 | + $value ['invoice_prefix'].$value ['invoiceid'].$icon, |
|
198 | 198 | // $value['invoice_prefix'].$value['invoiceid'].'('.$value['type'].')', |
199 | 199 | $invoice_type, |
200 | - $account_array [0] ['first_name'] . ' ' . $account_array [0] ['last_name'] . '</br>' . $account_array [0] ['number'], |
|
200 | + $account_array [0] ['first_name'].' '.$account_array [0] ['last_name'].'</br>'.$account_array [0] ['number'], |
|
201 | 201 | $invoice_date, |
202 | 202 | $from_date, |
203 | 203 | $due_date, |
204 | 204 | $payment_last, |
205 | - $this->common->currency_decimal ( $this->common_model->calculate_currency ( $value ['amount'] ) ), |
|
206 | - $this->common->currency_decimal ( $this->common_model->calculate_currency ( $outstanding ) ), |
|
207 | - $download . '' . $payment . ' ' . $delete_button |
|
205 | + $this->common->currency_decimal($this->common_model->calculate_currency($value ['amount'])), |
|
206 | + $this->common->currency_decimal($this->common_model->calculate_currency($outstanding)), |
|
207 | + $download.''.$payment.' '.$delete_button |
|
208 | 208 | ) |
209 | 209 | |
210 | 210 | ); |
@@ -212,80 +212,80 @@ discard block |
||
212 | 212 | $ountstanding_value = $ountstanding_value + $outstanding; |
213 | 213 | } |
214 | 214 | } |
215 | - echo json_encode ( $json_data ); |
|
215 | + echo json_encode($json_data); |
|
216 | 216 | } |
217 | 217 | // end |
218 | 218 | function invoice_manually_edit($id) { |
219 | - $confirm = $this->common->get_field_name ( 'confirm', 'invoices', $id ); |
|
220 | - $deleted = $this->common->get_field_name ( 'deleted', 'invoices', $id ); |
|
219 | + $confirm = $this->common->get_field_name('confirm', 'invoices', $id); |
|
220 | + $deleted = $this->common->get_field_name('deleted', 'invoices', $id); |
|
221 | 221 | if ($confirm == 1 || $deleted == 1) { |
222 | - redirect ( base_url () . 'invoices/invoice_list/' ); |
|
222 | + redirect(base_url().'invoices/invoice_list/'); |
|
223 | 223 | } |
224 | 224 | $data ['total_tax_dis'] = 0; |
225 | 225 | $data ['total_credit_dis'] = 0; |
226 | 226 | $query = "SELECT * from invoice_details where generate_type=1 AND invoiceid='$id' "; |
227 | - $invoice_total_query = $this->db->query ( $query ); |
|
227 | + $invoice_total_query = $this->db->query($query); |
|
228 | 228 | $data ['count'] = 0; |
229 | 229 | $data ['row_count'] = 5; |
230 | - if ($invoice_total_query->num_rows () > 0) { |
|
231 | - $count = $invoice_total_query->num_rows (); |
|
230 | + if ($invoice_total_query->num_rows() > 0) { |
|
231 | + $count = $invoice_total_query->num_rows(); |
|
232 | 232 | $data ['count'] = $count; |
233 | - $invoice_total_query = $invoice_total_query->result_array (); |
|
233 | + $invoice_total_query = $invoice_total_query->result_array(); |
|
234 | 234 | $i = 1; |
235 | 235 | $taxi = 0; |
236 | - $get_data = array (); |
|
237 | - $data ['total_tax_dis'] = array (); |
|
238 | - foreach ( $invoice_total_query as $value ) { |
|
236 | + $get_data = array(); |
|
237 | + $data ['total_tax_dis'] = array(); |
|
238 | + foreach ($invoice_total_query as $value) { |
|
239 | 239 | if ($value ['item_type'] == 'TAX') { |
240 | 240 | $data ['total_tax_dis'] [$taxi] = $value ['debit']; |
241 | - $taxi ++; |
|
241 | + $taxi++; |
|
242 | 242 | } else { |
243 | 243 | if ($i >= 5) { |
244 | 244 | $data ['row_count'] = $i + 1; |
245 | 245 | } |
246 | - $get_data ['invoice_from_date_' . $i] = $value ['created_date']; |
|
247 | - $get_data ['invoice_description_' . $i] = $value ['description']; |
|
248 | - $get_data ['invoice_amount_' . $i] = $value ['debit']; |
|
249 | - $i ++; |
|
246 | + $get_data ['invoice_from_date_'.$i] = $value ['created_date']; |
|
247 | + $get_data ['invoice_description_'.$i] = $value ['description']; |
|
248 | + $get_data ['invoice_amount_'.$i] = $value ['debit']; |
|
249 | + $i++; |
|
250 | 250 | $data ['total_credit_dis'] += $value ['debit']; |
251 | 251 | } |
252 | 252 | } |
253 | 253 | $data ['get_data'] = $get_data; |
254 | 254 | } |
255 | - $account_data = $this->session->userdata ( "accountinfo" ); |
|
256 | - $logintype = $this->session->userdata ( 'logintype' ); |
|
255 | + $account_data = $this->session->userdata("accountinfo"); |
|
256 | + $logintype = $this->session->userdata('logintype'); |
|
257 | 257 | $invoice_total = ''; |
258 | 258 | $query = "SELECT * from invoice_details where item_type='INVPAY' AND invoiceid='$id' ORDER BY created_date ASC"; |
259 | - $invoice = $this->db_model->getSelect ( "*", "invoices", array ( |
|
259 | + $invoice = $this->db_model->getSelect("*", "invoices", array( |
|
260 | 260 | "id" => $id |
261 | - ) ); |
|
262 | - if ($invoice->num_rows () > 0) { |
|
263 | - $invoice = $invoice->result_array (); |
|
261 | + )); |
|
262 | + if ($invoice->num_rows() > 0) { |
|
263 | + $invoice = $invoice->result_array(); |
|
264 | 264 | $result = $invoice [0]; |
265 | 265 | $data ['payment_due_date'] = $result ['due_date']; |
266 | 266 | } |
267 | 267 | |
268 | - $accountdata = $this->db_model->getSelect ( "*", "accounts", array ( |
|
268 | + $accountdata = $this->db_model->getSelect("*", "accounts", array( |
|
269 | 269 | "id" => $result ['accountid'] |
270 | - ) ); |
|
271 | - if ($accountdata->num_rows () > 0) { |
|
272 | - $accountdata = $accountdata->result_array (); |
|
270 | + )); |
|
271 | + if ($accountdata->num_rows() > 0) { |
|
272 | + $accountdata = $accountdata->result_array(); |
|
273 | 273 | $accountdata = $accountdata [0]; |
274 | 274 | } |
275 | 275 | $data ['taxes_count'] = 0; |
276 | - $taxes = $this->db_model->getSelect ( "*", "taxes_to_accounts", array ( |
|
276 | + $taxes = $this->db_model->getSelect("*", "taxes_to_accounts", array( |
|
277 | 277 | "accountid" => $result ['accountid'] |
278 | - ) ); |
|
278 | + )); |
|
279 | 279 | $total_tax = 0; |
280 | - $data ['taxes_count'] = $taxes->num_rows (); |
|
281 | - if ($taxes->num_rows () > 0) { |
|
282 | - $taxes = $taxes->result_array (); |
|
283 | - foreach ( $taxes as $tax_value ) { |
|
284 | - $taxe_res = $this->db_model->getSelect ( "*", "taxes", array ( |
|
280 | + $data ['taxes_count'] = $taxes->num_rows(); |
|
281 | + if ($taxes->num_rows() > 0) { |
|
282 | + $taxes = $taxes->result_array(); |
|
283 | + foreach ($taxes as $tax_value) { |
|
284 | + $taxe_res = $this->db_model->getSelect("*", "taxes", array( |
|
285 | 285 | "id" => $tax_value ['taxes_id'] |
286 | - ) ); |
|
287 | - $taxe_res = $taxe_res->result_array (); |
|
288 | - foreach ( $taxe_res as $taxe_res_val ) { |
|
286 | + )); |
|
287 | + $taxe_res = $taxe_res->result_array(); |
|
288 | + foreach ($taxe_res as $taxe_res_val) { |
|
289 | 289 | $data ['taxes_to_accounts'] [] = $taxe_res_val; |
290 | 290 | $total_tax += $taxe_res_val ['taxes_rate']; |
291 | 291 | } |
@@ -300,18 +300,18 @@ discard block |
||
300 | 300 | $data ["paypal_url"] = $system_config ["paypal_sandbox_url"]; |
301 | 301 | $data ["paypal_email_id"] = $system_config ["paypal_sandbox_id"]; |
302 | 302 | } |
303 | - $date = strtotime ( $result ['invoice_date'] ); |
|
304 | - $data ['time'] = date ( "Y-m-d h:i:s ", $date ); |
|
303 | + $date = strtotime($result ['invoice_date']); |
|
304 | + $data ['time'] = date("Y-m-d h:i:s ", $date); |
|
305 | 305 | $data ["paypal_tax"] = $system_config ["paypal_tax"]; |
306 | - $data ["from_currency"] = $this->common->get_field_name ( 'currency', 'currency', $account_data ["currency_id"] ); |
|
306 | + $data ["from_currency"] = $this->common->get_field_name('currency', 'currency', $account_data ["currency_id"]); |
|
307 | 307 | $data ["to_currency"] = Common_model::$global_config ['system_config'] ['base_currency']; |
308 | 308 | if ($account_data ['type'] == - 1) { |
309 | 309 | $data ["to_currency"] = $data ["to_currency"]; |
310 | 310 | } elseif ($account_data ['type'] == 1) { |
311 | - $accountdata ["currency_id"] = $this->common->get_field_name ( 'currency', 'currency', $account_data ["currency_id"] ); |
|
311 | + $accountdata ["currency_id"] = $this->common->get_field_name('currency', 'currency', $account_data ["currency_id"]); |
|
312 | 312 | $data ["to_currency"] = $accountdata ["currency_id"]; |
313 | 313 | } else { |
314 | - $accountdata ["currency_id"] = $this->common->get_field_name ( 'currency', 'currency', $account_data ["currency_id"] ); |
|
314 | + $accountdata ["currency_id"] = $this->common->get_field_name('currency', 'currency', $account_data ["currency_id"]); |
|
315 | 315 | $data ["to_currency"] = $accountdata ["currency_id"]; |
316 | 316 | } |
317 | 317 | $data ['total_tax'] = $total_tax; |
@@ -319,60 +319,60 @@ discard block |
||
319 | 319 | $data ['from_date'] = $result ['from_date']; |
320 | 320 | $data ['to_date'] = $result ['to_date']; |
321 | 321 | $data ['invoice_date'] = $result ['invoice_date']; |
322 | - $data ['amount'] = $this->common_model->calculate_currency ( $result ['amount'], '', '', '', '' ); |
|
322 | + $data ['amount'] = $this->common_model->calculate_currency($result ['amount'], '', '', '', ''); |
|
323 | 323 | $data ['invoice_prefix'] = $result ['invoice_prefix']; |
324 | - $data ['page_title'] = gettext ( 'Invoice Summary' ); |
|
324 | + $data ['page_title'] = gettext('Invoice Summary'); |
|
325 | 325 | $data ['invoice_date'] = $result ['invoice_date']; |
326 | - $data ['return'] = base_url () . "invoices/invoice_list_modified"; |
|
327 | - $data ['cancel_return'] = base_url () . "invoice/invoice_list_cancel"; |
|
326 | + $data ['return'] = base_url()."invoices/invoice_list_modified"; |
|
327 | + $data ['cancel_return'] = base_url()."invoice/invoice_list_cancel"; |
|
328 | 328 | $data ['paypal_mode'] = 1; |
329 | 329 | $data ['prefix_id'] = $result ['invoiceid']; |
330 | 330 | $data ['logintype'] = $logintype; |
331 | 331 | $data ['accountdata'] = $accountdata; |
332 | 332 | $data ['id'] = $id; |
333 | - $data ['notify_url'] = base_url () . "invoices/invoice_list_get_data"; |
|
333 | + $data ['notify_url'] = base_url()."invoices/invoice_list_get_data"; |
|
334 | 334 | if ($account_data ['type'] == '1') { |
335 | - $data ['response_url'] = base_url () . "invoices/invoice_list_responce/"; |
|
335 | + $data ['response_url'] = base_url()."invoices/invoice_list_responce/"; |
|
336 | 336 | } else { |
337 | - $data ['response_url'] = base_url () . "user/user_list_responce/"; |
|
337 | + $data ['response_url'] = base_url()."user/user_list_responce/"; |
|
338 | 338 | } |
339 | - $data ['sucess_url'] = base_url () . "invoices/invoice_list_sucess"; |
|
340 | - $this->load->view ( 'view_invoice_edit_manually', $data ); |
|
339 | + $data ['sucess_url'] = base_url()."invoices/invoice_list_sucess"; |
|
340 | + $this->load->view('view_invoice_edit_manually', $data); |
|
341 | 341 | } |
342 | 342 | function invoice_automatically_edit($id) { |
343 | - $confirm = $this->common->get_field_name ( 'confirm', 'invoices', $id ); |
|
344 | - $deleted = $this->common->get_field_name ( 'deleted', 'invoices', $id ); |
|
343 | + $confirm = $this->common->get_field_name('confirm', 'invoices', $id); |
|
344 | + $deleted = $this->common->get_field_name('deleted', 'invoices', $id); |
|
345 | 345 | if ($confirm == 1 || $deleted == 1) { |
346 | - redirect ( base_url () . 'invoices/invoice_list/' ); |
|
346 | + redirect(base_url().'invoices/invoice_list/'); |
|
347 | 347 | } |
348 | 348 | $data ['total_tax_dis'] = 0; |
349 | 349 | $data ['total_credit_dis'] = 0; |
350 | 350 | $query = "SELECT * from invoice_details where invoiceid='$id' "; |
351 | - $invoice_total_query = $this->db->query ( $query ); |
|
351 | + $invoice_total_query = $this->db->query($query); |
|
352 | 352 | $data ['count'] = 0; |
353 | 353 | $data ['row_count'] = 5; |
354 | - if ($invoice_total_query->num_rows () > 0) { |
|
355 | - $count = $invoice_total_query->num_rows (); |
|
354 | + if ($invoice_total_query->num_rows() > 0) { |
|
355 | + $count = $invoice_total_query->num_rows(); |
|
356 | 356 | $data ['count'] = $count; |
357 | - $invoice_total_query = $invoice_total_query->result_array (); |
|
357 | + $invoice_total_query = $invoice_total_query->result_array(); |
|
358 | 358 | $i = 1; |
359 | 359 | $taxi = 0; |
360 | - $get_data = array (); |
|
361 | - $data ['total_tax_dis'] = array (); |
|
360 | + $get_data = array(); |
|
361 | + $data ['total_tax_dis'] = array(); |
|
362 | 362 | $data ['total_credit_sum'] = 0; |
363 | - foreach ( $invoice_total_query as $value ) { |
|
363 | + foreach ($invoice_total_query as $value) { |
|
364 | 364 | if ($value ['item_type'] == 'TAX') { |
365 | 365 | $data ['total_tax_dis'] [$taxi] = $value ['debit']; |
366 | - $taxi ++; |
|
366 | + $taxi++; |
|
367 | 367 | } else { |
368 | 368 | if ($value ['generate_type'] == 1) { |
369 | 369 | if ($i >= 5) { |
370 | 370 | $data ['row_count'] = $i + 1; |
371 | 371 | } |
372 | - $get_data ['invoice_from_date_' . $i] = $value ['created_date']; |
|
373 | - $get_data ['invoice_description_' . $i] = $value ['description']; |
|
374 | - $get_data ['invoice_amount_' . $i] = $value ['debit']; |
|
375 | - $i ++; |
|
372 | + $get_data ['invoice_from_date_'.$i] = $value ['created_date']; |
|
373 | + $get_data ['invoice_description_'.$i] = $value ['description']; |
|
374 | + $get_data ['invoice_amount_'.$i] = $value ['debit']; |
|
375 | + $i++; |
|
376 | 376 | $data ['total_credit_dis'] += $value ['debit']; |
377 | 377 | } |
378 | 378 | $data ['total_credit_sum'] += $value ['debit']; |
@@ -380,58 +380,58 @@ discard block |
||
380 | 380 | } |
381 | 381 | $data ['get_data'] = $get_data; |
382 | 382 | } |
383 | - $account_data = $this->session->userdata ( "accountinfo" ); |
|
384 | - $logintype = $this->session->userdata ( 'logintype' ); |
|
383 | + $account_data = $this->session->userdata("accountinfo"); |
|
384 | + $logintype = $this->session->userdata('logintype'); |
|
385 | 385 | $invoice_total = ''; |
386 | 386 | $query = "SELECT * from invoice_details where invoiceid='$id' and generate_type=0 and item_type != 'TAX' ORDER BY id ASC"; |
387 | - $invoice_total_query = $this->db->query ( $query ); |
|
387 | + $invoice_total_query = $this->db->query($query); |
|
388 | 388 | $data ['auto_count'] = 0; |
389 | - if ($invoice_total_query->num_rows () > 0) { |
|
390 | - $data ['auto_count'] = $invoice_total_query->num_rows (); |
|
391 | - $invoice_total_query = $invoice_total_query->result_array (); |
|
389 | + if ($invoice_total_query->num_rows() > 0) { |
|
390 | + $data ['auto_count'] = $invoice_total_query->num_rows(); |
|
391 | + $invoice_total_query = $invoice_total_query->result_array(); |
|
392 | 392 | |
393 | 393 | $data ['invoice_total_query'] = $invoice_total_query; |
394 | 394 | } |
395 | - $invoice = $this->db_model->getSelect ( "*", "invoices", array ( |
|
395 | + $invoice = $this->db_model->getSelect("*", "invoices", array( |
|
396 | 396 | "id" => $id |
397 | - ) ); |
|
398 | - if ($invoice->num_rows () > 0) { |
|
399 | - $invoice = $invoice->result_array (); |
|
397 | + )); |
|
398 | + if ($invoice->num_rows() > 0) { |
|
399 | + $invoice = $invoice->result_array(); |
|
400 | 400 | $result = $invoice [0]; |
401 | 401 | $data ['payment_due_date'] = $result ['due_date']; |
402 | 402 | } |
403 | - $invoice_auto_res = $this->db_model->getSelect ( "sum(debit) as debit", "invoice_details", array ( |
|
403 | + $invoice_auto_res = $this->db_model->getSelect("sum(debit) as debit", "invoice_details", array( |
|
404 | 404 | "invoiceid" => $id, |
405 | 405 | 'generate_type' => 0 |
406 | - ) ); |
|
406 | + )); |
|
407 | 407 | $data ['invoice_auto_res'] = 0; |
408 | - if ($invoice_auto_res->num_rows () > 0) { |
|
409 | - $invoice_auto_res = $invoice_auto_res->result_array (); |
|
408 | + if ($invoice_auto_res->num_rows() > 0) { |
|
409 | + $invoice_auto_res = $invoice_auto_res->result_array(); |
|
410 | 410 | $result_auto_res = $invoice_auto_res [0]; |
411 | 411 | $data ['invoice_auto_res'] = $result_auto_res ['debit']; |
412 | 412 | } |
413 | 413 | |
414 | - $accountdata = $this->db_model->getSelect ( "*", "accounts", array ( |
|
414 | + $accountdata = $this->db_model->getSelect("*", "accounts", array( |
|
415 | 415 | "id" => $result ['accountid'] |
416 | - ) ); |
|
417 | - if ($accountdata->num_rows () > 0) { |
|
418 | - $accountdata = $accountdata->result_array (); |
|
416 | + )); |
|
417 | + if ($accountdata->num_rows() > 0) { |
|
418 | + $accountdata = $accountdata->result_array(); |
|
419 | 419 | $accountdata = $accountdata [0]; |
420 | 420 | } |
421 | 421 | $data ['taxes_count'] = 0; |
422 | - $taxes = $this->db_model->getSelect ( "*", "taxes_to_accounts", array ( |
|
422 | + $taxes = $this->db_model->getSelect("*", "taxes_to_accounts", array( |
|
423 | 423 | "accountid" => $result ['accountid'] |
424 | - ) ); |
|
425 | - $data ['taxes_count'] = $taxes->num_rows (); |
|
424 | + )); |
|
425 | + $data ['taxes_count'] = $taxes->num_rows(); |
|
426 | 426 | $total_tax = 0; |
427 | - if ($taxes->num_rows () > 0) { |
|
428 | - $taxes = $taxes->result_array (); |
|
429 | - foreach ( $taxes as $tax_value ) { |
|
430 | - $taxe_res = $this->db_model->getSelect ( "*", "taxes", array ( |
|
427 | + if ($taxes->num_rows() > 0) { |
|
428 | + $taxes = $taxes->result_array(); |
|
429 | + foreach ($taxes as $tax_value) { |
|
430 | + $taxe_res = $this->db_model->getSelect("*", "taxes", array( |
|
431 | 431 | "id" => $tax_value ['taxes_id'] |
432 | - ) ); |
|
433 | - $taxe_res = $taxe_res->result_array (); |
|
434 | - foreach ( $taxe_res as $taxe_res_val ) { |
|
432 | + )); |
|
433 | + $taxe_res = $taxe_res->result_array(); |
|
434 | + foreach ($taxe_res as $taxe_res_val) { |
|
435 | 435 | $data ['taxes_to_accounts'] [] = $taxe_res_val; |
436 | 436 | $total_tax += $taxe_res_val ['taxes_rate']; |
437 | 437 | } |
@@ -446,156 +446,156 @@ discard block |
||
446 | 446 | $data ["paypal_url"] = $system_config ["paypal_sandbox_url"]; |
447 | 447 | $data ["paypal_email_id"] = $system_config ["paypal_sandbox_id"]; |
448 | 448 | } |
449 | - $date = strtotime ( $result ['invoice_date'] ); |
|
449 | + $date = strtotime($result ['invoice_date']); |
|
450 | 450 | $data ['total_tax'] = $total_tax; |
451 | - $data ['time'] = date ( "Y-m-d h:i:s ", $date ); |
|
451 | + $data ['time'] = date("Y-m-d h:i:s ", $date); |
|
452 | 452 | $data ["paypal_tax"] = $system_config ["paypal_tax"]; |
453 | - $data ["from_currency"] = $this->common->get_field_name ( 'currency', 'currency', $account_data ["currency_id"] ); |
|
453 | + $data ["from_currency"] = $this->common->get_field_name('currency', 'currency', $account_data ["currency_id"]); |
|
454 | 454 | $data ["to_currency"] = Common_model::$global_config ['system_config'] ['base_currency']; |
455 | 455 | if ($account_data ['type'] == - 1) { |
456 | - $accountdata ["currency_id"] = $this->common->get_field_name ( 'currency', 'currency', $account_data ["currency_id"] ); |
|
456 | + $accountdata ["currency_id"] = $this->common->get_field_name('currency', 'currency', $account_data ["currency_id"]); |
|
457 | 457 | $data ["to_currency"] = $accountdata ["currency_id"]; |
458 | 458 | } elseif ($account_data ['type'] == 1) { |
459 | - $accountdata ["currency_id"] = $this->common->get_field_name ( 'currency', 'currency', $account_data ["currency_id"] ); |
|
459 | + $accountdata ["currency_id"] = $this->common->get_field_name('currency', 'currency', $account_data ["currency_id"]); |
|
460 | 460 | $data ["to_currency"] = $accountdata ["currency_id"]; |
461 | 461 | } else { |
462 | - $accountdata ["currency_id"] = $this->common->get_field_name ( 'currency', 'currency', $account_data ["currency_id"] ); |
|
462 | + $accountdata ["currency_id"] = $this->common->get_field_name('currency', 'currency', $account_data ["currency_id"]); |
|
463 | 463 | $data ["to_currency"] = $accountdata ["currency_id"]; |
464 | 464 | } |
465 | 465 | $data ['from_date'] = $result ['from_date']; |
466 | 466 | $data ['to_date'] = $result ['to_date']; |
467 | 467 | $data ['invoice_notes'] = $result ['notes']; |
468 | 468 | $data ['invoice_date'] = $result ['invoice_date']; |
469 | - $data ['amount'] = $this->common_model->calculate_currency ( $result ['amount'], '', '', '', '' ); |
|
469 | + $data ['amount'] = $this->common_model->calculate_currency($result ['amount'], '', '', '', ''); |
|
470 | 470 | $data ['invoice_prefix'] = $result ['invoice_prefix']; |
471 | - $data ['page_title'] = gettext ( 'Invoice Summary' ); |
|
471 | + $data ['page_title'] = gettext('Invoice Summary'); |
|
472 | 472 | $data ['invoice_date'] = $result ['invoice_date']; |
473 | - $data ['return'] = base_url () . "invoices/invoice_list_modified"; |
|
474 | - $data ['cancel_return'] = base_url () . "invoice/invoice_list_cancel"; |
|
473 | + $data ['return'] = base_url()."invoices/invoice_list_modified"; |
|
474 | + $data ['cancel_return'] = base_url()."invoice/invoice_list_cancel"; |
|
475 | 475 | $data ['paypal_mode'] = 1; |
476 | 476 | $data ['prefix_id'] = $result ['invoiceid']; |
477 | 477 | $data ['logintype'] = $logintype; |
478 | 478 | $data ['accountdata'] = $accountdata; |
479 | 479 | $data ['id'] = $id; |
480 | - $data ['notify_url'] = base_url () . "invoices/invoice_list_get_data"; |
|
480 | + $data ['notify_url'] = base_url()."invoices/invoice_list_get_data"; |
|
481 | 481 | if ($account_data ['type'] == '1') { |
482 | - $data ['response_url'] = base_url () . "invoices/invoice_list_responce/"; |
|
482 | + $data ['response_url'] = base_url()."invoices/invoice_list_responce/"; |
|
483 | 483 | } else { |
484 | - $data ['response_url'] = base_url () . "user/user_list_responce/"; |
|
484 | + $data ['response_url'] = base_url()."user/user_list_responce/"; |
|
485 | 485 | } |
486 | - $data ['sucess_url'] = base_url () . "invoices/invoice_list_sucess"; |
|
486 | + $data ['sucess_url'] = base_url()."invoices/invoice_list_sucess"; |
|
487 | 487 | |
488 | - $this->load->view ( 'view_invoice_edit_automatically', $data ); |
|
488 | + $this->load->view('view_invoice_edit_automatically', $data); |
|
489 | 489 | } |
490 | 490 | function invoice_manually_payment_edit_save() { |
491 | 491 | $response_arr = $_POST; |
492 | - if (isset ( $response_arr ['save'] )) { |
|
492 | + if (isset ($response_arr ['save'])) { |
|
493 | 493 | $confirm = 0; |
494 | 494 | } else { |
495 | 495 | $confirm = 1; |
496 | 496 | } |
497 | - $where = array ( |
|
497 | + $where = array( |
|
498 | 498 | 'invoiceid' => $response_arr ['invoiceid'], |
499 | 499 | 'generate_type' => 1 |
500 | 500 | ); |
501 | - $this->db->where ( $where ); |
|
502 | - $this->db->delete ( "invoice_details" ); |
|
501 | + $this->db->where($where); |
|
502 | + $this->db->delete("invoice_details"); |
|
503 | 503 | $final_bal = 0; |
504 | 504 | $final_tax_bal = 0; |
505 | - $account_balance = $this->common->get_field_name ( 'balance', 'accounts', $response_arr ['accountid'] ); |
|
505 | + $account_balance = $this->common->get_field_name('balance', 'accounts', $response_arr ['accountid']); |
|
506 | 506 | if ($response_arr ['taxes_count'] > 0) { |
507 | - for($a = 0; $a < $response_arr ['taxes_count']; $a ++) { |
|
508 | - $add_arr = array ( |
|
507 | + for ($a = 0; $a < $response_arr ['taxes_count']; $a++) { |
|
508 | + $add_arr = array( |
|
509 | 509 | 'accountid' => $response_arr ['accountid'], |
510 | 510 | 'reseller_id' => $response_arr ['reseller_id'], |
511 | 511 | 'invoiceid' => $response_arr ['invoiceid'], |
512 | 512 | 'item_id' => 0, |
513 | 513 | 'generate_type' => 1, |
514 | 514 | 'item_type' => 'TAX', |
515 | - 'description' => $response_arr ['description_total_tax_input_' . $a], |
|
516 | - 'debit' => $this->common_model->add_calculate_currency ( $response_arr ['abc_total_tax_input_' . $a], "", "", true, false ), |
|
517 | - 'created_date' => gmdate ( "Y-m-d H:i:s" ) |
|
515 | + 'description' => $response_arr ['description_total_tax_input_'.$a], |
|
516 | + 'debit' => $this->common_model->add_calculate_currency($response_arr ['abc_total_tax_input_'.$a], "", "", true, false), |
|
517 | + 'created_date' => gmdate("Y-m-d H:i:s") |
|
518 | 518 | ); |
519 | - $final_tax_bal += $this->common_model->add_calculate_currency ( $response_arr ['abc_total_tax_input_' . $a], "", "", true, false ); |
|
520 | - $this->db->insert ( "invoice_details", $add_arr ); |
|
519 | + $final_tax_bal += $this->common_model->add_calculate_currency($response_arr ['abc_total_tax_input_'.$a], "", "", true, false); |
|
520 | + $this->db->insert("invoice_details", $add_arr); |
|
521 | 521 | } |
522 | 522 | } |
523 | - for($i = 1; $i <= $response_arr ['row_count']; $i ++) { |
|
524 | - if ($response_arr ['invoice_amount_' . $i] != '') { |
|
525 | - $add_arr = array ( |
|
523 | + for ($i = 1; $i <= $response_arr ['row_count']; $i++) { |
|
524 | + if ($response_arr ['invoice_amount_'.$i] != '') { |
|
525 | + $add_arr = array( |
|
526 | 526 | 'accountid' => $response_arr ['accountid'], |
527 | 527 | 'reseller_id' => $response_arr ['reseller_id'], |
528 | 528 | 'invoiceid' => $response_arr ['invoiceid'], |
529 | 529 | 'item_id' => 0, |
530 | 530 | 'generate_type' => 1, |
531 | 531 | 'item_type' => 'manual_inv', |
532 | - 'description' => $response_arr ['invoice_description_' . $i], |
|
533 | - 'debit' => $this->common_model->add_calculate_currency ( $response_arr ['invoice_amount_' . $i], "", "", true, false ), |
|
534 | - 'created_date' => $response_arr ['invoice_from_date_' . $i] |
|
532 | + 'description' => $response_arr ['invoice_description_'.$i], |
|
533 | + 'debit' => $this->common_model->add_calculate_currency($response_arr ['invoice_amount_'.$i], "", "", true, false), |
|
534 | + 'created_date' => $response_arr ['invoice_from_date_'.$i] |
|
535 | 535 | ); |
536 | - $this->db->insert ( "invoice_details", $add_arr ); |
|
536 | + $this->db->insert("invoice_details", $add_arr); |
|
537 | 537 | } |
538 | - $final_bal += $this->common_model->add_calculate_currency ( $response_arr ['invoice_amount_' . $i], "", "", true, false ); |
|
538 | + $final_bal += $this->common_model->add_calculate_currency($response_arr ['invoice_amount_'.$i], "", "", true, false); |
|
539 | 539 | } |
540 | - $query = "select sum(debit) as credit from invoice_details where invoiceid = " . $response_arr ['invoiceid']; |
|
541 | - $invoice_total_query = $this->db->query ( $query ); |
|
542 | - $invoice_total_query = $invoice_total_query->result_array (); |
|
543 | - $data = array ( |
|
544 | - 'amount' => $this->common_model->add_calculate_currency ( $response_arr ['total_val_final'], "", "", true, false ), |
|
540 | + $query = "select sum(debit) as credit from invoice_details where invoiceid = ".$response_arr ['invoiceid']; |
|
541 | + $invoice_total_query = $this->db->query($query); |
|
542 | + $invoice_total_query = $invoice_total_query->result_array(); |
|
543 | + $data = array( |
|
544 | + 'amount' => $this->common_model->add_calculate_currency($response_arr ['total_val_final'], "", "", true, false), |
|
545 | 545 | 'confirm' => $confirm, |
546 | 546 | 'notes' => $response_arr ['invoice_notes'] |
547 | 547 | ); |
548 | - $this->db->where ( "id", $response_arr ['invoiceid'] ); |
|
549 | - $this->db->update ( "invoices", $data ); |
|
548 | + $this->db->where("id", $response_arr ['invoiceid']); |
|
549 | + $this->db->update("invoices", $data); |
|
550 | 550 | if ($confirm == 1) { |
551 | - $invoice_details = $this->db_model->getSelect ( "*", "invoice_details", array ( |
|
551 | + $invoice_details = $this->db_model->getSelect("*", "invoice_details", array( |
|
552 | 552 | "invoiceid" => $response_arr ["invoiceid"] |
553 | - ) ); |
|
553 | + )); |
|
554 | 554 | if ($invoice_details->num_rows > 0) { |
555 | - $invoice_details_res = $invoice_details->result_array (); |
|
555 | + $invoice_details_res = $invoice_details->result_array(); |
|
556 | 556 | $after_bal = 0; |
557 | - foreach ( $invoice_details_res as $details_key => $details_value ) { |
|
557 | + foreach ($invoice_details_res as $details_key => $details_value) { |
|
558 | 558 | $before_balance_add = $account_balance - $after_bal; |
559 | 559 | $after_balance_add = $before_balance_add - $details_value ['debit']; |
560 | - $balnace_update = array ( |
|
560 | + $balnace_update = array( |
|
561 | 561 | 'before_balance' => $before_balance_add, |
562 | 562 | 'after_balance' => $after_balance_add |
563 | 563 | ); |
564 | 564 | $after_bal += $details_value ['debit']; |
565 | - $this->db->where ( "id", $details_value ['id'] ); |
|
566 | - $this->db->update ( "invoice_details", $balnace_update ); |
|
565 | + $this->db->where("id", $details_value ['id']); |
|
566 | + $this->db->update("invoice_details", $balnace_update); |
|
567 | 567 | } |
568 | 568 | } |
569 | 569 | |
570 | - $account_data = $this->db_model->getSelect ( "*", "accounts", array ( |
|
570 | + $account_data = $this->db_model->getSelect("*", "accounts", array( |
|
571 | 571 | "id" => $response_arr ["accountid"] |
572 | - ) ); |
|
573 | - $account_data = $account_data->result_array (); |
|
572 | + )); |
|
573 | + $account_data = $account_data->result_array(); |
|
574 | 574 | if ($account_data [0] ['posttoexternal'] == 1) { |
575 | - $bal_data = $account_data [0] ['balance'] - $this->common_model->add_calculate_currency ( $response_arr ['total_val_final'], "", "", true, false ); |
|
575 | + $bal_data = $account_data [0] ['balance'] - $this->common_model->add_calculate_currency($response_arr ['total_val_final'], "", "", true, false); |
|
576 | 576 | } else { |
577 | - $bal_data = $account_data [0] ['balance'] - $this->common_model->add_calculate_currency ( $response_arr ['total_val_final'], "", "", true, false ); |
|
577 | + $bal_data = $account_data [0] ['balance'] - $this->common_model->add_calculate_currency($response_arr ['total_val_final'], "", "", true, false); |
|
578 | 578 | if ($response_arr ['reseller_id'] == 0) { |
579 | 579 | $payment = 1; |
580 | 580 | } else { |
581 | 581 | $payment = $response_arr ['reseller_id']; |
582 | 582 | } |
583 | - $invoice_prefix = $this->common->get_field_name ( 'invoice_prefix', 'invoices', $response_arr ['invoiceid'] ); |
|
584 | - $invoice_prefix_id = $this->common->get_field_name ( 'invoiceid', 'invoices', $response_arr ['invoiceid'] ); |
|
585 | - $payment_arr = array ( |
|
583 | + $invoice_prefix = $this->common->get_field_name('invoice_prefix', 'invoices', $response_arr ['invoiceid']); |
|
584 | + $invoice_prefix_id = $this->common->get_field_name('invoiceid', 'invoices', $response_arr ['invoiceid']); |
|
585 | + $payment_arr = array( |
|
586 | 586 | "accountid" => $response_arr ["accountid"], |
587 | 587 | "payment_mode" => "1", |
588 | - "credit" => $this->common_model->add_calculate_currency ( $response_arr ['total_val_final'], "", "", true, false ), |
|
588 | + "credit" => $this->common_model->add_calculate_currency($response_arr ['total_val_final'], "", "", true, false), |
|
589 | 589 | "type" => "invoice", |
590 | 590 | "payment_by" => $payment, |
591 | - "notes" => "Payment made by " . $account_data [0] ['first_name'] . " " . $account_data [0] ['last_name'] . ", invoices No: " . $invoice_prefix . "_" . $invoice_prefix_id . " ", |
|
591 | + "notes" => "Payment made by ".$account_data [0] ['first_name']." ".$account_data [0] ['last_name'].", invoices No: ".$invoice_prefix."_".$invoice_prefix_id." ", |
|
592 | 592 | "paypalid" => '', |
593 | 593 | "txn_id" => '', |
594 | - 'payment_date' => gmdate ( 'Y-m-d H:i:s' ) |
|
594 | + 'payment_date' => gmdate('Y-m-d H:i:s') |
|
595 | 595 | ); |
596 | - $this->db->insert ( 'payments', $payment_arr ); |
|
597 | - $account_balance = $this->common->get_field_name ( 'balance', 'accounts', $response_arr ['accountid'] ); |
|
598 | - $add_arr = array ( |
|
596 | + $this->db->insert('payments', $payment_arr); |
|
597 | + $account_balance = $this->common->get_field_name('balance', 'accounts', $response_arr ['accountid']); |
|
598 | + $add_arr = array( |
|
599 | 599 | 'accountid' => $response_arr ['accountid'], |
600 | 600 | 'reseller_id' => $response_arr ['reseller_id'], |
601 | 601 | 'invoiceid' => $response_arr ['invoiceid'], |
@@ -603,131 +603,131 @@ discard block |
||
603 | 603 | 'generate_type' => 1, |
604 | 604 | 'item_type' => 'INVPAY', |
605 | 605 | 'description' => 'Prepaid invoice generate', |
606 | - 'credit' => $this->common_model->add_calculate_currency ( $response_arr ['total_val_final'], "", "", true, false ), |
|
607 | - 'created_date' => gmdate ( "Y-m-d H:i:s" ), |
|
606 | + 'credit' => $this->common_model->add_calculate_currency($response_arr ['total_val_final'], "", "", true, false), |
|
607 | + 'created_date' => gmdate("Y-m-d H:i:s"), |
|
608 | 608 | 'before_balance' => $account_balance, |
609 | - 'after_balance' => $account_balance - $this->common_model->add_calculate_currency ( $response_arr ['total_val_final'], "", "", true, false ) |
|
609 | + 'after_balance' => $account_balance - $this->common_model->add_calculate_currency($response_arr ['total_val_final'], "", "", true, false) |
|
610 | 610 | ); |
611 | - $this->db->insert ( "invoice_details", $add_arr ); |
|
611 | + $this->db->insert("invoice_details", $add_arr); |
|
612 | 612 | } |
613 | - $this->db->where ( "id", $response_arr ['accountid'] ); |
|
613 | + $this->db->where("id", $response_arr ['accountid']); |
|
614 | 614 | $act_status = 0; |
615 | 615 | if ($bal_data < 0 && $account_data [0] ['posttoexternal'] == 0) { |
616 | 616 | $act_status = 1; |
617 | 617 | } |
618 | - $balance_data = array ( |
|
618 | + $balance_data = array( |
|
619 | 619 | 'balance' => $bal_data, |
620 | 620 | 'status' => $act_status |
621 | 621 | ); |
622 | - $this->db->update ( "accounts", $balance_data ); |
|
622 | + $this->db->update("accounts", $balance_data); |
|
623 | 623 | /** |
624 | 624 | * * invoice mail ** |
625 | 625 | */ |
626 | - $this->invoice_send_notification ( $response_arr ['invoiceid'], $account_data [0], 'manually' ); |
|
626 | + $this->invoice_send_notification($response_arr ['invoiceid'], $account_data [0], 'manually'); |
|
627 | 627 | /** |
628 | 628 | * *** ** |
629 | 629 | */ |
630 | 630 | } |
631 | - $this->session->set_flashdata ( 'astpp_errormsg', 'Invoice updated successfully!' ); |
|
632 | - redirect ( base_url () . 'invoices/invoice_list/' ); |
|
631 | + $this->session->set_flashdata('astpp_errormsg', 'Invoice updated successfully!'); |
|
632 | + redirect(base_url().'invoices/invoice_list/'); |
|
633 | 633 | } |
634 | 634 | function invoice_automatically_payment_edit_save() { |
635 | 635 | $response_arr = $_POST; |
636 | - if (isset ( $response_arr ['save'] )) { |
|
636 | + if (isset ($response_arr ['save'])) { |
|
637 | 637 | $confirm = 0; |
638 | 638 | } else { |
639 | 639 | $confirm = 1; |
640 | 640 | } |
641 | - foreach ( $response_arr ['auto_invoice_date'] as $key => $val ) { |
|
642 | - $data = array ( |
|
643 | - 'debit' => $this->common_model->add_calculate_currency ( $response_arr ['auto_invoice_amount'] [$key], "", "", true, false ), |
|
641 | + foreach ($response_arr ['auto_invoice_date'] as $key => $val) { |
|
642 | + $data = array( |
|
643 | + 'debit' => $this->common_model->add_calculate_currency($response_arr ['auto_invoice_amount'] [$key], "", "", true, false), |
|
644 | 644 | 'created_date' => $response_arr ['auto_invoice_date'] [$key], |
645 | 645 | 'description' => $response_arr ['auto_invoice_description'] [$key], |
646 | 646 | 'generate_type' => 0 |
647 | 647 | ); |
648 | - $this->db->where ( "id", $key ); |
|
649 | - $this->db->update ( "invoice_details", $data ); |
|
648 | + $this->db->where("id", $key); |
|
649 | + $this->db->update("invoice_details", $data); |
|
650 | 650 | } |
651 | - $where = array ( |
|
651 | + $where = array( |
|
652 | 652 | 'invoiceid' => $response_arr ['invoiceid'], |
653 | 653 | 'generate_type' => 1 |
654 | 654 | ); |
655 | - $this->db->where ( $where ); |
|
656 | - $this->db->delete ( "invoice_details" ); |
|
655 | + $this->db->where($where); |
|
656 | + $this->db->delete("invoice_details"); |
|
657 | 657 | $final_bal = 0; |
658 | 658 | $final_tax_bal = 0; |
659 | - $account_balance = $this->common->get_field_name ( 'balance', 'accounts', $response_arr ['accountid'] ); |
|
659 | + $account_balance = $this->common->get_field_name('balance', 'accounts', $response_arr ['accountid']); |
|
660 | 660 | if ($response_arr ['taxes_count'] > 0) { |
661 | - for($a = 0; $a < $response_arr ['row_count']; $a ++) { |
|
662 | - $arr_update = array ( |
|
661 | + for ($a = 0; $a < $response_arr ['row_count']; $a++) { |
|
662 | + $arr_update = array( |
|
663 | 663 | 'item_type' => 'TAX', |
664 | - 'id' => $response_arr ['description_total_tax_id_' . $a] |
|
664 | + 'id' => $response_arr ['description_total_tax_id_'.$a] |
|
665 | 665 | ); |
666 | - $this->db->where ( $arr_update ); |
|
667 | - $update_arr = array ( |
|
668 | - 'debit' => $this->common_model->add_calculate_currency ( $response_arr ['abc_total_tax_input_' . $a], "", "", true, false ) |
|
666 | + $this->db->where($arr_update); |
|
667 | + $update_arr = array( |
|
668 | + 'debit' => $this->common_model->add_calculate_currency($response_arr ['abc_total_tax_input_'.$a], "", "", true, false) |
|
669 | 669 | ); |
670 | - $final_tax_bal += $this->common_model->add_calculate_currency ( $response_arr ['abc_total_tax_input_' . $a], "", "", true, false ); |
|
671 | - $this->db->update ( "invoice_details", $update_arr ); |
|
670 | + $final_tax_bal += $this->common_model->add_calculate_currency($response_arr ['abc_total_tax_input_'.$a], "", "", true, false); |
|
671 | + $this->db->update("invoice_details", $update_arr); |
|
672 | 672 | } |
673 | 673 | } |
674 | - for($i = 1; $i <= $response_arr ['row_count']; $i ++) { |
|
675 | - if ($response_arr ['invoice_amount_' . $i] != '') { |
|
676 | - $add_arr = array ( |
|
674 | + for ($i = 1; $i <= $response_arr ['row_count']; $i++) { |
|
675 | + if ($response_arr ['invoice_amount_'.$i] != '') { |
|
676 | + $add_arr = array( |
|
677 | 677 | 'accountid' => $response_arr ['accountid'], |
678 | 678 | 'reseller_id' => $response_arr ['reseller_id'], |
679 | 679 | 'invoiceid' => $response_arr ['invoiceid'], |
680 | 680 | 'item_id' => 0, |
681 | 681 | 'generate_type' => 1, |
682 | 682 | 'item_type' => 'manual_inv', |
683 | - 'description' => $response_arr ['invoice_description_' . $i], |
|
684 | - 'debit' => $this->common_model->add_calculate_currency ( $response_arr ['invoice_amount_' . $i], "", "", true, false ), |
|
685 | - 'created_date' => $response_arr ['invoice_from_date_' . $i] |
|
683 | + 'description' => $response_arr ['invoice_description_'.$i], |
|
684 | + 'debit' => $this->common_model->add_calculate_currency($response_arr ['invoice_amount_'.$i], "", "", true, false), |
|
685 | + 'created_date' => $response_arr ['invoice_from_date_'.$i] |
|
686 | 686 | ); |
687 | - $this->db->insert ( "invoice_details", $add_arr ); |
|
687 | + $this->db->insert("invoice_details", $add_arr); |
|
688 | 688 | } |
689 | 689 | } |
690 | - $query = "select sum(debit) as credit from invoice_details where invoiceid = " . $response_arr ['invoiceid']; |
|
691 | - $invoice_total_query = $this->db->query ( $query ); |
|
692 | - $invoice_total_query = $invoice_total_query->result_array (); |
|
693 | - $data = array ( |
|
694 | - 'amount' => $this->common_model->add_calculate_currency ( $response_arr ['total_val_final'], "", "", true, false ), |
|
690 | + $query = "select sum(debit) as credit from invoice_details where invoiceid = ".$response_arr ['invoiceid']; |
|
691 | + $invoice_total_query = $this->db->query($query); |
|
692 | + $invoice_total_query = $invoice_total_query->result_array(); |
|
693 | + $data = array( |
|
694 | + 'amount' => $this->common_model->add_calculate_currency($response_arr ['total_val_final'], "", "", true, false), |
|
695 | 695 | 'confirm' => $confirm, |
696 | 696 | 'notes' => $response_arr ['invoice_notes'] |
697 | 697 | ); |
698 | - $this->db->where ( "id", $response_arr ['invoiceid'] ); |
|
699 | - $this->db->update ( "invoices", $data ); |
|
698 | + $this->db->where("id", $response_arr ['invoiceid']); |
|
699 | + $this->db->update("invoices", $data); |
|
700 | 700 | if ($confirm == 1) { |
701 | - $invoice_details = $this->db_model->getSelect ( "*", "invoice_details", array ( |
|
701 | + $invoice_details = $this->db_model->getSelect("*", "invoice_details", array( |
|
702 | 702 | "invoiceid" => $response_arr ["invoiceid"] |
703 | - ) ); |
|
703 | + )); |
|
704 | 704 | if ($invoice_details->num_rows > 0) { |
705 | - $invoice_details_res = $invoice_details->result_array (); |
|
705 | + $invoice_details_res = $invoice_details->result_array(); |
|
706 | 706 | $after_bal = 0; |
707 | - foreach ( $invoice_details_res as $details_key => $details_value ) { |
|
707 | + foreach ($invoice_details_res as $details_key => $details_value) { |
|
708 | 708 | if ($details_value ['item_type'] != 'STANDARD') { |
709 | 709 | $before_balance_add = $account_balance - $after_bal; |
710 | 710 | $after_balance_add = $before_balance_add - $details_value ['debit']; |
711 | - $balnace_update = array ( |
|
711 | + $balnace_update = array( |
|
712 | 712 | 'before_balance' => $before_balance_add, |
713 | 713 | 'after_balance' => $after_balance_add |
714 | 714 | ); |
715 | 715 | $after_bal += $details_value ['debit']; |
716 | - $this->db->where ( "id", $details_value ['id'] ); |
|
717 | - $this->db->update ( "invoice_details", $balnace_update ); |
|
716 | + $this->db->where("id", $details_value ['id']); |
|
717 | + $this->db->update("invoice_details", $balnace_update); |
|
718 | 718 | } |
719 | 719 | } |
720 | 720 | } |
721 | - $account_data = $this->db_model->getSelect ( "*", "accounts", array ( |
|
721 | + $account_data = $this->db_model->getSelect("*", "accounts", array( |
|
722 | 722 | "id" => $response_arr ["accountid"] |
723 | - ) ); |
|
724 | - $account_data = $account_data->result_array (); |
|
725 | - $invoice_not_deduct = $this->db_model->getSelect ( "*", "invoice_details", array ( |
|
723 | + )); |
|
724 | + $account_data = $account_data->result_array(); |
|
725 | + $invoice_not_deduct = $this->db_model->getSelect("*", "invoice_details", array( |
|
726 | 726 | "invoiceid" => $response_arr ['invoiceid'] |
727 | - ) ); |
|
727 | + )); |
|
728 | 728 | $standard_call_balance = 0; |
729 | - $invoice_not_deduct = $invoice_not_deduct->result_array (); |
|
730 | - foreach ( $invoice_not_deduct as $key => $invoice_nodeduct_val ) { |
|
729 | + $invoice_not_deduct = $invoice_not_deduct->result_array(); |
|
730 | + foreach ($invoice_not_deduct as $key => $invoice_nodeduct_val) { |
|
731 | 731 | if ($invoice_nodeduct_val ['item_type'] == 'STANDARD') { |
732 | 732 | $standard_call_balance = $invoice_nodeduct_val ['debit']; |
733 | 733 | } |
@@ -736,21 +736,21 @@ discard block |
||
736 | 736 | $finaldeduct_bal = $response_arr ['total_val_final'] - $standard_call_balance; |
737 | 737 | $bal_data = $account_data [0] ['balance'] - $finaldeduct_bal; |
738 | 738 | } |
739 | - $this->db->where ( "id", $response_arr ['accountid'] ); |
|
740 | - $balance_data = array ( |
|
739 | + $this->db->where("id", $response_arr ['accountid']); |
|
740 | + $balance_data = array( |
|
741 | 741 | 'balance' => $bal_data |
742 | 742 | ); |
743 | - $this->db->update ( "accounts", $balance_data ); |
|
743 | + $this->db->update("accounts", $balance_data); |
|
744 | 744 | /** |
745 | 745 | * * invoice mail ** |
746 | 746 | */ |
747 | - $this->invoice_send_notification ( $response_arr ['invoiceid'], $account_data [0], 'auto' ); |
|
747 | + $this->invoice_send_notification($response_arr ['invoiceid'], $account_data [0], 'auto'); |
|
748 | 748 | /** |
749 | 749 | * *** ** |
750 | 750 | */ |
751 | 751 | } |
752 | - $this->session->set_flashdata ( 'astpp_errormsg', 'Invoice updated successfully!' ); |
|
753 | - redirect ( base_url () . 'invoices/invoice_list/' ); |
|
752 | + $this->session->set_flashdata('astpp_errormsg', 'Invoice updated successfully!'); |
|
753 | + redirect(base_url().'invoices/invoice_list/'); |
|
754 | 754 | } |
755 | 755 | |
756 | 756 | /** |
@@ -758,76 +758,76 @@ discard block |
||
758 | 758 | * @param string $inv_flag |
759 | 759 | */ |
760 | 760 | function invoice_send_notification($invoice_id, $accountdata, $inv_flag) { |
761 | - $invoicedata = $this->db_model->getSelect ( "*", "invoices", array ( |
|
761 | + $invoicedata = $this->db_model->getSelect("*", "invoices", array( |
|
762 | 762 | "id" => $invoice_id |
763 | - ) ); |
|
764 | - $invoicedata = $invoicedata->result_array (); |
|
763 | + )); |
|
764 | + $invoicedata = $invoicedata->result_array(); |
|
765 | 765 | $invoicedata = $invoicedata [0]; |
766 | 766 | // $res = $this->common->get_invoice_template($invoicedata,$accountdata,"False"); |
767 | - $invoice_conf = array (); |
|
767 | + $invoice_conf = array(); |
|
768 | 768 | if ($accountdata ['reseller_id'] == 0) { |
769 | - $where = array ( |
|
769 | + $where = array( |
|
770 | 770 | "accountid" => 1 |
771 | 771 | ); |
772 | 772 | } else { |
773 | - $where = array ( |
|
773 | + $where = array( |
|
774 | 774 | "accountid" => $accountdata ['reseller_id'] |
775 | 775 | ); |
776 | 776 | } |
777 | - $query = $this->db_model->getSelect ( "*", "invoice_conf", $where ); |
|
777 | + $query = $this->db_model->getSelect("*", "invoice_conf", $where); |
|
778 | 778 | if ($query->num_rows > 0) { |
779 | - $invoice_conf = $query->result_array (); |
|
779 | + $invoice_conf = $query->result_array(); |
|
780 | 780 | $invoice_conf = $invoice_conf [0]; |
781 | 781 | } else { |
782 | - $query = $this->db_model->getSelect ( "*", "invoice_conf", array ( |
|
782 | + $query = $this->db_model->getSelect("*", "invoice_conf", array( |
|
783 | 783 | "accountid" => 1 |
784 | - ) ); |
|
785 | - $invoice_conf = $query->result_array (); |
|
784 | + )); |
|
785 | + $invoice_conf = $query->result_array(); |
|
786 | 786 | $invoice_conf = $invoice_conf [0]; |
787 | 787 | } |
788 | - $template_config = $this->config->item ( 'invoice_screen' ); |
|
789 | - include ($template_config . 'generateInvoice.php'); |
|
790 | - $generateInvoice = new generateInvoice (); |
|
791 | - $generateInvoice->download_invoice ( $invoicedata ['id'], $accountdata, $invoice_conf, $inv_flag ); |
|
788 | + $template_config = $this->config->item('invoice_screen'); |
|
789 | + include ($template_config.'generateInvoice.php'); |
|
790 | + $generateInvoice = new generateInvoice(); |
|
791 | + $generateInvoice->download_invoice($invoicedata ['id'], $accountdata, $invoice_conf, $inv_flag); |
|
792 | 792 | return true; |
793 | 793 | } |
794 | 794 | function currency_decimal($amount) { |
795 | 795 | $decimal_amount = Common_model::$global_config ['system_config'] ['decimalpoints']; |
796 | - $number_convert = number_format ( ( float ) $amount, $decimal_amount, '.', '' ); |
|
796 | + $number_convert = number_format((float)$amount, $decimal_amount, '.', ''); |
|
797 | 797 | return $number_convert; |
798 | 798 | } |
799 | 799 | function invoice_summary($id) { |
800 | 800 | $query = "SELECT * from invoice_details where invoiceid='$id' "; |
801 | 801 | |
802 | - $invoice_total_query = $this->db->query ( $query ); |
|
803 | - if ($invoice_total_query->num_rows () > 0) { |
|
804 | - $invoice_final_query = $invoice_total_query->result_array (); |
|
802 | + $invoice_total_query = $this->db->query($query); |
|
803 | + if ($invoice_total_query->num_rows() > 0) { |
|
804 | + $invoice_final_query = $invoice_total_query->result_array(); |
|
805 | 805 | $data ['invoice_final_query'] = $invoice_final_query; |
806 | 806 | |
807 | - $account_data = $this->session->userdata ( "accountinfo" ); |
|
808 | - $logintype = $this->session->userdata ( 'logintype' ); |
|
807 | + $account_data = $this->session->userdata("accountinfo"); |
|
808 | + $logintype = $this->session->userdata('logintype'); |
|
809 | 809 | $invoice_total = ''; |
810 | 810 | $query = "SELECT * from invoice_details where item_type='INVPAY' AND invoiceid='$id' ORDER BY created_date ASC"; |
811 | - $invoice_total_query = $this->db->query ( $query ); |
|
812 | - if ($invoice_total_query->num_rows () > 0) { |
|
813 | - $invoice_total_query = $invoice_total_query->result_array (); |
|
811 | + $invoice_total_query = $this->db->query($query); |
|
812 | + if ($invoice_total_query->num_rows() > 0) { |
|
813 | + $invoice_total_query = $invoice_total_query->result_array(); |
|
814 | 814 | |
815 | 815 | $data ['invoice_total_query'] = $invoice_total_query; |
816 | 816 | } |
817 | - $invoice = $this->db_model->getSelect ( "*", "invoices", array ( |
|
817 | + $invoice = $this->db_model->getSelect("*", "invoices", array( |
|
818 | 818 | "id" => $id |
819 | - ) ); |
|
820 | - if ($invoice->num_rows () > 0) { |
|
821 | - $invoice = $invoice->result_array (); |
|
819 | + )); |
|
820 | + if ($invoice->num_rows() > 0) { |
|
821 | + $invoice = $invoice->result_array(); |
|
822 | 822 | $result = $invoice [0]; |
823 | 823 | $data ['payment_due_date'] = $result ['due_date']; |
824 | 824 | } |
825 | 825 | |
826 | - $accountdata = $this->db_model->getSelect ( "*", "accounts", array ( |
|
826 | + $accountdata = $this->db_model->getSelect("*", "accounts", array( |
|
827 | 827 | "id" => $result ['accountid'] |
828 | - ) ); |
|
829 | - if ($accountdata->num_rows () > 0) { |
|
830 | - $accountdata = $accountdata->result_array (); |
|
828 | + )); |
|
829 | + if ($accountdata->num_rows() > 0) { |
|
830 | + $accountdata = $accountdata->result_array(); |
|
831 | 831 | $accountdata = $accountdata [0]; |
832 | 832 | } |
833 | 833 | |
@@ -839,108 +839,108 @@ discard block |
||
839 | 839 | $data ["paypal_url"] = $system_config ["paypal_sandbox_url"]; |
840 | 840 | $data ["paypal_email_id"] = $system_config ["paypal_sandbox_id"]; |
841 | 841 | } |
842 | - $date = strtotime ( $result ['invoice_date'] ); |
|
843 | - $data ['time'] = date ( "Y-m-d h:i:s ", $date ); |
|
842 | + $date = strtotime($result ['invoice_date']); |
|
843 | + $data ['time'] = date("Y-m-d h:i:s ", $date); |
|
844 | 844 | $data ["paypal_tax"] = $system_config ["paypal_tax"]; |
845 | - $data ["from_currency"] = $this->common->get_field_name ( 'currency', 'currency', $account_data ["currency_id"] ); |
|
845 | + $data ["from_currency"] = $this->common->get_field_name('currency', 'currency', $account_data ["currency_id"]); |
|
846 | 846 | $data ["to_currency"] = Common_model::$global_config ['system_config'] ['base_currency']; |
847 | 847 | if ($account_data ['type'] == - 1) { |
848 | - $accountdata ["currency_id"] = $this->common->get_field_name ( 'currency', 'currency', $account_data ["currency_id"] ); |
|
848 | + $accountdata ["currency_id"] = $this->common->get_field_name('currency', 'currency', $account_data ["currency_id"]); |
|
849 | 849 | $data ["to_currency"] = $accountdata ["currency_id"]; |
850 | 850 | } elseif ($account_data ['type'] == 1) { |
851 | - $accountdata ["currency_id"] = $this->common->get_field_name ( 'currency', 'currency', $account_data ["currency_id"] ); |
|
851 | + $accountdata ["currency_id"] = $this->common->get_field_name('currency', 'currency', $account_data ["currency_id"]); |
|
852 | 852 | $data ["to_currency"] = $accountdata ["currency_id"]; |
853 | 853 | } else { |
854 | - $accountdata ["currency_id"] = $this->common->get_field_name ( 'currency', 'currency', $account_data ["currency_id"] ); |
|
854 | + $accountdata ["currency_id"] = $this->common->get_field_name('currency', 'currency', $account_data ["currency_id"]); |
|
855 | 855 | $data ["to_currency"] = $accountdata ["currency_id"]; |
856 | 856 | } |
857 | 857 | $data ["system_currency"] = Common_model::$global_config ['system_config'] ['base_currency']; |
858 | - foreach ( $invoice_total_query as $value ) { |
|
858 | + foreach ($invoice_total_query as $value) { |
|
859 | 859 | $data ['from_date'] = $result ['from_date']; |
860 | 860 | $data ['to_date'] = $result ['to_date']; |
861 | 861 | $data ['invoice_date'] = $result ['invoice_date']; |
862 | - $data ['amount'] = $this->common_model->calculate_currency ( $result ['amount'] ); |
|
862 | + $data ['amount'] = $this->common_model->calculate_currency($result ['amount']); |
|
863 | 863 | $data ['invoice_prefix'] = $result ['invoice_prefix']; |
864 | - $data ['page_title'] = gettext ( 'Invoice Summary' ); |
|
864 | + $data ['page_title'] = gettext('Invoice Summary'); |
|
865 | 865 | $data ['invoice_date'] = $result ['invoice_date']; |
866 | - $data ['return'] = base_url () . "invoices/invoice_list_modified"; |
|
867 | - $data ['cancel_return'] = base_url () . "invoice/invoice_list_cancel"; |
|
866 | + $data ['return'] = base_url()."invoices/invoice_list_modified"; |
|
867 | + $data ['cancel_return'] = base_url()."invoice/invoice_list_cancel"; |
|
868 | 868 | $data ['paypal_mode'] = 1; |
869 | 869 | $data ['prefix_id'] = $result ['invoiceid']; |
870 | 870 | $data ['logintype'] = $logintype; |
871 | 871 | $data ['accountdata'] = $accountdata; |
872 | 872 | $data ['value'] = $value; |
873 | 873 | $data ['id'] = $id; |
874 | - $data ['notify_url'] = base_url () . "invoices/invoice_list_get_data/"; |
|
874 | + $data ['notify_url'] = base_url()."invoices/invoice_list_get_data/"; |
|
875 | 875 | if ($account_data ['type'] == '1') { |
876 | - $data ['response_url'] = base_url () . "invoices/invoice_list_responce/"; |
|
876 | + $data ['response_url'] = base_url()."invoices/invoice_list_responce/"; |
|
877 | 877 | } else { |
878 | - $data ['response_url'] = base_url () . "user/user_list_responce/"; |
|
878 | + $data ['response_url'] = base_url()."user/user_list_responce/"; |
|
879 | 879 | } |
880 | - $data ['sucess_url'] = base_url () . "invoices/invoice_list_sucess/"; |
|
880 | + $data ['sucess_url'] = base_url()."invoices/invoice_list_sucess/"; |
|
881 | 881 | } |
882 | 882 | } else { |
883 | 883 | |
884 | - redirect ( base_url () . 'dashboard/' ); |
|
884 | + redirect(base_url().'dashboard/'); |
|
885 | 885 | } |
886 | - $this->load->view ( 'view_invoice_payment', $data ); |
|
886 | + $this->load->view('view_invoice_payment', $data); |
|
887 | 887 | } |
888 | 888 | function invoice_list_get_data() { |
889 | - redirect ( base_url () . 'invoices/invoice_list/' ); |
|
889 | + redirect(base_url().'invoices/invoice_list/'); |
|
890 | 890 | } |
891 | 891 | function convert_amount($amount) { |
892 | - $amount = $this->common_model->add_calculate_currency ( $amount, "", "", true, false ); |
|
893 | - echo number_format ( $amount, 2 ); |
|
892 | + $amount = $this->common_model->add_calculate_currency($amount, "", "", true, false); |
|
893 | + echo number_format($amount, 2); |
|
894 | 894 | } |
895 | 895 | function invoice_list_responce() { |
896 | 896 | $response_arr = $_POST; |
897 | - $logintype = $this->session->userdata ( 'logintype' ); |
|
897 | + $logintype = $this->session->userdata('logintype'); |
|
898 | 898 | if (($response_arr ["payment_status"] == "Pending" || $response_arr ["payment_status"] == "Complete" || $response_arr ["payment_status"] == "Completed")) { |
899 | 899 | $invoice_id = $response_arr ['item_number']; |
900 | 900 | $amount = $response_arr ['payment_gross']; |
901 | 901 | $description = $response_arr ['item_name']; |
902 | 902 | $debit = ''; |
903 | 903 | |
904 | - $paypal_tax = $this->db_model->getSelect ( "value", "system", array ( |
|
904 | + $paypal_tax = $this->db_model->getSelect("value", "system", array( |
|
905 | 905 | "name" => "paypal_tax", |
906 | 906 | "group_title" => "paypal" |
907 | - ) ); |
|
908 | - $paypal_tax = $paypal_tax->result (); |
|
907 | + )); |
|
908 | + $paypal_tax = $paypal_tax->result(); |
|
909 | 909 | $paypal_tax = $paypal_tax [0]->value; |
910 | 910 | $balance_amt = $actual_amount = $response_arr ["custom"]; |
911 | 911 | |
912 | - $paypal_fee = $this->db_model->getSelect ( "value", "system", array ( |
|
912 | + $paypal_fee = $this->db_model->getSelect("value", "system", array( |
|
913 | 913 | "name" => "paypal_fee", |
914 | 914 | "group_title" => "paypal" |
915 | - ) ); |
|
916 | - $paypal_fee = $paypal_fee->result (); |
|
915 | + )); |
|
916 | + $paypal_fee = $paypal_fee->result(); |
|
917 | 917 | $paypal_fee = $paypal_fee [0]->value; |
918 | 918 | |
919 | 919 | $paypalfee = ($paypal_fee == 0) ? '0' : $response_arr ["mc_gross"]; |
920 | 920 | |
921 | - $account_data = $this->db_model->getSelect ( "*", "accounts", array ( |
|
921 | + $account_data = $this->db_model->getSelect("*", "accounts", array( |
|
922 | 922 | "id" => $response_arr ["custom"] |
923 | - ) ); |
|
924 | - $account_data = $account_data->result_array (); |
|
923 | + )); |
|
924 | + $account_data = $account_data->result_array(); |
|
925 | 925 | $account_data = $account_data [0]; |
926 | - $currency = $this->db_model->getSelect ( 'currency,currencyrate', 'currency', array ( |
|
926 | + $currency = $this->db_model->getSelect('currency,currencyrate', 'currency', array( |
|
927 | 927 | "id" => $account_data ["currency_id"] |
928 | - ) ); |
|
929 | - $currency = $currency->result_array (); |
|
928 | + )); |
|
929 | + $currency = $currency->result_array(); |
|
930 | 930 | $currency = $currency [0]; |
931 | - $date = date ( 'Y-m-d H:i:s' ); |
|
932 | - $invoice_total_query = $this->db_model->getSelect ( "*", "invoices", array ( |
|
931 | + $date = date('Y-m-d H:i:s'); |
|
932 | + $invoice_total_query = $this->db_model->getSelect("*", "invoices", array( |
|
933 | 933 | "id" => $invoice_id |
934 | - ) ); |
|
935 | - if ($invoice_total_query->num_rows () > 0) { |
|
936 | - $invoice_total_query = $invoice_total_query->result_array (); |
|
934 | + )); |
|
935 | + if ($invoice_total_query->num_rows() > 0) { |
|
936 | + $invoice_total_query = $invoice_total_query->result_array(); |
|
937 | 937 | $debit = $invoice_total_query [0] ['amount']; |
938 | 938 | } |
939 | - $query = "select sum(credit) as credit from invoice_details where invoiceid = " . $invoice_id . " AND item_type !='PAYMENT' Group By invoiceid"; |
|
939 | + $query = "select sum(credit) as credit from invoice_details where invoiceid = ".$invoice_id." AND item_type !='PAYMENT' Group By invoiceid"; |
|
940 | 940 | // echo $query; exit; |
941 | - $invoice_total_query = $this->db->query ( $query ); |
|
942 | - if ($invoice_total_query->num_rows () > 0) { |
|
943 | - $invoice_total_query = $invoice_total_query->result_array (); |
|
941 | + $invoice_total_query = $this->db->query($query); |
|
942 | + if ($invoice_total_query->num_rows() > 0) { |
|
943 | + $invoice_total_query = $invoice_total_query->result_array(); |
|
944 | 944 | $total_debit = $invoice_total_query [0] ['credit']; |
945 | 945 | } |
946 | 946 | $credit_total = $total_debit + $amount; |
@@ -949,26 +949,26 @@ discard block |
||
949 | 949 | |
950 | 950 | if ($debit == $credit_total) { |
951 | 951 | |
952 | - $this->db->where ( "id", $invoice_id ); |
|
953 | - $data = array ( |
|
952 | + $this->db->where("id", $invoice_id); |
|
953 | + $data = array( |
|
954 | 954 | 'status' => '0' |
955 | 955 | ); |
956 | - $this->db->update ( "invoices", $data ); |
|
956 | + $this->db->update("invoices", $data); |
|
957 | 957 | // echo $this->db->last_query(); exit; |
958 | 958 | } else { |
959 | - $this->db->where ( "id", $invoice_id ); |
|
960 | - $data = array ( |
|
959 | + $this->db->where("id", $invoice_id); |
|
960 | + $data = array( |
|
961 | 961 | 'status' => '2' |
962 | 962 | ); |
963 | - $this->db->update ( "invoices", $data ); |
|
963 | + $this->db->update("invoices", $data); |
|
964 | 964 | // echo $this->db->last_query(); exit; |
965 | 965 | } |
966 | 966 | |
967 | 967 | if ($amount > $debit) { |
968 | - $this->session->set_flashdata ( 'astpp_notification', 'Invoice payment amount should be higher then the invoice amount.' ); |
|
969 | - redirect ( base_url () . 'invoices/invoice_summary/' . $invoice_id ); |
|
968 | + $this->session->set_flashdata('astpp_notification', 'Invoice payment amount should be higher then the invoice amount.'); |
|
969 | + redirect(base_url().'invoices/invoice_summary/'.$invoice_id); |
|
970 | 970 | } |
971 | - $payment_trans_array = array ( |
|
971 | + $payment_trans_array = array( |
|
972 | 972 | "accountid" => $response_arr ["custom"], |
973 | 973 | "amount" => $response_arr ["payment_gross"], |
974 | 974 | "tax" => "1", |
@@ -977,65 +977,65 @@ discard block |
||
977 | 977 | "paypal_fee" => $paypalfee, |
978 | 978 | "user_currency" => $currency ["currency"], |
979 | 979 | "currency_rate" => $currency ["currencyrate"], |
980 | - "transaction_details" => json_encode ( $response_arr ), |
|
980 | + "transaction_details" => json_encode($response_arr), |
|
981 | 981 | "date" => $date |
982 | 982 | ); |
983 | - $this->db->insert ( 'payment_transaction', $payment_trans_array ); |
|
984 | - $transaction_details_id = $this->db->insert_id (); |
|
983 | + $this->db->insert('payment_transaction', $payment_trans_array); |
|
984 | + $transaction_details_id = $this->db->insert_id(); |
|
985 | 985 | |
986 | 986 | if ($transaction_details_id == '') { |
987 | 987 | $transaction_details_id == 0; |
988 | 988 | } |
989 | 989 | |
990 | - $accountdata = $this->db_model->getSelect ( "*", "payment_transaction", array () ); |
|
991 | - if ($accountdata->num_rows () > 0) { |
|
992 | - foreach ( $accountdata->result_array () as $payment_value ) { |
|
990 | + $accountdata = $this->db_model->getSelect("*", "payment_transaction", array()); |
|
991 | + if ($accountdata->num_rows() > 0) { |
|
992 | + foreach ($accountdata->result_array() as $payment_value) { |
|
993 | 993 | $payment_transaction = $payment_value ['transaction_details']; |
994 | - $payment_result = json_decode ( $payment_transaction, true ); |
|
994 | + $payment_result = json_decode($payment_transaction, true); |
|
995 | 995 | $transaction_id = $payment_result ['txn_id']; |
996 | 996 | } |
997 | 997 | } |
998 | - $invoice_total_history = $this->db_model->getSelect ( "*", "invoice_details", array ( |
|
998 | + $invoice_total_history = $this->db_model->getSelect("*", "invoice_details", array( |
|
999 | 999 | "invoiceid" => $invoice_id, |
1000 | 1000 | 'item_type' => 'INVPAY' |
1001 | - ) ); |
|
1001 | + )); |
|
1002 | 1002 | $account_balance = $account_data ['balance']; |
1003 | - if ($invoice_total_history->num_rows () > 0) { |
|
1003 | + if ($invoice_total_history->num_rows() > 0) { |
|
1004 | 1004 | // echo 'if'; exit; |
1005 | - $invoice_main = $invoice_total_history->result_array (); |
|
1005 | + $invoice_main = $invoice_total_history->result_array(); |
|
1006 | 1006 | // echo '<pre>'; print_r($invoice_main); exit; |
1007 | 1007 | $debit_amount = "0.00"; |
1008 | - foreach ( $invoice_main as $value ) { |
|
1008 | + foreach ($invoice_main as $value) { |
|
1009 | 1009 | $debit_amount = $value ['debit']; |
1010 | 1010 | } |
1011 | 1011 | |
1012 | 1012 | $actual_amount = $debit_amount - $amount; |
1013 | 1013 | // echo $actual_amount; exit; |
1014 | - $tax_array = array ( |
|
1014 | + $tax_array = array( |
|
1015 | 1015 | "accountid" => $response_arr ["custom"], |
1016 | 1016 | "invoiceid" => $invoice_id, |
1017 | 1017 | "item_id" => $transaction_details_id, |
1018 | 1018 | "description" => $description, |
1019 | - "debit" => $this->common->currency_decimal ( 0 ), |
|
1020 | - "credit" => $this->common->currency_decimal ( $amount ), |
|
1019 | + "debit" => $this->common->currency_decimal(0), |
|
1020 | + "credit" => $this->common->currency_decimal($amount), |
|
1021 | 1021 | "item_type" => "INVPAY", |
1022 | 1022 | "created_date" => $date, |
1023 | 1023 | "reseller_id" => $account_data ['reseller_id'], |
1024 | 1024 | 'before_balance' => $account_balance, |
1025 | 1025 | 'after_balance' => $account_balance + $amount |
1026 | 1026 | ); // echo '<pre>'; print_r( $tax_array); exit; |
1027 | - $this->db->insert ( "invoice_details", $tax_array ); |
|
1027 | + $this->db->insert("invoice_details", $tax_array); |
|
1028 | 1028 | } else { |
1029 | 1029 | |
1030 | 1030 | // echo 'else'; exit; |
1031 | 1031 | $actual_amount = $debit - $amount; |
1032 | - $tax_array = array ( |
|
1032 | + $tax_array = array( |
|
1033 | 1033 | "accountid" => $response_arr ["custom"], |
1034 | 1034 | "invoiceid" => $invoice_id, |
1035 | 1035 | "item_id" => $transaction_details_id, |
1036 | 1036 | "description" => $description, |
1037 | - "debit" => $this->common->currency_decimal ( 0 ), |
|
1038 | - "credit" => $this->common->currency_decimal ( $amount ), |
|
1037 | + "debit" => $this->common->currency_decimal(0), |
|
1038 | + "credit" => $this->common->currency_decimal($amount), |
|
1039 | 1039 | "item_type" => "INVPAY", |
1040 | 1040 | "created_date" => $date, |
1041 | 1041 | "reseller_id" => $account_data ['reseller_id'], |
@@ -1043,66 +1043,66 @@ discard block |
||
1043 | 1043 | 'after_balance' => $account_balance + $amount |
1044 | 1044 | ); |
1045 | 1045 | |
1046 | - $this->db->insert ( "invoice_details", $tax_array ); |
|
1046 | + $this->db->insert("invoice_details", $tax_array); |
|
1047 | 1047 | } |
1048 | 1048 | } else { |
1049 | 1049 | if ($logintype = 0) { |
1050 | - $this->session->set_flashdata ( 'astpp_notification', 'Invoice payment amount should be higher then the invoice amount.' ); |
|
1051 | - redirect ( base_url () . 'user/user_invoice_payment/' . $invoice_id ); |
|
1050 | + $this->session->set_flashdata('astpp_notification', 'Invoice payment amount should be higher then the invoice amount.'); |
|
1051 | + redirect(base_url().'user/user_invoice_payment/'.$invoice_id); |
|
1052 | 1052 | } else { |
1053 | - $this->session->set_flashdata ( 'astpp_notification', 'Invoice payment amount should be higher then the invoice amount.' ); |
|
1054 | - redirect ( base_url () . 'invoices/invoice_summary/' . $invoice_id ); |
|
1053 | + $this->session->set_flashdata('astpp_notification', 'Invoice payment amount should be higher then the invoice amount.'); |
|
1054 | + redirect(base_url().'invoices/invoice_summary/'.$invoice_id); |
|
1055 | 1055 | } |
1056 | 1056 | } |
1057 | 1057 | |
1058 | - $this->load->module ( 'accounts/accounts' ); |
|
1058 | + $this->load->module('accounts/accounts'); |
|
1059 | 1059 | $reseller_debit = 0; |
1060 | - $reseller_debit = $this->common->get_field_name ( 'reseller_id', 'accounts', array ( |
|
1060 | + $reseller_debit = $this->common->get_field_name('reseller_id', 'accounts', array( |
|
1061 | 1061 | 'id' => $response_arr ["custom"], |
1062 | 1062 | 'status' => 0, |
1063 | 1063 | 'deleted' => 0 |
1064 | - ) ); |
|
1064 | + )); |
|
1065 | 1065 | // echo '<pre>'; print_r($reseller_debit); exit; |
1066 | 1066 | if ($reseller_debit > 0) { |
1067 | - $this->accounts_model->update_balance ( $amount, $response_arr ["custom"], "debit" ); |
|
1068 | - $this->accounts_model->update_balance ( $amount, $reseller_debit, "debit" ); |
|
1067 | + $this->accounts_model->update_balance($amount, $response_arr ["custom"], "debit"); |
|
1068 | + $this->accounts_model->update_balance($amount, $reseller_debit, "debit"); |
|
1069 | 1069 | } else { |
1070 | - $this->accounts_model->update_balance ( $amount, $response_arr ["custom"], "debit" ); |
|
1070 | + $this->accounts_model->update_balance($amount, $response_arr ["custom"], "debit"); |
|
1071 | 1071 | } |
1072 | 1072 | $account_data ['accountid'] = $account_data ['id']; |
1073 | - $this->email_lib->send_email ( 'email_payment_notification', $account_data, '', '', 0, 0, 0 ); |
|
1073 | + $this->email_lib->send_email('email_payment_notification', $account_data, '', '', 0, 0, 0); |
|
1074 | 1074 | if ($logintype = '1') { |
1075 | - $this->session->set_flashdata ( 'astpp_errormsg', 'Invoice payment done successfully!' ); |
|
1076 | - redirect ( base_url () . 'invoices/invoice_list/' ); |
|
1075 | + $this->session->set_flashdata('astpp_errormsg', 'Invoice payment done successfully!'); |
|
1076 | + redirect(base_url().'invoices/invoice_list/'); |
|
1077 | 1077 | } else { |
1078 | - $this->session->set_flashdata ( 'astpp_errormsg', 'Invoice payment done successfully!' ); |
|
1079 | - redirect ( base_url () . 'user/user_invoices_list/' ); |
|
1078 | + $this->session->set_flashdata('astpp_errormsg', 'Invoice payment done successfully!'); |
|
1079 | + redirect(base_url().'user/user_invoices_list/'); |
|
1080 | 1080 | } |
1081 | 1081 | } |
1082 | 1082 | } |
1083 | 1083 | function invoice_admin_payment() { |
1084 | 1084 | $response_arr = $_POST; |
1085 | 1085 | |
1086 | - if (! empty ( $response_arr )) { |
|
1086 | + if ( ! empty ($response_arr)) { |
|
1087 | 1087 | |
1088 | 1088 | $amount = $response_arr ['amount']; |
1089 | 1089 | $description = $response_arr ['item_name']; |
1090 | 1090 | $invoice_id = $response_arr ['item_number']; |
1091 | - $date = date ( 'Y-m-d H:i:s' ); |
|
1091 | + $date = date('Y-m-d H:i:s'); |
|
1092 | 1092 | |
1093 | - $invoice_total_query = $this->db_model->getSelect ( "*", "invoices", array ( |
|
1093 | + $invoice_total_query = $this->db_model->getSelect("*", "invoices", array( |
|
1094 | 1094 | "id" => $invoice_id |
1095 | - ) ); |
|
1096 | - if ($invoice_total_query->num_rows () > 0) { |
|
1097 | - $invoice_total_query = $invoice_total_query->result_array (); |
|
1095 | + )); |
|
1096 | + if ($invoice_total_query->num_rows() > 0) { |
|
1097 | + $invoice_total_query = $invoice_total_query->result_array(); |
|
1098 | 1098 | $debit = $invoice_total_query [0] ['amount']; |
1099 | 1099 | } |
1100 | 1100 | |
1101 | - $query = "select sum(credit) as credit from invoice_details where invoiceid = " . $invoice_id . " AND item_type !='PAYMENT' Group By invoiceid"; |
|
1101 | + $query = "select sum(credit) as credit from invoice_details where invoiceid = ".$invoice_id." AND item_type !='PAYMENT' Group By invoiceid"; |
|
1102 | 1102 | // echo $query; exit; |
1103 | - $invoice_total_query = $this->db->query ( $query ); |
|
1104 | - if ($invoice_total_query->num_rows () > 0) { |
|
1105 | - $invoice_total_query = $invoice_total_query->result_array (); |
|
1103 | + $invoice_total_query = $this->db->query($query); |
|
1104 | + if ($invoice_total_query->num_rows() > 0) { |
|
1105 | + $invoice_total_query = $invoice_total_query->result_array(); |
|
1106 | 1106 | $total_debit = $invoice_total_query [0] ['credit']; |
1107 | 1107 | } |
1108 | 1108 | $credit_total = $total_debit + $amount; |
@@ -1111,29 +1111,29 @@ discard block |
||
1111 | 1111 | |
1112 | 1112 | if ($debit == $credit_total) { |
1113 | 1113 | |
1114 | - $this->db->where ( "id", $invoice_id ); |
|
1115 | - $data = array ( |
|
1114 | + $this->db->where("id", $invoice_id); |
|
1115 | + $data = array( |
|
1116 | 1116 | 'status' => '0' |
1117 | 1117 | ); |
1118 | - $this->db->update ( "invoices", $data ); |
|
1118 | + $this->db->update("invoices", $data); |
|
1119 | 1119 | // echo $this->db->last_query(); exit; |
1120 | 1120 | } else { |
1121 | - $this->db->where ( "id", $invoice_id ); |
|
1122 | - $data = array ( |
|
1121 | + $this->db->where("id", $invoice_id); |
|
1122 | + $data = array( |
|
1123 | 1123 | 'status' => '2' |
1124 | 1124 | ); |
1125 | - $this->db->update ( "invoices", $data ); |
|
1125 | + $this->db->update("invoices", $data); |
|
1126 | 1126 | // echo $this->db->last_query(); exit; |
1127 | 1127 | } |
1128 | 1128 | |
1129 | 1129 | if ($amount > $debit) { |
1130 | - $this->session->set_flashdata ( 'astpp_notification', 'Invoice payment amount should be higher then the invoice amount.' ); |
|
1131 | - redirect ( base_url () . 'invoices/invoice_summary/' . $invoice_id ); |
|
1130 | + $this->session->set_flashdata('astpp_notification', 'Invoice payment amount should be higher then the invoice amount.'); |
|
1131 | + redirect(base_url().'invoices/invoice_summary/'.$invoice_id); |
|
1132 | 1132 | } |
1133 | 1133 | |
1134 | 1134 | $debit_amount = "0.00"; |
1135 | - $account_balance = $this->common->get_field_name ( 'balance', 'accounts', $response_arr ['custom'] ); |
|
1136 | - $tax_array = array ( |
|
1135 | + $account_balance = $this->common->get_field_name('balance', 'accounts', $response_arr ['custom']); |
|
1136 | + $tax_array = array( |
|
1137 | 1137 | "accountid" => $response_arr ["custom"], |
1138 | 1138 | "invoiceid" => $invoice_id, |
1139 | 1139 | "item_id" => '', |
@@ -1146,25 +1146,25 @@ discard block |
||
1146 | 1146 | 'before_balance' => $account_balance, |
1147 | 1147 | 'after_balance' => $account_balance + $amount |
1148 | 1148 | ); |
1149 | - $this->db->insert ( "invoice_details", $tax_array ); |
|
1149 | + $this->db->insert("invoice_details", $tax_array); |
|
1150 | 1150 | } else { |
1151 | 1151 | |
1152 | - $this->session->set_flashdata ( 'astpp_notification', 'Invoice payment amount should be higher then the invoice amount.' ); |
|
1153 | - redirect ( base_url () . 'invoices/invoice_summary/' . $invoice_id ); |
|
1152 | + $this->session->set_flashdata('astpp_notification', 'Invoice payment amount should be higher then the invoice amount.'); |
|
1153 | + redirect(base_url().'invoices/invoice_summary/'.$invoice_id); |
|
1154 | 1154 | } |
1155 | 1155 | |
1156 | - $this->load->module ( 'accounts/accounts' ); |
|
1157 | - $this->accounts_model->update_balance ( $amount, $response_arr ["custom"], "debit" ); |
|
1158 | - $this->session->set_flashdata ( 'astpp_errormsg', 'Invoice payment done successfully!' ); |
|
1156 | + $this->load->module('accounts/accounts'); |
|
1157 | + $this->accounts_model->update_balance($amount, $response_arr ["custom"], "debit"); |
|
1158 | + $this->session->set_flashdata('astpp_errormsg', 'Invoice payment done successfully!'); |
|
1159 | 1159 | } |
1160 | - $account_data = $this->db_model->getSelect ( "*", "accounts", array ( |
|
1160 | + $account_data = $this->db_model->getSelect("*", "accounts", array( |
|
1161 | 1161 | "id" => $response_arr ["custom"] |
1162 | - ) ); |
|
1163 | - $account_data = $account_data->result_array (); |
|
1162 | + )); |
|
1163 | + $account_data = $account_data->result_array(); |
|
1164 | 1164 | $account_data = $account_data [0]; |
1165 | 1165 | $account_data ['accountid'] = $account_data ['id']; |
1166 | 1166 | // $this->email_lib->send_email('email_payment_notification',$account_data ,'','',0,0,0); |
1167 | - redirect ( base_url () . 'invoices/invoice_list/' ); |
|
1167 | + redirect(base_url().'invoices/invoice_list/'); |
|
1168 | 1168 | } |
1169 | 1169 | function invoice_list_sucess() { |
1170 | 1170 | echo 'sucess'; |
@@ -1175,73 +1175,73 @@ discard block |
||
1175 | 1175 | exit (); |
1176 | 1176 | } |
1177 | 1177 | function invoice_delete() { |
1178 | - $ids = $this->input->post ( "selected_ids", true ); |
|
1178 | + $ids = $this->input->post("selected_ids", true); |
|
1179 | 1179 | $where = "id IN ($ids)"; |
1180 | - $this->db->where ( $where ); |
|
1181 | - echo $this->db->delete ( "invoices" ); |
|
1180 | + $this->db->where($where); |
|
1181 | + echo $this->db->delete("invoices"); |
|
1182 | 1182 | } |
1183 | 1183 | function invoice_conf() { |
1184 | - $data ['page_title'] = gettext ( 'Company Profile' ); |
|
1185 | - $post_array = $this->input->post (); |
|
1186 | - $accountinfo = $this->session->userdata ( 'accountinfo' ); |
|
1187 | - unset ( $post_array ['action'] ); |
|
1188 | - unset ( $post_array ['button'] ); |
|
1189 | - unset ( $post_array ['file'] ); |
|
1184 | + $data ['page_title'] = gettext('Company Profile'); |
|
1185 | + $post_array = $this->input->post(); |
|
1186 | + $accountinfo = $this->session->userdata('accountinfo'); |
|
1187 | + unset ($post_array ['action']); |
|
1188 | + unset ($post_array ['button']); |
|
1189 | + unset ($post_array ['file']); |
|
1190 | 1190 | |
1191 | - if (! empty ( $post_array )) { |
|
1192 | - $invoice_prefix = trim ( $post_array ['invoice_prefix'] ); |
|
1191 | + if ( ! empty ($post_array)) { |
|
1192 | + $invoice_prefix = trim($post_array ['invoice_prefix']); |
|
1193 | 1193 | if ($_FILES ['file'] ['name'] == '') { |
1194 | - $invoiceconf = $this->invoices_model->get_invoiceconf ( $post_array ['accountid'] ); |
|
1194 | + $invoiceconf = $this->invoices_model->get_invoiceconf($post_array ['accountid']); |
|
1195 | 1195 | $file_name = ($invoiceconf ['logo'] != '') ? $invoiceconf ['logo'] : ''; |
1196 | 1196 | } |
1197 | 1197 | if ($_FILES ['file_fav'] ['name'] == '') { |
1198 | - $invoiceconf = $this->invoices_model->get_invoiceconf ( $post_array ['accountid'] ); |
|
1198 | + $invoiceconf = $this->invoices_model->get_invoiceconf($post_array ['accountid']); |
|
1199 | 1199 | $file_name_fav = ($invoiceconf ['favicon'] != '') ? $invoiceconf ['favicon'] : ''; |
1200 | 1200 | } |
1201 | 1201 | if ($invoice_prefix == '') { |
1202 | - $this->session->set_flashdata ( 'astpp_notification', 'Invoice Prefix is required.' ); |
|
1203 | - redirect ( base_url () . 'invoices/invoice_conf/' ); |
|
1202 | + $this->session->set_flashdata('astpp_notification', 'Invoice Prefix is required.'); |
|
1203 | + redirect(base_url().'invoices/invoice_conf/'); |
|
1204 | 1204 | } |
1205 | 1205 | |
1206 | - if (isset ( $_FILES ['file'] ['name'] ) && $_FILES ['file'] ['name'] != '') { |
|
1206 | + if (isset ($_FILES ['file'] ['name']) && $_FILES ['file'] ['name'] != '') { |
|
1207 | 1207 | $files = $_FILES ['file']; |
1208 | 1208 | if ($files ['size'] < 0) { |
1209 | - $this->session->set_flashdata ( 'astpp_notification', 'PLease upload maximum file' ); |
|
1210 | - redirect ( base_url () . 'invoices/invoice_conf/' ); |
|
1209 | + $this->session->set_flashdata('astpp_notification', 'PLease upload maximum file'); |
|
1210 | + redirect(base_url().'invoices/invoice_conf/'); |
|
1211 | 1211 | } |
1212 | 1212 | $file = $_FILES ['file']; |
1213 | 1213 | $uploadedFile = $file ["tmp_name"]; |
1214 | 1214 | $file_name = $file ['name']; |
1215 | 1215 | $file_type = $file ['type']; |
1216 | 1216 | if ($file_type == 'image/jpg' || $file_type == 'image/png' || $file_type == 'image/jpeg') { |
1217 | - $dir_path = FCPATH . "upload/"; |
|
1218 | - $path = $dir_path . $accountinfo ['id'] . "_" . $file ['name']; |
|
1219 | - if (move_uploaded_file ( $uploadedFile, $path )) { |
|
1220 | - $this->session->set_flashdata ( 'astpp_errormsg', gettext ( 'files added successfully!' ) ); |
|
1217 | + $dir_path = FCPATH."upload/"; |
|
1218 | + $path = $dir_path.$accountinfo ['id']."_".$file ['name']; |
|
1219 | + if (move_uploaded_file($uploadedFile, $path)) { |
|
1220 | + $this->session->set_flashdata('astpp_errormsg', gettext('files added successfully!')); |
|
1221 | 1221 | } else { |
1222 | - $this->session->set_flashdata ( 'astpp_notification', "File Uploading Fail Please Try Again" ); |
|
1223 | - redirect ( base_url () . 'invoices/invoice_conf/' ); |
|
1222 | + $this->session->set_flashdata('astpp_notification', "File Uploading Fail Please Try Again"); |
|
1223 | + redirect(base_url().'invoices/invoice_conf/'); |
|
1224 | 1224 | } |
1225 | 1225 | } else { |
1226 | - $this->session->set_flashdata ( 'astpp_notification', 'Please upload only image!' ); |
|
1227 | - redirect ( base_url () . 'invoices/invoice_conf/' ); |
|
1226 | + $this->session->set_flashdata('astpp_notification', 'Please upload only image!'); |
|
1227 | + redirect(base_url().'invoices/invoice_conf/'); |
|
1228 | 1228 | } |
1229 | 1229 | } |
1230 | - if (isset ( $_FILES ['file_fav'] ['name'] ) && $_FILES ['file_fav'] ['name'] != '') { |
|
1230 | + if (isset ($_FILES ['file_fav'] ['name']) && $_FILES ['file_fav'] ['name'] != '') { |
|
1231 | 1231 | $files = $_FILES ['file_fav']; |
1232 | 1232 | if ($files ['size'] < 0) { |
1233 | - $this->session->set_flashdata ( 'astpp_notification', 'PLease upload maximum file' ); |
|
1234 | - redirect ( base_url () . 'invoices/invoice_conf/' ); |
|
1233 | + $this->session->set_flashdata('astpp_notification', 'PLease upload maximum file'); |
|
1234 | + redirect(base_url().'invoices/invoice_conf/'); |
|
1235 | 1235 | } |
1236 | - $imageInformation = getimagesize ( $_FILES ['file_fav'] ['tmp_name'] ); |
|
1236 | + $imageInformation = getimagesize($_FILES ['file_fav'] ['tmp_name']); |
|
1237 | 1237 | |
1238 | 1238 | $imageWidth = $imageInformation [0]; // Contains the Width of the Image |
1239 | 1239 | |
1240 | 1240 | $imageHeight = $imageInformation [1]; // Contains the Height of the Image |
1241 | 1241 | |
1242 | 1242 | if ($imageWidth > '16' && $imageHeight > '16') { |
1243 | - $this->session->set_flashdata ( 'astpp_notification', 'Please upload 16 * 16 size file' ); |
|
1244 | - redirect ( base_url () . 'invoices/invoice_conf/' ); |
|
1243 | + $this->session->set_flashdata('astpp_notification', 'Please upload 16 * 16 size file'); |
|
1244 | + redirect(base_url().'invoices/invoice_conf/'); |
|
1245 | 1245 | } |
1246 | 1246 | $file = $_FILES ['file_fav']; |
1247 | 1247 | $uploadedFile = $file ["tmp_name"]; |
@@ -1249,139 +1249,139 @@ discard block |
||
1249 | 1249 | $file_type = $file ['type']; |
1250 | 1250 | |
1251 | 1251 | if ($file_type == 'image/jpg' || $file_type == 'image/png' || $file_type == 'image/jpeg' || $file_type == 'image/vnd.microsoft.icon') { |
1252 | - $dir_path = FCPATH . "upload/"; |
|
1253 | - $path = $dir_path . $accountinfo ['id'] . "_" . $file ['name']; |
|
1254 | - if (move_uploaded_file ( $uploadedFile, $path )) { |
|
1255 | - $this->session->set_flashdata ( 'astpp_errormsg', gettext ( 'files added successfully!' ) ); |
|
1252 | + $dir_path = FCPATH."upload/"; |
|
1253 | + $path = $dir_path.$accountinfo ['id']."_".$file ['name']; |
|
1254 | + if (move_uploaded_file($uploadedFile, $path)) { |
|
1255 | + $this->session->set_flashdata('astpp_errormsg', gettext('files added successfully!')); |
|
1256 | 1256 | } else { |
1257 | - $this->session->set_flashdata ( 'astpp_notification', "File Uploading Fail Please Try Again" ); |
|
1258 | - redirect ( base_url () . 'invoices/invoice_conf/' ); |
|
1257 | + $this->session->set_flashdata('astpp_notification', "File Uploading Fail Please Try Again"); |
|
1258 | + redirect(base_url().'invoices/invoice_conf/'); |
|
1259 | 1259 | } |
1260 | 1260 | } else { |
1261 | - $this->session->set_flashdata ( 'astpp_notification', 'Please upload only image!' ); |
|
1262 | - redirect ( base_url () . 'invoices/invoice_conf/' ); |
|
1261 | + $this->session->set_flashdata('astpp_notification', 'Please upload only image!'); |
|
1262 | + redirect(base_url().'invoices/invoice_conf/'); |
|
1263 | 1263 | } |
1264 | 1264 | } |
1265 | 1265 | $post_array ['logo'] = $file_name; |
1266 | 1266 | $post_array ['favicon'] = $file_name_fav; |
1267 | - $this->invoices_model->save_invoiceconf ( $post_array ); |
|
1268 | - $this->session->set_flashdata ( 'astpp_errormsg', 'Invoice configuration updated sucessfully!' ); |
|
1269 | - redirect ( base_url () . 'invoices/invoice_conf/' ); |
|
1267 | + $this->invoices_model->save_invoiceconf($post_array); |
|
1268 | + $this->session->set_flashdata('astpp_errormsg', 'Invoice configuration updated sucessfully!'); |
|
1269 | + redirect(base_url().'invoices/invoice_conf/'); |
|
1270 | 1270 | } else { |
1271 | 1271 | |
1272 | - $invoiceconf = $this->invoices_model->get_invoiceconf ( $accountinfo ['id'] ); |
|
1272 | + $invoiceconf = $this->invoices_model->get_invoiceconf($accountinfo ['id']); |
|
1273 | 1273 | |
1274 | - if (! empty ( $invoiceconf )) { |
|
1275 | - $data ['file_name'] = $accountinfo ['id'] . "_" . $invoiceconf ['logo']; |
|
1276 | - $invoiceconf ['file'] = $accountinfo ['id'] . "_" . $invoiceconf ['logo']; |
|
1277 | - $invoiceconf ['file_fav'] = $accountinfo ['id'] . "_" . $invoiceconf ['favicon']; |
|
1278 | - $data ['file_name_fav'] = $accountinfo ['id'] . "_" . $invoiceconf ['favicon']; |
|
1274 | + if ( ! empty ($invoiceconf)) { |
|
1275 | + $data ['file_name'] = $accountinfo ['id']."_".$invoiceconf ['logo']; |
|
1276 | + $invoiceconf ['file'] = $accountinfo ['id']."_".$invoiceconf ['logo']; |
|
1277 | + $invoiceconf ['file_fav'] = $accountinfo ['id']."_".$invoiceconf ['favicon']; |
|
1278 | + $data ['file_name_fav'] = $accountinfo ['id']."_".$invoiceconf ['favicon']; |
|
1279 | 1279 | } |
1280 | 1280 | |
1281 | - $data ['form'] = $this->form->build_form ( $this->invoices_form->get_invoiceconf_form_fields ( $invoiceconf ), $invoiceconf ); |
|
1281 | + $data ['form'] = $this->form->build_form($this->invoices_form->get_invoiceconf_form_fields($invoiceconf), $invoiceconf); |
|
1282 | 1282 | |
1283 | - $this->load->view ( 'view_invoiceconf', $data ); |
|
1283 | + $this->load->view('view_invoiceconf', $data); |
|
1284 | 1284 | } |
1285 | 1285 | } |
1286 | 1286 | function incr($inteval) { |
1287 | - $inteval ++; // $a is undefined |
|
1287 | + $inteval++; // $a is undefined |
|
1288 | 1288 | return $inteval; |
1289 | 1289 | } |
1290 | 1290 | |
1291 | 1291 | // /*ASTPP_invoice_changes_05_05_start*/ |
1292 | 1292 | function customer_invoices($accountid) { |
1293 | 1293 | // echo '<pre>'; print_r($accountid); exit; |
1294 | - $json_data = array (); |
|
1294 | + $json_data = array(); |
|
1295 | 1295 | /** |
1296 | 1296 | * ** |
1297 | 1297 | * Invoice manually |
1298 | 1298 | * * |
1299 | 1299 | */ |
1300 | - $where = array ( |
|
1300 | + $where = array( |
|
1301 | 1301 | 'accountid' => $accountid, |
1302 | 1302 | 'confirm' => 1 |
1303 | 1303 | ); |
1304 | - $count_all = $this->db_model->countQuery ( "*", "invoices", $where ); |
|
1304 | + $count_all = $this->db_model->countQuery("*", "invoices", $where); |
|
1305 | 1305 | $currency_id = Common_model::$global_config ['system_config'] ['base_currency']; |
1306 | - $paging_data = $this->form->load_grid_config ( $count_all, $_GET ['rp'], $_GET ['page'] ); |
|
1306 | + $paging_data = $this->form->load_grid_config($count_all, $_GET ['rp'], $_GET ['page']); |
|
1307 | 1307 | $json_data = $paging_data ["json_paging"]; |
1308 | 1308 | |
1309 | - $Invoice_grid_data = $this->db_model->select ( "*", "invoices", $where, "invoice_date", "desc", $paging_data ["paging"] ["page_no"], $paging_data ["paging"] ["start"] ); |
|
1309 | + $Invoice_grid_data = $this->db_model->select("*", "invoices", $where, "invoice_date", "desc", $paging_data ["paging"] ["page_no"], $paging_data ["paging"] ["start"]); |
|
1310 | 1310 | // echo $this->db->last_query(); exit; |
1311 | - $grid_fields = json_decode ( $this->invoices_form->build_invoices_list_for_admin () ); |
|
1311 | + $grid_fields = json_decode($this->invoices_form->build_invoices_list_for_admin()); |
|
1312 | 1312 | |
1313 | 1313 | // $json_data['rows'] = $this->form->build_grid($Invoice_grid_data,$grid_fields); |
1314 | - $logintype = $this->session->userdata ( 'logintype' ); |
|
1314 | + $logintype = $this->session->userdata('logintype'); |
|
1315 | 1315 | $url = ($logintype == 0 || $logintype == 3) ? "/user/user_invoice_download/" : '/invoices/invoice_download/'; |
1316 | 1316 | if ($Invoice_grid_data->num_rows > 0) { |
1317 | - $query = $Invoice_grid_data->result_array (); |
|
1317 | + $query = $Invoice_grid_data->result_array(); |
|
1318 | 1318 | $total_value = 0; |
1319 | 1319 | $ountstanding_value = 0; |
1320 | 1320 | |
1321 | - foreach ( $query as $key => $value ) { |
|
1322 | - $date = strtotime ( $value ['invoice_date'] ); |
|
1323 | - $invoice_date = date ( "Y-m-d", $date ); |
|
1324 | - $fromdate = strtotime ( $value ['from_date'] ); |
|
1325 | - $from_date = date ( "Y-m-d", $fromdate ); |
|
1326 | - $duedate = strtotime ( $value ['due_date'] ); |
|
1327 | - $due_date = date ( "Y-m-d", $duedate ); |
|
1321 | + foreach ($query as $key => $value) { |
|
1322 | + $date = strtotime($value ['invoice_date']); |
|
1323 | + $invoice_date = date("Y-m-d", $date); |
|
1324 | + $fromdate = strtotime($value ['from_date']); |
|
1325 | + $from_date = date("Y-m-d", $fromdate); |
|
1326 | + $duedate = strtotime($value ['due_date']); |
|
1327 | + $due_date = date("Y-m-d", $duedate); |
|
1328 | 1328 | $outstanding = $value ['amount']; |
1329 | 1329 | $last_payment_date = ''; |
1330 | - $invoice_total_query = $this->db_model->select ( "sum(debit) as debit,sum(credit) as credit,created_date", "invoice_details", array ( |
|
1330 | + $invoice_total_query = $this->db_model->select("sum(debit) as debit,sum(credit) as credit,created_date", "invoice_details", array( |
|
1331 | 1331 | "invoiceid" => $value ['id'], |
1332 | 1332 | "item_type" => "INVPAY" |
1333 | - ), "created_date", "DESC", "1", "0" ); |
|
1333 | + ), "created_date", "DESC", "1", "0"); |
|
1334 | 1334 | // echo $this->db->last_query(); exit; |
1335 | - if ($invoice_total_query->num_rows () > 0) { |
|
1336 | - $invoice_total_query = $invoice_total_query->result_array (); |
|
1335 | + if ($invoice_total_query->num_rows() > 0) { |
|
1336 | + $invoice_total_query = $invoice_total_query->result_array(); |
|
1337 | 1337 | // echo '<pre>'; print_r($invoice_total_query); |
1338 | 1338 | $outstanding -= $invoice_total_query [0] ['credit']; |
1339 | 1339 | |
1340 | 1340 | $last_payment_date = $invoice_total_query [0] ['created_date']; |
1341 | 1341 | if ($last_payment_date) { |
1342 | - $payment_date = strtotime ( $last_payment_date ); |
|
1343 | - $payment_last = date ( "d/m/Y", $payment_date ); |
|
1342 | + $payment_date = strtotime($last_payment_date); |
|
1343 | + $payment_last = date("d/m/Y", $payment_date); |
|
1344 | 1344 | } else { |
1345 | 1345 | $payment_last = ''; |
1346 | 1346 | } |
1347 | 1347 | } |
1348 | 1348 | $invoice_total = ''; |
1349 | - $accountinfo = $this->session->userdata ( 'accountinfo' ); |
|
1349 | + $accountinfo = $this->session->userdata('accountinfo'); |
|
1350 | 1350 | $id = $accountinfo ['id']; |
1351 | 1351 | $query = "select sum(amount) as grand_total from invoices where confirm=1 and accountid=$accountid"; |
1352 | 1352 | |
1353 | - $ext_query = $this->db->query ( $query ); |
|
1354 | - if ($ext_query->num_rows () > 0) { |
|
1355 | - $result_total = $ext_query->result_array (); |
|
1353 | + $ext_query = $this->db->query($query); |
|
1354 | + if ($ext_query->num_rows() > 0) { |
|
1355 | + $result_total = $ext_query->result_array(); |
|
1356 | 1356 | $grandtotal = $result_total [0] ['grand_total']; |
1357 | - $grand_total = $this->common->currency_decimal ( $grandtotal ) . ' ' . $currency_id; |
|
1357 | + $grand_total = $this->common->currency_decimal($grandtotal).' '.$currency_id; |
|
1358 | 1358 | } |
1359 | 1359 | |
1360 | 1360 | $invoice_query = "select sum(credit) as grand_credit from invoice_details where accountid=$accountid"; |
1361 | - $credit_query = $this->db->query ( $invoice_query ); |
|
1362 | - if ($credit_query->num_rows () > 0) { |
|
1363 | - $credit_total = $credit_query->result_array (); |
|
1361 | + $credit_query = $this->db->query($invoice_query); |
|
1362 | + if ($credit_query->num_rows() > 0) { |
|
1363 | + $credit_total = $credit_query->result_array(); |
|
1364 | 1364 | $grand_credit_total = $credit_total [0] ['grand_credit']; |
1365 | 1365 | $grandcredit = $grand_total - $grand_credit_total; |
1366 | - $grand_credit = $this->common->currency_decimal ( $grandcredit ) . ' ' . $currency_id; |
|
1366 | + $grand_credit = $this->common->currency_decimal($grandcredit).' '.$currency_id; |
|
1367 | 1367 | } |
1368 | 1368 | |
1369 | - $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> "; |
|
1369 | + $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> "; |
|
1370 | 1370 | if ($value ['type'] == 'R') { |
1371 | 1371 | $payment = ''; |
1372 | 1372 | $outstanding = 0; |
1373 | 1373 | } else { |
1374 | 1374 | if ($outstanding > 0) { |
1375 | - $payment = '<a style="padding: 0 8px;" href="' . base_url () . 'invoices/invoice_summary/' . $value ['id'] . '" class="btn btn-warning" title="Payment">Unpaid</i></a>'; |
|
1375 | + $payment = '<a style="padding: 0 8px;" href="'.base_url().'invoices/invoice_summary/'.$value ['id'].'" class="btn btn-warning" title="Payment">Unpaid</i></a>'; |
|
1376 | 1376 | } else { |
1377 | 1377 | $payment = ' <button style="padding: 0 8px;" type="button" class="btn btn-success">Paid</button>'; |
1378 | 1378 | } |
1379 | 1379 | } |
1380 | 1380 | |
1381 | - $account_arr = $this->db_model->getSelect ( 'first_name,number,last_name', 'accounts', array ( |
|
1381 | + $account_arr = $this->db_model->getSelect('first_name,number,last_name', 'accounts', array( |
|
1382 | 1382 | 'id' => $value ['accountid'] |
1383 | - ) ); |
|
1384 | - $account_array = $account_arr->result_array (); |
|
1383 | + )); |
|
1384 | + $account_array = $account_arr->result_array(); |
|
1385 | 1385 | if ($value ['generate_type'] == 1) { |
1386 | 1386 | $invoice_type = 'Manually'; |
1387 | 1387 | } else { |
@@ -1394,9 +1394,9 @@ discard block |
||
1394 | 1394 | $icon = '<div class="flx_font flx_drk_pink">I</div>'; |
1395 | 1395 | } |
1396 | 1396 | |
1397 | - $json_data ['rows'] [] = array ( |
|
1398 | - 'cell' => array ( |
|
1399 | - $value ['invoice_prefix'] . $value ['invoiceid'] . $icon, |
|
1397 | + $json_data ['rows'] [] = array( |
|
1398 | + 'cell' => array( |
|
1399 | + $value ['invoice_prefix'].$value ['invoiceid'].$icon, |
|
1400 | 1400 | // $value['invoice_prefix'].$value['invoiceid'].' ('.$value['type'].')', |
1401 | 1401 | $invoice_type, |
1402 | 1402 | // $account_array[0]['first_name'].' '.$account_array[0]['last_name'].'</br>'.$account_array[0]['number'], |
@@ -1404,9 +1404,9 @@ discard block |
||
1404 | 1404 | $from_date, |
1405 | 1405 | $due_date, |
1406 | 1406 | $payment_last, |
1407 | - $this->common_model->to_calculate_currency ( $value ['amount'], '', '', true, false ), |
|
1408 | - $this->common_model->to_calculate_currency ( $outstanding, '', '', true, false ), |
|
1409 | - $download . '' . $payment |
|
1407 | + $this->common_model->to_calculate_currency($value ['amount'], '', '', true, false), |
|
1408 | + $this->common_model->to_calculate_currency($outstanding, '', '', true, false), |
|
1409 | + $download.''.$payment |
|
1410 | 1410 | ) |
1411 | 1411 | ); |
1412 | 1412 | $total_value = $total_value + $value ['amount']; |
@@ -1414,105 +1414,105 @@ discard block |
||
1414 | 1414 | } |
1415 | 1415 | } |
1416 | 1416 | |
1417 | - echo json_encode ( $json_data ); |
|
1417 | + echo json_encode($json_data); |
|
1418 | 1418 | } |
1419 | 1419 | // end |
1420 | 1420 | function user_invoices($accountid) { |
1421 | - $json_data = array (); |
|
1422 | - $count_all = $this->invoices_model->get_user_invoice_list ( false ); |
|
1423 | - $paging_data = $this->form->load_grid_config ( $count_all, $_GET ['rp'], $_GET ['page'] ); |
|
1421 | + $json_data = array(); |
|
1422 | + $count_all = $this->invoices_model->get_user_invoice_list(false); |
|
1423 | + $paging_data = $this->form->load_grid_config($count_all, $_GET ['rp'], $_GET ['page']); |
|
1424 | 1424 | $json_data = $paging_data ["json_paging"]; |
1425 | 1425 | $currency_id = Common_model::$global_config ['system_config'] ['base_currency']; |
1426 | - $query = $this->invoices_model->get_user_invoice_list ( true, $paging_data ["paging"] ["start"], $paging_data ["paging"] ["page_no"] ); |
|
1427 | - $grid_fields = json_decode ( $this->invoices_form->build_invoices_list_for_customer () ); |
|
1428 | - $query = $query->result_array (); |
|
1426 | + $query = $this->invoices_model->get_user_invoice_list(true, $paging_data ["paging"] ["start"], $paging_data ["paging"] ["page_no"]); |
|
1427 | + $grid_fields = json_decode($this->invoices_form->build_invoices_list_for_customer()); |
|
1428 | + $query = $query->result_array(); |
|
1429 | 1429 | $account_arr = ''; |
1430 | 1430 | $created_date = ''; |
1431 | - foreach ( $query as $key => $value ) { |
|
1432 | - $date = strtotime ( $value ['invoice_date'] ); |
|
1433 | - $invoice_date = date ( "d/m/Y", $date ); |
|
1434 | - $fromdate = strtotime ( $value ['from_date'] ); |
|
1435 | - $from_date = date ( "d/m/Y", $fromdate ); |
|
1436 | - $duedate = strtotime ( $value ['due_date'] ); |
|
1437 | - $due_date = date ( "d/m/Y", $duedate ); |
|
1431 | + foreach ($query as $key => $value) { |
|
1432 | + $date = strtotime($value ['invoice_date']); |
|
1433 | + $invoice_date = date("d/m/Y", $date); |
|
1434 | + $fromdate = strtotime($value ['from_date']); |
|
1435 | + $from_date = date("d/m/Y", $fromdate); |
|
1436 | + $duedate = strtotime($value ['due_date']); |
|
1437 | + $due_date = date("d/m/Y", $duedate); |
|
1438 | 1438 | $outstanding = $value ['amount']; |
1439 | - $invoice_total_query = $this->db_model->select ( "sum(debit) as debit,sum(credit) as credit,created_date", "invoice_details", array ( |
|
1439 | + $invoice_total_query = $this->db_model->select("sum(debit) as debit,sum(credit) as credit,created_date", "invoice_details", array( |
|
1440 | 1440 | "invoiceid" => $value ['id'], |
1441 | 1441 | "item_type" => "INVPAY" |
1442 | - ), "created_date", "DESC", "1", "0" ); |
|
1442 | + ), "created_date", "DESC", "1", "0"); |
|
1443 | 1443 | // echo $this->db->last_query(); exit; |
1444 | - if ($invoice_total_query->num_rows () > 0) { |
|
1445 | - $invoice_total_query = $invoice_total_query->result_array (); |
|
1444 | + if ($invoice_total_query->num_rows() > 0) { |
|
1445 | + $invoice_total_query = $invoice_total_query->result_array(); |
|
1446 | 1446 | // echo '<pre>'; print_r($invoice_total_query); |
1447 | 1447 | $outstanding -= $invoice_total_query [0] ['credit']; |
1448 | 1448 | |
1449 | 1449 | $last_payment_date = $invoice_total_query [0] ['created_date']; |
1450 | 1450 | if ($last_payment_date) { |
1451 | - $payment_date = strtotime ( $last_payment_date ); |
|
1452 | - $payment_last = date ( "d/m/Y", $payment_date ); |
|
1451 | + $payment_date = strtotime($last_payment_date); |
|
1452 | + $payment_last = date("d/m/Y", $payment_date); |
|
1453 | 1453 | } else { |
1454 | 1454 | $payment_last = ''; |
1455 | 1455 | } |
1456 | 1456 | } |
1457 | - $invoice_total_query = $this->db_model->select ( "debit,created_date", "invoice_details", array ( |
|
1457 | + $invoice_total_query = $this->db_model->select("debit,created_date", "invoice_details", array( |
|
1458 | 1458 | "invoiceid" => $value ['id'], |
1459 | 1459 | "item_type" => "INVPAY" |
1460 | - ), "created_date", "DESC", "1", "0" ); |
|
1461 | - if ($invoice_total_query->num_rows () > 0) { |
|
1462 | - $invoice_total_query = $invoice_total_query->result_array (); |
|
1460 | + ), "created_date", "DESC", "1", "0"); |
|
1461 | + if ($invoice_total_query->num_rows() > 0) { |
|
1462 | + $invoice_total_query = $invoice_total_query->result_array(); |
|
1463 | 1463 | // $outstanding = $invoice_total_query[0]['debit']; |
1464 | 1464 | $created_date = $invoice_total_query [0] ['created_date']; |
1465 | 1465 | } |
1466 | - $accountinfo = $this->session->userdata ( 'accountinfo' ); |
|
1466 | + $accountinfo = $this->session->userdata('accountinfo'); |
|
1467 | 1467 | $query = "select sum(amount) as grand_total from invoices where confirm=1 and accountid=$accountid"; |
1468 | 1468 | |
1469 | - $ext_query = $this->db->query ( $query ); |
|
1470 | - if ($ext_query->num_rows () > 0) { |
|
1471 | - $result_total = $ext_query->result_array (); |
|
1469 | + $ext_query = $this->db->query($query); |
|
1470 | + if ($ext_query->num_rows() > 0) { |
|
1471 | + $result_total = $ext_query->result_array(); |
|
1472 | 1472 | $grandtotal = $result_total [0] ['grand_total']; |
1473 | - $grand_total = $this->common->currency_decimal ( $grandtotal ) . ' ' . $currency_id; |
|
1473 | + $grand_total = $this->common->currency_decimal($grandtotal).' '.$currency_id; |
|
1474 | 1474 | } |
1475 | 1475 | |
1476 | 1476 | $invoice_query = "select sum(credit) as grand_credit from invoice_details where accountid=$accountid"; |
1477 | - $credit_query = $this->db->query ( $invoice_query ); |
|
1478 | - if ($credit_query->num_rows () > 0) { |
|
1479 | - $credit_total = $credit_query->result_array (); |
|
1477 | + $credit_query = $this->db->query($invoice_query); |
|
1478 | + if ($credit_query->num_rows() > 0) { |
|
1479 | + $credit_total = $credit_query->result_array(); |
|
1480 | 1480 | $grand_credit_total = $credit_total [0] ['grand_credit']; |
1481 | 1481 | $grandcredit = $grand_total - $grand_credit_total; |
1482 | - $grand_credit = $this->common->currency_decimal ( $grandcredit ) . ' ' . $currency_id; |
|
1482 | + $grand_credit = $this->common->currency_decimal($grandcredit).' '.$currency_id; |
|
1483 | 1483 | } |
1484 | - $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> '; |
|
1484 | + $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> '; |
|
1485 | 1485 | if ($outstanding > 0) { |
1486 | - $payment = ' <a style="padding: 0 8px;" href="' . base_url () . 'user/user_invoice_payment/' . $value ['id'] . '" class="btn btn-warning" title="Payment">Unpaid</a>'; |
|
1486 | + $payment = ' <a style="padding: 0 8px;" href="'.base_url().'user/user_invoice_payment/'.$value ['id'].'" class="btn btn-warning" title="Payment">Unpaid</a>'; |
|
1487 | 1487 | } else { |
1488 | 1488 | |
1489 | 1489 | $payment = ' <button style="padding: 0 8px;" class="btn btn-success" type="button">Paid</button>'; |
1490 | 1490 | } |
1491 | - $account_arr = $this->db_model->getSelect ( 'first_name,number,last_name', 'accounts', array ( |
|
1491 | + $account_arr = $this->db_model->getSelect('first_name,number,last_name', 'accounts', array( |
|
1492 | 1492 | 'id' => $value ['accountid'] |
1493 | - ) ); |
|
1494 | - $account_array = $account_arr->result_array (); |
|
1495 | - $date = strtotime ( $value ['invoice_date'] ); |
|
1496 | - $date = strtotime ( "+7 day", $date ); |
|
1497 | - $time = date ( "Y-m-d h:i:s ", $date ); |
|
1498 | - $json_data ['rows'] [] = array ( |
|
1499 | - 'cell' => array ( |
|
1500 | - $value ['invoice_prefix'] . $value ['invoiceid'] . ' (' . $value ['type'] . ')', |
|
1501 | - $account_array [0] ['first_name'] . ' ' . $account_array [0] ['last_name'] . '</br>' . $account_array [0] ['number'], |
|
1493 | + )); |
|
1494 | + $account_array = $account_arr->result_array(); |
|
1495 | + $date = strtotime($value ['invoice_date']); |
|
1496 | + $date = strtotime("+7 day", $date); |
|
1497 | + $time = date("Y-m-d h:i:s ", $date); |
|
1498 | + $json_data ['rows'] [] = array( |
|
1499 | + 'cell' => array( |
|
1500 | + $value ['invoice_prefix'].$value ['invoiceid'].' ('.$value ['type'].')', |
|
1501 | + $account_array [0] ['first_name'].' '.$account_array [0] ['last_name'].'</br>'.$account_array [0] ['number'], |
|
1502 | 1502 | $invoice_date, |
1503 | 1503 | $from_date, |
1504 | 1504 | $due_date, |
1505 | 1505 | $payment_last, |
1506 | - $this->common->currency_decimal ( $value ['amount'] ) . ' ' . $currency_id, |
|
1507 | - $this->common->currency_decimal ( $outstanding ) . ' ' . $currency_id, |
|
1508 | - $download . $payment |
|
1506 | + $this->common->currency_decimal($value ['amount']).' '.$currency_id, |
|
1507 | + $this->common->currency_decimal($outstanding).' '.$currency_id, |
|
1508 | + $download.$payment |
|
1509 | 1509 | ) |
1510 | 1510 | |
1511 | 1511 | ); |
1512 | 1512 | } |
1513 | 1513 | |
1514 | - $json_data ['rows'] [] = array ( |
|
1515 | - 'cell' => array ( |
|
1514 | + $json_data ['rows'] [] = array( |
|
1515 | + 'cell' => array( |
|
1516 | 1516 | // $date.'- 0'.$value['id'].'('.$value['type'].')', |
1517 | 1517 | '<b>Grand Total</b>', |
1518 | 1518 | '', |
@@ -1520,166 +1520,166 @@ discard block |
||
1520 | 1520 | '', |
1521 | 1521 | '', |
1522 | 1522 | '', |
1523 | - "<b>" . $grand_total . "</b>", |
|
1524 | - "<b>" . $grand_credit . "<b>", |
|
1523 | + "<b>".$grand_total."</b>", |
|
1524 | + "<b>".$grand_credit."<b>", |
|
1525 | 1525 | '' |
1526 | 1526 | ) |
1527 | 1527 | |
1528 | 1528 | ); |
1529 | - echo json_encode ( $json_data ); |
|
1529 | + echo json_encode($json_data); |
|
1530 | 1530 | } |
1531 | 1531 | function invoice_logo_delete($accountid) { |
1532 | - $invoiceconf = $this->db_model->getSelect ( "*", "invoice_conf", array ( |
|
1532 | + $invoiceconf = $this->db_model->getSelect("*", "invoice_conf", array( |
|
1533 | 1533 | "id" => $accountid |
1534 | - ) ); |
|
1535 | - $result = $invoiceconf->result_array (); |
|
1534 | + )); |
|
1535 | + $result = $invoiceconf->result_array(); |
|
1536 | 1536 | $logo = $result [0] ['logo']; |
1537 | - $post_arr = array ( |
|
1537 | + $post_arr = array( |
|
1538 | 1538 | 'logo' => '' |
1539 | 1539 | ); |
1540 | - $where_arr = array ( |
|
1540 | + $where_arr = array( |
|
1541 | 1541 | 'logo' => $logo |
1542 | 1542 | ); |
1543 | - $this->db->where ( $where_arr ); |
|
1544 | - $this->db->update ( 'invoice_conf', $post_arr ); |
|
1543 | + $this->db->where($where_arr); |
|
1544 | + $this->db->update('invoice_conf', $post_arr); |
|
1545 | 1545 | // redirect(base_url() . 'invoices/invoice_conf/'); |
1546 | 1546 | } |
1547 | 1547 | function invoice_list_view_invoice($invoiceid = false) { |
1548 | - $data ['username'] = $this->session->userdata ( 'user_name' ); |
|
1549 | - $data ['page_title'] = gettext ( 'Invoice Detail' ); |
|
1548 | + $data ['username'] = $this->session->userdata('user_name'); |
|
1549 | + $data ['page_title'] = gettext('Invoice Detail'); |
|
1550 | 1550 | |
1551 | - $cdrs_query = $this->invoices_model->getCdrs_invoice ( $invoiceid ); |
|
1551 | + $cdrs_query = $this->invoices_model->getCdrs_invoice($invoiceid); |
|
1552 | 1552 | |
1553 | - $invoice_cdr_list = array (); |
|
1554 | - $cdr_list = array (); |
|
1555 | - if ($cdrs_query->num_rows () > 0) { |
|
1556 | - foreach ( $cdrs_query->result_array () as $cdr ) { |
|
1557 | - $cdr ['charge'] = $this->common_model->calculate_currency ( $cdr ['debit'] - $cdr ['credit'] ); |
|
1558 | - array_push ( $cdr_list, $cdr ); |
|
1553 | + $invoice_cdr_list = array(); |
|
1554 | + $cdr_list = array(); |
|
1555 | + if ($cdrs_query->num_rows() > 0) { |
|
1556 | + foreach ($cdrs_query->result_array() as $cdr) { |
|
1557 | + $cdr ['charge'] = $this->common_model->calculate_currency($cdr ['debit'] - $cdr ['credit']); |
|
1558 | + array_push($cdr_list, $cdr); |
|
1559 | 1559 | } |
1560 | 1560 | } |
1561 | 1561 | $data ['invoice_cdr_list'] = $cdr_list; |
1562 | 1562 | |
1563 | - $invoice_total_query = $this->Astpp_common->get_invoice_total ( $invoiceid ); |
|
1563 | + $invoice_total_query = $this->Astpp_common->get_invoice_total($invoiceid); |
|
1564 | 1564 | |
1565 | - $total_list = array (); |
|
1566 | - $invoice_total_list = array (); |
|
1565 | + $total_list = array(); |
|
1566 | + $invoice_total_list = array(); |
|
1567 | 1567 | |
1568 | - if ($invoice_total_query->num_rows () > 0) { |
|
1569 | - foreach ( $invoice_total_query->result_array () as $total ) { |
|
1570 | - array_push ( $total_list, $total ); |
|
1568 | + if ($invoice_total_query->num_rows() > 0) { |
|
1569 | + foreach ($invoice_total_query->result_array() as $total) { |
|
1570 | + array_push($total_list, $total); |
|
1571 | 1571 | } |
1572 | 1572 | } |
1573 | 1573 | $data ['invoice_total_list'] = $total_list; |
1574 | - $invoicedata = $this->Astpp_common->get_invoice ( $invoiceid ); |
|
1574 | + $invoicedata = $this->Astpp_common->get_invoice($invoiceid); |
|
1575 | 1575 | $data ['invoiceid'] = @$invoicedata [0] ['invoiceid']; |
1576 | 1576 | $data ['invoicedate'] = @$invoicedata [0] ['date']; |
1577 | 1577 | $data ['accountid'] = @$invoicedata [0] ['accountid']; |
1578 | - if (! empty ( $invoicedata )) { |
|
1579 | - $accountinfo = $this->invoices_model->get_account_including_closed ( @$invoicedata [0] ['accountid'] ); |
|
1578 | + if ( ! empty ($invoicedata)) { |
|
1579 | + $accountinfo = $this->invoices_model->get_account_including_closed(@$invoicedata [0] ['accountid']); |
|
1580 | 1580 | $data ['accountinfo'] = $accountinfo; |
1581 | 1581 | } |
1582 | - $invoiceconf = $this->invoices_model->get_invoiceconf ( $accountinfo ['reseller'] ); |
|
1582 | + $invoiceconf = $this->invoices_model->get_invoiceconf($accountinfo ['reseller']); |
|
1583 | 1583 | $data ['invoiceconf'] = $invoiceconf; |
1584 | - $this->load->view ( 'view_account_invoice_detail', $data ); |
|
1584 | + $this->load->view('view_account_invoice_detail', $data); |
|
1585 | 1585 | } |
1586 | 1586 | function invoice_download($invoiceid) { |
1587 | - $this->db->where ( 'id', $invoiceid ); |
|
1588 | - $this->db->select ( 'type' ); |
|
1589 | - $this->db->from ( 'invoices' ); |
|
1590 | - $result = $this->db->get (); |
|
1591 | - if ($result->num_rows () > 0) { |
|
1592 | - $result = $result->result_array (); |
|
1587 | + $this->db->where('id', $invoiceid); |
|
1588 | + $this->db->select('type'); |
|
1589 | + $this->db->from('invoices'); |
|
1590 | + $result = $this->db->get(); |
|
1591 | + if ($result->num_rows() > 0) { |
|
1592 | + $result = $result->result_array(); |
|
1593 | 1593 | $type = $result [0] ['type']; |
1594 | 1594 | if ($type == 'I') { |
1595 | - $this->invoice_main_download ( $invoiceid ); |
|
1595 | + $this->invoice_main_download($invoiceid); |
|
1596 | 1596 | } |
1597 | 1597 | if ($type == 'R') { |
1598 | - $this->receipt_download ( $invoiceid ); |
|
1598 | + $this->receipt_download($invoiceid); |
|
1599 | 1599 | } |
1600 | 1600 | } else { |
1601 | - redirect ( base_url () . 'invoices/invoice_list/' ); |
|
1601 | + redirect(base_url().'invoices/invoice_list/'); |
|
1602 | 1602 | } |
1603 | 1603 | } |
1604 | 1604 | function invoice_screen() { |
1605 | 1605 | $login_type = $this->session->userdata ['userlevel_logintype']; |
1606 | 1606 | if ($login_type == - 1 || $login_type == 2 || $login_type == 1 || $login_type == 4) { |
1607 | - if ($this->input->post ()) { |
|
1608 | - $data = $this->input->post (); |
|
1607 | + if ($this->input->post()) { |
|
1608 | + $data = $this->input->post(); |
|
1609 | 1609 | if ($data ['accountid'] == '' || $data ['accountid'] == '-Select-') { |
1610 | - $this->session->set_flashdata ( 'astpp_notification', 'Please select accounts' ); |
|
1611 | - redirect ( base_url () . "invoices/invoice_list/" ); |
|
1610 | + $this->session->set_flashdata('astpp_notification', 'Please select accounts'); |
|
1611 | + redirect(base_url()."invoices/invoice_list/"); |
|
1612 | 1612 | } |
1613 | - if (! empty ( $data )) { |
|
1614 | - if (isset ( $data ['notes'] ) && $data ['notes'] != '') { |
|
1615 | - $this->session->set_userdata ( 'invoice_note', $data ['notes'] ); |
|
1613 | + if ( ! empty ($data)) { |
|
1614 | + if (isset ($data ['notes']) && $data ['notes'] != '') { |
|
1615 | + $this->session->set_userdata('invoice_note', $data ['notes']); |
|
1616 | 1616 | } |
1617 | - $date = date ( 'Y-m-d' ); |
|
1618 | - $feture_date = date ( 'Y-m-d', strtotime ( $date ) ); |
|
1617 | + $date = date('Y-m-d'); |
|
1618 | + $feture_date = date('Y-m-d', strtotime($date)); |
|
1619 | 1619 | $from_date = $data ['fromdate']; |
1620 | 1620 | $genrated_date = $data ['todate']; |
1621 | - $to_date = date ( 'Y-m-d', strtotime ( $genrated_date ) ); |
|
1621 | + $to_date = date('Y-m-d', strtotime($genrated_date)); |
|
1622 | 1622 | if ($to_date > $feture_date) { |
1623 | - $this->session->set_flashdata ( 'astpp_notification', 'To date should not be greater than current date.' ); |
|
1624 | - redirect ( base_url () . "invoices/invoice_list/" ); |
|
1623 | + $this->session->set_flashdata('astpp_notification', 'To date should not be greater than current date.'); |
|
1624 | + redirect(base_url()."invoices/invoice_list/"); |
|
1625 | 1625 | } else { |
1626 | - $todate = $data ['todate'] . ' ' . '23:59:59'; |
|
1627 | - $from_date = $data ['fromdate'] . ' ' . '00:00:01'; |
|
1626 | + $todate = $data ['todate'].' '.'23:59:59'; |
|
1627 | + $from_date = $data ['fromdate'].' '.'00:00:01'; |
|
1628 | 1628 | $accountid = $data ['accountid']; |
1629 | - $acc_query = $this->db_model->getSelect ( "*", "accounts", array ( |
|
1629 | + $acc_query = $this->db_model->getSelect("*", "accounts", array( |
|
1630 | 1630 | "id" => $accountid |
1631 | - ) ); |
|
1632 | - $accountdata = $acc_query->result_array (); |
|
1631 | + )); |
|
1632 | + $accountdata = $acc_query->result_array(); |
|
1633 | 1633 | $accountdata = $accountdata [0]; |
1634 | - $screen_path = getcwd () . "/cron"; |
|
1635 | - $screen_filename = "Email_Broadcast_" . strtotime ( 'now' ); |
|
1636 | - $command = "cd " . $screen_path . " && /usr/bin/screen -d -m -S $screen_filename php cron.php BroadcastEmail"; |
|
1637 | - exec ( $command ); |
|
1634 | + $screen_path = getcwd()."/cron"; |
|
1635 | + $screen_filename = "Email_Broadcast_".strtotime('now'); |
|
1636 | + $command = "cd ".$screen_path." && /usr/bin/screen -d -m -S $screen_filename php cron.php BroadcastEmail"; |
|
1637 | + exec($command); |
|
1638 | 1638 | $invoice_data_count = 0; |
1639 | - $invoice_conf = array (); |
|
1639 | + $invoice_conf = array(); |
|
1640 | 1640 | if ($accountdata ['reseller_id'] == 0) { |
1641 | - $where = array ( |
|
1641 | + $where = array( |
|
1642 | 1642 | "accountid" => 1 |
1643 | 1643 | ); |
1644 | 1644 | } else { |
1645 | - $where = array ( |
|
1645 | + $where = array( |
|
1646 | 1646 | "accountid" => $accountdata ['reseller_id'] |
1647 | 1647 | ); |
1648 | 1648 | } |
1649 | - $query = $this->db_model->getSelect ( "*", "invoice_conf", $where ); |
|
1649 | + $query = $this->db_model->getSelect("*", "invoice_conf", $where); |
|
1650 | 1650 | if ($query->num_rows > 0) { |
1651 | - $invoice_conf = $query->result_array (); |
|
1651 | + $invoice_conf = $query->result_array(); |
|
1652 | 1652 | $invoice_conf = $invoice_conf [0]; |
1653 | 1653 | } else { |
1654 | - $query = $this->db_model->getSelect ( "*", "invoice_conf", array ( |
|
1654 | + $query = $this->db_model->getSelect("*", "invoice_conf", array( |
|
1655 | 1655 | "accountid" => 1 |
1656 | - ) ); |
|
1657 | - $invoice_conf = $query->result_array (); |
|
1656 | + )); |
|
1657 | + $invoice_conf = $query->result_array(); |
|
1658 | 1658 | $invoice_conf = $invoice_conf [0]; |
1659 | 1659 | } |
1660 | - $last_invoice_ID = $this->get_invoice_date ( "invoiceid" ); |
|
1660 | + $last_invoice_ID = $this->get_invoice_date("invoiceid"); |
|
1661 | 1661 | if ($last_invoice_ID && $last_invoice_ID > 0) { |
1662 | 1662 | $last_invoice_ID = ($last_invoice_ID + 1); |
1663 | 1663 | } else { |
1664 | 1664 | $last_invoice_ID = $invoice_conf ['invoice_start_from']; |
1665 | 1665 | } |
1666 | - $last_invoice_ID = str_pad ( $last_invoice_ID, (strlen ( $last_invoice_ID ) + 4), '0', STR_PAD_LEFT ); |
|
1666 | + $last_invoice_ID = str_pad($last_invoice_ID, (strlen($last_invoice_ID) + 4), '0', STR_PAD_LEFT); |
|
1667 | 1667 | if ($accountdata ['posttoexternal'] == 1) { |
1668 | 1668 | $balance = ($accountdata ['credit_limit'] - $accountdata ['balance']); |
1669 | 1669 | } else { |
1670 | 1670 | $balance = $accountdata ['balance']; |
1671 | 1671 | } |
1672 | 1672 | if ($invoice_conf ['interval'] > 0) { |
1673 | - $due_date = gmdate ( "Y-m-d H:i:s", strtotime ( gmdate ( "Y-m-d H:i:s" ) . " +" . $invoice_conf ['interval'] . " days" ) ); |
|
1673 | + $due_date = gmdate("Y-m-d H:i:s", strtotime(gmdate("Y-m-d H:i:s")." +".$invoice_conf ['interval']." days")); |
|
1674 | 1674 | } else { |
1675 | - $due_date = gmdate ( "Y-m-d H:i:s", strtotime ( gmdate ( "Y-m-d H:i:s" ) . " +7 days" ) ); |
|
1675 | + $due_date = gmdate("Y-m-d H:i:s", strtotime(gmdate("Y-m-d H:i:s")." +7 days")); |
|
1676 | 1676 | } |
1677 | - $invoice_data = array ( |
|
1677 | + $invoice_data = array( |
|
1678 | 1678 | "accountid" => $accountdata ['id'], |
1679 | 1679 | "invoice_prefix" => $invoice_conf ['invoice_prefix'], |
1680 | 1680 | "invoiceid" => $last_invoice_ID, |
1681 | 1681 | "reseller_id" => $accountdata ['reseller_id'], |
1682 | - "invoice_date" => gmdate ( "Y-m-d H:i:s" ), |
|
1682 | + "invoice_date" => gmdate("Y-m-d H:i:s"), |
|
1683 | 1683 | "from_date" => $from_date, |
1684 | 1684 | "to_date" => $todate, |
1685 | 1685 | "due_date" => $due_date, |
@@ -1691,23 +1691,23 @@ discard block |
||
1691 | 1691 | 'notes' => $data ['notes'] |
1692 | 1692 | ); |
1693 | 1693 | // echo "<pre>"; print_r($invoice_data); exit; |
1694 | - $invoice_note = $this->session->userdata ( 'invoice_note' ); |
|
1695 | - $this->session->unset_userdata ( 'invoice_note' ); |
|
1694 | + $invoice_note = $this->session->userdata('invoice_note'); |
|
1695 | + $this->session->unset_userdata('invoice_note'); |
|
1696 | 1696 | $invoice_data ['invoice_note'] = $invoice_note; |
1697 | - $this->db->insert ( "invoices", $invoice_data ); |
|
1698 | - $invoiceid = $this->db->insert_id (); |
|
1697 | + $this->db->insert("invoices", $invoice_data); |
|
1698 | + $invoiceid = $this->db->insert_id(); |
|
1699 | 1699 | // $generateInvoice->process_invoice($accountdata,$from_date,$todate); |
1700 | - $this->session->set_flashdata ( 'astpp_errormsg', 'Invoice generation completed .' ); |
|
1701 | - redirect ( base_url () . "invoices/invoice_manually_edit/" . $invoiceid ); |
|
1700 | + $this->session->set_flashdata('astpp_errormsg', 'Invoice generation completed .'); |
|
1701 | + redirect(base_url()."invoices/invoice_manually_edit/".$invoiceid); |
|
1702 | 1702 | } |
1703 | 1703 | } |
1704 | 1704 | } else { |
1705 | - $this->session->set_flashdata ( 'astpp_errormsg', 'No data found.....' ); |
|
1706 | - redirect ( base_url () . "invoices/invoice_list/" ); |
|
1705 | + $this->session->set_flashdata('astpp_errormsg', 'No data found.....'); |
|
1706 | + redirect(base_url()."invoices/invoice_list/"); |
|
1707 | 1707 | } |
1708 | 1708 | } else { |
1709 | - $this->session->set_flashdata ( 'astpp_notification', 'Permission Denied.' ); |
|
1710 | - redirect ( base_url () . "invoices/invoice_list/" ); |
|
1709 | + $this->session->set_flashdata('astpp_notification', 'Permission Denied.'); |
|
1710 | + redirect(base_url()."invoices/invoice_list/"); |
|
1711 | 1711 | } |
1712 | 1712 | } |
1713 | 1713 | |
@@ -1717,94 +1717,94 @@ discard block |
||
1717 | 1717 | */ |
1718 | 1718 | function get_invoice_date($select, $accountid = false) { |
1719 | 1719 | if ($accountid) { |
1720 | - $where = array ( |
|
1720 | + $where = array( |
|
1721 | 1721 | 'type' => "I", |
1722 | 1722 | "accountid" => $accountid |
1723 | 1723 | ); |
1724 | - $query = $this->db_model->select ( $select, "invoices", $where, "to_date", "DESC", "1", "0" ); |
|
1724 | + $query = $this->db_model->select($select, "invoices", $where, "to_date", "DESC", "1", "0"); |
|
1725 | 1725 | } else { |
1726 | - $where = array ( |
|
1726 | + $where = array( |
|
1727 | 1727 | 'type' => "I" |
1728 | 1728 | ); |
1729 | - $query = $this->db_model->select ( $select, "invoices", $where, "id", "DESC", "1", "0" ); |
|
1729 | + $query = $this->db_model->select($select, "invoices", $where, "id", "DESC", "1", "0"); |
|
1730 | 1730 | } |
1731 | 1731 | if ($query->num_rows > 0) { |
1732 | - $invoiceid = $query->result_array (); |
|
1732 | + $invoiceid = $query->result_array(); |
|
1733 | 1733 | $invoice_date = $invoiceid [0] [$select]; |
1734 | 1734 | return $invoice_date; |
1735 | 1735 | } |
1736 | 1736 | return false; |
1737 | 1737 | } |
1738 | 1738 | function invoice_main_download($invoiceid) { |
1739 | - $invoicedata = $this->db_model->getSelect ( "*", "invoices", array ( |
|
1739 | + $invoicedata = $this->db_model->getSelect("*", "invoices", array( |
|
1740 | 1740 | "id" => $invoiceid |
1741 | - ) ); |
|
1742 | - $invoicedata = $invoicedata->result_array (); |
|
1741 | + )); |
|
1742 | + $invoicedata = $invoicedata->result_array(); |
|
1743 | 1743 | $invoicedata = $invoicedata [0]; |
1744 | 1744 | $invoice_path = ''; |
1745 | 1745 | $accountid = $invoicedata ['accountid']; |
1746 | - $acc_file = $invoice_path . $accountid . '/' . $invoiceid; |
|
1747 | - $accountdata = $this->db_model->getSelect ( "*", "accounts", array ( |
|
1746 | + $acc_file = $invoice_path.$accountid.'/'.$invoiceid; |
|
1747 | + $accountdata = $this->db_model->getSelect("*", "accounts", array( |
|
1748 | 1748 | "id" => $accountid |
1749 | - ) ); |
|
1750 | - $accountdata = $accountdata->result_array (); |
|
1749 | + )); |
|
1750 | + $accountdata = $accountdata->result_array(); |
|
1751 | 1751 | $accountdata = $accountdata [0]; |
1752 | 1752 | |
1753 | 1753 | $login_type = $this->session->userdata ['userlevel_logintype']; |
1754 | - $query = "select item_type,credit from invoice_details where invoiceid = " . $invoicedata ['id'] . " and item_type='INVPAY' Group By id order by item_type desc"; |
|
1754 | + $query = "select item_type,credit from invoice_details where invoiceid = ".$invoicedata ['id']." and item_type='INVPAY' Group By id order by item_type desc"; |
|
1755 | 1755 | // echo $query; exit; |
1756 | - $invoice_total_query = $this->db->query ( $query ); |
|
1757 | - if ($invoice_total_query->num_rows () > 0) { |
|
1758 | - $total = $invoice_total_query->result_array (); |
|
1759 | - foreach ( $total as $key => $value ) { |
|
1756 | + $invoice_total_query = $this->db->query($query); |
|
1757 | + if ($invoice_total_query->num_rows() > 0) { |
|
1758 | + $total = $invoice_total_query->result_array(); |
|
1759 | + foreach ($total as $key => $value) { |
|
1760 | 1760 | $debit = $value ['credit']; |
1761 | 1761 | } |
1762 | 1762 | if ($debit) { |
1763 | 1763 | // echo 'debit'; exit; |
1764 | - $invoice_path = $this->config->item ( 'invoices_path' ); |
|
1765 | - $download_path = $invoice_path . $accountdata ["id"] . '/' . $invoicedata ['invoice_prefix'] . $invoicedata ['invoiceid'] . "_invoice.pdf"; |
|
1766 | - unlink ( $download_path ); |
|
1767 | - $res = $this->common->get_invoice_template ( $invoicedata, $accountdata, "TRUE" ); |
|
1764 | + $invoice_path = $this->config->item('invoices_path'); |
|
1765 | + $download_path = $invoice_path.$accountdata ["id"].'/'.$invoicedata ['invoice_prefix'].$invoicedata ['invoiceid']."_invoice.pdf"; |
|
1766 | + unlink($download_path); |
|
1767 | + $res = $this->common->get_invoice_template($invoicedata, $accountdata, "TRUE"); |
|
1768 | 1768 | } |
1769 | 1769 | } |
1770 | - $invoice_path = $this->config->item ( 'invoices_path' ); |
|
1771 | - $download_path = $invoice_path . $accountdata ["id"] . '/' . $invoicedata ['invoice_prefix'] . $invoicedata ['invoiceid'] . "_invoice.pdf"; |
|
1772 | - $res = $this->common->get_invoice_template ( $invoicedata, $accountdata, "TRUE" ); |
|
1770 | + $invoice_path = $this->config->item('invoices_path'); |
|
1771 | + $download_path = $invoice_path.$accountdata ["id"].'/'.$invoicedata ['invoice_prefix'].$invoicedata ['invoiceid']."_invoice.pdf"; |
|
1772 | + $res = $this->common->get_invoice_template($invoicedata, $accountdata, "TRUE"); |
|
1773 | 1773 | } |
1774 | 1774 | function Sec2Minutes($seconds) { |
1775 | - return sprintf ( "%02.2d:%02.2d", floor ( $seconds / 60 ), $seconds % 60 ); |
|
1775 | + return sprintf("%02.2d:%02.2d", floor($seconds / 60), $seconds % 60); |
|
1776 | 1776 | } |
1777 | 1777 | function receipt_download($invoiceid) { |
1778 | - $login_info = $this->session->userdata ( 'accountinfo' ); |
|
1779 | - ob_start (); |
|
1780 | - $this->load->library ( '/html2pdf/html2pdf' ); |
|
1781 | - $template_config = $this->config->item ( 'invoice_template' ); |
|
1782 | - include ($template_config . 'invoice_template_receipt.php'); |
|
1783 | - $content = ob_get_clean (); |
|
1784 | - ob_clean (); |
|
1785 | - $accountid = $this->common->get_field_name ( 'accountid', 'invoices', $invoiceid ); |
|
1786 | - $accountdata = $this->db_model->getSelect ( "*", "accounts", array ( |
|
1778 | + $login_info = $this->session->userdata('accountinfo'); |
|
1779 | + ob_start(); |
|
1780 | + $this->load->library('/html2pdf/html2pdf'); |
|
1781 | + $template_config = $this->config->item('invoice_template'); |
|
1782 | + include ($template_config.'invoice_template_receipt.php'); |
|
1783 | + $content = ob_get_clean(); |
|
1784 | + ob_clean(); |
|
1785 | + $accountid = $this->common->get_field_name('accountid', 'invoices', $invoiceid); |
|
1786 | + $accountdata = $this->db_model->getSelect("*", "accounts", array( |
|
1787 | 1787 | "id" => $accountid |
1788 | - ) ); |
|
1789 | - $accountdata = $accountdata->result_array (); |
|
1788 | + )); |
|
1789 | + $accountdata = $accountdata->result_array(); |
|
1790 | 1790 | $accountdata = $accountdata [0]; |
1791 | - $accountdata ["country"] = $this->common->get_field_name ( 'country', 'countrycode', $accountdata ["country_id"] ); |
|
1791 | + $accountdata ["country"] = $this->common->get_field_name('country', 'countrycode', $accountdata ["country_id"]); |
|
1792 | 1792 | |
1793 | 1793 | if ($login_info ['type'] == - 1) { |
1794 | 1794 | $data ["to_currency"] = Common_model::$global_config ['system_config'] ['base_currency']; |
1795 | 1795 | $currency = $data ["to_currency"]; |
1796 | 1796 | } elseif ($login_info ['type'] == 1) { |
1797 | - $accountdata ["currency_id"] = $this->common->get_field_name ( 'currency', 'currency', $login_info ["currency_id"] ); |
|
1797 | + $accountdata ["currency_id"] = $this->common->get_field_name('currency', 'currency', $login_info ["currency_id"]); |
|
1798 | 1798 | $currency = $accountdata ["currency_id"]; |
1799 | 1799 | } else { |
1800 | - $accountdata ["currency_id"] = $this->common->get_field_name ( 'currency', 'currency', $login_info ["currency_id"] ); |
|
1800 | + $accountdata ["currency_id"] = $this->common->get_field_name('currency', 'currency', $login_info ["currency_id"]); |
|
1801 | 1801 | $currency = $accountdata ["currency_id"]; |
1802 | 1802 | } |
1803 | - $invoice_cdr_list = array (); |
|
1804 | - $invoicedata = $this->db_model->getSelect ( "*", "invoices", array ( |
|
1803 | + $invoice_cdr_list = array(); |
|
1804 | + $invoicedata = $this->db_model->getSelect("*", "invoices", array( |
|
1805 | 1805 | "id" => $invoiceid |
1806 | - ) ); |
|
1807 | - $invoicedata = $invoicedata->result_array (); |
|
1806 | + )); |
|
1807 | + $invoicedata = $invoicedata->result_array(); |
|
1808 | 1808 | $invoicedata = $invoicedata [0]; |
1809 | 1809 | |
1810 | 1810 | $data ['invoiceid'] = @$invoicedata [0] ['id']; |
@@ -1814,16 +1814,16 @@ discard block |
||
1814 | 1814 | $data ['accountid'] = @$invoicedata [0] ['accountid']; |
1815 | 1815 | $data ['from_date'] = @$invoicedata [0] ['from_date']; |
1816 | 1816 | $data ['to_date'] = @$invoicedata [0] ['to_date']; |
1817 | - $total_list = array (); |
|
1817 | + $total_list = array(); |
|
1818 | 1818 | $data ['description'] = ''; |
1819 | 1819 | $data ['item_type'] = ''; |
1820 | 1820 | $data ['debit'] = ''; |
1821 | - $invoice_total_list = array (); |
|
1822 | - $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"; |
|
1823 | - $invoice_total_query = $this->db->query ( $query ); |
|
1824 | - if ($invoice_total_query->num_rows () > 0) { |
|
1825 | - $invoice_total_query = $invoice_total_query->result_array (); |
|
1826 | - foreach ( $invoice_total_query as $key => $value ) { |
|
1821 | + $invoice_total_list = array(); |
|
1822 | + $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"; |
|
1823 | + $invoice_total_query = $this->db->query($query); |
|
1824 | + if ($invoice_total_query->num_rows() > 0) { |
|
1825 | + $invoice_total_query = $invoice_total_query->result_array(); |
|
1826 | + foreach ($invoice_total_query as $key => $value) { |
|
1827 | 1827 | $data ['item_type'] = $value ['item_type']; |
1828 | 1828 | $data ['description'] = $value ['description']; |
1829 | 1829 | if ($value ['item_type'] == 'Refill') { |
@@ -1836,12 +1836,12 @@ discard block |
||
1836 | 1836 | } |
1837 | 1837 | } else { |
1838 | 1838 | //ASTPP_receipt_description_not_display_issue |
1839 | - $query = "select item_type,description,created_date,invoiceid,debit,credit from invoice_details where invoiceid = " . $invoiceid . " And ( item_type='SUBCHRG' OR item_type='DIDCHRG') Group By item_type"; |
|
1839 | + $query = "select item_type,description,created_date,invoiceid,debit,credit from invoice_details where invoiceid = ".$invoiceid." And ( item_type='SUBCHRG' OR item_type='DIDCHRG') Group By item_type"; |
|
1840 | 1840 | //END |
1841 | - $invoice_total_query = $this->db->query ( $query ); |
|
1842 | - if ($invoice_total_query->num_rows () > 0) { |
|
1843 | - $invoice_total_query = $invoice_total_query->result_array (); |
|
1844 | - foreach ( $invoice_total_query as $key => $value ) { |
|
1841 | + $invoice_total_query = $this->db->query($query); |
|
1842 | + if ($invoice_total_query->num_rows() > 0) { |
|
1843 | + $invoice_total_query = $invoice_total_query->result_array(); |
|
1844 | + foreach ($invoice_total_query as $key => $value) { |
|
1845 | 1845 | $data ['item_type'] = $value ['item_type']; |
1846 | 1846 | $data ['description'] = $value ['description']; |
1847 | 1847 | if ($value ['item_type'] == 'Refill') { |
@@ -1860,17 +1860,17 @@ discard block |
||
1860 | 1860 | $accountid = '1'; |
1861 | 1861 | else |
1862 | 1862 | $accountid = $accountdata ['reseller_id']; |
1863 | - $invoiceconf = $this->db_model->getSelect ( "*", "invoice_conf", array ( |
|
1863 | + $invoiceconf = $this->db_model->getSelect("*", "invoice_conf", array( |
|
1864 | 1864 | "accountid" => $accountid |
1865 | - ) ); |
|
1866 | - $invoiceconf = $invoiceconf->result_array (); |
|
1867 | - if (! empty ( $invoiceconf )) { |
|
1865 | + )); |
|
1866 | + $invoiceconf = $invoiceconf->result_array(); |
|
1867 | + if ( ! empty ($invoiceconf)) { |
|
1868 | 1868 | $data ['invoiceconf'] = $invoiceconf [0]; |
1869 | 1869 | } else { |
1870 | - $invoiceconf = $this->db_model->getSelect ( "*", "invoice_conf", array ( |
|
1870 | + $invoiceconf = $this->db_model->getSelect("*", "invoice_conf", array( |
|
1871 | 1871 | "accountid" => "1" |
1872 | - ) ); |
|
1873 | - $invoiceconf = $invoiceconf->result_array (); |
|
1872 | + )); |
|
1873 | + $invoiceconf = $invoiceconf->result_array(); |
|
1874 | 1874 | $data ['invoiceconf'] = $invoiceconf [0]; |
1875 | 1875 | } |
1876 | 1876 | |
@@ -1881,39 +1881,39 @@ discard block |
||
1881 | 1881 | $INVOICE_CHARGE = ''; |
1882 | 1882 | $total_sum = 0; |
1883 | 1883 | $total_vat = 0; |
1884 | - $fromdate = strtotime ( $invoicedata ['from_date'] ); |
|
1885 | - $from_date = date ( "Y-m-d", $fromdate ); |
|
1886 | - $duedate = strtotime ( $invoicedata ['due_date'] ); |
|
1887 | - $due_date = date ( "Y-m-d", $duedate ); |
|
1884 | + $fromdate = strtotime($invoicedata ['from_date']); |
|
1885 | + $from_date = date("Y-m-d", $fromdate); |
|
1886 | + $duedate = strtotime($invoicedata ['due_date']); |
|
1887 | + $due_date = date("Y-m-d", $duedate); |
|
1888 | 1888 | /** |
1889 | 1889 | * ****************************Invoivce number************************************************************* |
1890 | 1890 | */ |
1891 | - $INVOICE_NUM = '<td style="font-size: 10px;color:#000;font-family:arial; line-height: 22px;letter-spacing:02;float:right;"><b><h2>Receipt: ' . $invoicedata ["invoice_prefix"] . $data ['id'] . '</h2></b></td>'; |
|
1891 | + $INVOICE_NUM = '<td style="font-size: 10px;color:#000;font-family:arial; line-height: 22px;letter-spacing:02;float:right;"><b><h2>Receipt: '.$invoicedata ["invoice_prefix"].$data ['id'].'</h2></b></td>'; |
|
1892 | 1892 | /** |
1893 | 1893 | * ************************* Company Address Code START ************************************************** |
1894 | 1894 | */ |
1895 | 1895 | |
1896 | - $ACCOUNTADD .= '<tr><td style="width:100%;font-size: 12px;color:#000;font-family:arial; line-height: 22px;">' . $data ['invoiceconf'] ['company_name'] . '</td>'; |
|
1896 | + $ACCOUNTADD .= '<tr><td style="width:100%;font-size: 12px;color:#000;font-family:arial; line-height: 22px;">'.$data ['invoiceconf'] ['company_name'].'</td>'; |
|
1897 | 1897 | $ACCOUNTADD .= '</tr>'; |
1898 | 1898 | if ($data ['invoiceconf'] != "") { |
1899 | 1899 | |
1900 | - $ACCOUNTADD .= '<tr><td style="width:100%;font-size: 12px;color:#000;font-family:arial; line-height: 22px;">' . $data ['invoiceconf'] ['address'] . '</td></tr>'; |
|
1900 | + $ACCOUNTADD .= '<tr><td style="width:100%;font-size: 12px;color:#000;font-family:arial; line-height: 22px;">'.$data ['invoiceconf'] ['address'].'</td></tr>'; |
|
1901 | 1901 | } |
1902 | 1902 | if ($data ['invoiceconf'] ['city'] != "") { |
1903 | 1903 | |
1904 | - $ACCOUNTADD .= '<tr><td style="width:100%;font-size: 12px;color:#000;font-family:arial; line-height: 22px;">' . $data ['invoiceconf'] ['city'] . '</td></tr>'; |
|
1904 | + $ACCOUNTADD .= '<tr><td style="width:100%;font-size: 12px;color:#000;font-family:arial; line-height: 22px;">'.$data ['invoiceconf'] ['city'].'</td></tr>'; |
|
1905 | 1905 | } |
1906 | 1906 | if ($data ['invoiceconf'] ['province'] != "") { |
1907 | 1907 | |
1908 | - $ACCOUNTADD .= '<tr><td style="width:100%;font-size: 12px;color:#000;font-family:arial; line-height: 22px;">' . $data ['invoiceconf'] ['province'] . '</td></tr>'; |
|
1908 | + $ACCOUNTADD .= '<tr><td style="width:100%;font-size: 12px;color:#000;font-family:arial; line-height: 22px;">'.$data ['invoiceconf'] ['province'].'</td></tr>'; |
|
1909 | 1909 | } |
1910 | 1910 | if ($data ['invoiceconf'] ['country'] != "") { |
1911 | 1911 | |
1912 | - $ACCOUNTADD .= '<tr><td style="width:100%;font-size: 12px;color:#000;font-family:arial; line-height: 22px;">' . $data ['invoiceconf'] ['country'] . '</td></tr>'; |
|
1912 | + $ACCOUNTADD .= '<tr><td style="width:100%;font-size: 12px;color:#000;font-family:arial; line-height: 22px;">'.$data ['invoiceconf'] ['country'].'</td></tr>'; |
|
1913 | 1913 | } |
1914 | 1914 | if ($data ['invoiceconf'] ['zipcode'] != "") { |
1915 | 1915 | |
1916 | - $ACCOUNTADD .= '<tr><td style="width:100%;font-size: 12px;color:#000;font-family:arial; line-height: 22px;">' . $data ['invoiceconf'] ['zipcode'] . '</td></tr>'; |
|
1916 | + $ACCOUNTADD .= '<tr><td style="width:100%;font-size: 12px;color:#000;font-family:arial; line-height: 22px;">'.$data ['invoiceconf'] ['zipcode'].'</td></tr>'; |
|
1917 | 1917 | } |
1918 | 1918 | /** |
1919 | 1919 | * ************************* Company Address Code END ************************************************** |
@@ -1924,27 +1924,27 @@ discard block |
||
1924 | 1924 | */ |
1925 | 1925 | $ACCOUNTADD_CUSTOMER .= '<table align=right>'; |
1926 | 1926 | $ACCOUNTADD_CUSTOMER .= '<tr>'; |
1927 | - $ACCOUNTADD_CUSTOMER .= '<td align="right" style="width:100%;font-size: 12px;color:#000;font-family:arial; line-height: 22px;">' . $accountdata ['company_name'] . '</td></tr>'; |
|
1927 | + $ACCOUNTADD_CUSTOMER .= '<td align="right" style="width:100%;font-size: 12px;color:#000;font-family:arial; line-height: 22px;">'.$accountdata ['company_name'].'</td></tr>'; |
|
1928 | 1928 | |
1929 | 1929 | if ($accountdata ['address_1'] != "") { |
1930 | 1930 | |
1931 | - $ACCOUNTADD_CUSTOMER .= '<tr><td align="right" style="width:100%;font-size: 12px;color:#000;font-family:arial; line-height: 22px;">' . $accountdata ['address_1'] . '</td></tr>'; |
|
1931 | + $ACCOUNTADD_CUSTOMER .= '<tr><td align="right" style="width:100%;font-size: 12px;color:#000;font-family:arial; line-height: 22px;">'.$accountdata ['address_1'].'</td></tr>'; |
|
1932 | 1932 | } |
1933 | 1933 | if ($accountdata ['city'] != "") { |
1934 | 1934 | |
1935 | - $ACCOUNTADD_CUSTOMER .= '<tr><td align="right" style="width:100%;font-size: 12px;color:#000;font-family:arial; line-height: 22px;">' . $accountdata ['city'] . '</td></tr>'; |
|
1935 | + $ACCOUNTADD_CUSTOMER .= '<tr><td align="right" style="width:100%;font-size: 12px;color:#000;font-family:arial; line-height: 22px;">'.$accountdata ['city'].'</td></tr>'; |
|
1936 | 1936 | } |
1937 | 1937 | if ($accountdata ['province'] != "") { |
1938 | 1938 | |
1939 | - $ACCOUNTADD_CUSTOMER .= '<tr><td align="right" style="width:100%;font-size: 12px;color:#000;font-family:arial; line-height: 22px;">' . $accountdata ['province'] . '</td></tr>'; |
|
1939 | + $ACCOUNTADD_CUSTOMER .= '<tr><td align="right" style="width:100%;font-size: 12px;color:#000;font-family:arial; line-height: 22px;">'.$accountdata ['province'].'</td></tr>'; |
|
1940 | 1940 | } |
1941 | 1941 | if ($accountdata ['country'] != "") { |
1942 | 1942 | |
1943 | - $ACCOUNTADD_CUSTOMER .= '<tr><td align="right" style="width:100%;font-size: 12px;color:#000;font-family:arial; line-height: 22px;">' . $accountdata ['country'] . '</td></tr>'; |
|
1943 | + $ACCOUNTADD_CUSTOMER .= '<tr><td align="right" style="width:100%;font-size: 12px;color:#000;font-family:arial; line-height: 22px;">'.$accountdata ['country'].'</td></tr>'; |
|
1944 | 1944 | } |
1945 | 1945 | if ($accountdata ['postal_code'] != "") { |
1946 | 1946 | |
1947 | - $ACCOUNTADD_CUSTOMER .= '<tr><td align="right" style="width:100%;font-size: 12px;color:#000;font-family:arial; line-height: 22px;">' . $accountdata ['postal_code'] . '</td></tr>'; |
|
1947 | + $ACCOUNTADD_CUSTOMER .= '<tr><td align="right" style="width:100%;font-size: 12px;color:#000;font-family:arial; line-height: 22px;">'.$accountdata ['postal_code'].'</td></tr>'; |
|
1948 | 1948 | } |
1949 | 1949 | $ACCOUNTADD_CUSTOMER .= "</table>"; |
1950 | 1950 | /** |
@@ -1960,9 +1960,9 @@ discard block |
||
1960 | 1960 | <tbody><tr> |
1961 | 1961 | |
1962 | 1962 | <td style="width:25%;"><b>Receipt Date :</b></td> |
1963 | - <td style="width:25%;text-align:right;border-right:1px solid #000; padding-right: 3px;">' . date ( "Y-m-d", strtotime ( $invoicedata ['from_date'] ) ) . '</td> |
|
1963 | + <td style="width:25%;text-align:right;border-right:1px solid #000; padding-right: 3px;">' . date("Y-m-d", strtotime($invoicedata ['from_date'])).'</td> |
|
1964 | 1964 | <td style="width:25%;"><b>This Receipt Amount :</b> </td> |
1965 | - <td style="width:25%;text-align:right;">' . $this->currency_decimal ( $this->common_model->calculate_currency ( $invoicedata ['amount'] ) ) . '</td> |
|
1965 | + <td style="width:25%;text-align:right;">' . $this->currency_decimal($this->common_model->calculate_currency($invoicedata ['amount'])).'</td> |
|
1966 | 1966 | </tr> |
1967 | 1967 | <tr> |
1968 | 1968 | |
@@ -1974,12 +1974,12 @@ discard block |
||
1974 | 1974 | |
1975 | 1975 | <tr> |
1976 | 1976 | <td style="width:25%;border-bottom:1px solid #000;"><b>Account Number :</b></td> |
1977 | - <td style="width:25%;border-bottom:1px solid #000;text-align:right;border-right:1px solid #000;padding-right: 3px;">' . $accountdata ['number'] . '</td> |
|
1977 | + <td style="width:25%;border-bottom:1px solid #000;text-align:right;border-right:1px solid #000;padding-right: 3px;">' . $accountdata ['number'].'</td> |
|
1978 | 1978 | <td colspan="2" style="width:50%;padding-left: 3px;"> |
1979 | 1979 | <table style="border:1px solid #000;width:100%;"> |
1980 | 1980 | <tbody><tr> |
1981 | 1981 | <td style="width:50%;font-weight:bold;font-style:italic;">Total Amount :</td> |
1982 | - <td style="width:50%;text-align:right;font-style:italic;">' . $this->currency_decimal ( $this->common_model->calculate_currency ( $invoicedata ['amount'] ) ) . '</td> |
|
1982 | + <td style="width:50%;text-align:right;font-style:italic;">' . $this->currency_decimal($this->common_model->calculate_currency($invoicedata ['amount'])).'</td> |
|
1983 | 1983 | </tr> |
1984 | 1984 | </tbody></table> |
1985 | 1985 | </td> |
@@ -2001,23 +2001,23 @@ discard block |
||
2001 | 2001 | <tr><th style="width:20%;border-left:1px solid #000;border-top:1px solid #000;border-bottom:1px solid #000;background-color:#EBEEF2;padding:5px;">Date </th> |
2002 | 2002 | <th style="width:40%;border-left:1px solid #000;border-top:1px solid #000;border-bottom:1px solid #000;background-color:#EBEEF2;padding:5px;">Description</th> |
2003 | 2003 | |
2004 | - <th style="width:20%;border-left:1px solid #000;border-top:1px solid #000;border-bottom:1px solid #000;background-color:#EBEEF2;padding:5px;" align="right">Unit Price (' . $currency . ')</th> |
|
2005 | - <th style="width:20%;border-left:1px solid #000;border-right:1px solid #000;border-top:1px solid #000;border-bottom:1px solid #000;background-color:#EBEEF2;padding:5px;" align="right">Cost (' . $currency . ')</th> |
|
2004 | + <th style="width:20%;border-left:1px solid #000;border-top:1px solid #000;border-bottom:1px solid #000;background-color:#EBEEF2;padding:5px;" align="right">Unit Price (' . $currency.')</th> |
|
2005 | + <th style="width:20%;border-left:1px solid #000;border-right:1px solid #000;border-top:1px solid #000;border-bottom:1px solid #000;background-color:#EBEEF2;padding:5px;" align="right">Cost (' . $currency.')</th> |
|
2006 | 2006 | </tr> |
2007 | 2007 | '; |
2008 | 2008 | |
2009 | 2009 | // echo "<pre>";print_r($charge_res['description']);exit; |
2010 | 2010 | $INVOICE_CHARGE .= '<tr > |
2011 | - <td style="width:20%;line-height:15px;border-left:1px solid #000;border-bottom:1px solid #000;padding:5px;">' . date ( 'Y-m-d', strtotime ( $invoicedata ['invoice_date'] ) ) . '</td> |
|
2012 | - <td style="width:40%;line-height:15px;border-left:1px solid #000;border-bottom:1px solid #000;padding:5px;">' . $data ['description'] . '</td> |
|
2013 | - <td style="width:20%;line-height:15px;border-left:1px solid #000;border-bottom:1px solid #000;text-align:right;padding:5px;">' . $this->currency_decimal ( $this->common_model->calculate_currency ( $invoicedata ['amount'] ) ) . '</td> |
|
2014 | - <td style="width:20%;line-height:15px;border-right:1px solid #000;border-left:1px solid #000;border-bottom:1px solid #000;text-align:right;padding:5px;">' . $this->currency_decimal ( $this->common_model->calculate_currency ( $invoicedata ['amount'] ) ) . '</td> |
|
2011 | + <td style="width:20%;line-height:15px;border-left:1px solid #000;border-bottom:1px solid #000;padding:5px;">' . date('Y-m-d', strtotime($invoicedata ['invoice_date'])).'</td> |
|
2012 | + <td style="width:40%;line-height:15px;border-left:1px solid #000;border-bottom:1px solid #000;padding:5px;">' . $data ['description'].'</td> |
|
2013 | + <td style="width:20%;line-height:15px;border-left:1px solid #000;border-bottom:1px solid #000;text-align:right;padding:5px;">' . $this->currency_decimal($this->common_model->calculate_currency($invoicedata ['amount'])).'</td> |
|
2014 | + <td style="width:20%;line-height:15px;border-right:1px solid #000;border-left:1px solid #000;border-bottom:1px solid #000;text-align:right;padding:5px;">' . $this->currency_decimal($this->common_model->calculate_currency($invoicedata ['amount'])).'</td> |
|
2015 | 2015 | </tr>'; |
2016 | 2016 | |
2017 | 2017 | $INVOICE_CHARGE .= '<tr> |
2018 | 2018 | <td></td><td></td> |
2019 | 2019 | <td style="border-left:1px solid #000;border-bottom:1px solid #000;width:20%;padding:5px;text-align:left;" align="right">Sub Total</td> |
2020 | - <td style="border-left:1px solid #000;border-bottom:1px solid #000;border-right:1px solid #000;width:10%;text-align:right;padding-top:5px;padding-right:5px;">' . $this->currency_decimal ( $this->common_model->calculate_currency ( $invoicedata ['amount'] ) ) . '</td> |
|
2020 | + <td style="border-left:1px solid #000;border-bottom:1px solid #000;border-right:1px solid #000;width:10%;text-align:right;padding-top:5px;padding-right:5px;">' . $this->currency_decimal($this->common_model->calculate_currency($invoicedata ['amount'])).'</td> |
|
2021 | 2021 | </tr>'; |
2022 | 2022 | |
2023 | 2023 | /* |
@@ -2038,7 +2038,7 @@ discard block |
||
2038 | 2038 | $INVOICE_CHARGE .= '<tr> |
2039 | 2039 | <td></td><td></td> |
2040 | 2040 | <td style="border-left:1px solid #000;border-bottom:1px solid #000;width:20%;padding:5px;text-align:left;" align="right"><b>Total</b></td> |
2041 | - <td style="border-left:1px solid #000;border-bottom:1px solid #000;border-right:1px solid #000;width:10%;text-align:right;padding-top:5px;padding-right:5px;">' . $this->currency_decimal ( $this->common_model->calculate_currency ( $invoicedata ['amount'] ) ) . '</td> |
|
2041 | + <td style="border-left:1px solid #000;border-bottom:1px solid #000;border-right:1px solid #000;width:10%;text-align:right;padding-top:5px;padding-right:5px;">' . $this->currency_decimal($this->common_model->calculate_currency($invoicedata ['amount'])).'</td> |
|
2042 | 2042 | </tr> |
2043 | 2043 | |
2044 | 2044 | '; |
@@ -2051,12 +2051,12 @@ discard block |
||
2051 | 2051 | * ************************* Invoice Note Code END ************************************************** |
2052 | 2052 | */ |
2053 | 2053 | |
2054 | - $invoice_notes = $this->db_model->getSelect ( '*', 'invoices', array ( |
|
2054 | + $invoice_notes = $this->db_model->getSelect('*', 'invoices', array( |
|
2055 | 2055 | 'id' => $invoicedata ['id'] |
2056 | - ) ); |
|
2057 | - $invoice_notes = $invoice_notes->result_array (); |
|
2056 | + )); |
|
2057 | + $invoice_notes = $invoice_notes->result_array(); |
|
2058 | 2058 | |
2059 | - if (isset ( $invoice_notes [0] ['notes'] )) { |
|
2059 | + if (isset ($invoice_notes [0] ['notes'])) { |
|
2060 | 2060 | $invoice_notes = $invoice_notes [0] ['notes']; |
2061 | 2061 | } else { |
2062 | 2062 | if ($invoice_notes [0] ['invoice_note'] == '0') { |
@@ -2069,51 +2069,51 @@ discard block |
||
2069 | 2069 | * ************************* Invoice Note Code END ************************************************** |
2070 | 2070 | */ |
2071 | 2071 | //ASTPP_invoice_download_issue |
2072 | - if (! empty ( $data ['invoiceconf'] ) && $data ['invoiceconf'] != '') { |
|
2072 | + if ( ! empty ($data ['invoiceconf']) && $data ['invoiceconf'] != '') { |
|
2073 | 2073 | $logo = $data ['invoiceconf'] ['logo']; |
2074 | - $dir_path = getcwd () . "/upload/"; |
|
2075 | - $path = $dir_path . $data ['invoiceconf'] ['accountid'] . "_" . $data ['invoiceconf'] ['logo']; |
|
2074 | + $dir_path = getcwd()."/upload/"; |
|
2075 | + $path = $dir_path.$data ['invoiceconf'] ['accountid']."_".$data ['invoiceconf'] ['logo']; |
|
2076 | 2076 | |
2077 | - if (file_exists ( $path )) { |
|
2077 | + if (file_exists($path)) { |
|
2078 | 2078 | if ($logo != '') { |
2079 | 2079 | $src = $path; |
2080 | - $logo = "<img style='height:50px; width:180px; margin-left:70px;' alt='logo' src='" . $src . "'>"; |
|
2080 | + $logo = "<img style='height:50px; width:180px; margin-left:70px;' alt='logo' src='".$src."'>"; |
|
2081 | 2081 | } else { |
2082 | - $path = FCPATH . "/assets/images/logo.png"; |
|
2082 | + $path = FCPATH."/assets/images/logo.png"; |
|
2083 | 2083 | $src = $path; |
2084 | - $logo = "<img style='height:50px; width:180px; margin-left:70px;' alt='logo' src='" . $src . "'>"; |
|
2084 | + $logo = "<img style='height:50px; width:180px; margin-left:70px;' alt='logo' src='".$src."'>"; |
|
2085 | 2085 | } |
2086 | 2086 | } else { |
2087 | - $dir_path = FCPATH . "/upload/logo.png"; |
|
2087 | + $dir_path = FCPATH."/upload/logo.png"; |
|
2088 | 2088 | $src = $dir_path; |
2089 | - $logo = "<img style='height:50px; width:180px; margin-left:70px;' alt='logo' src='" . $src . "'>"; |
|
2089 | + $logo = "<img style='height:50px; width:180px; margin-left:70px;' alt='logo' src='".$src."'>"; |
|
2090 | 2090 | } |
2091 | 2091 | } |
2092 | 2092 | //END |
2093 | - $content = str_replace ( "<INVOICE_NUM>", $INVOICE_NUM, $content ); |
|
2094 | - $content = str_replace ( "<ACCOUNTADD>", $ACCOUNTADD, $content ); |
|
2095 | - $content = str_replace ( "<ACCOUNTADD_CUSTOMER>", $ACCOUNTADD_CUSTOMER, $content ); |
|
2096 | - $content = str_replace ( "<INVOICE_DETAIL>", $INVOICE_DETAIL, $content ); |
|
2097 | - $content = str_replace ( "<INVOICE_CHARGE>", $INVOICE_CHARGE, $content ); |
|
2098 | - $content = str_replace ( "<NOTES>", $invoice_notes, $content ); |
|
2099 | - $content = str_replace ( "<LOGO>", $src, $content ); |
|
2093 | + $content = str_replace("<INVOICE_NUM>", $INVOICE_NUM, $content); |
|
2094 | + $content = str_replace("<ACCOUNTADD>", $ACCOUNTADD, $content); |
|
2095 | + $content = str_replace("<ACCOUNTADD_CUSTOMER>", $ACCOUNTADD_CUSTOMER, $content); |
|
2096 | + $content = str_replace("<INVOICE_DETAIL>", $INVOICE_DETAIL, $content); |
|
2097 | + $content = str_replace("<INVOICE_CHARGE>", $INVOICE_CHARGE, $content); |
|
2098 | + $content = str_replace("<NOTES>", $invoice_notes, $content); |
|
2099 | + $content = str_replace("<LOGO>", $src, $content); |
|
2100 | 2100 | // echo $content ; exit; |
2101 | 2101 | |
2102 | - $invoice_path = $this->config->item ( 'invoices_path' ); |
|
2103 | - $download_path = $invoicedata ['invoice_prefix'] . $data ['id'] . ".pdf"; |
|
2104 | - $this->html2pdf->pdf->SetDisplayMode ( 'fullpage' ); |
|
2105 | - $this->html2pdf->writeHTML ( $content ); |
|
2102 | + $invoice_path = $this->config->item('invoices_path'); |
|
2103 | + $download_path = $invoicedata ['invoice_prefix'].$data ['id'].".pdf"; |
|
2104 | + $this->html2pdf->pdf->SetDisplayMode('fullpage'); |
|
2105 | + $this->html2pdf->writeHTML($content); |
|
2106 | 2106 | |
2107 | - $this->html2pdf->Output ( $download_path, "D" ); |
|
2107 | + $this->html2pdf->Output($download_path, "D"); |
|
2108 | 2108 | } |
2109 | 2109 | function calculate_currency($amount, $accountdata) { |
2110 | 2110 | $base_currency = Common_model::$global_config ['system_config'] ['base_currency']; |
2111 | 2111 | $from_currency = Common_model::$global_config ['currency_list'] [$base_currency]; |
2112 | - $to_currency = $this->db_model->getSelect ( "currencyrate", "currency", array ( |
|
2112 | + $to_currency = $this->db_model->getSelect("currencyrate", "currency", array( |
|
2113 | 2113 | "currency" => $accountdata ["currency_id"] |
2114 | - ) ); |
|
2115 | - if ($to_currency->num_rows () > 0) { |
|
2116 | - $to_currency_arr = $to_currency->result_array (); |
|
2114 | + )); |
|
2115 | + if ($to_currency->num_rows() > 0) { |
|
2116 | + $to_currency_arr = $to_currency->result_array(); |
|
2117 | 2117 | $to_currency = $to_currency_arr [0] ["currencyrate"]; |
2118 | 2118 | } else { |
2119 | 2119 | $to_currency = $from_currency; |
@@ -2123,61 +2123,61 @@ discard block |
||
2123 | 2123 | return $cal_amount; |
2124 | 2124 | } |
2125 | 2125 | function format_currency($amount) { |
2126 | - $dp = $this->db_model->getSelect ( "value", "system", array ( |
|
2126 | + $dp = $this->db_model->getSelect("value", "system", array( |
|
2127 | 2127 | "name" => "decimalpoints" |
2128 | - ) ); |
|
2129 | - $dp = $dp->result_array (); |
|
2128 | + )); |
|
2129 | + $dp = $dp->result_array(); |
|
2130 | 2130 | $dp = $dp [0] ["value"]; |
2131 | 2131 | |
2132 | - return money_format ( '%.' . $dp . 'n', $amount ); |
|
2132 | + return money_format('%.'.$dp.'n', $amount); |
|
2133 | 2133 | } |
2134 | 2134 | function date_diff_custom($end = '2020-06-09 10:30:00', $out_in_array = false) { |
2135 | - $intervalo = date_diff ( date_create (), date_create ( $end ) ); |
|
2136 | - $out = $intervalo->format ( "Years:%Y,Months:%M,Days:%d,Hours:%H,Minutes:%i,Seconds:%s" ); |
|
2137 | - if (! $out_in_array) |
|
2135 | + $intervalo = date_diff(date_create(), date_create($end)); |
|
2136 | + $out = $intervalo->format("Years:%Y,Months:%M,Days:%d,Hours:%H,Minutes:%i,Seconds:%s"); |
|
2137 | + if ( ! $out_in_array) |
|
2138 | 2138 | return $out; |
2139 | - $a_out = array (); |
|
2140 | - array_walk ( explode ( ',', $out ), function ($val, $key) use (&$a_out) { |
|
2141 | - $v = explode ( ':', $val ); |
|
2139 | + $a_out = array(); |
|
2140 | + array_walk(explode(',', $out), function($val, $key) use (&$a_out) { |
|
2141 | + $v = explode(':', $val); |
|
2142 | 2142 | $a_out [$v [0]] = $v [1]; |
2143 | 2143 | } ); |
2144 | 2144 | return $a_out; |
2145 | 2145 | } |
2146 | 2146 | function invoice_list_search() { |
2147 | - $ajax_search = $this->input->post ( 'ajax_search', 0 ); |
|
2147 | + $ajax_search = $this->input->post('ajax_search', 0); |
|
2148 | 2148 | |
2149 | - if ($this->input->post ( 'advance_search', TRUE ) == 1) { |
|
2150 | - $this->session->set_userdata ( 'advance_search', $this->input->post ( 'advance_search' ) ); |
|
2151 | - $action = $this->input->post (); |
|
2149 | + if ($this->input->post('advance_search', TRUE) == 1) { |
|
2150 | + $this->session->set_userdata('advance_search', $this->input->post('advance_search')); |
|
2151 | + $action = $this->input->post(); |
|
2152 | 2152 | |
2153 | 2153 | echo '<pre>'; |
2154 | - print_r ( $action ); |
|
2155 | - unset ( $action ['action'] ); |
|
2156 | - unset ( $action ['advance_search'] ); |
|
2157 | - $action ['from_date'] [0] = $action ['from_date'] [0] ? $action ['from_date'] [0] . " 00:00:00" : ''; |
|
2158 | - $action ['invoice_date'] [0] = $action ['invoice_date'] [0] ? $action ['invoice_date'] [0] . " 00:00:00" : ''; |
|
2159 | - $this->session->set_userdata ( 'invoice_list_search', $action ); |
|
2154 | + print_r($action); |
|
2155 | + unset ($action ['action']); |
|
2156 | + unset ($action ['advance_search']); |
|
2157 | + $action ['from_date'] [0] = $action ['from_date'] [0] ? $action ['from_date'] [0]." 00:00:00" : ''; |
|
2158 | + $action ['invoice_date'] [0] = $action ['invoice_date'] [0] ? $action ['invoice_date'] [0]." 00:00:00" : ''; |
|
2159 | + $this->session->set_userdata('invoice_list_search', $action); |
|
2160 | 2160 | } |
2161 | 2161 | if (@$ajax_search != 1) { |
2162 | - redirect ( base_url () . 'invoices/invoice_list/' ); |
|
2162 | + redirect(base_url().'invoices/invoice_list/'); |
|
2163 | 2163 | } |
2164 | 2164 | } |
2165 | 2165 | function invoice_list_clearsearchfilter() { |
2166 | - $this->session->set_userdata ( 'advance_search', 0 ); |
|
2167 | - $this->session->set_userdata ( 'invoice_list_search', "" ); |
|
2166 | + $this->session->set_userdata('advance_search', 0); |
|
2167 | + $this->session->set_userdata('invoice_list_search', ""); |
|
2168 | 2168 | } |
2169 | 2169 | /** |
2170 | 2170 | * ============ From below code developed for ASTPP version 2.0 ======================================* |
2171 | 2171 | */ |
2172 | 2172 | function generate_receipt($accountid, $amount, $accountinfo, $last_invoice_ID, $invoice_prefix, $due_date) { |
2173 | - $invoice_data = array ( |
|
2173 | + $invoice_data = array( |
|
2174 | 2174 | "accountid" => $accountid, |
2175 | 2175 | "invoice_prefix" => $invoice_prefix, |
2176 | - "invoiceid" => '0000' . $last_invoice_ID, |
|
2176 | + "invoiceid" => '0000'.$last_invoice_ID, |
|
2177 | 2177 | "reseller_id" => $accountinfo ['reseller_id'], |
2178 | - "invoice_date" => gmdate ( "Y-m-d H:i:s" ), |
|
2179 | - "from_date" => gmdate ( "Y-m-d H:i:s" ), |
|
2180 | - "to_date" => gmdate ( "Y-m-d H:i:s" ), |
|
2178 | + "invoice_date" => gmdate("Y-m-d H:i:s"), |
|
2179 | + "from_date" => gmdate("Y-m-d H:i:s"), |
|
2180 | + "to_date" => gmdate("Y-m-d H:i:s"), |
|
2181 | 2181 | "due_date" => $due_date, |
2182 | 2182 | "status" => 1, |
2183 | 2183 | "balance" => $accountinfo ['balance'], |
@@ -2185,12 +2185,12 @@ discard block |
||
2185 | 2185 | "type" => 'R', |
2186 | 2186 | "confirm" => '1' |
2187 | 2187 | ); |
2188 | - $this->db->insert ( "invoices", $invoice_data ); |
|
2189 | - $invoiceid = $this->db->insert_id (); |
|
2188 | + $this->db->insert("invoices", $invoice_data); |
|
2189 | + $invoiceid = $this->db->insert_id(); |
|
2190 | 2190 | return $invoiceid; |
2191 | 2191 | } |
2192 | 2192 | function insert_invoice_total_data($invoiceid, $sub_total, $sort_order) { |
2193 | - $invoice_total_arr = array ( |
|
2193 | + $invoice_total_arr = array( |
|
2194 | 2194 | "invoiceid" => $invoiceid, |
2195 | 2195 | "sort_order" => $sort_order, |
2196 | 2196 | "value" => $sub_total, |
@@ -2198,35 +2198,35 @@ discard block |
||
2198 | 2198 | "text" => "Sub Total", |
2199 | 2199 | "class" => "1" |
2200 | 2200 | ); |
2201 | - $this->db->insert ( "invoices_total", $invoice_total_arr ); |
|
2202 | - return $sort_order ++; |
|
2201 | + $this->db->insert("invoices_total", $invoice_total_arr); |
|
2202 | + return $sort_order++; |
|
2203 | 2203 | } |
2204 | 2204 | function apply_invoice_taxes($invoiceid, $accountid, $sort_order) { |
2205 | 2205 | $tax_priority = ""; |
2206 | - $where = array ( |
|
2206 | + $where = array( |
|
2207 | 2207 | "accountid" => $accountid |
2208 | 2208 | ); |
2209 | - $accounttax_query = $this->db_model->getSelectWithOrder ( "*", "taxes_to_accounts", $where, "ASC", "taxes_priority" ); |
|
2209 | + $accounttax_query = $this->db_model->getSelectWithOrder("*", "taxes_to_accounts", $where, "ASC", "taxes_priority"); |
|
2210 | 2210 | if ($accounttax_query->num_rows > 0) { |
2211 | - $accounttax_query = $accounttax_query->result_array (); |
|
2212 | - foreach ( $accounttax_query as $tax_key => $tax_value ) { |
|
2213 | - $taxes_info = $this->db->get_where ( 'taxes', array ( |
|
2211 | + $accounttax_query = $accounttax_query->result_array(); |
|
2212 | + foreach ($accounttax_query as $tax_key => $tax_value) { |
|
2213 | + $taxes_info = $this->db->get_where('taxes', array( |
|
2214 | 2214 | 'id' => $tax_value ['taxes_id'] |
2215 | - ) ); |
|
2216 | - if ($taxes_info->num_rows () > 0) { |
|
2217 | - $tax_value = $taxes_info->result_array (); |
|
2215 | + )); |
|
2216 | + if ($taxes_info->num_rows() > 0) { |
|
2217 | + $tax_value = $taxes_info->result_array(); |
|
2218 | 2218 | $tax_value = $tax_value [0]; |
2219 | 2219 | if ($tax_value ["taxes_priority"] == "") { |
2220 | 2220 | $tax_priority = $tax_value ["taxes_priority"]; |
2221 | 2221 | } else if ($tax_value ["taxes_priority"] > $tax_priority) { |
2222 | - $query = $this->db_model->getSelect ( "SUM(value) as total", "invoices_total", array ( |
|
2222 | + $query = $this->db_model->getSelect("SUM(value) as total", "invoices_total", array( |
|
2223 | 2223 | "invoiceid" => $invoiceid |
2224 | - ) ); |
|
2225 | - $query = $query->result_array (); |
|
2224 | + )); |
|
2225 | + $query = $query->result_array(); |
|
2226 | 2226 | $sub_total = $query ["0"] ["total"]; |
2227 | 2227 | } |
2228 | 2228 | $tax_total = (($sub_total * ($tax_value ['taxes_rate'] / 100)) + $tax_value ['taxes_amount']); |
2229 | - $tax_array = array ( |
|
2229 | + $tax_array = array( |
|
2230 | 2230 | "invoiceid" => $invoiceid, |
2231 | 2231 | "title" => "TAX", |
2232 | 2232 | "text" => $tax_value ['taxes_description'], |
@@ -2234,21 +2234,21 @@ discard block |
||
2234 | 2234 | "class" => "2", |
2235 | 2235 | "sort_order" => $sort_order |
2236 | 2236 | ); |
2237 | - $this->db->insert ( "invoices_total", $tax_array ); |
|
2238 | - $sort_order ++; |
|
2237 | + $this->db->insert("invoices_total", $tax_array); |
|
2238 | + $sort_order++; |
|
2239 | 2239 | } |
2240 | 2240 | } |
2241 | 2241 | } |
2242 | 2242 | return $sort_order; |
2243 | 2243 | } |
2244 | 2244 | function set_invoice_total($invoiceid, $sort_order) { |
2245 | - $query = $this->db_model->getSelect ( "SUM(value) as total", "invoices_total", array ( |
|
2245 | + $query = $this->db_model->getSelect("SUM(value) as total", "invoices_total", array( |
|
2246 | 2246 | "invoiceid" => $invoiceid |
2247 | - ) ); |
|
2248 | - $query = $query->result_array (); |
|
2247 | + )); |
|
2248 | + $query = $query->result_array(); |
|
2249 | 2249 | $sub_total = $query ["0"] ["total"]; |
2250 | 2250 | |
2251 | - $invoice_total_arr = array ( |
|
2251 | + $invoice_total_arr = array( |
|
2252 | 2252 | "invoiceid" => $invoiceid, |
2253 | 2253 | "sort_order" => $sort_order, |
2254 | 2254 | "value" => $sub_total, |
@@ -2256,21 +2256,21 @@ discard block |
||
2256 | 2256 | "text" => "Total", |
2257 | 2257 | "class" => "9" |
2258 | 2258 | ); |
2259 | - $this->db->insert ( "invoices_total", $invoice_total_arr ); |
|
2259 | + $this->db->insert("invoices_total", $invoice_total_arr); |
|
2260 | 2260 | return true; |
2261 | 2261 | } |
2262 | 2262 | function invoice_delete_statically($inv_id) { |
2263 | - $data = array ( |
|
2263 | + $data = array( |
|
2264 | 2264 | 'deleted' => 1 |
2265 | 2265 | ); |
2266 | - $this->db->where ( 'id', $inv_id ); |
|
2267 | - $this->db->update ( "invoices", $data ); |
|
2268 | - $this->session->set_flashdata ( 'astpp_notification', 'Invoices removed successfully' ); |
|
2269 | - redirect ( base_url () . 'invoices/invoice_list/' ); |
|
2266 | + $this->db->where('id', $inv_id); |
|
2267 | + $this->db->update("invoices", $data); |
|
2268 | + $this->session->set_flashdata('astpp_notification', 'Invoices removed successfully'); |
|
2269 | + redirect(base_url().'invoices/invoice_list/'); |
|
2270 | 2270 | } |
2271 | 2271 | function invoice_delete_massege() { |
2272 | - $this->session->set_flashdata ( 'astpp_notification', 'Invoices removed successfully' ); |
|
2273 | - redirect ( base_url () . 'invoices/invoice_list/' ); |
|
2272 | + $this->session->set_flashdata('astpp_notification', 'Invoices removed successfully'); |
|
2273 | + redirect(base_url().'invoices/invoice_list/'); |
|
2274 | 2274 | } |
2275 | 2275 | } |
2276 | 2276 |
@@ -36,8 +36,9 @@ discard block |
||
36 | 36 | $this->load->library ( 'fpdf' ); |
37 | 37 | $this->load->library ( 'pdf' ); |
38 | 38 | |
39 | - if ($this->session->userdata ( 'user_login' ) == FALSE) |
|
40 | - redirect ( base_url () . '/astpp/login' ); |
|
39 | + if ($this->session->userdata ( 'user_login' ) == FALSE) { |
|
40 | + redirect ( base_url () . '/astpp/login' ); |
|
41 | + } |
|
41 | 42 | } |
42 | 43 | function invoice_list() { |
43 | 44 | $data ['username'] = $this->session->userdata ( 'user_name' ); |
@@ -1856,10 +1857,11 @@ discard block |
||
1856 | 1857 | } |
1857 | 1858 | $data ['accountinfo'] = $accountdata; |
1858 | 1859 | // Get invoice header information |
1859 | - if ($accountdata ['reseller_id'] == '0') |
|
1860 | - $accountid = '1'; |
|
1861 | - else |
|
1862 | - $accountid = $accountdata ['reseller_id']; |
|
1860 | + if ($accountdata ['reseller_id'] == '0') { |
|
1861 | + $accountid = '1'; |
|
1862 | + } else { |
|
1863 | + $accountid = $accountdata ['reseller_id']; |
|
1864 | + } |
|
1863 | 1865 | $invoiceconf = $this->db_model->getSelect ( "*", "invoice_conf", array ( |
1864 | 1866 | "accountid" => $accountid |
1865 | 1867 | ) ); |
@@ -2134,8 +2136,9 @@ discard block |
||
2134 | 2136 | function date_diff_custom($end = '2020-06-09 10:30:00', $out_in_array = false) { |
2135 | 2137 | $intervalo = date_diff ( date_create (), date_create ( $end ) ); |
2136 | 2138 | $out = $intervalo->format ( "Years:%Y,Months:%M,Days:%d,Hours:%H,Minutes:%i,Seconds:%s" ); |
2137 | - if (! $out_in_array) |
|
2138 | - return $out; |
|
2139 | + if (! $out_in_array) { |
|
2140 | + return $out; |
|
2141 | + } |
|
2139 | 2142 | $a_out = array (); |
2140 | 2143 | array_walk ( explode ( ',', $out ), function ($val, $key) use (&$a_out) { |
2141 | 2144 | $v = explode ( ':', $val ); |
@@ -20,23 +20,23 @@ discard block |
||
20 | 20 | // You should have received a copy of the GNU Affero General Public License |
21 | 21 | // along with this program. If not, see <http://www.gnu.org/licenses/>. |
22 | 22 | // ############################################################################## |
23 | -if (! defined ( 'BASEPATH' )) { |
|
24 | - exit ( 'No direct script access allowed' ); |
|
23 | +if ( ! defined('BASEPATH')) { |
|
24 | + exit ('No direct script access allowed'); |
|
25 | 25 | } |
26 | 26 | class invoices_form { |
27 | 27 | function __construct($library_name = '') { |
28 | - $this->CI = & get_instance (); |
|
28 | + $this->CI = & get_instance(); |
|
29 | 29 | } |
30 | 30 | function build_invoices_list_for_admin() { |
31 | - $account_info = $accountinfo = $this->CI->session->userdata ( 'accountinfo' ); |
|
31 | + $account_info = $accountinfo = $this->CI->session->userdata('accountinfo'); |
|
32 | 32 | $currency_id = $account_info ['currency_id']; |
33 | - $currency = $this->CI->common->get_field_name ( 'currency', 'currency', $currency_id ); |
|
33 | + $currency = $this->CI->common->get_field_name('currency', 'currency', $currency_id); |
|
34 | 34 | |
35 | - $logintype = $this->CI->session->userdata ( 'logintype' ); |
|
35 | + $logintype = $this->CI->session->userdata('logintype'); |
|
36 | 36 | $url = ($logintype == 0 || $logintype == 3) ? "/user/user_invoice_download/" : '/invoices/invoice_main_download/'; |
37 | - $grid_field_arr = json_encode ( array ( |
|
38 | - array ( |
|
39 | - gettext ( "Number" ), |
|
37 | + $grid_field_arr = json_encode(array( |
|
38 | + array( |
|
39 | + gettext("Number"), |
|
40 | 40 | "110", |
41 | 41 | "id", |
42 | 42 | "id,'',type", |
@@ -46,8 +46,8 @@ discard block |
||
46 | 46 | "true", |
47 | 47 | "center" |
48 | 48 | ), |
49 | - array ( |
|
50 | - gettext ( "Type" ), |
|
49 | + array( |
|
50 | + gettext("Type"), |
|
51 | 51 | "130", |
52 | 52 | "id", |
53 | 53 | "id,'',type", |
@@ -57,8 +57,8 @@ discard block |
||
57 | 57 | "true", |
58 | 58 | "center" |
59 | 59 | ), |
60 | - array ( |
|
61 | - gettext ( "Account" ), |
|
60 | + array( |
|
61 | + gettext("Account"), |
|
62 | 62 | "130", |
63 | 63 | "accountid", |
64 | 64 | "first_name,last_name,number", |
@@ -68,8 +68,8 @@ discard block |
||
68 | 68 | "true", |
69 | 69 | "center" |
70 | 70 | ), |
71 | - array ( |
|
72 | - gettext ( "Generated<br/> Date" ), |
|
71 | + array( |
|
72 | + gettext("Generated<br/> Date"), |
|
73 | 73 | "140", |
74 | 74 | "invoice_date", |
75 | 75 | "invoice_date", |
@@ -79,8 +79,8 @@ discard block |
||
79 | 79 | "true", |
80 | 80 | "center" |
81 | 81 | ), |
82 | - array ( |
|
83 | - gettext ( "From Date" ), |
|
82 | + array( |
|
83 | + gettext("From Date"), |
|
84 | 84 | "120", |
85 | 85 | "from_date", |
86 | 86 | "from_date", |
@@ -90,8 +90,8 @@ discard block |
||
90 | 90 | "true", |
91 | 91 | "center" |
92 | 92 | ), |
93 | - array ( |
|
94 | - gettext ( "Due Date" ), |
|
93 | + array( |
|
94 | + gettext("Due Date"), |
|
95 | 95 | "130", |
96 | 96 | "", |
97 | 97 | "", |
@@ -101,8 +101,8 @@ discard block |
||
101 | 101 | "true", |
102 | 102 | "center" |
103 | 103 | ), |
104 | - array ( |
|
105 | - gettext ( "Last <br/>Pay Date" ), |
|
104 | + array( |
|
105 | + gettext("Last <br/>Pay Date"), |
|
106 | 106 | "100", |
107 | 107 | "", |
108 | 108 | "", |
@@ -112,8 +112,8 @@ discard block |
||
112 | 112 | "true", |
113 | 113 | "center" |
114 | 114 | ), |
115 | - array ( |
|
116 | - gettext ( "Amount($currency)" ), |
|
115 | + array( |
|
116 | + gettext("Amount($currency)"), |
|
117 | 117 | "120", |
118 | 118 | "id", |
119 | 119 | "id", |
@@ -124,8 +124,8 @@ discard block |
||
124 | 124 | "right" |
125 | 125 | ), |
126 | 126 | |
127 | - array ( |
|
128 | - gettext ( "Outstanding <br/>Amount($currency)" ), |
|
127 | + array( |
|
128 | + gettext("Outstanding <br/>Amount($currency)"), |
|
129 | 129 | "140", |
130 | 130 | "", |
131 | 131 | "", |
@@ -136,14 +136,14 @@ discard block |
||
136 | 136 | "right" |
137 | 137 | ), |
138 | 138 | // array("Payment", "110", "payment", "", "", ""), |
139 | - array ( |
|
140 | - gettext ( "Action" ), |
|
139 | + array( |
|
140 | + gettext("Action"), |
|
141 | 141 | "120", |
142 | 142 | "", |
143 | 143 | "", |
144 | 144 | "", |
145 | - array ( |
|
146 | - "DOWNLOAD" => array ( |
|
145 | + array( |
|
146 | + "DOWNLOAD" => array( |
|
147 | 147 | "url" => $url, |
148 | 148 | "mode" => "single" |
149 | 149 | ) |
@@ -151,19 +151,19 @@ discard block |
||
151 | 151 | // "VIEW" => array("url" => "invoices/invoice_summary_payment/", "mode" => "popup") |
152 | 152 | |
153 | 153 | ) |
154 | - ) ); |
|
154 | + )); |
|
155 | 155 | return $grid_field_arr; |
156 | 156 | } |
157 | 157 | function build_invoices_list_for_customer_admin() { |
158 | - $account_info = $accountinfo = $this->CI->session->userdata ( 'accountinfo' ); |
|
158 | + $account_info = $accountinfo = $this->CI->session->userdata('accountinfo'); |
|
159 | 159 | $currency_id = $account_info ['currency_id']; |
160 | - $currency = $this->CI->common->get_field_name ( 'currency', 'currency', $currency_id ); |
|
160 | + $currency = $this->CI->common->get_field_name('currency', 'currency', $currency_id); |
|
161 | 161 | |
162 | - $logintype = $this->CI->session->userdata ( 'logintype' ); |
|
162 | + $logintype = $this->CI->session->userdata('logintype'); |
|
163 | 163 | $url = ($logintype == 0 || $logintype == 3) ? "/user/user_invoice_download/" : '/invoices/invoice_main_download/'; |
164 | - $grid_field_arr = json_encode ( array ( |
|
165 | - array ( |
|
166 | - gettext ( "Number" ), |
|
164 | + $grid_field_arr = json_encode(array( |
|
165 | + array( |
|
166 | + gettext("Number"), |
|
167 | 167 | "110", |
168 | 168 | "id", |
169 | 169 | "id,'',type", |
@@ -173,8 +173,8 @@ discard block |
||
173 | 173 | "true", |
174 | 174 | "center" |
175 | 175 | ), |
176 | - array ( |
|
177 | - gettext ( "Type" ), |
|
176 | + array( |
|
177 | + gettext("Type"), |
|
178 | 178 | "110", |
179 | 179 | "id", |
180 | 180 | "id,'',type", |
@@ -184,8 +184,8 @@ discard block |
||
184 | 184 | "true", |
185 | 185 | "center" |
186 | 186 | ), |
187 | - array ( |
|
188 | - gettext ( "Generated<br/> Date" ), |
|
187 | + array( |
|
188 | + gettext("Generated<br/> Date"), |
|
189 | 189 | "120", |
190 | 190 | "invoice_date", |
191 | 191 | "invoice_date", |
@@ -195,8 +195,8 @@ discard block |
||
195 | 195 | "true", |
196 | 196 | "center" |
197 | 197 | ), |
198 | - array ( |
|
199 | - gettext ( "From Date" ), |
|
198 | + array( |
|
199 | + gettext("From Date"), |
|
200 | 200 | "120", |
201 | 201 | "from_date", |
202 | 202 | "from_date", |
@@ -206,8 +206,8 @@ discard block |
||
206 | 206 | "true", |
207 | 207 | "center" |
208 | 208 | ), |
209 | - array ( |
|
210 | - gettext ( "Due Date" ), |
|
209 | + array( |
|
210 | + gettext("Due Date"), |
|
211 | 211 | "130", |
212 | 212 | "", |
213 | 213 | "", |
@@ -217,8 +217,8 @@ discard block |
||
217 | 217 | "true", |
218 | 218 | "center" |
219 | 219 | ), |
220 | - array ( |
|
221 | - gettext ( "Last <br/>Pay Date" ), |
|
220 | + array( |
|
221 | + gettext("Last <br/>Pay Date"), |
|
222 | 222 | "100", |
223 | 223 | "", |
224 | 224 | "", |
@@ -228,8 +228,8 @@ discard block |
||
228 | 228 | "true", |
229 | 229 | "center" |
230 | 230 | ), |
231 | - array ( |
|
232 | - gettext ( "Amount($currency)" ), |
|
231 | + array( |
|
232 | + gettext("Amount($currency)"), |
|
233 | 233 | "100", |
234 | 234 | "id", |
235 | 235 | "id", |
@@ -240,8 +240,8 @@ discard block |
||
240 | 240 | "right" |
241 | 241 | ), |
242 | 242 | |
243 | - array ( |
|
244 | - gettext ( "Outstanding <br/>Amount($currency)" ), |
|
243 | + array( |
|
244 | + gettext("Outstanding <br/>Amount($currency)"), |
|
245 | 245 | "100", |
246 | 246 | "", |
247 | 247 | "", |
@@ -251,28 +251,28 @@ discard block |
||
251 | 251 | "true", |
252 | 252 | "right" |
253 | 253 | ), |
254 | - array ( |
|
255 | - gettext ( "Action" ), |
|
254 | + array( |
|
255 | + gettext("Action"), |
|
256 | 256 | "120", |
257 | 257 | "", |
258 | 258 | "", |
259 | 259 | "", |
260 | - array ( |
|
261 | - "DOWNLOAD" => array ( |
|
260 | + array( |
|
261 | + "DOWNLOAD" => array( |
|
262 | 262 | "url" => $url, |
263 | 263 | "mode" => "single" |
264 | 264 | ) |
265 | 265 | ) |
266 | 266 | ) |
267 | - ) ); |
|
267 | + )); |
|
268 | 268 | return $grid_field_arr; |
269 | 269 | } |
270 | 270 | function build_invoices_list_for_customer() { |
271 | - $url = ($this->CI->session->userdata ( 'logintype' ) == 0) ? "/user/user_invoice_download/" : '/invoices/invoice_main_download/'; |
|
271 | + $url = ($this->CI->session->userdata('logintype') == 0) ? "/user/user_invoice_download/" : '/invoices/invoice_main_download/'; |
|
272 | 272 | // array(display name, width, db_field_parent_table,feidname, db_field_child_table,function name); |
273 | - $grid_field_arr = json_encode ( array ( |
|
274 | - array ( |
|
275 | - gettext ( "Number" ), |
|
273 | + $grid_field_arr = json_encode(array( |
|
274 | + array( |
|
275 | + gettext("Number"), |
|
276 | 276 | "100", |
277 | 277 | "id", |
278 | 278 | "id,'',type", |
@@ -282,8 +282,8 @@ discard block |
||
282 | 282 | "true", |
283 | 283 | "center" |
284 | 284 | ), |
285 | - array ( |
|
286 | - gettext ( "Account" ), |
|
285 | + array( |
|
286 | + gettext("Account"), |
|
287 | 287 | "110", |
288 | 288 | "accountid", |
289 | 289 | "first_name,last_name,number", |
@@ -293,8 +293,8 @@ discard block |
||
293 | 293 | "true", |
294 | 294 | "center" |
295 | 295 | ), |
296 | - array ( |
|
297 | - gettext ( "Generated Date" ), |
|
296 | + array( |
|
297 | + gettext("Generated Date"), |
|
298 | 298 | "140", |
299 | 299 | "invoice_date", |
300 | 300 | "invoice_date", |
@@ -304,8 +304,8 @@ discard block |
||
304 | 304 | "true", |
305 | 305 | "center" |
306 | 306 | ), |
307 | - array ( |
|
308 | - gettext ( "From Date" ), |
|
307 | + array( |
|
308 | + gettext("From Date"), |
|
309 | 309 | "140", |
310 | 310 | "from_date", |
311 | 311 | "from_date", |
@@ -315,8 +315,8 @@ discard block |
||
315 | 315 | "true", |
316 | 316 | "center" |
317 | 317 | ), |
318 | - array ( |
|
319 | - gettext ( "Due Date" ), |
|
318 | + array( |
|
319 | + gettext("Due Date"), |
|
320 | 320 | "150", |
321 | 321 | "", |
322 | 322 | "", |
@@ -326,8 +326,8 @@ discard block |
||
326 | 326 | "true", |
327 | 327 | "center" |
328 | 328 | ), |
329 | - array ( |
|
330 | - gettext ( "Last Pay Date" ), |
|
329 | + array( |
|
330 | + gettext("Last Pay Date"), |
|
331 | 331 | "150", |
332 | 332 | "", |
333 | 333 | "", |
@@ -337,8 +337,8 @@ discard block |
||
337 | 337 | "true", |
338 | 338 | "center" |
339 | 339 | ), |
340 | - array ( |
|
341 | - gettext ( "Amount)" ), |
|
340 | + array( |
|
341 | + gettext("Amount)"), |
|
342 | 342 | "150", |
343 | 343 | "id", |
344 | 344 | "id", |
@@ -348,8 +348,8 @@ discard block |
||
348 | 348 | "true", |
349 | 349 | "center" |
350 | 350 | ), |
351 | - array ( |
|
352 | - gettext ( "Outstanding Amount" ), |
|
351 | + array( |
|
352 | + gettext("Outstanding Amount"), |
|
353 | 353 | "150", |
354 | 354 | "", |
355 | 355 | "", |
@@ -357,14 +357,14 @@ discard block |
||
357 | 357 | "" |
358 | 358 | ), |
359 | 359 | // array("Payment", "110", "payment", "", "", ""), |
360 | - array ( |
|
361 | - gettext ( "Action" ), |
|
360 | + array( |
|
361 | + gettext("Action"), |
|
362 | 362 | "160", |
363 | 363 | "", |
364 | 364 | "", |
365 | 365 | "", |
366 | - array ( |
|
367 | - "DOWNLOAD" => array ( |
|
366 | + array( |
|
367 | + "DOWNLOAD" => array( |
|
368 | 368 | "url" => $url, |
369 | 369 | "mode" => "single" |
370 | 370 | ) |
@@ -372,23 +372,23 @@ discard block |
||
372 | 372 | // "VIEW" => array("url" => "invoices/invoice_summary_payment/", "mode" => "popup") |
373 | 373 | |
374 | 374 | ) |
375 | - ) ); |
|
375 | + )); |
|
376 | 376 | return $grid_field_arr; |
377 | 377 | } |
378 | 378 | function get_invoice_search_form() { |
379 | - $account_data = $this->CI->session->userdata ( "accountinfo" ); |
|
379 | + $account_data = $this->CI->session->userdata("accountinfo"); |
|
380 | 380 | $reseller_id = $account_data ['type'] == 1 ? $account_data ['id'] : 0; |
381 | - $form ['forms'] = array ( |
|
381 | + $form ['forms'] = array( |
|
382 | 382 | "", |
383 | - array ( |
|
383 | + array( |
|
384 | 384 | 'id' => "invoice_search" |
385 | 385 | ) |
386 | 386 | ); |
387 | - $form [gettext ( 'Search' )] = array ( |
|
388 | - array ( |
|
389 | - gettext ( 'Number' ), |
|
387 | + $form [gettext('Search')] = array( |
|
388 | + array( |
|
389 | + gettext('Number'), |
|
390 | 390 | 'INPUT', |
391 | - array ( |
|
391 | + array( |
|
392 | 392 | 'name' => 'invoiceid[invoiceid]', |
393 | 393 | '', |
394 | 394 | 'id' => 'invoiceid', |
@@ -405,10 +405,10 @@ discard block |
||
405 | 405 | 'search_string_type', |
406 | 406 | '' |
407 | 407 | ), |
408 | - array ( |
|
409 | - gettext ( 'From Date' ), |
|
408 | + array( |
|
409 | + gettext('From Date'), |
|
410 | 410 | 'INPUT', |
411 | - array ( |
|
411 | + array( |
|
412 | 412 | 'name' => 'from_date[0]', |
413 | 413 | 'id' => 'invoice_from_date', |
414 | 414 | 'size' => '20', |
@@ -419,10 +419,10 @@ discard block |
||
419 | 419 | '', |
420 | 420 | 'from_date[from_date-date]' |
421 | 421 | ), |
422 | - array ( |
|
423 | - gettext ( 'To Date' ), |
|
422 | + array( |
|
423 | + gettext('To Date'), |
|
424 | 424 | 'INPUT', |
425 | - array ( |
|
425 | + array( |
|
426 | 426 | 'name' => 'to_date[0]', |
427 | 427 | 'id' => 'invoice_to_date', |
428 | 428 | 'size' => '20', |
@@ -433,10 +433,10 @@ discard block |
||
433 | 433 | '', |
434 | 434 | 'from_date[from_date-date]' |
435 | 435 | ), |
436 | - array ( |
|
437 | - gettext ( 'Amount' ), |
|
436 | + array( |
|
437 | + gettext('Amount'), |
|
438 | 438 | 'INPUT', |
439 | - array ( |
|
439 | + array( |
|
440 | 440 | 'name' => 'amount[amount]', |
441 | 441 | 'value' => '', |
442 | 442 | 'size' => '20', |
@@ -452,10 +452,10 @@ discard block |
||
452 | 452 | 'search_string_type', |
453 | 453 | '' |
454 | 454 | ), |
455 | - array ( |
|
456 | - gettext ( 'Generated Date' ), |
|
455 | + array( |
|
456 | + gettext('Generated Date'), |
|
457 | 457 | 'INPUT', |
458 | - array ( |
|
458 | + array( |
|
459 | 459 | 'name' => 'invoice_date[0]', |
460 | 460 | '', |
461 | 461 | 'size' => '20', |
@@ -468,8 +468,8 @@ discard block |
||
468 | 468 | 'invoice_date[invoice_date-date]' |
469 | 469 | ), |
470 | 470 | // array('Invoice', 'deleted', 'SELECT', '', '', 'tOOL TIP', 'Please Enter account number', '', '', '', 'set_invoice_details'), |
471 | - array ( |
|
472 | - gettext ( 'Account' ), |
|
471 | + array( |
|
472 | + gettext('Account'), |
|
473 | 473 | 'accountid', |
474 | 474 | 'SELECT', |
475 | 475 | '', |
@@ -481,12 +481,12 @@ discard block |
||
481 | 481 | 'accounts', |
482 | 482 | 'build_dropdown_deleted', |
483 | 483 | 'where_arr', |
484 | - array ( |
|
484 | + array( |
|
485 | 485 | "reseller_id" => $reseller_id, |
486 | 486 | "type" => "GLOBAL" |
487 | 487 | ) |
488 | 488 | ), |
489 | - array ( |
|
489 | + array( |
|
490 | 490 | '', |
491 | 491 | 'HIDDEN', |
492 | 492 | 'ajax_search', |
@@ -495,7 +495,7 @@ discard block |
||
495 | 495 | '', |
496 | 496 | '' |
497 | 497 | ), |
498 | - array ( |
|
498 | + array( |
|
499 | 499 | '', |
500 | 500 | 'HIDDEN', |
501 | 501 | 'advance_search', |
@@ -506,18 +506,18 @@ discard block |
||
506 | 506 | ) |
507 | 507 | ); |
508 | 508 | |
509 | - $form ['button_search'] = array ( |
|
509 | + $form ['button_search'] = array( |
|
510 | 510 | 'name' => 'action', |
511 | 511 | 'id' => "invoice_search_btn", |
512 | - 'content' => gettext ( 'Search' ), |
|
512 | + 'content' => gettext('Search'), |
|
513 | 513 | 'value' => 'save', |
514 | 514 | 'type' => 'button', |
515 | 515 | 'class' => 'btn btn-line-parrot pull-right' |
516 | 516 | ); |
517 | - $form ['button_reset'] = array ( |
|
517 | + $form ['button_reset'] = array( |
|
518 | 518 | 'name' => 'action', |
519 | 519 | 'id' => "id_reset", |
520 | - 'content' => gettext ( 'Clear' ), |
|
520 | + 'content' => gettext('Clear'), |
|
521 | 521 | 'value' => 'cancel', |
522 | 522 | 'type' => 'reset', |
523 | 523 | 'class' => 'btn btn-line-sky pull-right margin-x-10' |
@@ -526,11 +526,11 @@ discard block |
||
526 | 526 | return $form; |
527 | 527 | } |
528 | 528 | function build_grid_buttons() { |
529 | - $buttons_json = json_encode ( array () ); |
|
529 | + $buttons_json = json_encode(array()); |
|
530 | 530 | return $buttons_json; |
531 | 531 | } |
532 | 532 | function get_invoiceconf_form_fields($invoiceconf = '0') { |
533 | - if (! empty ( $invoiceconf )) { |
|
533 | + if ( ! empty ($invoiceconf)) { |
|
534 | 534 | if ($invoiceconf ['logo'] != '') { |
535 | 535 | $logo = $invoiceconf ['file']; |
536 | 536 | } else { |
@@ -543,11 +543,11 @@ discard block |
||
543 | 543 | } |
544 | 544 | $accountid = $invoiceconf ['accountid']; |
545 | 545 | if ($logo != '') { |
546 | - $file_name = base_url () . "upload/$logo"; |
|
547 | - $image_path = array ( |
|
546 | + $file_name = base_url()."upload/$logo"; |
|
547 | + $image_path = array( |
|
548 | 548 | 'Existing Image', |
549 | 549 | 'IMAGE', |
550 | - array ( |
|
550 | + array( |
|
551 | 551 | 'type' => 'image', |
552 | 552 | 'name' => 'image', |
553 | 553 | 'style' => 'width:100%;margin-top:20px;', |
@@ -557,10 +557,10 @@ discard block |
||
557 | 557 | 'tOOL TIP', |
558 | 558 | '' |
559 | 559 | ); |
560 | - $delete_logo = array ( |
|
560 | + $delete_logo = array( |
|
561 | 561 | 'Delete logo', |
562 | 562 | 'DEL_BUTTON', |
563 | - array ( |
|
563 | + array( |
|
564 | 564 | 'value' => 'ankit', |
565 | 565 | 'style' => 'margin-top:20px;', |
566 | 566 | 'name' => 'button', |
@@ -573,10 +573,10 @@ discard block |
||
573 | 573 | 'Please Enter account number' |
574 | 574 | ); |
575 | 575 | } else { |
576 | - $image_path = array ( |
|
576 | + $image_path = array( |
|
577 | 577 | 'Existing Image', |
578 | 578 | 'HIDDEN', |
579 | - array ( |
|
579 | + array( |
|
580 | 580 | 'type' => '', |
581 | 581 | 'name' => '', |
582 | 582 | 'style' => 'width:250px;' |
@@ -585,10 +585,10 @@ discard block |
||
585 | 585 | 'tOOL TIP', |
586 | 586 | '' |
587 | 587 | ); |
588 | - $delete_logo = array ( |
|
588 | + $delete_logo = array( |
|
589 | 589 | 'Delete logo', |
590 | 590 | 'HIDDEN', |
591 | - array ( |
|
591 | + array( |
|
592 | 592 | 'value' => 'ankit', |
593 | 593 | 'style' => 'margin-top:0px;', |
594 | 594 | 'name' => 'button', |
@@ -605,12 +605,12 @@ discard block |
||
605 | 605 | } |
606 | 606 | if ($favicon != '') { |
607 | 607 | |
608 | - $file_name_fav = base_url () . "upload/$favicon"; |
|
608 | + $file_name_fav = base_url()."upload/$favicon"; |
|
609 | 609 | |
610 | - $image_fav = array ( |
|
610 | + $image_fav = array( |
|
611 | 611 | 'Existing Favicon', |
612 | 612 | 'IMAGE', |
613 | - array ( |
|
613 | + array( |
|
614 | 614 | 'type' => 'image', |
615 | 615 | 'name' => 'image', |
616 | 616 | 'style' => 'width:100%;margin-top:20px;', |
@@ -620,10 +620,10 @@ discard block |
||
620 | 620 | 'tOOL TIP', |
621 | 621 | '' |
622 | 622 | ); |
623 | - $delete_fav = array ( |
|
623 | + $delete_fav = array( |
|
624 | 624 | 'Delete Favicon', |
625 | 625 | 'DEL_BUTTON', |
626 | - array ( |
|
626 | + array( |
|
627 | 627 | 'value' => '', |
628 | 628 | 'style' => 'margin-top:20px;', |
629 | 629 | 'name' => 'button', |
@@ -636,10 +636,10 @@ discard block |
||
636 | 636 | 'Please Enter account number' |
637 | 637 | ); |
638 | 638 | } else { |
639 | - $image_fav = array ( |
|
639 | + $image_fav = array( |
|
640 | 640 | 'Existing Favicon', |
641 | 641 | 'HIDDEN', |
642 | - array ( |
|
642 | + array( |
|
643 | 643 | 'type' => '', |
644 | 644 | 'name' => '', |
645 | 645 | 'style' => 'width:250px;' |
@@ -648,10 +648,10 @@ discard block |
||
648 | 648 | 'tOOL TIP', |
649 | 649 | '' |
650 | 650 | ); |
651 | - $delete_fav = array ( |
|
651 | + $delete_fav = array( |
|
652 | 652 | 'Delete Favicon', |
653 | 653 | 'HIDDEN', |
654 | - array ( |
|
654 | + array( |
|
655 | 655 | 'value' => '', |
656 | 656 | 'style' => 'margin-top:0px;', |
657 | 657 | 'name' => 'button', |
@@ -672,10 +672,10 @@ discard block |
||
672 | 672 | $favicon = ''; |
673 | 673 | $file_name_fav = ''; |
674 | 674 | $accountid = 0; |
675 | - $image_path = array ( |
|
675 | + $image_path = array( |
|
676 | 676 | 'Existing Image', |
677 | 677 | 'HIDDEN', |
678 | - array ( |
|
678 | + array( |
|
679 | 679 | 'type' => '', |
680 | 680 | 'name' => '' |
681 | 681 | ), |
@@ -683,14 +683,14 @@ discard block |
||
683 | 683 | 'tOOL TIP', |
684 | 684 | '' |
685 | 685 | ); |
686 | - $delete_logo = array ( |
|
686 | + $delete_logo = array( |
|
687 | 687 | 'Delete logo', |
688 | 688 | 'HIDDEN', |
689 | - array ( |
|
689 | + array( |
|
690 | 690 | 'value' => '', |
691 | 691 | 'style' => 'margin-top:0px;', |
692 | 692 | 'name' => 'button', |
693 | - 'onclick' => 'return image_delete(' . $accountid . ')', |
|
693 | + 'onclick' => 'return image_delete('.$accountid.')', |
|
694 | 694 | 'size' => '20', |
695 | 695 | 'maxlength' => '100', |
696 | 696 | 'class' => "btn btn-line-parrot" |
@@ -699,10 +699,10 @@ discard block |
||
699 | 699 | 'tOOL TIP', |
700 | 700 | 'Please Enter account number' |
701 | 701 | ); |
702 | - $image_fav = array ( |
|
702 | + $image_fav = array( |
|
703 | 703 | 'Existing Favicon', |
704 | 704 | 'HIDDEN', |
705 | - array ( |
|
705 | + array( |
|
706 | 706 | 'type' => '', |
707 | 707 | 'name' => '' |
708 | 708 | ), |
@@ -710,14 +710,14 @@ discard block |
||
710 | 710 | 'tOOL TIP', |
711 | 711 | '' |
712 | 712 | ); |
713 | - $delete_fav = array ( |
|
713 | + $delete_fav = array( |
|
714 | 714 | 'Delete Favicon', |
715 | 715 | 'HIDDEN', |
716 | - array ( |
|
716 | + array( |
|
717 | 717 | 'value' => '', |
718 | 718 | 'style' => 'margin-top:0px;', |
719 | 719 | 'name' => 'button', |
720 | - 'onclick' => 'return image_delete(' . $accountid . ')', |
|
720 | + 'onclick' => 'return image_delete('.$accountid.')', |
|
721 | 721 | 'size' => '20', |
722 | 722 | 'maxlength' => '100', |
723 | 723 | 'class' => "btn btn-line-parrot" |
@@ -728,20 +728,20 @@ discard block |
||
728 | 728 | ); |
729 | 729 | // $image_path=array(); |
730 | 730 | } |
731 | - $form ['forms'] = array ( |
|
732 | - base_url () . 'invoices/invoice_conf/', |
|
733 | - array ( |
|
731 | + $form ['forms'] = array( |
|
732 | + base_url().'invoices/invoice_conf/', |
|
733 | + array( |
|
734 | 734 | 'id' => 'invoice_conf_form', |
735 | 735 | 'method' => 'POST', |
736 | 736 | 'name' => 'invoice_conf_form', |
737 | 737 | 'enctype' => 'multipart/form-data' |
738 | 738 | ) |
739 | 739 | ); |
740 | - $form ['Configuration '] = array ( |
|
741 | - array ( |
|
740 | + $form ['Configuration '] = array( |
|
741 | + array( |
|
742 | 742 | '', |
743 | 743 | 'HIDDEN', |
744 | - array ( |
|
744 | + array( |
|
745 | 745 | 'name' => 'id' |
746 | 746 | ), |
747 | 747 | '', |
@@ -749,10 +749,10 @@ discard block |
||
749 | 749 | '', |
750 | 750 | '' |
751 | 751 | ), |
752 | - array ( |
|
752 | + array( |
|
753 | 753 | '', |
754 | 754 | 'HIDDEN', |
755 | - array ( |
|
755 | + array( |
|
756 | 756 | 'name' => 'accountid' |
757 | 757 | ), |
758 | 758 | '', |
@@ -761,10 +761,10 @@ discard block |
||
761 | 761 | '' |
762 | 762 | ), |
763 | 763 | // array('', 'HIDDEN', array('name' => 'start_name','value' => '1'), '', '', ''), |
764 | - array ( |
|
765 | - gettext ( 'Company name' ), |
|
764 | + array( |
|
765 | + gettext('Company name'), |
|
766 | 766 | 'INPUT', |
767 | - array ( |
|
767 | + array( |
|
768 | 768 | 'name' => 'company_name', |
769 | 769 | 'size' => '20', |
770 | 770 | 'class' => "text field medium" |
@@ -773,10 +773,10 @@ discard block |
||
773 | 773 | 'tOOL TIP', |
774 | 774 | 'Please Enter account number' |
775 | 775 | ), |
776 | - array ( |
|
777 | - gettext ( 'Address' ), |
|
776 | + array( |
|
777 | + gettext('Address'), |
|
778 | 778 | 'INPUT', |
779 | - array ( |
|
779 | + array( |
|
780 | 780 | 'name' => 'address', |
781 | 781 | 'size' => '20', |
782 | 782 | 'class' => "text field medium" |
@@ -785,10 +785,10 @@ discard block |
||
785 | 785 | 'tOOL TIP', |
786 | 786 | 'Please Enter account number' |
787 | 787 | ), |
788 | - array ( |
|
789 | - gettext ( 'City' ), |
|
788 | + array( |
|
789 | + gettext('City'), |
|
790 | 790 | 'INPUT', |
791 | - array ( |
|
791 | + array( |
|
792 | 792 | 'name' => 'city', |
793 | 793 | 'size' => '20', |
794 | 794 | 'class' => "text field medium" |
@@ -797,10 +797,10 @@ discard block |
||
797 | 797 | 'tOOL TIP', |
798 | 798 | 'Please Enter account number' |
799 | 799 | ), |
800 | - array ( |
|
801 | - gettext ( 'Province' ), |
|
800 | + array( |
|
801 | + gettext('Province'), |
|
802 | 802 | 'INPUT', |
803 | - array ( |
|
803 | + array( |
|
804 | 804 | 'name' => 'province', |
805 | 805 | 'size' => '20', |
806 | 806 | 'class' => "text field medium" |
@@ -809,10 +809,10 @@ discard block |
||
809 | 809 | 'tOOL TIP', |
810 | 810 | 'Please Enter account number' |
811 | 811 | ), |
812 | - array ( |
|
813 | - gettext ( 'Country' ), |
|
812 | + array( |
|
813 | + gettext('Country'), |
|
814 | 814 | 'INPUT', |
815 | - array ( |
|
815 | + array( |
|
816 | 816 | 'name' => 'country', |
817 | 817 | 'size' => '20', |
818 | 818 | 'class' => "text field medium" |
@@ -821,10 +821,10 @@ discard block |
||
821 | 821 | 'tOOL TIP', |
822 | 822 | 'Please Enter account number' |
823 | 823 | ), |
824 | - array ( |
|
825 | - gettext ( 'Zipcode' ), |
|
824 | + array( |
|
825 | + gettext('Zipcode'), |
|
826 | 826 | 'INPUT', |
827 | - array ( |
|
827 | + array( |
|
828 | 828 | 'name' => 'zipcode', |
829 | 829 | 'size' => '20', |
830 | 830 | 'class' => "text field medium" |
@@ -833,10 +833,10 @@ discard block |
||
833 | 833 | 'tOOL TIP', |
834 | 834 | 'Please Enter account number' |
835 | 835 | ), |
836 | - array ( |
|
837 | - gettext ( 'Telephone' ), |
|
836 | + array( |
|
837 | + gettext('Telephone'), |
|
838 | 838 | 'INPUT', |
839 | - array ( |
|
839 | + array( |
|
840 | 840 | 'name' => 'telephone', |
841 | 841 | 'size' => '20', |
842 | 842 | 'class' => "text field medium" |
@@ -845,10 +845,10 @@ discard block |
||
845 | 845 | 'tOOL TIP', |
846 | 846 | 'Please Enter account number' |
847 | 847 | ), |
848 | - array ( |
|
849 | - gettext ( 'Fax' ), |
|
848 | + array( |
|
849 | + gettext('Fax'), |
|
850 | 850 | 'INPUT', |
851 | - array ( |
|
851 | + array( |
|
852 | 852 | 'name' => 'fax', |
853 | 853 | 'size' => '20', |
854 | 854 | 'class' => "text field medium" |
@@ -857,10 +857,10 @@ discard block |
||
857 | 857 | 'tOOL TIP', |
858 | 858 | 'Please Enter account number' |
859 | 859 | ), |
860 | - array ( |
|
861 | - gettext ( 'Email Address' ), |
|
860 | + array( |
|
861 | + gettext('Email Address'), |
|
862 | 862 | 'INPUT', |
863 | - array ( |
|
863 | + array( |
|
864 | 864 | 'name' => 'emailaddress', |
865 | 865 | 'size' => '20', |
866 | 866 | 'class' => "text field medium" |
@@ -869,10 +869,10 @@ discard block |
||
869 | 869 | 'tOOL TIP', |
870 | 870 | 'Please Enter account number' |
871 | 871 | ), |
872 | - array ( |
|
873 | - gettext ( 'Website' ), |
|
872 | + array( |
|
873 | + gettext('Website'), |
|
874 | 874 | 'INPUT', |
875 | - array ( |
|
875 | + array( |
|
876 | 876 | 'name' => 'website', |
877 | 877 | 'size' => '20', |
878 | 878 | 'class' => "text field medium" |
@@ -883,11 +883,11 @@ discard block |
||
883 | 883 | ) |
884 | 884 | ) |
885 | 885 | ; |
886 | - $form ['Invoice Configuration '] = array ( |
|
887 | - array ( |
|
886 | + $form ['Invoice Configuration '] = array( |
|
887 | + array( |
|
888 | 888 | '', |
889 | 889 | 'HIDDEN', |
890 | - array ( |
|
890 | + array( |
|
891 | 891 | 'name' => 'id' |
892 | 892 | ), |
893 | 893 | '', |
@@ -895,10 +895,10 @@ discard block |
||
895 | 895 | '', |
896 | 896 | '' |
897 | 897 | ), |
898 | - array ( |
|
898 | + array( |
|
899 | 899 | '', |
900 | 900 | 'HIDDEN', |
901 | - array ( |
|
901 | + array( |
|
902 | 902 | 'name' => 'accountid' |
903 | 903 | ), |
904 | 904 | '', |
@@ -906,8 +906,8 @@ discard block |
||
906 | 906 | '', |
907 | 907 | '' |
908 | 908 | ), |
909 | - array ( |
|
910 | - gettext ( 'Invoice Notification' ), |
|
909 | + array( |
|
910 | + gettext('Invoice Notification'), |
|
911 | 911 | 'invoice_notification', |
912 | 912 | 'SELECT', |
913 | 913 | '', |
@@ -919,8 +919,8 @@ discard block |
||
919 | 919 | '', |
920 | 920 | 'set_allow_invoice' |
921 | 921 | ), |
922 | - array ( |
|
923 | - gettext ( 'Invoice Due Notification' ), |
|
922 | + array( |
|
923 | + gettext('Invoice Due Notification'), |
|
924 | 924 | 'invoice_due_notification', |
925 | 925 | 'SELECT', |
926 | 926 | '', |
@@ -932,10 +932,10 @@ discard block |
||
932 | 932 | '', |
933 | 933 | 'set_allow_invoice' |
934 | 934 | ), |
935 | - array ( |
|
936 | - gettext ( 'Invoice Date Interval' ), |
|
935 | + array( |
|
936 | + gettext('Invoice Date Interval'), |
|
937 | 937 | 'INPUT', |
938 | - array ( |
|
938 | + array( |
|
939 | 939 | 'name' => 'interval', |
940 | 940 | 'size' => '20', |
941 | 941 | 'class' => "text field medium" |
@@ -944,10 +944,10 @@ discard block |
||
944 | 944 | 'tOOL TIP', |
945 | 945 | 'Please Enter account number' |
946 | 946 | ), |
947 | - array ( |
|
948 | - gettext ( 'Notify before days' ), |
|
947 | + array( |
|
948 | + gettext('Notify before days'), |
|
949 | 949 | 'INPUT', |
950 | - array ( |
|
950 | + array( |
|
951 | 951 | 'name' => 'notify_before_day', |
952 | 952 | 'size' => '20', |
953 | 953 | 'class' => "text field medium" |
@@ -956,10 +956,10 @@ discard block |
||
956 | 956 | 'tOOL TIP', |
957 | 957 | 'Please Enter account number' |
958 | 958 | ), |
959 | - array ( |
|
960 | - gettext ( 'Invoice Prefix' ), |
|
959 | + array( |
|
960 | + gettext('Invoice Prefix'), |
|
961 | 961 | 'INPUT', |
962 | - array ( |
|
962 | + array( |
|
963 | 963 | 'name' => 'invoice_prefix', |
964 | 964 | 'size' => '20', |
965 | 965 | 'class' => "text field medium" |
@@ -968,10 +968,10 @@ discard block |
||
968 | 968 | 'tOOL TIP', |
969 | 969 | 'Please Enter account number' |
970 | 970 | ), |
971 | - array ( |
|
972 | - gettext ( 'Invoice Start Form' ), |
|
971 | + array( |
|
972 | + gettext('Invoice Start Form'), |
|
973 | 973 | 'INPUT', |
974 | - array ( |
|
974 | + array( |
|
975 | 975 | 'name' => 'invoice_start_from', |
976 | 976 | 'size' => '20', |
977 | 977 | 'class' => "text field medium" |
@@ -980,10 +980,10 @@ discard block |
||
980 | 980 | 'tOOL TIP', |
981 | 981 | 'Please Enter account number' |
982 | 982 | ), |
983 | - array ( |
|
984 | - gettext ( 'Invoice Taxes number' ), |
|
983 | + array( |
|
984 | + gettext('Invoice Taxes number'), |
|
985 | 985 | 'INPUT', |
986 | - array ( |
|
986 | + array( |
|
987 | 987 | 'name' => 'invoice_taxes_number', |
988 | 988 | 'size' => '20', |
989 | 989 | 'class' => "text field medium" |
@@ -992,10 +992,10 @@ discard block |
||
992 | 992 | 'tOOL TIP', |
993 | 993 | 'Please Enter account number' |
994 | 994 | ), |
995 | - array ( |
|
995 | + array( |
|
996 | 996 | '', |
997 | 997 | 'HIDDEN', |
998 | - array ( |
|
998 | + array( |
|
999 | 999 | 'name' => '' |
1000 | 1000 | ), |
1001 | 1001 | '', |
@@ -1003,10 +1003,10 @@ discard block |
||
1003 | 1003 | '', |
1004 | 1004 | '' |
1005 | 1005 | ), |
1006 | - array ( |
|
1006 | + array( |
|
1007 | 1007 | '', |
1008 | 1008 | 'HIDDEN', |
1009 | - array ( |
|
1009 | + array( |
|
1010 | 1010 | 'name' => '' |
1011 | 1011 | ), |
1012 | 1012 | '', |
@@ -1015,12 +1015,12 @@ discard block |
||
1015 | 1015 | '' |
1016 | 1016 | ) |
1017 | 1017 | ); |
1018 | - $form ['Company personalization'] = array ( |
|
1018 | + $form ['Company personalization'] = array( |
|
1019 | 1019 | |
1020 | - array ( |
|
1021 | - gettext ( 'Website Domain' ), |
|
1020 | + array( |
|
1021 | + gettext('Website Domain'), |
|
1022 | 1022 | 'INPUT', |
1023 | - array ( |
|
1023 | + array( |
|
1024 | 1024 | 'name' => 'domain', |
1025 | 1025 | 'size' => '20', |
1026 | 1026 | 'maxlength' => '100', |
@@ -1030,10 +1030,10 @@ discard block |
||
1030 | 1030 | 'tOOL TIP', |
1031 | 1031 | '' |
1032 | 1032 | ), |
1033 | - array ( |
|
1034 | - gettext ( 'Website Header' ), |
|
1033 | + array( |
|
1034 | + gettext('Website Header'), |
|
1035 | 1035 | 'INPUT', |
1036 | - array ( |
|
1036 | + array( |
|
1037 | 1037 | 'name' => 'website_title', |
1038 | 1038 | 'size' => '100', |
1039 | 1039 | 'maxlength' => '100', |
@@ -1043,10 +1043,10 @@ discard block |
||
1043 | 1043 | 'tOOL TIP', |
1044 | 1044 | '' |
1045 | 1045 | ), |
1046 | - array ( |
|
1047 | - gettext ( 'Website Footer' ), |
|
1046 | + array( |
|
1047 | + gettext('Website Footer'), |
|
1048 | 1048 | 'INPUT', |
1049 | - array ( |
|
1049 | + array( |
|
1050 | 1050 | 'name' => 'website_footer', |
1051 | 1051 | 'size' => '200', |
1052 | 1052 | 'maxlength' => '200', |
@@ -1056,10 +1056,10 @@ discard block |
||
1056 | 1056 | 'tOOL TIP', |
1057 | 1057 | '' |
1058 | 1058 | ), |
1059 | - array ( |
|
1060 | - gettext ( 'Company logo' ), |
|
1059 | + array( |
|
1060 | + gettext('Company logo'), |
|
1061 | 1061 | 'IMAGE', |
1062 | - array ( |
|
1062 | + array( |
|
1063 | 1063 | 'name' => 'file', |
1064 | 1064 | 'size' => '20', |
1065 | 1065 | 'maxlength' => '100', |
@@ -1074,10 +1074,10 @@ discard block |
||
1074 | 1074 | // array('', 'BLANL_DIV', array('name'=>'accountid','id'=>'imagePreview'),'', '', '', ''), |
1075 | 1075 | $delete_logo, |
1076 | 1076 | $image_path, |
1077 | - array ( |
|
1077 | + array( |
|
1078 | 1078 | 'Company Favicon', |
1079 | 1079 | 'IMAGE', |
1080 | - array ( |
|
1080 | + array( |
|
1081 | 1081 | 'name' => 'file_fav', |
1082 | 1082 | 'size' => '20', |
1083 | 1083 | 'maxlength' => '100', |
@@ -1092,9 +1092,9 @@ discard block |
||
1092 | 1092 | $delete_fav, |
1093 | 1093 | $image_fav |
1094 | 1094 | ); |
1095 | - $form ['button_save'] = array ( |
|
1095 | + $form ['button_save'] = array( |
|
1096 | 1096 | 'name' => 'action', |
1097 | - 'content' => gettext ( 'Save' ), |
|
1097 | + 'content' => gettext('Save'), |
|
1098 | 1098 | 'value' => 'save', |
1099 | 1099 | 'type' => 'submit', |
1100 | 1100 | 'class' => 'btn btn-line-parrot' |
@@ -133,10 +133,10 @@ |
||
133 | 133 | <div class="col-md-5"><label style="text-align:left;float:left;" class="col-md-3"><?php echo gettext('Accounts'); ?> </label> |
134 | 134 | <?php |
135 | 135 | if($login_type == -1 || $login_type == 4 || $login_type == 2){ |
136 | - $where="deleted = '0' AND reseller_id = '0' AND status = '0' AND (type= '0' OR type= '3' OR type= '1')"; |
|
136 | + $where="deleted = '0' AND reseller_id = '0' AND status = '0' AND (type= '0' OR type= '3' OR type= '1')"; |
|
137 | 137 | }if($login_type == 1 ){ |
138 | 138 | |
139 | - $where="deleted = '0' AND reseller_id = '$id' AND status = '0' AND (type= '0' OR type= '3' OR type='1')"; |
|
139 | + $where="deleted = '0' AND reseller_id = '$id' AND status = '0' AND (type= '0' OR type= '3' OR type='1')"; |
|
140 | 140 | |
141 | 141 | } |
142 | 142 | $account=$this->db_model->build_dropdown_invoices('id,first_name,last_name,number,type', 'accounts', '', $where);?> |
@@ -132,16 +132,16 @@ |
||
132 | 132 | </div> |
133 | 133 | <div class="col-md-5"><label style="text-align:left;float:left;" class="col-md-3"><?php echo gettext('Accounts'); ?> </label> |
134 | 134 | <?php |
135 | - if($login_type == -1 || $login_type == 4 || $login_type == 2){ |
|
136 | - $where="deleted = '0' AND reseller_id = '0' AND status = '0' AND (type= '0' OR type= '3' OR type= '1')"; |
|
137 | - }if($login_type == 1 ){ |
|
135 | + if ($login_type == -1 || $login_type == 4 || $login_type == 2) { |
|
136 | + $where = "deleted = '0' AND reseller_id = '0' AND status = '0' AND (type= '0' OR type= '3' OR type= '1')"; |
|
137 | + }if ($login_type == 1) { |
|
138 | 138 | |
139 | - $where="deleted = '0' AND reseller_id = '$id' AND status = '0' AND (type= '0' OR type= '3' OR type='1')"; |
|
139 | + $where = "deleted = '0' AND reseller_id = '$id' AND status = '0' AND (type= '0' OR type= '3' OR type='1')"; |
|
140 | 140 | |
141 | 141 | } |
142 | - $account=$this->db_model->build_dropdown_invoices('id,first_name,last_name,number,type', 'accounts', '', $where);?> |
|
142 | + $account = $this->db_model->build_dropdown_invoices('id,first_name,last_name,number,type', 'accounts', '', $where); ?> |
|
143 | 143 | |
144 | - <?php echo form_dropdown_all('accountid', $account,''); ?> |
|
144 | + <?php echo form_dropdown_all('accountid', $account, ''); ?> |
|
145 | 145 | </div> |
146 | 146 | <div> |
147 | 147 | <div><label style="text-align:left;float:left;" class="col-md-1"><?php echo gettext('Notes'); ?> </label> |
@@ -22,78 +22,78 @@ discard block |
||
22 | 22 | // ############################################################################## |
23 | 23 | class Package_model extends CI_Model { |
24 | 24 | function Package_model() { |
25 | - parent::__construct (); |
|
25 | + parent::__construct(); |
|
26 | 26 | } |
27 | 27 | function getpackage_list($flag, $start = 0, $limit = 0) { |
28 | - $this->db_model->build_search ( 'package_list_search' ); |
|
29 | - if ($this->session->userdata ( 'logintype' ) == 1 || $this->session->userdata ( 'logintype' ) == 5) { |
|
30 | - $account_data = $this->session->userdata ( "accountinfo" ); |
|
31 | - $where = array ( |
|
28 | + $this->db_model->build_search('package_list_search'); |
|
29 | + if ($this->session->userdata('logintype') == 1 || $this->session->userdata('logintype') == 5) { |
|
30 | + $account_data = $this->session->userdata("accountinfo"); |
|
31 | + $where = array( |
|
32 | 32 | "reseller_id" => $account_data ['id'] |
33 | 33 | ); |
34 | 34 | } else { |
35 | - $where = array ( |
|
35 | + $where = array( |
|
36 | 36 | "reseller_id" => "0" |
37 | 37 | ); |
38 | 38 | } |
39 | 39 | if ($flag) { |
40 | - $query = $this->db_model->select ( "*", "packages", $where, "id", "ASC", $limit, $start ); |
|
40 | + $query = $this->db_model->select("*", "packages", $where, "id", "ASC", $limit, $start); |
|
41 | 41 | } else { |
42 | - $query = $this->db_model->countQuery ( "*", "packages", $where ); |
|
42 | + $query = $this->db_model->countQuery("*", "packages", $where); |
|
43 | 43 | } |
44 | 44 | return $query; |
45 | 45 | } |
46 | 46 | function get_reseller_package_list($flag, $accountid, $accounttype, $start = 0, $limit = 0) { |
47 | - $instant_search = $this->session->userdata ( 'left_panel_search_' . $accounttype . '_packages' ); |
|
48 | - $instant_search_currency = $this->common_model->add_calculate_currency ( $instant_search, "", '', true, false ); |
|
49 | - $like_str = ! empty ( $instant_search ) ? "(package_name like '%$instant_search%' |
|
47 | + $instant_search = $this->session->userdata('left_panel_search_'.$accounttype.'_packages'); |
|
48 | + $instant_search_currency = $this->common_model->add_calculate_currency($instant_search, "", '', true, false); |
|
49 | + $like_str = ! empty ($instant_search) ? "(package_name like '%$instant_search%' |
|
50 | 50 | OR includedseconds like '%$instant_search%')" : null; |
51 | - $this->db->where ( 'id', $accountid ); |
|
52 | - $this->db->select ( 'pricelist_id' ); |
|
53 | - $account_info = ( array ) $this->db->get ( 'accounts' )->first_row (); |
|
54 | - $where = array ( |
|
51 | + $this->db->where('id', $accountid); |
|
52 | + $this->db->select('pricelist_id'); |
|
53 | + $account_info = (array)$this->db->get('accounts')->first_row(); |
|
54 | + $where = array( |
|
55 | 55 | 'pricelist_id' => $account_info ['pricelist_id'] |
56 | 56 | ); |
57 | - if (! empty ( $like_str )) |
|
58 | - $this->db->where ( $like_str ); |
|
57 | + if ( ! empty ($like_str)) |
|
58 | + $this->db->where($like_str); |
|
59 | 59 | if ($flag) { |
60 | - $query = $this->db_model->select ( "*", "packages", $where, "id", "ASC", $limit, $start ); |
|
60 | + $query = $this->db_model->select("*", "packages", $where, "id", "ASC", $limit, $start); |
|
61 | 61 | } else { |
62 | - $query = $this->db_model->countQuery ( "*", "packages", $where ); |
|
62 | + $query = $this->db_model->countQuery("*", "packages", $where); |
|
63 | 63 | } |
64 | 64 | return $query; |
65 | 65 | } |
66 | 66 | function add_package($add_array) { |
67 | - if ($this->session->userdata ( 'logintype' ) == 1 || $this->session->userdata ( 'logintype' ) == 5) { |
|
68 | - $account_data = $this->session->userdata ( "accountinfo" ); |
|
67 | + if ($this->session->userdata('logintype') == 1 || $this->session->userdata('logintype') == 5) { |
|
68 | + $account_data = $this->session->userdata("accountinfo"); |
|
69 | 69 | $add_array ["reseller_id"] = $account_data ['id']; |
70 | 70 | } |
71 | - unset ( $add_array ["action"] ); |
|
71 | + unset ($add_array ["action"]); |
|
72 | 72 | /* |
73 | 73 | * ASTPP 3.0 Add creation date |
74 | 74 | */ |
75 | - $add_array ['creation_date'] = gmdate ( 'Y-m-d H:i:s' ); |
|
75 | + $add_array ['creation_date'] = gmdate('Y-m-d H:i:s'); |
|
76 | 76 | /** |
77 | 77 | * **************************************** |
78 | 78 | */ |
79 | - $this->db->insert ( "packages", $add_array ); |
|
79 | + $this->db->insert("packages", $add_array); |
|
80 | 80 | return true; |
81 | 81 | } |
82 | 82 | function edit_package($data, $id) { |
83 | - unset ( $data ["action"] ); |
|
83 | + unset ($data ["action"]); |
|
84 | 84 | /* |
85 | 85 | * ASTPP 3.0 add last modified field. |
86 | 86 | */ |
87 | - $data ['last_modified_date'] = gmdate ( 'Y-m-d H:i:s' ); |
|
87 | + $data ['last_modified_date'] = gmdate('Y-m-d H:i:s'); |
|
88 | 88 | /** |
89 | 89 | * ***************************************** |
90 | 90 | */ |
91 | - if ($this->session->userdata ( 'logintype' ) == 1 || $this->session->userdata ( 'logintype' ) == 5) { |
|
92 | - $account_data = $this->session->userdata ( "accountinfo" ); |
|
91 | + if ($this->session->userdata('logintype') == 1 || $this->session->userdata('logintype') == 5) { |
|
92 | + $account_data = $this->session->userdata("accountinfo"); |
|
93 | 93 | $add_array ["reseller_id"] = $account_data ['id']; |
94 | 94 | } |
95 | - $this->db->where ( "id", $id ); |
|
96 | - $this->db->update ( "packages", $data ); |
|
95 | + $this->db->where("id", $id); |
|
96 | + $this->db->update("packages", $data); |
|
97 | 97 | return true; |
98 | 98 | } |
99 | 99 | function remove_package($id) { |
@@ -101,55 +101,55 @@ discard block |
||
101 | 101 | * ASTPP 3.0 |
102 | 102 | * Remove Package information from table package_patterns as well. |
103 | 103 | */ |
104 | - $this->db->where ( 'package_id', $id ); |
|
105 | - $this->db->delete ( 'package_patterns' ); |
|
104 | + $this->db->where('package_id', $id); |
|
105 | + $this->db->delete('package_patterns'); |
|
106 | 106 | /** |
107 | 107 | * ************************************ |
108 | 108 | */ |
109 | - $this->db->where ( "id", $id ); |
|
110 | - $this->db->delete ( "packages" ); |
|
109 | + $this->db->where("id", $id); |
|
110 | + $this->db->delete("packages"); |
|
111 | 111 | return true; |
112 | 112 | } |
113 | 113 | function getpackage_counter_list($flag, $start = 0, $limit = 0) { |
114 | - $where = array (); |
|
115 | - $accountinfo = $this->session->userdata ( 'accountinfo' ); |
|
114 | + $where = array(); |
|
115 | + $accountinfo = $this->session->userdata('accountinfo'); |
|
116 | 116 | $reseller_id = $accountinfo ['type'] == - 1 ? 0 : $accountinfo ['id']; |
117 | - $this->db->where ( 'reseller_id', $reseller_id ); |
|
118 | - $this->db->select ( 'id' ); |
|
119 | - $result = $this->db->get ( 'accounts' ); |
|
120 | - $this->db_model->build_search ( 'package_list_search' ); |
|
121 | - if ($this->session->userdata ( 'advance_search' ) != 1) { |
|
122 | - if ($result->num_rows () > 0) { |
|
123 | - $acc_arr = array (); |
|
124 | - $result = $result->result_array (); |
|
125 | - foreach ( $result as $data ) { |
|
117 | + $this->db->where('reseller_id', $reseller_id); |
|
118 | + $this->db->select('id'); |
|
119 | + $result = $this->db->get('accounts'); |
|
120 | + $this->db_model->build_search('package_list_search'); |
|
121 | + if ($this->session->userdata('advance_search') != 1) { |
|
122 | + if ($result->num_rows() > 0) { |
|
123 | + $acc_arr = array(); |
|
124 | + $result = $result->result_array(); |
|
125 | + foreach ($result as $data) { |
|
126 | 126 | $acc_arr [] = $data ['id']; |
127 | 127 | } |
128 | - $this->db->where_in ( 'accountid', $acc_arr ); |
|
128 | + $this->db->where_in('accountid', $acc_arr); |
|
129 | 129 | if ($flag) { |
130 | - $this->db->select ( '*' ); |
|
130 | + $this->db->select('*'); |
|
131 | 131 | } else { |
132 | - $this->db->select ( 'count(id) as count' ); |
|
132 | + $this->db->select('count(id) as count'); |
|
133 | 133 | } |
134 | 134 | if ($flag) { |
135 | - $this->db->limit ( $limit, $start ); |
|
135 | + $this->db->limit($limit, $start); |
|
136 | 136 | } |
137 | - if (isset ( $_GET ['sortname'] ) && $_GET ['sortname'] != 'undefined') { |
|
138 | - $this->db->order_by ( $_GET ['sortname'], ($_GET ['sortorder'] == 'undefined') ? 'desc' : $_GET ['sortorder'] ); |
|
137 | + if (isset ($_GET ['sortname']) && $_GET ['sortname'] != 'undefined') { |
|
138 | + $this->db->order_by($_GET ['sortname'], ($_GET ['sortorder'] == 'undefined') ? 'desc' : $_GET ['sortorder']); |
|
139 | 139 | } else { |
140 | - $this->db->order_by ( 'seconds', 'desc' ); |
|
140 | + $this->db->order_by('seconds', 'desc'); |
|
141 | 141 | } |
142 | - $result = $this->db->get ( 'counters' ); |
|
142 | + $result = $this->db->get('counters'); |
|
143 | 143 | // echo $this->db->last_query();exit; |
144 | 144 | if ($flag) { |
145 | 145 | return $result; |
146 | 146 | } else { |
147 | - $result = $result->result_array (); |
|
147 | + $result = $result->result_array(); |
|
148 | 148 | return $result [0] ['count']; |
149 | 149 | } |
150 | 150 | } else { |
151 | 151 | if ($flag) { |
152 | - $query = ( object ) array ( |
|
152 | + $query = (object)array( |
|
153 | 153 | 'num_rows' => 0 |
154 | 154 | ); |
155 | 155 | } else { |
@@ -159,39 +159,39 @@ discard block |
||
159 | 159 | } |
160 | 160 | } else { |
161 | 161 | |
162 | - if ($result->num_rows () > 0) { |
|
163 | - $acc_arr = array (); |
|
164 | - $result = $result->result_array (); |
|
165 | - foreach ( $result as $data ) { |
|
162 | + if ($result->num_rows() > 0) { |
|
163 | + $acc_arr = array(); |
|
164 | + $result = $result->result_array(); |
|
165 | + foreach ($result as $data) { |
|
166 | 166 | $acc_arr [] = $data ['id']; |
167 | 167 | } |
168 | - $this->db->where_in ( 'accountid', $acc_arr ); |
|
168 | + $this->db->where_in('accountid', $acc_arr); |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | if ($flag) { |
172 | - $this->db->select ( '*' ); |
|
172 | + $this->db->select('*'); |
|
173 | 173 | } else { |
174 | - $this->db->select ( 'count(id) as count' ); |
|
174 | + $this->db->select('count(id) as count'); |
|
175 | 175 | } |
176 | 176 | if ($flag) { |
177 | - $this->db->order_by ( 'seconds', 'desc' ); |
|
178 | - $this->db->limit ( $limit, $start ); |
|
177 | + $this->db->order_by('seconds', 'desc'); |
|
178 | + $this->db->limit($limit, $start); |
|
179 | 179 | } |
180 | - $result = $this->db->get ( 'counters' ); |
|
180 | + $result = $this->db->get('counters'); |
|
181 | 181 | // echo $this->db->last_query();exit; |
182 | - if ($result->num_rows () > 0) { |
|
182 | + if ($result->num_rows() > 0) { |
|
183 | 183 | if ($flag) { |
184 | 184 | |
185 | 185 | return $result; |
186 | 186 | } else { |
187 | - $result = $result->result_array (); |
|
187 | + $result = $result->result_array(); |
|
188 | 188 | |
189 | 189 | return $result [0] ['count']; |
190 | 190 | } |
191 | 191 | } else { |
192 | 192 | if ($flag) { |
193 | 193 | |
194 | - $query = ( object ) array ( |
|
194 | + $query = (object)array( |
|
195 | 195 | 'num_rows' => 0 |
196 | 196 | ); |
197 | 197 | } else { |
@@ -205,22 +205,22 @@ discard block |
||
205 | 205 | function insert_package_pattern($data, $packageid) { |
206 | 206 | |
207 | 207 | // echo "<pre>"; prit_r($data); exit; |
208 | - $this->db->select ( "pattern,comment" ); |
|
209 | - $this->db->where ( "id IN (" . $data . ")" ); |
|
210 | - $result = $this->db->get ( "routes" )->result_array (); |
|
208 | + $this->db->select("pattern,comment"); |
|
209 | + $this->db->where("id IN (".$data.")"); |
|
210 | + $result = $this->db->get("routes")->result_array(); |
|
211 | 211 | |
212 | - $tmp = array (); |
|
213 | - foreach ( $result as $key => $data_value ) { |
|
212 | + $tmp = array(); |
|
213 | + foreach ($result as $key => $data_value) { |
|
214 | 214 | $tmp [$key] ["package_id"] = $packageid; |
215 | 215 | $tmp [$key] ["patterns"] = $data_value ['pattern']; |
216 | 216 | $tmp [$key] ["destination"] = $data_value ['comment']; |
217 | 217 | } |
218 | - return $this->db->insert_batch ( "package_patterns", $tmp ); |
|
218 | + return $this->db->insert_batch("package_patterns", $tmp); |
|
219 | 219 | } |
220 | 220 | function bulk_insert_package_pattern($inserted_array) { |
221 | 221 | // echo "<pre>";print_r($inserted_array);exit; |
222 | - $this->db->insert_batch ( 'package_patterns', $inserted_array ); |
|
223 | - $affected_row = $this->db->affected_rows (); |
|
222 | + $this->db->insert_batch('package_patterns', $inserted_array); |
|
223 | + $affected_row = $this->db->affected_rows(); |
|
224 | 224 | return $affected_row; |
225 | 225 | } |
226 | 226 | } |
@@ -54,8 +54,9 @@ |
||
54 | 54 | $where = array ( |
55 | 55 | 'pricelist_id' => $account_info ['pricelist_id'] |
56 | 56 | ); |
57 | - if (! empty ( $like_str )) |
|
58 | - $this->db->where ( $like_str ); |
|
57 | + if (! empty ( $like_str )) { |
|
58 | + $this->db->where ( $like_str ); |
|
59 | + } |
|
59 | 60 | if ($flag) { |
60 | 61 | $query = $this->db_model->select ( "*", "packages", $where, "id", "ASC", $limit, $start ); |
61 | 62 | } else { |
@@ -22,28 +22,28 @@ discard block |
||
22 | 22 | // ############################################################################## |
23 | 23 | class Package extends MX_Controller { |
24 | 24 | function Package() { |
25 | - parent::__construct (); |
|
25 | + parent::__construct(); |
|
26 | 26 | |
27 | - $this->load->helper ( 'template_inheritance' ); |
|
27 | + $this->load->helper('template_inheritance'); |
|
28 | 28 | |
29 | - $this->load->library ( 'session' ); |
|
30 | - $this->load->library ( 'package_form' ); |
|
31 | - $this->load->library ( 'astpp/form' ); |
|
32 | - $this->load->model ( 'package_model' ); |
|
33 | - $this->load->library ( 'csvreader' ); |
|
29 | + $this->load->library('session'); |
|
30 | + $this->load->library('package_form'); |
|
31 | + $this->load->library('astpp/form'); |
|
32 | + $this->load->model('package_model'); |
|
33 | + $this->load->library('csvreader'); |
|
34 | 34 | |
35 | - if ($this->session->userdata ( 'user_login' ) == FALSE) |
|
36 | - redirect ( base_url () . '/astpp/login' ); |
|
35 | + if ($this->session->userdata('user_login') == FALSE) |
|
36 | + redirect(base_url().'/astpp/login'); |
|
37 | 37 | } |
38 | 38 | function package_list() { |
39 | - $data ['username'] = $this->session->userdata ( 'user_name' ); |
|
40 | - $data ['page_title'] = gettext ( gettext ( 'Packages' ) ); |
|
39 | + $data ['username'] = $this->session->userdata('user_name'); |
|
40 | + $data ['page_title'] = gettext(gettext('Packages')); |
|
41 | 41 | $data ['search_flag'] = true; |
42 | - $this->session->set_userdata ( 'advance_search', 0 ); |
|
43 | - $data ['grid_fields'] = $this->package_form->build_package_list_for_admin (); |
|
44 | - $data ["grid_buttons"] = $this->package_form->build_grid_buttons (); |
|
45 | - $data ['form_search'] = $this->form->build_serach_form ( $this->package_form->get_package_search_form () ); |
|
46 | - $this->load->view ( 'view_package_list', $data ); |
|
42 | + $this->session->set_userdata('advance_search', 0); |
|
43 | + $data ['grid_fields'] = $this->package_form->build_package_list_for_admin(); |
|
44 | + $data ["grid_buttons"] = $this->package_form->build_grid_buttons(); |
|
45 | + $data ['form_search'] = $this->form->build_serach_form($this->package_form->get_package_search_form()); |
|
46 | + $this->load->view('view_package_list', $data); |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | /** |
@@ -51,108 +51,108 @@ discard block |
||
51 | 51 | * Listing of Accounts table data through php function json_encode |
52 | 52 | */ |
53 | 53 | function package_list_json() { |
54 | - $json_data = array (); |
|
55 | - $count_all = $this->package_model->getpackage_list ( false ); |
|
56 | - $paging_data = $this->form->load_grid_config ( $count_all, $_GET ['rp'], $_GET ['page'] ); |
|
54 | + $json_data = array(); |
|
55 | + $count_all = $this->package_model->getpackage_list(false); |
|
56 | + $paging_data = $this->form->load_grid_config($count_all, $_GET ['rp'], $_GET ['page']); |
|
57 | 57 | $json_data = $paging_data ["json_paging"]; |
58 | 58 | |
59 | - $query = $this->package_model->getpackage_list ( true, $paging_data ["paging"] ["start"], $paging_data ["paging"] ["page_no"] ); |
|
60 | - $grid_fields = json_decode ( $this->package_form->build_package_list_for_admin () ); |
|
61 | - $json_data ['rows'] = $this->form->build_grid ( $query, $grid_fields ); |
|
59 | + $query = $this->package_model->getpackage_list(true, $paging_data ["paging"] ["start"], $paging_data ["paging"] ["page_no"]); |
|
60 | + $grid_fields = json_decode($this->package_form->build_package_list_for_admin()); |
|
61 | + $json_data ['rows'] = $this->form->build_grid($query, $grid_fields); |
|
62 | 62 | |
63 | - echo json_encode ( $json_data ); |
|
63 | + echo json_encode($json_data); |
|
64 | 64 | } |
65 | 65 | function package_list_reseller($accountid, $accounttype) { |
66 | - $json_data = array (); |
|
67 | - $count_all = $this->package_model->get_reseller_package_list ( false, $accountid, $accounttype ); |
|
68 | - $paging_data = $this->form->load_grid_config ( $count_all, $_GET ['rp'], $_GET ['page'] ); |
|
66 | + $json_data = array(); |
|
67 | + $count_all = $this->package_model->get_reseller_package_list(false, $accountid, $accounttype); |
|
68 | + $paging_data = $this->form->load_grid_config($count_all, $_GET ['rp'], $_GET ['page']); |
|
69 | 69 | $json_data = $paging_data ["json_paging"]; |
70 | - $query = $this->package_model->get_reseller_package_list ( true, $accountid, $accounttype, $paging_data ["paging"] ["start"], $paging_data ["paging"] ["page_no"] ); |
|
71 | - $grid_fields = json_decode ( $this->package_form->build_package_list_for_reseller () ); |
|
72 | - $json_data ['rows'] = $this->form->build_grid ( $query, $grid_fields ); |
|
73 | - echo json_encode ( $json_data ); |
|
70 | + $query = $this->package_model->get_reseller_package_list(true, $accountid, $accounttype, $paging_data ["paging"] ["start"], $paging_data ["paging"] ["page_no"]); |
|
71 | + $grid_fields = json_decode($this->package_form->build_package_list_for_reseller()); |
|
72 | + $json_data ['rows'] = $this->form->build_grid($query, $grid_fields); |
|
73 | + echo json_encode($json_data); |
|
74 | 74 | } |
75 | 75 | function package_list_search() { |
76 | - $ajax_search = $this->input->post ( 'ajax_search', 0 ); |
|
76 | + $ajax_search = $this->input->post('ajax_search', 0); |
|
77 | 77 | |
78 | - if ($this->input->post ( 'advance_search', TRUE ) == 1) { |
|
79 | - $this->session->set_userdata ( 'advance_search', $this->input->post ( 'advance_search' ) ); |
|
80 | - $action = $this->input->post (); |
|
81 | - unset ( $action ['action'] ); |
|
82 | - unset ( $action ['advance_search'] ); |
|
83 | - $this->session->set_userdata ( 'package_list_search', $action ); |
|
78 | + if ($this->input->post('advance_search', TRUE) == 1) { |
|
79 | + $this->session->set_userdata('advance_search', $this->input->post('advance_search')); |
|
80 | + $action = $this->input->post(); |
|
81 | + unset ($action ['action']); |
|
82 | + unset ($action ['advance_search']); |
|
83 | + $this->session->set_userdata('package_list_search', $action); |
|
84 | 84 | } |
85 | 85 | if (@$ajax_search != 1) { |
86 | - redirect ( base_url () . 'package/package_list/' ); |
|
86 | + redirect(base_url().'package/package_list/'); |
|
87 | 87 | } |
88 | 88 | } |
89 | 89 | function package_list_clearsearchfilter() { |
90 | - $this->session->set_userdata ( 'advance_search', 0 ); |
|
91 | - $this->session->set_userdata ( 'package_list_search', "" ); |
|
90 | + $this->session->set_userdata('advance_search', 0); |
|
91 | + $this->session->set_userdata('package_list_search', ""); |
|
92 | 92 | } |
93 | 93 | function package_add($type = "") { |
94 | - $data ['page_title'] = gettext ( 'Create Package' ); |
|
95 | - $data ['form'] = $this->form->build_form ( $this->package_form->get_package_form_fields (), '' ); |
|
96 | - $this->load->view ( 'view_package_add', $data ); |
|
94 | + $data ['page_title'] = gettext('Create Package'); |
|
95 | + $data ['form'] = $this->form->build_form($this->package_form->get_package_form_fields(), ''); |
|
96 | + $this->load->view('view_package_add', $data); |
|
97 | 97 | } |
98 | 98 | function package_edit($edit_id = '') { |
99 | - $data ['page_title'] = gettext ( 'Package Details' ); |
|
100 | - $accountinfo = $this->session->userdata ( "accountinfo" ); |
|
99 | + $data ['page_title'] = gettext('Package Details'); |
|
100 | + $accountinfo = $this->session->userdata("accountinfo"); |
|
101 | 101 | $reseller_id = $accountinfo ['type'] == 1 ? $accountinfo ['id'] : 0; |
102 | - $package_result = $this->db_model->getSelect ( "*", " packages", array ( |
|
102 | + $package_result = $this->db_model->getSelect("*", " packages", array( |
|
103 | 103 | 'id' => $edit_id, |
104 | 104 | "reseller_id" => $reseller_id |
105 | - ) ); |
|
105 | + )); |
|
106 | 106 | if ($package_result->num_rows > 0) { |
107 | - $package_info = ( array ) $package_result->first_row (); |
|
108 | - $data ['form'] = $this->form->build_form ( $this->package_form->get_package_form_fields ( $package_info ['id'] ), $package_info ); |
|
107 | + $package_info = (array)$package_result->first_row(); |
|
108 | + $data ['form'] = $this->form->build_form($this->package_form->get_package_form_fields($package_info ['id']), $package_info); |
|
109 | 109 | $data ['edit_id'] = $package_info ['id']; |
110 | - $this->load->view ( 'view_packages_edit', $data ); |
|
110 | + $this->load->view('view_packages_edit', $data); |
|
111 | 111 | } else { |
112 | - redirect ( base_url () . 'package/package_list/' ); |
|
112 | + redirect(base_url().'package/package_list/'); |
|
113 | 113 | } |
114 | 114 | } |
115 | 115 | function package_save($id = "") { |
116 | - $add_array = $this->input->post (); |
|
117 | - $data ['form'] = $this->form->build_form ( $this->package_form->get_package_form_fields ( $add_array ['id'] ), $add_array ); |
|
116 | + $add_array = $this->input->post(); |
|
117 | + $data ['form'] = $this->form->build_form($this->package_form->get_package_form_fields($add_array ['id']), $add_array); |
|
118 | 118 | if ($add_array ['id'] != '') { |
119 | - if ($this->form_validation->run () == FALSE) { |
|
119 | + if ($this->form_validation->run() == FALSE) { |
|
120 | 120 | $data ['edit_id'] = $add_array ['id']; |
121 | - $data ['validation_errors'] = validation_errors (); |
|
122 | - $this->load->view ( 'view_packages_edit', $data ); |
|
121 | + $data ['validation_errors'] = validation_errors(); |
|
122 | + $this->load->view('view_packages_edit', $data); |
|
123 | 123 | } else { |
124 | - $this->package_model->edit_package ( $add_array, $add_array ['id'] ); |
|
125 | - $this->session->set_flashdata ( 'astpp_errormsg', 'Package updated successfully!' ); |
|
126 | - redirect ( base_url () . 'package/package_list/' ); |
|
124 | + $this->package_model->edit_package($add_array, $add_array ['id']); |
|
125 | + $this->session->set_flashdata('astpp_errormsg', 'Package updated successfully!'); |
|
126 | + redirect(base_url().'package/package_list/'); |
|
127 | 127 | exit (); |
128 | 128 | } |
129 | 129 | } else { |
130 | - $data ['page_title'] = gettext ( 'Create Package' ); |
|
131 | - if ($this->form_validation->run () == FALSE) { |
|
132 | - $data ['validation_errors'] = validation_errors (); |
|
133 | - $this->load->view ( 'view_package_add', $data ); |
|
130 | + $data ['page_title'] = gettext('Create Package'); |
|
131 | + if ($this->form_validation->run() == FALSE) { |
|
132 | + $data ['validation_errors'] = validation_errors(); |
|
133 | + $this->load->view('view_package_add', $data); |
|
134 | 134 | } else { |
135 | 135 | |
136 | - $this->package_model->add_package ( $add_array ); |
|
136 | + $this->package_model->add_package($add_array); |
|
137 | 137 | /** |
138 | 138 | * ASTPP 3.0 |
139 | 139 | * For Email Broadcast when package is add |
140 | 140 | * * |
141 | 141 | */ |
142 | - $accountinfo = $this->db_model->getSelect ( "*", "accounts", array ( |
|
142 | + $accountinfo = $this->db_model->getSelect("*", "accounts", array( |
|
143 | 143 | "pricelist_id" => $add_array ['pricelist_id'], |
144 | 144 | "status" => 0, |
145 | 145 | "deleted" => 0 |
146 | - ) ); |
|
147 | - $accountinfo = $accountinfo->result_array (); |
|
148 | - $this->session->set_flashdata ( 'astpp_errormsg', 'Package added successfully!' ); |
|
149 | - foreach ( $accountinfo as $key => $value ) { |
|
150 | - $this->common->mail_to_users ( 'add_package', $value ); |
|
146 | + )); |
|
147 | + $accountinfo = $accountinfo->result_array(); |
|
148 | + $this->session->set_flashdata('astpp_errormsg', 'Package added successfully!'); |
|
149 | + foreach ($accountinfo as $key => $value) { |
|
150 | + $this->common->mail_to_users('add_package', $value); |
|
151 | 151 | } |
152 | 152 | /** |
153 | 153 | * *********************************** |
154 | 154 | */ |
155 | - redirect ( base_url () . 'package/package_list/' ); |
|
155 | + redirect(base_url().'package/package_list/'); |
|
156 | 156 | exit (); |
157 | 157 | } |
158 | 158 | } |
@@ -163,70 +163,70 @@ discard block |
||
163 | 163 | * For Email Broadcast when package is add |
164 | 164 | * * |
165 | 165 | */ |
166 | - $package_detail = $this->db_model->getSelect ( "*", "packages", array ( |
|
166 | + $package_detail = $this->db_model->getSelect("*", "packages", array( |
|
167 | 167 | "id" => $id |
168 | - ) ); |
|
169 | - $package_detail = $package_detail->result_array (); |
|
168 | + )); |
|
169 | + $package_detail = $package_detail->result_array(); |
|
170 | 170 | $package_detail = $package_detail [0]; |
171 | - $accountinfo = $this->db_model->getSelect ( "*", "accounts", array ( |
|
171 | + $accountinfo = $this->db_model->getSelect("*", "accounts", array( |
|
172 | 172 | "pricelist_id" => $package_detail ['pricelist_id'], |
173 | 173 | "status" => 0, |
174 | 174 | "deleted" => 0 |
175 | - ) ); |
|
176 | - $this->package_model->remove_package ( $id ); |
|
177 | - $this->session->set_flashdata ( 'astpp_notification', 'Package removed successfully!' ); |
|
178 | - foreach ( $accountinfo->result_array () as $key => $value ) { |
|
179 | - $this->common->mail_to_users ( 'remove_package', $value ); |
|
175 | + )); |
|
176 | + $this->package_model->remove_package($id); |
|
177 | + $this->session->set_flashdata('astpp_notification', 'Package removed successfully!'); |
|
178 | + foreach ($accountinfo->result_array() as $key => $value) { |
|
179 | + $this->common->mail_to_users('remove_package', $value); |
|
180 | 180 | } |
181 | 181 | /** |
182 | 182 | * *************************************** |
183 | 183 | */ |
184 | - redirect ( base_url () . 'package/package_list/' ); |
|
184 | + redirect(base_url().'package/package_list/'); |
|
185 | 185 | } |
186 | 186 | function package_delete_multiple() { |
187 | - $ids = $this->input->post ( "selected_ids", true ); |
|
187 | + $ids = $this->input->post("selected_ids", true); |
|
188 | 188 | $where = "id IN ($ids)"; |
189 | - $this->db->where ( $where ); |
|
190 | - echo $this->db->delete ( "packages" ); |
|
189 | + $this->db->where($where); |
|
190 | + echo $this->db->delete("packages"); |
|
191 | 191 | } |
192 | 192 | function package_pattern_list($package_id) { |
193 | - $data ['page_title'] = gettext ( 'Package Codes' ); |
|
194 | - if (! empty ( $package_id )) { |
|
195 | - $data ['grid_fields'] = $this->package_form->build_pattern_list_for_customer ( $package_id ); |
|
196 | - $data ['grid_buttons'] = $this->package_form->set_pattern_grid_buttons ( $package_id ); |
|
193 | + $data ['page_title'] = gettext('Package Codes'); |
|
194 | + if ( ! empty ($package_id)) { |
|
195 | + $data ['grid_fields'] = $this->package_form->build_pattern_list_for_customer($package_id); |
|
196 | + $data ['grid_buttons'] = $this->package_form->set_pattern_grid_buttons($package_id); |
|
197 | 197 | $data ["edit_id"] = $package_id; |
198 | - $this->load->view ( "view_package_pattern_list", $data ); |
|
198 | + $this->load->view("view_package_pattern_list", $data); |
|
199 | 199 | } else { |
200 | - redirect ( base_url () . "package/package_list/" ); |
|
200 | + redirect(base_url()."package/package_list/"); |
|
201 | 201 | } |
202 | 202 | } |
203 | 203 | function package_pattern_list_json($package_id) { |
204 | - $json_data = array (); |
|
205 | - $instant_search = $this->session->userdata ( 'left_panel_search_package_pattern' ); |
|
206 | - $like_str = ! empty ( $instant_search ) ? "(patterns like '%$instant_search%' OR destination like '%$instant_search%' )" : null; |
|
207 | - if (! empty ( $like_str )) |
|
208 | - $this->db->where ( $like_str ); |
|
209 | - $where = array ( |
|
204 | + $json_data = array(); |
|
205 | + $instant_search = $this->session->userdata('left_panel_search_package_pattern'); |
|
206 | + $like_str = ! empty ($instant_search) ? "(patterns like '%$instant_search%' OR destination like '%$instant_search%' )" : null; |
|
207 | + if ( ! empty ($like_str)) |
|
208 | + $this->db->where($like_str); |
|
209 | + $where = array( |
|
210 | 210 | 'package_id' => $package_id |
211 | 211 | ); |
212 | - $count_all = $this->db_model->countQuery ( "*", "package_patterns", $where ); |
|
213 | - $paging_data = $this->form->load_grid_config ( $count_all, $_GET ['rp'], $_GET ['page'] ); |
|
212 | + $count_all = $this->db_model->countQuery("*", "package_patterns", $where); |
|
213 | + $paging_data = $this->form->load_grid_config($count_all, $_GET ['rp'], $_GET ['page']); |
|
214 | 214 | $json_data = $paging_data ["json_paging"]; |
215 | - if (! empty ( $like_str )) |
|
216 | - $this->db->where ( $like_str ); |
|
217 | - $pattern_data = $this->db_model->select ( "*", "package_patterns", $where, "id", "ASC", $paging_data ["paging"] ["page_no"], $paging_data ["paging"] ["start"] ); |
|
215 | + if ( ! empty ($like_str)) |
|
216 | + $this->db->where($like_str); |
|
217 | + $pattern_data = $this->db_model->select("*", "package_patterns", $where, "id", "ASC", $paging_data ["paging"] ["page_no"], $paging_data ["paging"] ["start"]); |
|
218 | 218 | |
219 | - $grid_fields = json_decode ( $this->package_form->build_pattern_list_for_customer ( $package_id ) ); |
|
220 | - $json_data ['rows'] = $this->form->build_grid ( $pattern_data, $grid_fields ); |
|
219 | + $grid_fields = json_decode($this->package_form->build_pattern_list_for_customer($package_id)); |
|
220 | + $json_data ['rows'] = $this->form->build_grid($pattern_data, $grid_fields); |
|
221 | 221 | |
222 | - echo json_encode ( $json_data ); |
|
222 | + echo json_encode($json_data); |
|
223 | 223 | } |
224 | 224 | function package_counter() { |
225 | - $data ['username'] = $this->session->userdata ( 'user_name' ); |
|
226 | - $data ['page_title'] = gettext ( 'Usage Report' ); |
|
227 | - $data ['grid_fields'] = $this->package_form->build_package_counter_list_for_admin (); |
|
228 | - $data ["grid_buttons"] = $this->package_form->build_package_counter_report (); |
|
229 | - $this->load->view ( 'view_package_counter_report', $data ); |
|
225 | + $data ['username'] = $this->session->userdata('user_name'); |
|
226 | + $data ['page_title'] = gettext('Usage Report'); |
|
227 | + $data ['grid_fields'] = $this->package_form->build_package_counter_list_for_admin(); |
|
228 | + $data ["grid_buttons"] = $this->package_form->build_package_counter_report(); |
|
229 | + $this->load->view('view_package_counter_report', $data); |
|
230 | 230 | } |
231 | 231 | |
232 | 232 | /** |
@@ -234,162 +234,162 @@ discard block |
||
234 | 234 | * Listing of Accounts table data through php function json_encode |
235 | 235 | */ |
236 | 236 | function package_counter_json() { |
237 | - $json_data = array (); |
|
238 | - $count_all = $this->package_model->getpackage_counter_list ( false ); |
|
239 | - $paging_data = $this->form->load_grid_config ( $count_all, $_GET ['rp'], $_GET ['page'] ); |
|
237 | + $json_data = array(); |
|
238 | + $count_all = $this->package_model->getpackage_counter_list(false); |
|
239 | + $paging_data = $this->form->load_grid_config($count_all, $_GET ['rp'], $_GET ['page']); |
|
240 | 240 | $json_data = $paging_data ["json_paging"]; |
241 | 241 | |
242 | - $query = $this->package_model->getpackage_counter_list ( true, $paging_data ["paging"] ["start"], $paging_data ["paging"] ["page_no"] ); |
|
243 | - $grid_fields = json_decode ( $this->package_form->build_package_counter_list_for_admin () ); |
|
244 | - $json_data ['rows'] = $this->form->build_grid ( $query, $grid_fields ); |
|
242 | + $query = $this->package_model->getpackage_counter_list(true, $paging_data ["paging"] ["start"], $paging_data ["paging"] ["page_no"]); |
|
243 | + $grid_fields = json_decode($this->package_form->build_package_counter_list_for_admin()); |
|
244 | + $json_data ['rows'] = $this->form->build_grid($query, $grid_fields); |
|
245 | 245 | |
246 | - echo json_encode ( $json_data ); |
|
246 | + echo json_encode($json_data); |
|
247 | 247 | } |
248 | 248 | function package_counter_report_export() { |
249 | - $query = $this->db_model->getSelect ( "*", "counters", '' ); |
|
250 | - $outbound_array = array (); |
|
251 | - ob_clean (); |
|
252 | - $outbound_array [] = array ( |
|
253 | - gettext ( "Package Name" ), |
|
254 | - gettext ( "Account" ), |
|
255 | - gettext ( "Used Seconds" ) |
|
249 | + $query = $this->db_model->getSelect("*", "counters", ''); |
|
250 | + $outbound_array = array(); |
|
251 | + ob_clean(); |
|
252 | + $outbound_array [] = array( |
|
253 | + gettext("Package Name"), |
|
254 | + gettext("Account"), |
|
255 | + gettext("Used Seconds") |
|
256 | 256 | ); |
257 | - if ($query->num_rows () > 0) { |
|
257 | + if ($query->num_rows() > 0) { |
|
258 | 258 | |
259 | - foreach ( $query->result_array () as $row ) { |
|
260 | - $outbound_array [] = array ( |
|
261 | - $this->common->get_field_name ( 'package_name', 'packages', $row ['package_id'] ), |
|
262 | - $this->common->get_field_name_coma_new ( 'first_name,last_name,number', 'accounts', $row ['accountid'] ), |
|
259 | + foreach ($query->result_array() as $row) { |
|
260 | + $outbound_array [] = array( |
|
261 | + $this->common->get_field_name('package_name', 'packages', $row ['package_id']), |
|
262 | + $this->common->get_field_name_coma_new('first_name,last_name,number', 'accounts', $row ['accountid']), |
|
263 | 263 | $row ['seconds'] |
264 | 264 | ); |
265 | 265 | } |
266 | 266 | } |
267 | - $this->load->helper ( 'csv' ); |
|
268 | - array_to_csv ( $outbound_array, 'Usage_Report_' . date ( "Y-m-d" ) . '.csv' ); |
|
267 | + $this->load->helper('csv'); |
|
268 | + array_to_csv($outbound_array, 'Usage_Report_'.date("Y-m-d").'.csv'); |
|
269 | 269 | } |
270 | 270 | function package_pattern_json($package_id) { |
271 | - $json_data = array (); |
|
272 | - $where = array ( |
|
271 | + $json_data = array(); |
|
272 | + $where = array( |
|
273 | 273 | 'package_id' => $package_id |
274 | 274 | ); |
275 | 275 | |
276 | - $count_all = $this->db_model->countQuery ( "*", "package_patterns", $where ); |
|
277 | - $paging_data = $this->form->load_grid_config ( $count_all, $_GET ['rp'], $_GET ['page'] ); |
|
276 | + $count_all = $this->db_model->countQuery("*", "package_patterns", $where); |
|
277 | + $paging_data = $this->form->load_grid_config($count_all, $_GET ['rp'], $_GET ['page']); |
|
278 | 278 | $json_data = $paging_data ["json_paging"]; |
279 | 279 | |
280 | - $pattern_data = $this->db_model->select ( "*", "package_patterns", $where, "id", "ASC", $paging_data ["paging"] ["page_no"], $paging_data ["paging"] ["start"] ); |
|
281 | - $grid_fields = json_decode ( $this->package_form->build_pattern_list_for_customer ( $package_id ) ); |
|
282 | - $json_data ['rows'] = $this->form->build_grid ( $pattern_data, $grid_fields ); |
|
280 | + $pattern_data = $this->db_model->select("*", "package_patterns", $where, "id", "ASC", $paging_data ["paging"] ["page_no"], $paging_data ["paging"] ["start"]); |
|
281 | + $grid_fields = json_decode($this->package_form->build_pattern_list_for_customer($package_id)); |
|
282 | + $json_data ['rows'] = $this->form->build_grid($pattern_data, $grid_fields); |
|
283 | 283 | |
284 | - echo json_encode ( $json_data ); |
|
284 | + echo json_encode($json_data); |
|
285 | 285 | } |
286 | 286 | function package_patterns_add($packageid) { |
287 | - $data ['username'] = $this->session->userdata ( 'user_name' ); |
|
288 | - $data ['page_title'] = gettext ( 'Unblocked Prefixes' ); |
|
289 | - $this->session->set_userdata ( 'advance_search', 0 ); |
|
290 | - $this->load->module ( 'rates/rates' ); |
|
291 | - $data ['patters_grid_fields'] = $this->rates->rates_form->build_block_pattern_list_for_customer (); |
|
287 | + $data ['username'] = $this->session->userdata('user_name'); |
|
288 | + $data ['page_title'] = gettext('Unblocked Prefixes'); |
|
289 | + $this->session->set_userdata('advance_search', 0); |
|
290 | + $this->load->module('rates/rates'); |
|
291 | + $data ['patters_grid_fields'] = $this->rates->rates_form->build_block_pattern_list_for_customer(); |
|
292 | 292 | $data ["packageid"] = $packageid; |
293 | - $this->load->view ( 'view_prefix_list', $data ); |
|
293 | + $this->load->view('view_prefix_list', $data); |
|
294 | 294 | } |
295 | 295 | function package_patterns_add_json($accountid) { |
296 | - $this->load->module ( 'rates/rates' ); |
|
297 | - $json_data = array (); |
|
298 | - $count_all = $this->rates_model->getunblocked_package_pattern ( $accountid, false ); |
|
299 | - $paging_data = $this->form->load_grid_config ( $count_all, $_GET ['rp'], $_GET ['page'] ); |
|
296 | + $this->load->module('rates/rates'); |
|
297 | + $json_data = array(); |
|
298 | + $count_all = $this->rates_model->getunblocked_package_pattern($accountid, false); |
|
299 | + $paging_data = $this->form->load_grid_config($count_all, $_GET ['rp'], $_GET ['page']); |
|
300 | 300 | $json_data = $paging_data ["json_paging"]; |
301 | 301 | |
302 | - $query = $this->rates->rates_model->getunblocked_package_pattern ( $accountid, true, $paging_data ["paging"] ["start"], $paging_data ["paging"] ["page_no"] ); |
|
303 | - $grid_fields = json_decode ( $this->rates->rates_form->build_block_pattern_list_for_customer () ); |
|
304 | - $json_data ['rows'] = $this->rates->form->build_grid ( $query, $grid_fields ); |
|
302 | + $query = $this->rates->rates_model->getunblocked_package_pattern($accountid, true, $paging_data ["paging"] ["start"], $paging_data ["paging"] ["page_no"]); |
|
303 | + $grid_fields = json_decode($this->rates->rates_form->build_block_pattern_list_for_customer()); |
|
304 | + $json_data ['rows'] = $this->rates->form->build_grid($query, $grid_fields); |
|
305 | 305 | |
306 | - echo json_encode ( $json_data ); |
|
306 | + echo json_encode($json_data); |
|
307 | 307 | } |
308 | 308 | function package_patterns_add_info($packageid) { |
309 | - $result = $this->package_model->insert_package_pattern ( $this->input->post ( 'prefixies', true ), $packageid ); |
|
310 | - unset ( $_POST ); |
|
309 | + $result = $this->package_model->insert_package_pattern($this->input->post('prefixies', true), $packageid); |
|
310 | + unset ($_POST); |
|
311 | 311 | echo $result; |
312 | 312 | exit (); |
313 | 313 | } |
314 | 314 | function package_patterns_delete($packageid, $patternid) { |
315 | - $this->db->delete ( "package_patterns", array ( |
|
315 | + $this->db->delete("package_patterns", array( |
|
316 | 316 | "id" => $patternid |
317 | - ) ); |
|
318 | - redirect ( base_url () . "package/package_pattern_list/$packageid" ); |
|
317 | + )); |
|
318 | + redirect(base_url()."package/package_pattern_list/$packageid"); |
|
319 | 319 | } |
320 | 320 | function package_patterns_selected_delete() { |
321 | - $ids = $this->input->post ( "selected_ids", true ); |
|
321 | + $ids = $this->input->post("selected_ids", true); |
|
322 | 322 | $where = "id IN ($ids)"; |
323 | - unset ( $_POST ); |
|
324 | - echo $this->db->delete ( "package_patterns", $where ); |
|
323 | + unset ($_POST); |
|
324 | + echo $this->db->delete("package_patterns", $where); |
|
325 | 325 | } |
326 | 326 | function package_quick_search($module_name) { |
327 | - $action = $this->input->post (); |
|
328 | - $this->session->set_userdata ( 'left_panel_search_package_pattern', "" ); |
|
329 | - if (! empty ( $action ['left_panel_search'] )) { |
|
330 | - $this->session->set_userdata ( 'left_panel_search_package_pattern', $action ['left_panel_search'] ); |
|
327 | + $action = $this->input->post(); |
|
328 | + $this->session->set_userdata('left_panel_search_package_pattern', ""); |
|
329 | + if ( ! empty ($action ['left_panel_search'])) { |
|
330 | + $this->session->set_userdata('left_panel_search_package_pattern', $action ['left_panel_search']); |
|
331 | 331 | } |
332 | 332 | } |
333 | 333 | function package_patterns_import($edit_id) { |
334 | 334 | // echo "nick";exit; |
335 | - $data ['page_title'] = gettext ( 'Import Package Patterns' ); |
|
336 | - $this->session->set_userdata ( 'import_package_code_csv', "" ); |
|
337 | - $error_data = $this->session->userdata ( 'import_package_code_csv_error' ); |
|
338 | - $full_path = $this->config->item ( 'rates-file-path' ); |
|
339 | - if (file_exists ( $full_path . $error_data ) && $error_data != "") { |
|
340 | - unlink ( $full_path . $error_data ); |
|
341 | - $this->session->set_userdata ( 'import_package_code_csv_error', "" ); |
|
335 | + $data ['page_title'] = gettext('Import Package Patterns'); |
|
336 | + $this->session->set_userdata('import_package_code_csv', ""); |
|
337 | + $error_data = $this->session->userdata('import_package_code_csv_error'); |
|
338 | + $full_path = $this->config->item('rates-file-path'); |
|
339 | + if (file_exists($full_path.$error_data) && $error_data != "") { |
|
340 | + unlink($full_path.$error_data); |
|
341 | + $this->session->set_userdata('import_package_code_csv_error', ""); |
|
342 | 342 | } |
343 | 343 | $data ['edit_id'] = $edit_id; |
344 | - $this->load->view ( 'view_import_package_code', $data ); |
|
344 | + $this->load->view('view_import_package_code', $data); |
|
345 | 345 | } |
346 | 346 | function package_patterns_download_sample_file($file_name) { |
347 | - $this->load->helper ( 'download' ); |
|
348 | - $full_path = base_url () . "assets/Rates_File/" . $file_name . ".csv"; |
|
349 | - $arrContextOptions = array ( |
|
350 | - "ssl" => array ( |
|
347 | + $this->load->helper('download'); |
|
348 | + $full_path = base_url()."assets/Rates_File/".$file_name.".csv"; |
|
349 | + $arrContextOptions = array( |
|
350 | + "ssl" => array( |
|
351 | 351 | "verify_peer" => false, |
352 | 352 | "verify_peer_name" => false |
353 | 353 | ) |
354 | 354 | ); |
355 | - $file = file_get_contents ( $full_path, false, stream_context_create ( $arrContextOptions ) ); |
|
356 | - force_download ( "samplefile.csv", $file ); |
|
355 | + $file = file_get_contents($full_path, false, stream_context_create($arrContextOptions)); |
|
356 | + force_download("samplefile.csv", $file); |
|
357 | 357 | } |
358 | 358 | function package_patterns_preview_file($edit_id) { |
359 | 359 | $invalid_flag = false; |
360 | - $data = array (); |
|
361 | - $data ['page_title'] = gettext ( 'Import Package Patterns' ); |
|
362 | - $check_header = $this->input->post ( 'check_header', true ); |
|
363 | - if (empty ( $_FILES ) || ! isset ( $_FILES )) { |
|
364 | - redirect ( base_url () . "package/package_pattern_list/" ); |
|
360 | + $data = array(); |
|
361 | + $data ['page_title'] = gettext('Import Package Patterns'); |
|
362 | + $check_header = $this->input->post('check_header', true); |
|
363 | + if (empty ($_FILES) || ! isset ($_FILES)) { |
|
364 | + redirect(base_url()."package/package_pattern_list/"); |
|
365 | 365 | } |
366 | - $get_extension = strpos ( $_FILES ['package_code_import'] ['name'], '.' ); |
|
367 | - $new_final_arr_key = $this->config->item ( 'package-code-field' ); |
|
368 | - if (! $get_extension) { |
|
366 | + $get_extension = strpos($_FILES ['package_code_import'] ['name'], '.'); |
|
367 | + $new_final_arr_key = $this->config->item('package-code-field'); |
|
368 | + if ( ! $get_extension) { |
|
369 | 369 | $data ['error'] = "Please Upload File Atleast"; |
370 | 370 | } |
371 | 371 | // echo "<pre>";print_r($_FILES);exit; |
372 | - if (isset ( $_FILES ['package_code_import'] ['name'] ) && $_FILES ['package_code_import'] ['name'] != "") { |
|
373 | - list ( $txt, $ext ) = explode ( ".", $_FILES ['package_code_import'] ['name'] ); |
|
372 | + if (isset ($_FILES ['package_code_import'] ['name']) && $_FILES ['package_code_import'] ['name'] != "") { |
|
373 | + list ($txt, $ext) = explode(".", $_FILES ['package_code_import'] ['name']); |
|
374 | 374 | |
375 | 375 | if ($ext == "csv" && $_FILES ['package_code_import'] ['size'] > 0) { |
376 | 376 | $error = $_FILES ['package_code_import'] ['error']; |
377 | 377 | if ($error == 0) { |
378 | 378 | $uploadedFile = $_FILES ["package_code_import"] ["tmp_name"]; |
379 | - $csv_data = $this->csvreader->parse_file ( $uploadedFile, $new_final_arr_key, $check_header ); |
|
380 | - if (! empty ( $csv_data )) { |
|
381 | - $full_path = $this->config->item ( 'rates-file-path' ); |
|
379 | + $csv_data = $this->csvreader->parse_file($uploadedFile, $new_final_arr_key, $check_header); |
|
380 | + if ( ! empty ($csv_data)) { |
|
381 | + $full_path = $this->config->item('rates-file-path'); |
|
382 | 382 | // echo "<pre>";print_r($full_path);exit; |
383 | - $actual_file_name = "ASTPP-ORIGIN-RATES-" . date ( "Y-m-d H:i:s" ) . "." . $ext; |
|
383 | + $actual_file_name = "ASTPP-ORIGIN-RATES-".date("Y-m-d H:i:s").".".$ext; |
|
384 | 384 | // echo "<pre>";print_r($actual_file_name);exit; |
385 | - if (move_uploaded_file ( $uploadedFile, $full_path . $actual_file_name )) { |
|
385 | + if (move_uploaded_file($uploadedFile, $full_path.$actual_file_name)) { |
|
386 | 386 | $flag = false; |
387 | 387 | // $data['trunkid']=isset($_POST['trunk_id']) && $_POST['trunk_id'] > 0 ? $_POST['trunk_id'] : 0; |
388 | 388 | $data ['csv_tmp_data'] = $csv_data; |
389 | 389 | // $data['pricelistid'] = $_POST['pricelist_id']; |
390 | - $data ['page_title'] = gettext ( "Package Patterns Preview" ); |
|
390 | + $data ['page_title'] = gettext("Package Patterns Preview"); |
|
391 | 391 | $data ['check_header'] = $check_header; |
392 | - $this->session->set_userdata ( 'import_package_code_csv', $actual_file_name ); |
|
392 | + $this->session->set_userdata('import_package_code_csv', $actual_file_name); |
|
393 | 393 | } else { |
394 | 394 | $data ['error'] = "File Uploading Fail Please Try Again"; |
395 | 395 | } |
@@ -405,49 +405,49 @@ discard block |
||
405 | 405 | } |
406 | 406 | if ($invalid_flag) { |
407 | 407 | $str = ''; |
408 | - if (empty ( $_FILES ['package_code_import'] ['name'] )) { |
|
408 | + if (empty ($_FILES ['package_code_import'] ['name'])) { |
|
409 | 409 | $str .= '<br/>Please Select File.'; |
410 | 410 | } |
411 | 411 | $data ['error'] = $str; |
412 | 412 | } |
413 | 413 | $data ['edit_id'] = $edit_id; |
414 | - $this->load->view ( 'view_import_package_code', $data ); |
|
414 | + $this->load->view('view_import_package_code', $data); |
|
415 | 415 | } |
416 | 416 | function package_patterns_import_file($edit_id, $check_header = false) { |
417 | 417 | // echo $edit_id."===="; exit; |
418 | - $new_final_arr = array (); |
|
419 | - $invalid_array = array (); |
|
420 | - $new_final_arr_key = $this->config->item ( 'package-code-field' ); |
|
421 | - $screen_path = $this->config->item ( 'screen_path' ); |
|
418 | + $new_final_arr = array(); |
|
419 | + $invalid_array = array(); |
|
420 | + $new_final_arr_key = $this->config->item('package-code-field'); |
|
421 | + $screen_path = $this->config->item('screen_path'); |
|
422 | 422 | $reseller_id = 0; |
423 | - if ($this->session->userdata ( 'logintype' ) == 1 || $this->session->userdata ( 'logintype' ) == 5) { |
|
423 | + if ($this->session->userdata('logintype') == 1 || $this->session->userdata('logintype') == 5) { |
|
424 | 424 | $reseller_id = $this->session->userdata ["accountinfo"] ['id']; |
425 | 425 | } |
426 | 426 | |
427 | - $full_path = $this->config->item ( 'rates-file-path' ); |
|
427 | + $full_path = $this->config->item('rates-file-path'); |
|
428 | 428 | // echo "<pre>";print_r($full_path);exit; |
429 | - $originationrate_file_name = $this->session->userdata ( 'import_package_code_csv' ); |
|
430 | - $csv_tmp_data = $this->csvreader->parse_file ( $full_path . $originationrate_file_name, $new_final_arr_key, $check_header ); |
|
429 | + $originationrate_file_name = $this->session->userdata('import_package_code_csv'); |
|
430 | + $csv_tmp_data = $this->csvreader->parse_file($full_path.$originationrate_file_name, $new_final_arr_key, $check_header); |
|
431 | 431 | // echo "<pre>";print_r($csv_tmp_data);exit; |
432 | 432 | $i = 0; |
433 | - $pattern_arr = array (); |
|
434 | - foreach ( $csv_tmp_data as $key => $csv_data ) { |
|
435 | - if (isset ( $csv_data ['patterns'] ) && $csv_data ['patterns'] != '' && $i != 0) { |
|
433 | + $pattern_arr = array(); |
|
434 | + foreach ($csv_tmp_data as $key => $csv_data) { |
|
435 | + if (isset ($csv_data ['patterns']) && $csv_data ['patterns'] != '' && $i != 0) { |
|
436 | 436 | $str = null; |
437 | 437 | $pattern = $csv_data ['patterns']; |
438 | - if (! in_array ( $csv_data ['patterns'], $pattern_arr )) { |
|
439 | - $this->db->select ( 'count(id) as count' ); |
|
440 | - $this->db->where ( 'patterns', "^" . $csv_data ['patterns'] . ".*" ); |
|
441 | - $this->db->where ( 'package_id', $edit_id ); |
|
442 | - $pattern_res = ( array ) $this->db->get ( 'package_patterns' )->first_row (); |
|
438 | + if ( ! in_array($csv_data ['patterns'], $pattern_arr)) { |
|
439 | + $this->db->select('count(id) as count'); |
|
440 | + $this->db->where('patterns', "^".$csv_data ['patterns'].".*"); |
|
441 | + $this->db->where('package_id', $edit_id); |
|
442 | + $pattern_res = (array)$this->db->get('package_patterns')->first_row(); |
|
443 | 443 | if ($pattern_res ['count'] == 0) { |
444 | - $csv_data ['destination'] = isset ( $csv_data ['destination'] ) ? $csv_data ['destination'] : ''; |
|
445 | - $str = $this->data_validate ( $csv_data ); |
|
444 | + $csv_data ['destination'] = isset ($csv_data ['destination']) ? $csv_data ['destination'] : ''; |
|
445 | + $str = $this->data_validate($csv_data); |
|
446 | 446 | if ($str != "") { |
447 | 447 | $invalid_array [$i] = $csv_data; |
448 | 448 | $invalid_array [$i] ['error'] = $str; |
449 | 449 | } else { |
450 | - $csv_data ['patterns'] = "^" . $csv_data ['patterns'] . ".*"; |
|
450 | + $csv_data ['patterns'] = "^".$csv_data ['patterns'].".*"; |
|
451 | 451 | $csv_data ['package_id'] = $edit_id; |
452 | 452 | $new_final_arr [$i] = $csv_data; |
453 | 453 | $pattern_arr [$csv_data ['patterns']] = $csv_data ['patterns']; |
@@ -463,38 +463,38 @@ discard block |
||
463 | 463 | $pattern_arr [$csv_data ['patterns']] = $pattern; |
464 | 464 | } |
465 | 465 | |
466 | - $i ++; |
|
466 | + $i++; |
|
467 | 467 | } |
468 | - if (! empty ( $new_final_arr )) { |
|
469 | - $result = $this->package_model->bulk_insert_package_pattern ( $new_final_arr ); |
|
468 | + if ( ! empty ($new_final_arr)) { |
|
469 | + $result = $this->package_model->bulk_insert_package_pattern($new_final_arr); |
|
470 | 470 | } |
471 | 471 | // unlink($full_path.$originationrate_file_name); |
472 | - $count = count ( $invalid_array ); |
|
472 | + $count = count($invalid_array); |
|
473 | 473 | // echo "<pre>";print_r($count);exit; |
474 | 474 | if ($count > 0) { |
475 | 475 | $session_id = "-1"; |
476 | - $fp = fopen ( $full_path . $session_id . '.csv', 'w' ); |
|
477 | - foreach ( $new_final_arr_key as $key => $value ) { |
|
478 | - $custom_array [0] [$key] = ucfirst ( $key ); |
|
476 | + $fp = fopen($full_path.$session_id.'.csv', 'w'); |
|
477 | + foreach ($new_final_arr_key as $key => $value) { |
|
478 | + $custom_array [0] [$key] = ucfirst($key); |
|
479 | 479 | } |
480 | 480 | $custom_array [0] ['error'] = "Error"; |
481 | - $invalid_array = array_merge ( $custom_array, $invalid_array ); |
|
482 | - foreach ( $invalid_array as $err_data ) { |
|
483 | - fputcsv ( $fp, $err_data ); |
|
481 | + $invalid_array = array_merge($custom_array, $invalid_array); |
|
482 | + foreach ($invalid_array as $err_data) { |
|
483 | + fputcsv($fp, $err_data); |
|
484 | 484 | } |
485 | - fclose ( $fp ); |
|
486 | - $this->session->set_userdata ( 'import_package_code_csv_error', $session_id . ".csv" ); |
|
485 | + fclose($fp); |
|
486 | + $this->session->set_userdata('import_package_code_csv_error', $session_id.".csv"); |
|
487 | 487 | $data ["error"] = $invalid_array; |
488 | 488 | $data ['packageid'] = $edit_id; |
489 | - $data ['impoted_count'] = count ( $new_final_arr ); |
|
490 | - $data ['failure_count'] = count ( $invalid_array ) - 1; |
|
491 | - $data ['page_title'] = gettext ( 'Package Patterns Import Error' ); |
|
489 | + $data ['impoted_count'] = count($new_final_arr); |
|
490 | + $data ['failure_count'] = count($invalid_array) - 1; |
|
491 | + $data ['page_title'] = gettext('Package Patterns Import Error'); |
|
492 | 492 | // print_r($data) ;exit; |
493 | - $this->load->view ( 'view_import_error', $data ); |
|
493 | + $this->load->view('view_import_error', $data); |
|
494 | 494 | } else { |
495 | - $this->session->set_flashdata ( 'astpp_errormsg', 'Package patterns imported successfully!' ); |
|
495 | + $this->session->set_flashdata('astpp_errormsg', 'Package patterns imported successfully!'); |
|
496 | 496 | // echo base_url()."package/package_pattern_list/" . $edit_id . "/";exit; |
497 | - redirect ( base_url () . "package/package_pattern_list/" . $edit_id . "/" ); |
|
497 | + redirect(base_url()."package/package_pattern_list/".$edit_id."/"); |
|
498 | 498 | } |
499 | 499 | } |
500 | 500 | function data_validate($csvdata) { |
@@ -503,35 +503,35 @@ discard block |
||
503 | 503 | $alpha_numeric_regex = "/^[a-z0-9 ,.'-]+$/i"; |
504 | 504 | $email_regex = "/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/"; |
505 | 505 | $str .= $csvdata ['patterns'] != '' ? null : 'Code,'; |
506 | - $str = rtrim ( $str, ',' ); |
|
507 | - if (! $str) { |
|
508 | - $str .= is_numeric ( $csvdata ['patterns'] ) ? null : 'Code,'; |
|
506 | + $str = rtrim($str, ','); |
|
507 | + if ( ! $str) { |
|
508 | + $str .= is_numeric($csvdata ['patterns']) ? null : 'Code,'; |
|
509 | 509 | |
510 | - $str .= preg_match ( $alpha_numeric_regex, $csvdata ['destination'] ) ? null : 'Destination,'; |
|
510 | + $str .= preg_match($alpha_numeric_regex, $csvdata ['destination']) ? null : 'Destination,'; |
|
511 | 511 | |
512 | 512 | if ($str) { |
513 | - $str = rtrim ( $str, ',' ); |
|
514 | - $error_field = explode ( ',', $str ); |
|
515 | - $count = count ( $error_field ); |
|
513 | + $str = rtrim($str, ','); |
|
514 | + $error_field = explode(',', $str); |
|
515 | + $count = count($error_field); |
|
516 | 516 | $str .= $count > 1 ? ' are not valid' : ' is not Valid'; |
517 | 517 | return $str; |
518 | 518 | } else { |
519 | 519 | return false; |
520 | 520 | } |
521 | 521 | } else { |
522 | - $str = rtrim ( $str, ',' ); |
|
523 | - $error_field = explode ( ',', $str ); |
|
524 | - $count = count ( $error_field ); |
|
522 | + $str = rtrim($str, ','); |
|
523 | + $error_field = explode(',', $str); |
|
524 | + $count = count($error_field); |
|
525 | 525 | $str .= $count > 1 ? ' are required' : ' is Required'; |
526 | 526 | return $str; |
527 | 527 | } |
528 | 528 | } |
529 | 529 | function package_patterns_error_download() { |
530 | - $this->load->helper ( 'download' ); |
|
531 | - $error_data = $this->session->userdata ( 'import_package_code_csv_error' ); |
|
532 | - $full_path = $this->config->item ( 'rates-file-path' ); |
|
533 | - $data = file_get_contents ( $full_path . $error_data ); |
|
534 | - force_download ( "Package_Code_error.csv", $data ); |
|
530 | + $this->load->helper('download'); |
|
531 | + $error_data = $this->session->userdata('import_package_code_csv_error'); |
|
532 | + $full_path = $this->config->item('rates-file-path'); |
|
533 | + $data = file_get_contents($full_path.$error_data); |
|
534 | + force_download("Package_Code_error.csv", $data); |
|
535 | 535 | } |
536 | 536 | } |
537 | 537 |
@@ -32,8 +32,9 @@ discard block |
||
32 | 32 | $this->load->model ( 'package_model' ); |
33 | 33 | $this->load->library ( 'csvreader' ); |
34 | 34 | |
35 | - if ($this->session->userdata ( 'user_login' ) == FALSE) |
|
36 | - redirect ( base_url () . '/astpp/login' ); |
|
35 | + if ($this->session->userdata ( 'user_login' ) == FALSE) { |
|
36 | + redirect ( base_url () . '/astpp/login' ); |
|
37 | + } |
|
37 | 38 | } |
38 | 39 | function package_list() { |
39 | 40 | $data ['username'] = $this->session->userdata ( 'user_name' ); |
@@ -204,16 +205,18 @@ discard block |
||
204 | 205 | $json_data = array (); |
205 | 206 | $instant_search = $this->session->userdata ( 'left_panel_search_package_pattern' ); |
206 | 207 | $like_str = ! empty ( $instant_search ) ? "(patterns like '%$instant_search%' OR destination like '%$instant_search%' )" : null; |
207 | - if (! empty ( $like_str )) |
|
208 | - $this->db->where ( $like_str ); |
|
208 | + if (! empty ( $like_str )) { |
|
209 | + $this->db->where ( $like_str ); |
|
210 | + } |
|
209 | 211 | $where = array ( |
210 | 212 | 'package_id' => $package_id |
211 | 213 | ); |
212 | 214 | $count_all = $this->db_model->countQuery ( "*", "package_patterns", $where ); |
213 | 215 | $paging_data = $this->form->load_grid_config ( $count_all, $_GET ['rp'], $_GET ['page'] ); |
214 | 216 | $json_data = $paging_data ["json_paging"]; |
215 | - if (! empty ( $like_str )) |
|
216 | - $this->db->where ( $like_str ); |
|
217 | + if (! empty ( $like_str )) { |
|
218 | + $this->db->where ( $like_str ); |
|
219 | + } |
|
217 | 220 | $pattern_data = $this->db_model->select ( "*", "package_patterns", $where, "id", "ASC", $paging_data ["paging"] ["page_no"], $paging_data ["paging"] ["start"] ); |
218 | 221 | |
219 | 222 | $grid_fields = json_decode ( $this->package_form->build_pattern_list_for_customer ( $package_id ) ); |
@@ -21,23 +21,23 @@ discard block |
||
21 | 21 | // You should have received a copy of the GNU Affero General Public License |
22 | 22 | // along with this program. If not, see <http://www.gnu.org/licenses/>. |
23 | 23 | // ############################################################################## |
24 | -if (! defined ( 'BASEPATH' )) |
|
25 | - exit ( 'No direct script access allowed' ); |
|
24 | +if ( ! defined('BASEPATH')) |
|
25 | + exit ('No direct script access allowed'); |
|
26 | 26 | class Package_form { |
27 | 27 | function get_package_form_fields($id = '') { |
28 | - $form ['forms'] = array ( |
|
29 | - base_url () . 'package/package_save/' . $id . "/", |
|
30 | - array ( |
|
28 | + $form ['forms'] = array( |
|
29 | + base_url().'package/package_save/'.$id."/", |
|
30 | + array( |
|
31 | 31 | 'id' => 'packeage_form', |
32 | 32 | 'method' => 'POST', |
33 | 33 | 'name' => 'packeage_form' |
34 | 34 | ) |
35 | 35 | ); |
36 | - $form [gettext ( 'Package Information' )] = array ( |
|
37 | - array ( |
|
36 | + $form [gettext('Package Information')] = array( |
|
37 | + array( |
|
38 | 38 | '', |
39 | 39 | 'HIDDEN', |
40 | - array ( |
|
40 | + array( |
|
41 | 41 | 'name' => 'id' |
42 | 42 | ), |
43 | 43 | '', |
@@ -45,10 +45,10 @@ discard block |
||
45 | 45 | '', |
46 | 46 | '' |
47 | 47 | ), |
48 | - array ( |
|
48 | + array( |
|
49 | 49 | '', |
50 | 50 | 'HIDDEN', |
51 | - array ( |
|
51 | + array( |
|
52 | 52 | 'name' => 'status', |
53 | 53 | 'value' => '1' |
54 | 54 | ), |
@@ -56,10 +56,10 @@ discard block |
||
56 | 56 | '', |
57 | 57 | '' |
58 | 58 | ), |
59 | - array ( |
|
60 | - gettext ( 'Name' ), |
|
59 | + array( |
|
60 | + gettext('Name'), |
|
61 | 61 | 'INPUT', |
62 | - array ( |
|
62 | + array( |
|
63 | 63 | 'name' => 'package_name', |
64 | 64 | 'size' => '20', |
65 | 65 | 'class' => "text field medium" |
@@ -68,8 +68,8 @@ discard block |
||
68 | 68 | 'tOOL TIP', |
69 | 69 | '' |
70 | 70 | ), |
71 | - array ( |
|
72 | - gettext ( 'Rate Group' ), |
|
71 | + array( |
|
72 | + gettext('Rate Group'), |
|
73 | 73 | 'pricelist_id', |
74 | 74 | 'SELECT', |
75 | 75 | '', |
@@ -81,15 +81,15 @@ discard block |
||
81 | 81 | 'pricelists', |
82 | 82 | 'build_dropdown', |
83 | 83 | 'where_arr', |
84 | - array ( |
|
84 | + array( |
|
85 | 85 | "status" => "0", |
86 | 86 | "reseller_id" => "0" |
87 | 87 | ) |
88 | 88 | ), |
89 | - array ( |
|
90 | - gettext ( 'Included Seconds' ), |
|
89 | + array( |
|
90 | + gettext('Included Seconds'), |
|
91 | 91 | 'INPUT', |
92 | - array ( |
|
92 | + array( |
|
93 | 93 | 'name' => 'includedseconds', |
94 | 94 | 'size' => '20', |
95 | 95 | 'class' => "text field medium" |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | * Add For Package Inbound or Outbound or both? |
104 | 104 | * * |
105 | 105 | */ |
106 | - array ( |
|
106 | + array( |
|
107 | 107 | 'Applicable For?', |
108 | 108 | 'applicable_for', |
109 | 109 | 'SELECT', |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | /** |
121 | 121 | * ****************************************** |
122 | 122 | */ |
123 | - array ( |
|
123 | + array( |
|
124 | 124 | 'Status', |
125 | 125 | 'status', |
126 | 126 | 'SELECT', |
@@ -134,17 +134,17 @@ discard block |
||
134 | 134 | 'set_status' |
135 | 135 | ) |
136 | 136 | ); |
137 | - $form ['button_cancel'] = array ( |
|
137 | + $form ['button_cancel'] = array( |
|
138 | 138 | 'name' => 'action', |
139 | - 'content' => gettext ( 'Cancel' ), |
|
139 | + 'content' => gettext('Cancel'), |
|
140 | 140 | 'value' => 'cancel', |
141 | 141 | 'type' => 'button', |
142 | 142 | 'class' => 'btn btn-line-sky margin-x-10', |
143 | 143 | 'onclick' => 'return redirect_page(\'/package/package_list/\')' |
144 | 144 | ); |
145 | - $form ['button_save'] = array ( |
|
145 | + $form ['button_save'] = array( |
|
146 | 146 | 'name' => 'action', |
147 | - 'content' => gettext ( 'Save' ), |
|
147 | + 'content' => gettext('Save'), |
|
148 | 148 | 'value' => 'save', |
149 | 149 | 'type' => 'submit', |
150 | 150 | 'class' => 'btn btn-line-parrot' |
@@ -153,17 +153,17 @@ discard block |
||
153 | 153 | return $form; |
154 | 154 | } |
155 | 155 | function get_package_search_form() { |
156 | - $form ['forms'] = array ( |
|
156 | + $form ['forms'] = array( |
|
157 | 157 | "", |
158 | - array ( |
|
158 | + array( |
|
159 | 159 | 'id' => "package_search" |
160 | 160 | ) |
161 | 161 | ); |
162 | - $form [gettext ( 'Search' )] = array ( |
|
163 | - array ( |
|
164 | - gettext ( 'Name' ), |
|
162 | + $form [gettext('Search')] = array( |
|
163 | + array( |
|
164 | + gettext('Name'), |
|
165 | 165 | 'INPUT', |
166 | - array ( |
|
166 | + array( |
|
167 | 167 | 'name' => 'package_name[package_name]', |
168 | 168 | '', |
169 | 169 | 'size' => '20', |
@@ -179,8 +179,8 @@ discard block |
||
179 | 179 | 'search_string_type', |
180 | 180 | '' |
181 | 181 | ), |
182 | - array ( |
|
183 | - gettext ( 'Rate Group' ), |
|
182 | + array( |
|
183 | + gettext('Rate Group'), |
|
184 | 184 | 'pricelist_id', |
185 | 185 | 'SELECT', |
186 | 186 | '', |
@@ -192,15 +192,15 @@ discard block |
||
192 | 192 | 'pricelists', |
193 | 193 | 'build_dropdown', |
194 | 194 | 'where_arr', |
195 | - array ( |
|
195 | + array( |
|
196 | 196 | "status" => "0", |
197 | 197 | "reseller_id" => "0" |
198 | 198 | ) |
199 | 199 | ), |
200 | - array ( |
|
201 | - gettext ( 'Included Seconds' ), |
|
200 | + array( |
|
201 | + gettext('Included Seconds'), |
|
202 | 202 | 'INPUT', |
203 | - array ( |
|
203 | + array( |
|
204 | 204 | 'name' => 'includedseconds[includedseconds]', |
205 | 205 | 'value' => '', |
206 | 206 | 'size' => '20', |
@@ -221,8 +221,8 @@ discard block |
||
221 | 221 | * Add For Package Inbound or Outbound or both? |
222 | 222 | * * |
223 | 223 | */ |
224 | - array ( |
|
225 | - gettext ( 'Applicable For?' ), |
|
224 | + array( |
|
225 | + gettext('Applicable For?'), |
|
226 | 226 | 'applicable_for', |
227 | 227 | 'SELECT', |
228 | 228 | '', |
@@ -239,8 +239,8 @@ discard block |
||
239 | 239 | /** |
240 | 240 | * ****************************************** |
241 | 241 | */ |
242 | - array ( |
|
243 | - gettext ( 'Status' ), |
|
242 | + array( |
|
243 | + gettext('Status'), |
|
244 | 244 | 'status', |
245 | 245 | 'SELECT', |
246 | 246 | '', |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | '' |
256 | 256 | ), |
257 | 257 | |
258 | - array ( |
|
258 | + array( |
|
259 | 259 | '', |
260 | 260 | 'HIDDEN', |
261 | 261 | 'ajax_search', |
@@ -264,7 +264,7 @@ discard block |
||
264 | 264 | '', |
265 | 265 | '' |
266 | 266 | ), |
267 | - array ( |
|
267 | + array( |
|
268 | 268 | '', |
269 | 269 | 'HIDDEN', |
270 | 270 | 'advance_search', |
@@ -275,18 +275,18 @@ discard block |
||
275 | 275 | ) |
276 | 276 | ) |
277 | 277 | ; |
278 | - $form ['button_search'] = array ( |
|
278 | + $form ['button_search'] = array( |
|
279 | 279 | 'name' => 'action', |
280 | 280 | 'id' => "package_search_btn", |
281 | - 'content' => gettext ( 'Search' ), |
|
281 | + 'content' => gettext('Search'), |
|
282 | 282 | 'value' => 'save', |
283 | 283 | 'type' => 'button', |
284 | 284 | 'class' => 'btn btn-line-parrot pull-right' |
285 | 285 | ); |
286 | - $form ['button_reset'] = array ( |
|
286 | + $form ['button_reset'] = array( |
|
287 | 287 | 'name' => 'action', |
288 | 288 | 'id' => "id_reset", |
289 | - 'content' => gettext ( 'Clear' ), |
|
289 | + 'content' => gettext('Clear'), |
|
290 | 290 | 'value' => 'cancel', |
291 | 291 | 'type' => 'reset', |
292 | 292 | 'class' => 'btn btn-line-sky pull-right margin-x-10' |
@@ -296,8 +296,8 @@ discard block |
||
296 | 296 | } |
297 | 297 | function build_package_list_for_admin() { |
298 | 298 | // array(display name, width, db_field_parent_table,feidname, db_field_child_table,function name); |
299 | - $grid_field_arr = json_encode ( array ( |
|
300 | - array ( |
|
299 | + $grid_field_arr = json_encode(array( |
|
300 | + array( |
|
301 | 301 | "<input type='checkbox' name='chkAll' class='ace checkall'/><label class='lbl'></label>", |
302 | 302 | "30", |
303 | 303 | "", |
@@ -313,8 +313,8 @@ discard block |
||
313 | 313 | * For Package edit on Name |
314 | 314 | * * |
315 | 315 | */ |
316 | - array ( |
|
317 | - gettext ( "Name" ), |
|
316 | + array( |
|
317 | + gettext("Name"), |
|
318 | 318 | "170", |
319 | 319 | "package_name", |
320 | 320 | "", |
@@ -327,8 +327,8 @@ discard block |
||
327 | 327 | /** |
328 | 328 | * ******************************** |
329 | 329 | */ |
330 | - array ( |
|
331 | - gettext ( "Rate Group" ), |
|
330 | + array( |
|
331 | + gettext("Rate Group"), |
|
332 | 332 | "150", |
333 | 333 | "pricelist_id", |
334 | 334 | "name", |
@@ -338,8 +338,8 @@ discard block |
||
338 | 338 | "true", |
339 | 339 | "center" |
340 | 340 | ), |
341 | - array ( |
|
342 | - gettext ( "Included Seconds" ), |
|
341 | + array( |
|
342 | + gettext("Included Seconds"), |
|
343 | 343 | "160", |
344 | 344 | "includedseconds", |
345 | 345 | "", |
@@ -354,8 +354,8 @@ discard block |
||
354 | 354 | * Add For Package Inbound or Outbound or both? |
355 | 355 | * * |
356 | 356 | */ |
357 | - array ( |
|
358 | - gettext ( "Applicable For?" ), |
|
357 | + array( |
|
358 | + gettext("Applicable For?"), |
|
359 | 359 | "200", |
360 | 360 | "applicable_for", |
361 | 361 | "applicable_for", |
@@ -372,8 +372,8 @@ discard block |
||
372 | 372 | * ASTPP 3.0 |
373 | 373 | * Creation date,last modified date show in grid |
374 | 374 | */ |
375 | - array ( |
|
376 | - gettext ( "Status" ), |
|
375 | + array( |
|
376 | + gettext("Status"), |
|
377 | 377 | "140", |
378 | 378 | "status", |
379 | 379 | "status", |
@@ -383,8 +383,8 @@ discard block |
||
383 | 383 | "true", |
384 | 384 | "center" |
385 | 385 | ), |
386 | - array ( |
|
387 | - gettext ( "Created Date" ), |
|
386 | + array( |
|
387 | + gettext("Created Date"), |
|
388 | 388 | "120", |
389 | 389 | "creation_date", |
390 | 390 | "creation_date", |
@@ -394,8 +394,8 @@ discard block |
||
394 | 394 | "true", |
395 | 395 | "center" |
396 | 396 | ), |
397 | - array ( |
|
398 | - gettext ( "Modified Date" ), |
|
397 | + array( |
|
398 | + gettext("Modified Date"), |
|
399 | 399 | "140", |
400 | 400 | "last_modified_date", |
401 | 401 | "last_modified_date", |
@@ -416,50 +416,50 @@ discard block |
||
416 | 416 | /** |
417 | 417 | * ***************************************** |
418 | 418 | */ |
419 | - array ( |
|
420 | - gettext ( "Action" ), |
|
419 | + array( |
|
420 | + gettext("Action"), |
|
421 | 421 | "160", |
422 | 422 | "", |
423 | 423 | "", |
424 | 424 | "", |
425 | - array ( |
|
426 | - "EDIT" => array ( |
|
425 | + array( |
|
426 | + "EDIT" => array( |
|
427 | 427 | "url" => "package/package_edit/", |
428 | 428 | "mode" => "single" |
429 | 429 | ), |
430 | - "DELETE" => array ( |
|
430 | + "DELETE" => array( |
|
431 | 431 | "url" => "package/package_delete/", |
432 | 432 | "mode" => "single" |
433 | 433 | ) |
434 | 434 | ) |
435 | 435 | ) |
436 | - ) ); |
|
436 | + )); |
|
437 | 437 | return $grid_field_arr; |
438 | 438 | } |
439 | 439 | function build_grid_buttons() { |
440 | - $buttons_json = json_encode ( array ( |
|
441 | - array ( |
|
442 | - gettext ( "Create" ), |
|
440 | + $buttons_json = json_encode(array( |
|
441 | + array( |
|
442 | + gettext("Create"), |
|
443 | 443 | "btn btn-line-warning btn", |
444 | 444 | "fa fa-plus-circle fa-lg", |
445 | 445 | "button_action", |
446 | 446 | "/package/package_add/" |
447 | 447 | ), |
448 | - array ( |
|
449 | - gettext ( "Delete" ), |
|
448 | + array( |
|
449 | + gettext("Delete"), |
|
450 | 450 | "btn btn-line-danger", |
451 | 451 | "fa fa-times-circle fa-lg", |
452 | 452 | "button_action", |
453 | 453 | "/package/package_delete_multiple/" |
454 | 454 | ) |
455 | - ) ); |
|
455 | + )); |
|
456 | 456 | return $buttons_json; |
457 | 457 | } |
458 | 458 | function build_package_counter_list_for_admin() { |
459 | 459 | // array(display name, width, db_field_parent_table,feidname, db_field_child_table,function name); |
460 | - $grid_field_arr = json_encode ( array ( |
|
461 | - array ( |
|
462 | - gettext ( "Package Name" ), |
|
460 | + $grid_field_arr = json_encode(array( |
|
461 | + array( |
|
462 | + gettext("Package Name"), |
|
463 | 463 | "430", |
464 | 464 | "package_id", |
465 | 465 | "package_name", |
@@ -469,8 +469,8 @@ discard block |
||
469 | 469 | "true", |
470 | 470 | "center" |
471 | 471 | ), |
472 | - array ( |
|
473 | - gettext ( "Account" ), |
|
472 | + array( |
|
473 | + gettext("Account"), |
|
474 | 474 | "420", |
475 | 475 | "accountid", |
476 | 476 | "first_name,last_name,number", |
@@ -480,8 +480,8 @@ discard block |
||
480 | 480 | "true", |
481 | 481 | "center" |
482 | 482 | ), |
483 | - array ( |
|
484 | - gettext ( "Used Seconds" ), |
|
483 | + array( |
|
484 | + gettext("Used Seconds"), |
|
485 | 485 | "420", |
486 | 486 | "seconds", |
487 | 487 | "", |
@@ -491,12 +491,12 @@ discard block |
||
491 | 491 | "true", |
492 | 492 | "center" |
493 | 493 | ) |
494 | - ) ); |
|
494 | + )); |
|
495 | 495 | return $grid_field_arr; |
496 | 496 | } |
497 | 497 | function build_pattern_list_for_customer($packageid) { |
498 | - $grid_field_arr = json_encode ( array ( |
|
499 | - array ( |
|
498 | + $grid_field_arr = json_encode(array( |
|
499 | + array( |
|
500 | 500 | "<input type='checkbox' name='chkAll' class='ace checkall'/><label class='lbl'></label>", |
501 | 501 | "30", |
502 | 502 | "", |
@@ -507,55 +507,55 @@ discard block |
||
507 | 507 | "false", |
508 | 508 | "center" |
509 | 509 | ), |
510 | - array ( |
|
511 | - gettext ( "Code" ), |
|
510 | + array( |
|
511 | + gettext("Code"), |
|
512 | 512 | "450", |
513 | 513 | "patterns", |
514 | 514 | "patterns", |
515 | 515 | "", |
516 | 516 | "get_only_numeric_val" |
517 | 517 | ), |
518 | - array ( |
|
519 | - gettext ( "Destination" ), |
|
518 | + array( |
|
519 | + gettext("Destination"), |
|
520 | 520 | "450", |
521 | 521 | "destination", |
522 | 522 | "", |
523 | 523 | "", |
524 | 524 | "" |
525 | 525 | ), |
526 | - array ( |
|
527 | - gettext ( "Action" ), |
|
526 | + array( |
|
527 | + gettext("Action"), |
|
528 | 528 | "100", |
529 | 529 | "", |
530 | 530 | "", |
531 | 531 | "", |
532 | - array ( |
|
533 | - "DELETE" => array ( |
|
532 | + array( |
|
533 | + "DELETE" => array( |
|
534 | 534 | "url" => "package/package_patterns_delete/$packageid/", |
535 | 535 | "mode" => "single" |
536 | 536 | ) |
537 | 537 | ) |
538 | 538 | ) |
539 | - ) ); |
|
539 | + )); |
|
540 | 540 | return $grid_field_arr; |
541 | 541 | } |
542 | 542 | function set_pattern_grid_buttons($packageid) { |
543 | - $buttons_json = json_encode ( array ( |
|
544 | - array ( |
|
545 | - gettext ( "Create" ), |
|
543 | + $buttons_json = json_encode(array( |
|
544 | + array( |
|
545 | + gettext("Create"), |
|
546 | 546 | "btn btn-line-warning btn", |
547 | 547 | "fa fa-plus-circle fa-lg", |
548 | 548 | "button_action", |
549 | 549 | "/package/customer_add_patterns/$packageid", |
550 | 550 | "popup" |
551 | 551 | ) |
552 | - ) ); |
|
552 | + )); |
|
553 | 553 | return $buttons_json; |
554 | 554 | } |
555 | 555 | function build_package_counter_report() { |
556 | - $buttons_json = json_encode ( array ( |
|
557 | - array ( |
|
558 | - gettext ( "Export" ), |
|
556 | + $buttons_json = json_encode(array( |
|
557 | + array( |
|
558 | + gettext("Export"), |
|
559 | 559 | "btn btn-xing", |
560 | 560 | " fa fa-download fa-lg", |
561 | 561 | "button_action", |
@@ -567,9 +567,9 @@ discard block |
||
567 | 567 | return $buttons_json; |
568 | 568 | } |
569 | 569 | function build_package_list_for_reseller() { |
570 | - $grid_field_arr = json_encode ( array ( |
|
571 | - array ( |
|
572 | - gettext ( "Name" ), |
|
570 | + $grid_field_arr = json_encode(array( |
|
571 | + array( |
|
572 | + gettext("Name"), |
|
573 | 573 | "310", |
574 | 574 | "package_name", |
575 | 575 | "", |
@@ -579,8 +579,8 @@ discard block |
||
579 | 579 | "true", |
580 | 580 | "center" |
581 | 581 | ), |
582 | - array ( |
|
583 | - gettext ( "Rate Group" ), |
|
582 | + array( |
|
583 | + gettext("Rate Group"), |
|
584 | 584 | "250", |
585 | 585 | "pricelist_id", |
586 | 586 | "name", |
@@ -590,8 +590,8 @@ discard block |
||
590 | 590 | "true", |
591 | 591 | "center" |
592 | 592 | ), |
593 | - array ( |
|
594 | - gettext ( "Included Seconds" ), |
|
593 | + array( |
|
594 | + gettext("Included Seconds"), |
|
595 | 595 | "260", |
596 | 596 | "includedseconds", |
597 | 597 | "", |
@@ -601,8 +601,8 @@ discard block |
||
601 | 601 | "true", |
602 | 602 | "center" |
603 | 603 | ), |
604 | - array ( |
|
605 | - gettext ( "Status" ), |
|
604 | + array( |
|
605 | + gettext("Status"), |
|
606 | 606 | "160", |
607 | 607 | "status", |
608 | 608 | "status", |
@@ -612,7 +612,7 @@ discard block |
||
612 | 612 | "true", |
613 | 613 | "center" |
614 | 614 | ) |
615 | - ) ); |
|
615 | + )); |
|
616 | 616 | return $grid_field_arr; |
617 | 617 | } |
618 | 618 | } |
@@ -21,8 +21,9 @@ |
||
21 | 21 | // You should have received a copy of the GNU Affero General Public License |
22 | 22 | // along with this program. If not, see <http://www.gnu.org/licenses/>. |
23 | 23 | // ############################################################################## |
24 | -if (! defined ( 'BASEPATH' )) |
|
24 | +if (! defined ( 'BASEPATH' )) { |
|
25 | 25 | exit ( 'No direct script access allowed' ); |
26 | +} |
|
26 | 27 | class Package_form { |
27 | 28 | function get_package_form_fields($id = '') { |
28 | 29 | $form ['forms'] = array ( |