Completed
Push — v3.0 ( 23635d...e28df5 )
by Samir
23s
created
web_interface/astpp/application/modules/reports/models/reports_model.php 1 patch
Spacing   +64 added lines, -64 removed lines patch added patch discarded remove patch
@@ -29,31 +29,31 @@  discard block
 block discarded – undo
29 29
 ASTPP  3.0 
30 30
     For Detail Customer Report List,Export
31 31
 **/
32
-    function getcustomer_cdrs($flag, $start, $limit,$export =false) {
32
+    function getcustomer_cdrs($flag, $start, $limit, $export = false) {
33 33
         $this->db_model->build_search('customer_cdr_list_search');
34 34
         $account_data = $this->session->userdata("accountinfo");
35
-        $where['reseller_id']=$account_data['type']== 1 ? $account_data['id']:0;
35
+        $where['reseller_id'] = $account_data['type'] == 1 ? $account_data['id'] : 0;
36 36
         //$where['type']=0;
37
-        if($this->session->userdata('advance_search') != 1){
38
-	    $where['callstart >= ']=date("Y-m-d")." 00:00:00";
39
-            $where['callstart <=']=date("Y-m-d")." 23:59:59";
37
+        if ($this->session->userdata('advance_search') != 1) {
38
+	    $where['callstart >= '] = date("Y-m-d")." 00:00:00";
39
+            $where['callstart <='] = date("Y-m-d")." 23:59:59";
40 40
         }
41 41
 
42
-        $types = array('0','3');
42
+        $types = array('0', '3');
43 43
         //$this->db->or_where_in('type', $types);    
44 44
 		$this->db->where_in('type', $types);  
45 45
 		
46 46
         $this->db->where($where);
47
-        if (isset($_GET['sortname']) && $_GET['sortname'] != 'undefined'){
48
-          $this->db->order_by($_GET['sortname'], ($_GET['sortorder']=='undefined')?'desc':$_GET['sortorder']);
49
-        }else{
47
+        if (isset($_GET['sortname']) && $_GET['sortname'] != 'undefined') {
48
+          $this->db->order_by($_GET['sortname'], ($_GET['sortorder'] == 'undefined') ? 'desc' : $_GET['sortorder']);
49
+        } else {
50 50
            $this->db->order_by("callstart desc");
51 51
         }
52 52
         if ($flag) {
53
-            if (!$export)
53
+            if ( ! $export)
54 54
                 $this->db->limit($limit, $start);
55 55
             $this->db->select('callstart,callerid,callednum,pattern,notes,billseconds,disposition,debit,cost,accountid,pricelist_id,calltype,is_recording,trunk_id,uniqueid');
56
-        }else {
56
+        } else {
57 57
             $this->db->select('count(*) as count,sum(billseconds) as billseconds,sum(debit) as total_debit,sum(cost) as total_cost,group_concat(distinct(pricelist_id)) as pricelist_ids,group_concat(distinct(trunk_id)) as trunk_ids,group_concat(distinct(accountid)) as accounts_ids');
58 58
         }
59 59
         $result = $this->db->get('cdrs');
@@ -62,23 +62,23 @@  discard block
 block discarded – undo
62 62
 /*
63 63
  * Below function using by Detail reseller report
64 64
  */
65
-    function getreseller_cdrs($flag, $start, $limit,$export=false) {
65
+    function getreseller_cdrs($flag, $start, $limit, $export = false) {
66 66
         $this->db_model->build_search('reseller_cdr_list_search');
67 67
         $account_data = $this->session->userdata("accountinfo");
68
-        $where['reseller_id']=$account_data['type']== 1 ? $account_data['id']:0;
69
-        $where["accountid <>"]=$account_data['type']== 1 ? $account_data['id']:0;
70
-	if($this->session->userdata('advance_search') != 1){
71
-	    $where['callstart >= ']=date("Y-m-d")." 00:00:00";
72
-            $where['callstart <=']=date("Y-m-d")." 23:59:59";
68
+        $where['reseller_id'] = $account_data['type'] == 1 ? $account_data['id'] : 0;
69
+        $where["accountid <>"] = $account_data['type'] == 1 ? $account_data['id'] : 0;
70
+	if ($this->session->userdata('advance_search') != 1) {
71
+	    $where['callstart >= '] = date("Y-m-d")." 00:00:00";
72
+            $where['callstart <='] = date("Y-m-d")." 23:59:59";
73 73
         }
74 74
         $this->db->where($where);
75
-        if (isset($_GET['sortname']) && $_GET['sortname'] != 'undefined'){
76
-          $this->db->order_by($_GET['sortname'], ($_GET['sortorder']=='undefined')?'desc':$_GET['sortorder']);
77
-        }else{
75
+        if (isset($_GET['sortname']) && $_GET['sortname'] != 'undefined') {
76
+          $this->db->order_by($_GET['sortname'], ($_GET['sortorder'] == 'undefined') ? 'desc' : $_GET['sortorder']);
77
+        } else {
78 78
            $this->db->order_by("callstart desc");
79 79
         }
80 80
         if ($flag) {
81
-            if (!$export)
81
+            if ( ! $export)
82 82
                 $this->db->limit($limit, $start);
83 83
                 $this->db->select('callstart,callerid,callednum,pattern,notes,billseconds,disposition,debit,cost,accountid,pricelist_id,calltype');
84 84
         } else {
@@ -89,48 +89,48 @@  discard block
 block discarded – undo
89 89
     }
90 90
         /*Below function using by Detail provider report
91 91
   */
92
-    function getprovider_cdrs($flag, $start, $limit,$export=false) {
92
+    function getprovider_cdrs($flag, $start, $limit, $export = false) {
93 93
         $this->db_model->build_search('provider_cdr_list_search');
94 94
         $account_data = $this->session->userdata("accountinfo");
95
-        $where=array();
96
-        if($account_data['type']== 3 ){ 
97
-            $where['provider_id']= $account_data['id'];
95
+        $where = array();
96
+        if ($account_data['type'] == 3) { 
97
+            $where['provider_id'] = $account_data['id'];
98 98
         }
99 99
         
100
-        if($this->session->userdata('advance_search') != 1){
101
-	    $where['callstart >= ']=date("Y-m-d")." 00:00:00";
102
-            $where['callstart <=']=date("Y-m-d")." 23:59:59";
100
+        if ($this->session->userdata('advance_search') != 1) {
101
+	    $where['callstart >= '] = date("Y-m-d")." 00:00:00";
102
+            $where['callstart <='] = date("Y-m-d")." 23:59:59";
103 103
         }
104 104
         $this->db->where('trunk_id !=', '');
105 105
         $this->db->where($where);
106
-        if (isset($_GET['sortname']) && $_GET['sortname'] != 'undefined'){
107
-          $this->db->order_by($_GET['sortname'], ($_GET['sortorder']=='undefined')?'desc':$_GET['sortorder']);
108
-        }else{
106
+        if (isset($_GET['sortname']) && $_GET['sortname'] != 'undefined') {
107
+          $this->db->order_by($_GET['sortname'], ($_GET['sortorder'] == 'undefined') ? 'desc' : $_GET['sortorder']);
108
+        } else {
109 109
            $this->db->order_by("callstart desc");
110 110
         }
111 111
         if ($flag) {
112
-            if (!$export)
112
+            if ( ! $export)
113 113
                 $this->db->limit($limit, $start);
114 114
             $this->db->select('callstart,callerid,callednum,pattern,notes,billseconds,provider_call_cost,disposition,provider_id,cost');
115
-        }else {
115
+        } else {
116 116
             $this->db->select('count(*) as count,sum(billseconds) as billseconds,sum(cost) as total_cost');
117 117
         }
118 118
         $result = $this->db->get('cdrs');
119 119
       //  echo $this->db->last_query();
120 120
         return $result;
121 121
     }
122
-     function users_cdrs_list($flag,$accountid,$entity_type,$start,$limit) {
122
+     function users_cdrs_list($flag, $accountid, $entity_type, $start, $limit) {
123 123
 		$where = "callstart >= '".date('Y-m-d 00:00:00')."' AND callstart <='".date('Y-m-d 23:59:59')."' AND ";
124
-        $account_type= $entity_type =='provider' ? 'provider_id' :'accountid';
125
-        $where.="accountid = '".$accountid."' ";
124
+        $account_type = $entity_type == 'provider' ? 'provider_id' : 'accountid';
125
+        $where .= "accountid = '".$accountid."' ";
126 126
         //~ if($entity_type == 'provider'){
127 127
          //~ $where.="OR provider_id = '".$accountid."'";
128 128
         //~ }
129
-        $table=$entity_type=='reseller'?'reseller_cdrs' : 'cdrs';
129
+        $table = $entity_type == 'reseller' ? 'reseller_cdrs' : 'cdrs';
130 130
         if ($flag) {
131 131
             $query = $this->db_model->select("*", $table, $where, "callstart", "DESC", $limit, $start);
132 132
         } else {
133
-            $query = $this->db_model->countQuery("*",$table, $where);
133
+            $query = $this->db_model->countQuery("*", $table, $where);
134 134
         }
135 135
         return $query;
136 136
 
@@ -154,13 +154,13 @@  discard block
 block discarded – undo
154 154
         return $query;
155 155
     }
156 156
 
157
-    function get_refill_list($flag, $start, $limit,$export=false) {
157
+    function get_refill_list($flag, $start, $limit, $export = false) {
158 158
         $this->db_model->build_search('cdr_refill_search');
159 159
         $accountinfo = $this->session->userdata('accountinfo');
160
-        $where['payment_by']=$accountinfo['type']==1 ? $accountinfo['id']:-1;
160
+        $where['payment_by'] = $accountinfo['type'] == 1 ? $accountinfo['id'] : -1;
161 161
         if ($flag) {
162
-            if($export)
163
-	      $query = $this->db_model->select("*", "payments", $where, "payment_date", "DESC","","");
162
+            if ($export)
163
+	      $query = $this->db_model->select("*", "payments", $where, "payment_date", "DESC", "", "");
164 164
             else
165 165
 	       $query = $this->db_model->select("*", "payments", $where, "payment_date", "DESC", $limit, $start);
166 166
         } else {
@@ -179,10 +179,10 @@  discard block
 block discarded – undo
179 179
             $reseller_id = "0";
180 180
         }
181 181
         if ($flag) {
182
-            $query = $this->db_model->select_by_in("*", "commission","" , "date", "DESC", $limit, $start,"","reseller_id",$reseller_id);
182
+            $query = $this->db_model->select_by_in("*", "commission", "", "date", "DESC", $limit, $start, "", "reseller_id", $reseller_id);
183 183
 
184 184
         } else {
185
-            $query = $this->db_model->countQuery_by_in("*", "commission", "","reseller_id",$reseller_id);
185
+            $query = $this->db_model->countQuery_by_in("*", "commission", "", "reseller_id", $reseller_id);
186 186
         }
187 187
 
188 188
         return $query;
@@ -192,22 +192,22 @@  discard block
 block discarded – undo
192 192
 Charge History
193 193
 ***********/
194 194
     function getcharges_list($flag, $start = 0, $limit = 0) {
195
-	$accountinfo=$this->session->userdata('accountinfo');
196
-	$reseller_id=$accountinfo['id'];
197
-	if($accountinfo['type'] == 1){
198
-		$where['reseller_id']=$reseller_id;
199
-	}else{
200
-		$where['reseller_id']=0;
195
+	$accountinfo = $this->session->userdata('accountinfo');
196
+	$reseller_id = $accountinfo['id'];
197
+	if ($accountinfo['type'] == 1) {
198
+		$where['reseller_id'] = $reseller_id;
199
+	} else {
200
+		$where['reseller_id'] = 0;
201 201
 	}
202
-	if($this->session->userdata('advance_search') != 1){
203
-		$where['created_date >=']=gmdate("Y-m-01 00:00:01");
204
-		$where['created_date <=']=gmdate("Y-m-d 23:59:59");
202
+	if ($this->session->userdata('advance_search') != 1) {
203
+		$where['created_date >='] = gmdate("Y-m-01 00:00:01");
204
+		$where['created_date <='] = gmdate("Y-m-d 23:59:59");
205 205
 	}
206 206
 	$this->db_model->build_search('charges_list_search');
207 207
 	$this->db->where($where);
208
-	$whr= "( invoiceid =0 OR invoiceid in (  select id  from invoices where confirm = 1) )";
208
+	$whr = "( invoiceid =0 OR invoiceid in (  select id  from invoices where confirm = 1) )";
209 209
 	$this->db->where($whr);
210
-	$this->db->where('item_type <>','STANDARD');
210
+	$this->db->where('item_type <>', 'STANDARD');
211 211
 	if ($flag) {
212 212
 		$query = $this->db_model->select('*', "invoice_details", "", "id", "DESC", $limit, $start);
213 213
 	} else {
@@ -220,15 +220,15 @@  discard block
 block discarded – undo
220 220
     /* ASTPP  3.0 
221 221
      * This function using for customer edit
222 222
      */
223
-   function get_customer_charge_list($flag,$accountid,$start = 0, $limit = 0){
223
+   function get_customer_charge_list($flag, $accountid, $start = 0, $limit = 0) {
224 224
         $this->db_model->build_search('charges_list_search');
225
-        $accountinfo=$this->session->userdata('accountinfo');
226
-        $reseller_id=$accountinfo['type']==1 ? $accountinfo['id'] : 0;
227
-        $where['reseller_id']=$reseller_id;
228
-        $where['accountid']=$accountid;
229
-        if($this->session->userdata('advance_search') != 1){
230
-             $where['created_date >=']=gmdate("Y-m-1 00:00:00");
231
-             $where['created_date <=']=gmdate("Y-m-d 23:59:59");
225
+        $accountinfo = $this->session->userdata('accountinfo');
226
+        $reseller_id = $accountinfo['type'] == 1 ? $accountinfo['id'] : 0;
227
+        $where['reseller_id'] = $reseller_id;
228
+        $where['accountid'] = $accountid;
229
+        if ($this->session->userdata('advance_search') != 1) {
230
+             $where['created_date >='] = gmdate("Y-m-1 00:00:00");
231
+             $where['created_date <='] = gmdate("Y-m-d 23:59:59");
232 232
         }
233 233
         if ($flag) {
234 234
             $query = $this->db_model->select("*", "invoice_details", $where, "id", "DESC", $limit, $start);
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
         }
238 238
         return $query;        
239 239
     }
240
-    function get_customer_refillreport($flag,$accountid,$start = 0, $limit = 0){
240
+    function get_customer_refillreport($flag, $accountid, $start = 0, $limit = 0) {
241 241
         $where = array("accountid"=>$accountid);
242 242
         if ($flag) {
243 243
             $query = $this->db_model->select("*", "payments", $where, "payment_date", "DESC", $limit, $start);
Please login to merge, or discard this patch.
web_interface/astpp/application/modules/invoices/controllers/invoices.php 1 patch
Spacing   +840 added lines, -840 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
         $this->load->library('pdf');
39 39
 
40 40
         if ($this->session->userdata('user_login') == FALSE)
41
-            redirect(base_url() . '/astpp/login');
41
+            redirect(base_url().'/astpp/login');
42 42
     }
43 43
 
44 44
 
@@ -48,141 +48,141 @@  discard block
 block discarded – undo
48 48
         $data['page_title'] = 'Invoices';
49 49
         $data['login_type'] = $this->session->userdata['userlevel_logintype'];
50 50
         $data['search_flag'] = true;
51
-        $this->session->set_userdata('advance_search',0);
52
-        $data['grid_fields']= $this->invoices_form->build_invoices_list_for_admin();
51
+        $this->session->set_userdata('advance_search', 0);
52
+        $data['grid_fields'] = $this->invoices_form->build_invoices_list_for_admin();
53 53
         $data["grid_buttons"] = $this->invoices_form->build_grid_buttons();
54
-        $data['form_search']=$this->form->build_serach_form($this->invoices_form->get_invoice_search_form());
55
-         $account=$this->db_model->getSelect('id,first_name,last_name,number', 'accounts', array('status'=>0,'type'=>'0,3','deleted'=>0)) ;
56
-        $data['account_value']=$account->result_array();
57
-        $this->load->view('view_invoices_list',$data);
54
+        $data['form_search'] = $this->form->build_serach_form($this->invoices_form->get_invoice_search_form());
55
+         $account = $this->db_model->getSelect('id,first_name,last_name,number', 'accounts', array('status'=>0, 'type'=>'0,3', 'deleted'=>0));
56
+        $data['account_value'] = $account->result_array();
57
+        $this->load->view('view_invoices_list', $data);
58 58
     }
59 59
     function invoice_list_json() {
60 60
         $login_info = $this->session->userdata('accountinfo');
61 61
          $logintype = $this->session->userdata('logintype');
62 62
          $json_data = array();
63 63
          $count_all = $this->invoices_model->get_invoice_list(false);
64
-         $paging_data =  $this->form->load_grid_config($count_all, $_GET['rp'], $_GET['page']);
64
+         $paging_data = $this->form->load_grid_config($count_all, $_GET['rp'], $_GET['page']);
65 65
          $json_data = $paging_data["json_paging"];
66
-         $result_query = $this->invoices_model->get_invoice_list(true,$paging_data["paging"]["start"], $paging_data["paging"]["page_no"]);
67
-      if($logintype == -1){
66
+         $result_query = $this->invoices_model->get_invoice_list(true, $paging_data["paging"]["start"], $paging_data["paging"]["page_no"]);
67
+      if ($logintype == -1) {
68 68
          $currency_id = Common_model::$global_config['system_config']['base_currency'];
69
-      }else{
69
+      } else {
70 70
 	  $accountdata["currency_id"] = $this->common->get_field_name('currency', 'currency', $login_info["currency_id"]);
71 71
          $currency_id = $accountdata["currency_id"];
72 72
       }
73
-         $grid_fields= json_decode($this->invoices_form->build_invoices_list_for_admin());
74
-         $url= ($logintype==0 ||$logintype==3 ) ? "/user/user_invoice_download/":'/invoices/invoice_download/';
75
-         if($result_query->num_rows > 0 ){
76
-	        $query=$result_query->result_array();
73
+         $grid_fields = json_decode($this->invoices_form->build_invoices_list_for_admin());
74
+         $url = ($logintype == 0 || $logintype == 3) ? "/user/user_invoice_download/" : '/invoices/invoice_download/';
75
+         if ($result_query->num_rows > 0) {
76
+	        $query = $result_query->result_array();
77 77
 	        $total_value = 0;
78 78
 	        $ountstanding_value = 0;
79 79
          foreach ($query as $key => $value) {
80
-	  $delete_button='';
80
+	  $delete_button = '';
81 81
           $date = strtotime($value['invoice_date']);
82
-          $invoice_date =date("Y-m-d",$date);
82
+          $invoice_date = date("Y-m-d", $date);
83 83
           $fromdate = strtotime($value['from_date']);
84
-          $from_date =date("Y-m-d",$fromdate);
84
+          $from_date = date("Y-m-d", $fromdate);
85 85
           $duedate = strtotime($value['due_date']);
86
-          if($value['type'] == 'I'){
87
-          $due_date =date("Y-m-d",$duedate);
88
-          }else{
89
-          $due_date='';
86
+          if ($value['type'] == 'I') {
87
+          $due_date = date("Y-m-d", $duedate);
88
+          } else {
89
+          $due_date = '';
90 90
           }
91 91
           $outstanding = $value['amount'];
92 92
 	         $last_payment_date = '';
93
-	         $invoice_total_query = $this->db_model->select("sum(debit) as debit,sum(credit) as credit,created_date", "invoice_details", array("invoiceid"=> $value['id'],"item_type"=>"INVPAY"),"created_date","DESC","1","0");
93
+	         $invoice_total_query = $this->db_model->select("sum(debit) as debit,sum(credit) as credit,created_date", "invoice_details", array("invoiceid"=> $value['id'], "item_type"=>"INVPAY"), "created_date", "DESC", "1", "0");
94 94
        // echo $this->db->last_query(); exit;
95
-          if ($invoice_total_query ->num_rows() > 0){
96
-            $invoice_total_query= $invoice_total_query->result_array();
95
+          if ($invoice_total_query ->num_rows() > 0) {
96
+            $invoice_total_query = $invoice_total_query->result_array();
97 97
             //echo '<pre>'; print_r($invoice_total_query); 
98
-            if($value['type'] == 'I'){
98
+            if ($value['type'] == 'I') {
99 99
             $outstanding -= $this->common->currency_decimal($invoice_total_query[0]['credit']);
100
-            }else{
101
-            $outstanding='';
100
+            } else {
101
+            $outstanding = '';
102 102
             }
103 103
             $last_payment_date = $invoice_total_query[0]['created_date'];
104
-            if($value['type'] == 'I'){
105
-            if($last_payment_date ){
106
-            $payment_date=strtotime( $last_payment_date);
107
-            $payment_last=date("Y-m-d",$payment_date);
108
-            }else{
109
-             $payment_last='';
104
+            if ($value['type'] == 'I') {
105
+            if ($last_payment_date) {
106
+            $payment_date = strtotime($last_payment_date);
107
+            $payment_last = date("Y-m-d", $payment_date);
108
+            } else {
109
+             $payment_last = '';
110 110
             }
111
-         }else{
112
-          $payment_last='';
111
+         } else {
112
+          $payment_last = '';
113 113
           }
114 114
             
115 115
           }
116 116
           
117
-          $invoice_total='';
118
-          $accountinfo=$this->session->userdata('accountinfo');
119
-          $id=$accountinfo['id'];
120
-          if($accountinfo['type'] == 1){
121
-          $query ="select sum(amount) as grand_total from invoices where reseller_id='$id'";
122
-          }else{
123
-          $query ="select sum(amount) as grand_total from invoices where reseller_id='0'";
117
+          $invoice_total = '';
118
+          $accountinfo = $this->session->userdata('accountinfo');
119
+          $id = $accountinfo['id'];
120
+          if ($accountinfo['type'] == 1) {
121
+          $query = "select sum(amount) as grand_total from invoices where reseller_id='$id'";
122
+          } else {
123
+          $query = "select sum(amount) as grand_total from invoices where reseller_id='0'";
124 124
           }
125
-          $ext_query=$this->db->query($query);
126
-          if($ext_query->num_rows() > 0){
127
-          $result_total=$ext_query->result_array();
128
-          $grandtotal=$result_total[0]['grand_total'];
129
-          $grand_total=$this->common->currency_decimal($grandtotal).' '.$currency_id;
125
+          $ext_query = $this->db->query($query);
126
+          if ($ext_query->num_rows() > 0) {
127
+          $result_total = $ext_query->result_array();
128
+          $grandtotal = $result_total[0]['grand_total'];
129
+          $grand_total = $this->common->currency_decimal($grandtotal).' '.$currency_id;
130 130
           }
131 131
           
132 132
           
133
-          if($accountinfo['type'] == 1){
134
-          $invoice_query ="select sum(credit) as grand_credit from invoice_details where reseller_id='$id'";
135
-          }else{
136
-          $invoice_query ="select sum(credit) as grand_credit from invoice_details where reseller_id='0'";
133
+          if ($accountinfo['type'] == 1) {
134
+          $invoice_query = "select sum(credit) as grand_credit from invoice_details where reseller_id='$id'";
135
+          } else {
136
+          $invoice_query = "select sum(credit) as grand_credit from invoice_details where reseller_id='0'";
137 137
           }
138
-          $credit_query=$this->db->query($invoice_query);
139
-          if($credit_query->num_rows() > 0){
140
-          $credit_total=$credit_query->result_array();
141
-          $grand_credit_total=$credit_total[0]['grand_credit'];
142
-          $grandcredit=$grand_total-$grand_credit_total;
143
-          $grand_credit=$this->common->currency_decimal($grandcredit).' '.$currency_id;
138
+          $credit_query = $this->db->query($invoice_query);
139
+          if ($credit_query->num_rows() > 0) {
140
+          $credit_total = $credit_query->result_array();
141
+          $grand_credit_total = $credit_total[0]['grand_credit'];
142
+          $grandcredit = $grand_total - $grand_credit_total;
143
+          $grand_credit = $this->common->currency_decimal($grandcredit).' '.$currency_id;
144 144
           }
145
-          $download="<a  href=" . $url .$value['id'].'/00_'.$value['invoice_prefix'].$value['invoiceid']. " class='btn btn-royelblue btn-sm'  title='Download Invoice' ><i class='fa fa-cloud-download fa-fw'></i></a>&nbsp";
146
-          if($value['type'] == 'I'){
147
-		if($value['confirm'] ==0){
148
-			if($value['generate_type'] ==1){
149
-		              $payment = '<a href="'. base_url() .'invoices/invoice_manually_edit/' . $value['id'] . '" class="btn btn-royelblue btn-sm"  title="Edit"><i class="fa fa-pencil-square-o fa-fw"></i></a>';
150
-			}else{
151
-		              $payment = '<a href="'. base_url() .'invoices/invoice_automatically_edit/' . $value['id'] . '" class="btn btn-royelblue btn-sm"  title="Edit"><i class="fa fa-pencil-square-o fa-fw"></i></a>';
145
+          $download = "<a  href=".$url.$value['id'].'/00_'.$value['invoice_prefix'].$value['invoiceid']." class='btn btn-royelblue btn-sm'  title='Download Invoice' ><i class='fa fa-cloud-download fa-fw'></i></a>&nbsp";
146
+          if ($value['type'] == 'I') {
147
+		if ($value['confirm'] == 0) {
148
+			if ($value['generate_type'] == 1) {
149
+		              $payment = '<a href="'.base_url().'invoices/invoice_manually_edit/'.$value['id'].'" class="btn btn-royelblue btn-sm"  title="Edit"><i class="fa fa-pencil-square-o fa-fw"></i></a>';
150
+			} else {
151
+		              $payment = '<a href="'.base_url().'invoices/invoice_automatically_edit/'.$value['id'].'" class="btn btn-royelblue btn-sm"  title="Edit"><i class="fa fa-pencil-square-o fa-fw"></i></a>';
152 152
 			}
153
-  		        $id=$value['id'];       
154
-		        $delete_button="<a onclick='invoice_delete($id)' class='btn btn-royelblue btn-sm'  title='Delete' ><i class='fa fa-trash fa-fw'></i></a>&nbsp";
153
+  		        $id = $value['id'];       
154
+		        $delete_button = "<a onclick='invoice_delete($id)' class='btn btn-royelblue btn-sm'  title='Delete' ><i class='fa fa-trash fa-fw'></i></a>&nbsp";
155 155
 
156
-		}else{
157
-            	     if($outstanding > 0){
158
-		        $payment = '<a style="padding: 0 8px;" href="'. base_url() .'invoices/invoice_summary/' . $value['id'] . '" class="btn btn-warning"  title="Payment">Unpaid</i></a>';
159
-            	     }else{
156
+		} else {
157
+            	     if ($outstanding > 0) {
158
+		        $payment = '<a style="padding: 0 8px;" href="'.base_url().'invoices/invoice_summary/'.$value['id'].'" class="btn btn-warning"  title="Payment">Unpaid</i></a>';
159
+            	     } else {
160 160
 		        $payment = '<button style="padding: 0 17px;" type="button"  class="btn btn-success">Paid</button>';
161 161
             	     }
162
-	             $delete_button="&nbsp";
162
+	             $delete_button = "&nbsp";
163 163
   	       }		
164
-             }else{
164
+             } else {
165 165
                $payment = '';
166 166
            }
167
-           $account_arr = $this->db_model->getSelect('first_name,number,last_name','accounts', array('id'=>$value['accountid']));
167
+           $account_arr = $this->db_model->getSelect('first_name,number,last_name', 'accounts', array('id'=>$value['accountid']));
168 168
            $account_array = $account_arr->result_array();
169
-            if($value['generate_type'] == 1){
170
-		$invoice_type='Manually';
171
-	   }else{
172
-		$invoice_type='Automatically';
169
+            if ($value['generate_type'] == 1) {
170
+		$invoice_type = 'Manually';
171
+	   } else {
172
+		$invoice_type = 'Automatically';
173 173
 	   }    
174
-	   if($value['deleted'] == 1){
175
-		$download='';
176
-		$payment='<button style="padding: 0 17px;" type="button"  class="btn btn-line-sky">Deleted</button>';
177
-		$delete_button='';
174
+	   if ($value['deleted'] == 1) {
175
+		$download = '';
176
+		$payment = '<button style="padding: 0 17px;" type="button"  class="btn btn-line-sky">Deleted</button>';
177
+		$delete_button = '';
178 178
 	   }
179 179
 	   
180
-	   if($value['deleted'] == 1){
181
-		$download='';
182
-		$payment='<button style="padding: 0 17px;" type="button"  class="btn btn-line-sky">Deleted</button>';
183
-		$delete_button='';
180
+	   if ($value['deleted'] == 1) {
181
+		$download = '';
182
+		$payment = '<button style="padding: 0 17px;" type="button"  class="btn btn-line-sky">Deleted</button>';
183
+		$delete_button = '';
184 184
 	   }
185
-		if($value['type'] == 'R'){
185
+		if ($value['type'] == 'R') {
186 186
 		$icon = '<div class="flx_font flx_magenta">R</div>';
187 187
 		}
188 188
 		else
@@ -206,281 +206,281 @@  discard block
 block discarded – undo
206 206
         		$download.''.$payment.' '.$delete_button,
207 207
 	
208 208
   		    ));
209
-          $total_value=$total_value + $value['amount'];
210
-          $ountstanding_value=$ountstanding_value + $outstanding;        
209
+          $total_value = $total_value + $value['amount'];
210
+          $ountstanding_value = $ountstanding_value + $outstanding;        
211 211
          }
212 212
          }  
213 213
         echo json_encode($json_data);
214 214
   
215 215
     }
216
-    function invoice_manually_edit($id){
216
+    function invoice_manually_edit($id) {
217 217
         $confirm = $this->common->get_field_name('confirm', 'invoices', $id);	
218 218
         $deleted = $this->common->get_field_name('deleted', 'invoices', $id);	
219
-	if($confirm == 1 || $deleted == 1){
220
-      	  redirect(base_url() . 'invoices/invoice_list/');
219
+	if ($confirm == 1 || $deleted == 1) {
220
+      	  redirect(base_url().'invoices/invoice_list/');
221 221
 	}
222
-	$data['total_tax_dis']=0;
223
-	$data['total_credit_dis']=0;
224
-         $query="SELECT  * from invoice_details where generate_type=1 AND invoiceid='$id' ";     
225
-          $invoice_total_query=$this->db->query($query);
226
-	  $data['count']=0;
227
-	  $data['row_count']=5;
222
+	$data['total_tax_dis'] = 0;
223
+	$data['total_credit_dis'] = 0;
224
+         $query = "SELECT  * from invoice_details where generate_type=1 AND invoiceid='$id' ";     
225
+          $invoice_total_query = $this->db->query($query);
226
+	  $data['count'] = 0;
227
+	  $data['row_count'] = 5;
228 228
           if ($invoice_total_query->num_rows() > 0) {
229
-	    $count=$invoice_total_query ->num_rows();
230
- 	    $data['count']=$count;
231
-	    $invoice_total_query= $invoice_total_query->result_array();
232
-	    $i=1;
233
-	    $taxi=0;
234
-	    $get_data=array();
235
-	    $data['total_tax_dis']=array();
236
-      	    foreach($invoice_total_query as $value){
237
-		if($value['item_type'] == 'TAX'){
238
-			$data['total_tax_dis'][$taxi]=$value['debit'];
229
+	    $count = $invoice_total_query ->num_rows();
230
+ 	    $data['count'] = $count;
231
+	    $invoice_total_query = $invoice_total_query->result_array();
232
+	    $i = 1;
233
+	    $taxi = 0;
234
+	    $get_data = array();
235
+	    $data['total_tax_dis'] = array();
236
+      	    foreach ($invoice_total_query as $value) {
237
+		if ($value['item_type'] == 'TAX') {
238
+			$data['total_tax_dis'][$taxi] = $value['debit'];
239 239
 			$taxi++;
240
-		}else{
241
-		     if($i >= 5){
242
-	   		     $data['row_count']=$i+1;
240
+		} else {
241
+		     if ($i >= 5) {
242
+	   		     $data['row_count'] = $i + 1;
243 243
 		     }
244
-		     $get_data['invoice_from_date_'.$i]=$value['created_date'];
245
-		     $get_data['invoice_description_'.$i]=$value['description'];
246
-		     $get_data['invoice_amount_'.$i]=$value['debit'];
244
+		     $get_data['invoice_from_date_'.$i] = $value['created_date'];
245
+		     $get_data['invoice_description_'.$i] = $value['description'];
246
+		     $get_data['invoice_amount_'.$i] = $value['debit'];
247 247
 		     $i++;
248 248
 		     $data['total_credit_dis'] += $value['debit'];	
249 249
 		}
250 250
 	    }
251
-	    $data['get_data']=$get_data;
251
+	    $data['get_data'] = $get_data;
252 252
 	  }
253 253
          $account_data = $this->session->userdata("accountinfo");
254 254
          $logintype = $this->session->userdata('logintype');
255
-         $invoice_total='';
256
-         $query="SELECT  * from invoice_details where item_type='INVPAY' AND invoiceid='$id' ORDER BY created_date ASC";
255
+         $invoice_total = '';
256
+         $query = "SELECT  * from invoice_details where item_type='INVPAY' AND invoiceid='$id' ORDER BY created_date ASC";
257 257
          $invoice = $this->db_model->getSelect("*", "invoices", array("id"=> $id));
258 258
          if ($invoice ->num_rows() > 0) {
259
-             $invoice= $invoice->result_array();
260
-             $result=$invoice[0];
261
-             $data['payment_due_date']=$result['due_date'];
259
+             $invoice = $invoice->result_array();
260
+             $result = $invoice[0];
261
+             $data['payment_due_date'] = $result['due_date'];
262 262
           }
263 263
      
264
-        	$accountdata = $this->db_model->getSelect("*","accounts",array("id"=> $result['accountid']));
264
+        	$accountdata = $this->db_model->getSelect("*", "accounts", array("id"=> $result['accountid']));
265 265
         	if ($accountdata ->num_rows() > 0) {
266
-        	   $accountdata =  $accountdata->result_array();
266
+        	   $accountdata = $accountdata->result_array();
267 267
              	   $accountdata = $accountdata[0];
268 268
         	 }
269
-		$data['taxes_count']= 0;
270
-        	$taxes = $this->db_model->getSelect("*","taxes_to_accounts",array("accountid"=> $result['accountid']));
271
-  	        $total_tax=0;
272
-		$data['taxes_count']= $taxes->num_rows();
269
+		$data['taxes_count'] = 0;
270
+        	$taxes = $this->db_model->getSelect("*", "taxes_to_accounts", array("accountid"=> $result['accountid']));
271
+  	        $total_tax = 0;
272
+		$data['taxes_count'] = $taxes->num_rows();
273 273
         	if ($taxes ->num_rows() > 0) {
274
-        	   $taxes =  $taxes->result_array();
275
-		   foreach($taxes as $tax_value){
276
-            	      $taxe_res = $this->db_model->getSelect("*","taxes",array("id"=> $tax_value['taxes_id']));
277
-        	      $taxe_res =  $taxe_res->result_array();
278
-		      foreach($taxe_res as $taxe_res_val){
279
-		      $data['taxes_to_accounts'][]= $taxe_res_val;
280
-		         $total_tax +=$taxe_res_val['taxes_rate'];
274
+        	   $taxes = $taxes->result_array();
275
+		   foreach ($taxes as $tax_value) {
276
+            	      $taxe_res = $this->db_model->getSelect("*", "taxes", array("id"=> $tax_value['taxes_id']));
277
+        	      $taxe_res = $taxe_res->result_array();
278
+		      foreach ($taxe_res as $taxe_res_val) {
279
+		      $data['taxes_to_accounts'][] = $taxe_res_val;
280
+		         $total_tax += $taxe_res_val['taxes_rate'];
281 281
 		      }
282 282
 		   }
283 283
         	 }		
284 284
 
285 285
         $system_config = common_model::$global_config['system_config'];
286
-        if($system_config["paypal_mode"]==0){
286
+        if ($system_config["paypal_mode"] == 0) {
287 287
             $data["paypal_url"] = $system_config["paypal_url"];
288 288
             $data["paypal_email_id"] = $system_config["paypal_id"];
289
-        }else{
289
+        } else {
290 290
             $data["paypal_url"] = $system_config["paypal_sandbox_url"];
291 291
             $data["paypal_email_id"] = $system_config["paypal_sandbox_id"];
292 292
          }
293 293
         $date = strtotime($result['invoice_date']);
294
-        $data['time'] = date("Y-m-d h:i:s ",$date);
294
+        $data['time'] = date("Y-m-d h:i:s ", $date);
295 295
         $data["paypal_tax"] = $system_config["paypal_tax"];
296 296
         $data["from_currency"] = $this->common->get_field_name('currency', 'currency', $account_data["currency_id"]);
297 297
         $data["to_currency"] = Common_model::$global_config['system_config']['base_currency'];
298
-	if($account_data['type'] == -1){
298
+	if ($account_data['type'] == -1) {
299 299
 		$data["to_currency"] = $data["to_currency"];
300
-	}elseif($account_data['type'] == 1){
300
+	}elseif ($account_data['type'] == 1) {
301 301
 		$accountdata["currency_id"] = $this->common->get_field_name('currency', 'currency', $account_data["currency_id"]);
302 302
 		$data["to_currency"] = $accountdata["currency_id"];
303
-	}else{
303
+	} else {
304 304
 		$accountdata["currency_id"] = $this->common->get_field_name('currency', 'currency', $account_data["currency_id"]);
305 305
 		$data["to_currency"] = $accountdata["currency_id"];
306 306
 	} 
307
-	$data['total_tax']=$total_tax;
308
- 	$data['invoice_notes']=$result['notes'];
309
- 	$data['from_date']=$result['from_date'];
310
-	$data['to_date']=$result['to_date'];
311
-	$data['invoice_date']=$result['invoice_date'];
312
-	$data['amount'] =  $this->common_model->calculate_currency($result['amount'],'','','','');
313
-	$data['invoice_prefix'] =  $result['invoice_prefix'];
314
-	$data['page_title'] =  'Invoice Summary';
315
-	$data['invoice_date']=$result['invoice_date'];
316
-	$data['return'] =base_url() . "invoices/invoice_list_modified";
317
-	$data['cancel_return'] =base_url()."invoice/invoice_list_cancel";
307
+	$data['total_tax'] = $total_tax;
308
+ 	$data['invoice_notes'] = $result['notes'];
309
+ 	$data['from_date'] = $result['from_date'];
310
+	$data['to_date'] = $result['to_date'];
311
+	$data['invoice_date'] = $result['invoice_date'];
312
+	$data['amount'] = $this->common_model->calculate_currency($result['amount'], '', '', '', '');
313
+	$data['invoice_prefix'] = $result['invoice_prefix'];
314
+	$data['page_title'] = 'Invoice Summary';
315
+	$data['invoice_date'] = $result['invoice_date'];
316
+	$data['return'] = base_url()."invoices/invoice_list_modified";
317
+	$data['cancel_return'] = base_url()."invoice/invoice_list_cancel";
318 318
 	$data['paypal_mode'] = 1;
319
-	$data['prefix_id']=$result['invoiceid'];
320
-	$data['logintype']=$logintype;
319
+	$data['prefix_id'] = $result['invoiceid'];
320
+	$data['logintype'] = $logintype;
321 321
 	$data['accountdata'] = $accountdata;
322
-	$data['id']=$id;
323
-	$data['notify_url'] = base_url() . "invoices/invoice_list_get_data";
324
-	if($account_data['type'] =='1'){
325
-		$data['response_url'] = base_url() . "invoices/invoice_list_responce/";
326
-	}else{
327
-		$data['response_url'] = base_url() . "user/user_list_responce/";
322
+	$data['id'] = $id;
323
+	$data['notify_url'] = base_url()."invoices/invoice_list_get_data";
324
+	if ($account_data['type'] == '1') {
325
+		$data['response_url'] = base_url()."invoices/invoice_list_responce/";
326
+	} else {
327
+		$data['response_url'] = base_url()."user/user_list_responce/";
328 328
 	}
329
-	$data['sucess_url'] = base_url() . "invoices/invoice_list_sucess";
330
-     	$this->load->view('view_invoice_edit_manually',$data);
329
+	$data['sucess_url'] = base_url()."invoices/invoice_list_sucess";
330
+     	$this->load->view('view_invoice_edit_manually', $data);
331 331
     }
332
-    function invoice_automatically_edit($id){
332
+    function invoice_automatically_edit($id) {
333 333
         $confirm = $this->common->get_field_name('confirm', 'invoices', $id);	
334 334
         $deleted = $this->common->get_field_name('deleted', 'invoices', $id);	
335
-	if($confirm == 1 || $deleted == 1){
336
-      	  redirect(base_url() . 'invoices/invoice_list/');
335
+	if ($confirm == 1 || $deleted == 1) {
336
+      	  redirect(base_url().'invoices/invoice_list/');
337 337
 	}
338
-	$data['total_tax_dis']=0;
339
-	$data['total_credit_dis']=0;
340
-         $query="SELECT  * from invoice_details where invoiceid='$id' ";     
341
-          $invoice_total_query=$this->db->query($query);
342
-	  $data['count']=0;
343
-	  $data['row_count']=5;
338
+	$data['total_tax_dis'] = 0;
339
+	$data['total_credit_dis'] = 0;
340
+         $query = "SELECT  * from invoice_details where invoiceid='$id' ";     
341
+          $invoice_total_query = $this->db->query($query);
342
+	  $data['count'] = 0;
343
+	  $data['row_count'] = 5;
344 344
           if ($invoice_total_query->num_rows() > 0) {
345
-	    $count=$invoice_total_query ->num_rows();
346
- 	    $data['count']=$count;
347
-	    $invoice_total_query= $invoice_total_query->result_array();
348
-	    $i=1;$taxi=0;
349
-	    $get_data=array();
350
-	    $data['total_tax_dis']=array();
351
-	    $data['total_credit_sum']=0;
352
-      	    foreach($invoice_total_query as $value){
353
-		if($value['item_type'] == 'TAX'){
354
-			$data['total_tax_dis'][$taxi]=$value['debit'];
345
+	    $count = $invoice_total_query ->num_rows();
346
+ 	    $data['count'] = $count;
347
+	    $invoice_total_query = $invoice_total_query->result_array();
348
+	    $i = 1; $taxi = 0;
349
+	    $get_data = array();
350
+	    $data['total_tax_dis'] = array();
351
+	    $data['total_credit_sum'] = 0;
352
+      	    foreach ($invoice_total_query as $value) {
353
+		if ($value['item_type'] == 'TAX') {
354
+			$data['total_tax_dis'][$taxi] = $value['debit'];
355 355
 			$taxi++;
356
-		}else{
357
-		   if($value['generate_type'] == 1){
358
-		     if($i >= 5){
359
-	   		     $data['row_count']=$i+1;
356
+		} else {
357
+		   if ($value['generate_type'] == 1) {
358
+		     if ($i >= 5) {
359
+	   		     $data['row_count'] = $i + 1;
360 360
 		     }
361
-		     $get_data['invoice_from_date_'.$i]=$value['created_date'];
362
-		     $get_data['invoice_description_'.$i]=$value['description'];
363
-		     $get_data['invoice_amount_'.$i]=$value['debit'];
361
+		     $get_data['invoice_from_date_'.$i] = $value['created_date'];
362
+		     $get_data['invoice_description_'.$i] = $value['description'];
363
+		     $get_data['invoice_amount_'.$i] = $value['debit'];
364 364
 		     $i++;	
365 365
 		     $data['total_credit_dis'] += $value['debit'];	
366 366
 		   }
367 367
 		     $data['total_credit_sum'] += $value['debit'];	
368 368
 		}
369 369
 	    }
370
-	    $data['get_data']=$get_data;
370
+	    $data['get_data'] = $get_data;
371 371
 	  }
372 372
          $account_data = $this->session->userdata("accountinfo");
373 373
          $logintype = $this->session->userdata('logintype');
374
-         $invoice_total='';
375
-         $query="SELECT  * from invoice_details where invoiceid='$id' and generate_type=0 and item_type != 'TAX'  ORDER BY id ASC";
376
-          $invoice_total_query=$this->db->query($query);
377
-	  $data['auto_count']=0;
374
+         $invoice_total = '';
375
+         $query = "SELECT  * from invoice_details where invoiceid='$id' and generate_type=0 and item_type != 'TAX'  ORDER BY id ASC";
376
+          $invoice_total_query = $this->db->query($query);
377
+	  $data['auto_count'] = 0;
378 378
           if ($invoice_total_query ->num_rows() > 0) {
379
-	  $data['auto_count']=$invoice_total_query ->num_rows();		
380
-            $invoice_total_query= $invoice_total_query->result_array();
379
+	  $data['auto_count'] = $invoice_total_query ->num_rows();		
380
+            $invoice_total_query = $invoice_total_query->result_array();
381 381
          
382
-            $data['invoice_total_query']=$invoice_total_query;
382
+            $data['invoice_total_query'] = $invoice_total_query;
383 383
           }
384 384
          $invoice = $this->db_model->getSelect("*", "invoices", array("id"=> $id));
385 385
          if ($invoice ->num_rows() > 0) {
386
-             $invoice= $invoice->result_array();
387
-             $result=$invoice[0];
388
-             $data['payment_due_date']=$result['due_date'];
386
+             $invoice = $invoice->result_array();
387
+             $result = $invoice[0];
388
+             $data['payment_due_date'] = $result['due_date'];
389 389
           }
390
-         $invoice_auto_res = $this->db_model->getSelect("sum(debit) as debit", "invoice_details", array("invoiceid"=> $id,'generate_type'=>0));
391
-	 $data['invoice_auto_res']=0;
390
+         $invoice_auto_res = $this->db_model->getSelect("sum(debit) as debit", "invoice_details", array("invoiceid"=> $id, 'generate_type'=>0));
391
+	 $data['invoice_auto_res'] = 0;
392 392
          if ($invoice_auto_res ->num_rows() > 0) {
393
-             $invoice_auto_res= $invoice_auto_res->result_array();
394
-             $result_auto_res=$invoice_auto_res[0];
395
-	     $data['invoice_auto_res']	=$result_auto_res['debit'];
393
+             $invoice_auto_res = $invoice_auto_res->result_array();
394
+             $result_auto_res = $invoice_auto_res[0];
395
+	     $data['invoice_auto_res'] = $result_auto_res['debit'];
396 396
           }
397 397
      
398
-        	$accountdata = $this->db_model->getSelect("*","accounts",array("id"=> $result['accountid']));
398
+        	$accountdata = $this->db_model->getSelect("*", "accounts", array("id"=> $result['accountid']));
399 399
         	if ($accountdata ->num_rows() > 0) {
400
-        	   $accountdata =  $accountdata->result_array();
400
+        	   $accountdata = $accountdata->result_array();
401 401
              $accountdata = $accountdata[0];
402 402
         	 }
403
-		$data['taxes_count']= 0;
404
-        	$taxes = $this->db_model->getSelect("*","taxes_to_accounts",array("accountid"=> $result['accountid']));
405
-		$data['taxes_count']= $taxes->num_rows();
406
- 	        $total_tax=0;
403
+		$data['taxes_count'] = 0;
404
+        	$taxes = $this->db_model->getSelect("*", "taxes_to_accounts", array("accountid"=> $result['accountid']));
405
+		$data['taxes_count'] = $taxes->num_rows();
406
+ 	        $total_tax = 0;
407 407
         	if ($taxes ->num_rows() > 0) {
408
-        	   $taxes =  $taxes->result_array();
409
-		   foreach($taxes as $tax_value){
410
-            	      $taxe_res = $this->db_model->getSelect("*","taxes",array("id"=> $tax_value['taxes_id']));
411
-        	      $taxe_res =  $taxe_res->result_array();
412
-		      foreach($taxe_res as $taxe_res_val){
413
-		      $data['taxes_to_accounts'][]= $taxe_res_val;
414
-		         $total_tax +=$taxe_res_val['taxes_rate'];
408
+        	   $taxes = $taxes->result_array();
409
+		   foreach ($taxes as $tax_value) {
410
+            	      $taxe_res = $this->db_model->getSelect("*", "taxes", array("id"=> $tax_value['taxes_id']));
411
+        	      $taxe_res = $taxe_res->result_array();
412
+		      foreach ($taxe_res as $taxe_res_val) {
413
+		      $data['taxes_to_accounts'][] = $taxe_res_val;
414
+		         $total_tax += $taxe_res_val['taxes_rate'];
415 415
 		      }
416 416
 		   }
417 417
         	 }		
418 418
 
419 419
         $system_config = common_model::$global_config['system_config'];
420
-        if($system_config["paypal_mode"]==0){
420
+        if ($system_config["paypal_mode"] == 0) {
421 421
             $data["paypal_url"] = $system_config["paypal_url"];
422 422
             $data["paypal_email_id"] = $system_config["paypal_id"];
423
-        }else{
423
+        } else {
424 424
             $data["paypal_url"] = $system_config["paypal_sandbox_url"];
425 425
             $data["paypal_email_id"] = $system_config["paypal_sandbox_id"];
426 426
          }
427 427
         $date = strtotime($result['invoice_date']);
428
- 	$data['total_tax']=$total_tax;
429
-        $data['time'] = date("Y-m-d h:i:s ",$date);
428
+ 	$data['total_tax'] = $total_tax;
429
+        $data['time'] = date("Y-m-d h:i:s ", $date);
430 430
         $data["paypal_tax"] = $system_config["paypal_tax"];
431 431
         $data["from_currency"] = $this->common->get_field_name('currency', 'currency', $account_data["currency_id"]);
432 432
         $data["to_currency"] = Common_model::$global_config['system_config']['base_currency'];
433
-	if($account_data['type'] == -1){
433
+	if ($account_data['type'] == -1) {
434 434
 	  $accountdata["currency_id"] = $this->common->get_field_name('currency', 'currency', $account_data["currency_id"]);
435 435
           $data["to_currency"] = $accountdata["currency_id"];
436
-	}elseif($account_data['type'] == 1){
436
+	}elseif ($account_data['type'] == 1) {
437 437
 		$accountdata["currency_id"] = $this->common->get_field_name('currency', 'currency', $account_data["currency_id"]);
438 438
 		$data["to_currency"] = $accountdata["currency_id"];
439
-	}else{
439
+	} else {
440 440
 		$accountdata["currency_id"] = $this->common->get_field_name('currency', 'currency', $account_data["currency_id"]);
441 441
 		$data["to_currency"] = $accountdata["currency_id"];
442 442
 	} 
443
- 	$data['from_date']=$result['from_date'];
444
-	$data['to_date']=$result['to_date'];
445
- 	$data['invoice_notes']=$result['notes'];
446
-	$data['invoice_date']=$result['invoice_date'];
447
-	$data['amount'] =  $this->common_model->calculate_currency($result['amount'],'','','','');
448
-	$data['invoice_prefix'] =  $result['invoice_prefix'];
449
-	$data['page_title'] =  'Invoice Summary';
450
-	$data['invoice_date']=$result['invoice_date'];
451
-	$data['return'] =base_url() . "invoices/invoice_list_modified";
452
-	$data['cancel_return'] =base_url()."invoice/invoice_list_cancel";
443
+ 	$data['from_date'] = $result['from_date'];
444
+	$data['to_date'] = $result['to_date'];
445
+ 	$data['invoice_notes'] = $result['notes'];
446
+	$data['invoice_date'] = $result['invoice_date'];
447
+	$data['amount'] = $this->common_model->calculate_currency($result['amount'], '', '', '', '');
448
+	$data['invoice_prefix'] = $result['invoice_prefix'];
449
+	$data['page_title'] = 'Invoice Summary';
450
+	$data['invoice_date'] = $result['invoice_date'];
451
+	$data['return'] = base_url()."invoices/invoice_list_modified";
452
+	$data['cancel_return'] = base_url()."invoice/invoice_list_cancel";
453 453
 	$data['paypal_mode'] = 1;
454
-	$data['prefix_id']=$result['invoiceid'];
455
-	$data['logintype']=$logintype;
454
+	$data['prefix_id'] = $result['invoiceid'];
455
+	$data['logintype'] = $logintype;
456 456
 	$data['accountdata'] = $accountdata;
457
-	$data['id']=$id;
458
-	$data['notify_url'] = base_url() . "invoices/invoice_list_get_data";
459
-	if($account_data['type'] =='1'){
460
-		$data['response_url'] = base_url() . "invoices/invoice_list_responce/";
461
-	}else{
462
-		$data['response_url'] = base_url() . "user/user_list_responce/";
457
+	$data['id'] = $id;
458
+	$data['notify_url'] = base_url()."invoices/invoice_list_get_data";
459
+	if ($account_data['type'] == '1') {
460
+		$data['response_url'] = base_url()."invoices/invoice_list_responce/";
461
+	} else {
462
+		$data['response_url'] = base_url()."user/user_list_responce/";
463 463
 	}
464
-	$data['sucess_url'] = base_url() . "invoices/invoice_list_sucess";
464
+	$data['sucess_url'] = base_url()."invoices/invoice_list_sucess";
465 465
 
466
-     	$this->load->view('view_invoice_edit_automatically',$data);
466
+     	$this->load->view('view_invoice_edit_automatically', $data);
467 467
     }
468
-    function invoice_manually_payment_edit_save(){
469
-	$response_arr=$_POST;
470
-	if(isset($response_arr['save'])){
471
-	   $confirm=0;
472
-	}else{
473
-	   $confirm=1;
468
+    function invoice_manually_payment_edit_save() {
469
+	$response_arr = $_POST;
470
+	if (isset($response_arr['save'])) {
471
+	   $confirm = 0;
472
+	} else {
473
+	   $confirm = 1;
474 474
 	}
475
-	$where=array('invoiceid'=>$response_arr['invoiceid'],'generate_type'=>1);
475
+	$where = array('invoiceid'=>$response_arr['invoiceid'], 'generate_type'=>1);
476 476
         $this->db->where($where);
477 477
         $this->db->delete("invoice_details");
478
-	$final_bal=0;	
479
-	$final_tax_bal=0;
478
+	$final_bal = 0;	
479
+	$final_tax_bal = 0;
480 480
         $account_balance = $this->common->get_field_name('balance', 'accounts', $response_arr['accountid']);
481
-	if($response_arr['taxes_count'] > 0){	
482
-	for($a=0 ;$a < $response_arr['taxes_count'];$a++){
483
-		$add_arr=array(
481
+	if ($response_arr['taxes_count'] > 0) {	
482
+	for ($a = 0; $a < $response_arr['taxes_count']; $a++) {
483
+		$add_arr = array(
484 484
 			  'accountid'=>$response_arr['accountid'],
485 485
 			  'reseller_id'=>$response_arr['reseller_id'],
486 486
 			  'invoiceid'=>$response_arr['invoiceid'],
@@ -488,16 +488,16 @@  discard block
 block discarded – undo
488 488
 			  'generate_type'=>1,
489 489
 			  'item_type'=>'TAX',
490 490
 			  'description'=>$response_arr['description_total_tax_input_'.$a],
491
-			  'debit'=>$this->common_model->add_calculate_currency($response_arr['abc_total_tax_input_'.$a],"","",true,false),
491
+			  'debit'=>$this->common_model->add_calculate_currency($response_arr['abc_total_tax_input_'.$a], "", "", true, false),
492 492
 			  'created_date'=>gmdate("Y-m-d H:i:s"),
493 493
 			);
494
-		 $final_tax_bal +=$this->common_model->add_calculate_currency($response_arr['abc_total_tax_input_'.$a],"","",true,false);	
495
-	       	 $this->db->insert("invoice_details",$add_arr);
494
+		 $final_tax_bal += $this->common_model->add_calculate_currency($response_arr['abc_total_tax_input_'.$a], "", "", true, false);	
495
+	       	 $this->db->insert("invoice_details", $add_arr);
496 496
 	}
497 497
 	}
498 498
 	for ($i = 1; $i <= $response_arr['row_count']; $i++) {
499
-		if($response_arr['invoice_amount_'.$i] != ''){
500
-			$add_arr=array(
499
+		if ($response_arr['invoice_amount_'.$i] != '') {
500
+			$add_arr = array(
501 501
 			  'accountid'=>$response_arr['accountid'],
502 502
 			  'reseller_id'=>$response_arr['reseller_id'],
503 503
 			  'invoiceid'=>$response_arr['invoiceid'],
@@ -505,29 +505,29 @@  discard block
 block discarded – undo
505 505
 			  'generate_type'=>1,
506 506
 			  'item_type'=>'manual_inv',
507 507
 			  'description'=>$response_arr['invoice_description_'.$i],
508
-			  'debit'=>$this->common_model->add_calculate_currency($response_arr['invoice_amount_'.$i],"","",true,false),
508
+			  'debit'=>$this->common_model->add_calculate_currency($response_arr['invoice_amount_'.$i], "", "", true, false),
509 509
 			  'created_date'=>$response_arr['invoice_from_date_'.$i],
510 510
 			);
511
-	       	 $this->db->insert("invoice_details",$add_arr);	
511
+	       	 $this->db->insert("invoice_details", $add_arr);	
512 512
 		}
513
-		$final_bal += $this->common_model->add_calculate_currency($response_arr['invoice_amount_'.$i],"","",true,false);
513
+		$final_bal += $this->common_model->add_calculate_currency($response_arr['invoice_amount_'.$i], "", "", true, false);
514 514
 	  }
515
-          $query="select  sum(debit) as credit from invoice_details where invoiceid = ".$response_arr['invoiceid']; 
516
-          $invoice_total_query=$this->db->query($query);
517
-          $invoice_total_query= $invoice_total_query->result_array();
518
-          $data = array('amount' =>$this->common_model->add_calculate_currency($response_arr['total_val_final'],"","",true,false),'confirm'=>$confirm,'notes'=>$response_arr['invoice_notes']);
515
+          $query = "select  sum(debit) as credit from invoice_details where invoiceid = ".$response_arr['invoiceid']; 
516
+          $invoice_total_query = $this->db->query($query);
517
+          $invoice_total_query = $invoice_total_query->result_array();
518
+          $data = array('amount' =>$this->common_model->add_calculate_currency($response_arr['total_val_final'], "", "", true, false), 'confirm'=>$confirm, 'notes'=>$response_arr['invoice_notes']);
519 519
           $this->db->where("id", $response_arr['invoiceid']);        
520 520
           $this->db->update("invoices", $data);
521
-	if($confirm == 1){
521
+	if ($confirm == 1) {
522 522
 		$invoice_details = $this->db_model->getSelect("*", "invoice_details", array("invoiceid" => $response_arr["invoiceid"]));
523
-		if($invoice_details->num_rows >0){
523
+		if ($invoice_details->num_rows > 0) {
524 524
 			$invoice_details_res = $invoice_details->result_array();
525
-			$after_bal=0;
526
-			foreach($invoice_details_res as $details_key=>$details_value){
527
-				$before_balance_add=$account_balance-$after_bal;
528
-				$after_balance_add=$before_balance_add-$details_value['debit'];
529
-				$balnace_update=array('before_balance'=>$before_balance_add,'after_balance'=>$after_balance_add);
530
-				$after_bal +=$details_value['debit'];
525
+			$after_bal = 0;
526
+			foreach ($invoice_details_res as $details_key=>$details_value) {
527
+				$before_balance_add = $account_balance - $after_bal;
528
+				$after_balance_add = $before_balance_add - $details_value['debit'];
529
+				$balnace_update = array('before_balance'=>$before_balance_add, 'after_balance'=>$after_balance_add);
530
+				$after_bal += $details_value['debit'];
531 531
 				$this->db->where("id", $details_value['id']);
532 532
 				$this->db->update("invoice_details", $balnace_update);       
533 533
 			}
@@ -535,21 +535,21 @@  discard block
 block discarded – undo
535 535
 
536 536
 		$account_data = $this->db_model->getSelect("*", "accounts", array("id" => $response_arr["accountid"]));
537 537
 		$account_data = $account_data->result_array();
538
-		if($account_data[0]['posttoexternal'] == 1){
539
-			$bal_data=$account_data[0]['balance']-$this->common_model->add_calculate_currency($response_arr['total_val_final'],"","",true,false);
540
-		}else{
541
-			$bal_data=$account_data[0]['balance']-$this->common_model->add_calculate_currency($response_arr['total_val_final'],"","",true,false);
542
-			if($response_arr['reseller_id'] == 0){
543
-				$payment=1;
544
-			}else{
545
-				$payment=$response_arr['reseller_id'];
538
+		if ($account_data[0]['posttoexternal'] == 1) {
539
+			$bal_data = $account_data[0]['balance'] - $this->common_model->add_calculate_currency($response_arr['total_val_final'], "", "", true, false);
540
+		} else {
541
+			$bal_data = $account_data[0]['balance'] - $this->common_model->add_calculate_currency($response_arr['total_val_final'], "", "", true, false);
542
+			if ($response_arr['reseller_id'] == 0) {
543
+				$payment = 1;
544
+			} else {
545
+				$payment = $response_arr['reseller_id'];
546 546
 			}
547 547
 		        $invoice_prefix = $this->common->get_field_name('invoice_prefix', 'invoices', $response_arr['invoiceid']);
548 548
 		        $invoice_prefix_id = $this->common->get_field_name('invoiceid', 'invoices', $response_arr['invoiceid']);
549
-                        $payment_arr = array("accountid"=> $response_arr["accountid"],"payment_mode"=>"1","credit"=>$this->common_model->add_calculate_currency($response_arr['total_val_final'],"","",true,false),"type"=>"invoice","payment_by"=>$payment,"notes"=>"Payment made by ".$account_data[0]['first_name']." ".$account_data[0]['last_name'].", invoices No: ".$invoice_prefix ."_".$invoice_prefix_id." ","paypalid"=>'',"txn_id"=>'','payment_date'=>gmdate('Y-m-d H:i:s'));
549
+                        $payment_arr = array("accountid"=> $response_arr["accountid"], "payment_mode"=>"1", "credit"=>$this->common_model->add_calculate_currency($response_arr['total_val_final'], "", "", true, false), "type"=>"invoice", "payment_by"=>$payment, "notes"=>"Payment made by ".$account_data[0]['first_name']." ".$account_data[0]['last_name'].", invoices No: ".$invoice_prefix."_".$invoice_prefix_id." ", "paypalid"=>'', "txn_id"=>'', 'payment_date'=>gmdate('Y-m-d H:i:s'));
550 550
 	            $this->db->insert('payments', $payment_arr);
551 551
 	        $account_balance = $this->common->get_field_name('balance', 'accounts', $response_arr['accountid']);
552
-		$add_arr=array(
552
+		$add_arr = array(
553 553
 			  'accountid'=>$response_arr['accountid'],
554 554
 			  'reseller_id'=>$response_arr['reseller_id'],
555 555
 			  'invoiceid'=>$response_arr['invoiceid'],
@@ -557,60 +557,60 @@  discard block
 block discarded – undo
557 557
 			  'generate_type'=>1,
558 558
 			  'item_type'=>'INVPAY',
559 559
 			  'description'=>'Prepaid invoice generate',
560
-			  'credit'=>$this->common_model->add_calculate_currency($response_arr['total_val_final'],"","",true,false),
560
+			  'credit'=>$this->common_model->add_calculate_currency($response_arr['total_val_final'], "", "", true, false),
561 561
 			  'created_date'=>gmdate("Y-m-d H:i:s"),
562 562
 			  'before_balance'=>$account_balance,
563
-			  'after_balance'=>$account_balance-$this->common_model->add_calculate_currency($response_arr['total_val_final'],"","",true,false),
563
+			  'after_balance'=>$account_balance - $this->common_model->add_calculate_currency($response_arr['total_val_final'], "", "", true, false),
564 564
 			);
565
-	       	 $this->db->insert("invoice_details",$add_arr);
565
+	       	 $this->db->insert("invoice_details", $add_arr);
566 566
 		}
567 567
 		$this->db->where("id", $response_arr['accountid']);        
568
-		$act_status=0;
569
-		if($bal_data < 0 && $account_data[0]['posttoexternal'] == 0){
570
-			$act_status=1;
568
+		$act_status = 0;
569
+		if ($bal_data < 0 && $account_data[0]['posttoexternal'] == 0) {
570
+			$act_status = 1;
571 571
 		}     
572
-		$balance_data = array('balance' => $bal_data,'status'=>$act_status);
572
+		$balance_data = array('balance' => $bal_data, 'status'=>$act_status);
573 573
 		$this->db->update("accounts", $balance_data);
574 574
 /*** invoice mail ***/
575
-		$this->invoice_send_notification($response_arr['invoiceid'],$account_data[0],'manually');
575
+		$this->invoice_send_notification($response_arr['invoiceid'], $account_data[0], 'manually');
576 576
 /***** ***/
577 577
 	}
578 578
           $this->session->set_flashdata('astpp_errormsg', 'Invoice updated successfully!'); 
579
-      	  redirect(base_url() . 'invoices/invoice_list/');
579
+      	  redirect(base_url().'invoices/invoice_list/');
580 580
     }
581
-    function invoice_automatically_payment_edit_save(){
582
-	$response_arr=$_POST;
583
-	if(isset($response_arr['save'])){
584
-	   $confirm=0;
585
-	}else{
586
-	   $confirm=1;
581
+    function invoice_automatically_payment_edit_save() {
582
+	$response_arr = $_POST;
583
+	if (isset($response_arr['save'])) {
584
+	   $confirm = 0;
585
+	} else {
586
+	   $confirm = 1;
587 587
 	}
588
-	foreach($response_arr['auto_invoice_date'] as $key=>$val){
589
-          $data = array('debit' => $this->common_model->add_calculate_currency($response_arr['auto_invoice_amount'][$key],"","",true,false),'created_date'=>$response_arr['auto_invoice_date'][$key],'description'=>$response_arr['auto_invoice_description'][$key],'generate_type'=>0);
588
+	foreach ($response_arr['auto_invoice_date'] as $key=>$val) {
589
+          $data = array('debit' => $this->common_model->add_calculate_currency($response_arr['auto_invoice_amount'][$key], "", "", true, false), 'created_date'=>$response_arr['auto_invoice_date'][$key], 'description'=>$response_arr['auto_invoice_description'][$key], 'generate_type'=>0);
590 590
           $this->db->where("id", $key);        
591 591
           $this->db->update("invoice_details", $data);
592 592
 
593 593
 	}
594
-	$where=array('invoiceid'=>$response_arr['invoiceid'],'generate_type'=>1);
594
+	$where = array('invoiceid'=>$response_arr['invoiceid'], 'generate_type'=>1);
595 595
         $this->db->where($where);
596 596
         $this->db->delete("invoice_details");
597
-	$final_bal=0;
598
-	$final_tax_bal=0;
597
+	$final_bal = 0;
598
+	$final_tax_bal = 0;
599 599
         $account_balance = $this->common->get_field_name('balance', 'accounts', $response_arr['accountid']);	
600
-	if($response_arr['taxes_count'] > 0){
601
-	for($a=0 ;$a < $response_arr['row_count'];$a++){
602
-		$arr_update=array('item_type'=>'TAX','id'=>$response_arr['description_total_tax_id_'.$a]);
600
+	if ($response_arr['taxes_count'] > 0) {
601
+	for ($a = 0; $a < $response_arr['row_count']; $a++) {
602
+		$arr_update = array('item_type'=>'TAX', 'id'=>$response_arr['description_total_tax_id_'.$a]);
603 603
 		$this->db->where($arr_update);
604
-		$update_arr=array(
605
-			  'debit'=>$this->common_model->add_calculate_currency($response_arr['abc_total_tax_input_'.$a],"","",true,false),
604
+		$update_arr = array(
605
+			  'debit'=>$this->common_model->add_calculate_currency($response_arr['abc_total_tax_input_'.$a], "", "", true, false),
606 606
 			);
607
-		 $final_tax_bal +=$this->common_model->add_calculate_currency($response_arr['abc_total_tax_input_'.$a],"","",true,false);	
608
-	       	 $this->db->update("invoice_details",$update_arr);
607
+		 $final_tax_bal += $this->common_model->add_calculate_currency($response_arr['abc_total_tax_input_'.$a], "", "", true, false);	
608
+	       	 $this->db->update("invoice_details", $update_arr);
609 609
 	}
610 610
 	}
611
-	     for ($i = 1; $i <=$response_arr['row_count']; $i++) {
612
-		if($response_arr['invoice_amount_'.$i] != ''){
613
-			$add_arr=array(
611
+	     for ($i = 1; $i <= $response_arr['row_count']; $i++) {
612
+		if ($response_arr['invoice_amount_'.$i] != '') {
613
+			$add_arr = array(
614 614
 			  'accountid'=>$response_arr['accountid'],
615 615
 			  'reseller_id'=>$response_arr['reseller_id'],
616 616
 			  'invoiceid'=>$response_arr['invoiceid'],
@@ -618,29 +618,29 @@  discard block
 block discarded – undo
618 618
 			  'generate_type'=>1,
619 619
 			  'item_type'=>'manual_inv',
620 620
 			  'description'=>$response_arr['invoice_description_'.$i],
621
-			  'debit'=>$this->common_model->add_calculate_currency($response_arr['invoice_amount_'.$i],"","",true,false),
621
+			  'debit'=>$this->common_model->add_calculate_currency($response_arr['invoice_amount_'.$i], "", "", true, false),
622 622
 			  'created_date'=>$response_arr['invoice_from_date_'.$i],
623 623
 			);
624
-	       	 $this->db->insert("invoice_details",$add_arr);	
624
+	       	 $this->db->insert("invoice_details", $add_arr);	
625 625
 		}
626 626
 	    }
627
-        $query="select  sum(debit) as credit from invoice_details where invoiceid = ".$response_arr['invoiceid']; 
628
-        $invoice_total_query=$this->db->query($query);
629
-        $invoice_total_query= $invoice_total_query->result_array();
630
-        $data = array('amount' => $this->common_model->add_calculate_currency($response_arr['total_val_final'],"","",true,false),'confirm'=>$confirm,'notes'=>$response_arr['invoice_notes']);
627
+        $query = "select  sum(debit) as credit from invoice_details where invoiceid = ".$response_arr['invoiceid']; 
628
+        $invoice_total_query = $this->db->query($query);
629
+        $invoice_total_query = $invoice_total_query->result_array();
630
+        $data = array('amount' => $this->common_model->add_calculate_currency($response_arr['total_val_final'], "", "", true, false), 'confirm'=>$confirm, 'notes'=>$response_arr['invoice_notes']);
631 631
         $this->db->where("id", $response_arr['invoiceid']);        
632 632
         $this->db->update("invoices", $data);
633
-	if($confirm == 1){
633
+	if ($confirm == 1) {
634 634
 		$invoice_details = $this->db_model->getSelect("*", "invoice_details", array("invoiceid" => $response_arr["invoiceid"]));
635
-		if($invoice_details->num_rows >0){
635
+		if ($invoice_details->num_rows > 0) {
636 636
 			$invoice_details_res = $invoice_details->result_array();
637
-			$after_bal=0;
638
-			foreach($invoice_details_res as $details_key=>$details_value){
639
-			   if($details_value['item_type'] != 'STANDARD'){
640
-				$before_balance_add=$account_balance-$after_bal;
641
-				$after_balance_add=$before_balance_add-$details_value['debit'];
642
-				$balnace_update=array('before_balance'=>$before_balance_add,'after_balance'=>$after_balance_add);
643
-				$after_bal +=$details_value['debit'];
637
+			$after_bal = 0;
638
+			foreach ($invoice_details_res as $details_key=>$details_value) {
639
+			   if ($details_value['item_type'] != 'STANDARD') {
640
+				$before_balance_add = $account_balance - $after_bal;
641
+				$after_balance_add = $before_balance_add - $details_value['debit'];
642
+				$balnace_update = array('before_balance'=>$before_balance_add, 'after_balance'=>$after_balance_add);
643
+				$after_bal += $details_value['debit'];
644 644
 				$this->db->where("id", $details_value['id']);
645 645
 				$this->db->update("invoice_details", $balnace_update);       
646 646
 			   }			   
@@ -648,262 +648,262 @@  discard block
 block discarded – undo
648 648
 		}
649 649
 		$account_data = $this->db_model->getSelect("*", "accounts", array("id" => $response_arr["accountid"]));
650 650
 		$account_data = $account_data->result_array();
651
-		$invoice_not_deduct= $this->db_model->getSelect("*", "invoice_details", array("invoiceid" =>$response_arr['invoiceid']));
652
-		$standard_call_balance=0;
651
+		$invoice_not_deduct = $this->db_model->getSelect("*", "invoice_details", array("invoiceid" =>$response_arr['invoiceid']));
652
+		$standard_call_balance = 0;
653 653
 		$invoice_not_deduct = $invoice_not_deduct->result_array();
654
-		foreach($invoice_not_deduct as $key=>$invoice_nodeduct_val){
655
-			if($invoice_nodeduct_val['item_type'] == 'STANDARD'){
656
-			   $standard_call_balance=$invoice_nodeduct_val['debit'];
654
+		foreach ($invoice_not_deduct as $key=>$invoice_nodeduct_val) {
655
+			if ($invoice_nodeduct_val['item_type'] == 'STANDARD') {
656
+			   $standard_call_balance = $invoice_nodeduct_val['debit'];
657 657
 			}
658 658
 		}
659
-		if($account_data[0]['posttoexternal'] == 1){
660
-			$finaldeduct_bal=$response_arr['total_val_final']-$standard_call_balance;
661
-			$bal_data=$account_data[0]['balance']-$finaldeduct_bal;
659
+		if ($account_data[0]['posttoexternal'] == 1) {
660
+			$finaldeduct_bal = $response_arr['total_val_final'] - $standard_call_balance;
661
+			$bal_data = $account_data[0]['balance'] - $finaldeduct_bal;
662 662
 		}
663 663
 		$this->db->where("id", $response_arr['accountid']);        
664 664
 		$balance_data = array('balance' => $bal_data);
665 665
 		$this->db->update("accounts", $balance_data);
666 666
 /*** invoice mail ***/
667
-		$this->invoice_send_notification($response_arr['invoiceid'],$account_data[0],'auto');
667
+		$this->invoice_send_notification($response_arr['invoiceid'], $account_data[0], 'auto');
668 668
 /***** ***/
669 669
 	}
670 670
         $this->session->set_flashdata('astpp_errormsg', 'Invoice updated successfully!'); 
671
-  	redirect(base_url() . 'invoices/invoice_list/');
671
+  	redirect(base_url().'invoices/invoice_list/');
672 672
     }   
673
-    function invoice_send_notification($invoice_id,$accountdata,$inv_flag){
673
+    function invoice_send_notification($invoice_id, $accountdata, $inv_flag) {
674 674
 		$invoicedata = $this->db_model->getSelect("*", "invoices", array("id" => $invoice_id));
675 675
 		$invoicedata = $invoicedata->result_array();
676
-		$invoicedata =$invoicedata[0];
676
+		$invoicedata = $invoicedata[0];
677 677
          	//$res = $this->common->get_invoice_template($invoicedata,$accountdata,"False");
678
-		$invoice_conf =  array();
679
-		if($accountdata['reseller_id'] == 0){
678
+		$invoice_conf = array();
679
+		if ($accountdata['reseller_id'] == 0) {
680 680
 			$where = array("accountid"=> 1);
681
-		}else{
681
+		} else {
682 682
 			$where = array("accountid"=> $accountdata['reseller_id']);    
683 683
 		}
684 684
 		$query = $this->db_model->getSelect("*", "invoice_conf", $where);
685
-		if($query->num_rows >0){
685
+		if ($query->num_rows > 0) {
686 686
 			$invoice_conf = $query->result_array();
687 687
 			$invoice_conf = $invoice_conf[0];
688
-		}else{
689
-			$query = $this->db_model->getSelect("*", "invoice_conf",array("accountid"=> 1));
688
+		} else {
689
+			$query = $this->db_model->getSelect("*", "invoice_conf", array("accountid"=> 1));
690 690
 			$invoice_conf = $query->result_array();
691 691
 			$invoice_conf = $invoice_conf[0];            
692 692
 		}
693
-		 $template_config=$this->config->item('invoice_screen');
693
+		 $template_config = $this->config->item('invoice_screen');
694 694
                  include($template_config.'generateInvoice.php');
695 695
                  $generateInvoice = new generateInvoice();
696
-                 $generateInvoice->download_invoice($invoicedata['id'],$accountdata,$invoice_conf,$inv_flag);
696
+                 $generateInvoice->download_invoice($invoicedata['id'], $accountdata, $invoice_conf, $inv_flag);
697 697
 		return true;
698 698
    }   
699
-    function currency_decimal($amount){
700
-    $decimal_amount=Common_model::$global_config['system_config']['decimalpoints_total'];
701
-    $number_convert=number_format((float)$amount,$decimal_amount, '.', '');
699
+    function currency_decimal($amount) {
700
+    $decimal_amount = Common_model::$global_config['system_config']['decimalpoints_total'];
701
+    $number_convert = number_format((float)$amount, $decimal_amount, '.', '');
702 702
     return $number_convert;
703 703
     }
704
-    function invoice_summary($id){
705
-         $query="SELECT  * from invoice_details where  invoiceid='$id' ";
704
+    function invoice_summary($id) {
705
+         $query = "SELECT  * from invoice_details where  invoiceid='$id' ";
706 706
         
707
-          $invoice_total_query=$this->db->query($query);
707
+          $invoice_total_query = $this->db->query($query);
708 708
           if ($invoice_total_query ->num_rows() > 0) {
709
-              $invoice_final_query =  $invoice_total_query->result_array();
710
-              $data['invoice_final_query']=$invoice_final_query;
709
+              $invoice_final_query = $invoice_total_query->result_array();
710
+              $data['invoice_final_query'] = $invoice_final_query;
711 711
           
712 712
          $account_data = $this->session->userdata("accountinfo");
713 713
          $logintype = $this->session->userdata('logintype');
714
-         $invoice_total='';
715
-         $query="SELECT  * from invoice_details where item_type='INVPAY' AND invoiceid='$id' ORDER BY created_date ASC";
716
-          $invoice_total_query=$this->db->query($query);
714
+         $invoice_total = '';
715
+         $query = "SELECT  * from invoice_details where item_type='INVPAY' AND invoiceid='$id' ORDER BY created_date ASC";
716
+          $invoice_total_query = $this->db->query($query);
717 717
           if ($invoice_total_query ->num_rows() > 0) {
718
-            $invoice_total_query= $invoice_total_query->result_array();
718
+            $invoice_total_query = $invoice_total_query->result_array();
719 719
          
720
-            $data['invoice_total_query']=$invoice_total_query;
720
+            $data['invoice_total_query'] = $invoice_total_query;
721 721
           }
722 722
           $invoice = $this->db_model->getSelect("*", "invoices", array("id"=> $id));
723 723
           if ($invoice ->num_rows() > 0) {
724
-             $invoice= $invoice->result_array();
725
-             $result=$invoice[0];
726
-             $data['payment_due_date']=$result['due_date'];
724
+             $invoice = $invoice->result_array();
725
+             $result = $invoice[0];
726
+             $data['payment_due_date'] = $result['due_date'];
727 727
           }
728 728
      
729
-        	$accountdata = $this->db_model->getSelect("*","accounts",array("id"=> $result['accountid']));
729
+        	$accountdata = $this->db_model->getSelect("*", "accounts", array("id"=> $result['accountid']));
730 730
         	if ($accountdata ->num_rows() > 0) {
731
-        	   $accountdata =  $accountdata->result_array();
731
+        	   $accountdata = $accountdata->result_array();
732 732
              $accountdata = $accountdata[0];
733 733
         	 }
734 734
         
735 735
         $system_config = common_model::$global_config['system_config'];
736
-        if($system_config["paypal_mode"]==0){
736
+        if ($system_config["paypal_mode"] == 0) {
737 737
             $data["paypal_url"] = $system_config["paypal_url"];
738 738
             $data["paypal_email_id"] = $system_config["paypal_id"];
739
-        }else{
739
+        } else {
740 740
             $data["paypal_url"] = $system_config["paypal_sandbox_url"];
741 741
             $data["paypal_email_id"] = $system_config["paypal_sandbox_id"];
742 742
          }
743 743
         $date = strtotime($result['invoice_date']);
744
-        $data['time'] = date("Y-m-d h:i:s ",$date);
744
+        $data['time'] = date("Y-m-d h:i:s ", $date);
745 745
         $data["paypal_tax"] = $system_config["paypal_tax"];
746 746
         $data["from_currency"] = $this->common->get_field_name('currency', 'currency', $account_data["currency_id"]);
747 747
         $data["to_currency"] = Common_model::$global_config['system_config']['base_currency'];
748
-      if($account_data['type'] == -1){
748
+      if ($account_data['type'] == -1) {
749 749
 	  $accountdata["currency_id"] = $this->common->get_field_name('currency', 'currency', $account_data["currency_id"]);
750 750
           $data["to_currency"] = $accountdata["currency_id"];
751
-      }elseif($account_data['type'] == 1){
751
+      }elseif ($account_data['type'] == 1) {
752 752
 	  $accountdata["currency_id"] = $this->common->get_field_name('currency', 'currency', $account_data["currency_id"]);
753 753
           $data["to_currency"] = $accountdata["currency_id"];
754
-      }else{
754
+      } else {
755 755
 	  $accountdata["currency_id"] = $this->common->get_field_name('currency', 'currency', $account_data["currency_id"]);
756 756
           $data["to_currency"] = $accountdata["currency_id"];
757 757
       }
758 758
       $data["system_currency"] = Common_model::$global_config['system_config']['base_currency'];
759
-        foreach($invoice_total_query as  $value){
760
-         	$data['from_date']=$result['from_date'];
761
-        	$data['to_date']=$result['to_date'];
762
-        	$data['invoice_date']=$result['invoice_date'];
763
-        	$data['amount'] =  $this->common_model->calculate_currency($result['amount']);
764
-        	$data['invoice_prefix'] =  $result['invoice_prefix'];
765
-        	$data['page_title'] =  'Invoice Summary';
766
-        	$data['invoice_date']=$result['invoice_date'];
767
-        	$data['return'] =base_url() . "invoices/invoice_list_modified";
768
-        	$data['cancel_return'] =base_url()."invoice/invoice_list_cancel";
759
+        foreach ($invoice_total_query as  $value) {
760
+         	$data['from_date'] = $result['from_date'];
761
+        	$data['to_date'] = $result['to_date'];
762
+        	$data['invoice_date'] = $result['invoice_date'];
763
+        	$data['amount'] = $this->common_model->calculate_currency($result['amount']);
764
+        	$data['invoice_prefix'] = $result['invoice_prefix'];
765
+        	$data['page_title'] = 'Invoice Summary';
766
+        	$data['invoice_date'] = $result['invoice_date'];
767
+        	$data['return'] = base_url()."invoices/invoice_list_modified";
768
+        	$data['cancel_return'] = base_url()."invoice/invoice_list_cancel";
769 769
         	$data['paypal_mode'] = 1;
770
-        	$data['prefix_id']=$result['invoiceid'];
771
-        	$data['logintype']=$logintype;
770
+        	$data['prefix_id'] = $result['invoiceid'];
771
+        	$data['logintype'] = $logintype;
772 772
         	$data['accountdata'] = $accountdata;
773
-        	$data['value']=$value;
774
-        	$data['id']=$id;
775
-        	$data['notify_url'] = base_url() . "invoices/invoice_list_get_data/";
776
-        	if($account_data['type'] =='1'){
777
-        	$data['response_url'] = base_url() . "invoices/invoice_list_responce/";
778
-        	}else{
779
-        	$data['response_url'] = base_url() . "user/user_list_responce/";
773
+        	$data['value'] = $value;
774
+        	$data['id'] = $id;
775
+        	$data['notify_url'] = base_url()."invoices/invoice_list_get_data/";
776
+        	if ($account_data['type'] == '1') {
777
+        	$data['response_url'] = base_url()."invoices/invoice_list_responce/";
778
+        	} else {
779
+        	$data['response_url'] = base_url()."user/user_list_responce/";
780 780
         	}
781
-        	$data['sucess_url'] = base_url() . "invoices/invoice_list_sucess/";
781
+        	$data['sucess_url'] = base_url()."invoices/invoice_list_sucess/";
782 782
       	}
783 783
       	
784
-      	}else{
784
+      	} else {
785 785
       	
786
-      	redirect(base_url() . 'dashboard/');
786
+      	redirect(base_url().'dashboard/');
787 787
       	}
788
-	      $this->load->view('view_invoice_payment',$data);
788
+	      $this->load->view('view_invoice_payment', $data);
789 789
     }
790
-    function invoice_list_get_data(){
790
+    function invoice_list_get_data() {
791 791
       redirect(base_url().'invoices/invoice_list/');
792 792
     }
793
-    function convert_amount($amount){
794
-       $amount = $this->common_model->add_calculate_currency($amount,"","",true,false);
795
-       echo number_format($amount,2);
793
+    function convert_amount($amount) {
794
+       $amount = $this->common_model->add_calculate_currency($amount, "", "", true, false);
795
+       echo number_format($amount, 2);
796 796
     }
797
-     function invoice_list_responce(){
798
-      $response_arr=$_POST;
797
+     function invoice_list_responce() {
798
+      $response_arr = $_POST;
799 799
        $logintype = $this->session->userdata('logintype');
800
-      if( ($response_arr["payment_status"] == "Pending" || $response_arr["payment_status"] == "Complete" || $response_arr["payment_status"] == "Completed" ) ){
801
-        $invoice_id=$response_arr['item_number'];
802
-        $amount=$response_arr['payment_gross'];       
803
-        $description=$response_arr['item_name'];     
804
-        $debit='';         
800
+      if (($response_arr["payment_status"] == "Pending" || $response_arr["payment_status"] == "Complete" || $response_arr["payment_status"] == "Completed")) {
801
+        $invoice_id = $response_arr['item_number'];
802
+        $amount = $response_arr['payment_gross'];       
803
+        $description = $response_arr['item_name'];     
804
+        $debit = '';         
805 805
                        
806
-            $paypal_tax = $this->db_model->getSelect("value", "system", array("name" => "paypal_tax","group_title"=>"paypal"));
806
+            $paypal_tax = $this->db_model->getSelect("value", "system", array("name" => "paypal_tax", "group_title"=>"paypal"));
807 807
             $paypal_tax = $paypal_tax->result();
808 808
             $paypal_tax = $paypal_tax[0]->value;
809 809
             $balance_amt = $actual_amount = $response_arr["custom"];                       
810 810
                             
811
-            $paypal_fee = $this->db_model->getSelect("value", "system", array("name" => "paypal_fee","group_title"=>"paypal"));
811
+            $paypal_fee = $this->db_model->getSelect("value", "system", array("name" => "paypal_fee", "group_title"=>"paypal"));
812 812
             $paypal_fee = $paypal_fee->result();
813 813
             $paypal_fee = $paypal_fee[0]->value;
814 814
 
815
-            $paypalfee = ($paypal_fee == 0)?'0':$response_arr["mc_gross"];               
815
+            $paypalfee = ($paypal_fee == 0) ? '0' : $response_arr["mc_gross"];               
816 816
              
817 817
              $account_data = $this->db_model->getSelect("*", "accounts", array("id" => $response_arr["custom"]));
818 818
             $account_data = $account_data->result_array();
819 819
             $account_data = $account_data[0];              
820 820
               $currency = $this->db_model->getSelect('currency,currencyrate', 'currency', array("id"=>$account_data["currency_id"]));
821 821
             $currency = $currency->result_array();
822
-            $currency =$currency[0];
822
+            $currency = $currency[0];
823 823
             $date = date('Y-m-d H:i:s');              
824 824
                $invoice_total_query = $this->db_model->getSelect("*", "invoices", array("id"=> $invoice_id));
825
-        if ( $invoice_total_query ->num_rows() > 0) {
826
-         $invoice_total_query= $invoice_total_query->result_array();
827
-         $debit=$invoice_total_query[0]['amount'];
825
+        if ($invoice_total_query ->num_rows() > 0) {
826
+         $invoice_total_query = $invoice_total_query->result_array();
827
+         $debit = $invoice_total_query[0]['amount'];
828 828
         }             
829
-              $query="select  sum(credit) as credit from invoice_details where invoiceid = ".$invoice_id." AND item_type !='PAYMENT' Group By invoiceid";  
829
+              $query = "select  sum(credit) as credit from invoice_details where invoiceid = ".$invoice_id." AND item_type !='PAYMENT' Group By invoiceid";  
830 830
         //echo $query; exit;
831
-        $invoice_total_query=$this->db->query($query);
831
+        $invoice_total_query = $this->db->query($query);
832 832
         if ($invoice_total_query ->num_rows() > 0) {
833
-            $invoice_total_query= $invoice_total_query->result_array();
834
-            $total_debit=$invoice_total_query[0]['credit'];
833
+            $invoice_total_query = $invoice_total_query->result_array();
834
+            $total_debit = $invoice_total_query[0]['credit'];
835 835
             }
836
-            $credit_total=$total_debit+$amount;
836
+            $credit_total = $total_debit + $amount;
837 837
        //   echo  $debit; exit;
838
-         if($debit >= $credit_total)   {
838
+         if ($debit >= $credit_total) {
839 839
          
840 840
          
841
-          if($debit == $credit_total){
841
+          if ($debit == $credit_total) {
842 842
           
843 843
           $this->db->where("id", $invoice_id);        
844 844
           $data = array('status' => '0');
845 845
           $this->db->update("invoices", $data);
846 846
          // echo $this->db->last_query(); exit;
847
-          }else{
847
+          } else {
848 848
           $this->db->where("id", $invoice_id);        
849 849
           $data = array('status' => '2');
850 850
           $this->db->update("invoices", $data);
851 851
           // echo $this->db->last_query(); exit;
852 852
           }
853 853
         
854
-        if($amount > $debit){
854
+        if ($amount > $debit) {
855 855
           $this->session->set_flashdata('astpp_notification', 'Invoice payment amount should be higher then the invoice amount.');
856 856
           redirect(base_url().'invoices/invoice_summary/'.$invoice_id);
857 857
         }               
858
-            $payment_trans_array = array("accountid"=>$response_arr["custom"],"amount"=>$response_arr["payment_gross"],
859
-                "tax"=>"1","payment_method"=>"Paypal","actual_amount"=> $amount,"paypal_fee"=>  $paypalfee,
860
-                "user_currency"=>$currency["currency"],"currency_rate"=>$currency["currencyrate"],"transaction_details"=>json_encode($response_arr),"date"=>$date);
861
-            $this->db->insert('payment_transaction',$payment_trans_array); 
862
-         $transaction_details_id= $this->db->insert_id();
858
+            $payment_trans_array = array("accountid"=>$response_arr["custom"], "amount"=>$response_arr["payment_gross"],
859
+                "tax"=>"1", "payment_method"=>"Paypal", "actual_amount"=> $amount, "paypal_fee"=>  $paypalfee,
860
+                "user_currency"=>$currency["currency"], "currency_rate"=>$currency["currencyrate"], "transaction_details"=>json_encode($response_arr), "date"=>$date);
861
+            $this->db->insert('payment_transaction', $payment_trans_array); 
862
+         $transaction_details_id = $this->db->insert_id();
863 863
          
864 864
         
865
-              if($transaction_details_id == ''){
865
+              if ($transaction_details_id == '') {
866 866
               $transaction_details_id == 0;
867 867
               }
868 868
               
869
-             $accountdata = $this->db_model->getSelect("*","payment_transaction",array());
870
-       if($accountdata->num_rows() > 0){
871
-        foreach($accountdata->result_array() as $payment_value){
872
-          $payment_transaction=$payment_value['transaction_details'];
873
-          $payment_result=json_decode($payment_transaction,true);
874
-          $transaction_id= $payment_result['txn_id'];
869
+             $accountdata = $this->db_model->getSelect("*", "payment_transaction", array());
870
+       if ($accountdata->num_rows() > 0) {
871
+        foreach ($accountdata->result_array() as $payment_value) {
872
+          $payment_transaction = $payment_value['transaction_details'];
873
+          $payment_result = json_decode($payment_transaction, true);
874
+          $transaction_id = $payment_result['txn_id'];
875 875
         }
876 876
        }
877
-         $invoice_total_history = $this->db_model->getSelect("*", "invoice_details", array("invoiceid"=> $invoice_id,'item_type'=>'INVPAY'));
878
-	$account_balance=$account_data['balance'];
877
+         $invoice_total_history = $this->db_model->getSelect("*", "invoice_details", array("invoiceid"=> $invoice_id, 'item_type'=>'INVPAY'));
878
+	$account_balance = $account_data['balance'];
879 879
        if ($invoice_total_history ->num_rows() > 0) {
880 880
         // echo 'if'; exit;
881
-         $invoice_main= $invoice_total_history->result_array();
881
+         $invoice_main = $invoice_total_history->result_array();
882 882
         // echo '<pre>'; print_r($invoice_main); exit;
883 883
          $debit_amount = "0.00";
884
-        foreach($invoice_main as $value){
884
+        foreach ($invoice_main as $value) {
885 885
            $debit_amount = $value['debit'];
886 886
         }
887 887
        
888
-         $actual_amount= $debit_amount-$amount;
888
+         $actual_amount = $debit_amount - $amount;
889 889
           // echo   $actual_amount; exit;
890
-        $tax_array = array("accountid"=>$response_arr["custom"],"invoiceid"=>$invoice_id,"item_id"=> $transaction_details_id,"description"=>$description,"debit"=>$this->common->currency_decimal(0),"credit"=> $this->common->currency_decimal($amount),"item_type"=>"INVPAY","created_date"=> $date,"reseller_id"=>$account_data['reseller_id'],'before_balance'=>$account_balance,'after_balance'=>$account_balance+$amount,
891
-);        // echo '<pre>'; print_r( $tax_array); exit;
892
-       	 $this->db->insert("invoice_details",$tax_array);
890
+        $tax_array = array("accountid"=>$response_arr["custom"], "invoiceid"=>$invoice_id, "item_id"=> $transaction_details_id, "description"=>$description, "debit"=>$this->common->currency_decimal(0), "credit"=> $this->common->currency_decimal($amount), "item_type"=>"INVPAY", "created_date"=> $date, "reseller_id"=>$account_data['reseller_id'], 'before_balance'=>$account_balance, 'after_balance'=>$account_balance + $amount,
891
+); // echo '<pre>'; print_r( $tax_array); exit;
892
+       	 $this->db->insert("invoice_details", $tax_array);
893 893
          
894
-         }else{
894
+         } else {
895 895
          
896 896
         //  echo 'else'; exit;
897
-         $actual_amount=$debit-$amount;
898
-         $tax_array = array("accountid"=>$response_arr["custom"],"invoiceid"=>$invoice_id,"item_id"=> $transaction_details_id,"description"=>$description,"debit"=> $this->common->currency_decimal(0),"credit"=> $this->common->currency_decimal($amount),"item_type"=>"INVPAY","created_date"=> $date,"reseller_id"=>$account_data['reseller_id'],'before_balance'=>$account_balance,'after_balance'=>$account_balance+$amount); 
897
+         $actual_amount = $debit - $amount;
898
+         $tax_array = array("accountid"=>$response_arr["custom"], "invoiceid"=>$invoice_id, "item_id"=> $transaction_details_id, "description"=>$description, "debit"=> $this->common->currency_decimal(0), "credit"=> $this->common->currency_decimal($amount), "item_type"=>"INVPAY", "created_date"=> $date, "reseller_id"=>$account_data['reseller_id'], 'before_balance'=>$account_balance, 'after_balance'=>$account_balance + $amount); 
899 899
        
900
-	         $this->db->insert("invoice_details",$tax_array);
900
+	         $this->db->insert("invoice_details", $tax_array);
901 901
          }
902
-	 }else{
903
-	  if($logintype = 0){
902
+	 } else {
903
+	  if ($logintype = 0) {
904 904
           $this->session->set_flashdata('astpp_notification', 'Invoice payment amount should be higher then the invoice amount.');
905 905
           redirect(base_url().'user/user_invoice_payment/'.$invoice_id);
906
-          }else{
906
+          } else {
907 907
           $this->session->set_flashdata('astpp_notification', 'Invoice payment amount should be higher then the invoice amount.');
908 908
           redirect(base_url().'invoices/invoice_summary/'.$invoice_id);
909 909
           }
@@ -911,69 +911,69 @@  discard block
 block discarded – undo
911 911
 	 }
912 912
         
913 913
          $this->load->module('accounts/accounts');
914
-         $reseller_debit=0;
915
-         $reseller_debit=$this->common->get_field_name('reseller_id', 'accounts', array('id'=>$response_arr["custom"],'status'=>0,'deleted'=>0)); 
914
+         $reseller_debit = 0;
915
+         $reseller_debit = $this->common->get_field_name('reseller_id', 'accounts', array('id'=>$response_arr["custom"], 'status'=>0, 'deleted'=>0)); 
916 916
         // echo '<pre>'; print_r($reseller_debit); exit;
917
-         if($reseller_debit > 0){
918
-	 $this->accounts_model->update_balance($amount,$response_arr["custom"], "debit");
919
-	 $this->accounts_model->update_balance($amount,$reseller_debit, "debit");
920
-	 }else{
921
-	 $this->accounts_model->update_balance($amount,$response_arr["custom"], "debit");
917
+         if ($reseller_debit > 0) {
918
+	 $this->accounts_model->update_balance($amount, $response_arr["custom"], "debit");
919
+	 $this->accounts_model->update_balance($amount, $reseller_debit, "debit");
920
+	 } else {
921
+	 $this->accounts_model->update_balance($amount, $response_arr["custom"], "debit");
922 922
 	 }
923
-	 $account_data['accountid']=$account_data['id'];
924
-         $this->email_lib->send_email('email_payment_notification',$account_data ,'','',0,0,0);
925
-	 if($logintype = '1'){
923
+	 $account_data['accountid'] = $account_data['id'];
924
+         $this->email_lib->send_email('email_payment_notification', $account_data, '', '', 0, 0, 0);
925
+	 if ($logintype = '1') {
926 926
          $this->session->set_flashdata('astpp_errormsg', 'Invoice payment done successfully!');
927
-       redirect(base_url() . 'invoices/invoice_list/');
928
-       }else{
927
+       redirect(base_url().'invoices/invoice_list/');
928
+       } else {
929 929
         $this->session->set_flashdata('astpp_errormsg', 'Invoice payment done successfully!');
930
-       redirect(base_url() . 'user/user_invoices_list/');
930
+       redirect(base_url().'user/user_invoices_list/');
931 931
        }
932 932
 	}
933 933
       }
934
-     function invoice_admin_payment(){
934
+     function invoice_admin_payment() {
935 935
      
936
-     $response_arr=$_POST;
936
+     $response_arr = $_POST;
937 937
     
938
-     if(!empty($response_arr)){
938
+     if ( ! empty($response_arr)) {
939 939
         
940
-        $amount=$response_arr['amount'];       
941
-        $description=$response_arr['item_name'];
942
-        $invoice_id=$response_arr['item_number'];
940
+        $amount = $response_arr['amount'];       
941
+        $description = $response_arr['item_name'];
942
+        $invoice_id = $response_arr['item_number'];
943 943
         $date = date('Y-m-d H:i:s'); 
944 944
     
945 945
         $invoice_total_query = $this->db_model->getSelect("*", "invoices", array("id"=> $invoice_id));
946
-        if ( $invoice_total_query ->num_rows() > 0) {
947
-         $invoice_total_query= $invoice_total_query->result_array();
948
-         $debit=$invoice_total_query[0]['amount'];
946
+        if ($invoice_total_query ->num_rows() > 0) {
947
+         $invoice_total_query = $invoice_total_query->result_array();
948
+         $debit = $invoice_total_query[0]['amount'];
949 949
         }
950 950
          
951
-        $query="select  sum(credit) as credit from invoice_details where invoiceid = ".$invoice_id."  AND item_type !='PAYMENT'  Group By invoiceid"; 
951
+        $query = "select  sum(credit) as credit from invoice_details where invoiceid = ".$invoice_id."  AND item_type !='PAYMENT'  Group By invoiceid"; 
952 952
         //echo $query; exit;
953
-        $invoice_total_query=$this->db->query($query);
953
+        $invoice_total_query = $this->db->query($query);
954 954
         if ($invoice_total_query ->num_rows() > 0) {
955
-            $invoice_total_query= $invoice_total_query->result_array();
956
-            $total_debit=$invoice_total_query[0]['credit'];
955
+            $invoice_total_query = $invoice_total_query->result_array();
956
+            $total_debit = $invoice_total_query[0]['credit'];
957 957
             }
958
-            $credit_total=$total_debit+$amount;
958
+            $credit_total = $total_debit + $amount;
959 959
           // echo  $credit_total; exit;
960
-         if($debit >= $credit_total)   {
960
+         if ($debit >= $credit_total) {
961 961
          
962 962
          
963
-          if($debit == $credit_total){
963
+          if ($debit == $credit_total) {
964 964
           
965 965
           $this->db->where("id", $invoice_id);        
966 966
           $data = array('status' => '0');
967 967
           $this->db->update("invoices", $data);
968 968
          // echo $this->db->last_query(); exit;
969
-          }else{
969
+          } else {
970 970
           $this->db->where("id", $invoice_id);        
971 971
           $data = array('status' => '2');
972 972
           $this->db->update("invoices", $data);
973 973
           // echo $this->db->last_query(); exit;
974 974
           }
975 975
         
976
-        if($amount > $debit){
976
+        if ($amount > $debit) {
977 977
           $this->session->set_flashdata('astpp_notification', 'Invoice payment amount should be higher then the invoice amount.');
978 978
           redirect(base_url().'invoices/invoice_summary/'.$invoice_id);
979 979
         }
@@ -981,40 +981,40 @@  discard block
 block discarded – undo
981 981
 
982 982
         $debit_amount = "0.00";
983 983
         $account_balance = $this->common->get_field_name('balance', 'accounts', $response_arr['custom']);
984
-        $tax_array = array("accountid"=>$response_arr["custom"],"invoiceid"=>$invoice_id,"item_id"=> '',"description"=>$description,"debit"=>"0.00","credit"=> $amount,"item_type"=>"INVPAY","created_date"=> $date,"reseller_id"=>"0",'before_balance'=>$account_balance,'after_balance'=>$account_balance+$amount); 
985
-        $this->db->insert("invoice_details",$tax_array);
984
+        $tax_array = array("accountid"=>$response_arr["custom"], "invoiceid"=>$invoice_id, "item_id"=> '', "description"=>$description, "debit"=>"0.00", "credit"=> $amount, "item_type"=>"INVPAY", "created_date"=> $date, "reseller_id"=>"0", 'before_balance'=>$account_balance, 'after_balance'=>$account_balance + $amount); 
985
+        $this->db->insert("invoice_details", $tax_array);
986 986
      
987 987
       
988
-         }else{
988
+         } else {
989 989
          
990 990
           $this->session->set_flashdata('astpp_notification', 'Invoice payment amount should be higher then the invoice amount.');
991 991
           redirect(base_url().'invoices/invoice_summary/'.$invoice_id);
992 992
          }
993 993
          
994 994
          $this->load->module('accounts/accounts');
995
-	 $this->accounts_model->update_balance($amount,$response_arr["custom"], "debit");
995
+	 $this->accounts_model->update_balance($amount, $response_arr["custom"], "debit");
996 996
          $this->session->set_flashdata('astpp_errormsg', 'Invoice payment done successfully!');
997 997
         
998 998
      }
999 999
      $account_data = $this->db_model->getSelect("*", "accounts", array("id" => $response_arr["custom"]));
1000 1000
             $account_data = $account_data->result_array();
1001 1001
             $account_data = $account_data[0]; 
1002
-     $account_data['accountid']=$account_data['id'];
1002
+     $account_data['accountid'] = $account_data['id'];
1003 1003
   //   $this->email_lib->send_email('email_payment_notification',$account_data ,'','',0,0,0);
1004
-     redirect(base_url() . 'invoices/invoice_list/');
1004
+     redirect(base_url().'invoices/invoice_list/');
1005 1005
      
1006 1006
      }
1007 1007
     
1008
-    function invoice_list_sucess(){
1008
+    function invoice_list_sucess() {
1009 1009
     echo 'sucess'; exit;
1010 1010
     
1011 1011
     }
1012
-     function invoice_list_modified(){
1012
+     function invoice_list_modified() {
1013 1013
     echo 'sucess'; exit;
1014 1014
     
1015 1015
     }
1016 1016
     
1017
-    function invoice_delete(){
1017
+    function invoice_delete() {
1018 1018
 	$ids = $this->input->post("selected_ids", true);
1019 1019
         $where = "id IN ($ids)";
1020 1020
         $this->db->where($where);
@@ -1024,58 +1024,58 @@  discard block
 block discarded – undo
1024 1024
     function invoice_conf() {
1025 1025
         $data['page_title'] = 'Company Profile';
1026 1026
         $post_array = $this->input->post();
1027
-        $accountinfo=$this->session->userdata('accountinfo');
1027
+        $accountinfo = $this->session->userdata('accountinfo');
1028 1028
         unset($post_array['action']);
1029 1029
         unset($post_array['button']);
1030 1030
         unset($post_array['file']);
1031 1031
                                 
1032
-        if (!empty($post_array)) {
1032
+        if ( ! empty($post_array)) {
1033 1033
             $invoice_prefix = trim($post_array['invoice_prefix']);
1034 1034
             if ($_FILES['file']['name'] == '') {
1035 1035
                 $invoiceconf = $this->invoices_model->get_invoiceconf($post_array['accountid']);
1036
-                $file_name=($invoiceconf['logo'] != '') ? $invoiceconf['logo'] : '';
1036
+                $file_name = ($invoiceconf['logo'] != '') ? $invoiceconf['logo'] : '';
1037 1037
             }
1038 1038
             if ($invoice_prefix == '') {
1039 1039
                 $this->session->set_flashdata('astpp_notification', 'Invoice Prefix is required.');
1040
-                redirect(base_url() . 'invoices/invoice_conf/');
1040
+                redirect(base_url().'invoices/invoice_conf/');
1041 1041
             }
1042 1042
             
1043 1043
             if (isset($_FILES['file']['name']) && $_FILES['file']['name'] != '') {
1044 1044
                 $files = $_FILES['file'];
1045 1045
                 if ($files['size'] < 0) {
1046 1046
                     $this->session->set_flashdata('astpp_notification', 'PLease upload maximum file');
1047
-                    redirect(base_url() . 'invoices/invoice_conf/');
1047
+                    redirect(base_url().'invoices/invoice_conf/');
1048 1048
                 }
1049 1049
                 $file = $_FILES['file'];
1050 1050
                 $uploadedFile = $file["tmp_name"];
1051 1051
                 $file_name = $file['name'];
1052 1052
                 $file_type = $file['type'];
1053 1053
                 if ($file_type == 'image/jpg' || $file_type == 'image/png' || $file_type == 'image/jpeg') {
1054
-                    $dir_path = FCPATH. "upload/";
1055
-                    $path = $dir_path . $accountinfo['id']."_".$file['name'];
1054
+                    $dir_path = FCPATH."upload/";
1055
+                    $path = $dir_path.$accountinfo['id']."_".$file['name'];
1056 1056
                     if (move_uploaded_file($uploadedFile, $path)) {
1057 1057
                         $this->session->set_flashdata('astpp_errormsg', gettext('files added successfully!'));
1058 1058
                     } else {
1059 1059
                         $this->session->set_flashdata('astpp_notification', "File Uploading Fail Please Try Again");
1060
-                        redirect(base_url() . 'invoices/invoice_conf/');
1060
+                        redirect(base_url().'invoices/invoice_conf/');
1061 1061
                     }
1062 1062
                 } else {
1063 1063
                     $this->session->set_flashdata('astpp_notification', 'Please upload only image!');
1064
-                    redirect(base_url() . 'invoices/invoice_conf/');
1064
+                    redirect(base_url().'invoices/invoice_conf/');
1065 1065
                 }
1066 1066
             }
1067 1067
             $post_array['logo'] = $file_name;
1068 1068
             
1069 1069
             $this->invoices_model->save_invoiceconf($post_array);
1070 1070
             $this->session->set_flashdata('astpp_errormsg', 'Invoice configuration updated sucessfully!');
1071
-            redirect(base_url() . 'invoices/invoice_conf/');
1071
+            redirect(base_url().'invoices/invoice_conf/');
1072 1072
         } else {
1073 1073
 
1074 1074
             $invoiceconf = $this->invoices_model->get_invoiceconf($accountinfo['id']);
1075 1075
 
1076
-            if (!empty($invoiceconf)) {
1076
+            if ( ! empty($invoiceconf)) {
1077 1077
                 $data['file_name'] = $accountinfo['id']."_".$invoiceconf['logo'];
1078
-                $invoiceconf['file']=$accountinfo['id']."_".$invoiceconf['logo'];
1078
+                $invoiceconf['file'] = $accountinfo['id']."_".$invoiceconf['logo'];
1079 1079
             }
1080 1080
             
1081 1081
             $data['form'] = $this->form->build_form($this->invoices_form->get_invoiceconf_form_fields($invoiceconf), $invoiceconf);
@@ -1083,106 +1083,106 @@  discard block
 block discarded – undo
1083 1083
             $this->load->view('view_invoiceconf', $data);
1084 1084
         }
1085 1085
     }
1086
-       function incr($inteval){
1086
+       function incr($inteval) {
1087 1087
        $inteval++; // $a is undefined
1088 1088
         return $inteval;
1089 1089
         }
1090 1090
      
1091 1091
     
1092
-    function customer_invoices($accountid){
1092
+    function customer_invoices($accountid) {
1093 1093
     // echo '<pre>'; print_r($accountid); exit;
1094 1094
         $json_data = array();
1095 1095
 /****
1096 1096
 Invoice manually
1097 1097
 **/
1098
-        $where = array('accountid' => $accountid,'confirm'=>1);
1099
-        $count_all = $this->db_model->countQuery("*","invoices",$where);
1098
+        $where = array('accountid' => $accountid, 'confirm'=>1);
1099
+        $count_all = $this->db_model->countQuery("*", "invoices", $where);
1100 1100
          $currency_id = Common_model::$global_config['system_config']['base_currency'];
1101
-        $paging_data =  $this->form->load_grid_config($count_all, $_GET['rp'], $_GET['page']);
1101
+        $paging_data = $this->form->load_grid_config($count_all, $_GET['rp'], $_GET['page']);
1102 1102
         $json_data = $paging_data["json_paging"];
1103 1103
 	
1104
-        $Invoice_grid_data = $this->db_model->select("*","invoices",$where,"invoice_date","desc",$paging_data["paging"]["page_no"],$paging_data["paging"]["start"]);
1104
+        $Invoice_grid_data = $this->db_model->select("*", "invoices", $where, "invoice_date", "desc", $paging_data["paging"]["page_no"], $paging_data["paging"]["start"]);
1105 1105
       //  echo $this->db->last_query(); exit;
1106
-        $grid_fields= json_decode($this->invoices_form->build_invoices_list_for_admin());
1106
+        $grid_fields = json_decode($this->invoices_form->build_invoices_list_for_admin());
1107 1107
         
1108 1108
        // $json_data['rows'] = $this->form->build_grid($Invoice_grid_data,$grid_fields);
1109 1109
         $logintype = $this->session->userdata('logintype');
1110
-       $url= ($logintype==0 ||$logintype==3 ) ? "/user/user_invoice_download/":'/invoices/invoice_download/';
1111
-        if($Invoice_grid_data->num_rows > 0 ){
1112
-          $query=$Invoice_grid_data->result_array();
1110
+       $url = ($logintype == 0 || $logintype == 3) ? "/user/user_invoice_download/" : '/invoices/invoice_download/';
1111
+        if ($Invoice_grid_data->num_rows > 0) {
1112
+          $query = $Invoice_grid_data->result_array();
1113 1113
 	        $total_value = 0;
1114 1114
 	        $ountstanding_value = 0;
1115 1115
          
1116 1116
          foreach ($query as $key => $value) {
1117 1117
           $date = strtotime($value['invoice_date']);
1118
-          $invoice_date =date("Y-m-d",$date);
1118
+          $invoice_date = date("Y-m-d", $date);
1119 1119
           $fromdate = strtotime($value['from_date']);
1120
-          $from_date =date("Y-m-d",$fromdate);
1120
+          $from_date = date("Y-m-d", $fromdate);
1121 1121
           $duedate = strtotime($value['due_date']);
1122
-          $due_date =date("Y-m-d",$duedate);
1122
+          $due_date = date("Y-m-d", $duedate);
1123 1123
           $outstanding = $value['amount'];
1124 1124
 	         $last_payment_date = '';
1125
-	          $invoice_total_query = $this->db_model->select("sum(debit) as debit,sum(credit) as credit,created_date", "invoice_details", array("invoiceid"=> $value['id'],"item_type"=>"INVPAY"),"created_date","DESC","1","0");
1125
+	          $invoice_total_query = $this->db_model->select("sum(debit) as debit,sum(credit) as credit,created_date", "invoice_details", array("invoiceid"=> $value['id'], "item_type"=>"INVPAY"), "created_date", "DESC", "1", "0");
1126 1126
        // echo $this->db->last_query(); exit;
1127
-          if ($invoice_total_query ->num_rows() > 0){
1128
-            $invoice_total_query= $invoice_total_query->result_array();
1127
+          if ($invoice_total_query ->num_rows() > 0) {
1128
+            $invoice_total_query = $invoice_total_query->result_array();
1129 1129
             //echo '<pre>'; print_r($invoice_total_query); 
1130 1130
             $outstanding -= $invoice_total_query[0]['credit'];
1131 1131
             
1132 1132
             $last_payment_date = $invoice_total_query[0]['created_date'];
1133
-            if($last_payment_date ){
1134
-            $payment_date=strtotime( $last_payment_date);
1135
-            $payment_last=date("d/m/Y",$payment_date);
1136
-            }else{
1137
-             $payment_last='';
1133
+            if ($last_payment_date) {
1134
+            $payment_date = strtotime($last_payment_date);
1135
+            $payment_last = date("d/m/Y", $payment_date);
1136
+            } else {
1137
+             $payment_last = '';
1138 1138
             }
1139 1139
          
1140 1140
             
1141 1141
           }
1142
-          $invoice_total='';
1143
-          $accountinfo=$this->session->userdata('accountinfo');
1144
-          $id=$accountinfo['id'];
1145
-          $query ="select sum(amount) as grand_total from invoices where confirm=1 and accountid=$accountid";
1142
+          $invoice_total = '';
1143
+          $accountinfo = $this->session->userdata('accountinfo');
1144
+          $id = $accountinfo['id'];
1145
+          $query = "select sum(amount) as grand_total from invoices where confirm=1 and accountid=$accountid";
1146 1146
          
1147
-          $ext_query=$this->db->query($query);
1148
-          if($ext_query->num_rows() > 0){
1149
-          $result_total=$ext_query->result_array();
1150
-          $grandtotal=$result_total[0]['grand_total'];
1151
-          $grand_total=$this->common->currency_decimal($grandtotal).' '.$currency_id;
1147
+          $ext_query = $this->db->query($query);
1148
+          if ($ext_query->num_rows() > 0) {
1149
+          $result_total = $ext_query->result_array();
1150
+          $grandtotal = $result_total[0]['grand_total'];
1151
+          $grand_total = $this->common->currency_decimal($grandtotal).' '.$currency_id;
1152 1152
           }
1153 1153
           
1154
-          $invoice_query ="select sum(credit) as grand_credit from invoice_details where accountid=$accountid";
1155
-          $credit_query=$this->db->query($invoice_query);
1156
-          if($credit_query->num_rows() > 0){
1157
-          $credit_total=$credit_query->result_array();
1158
-          $grand_credit_total=$credit_total[0]['grand_credit'];
1159
-          $grandcredit=$grand_total-$grand_credit_total;
1160
-          $grand_credit=$this->common->currency_decimal($grandcredit).' '.$currency_id;
1154
+          $invoice_query = "select sum(credit) as grand_credit from invoice_details where accountid=$accountid";
1155
+          $credit_query = $this->db->query($invoice_query);
1156
+          if ($credit_query->num_rows() > 0) {
1157
+          $credit_total = $credit_query->result_array();
1158
+          $grand_credit_total = $credit_total[0]['grand_credit'];
1159
+          $grandcredit = $grand_total - $grand_credit_total;
1160
+          $grand_credit = $this->common->currency_decimal($grandcredit).' '.$currency_id;
1161 1161
           }
1162 1162
          
1163 1163
          
1164 1164
        
1165
-          $download="<a href=" . $url .$value['id']. " class='btn btn-royelblue btn-sm'  title='Download Invoice' ><i class='fa fa-cloud-download fa-fw'></i></a>&nbsp";
1166
-	    if($value['type'] == 'R'){
1167
-		$payment ='';	
1168
-		$outstanding=0;	
1169
-	    }else{
1170
-		    if($outstanding > 0){
1171
-		      $payment = '<a style="padding: 0 8px;" href="'. base_url() .'invoices/invoice_summary/' . $value['id'] . '" class="btn btn-warning"  title="Payment">Unpaid</i></a>';
1172
-		    }else{
1165
+          $download = "<a href=".$url.$value['id']." class='btn btn-royelblue btn-sm'  title='Download Invoice' ><i class='fa fa-cloud-download fa-fw'></i></a>&nbsp";
1166
+	    if ($value['type'] == 'R') {
1167
+		$payment = '';	
1168
+		$outstanding = 0;	
1169
+	    } else {
1170
+		    if ($outstanding > 0) {
1171
+		      $payment = '<a style="padding: 0 8px;" href="'.base_url().'invoices/invoice_summary/'.$value['id'].'" class="btn btn-warning"  title="Payment">Unpaid</i></a>';
1172
+		    } else {
1173 1173
 		      $payment = ' <button style="padding: 0 8px;" type="button"  class="btn btn-success">Paid</button>';
1174 1174
 		    }
1175 1175
             }
1176 1176
         
1177
-           $account_arr = $this->db_model->getSelect('first_name,number,last_name','accounts', array('id'=>$value['accountid']));
1177
+           $account_arr = $this->db_model->getSelect('first_name,number,last_name', 'accounts', array('id'=>$value['accountid']));
1178 1178
            $account_array = $account_arr->result_array();
1179
-           if($value['generate_type'] == 1){
1180
-		$invoice_type='Manually';
1181
-	   }else{
1182
-		$invoice_type='Automatically';
1179
+           if ($value['generate_type'] == 1) {
1180
+		$invoice_type = 'Manually';
1181
+	   } else {
1182
+		$invoice_type = 'Automatically';
1183 1183
 	   }
1184 1184
 	   
1185
-	   if($value['type'] == 'R'){
1185
+	   if ($value['type'] == 'R') {
1186 1186
 		$icon = '<div class="flx_font flx_magenta">R</div>';
1187 1187
 		}
1188 1188
 		else
@@ -1205,84 +1205,84 @@  discard block
 block discarded – undo
1205 1205
 		$this->common_model->to_calculate_currency($outstanding, '', '', true, false),
1206 1206
 		$download.''.$payment,
1207 1207
   	  ));
1208
-          $total_value=$total_value + $value['amount'];
1209
-          $ountstanding_value=$ountstanding_value + $outstanding;
1208
+          $total_value = $total_value + $value['amount'];
1209
+          $ountstanding_value = $ountstanding_value + $outstanding;
1210 1210
          }
1211 1211
          }
1212 1212
         
1213 1213
         echo json_encode($json_data);
1214 1214
     }
1215
-    function user_invoices($accountid){
1215
+    function user_invoices($accountid) {
1216 1216
         $json_data = array();
1217 1217
 	$count_all = $this->invoices_model->get_user_invoice_list(false);
1218
-        $paging_data =  $this->form->load_grid_config($count_all, $_GET['rp'], $_GET['page']);
1218
+        $paging_data = $this->form->load_grid_config($count_all, $_GET['rp'], $_GET['page']);
1219 1219
         $json_data = $paging_data["json_paging"];
1220 1220
         $currency_id = Common_model::$global_config['system_config']['base_currency'];
1221
-        $query = $this->invoices_model->get_user_invoice_list(true,$paging_data["paging"]["start"], $paging_data["paging"]["page_no"]);
1222
-        $grid_fields= json_decode($this->invoices_form->build_invoices_list_for_customer());
1223
-         $query=$query->result_array();
1221
+        $query = $this->invoices_model->get_user_invoice_list(true, $paging_data["paging"]["start"], $paging_data["paging"]["page_no"]);
1222
+        $grid_fields = json_decode($this->invoices_form->build_invoices_list_for_customer());
1223
+         $query = $query->result_array();
1224 1224
          $account_arr = '';
1225
-         $created_date='';
1225
+         $created_date = '';
1226 1226
          foreach ($query as $key => $value) {
1227 1227
           $date = strtotime($value['invoice_date']);
1228
-          $invoice_date =date("d/m/Y",$date);
1228
+          $invoice_date = date("d/m/Y", $date);
1229 1229
           $fromdate = strtotime($value['from_date']);
1230
-          $from_date =date("d/m/Y",$fromdate);
1230
+          $from_date = date("d/m/Y", $fromdate);
1231 1231
           $duedate = strtotime($value['due_date']);
1232
-          $due_date =date("d/m/Y",$duedate);
1232
+          $due_date = date("d/m/Y", $duedate);
1233 1233
           $outstanding = $value['amount'];
1234
-           $invoice_total_query = $this->db_model->select("sum(debit) as debit,sum(credit) as credit,created_date", "invoice_details", array("invoiceid"=> $value['id'],"item_type"=>"INVPAY"),"created_date","DESC","1","0");
1234
+           $invoice_total_query = $this->db_model->select("sum(debit) as debit,sum(credit) as credit,created_date", "invoice_details", array("invoiceid"=> $value['id'], "item_type"=>"INVPAY"), "created_date", "DESC", "1", "0");
1235 1235
        // echo $this->db->last_query(); exit;
1236
-          if ($invoice_total_query ->num_rows() > 0){
1237
-            $invoice_total_query= $invoice_total_query->result_array();
1236
+          if ($invoice_total_query ->num_rows() > 0) {
1237
+            $invoice_total_query = $invoice_total_query->result_array();
1238 1238
             //echo '<pre>'; print_r($invoice_total_query); 
1239 1239
             $outstanding -= $invoice_total_query[0]['credit'];
1240 1240
             
1241 1241
             $last_payment_date = $invoice_total_query[0]['created_date'];
1242
-            if($last_payment_date ){
1243
-            $payment_date=strtotime( $last_payment_date);
1244
-            $payment_last=date("d/m/Y",$payment_date);
1245
-            }else{
1246
-             $payment_last='';
1242
+            if ($last_payment_date) {
1243
+            $payment_date = strtotime($last_payment_date);
1244
+            $payment_last = date("d/m/Y", $payment_date);
1245
+            } else {
1246
+             $payment_last = '';
1247 1247
             }
1248 1248
          
1249 1249
             
1250 1250
           }
1251
-         $invoice_total_query = $this->db_model->select("debit,created_date", "invoice_details", array("invoiceid"=> $value['id'],"item_type"=>"INVPAY"),"created_date","DESC","1","0");
1252
-         if ( $invoice_total_query ->num_rows() > 0) {
1253
-            $invoice_total_query= $invoice_total_query->result_array();
1251
+         $invoice_total_query = $this->db_model->select("debit,created_date", "invoice_details", array("invoiceid"=> $value['id'], "item_type"=>"INVPAY"), "created_date", "DESC", "1", "0");
1252
+         if ($invoice_total_query ->num_rows() > 0) {
1253
+            $invoice_total_query = $invoice_total_query->result_array();
1254 1254
            // $outstanding = $invoice_total_query[0]['debit'];
1255 1255
             $created_date = $invoice_total_query[0]['created_date'];
1256 1256
          }
1257
-    $accountinfo=$this->session->userdata('accountinfo');
1258
-          $query ="select sum(amount) as grand_total from invoices where  confirm=1 and accountid=$accountid";
1257
+    $accountinfo = $this->session->userdata('accountinfo');
1258
+          $query = "select sum(amount) as grand_total from invoices where  confirm=1 and accountid=$accountid";
1259 1259
          
1260
-          $ext_query=$this->db->query($query);
1261
-          if($ext_query->num_rows() > 0){
1262
-          $result_total=$ext_query->result_array();
1263
-          $grandtotal=$result_total[0]['grand_total'];
1264
-          $grand_total=$this->common->currency_decimal($grandtotal).' '.$currency_id;
1260
+          $ext_query = $this->db->query($query);
1261
+          if ($ext_query->num_rows() > 0) {
1262
+          $result_total = $ext_query->result_array();
1263
+          $grandtotal = $result_total[0]['grand_total'];
1264
+          $grand_total = $this->common->currency_decimal($grandtotal).' '.$currency_id;
1265 1265
           }
1266 1266
           
1267
-          $invoice_query ="select sum(credit) as grand_credit from invoice_details where accountid=$accountid";
1268
-          $credit_query=$this->db->query($invoice_query);
1269
-          if($credit_query->num_rows() > 0){
1270
-          $credit_total=$credit_query->result_array();
1271
-          $grand_credit_total=$credit_total[0]['grand_credit'];
1272
-          $grandcredit=$grand_total-$grand_credit_total;
1273
-          $grand_credit=$this->common->currency_decimal($grandcredit).' '.$currency_id;
1267
+          $invoice_query = "select sum(credit) as grand_credit from invoice_details where accountid=$accountid";
1268
+          $credit_query = $this->db->query($invoice_query);
1269
+          if ($credit_query->num_rows() > 0) {
1270
+          $credit_total = $credit_query->result_array();
1271
+          $grand_credit_total = $credit_total[0]['grand_credit'];
1272
+          $grandcredit = $grand_total - $grand_credit_total;
1273
+          $grand_credit = $this->common->currency_decimal($grandcredit).' '.$currency_id;
1274 1274
           }
1275
-         $download='<a href="'. base_url() .'/user/user_invoice_download/' . $value['id'].'/00'.$value['invoice_prefix'].$value['invoiceid'].'" class="btn btn-royelblue btn-sm"  title="Download Invoice" ><i class="fa fa-cloud-download fa-fw"></i></a>&nbsp';
1276
-         if($outstanding > 0){
1277
-         $payment = ' <a style="padding: 0 8px;" href="'. base_url() .'user/user_invoice_payment/' . $value['id'] . '" class="btn btn-warning"  title="Payment">Unpaid</a>';
1278
-}else{
1275
+         $download = '<a href="'.base_url().'/user/user_invoice_download/'.$value['id'].'/00'.$value['invoice_prefix'].$value['invoiceid'].'" class="btn btn-royelblue btn-sm"  title="Download Invoice" ><i class="fa fa-cloud-download fa-fw"></i></a>&nbsp';
1276
+         if ($outstanding > 0) {
1277
+         $payment = ' <a style="padding: 0 8px;" href="'.base_url().'user/user_invoice_payment/'.$value['id'].'" class="btn btn-warning"  title="Payment">Unpaid</a>';
1278
+} else {
1279 1279
 
1280 1280
 $payment = ' <button style="padding: 0 8px;" class="btn btn-success" type="button">Paid</button>';
1281
-}          $account_arr = $this->db_model->getSelect('first_name,number,last_name','accounts', array('id'=>$value['accountid']));
1281
+}          $account_arr = $this->db_model->getSelect('first_name,number,last_name', 'accounts', array('id'=>$value['accountid']));
1282 1282
 	   $account_array = $account_arr->result_array();
1283 1283
 	   $date = strtotime($value['invoice_date']);
1284 1284
          $date = strtotime("+7 day", $date);
1285
-         $time = date("Y-m-d h:i:s ",$date);
1285
+         $time = date("Y-m-d h:i:s ", $date);
1286 1286
           $json_data['rows'][] = array('cell' => array(
1287 1287
                 $value['invoice_prefix'].$value['invoiceid'].' ('.$value['type'].')',
1288 1288
 		$account_array[0]['first_name'].' '.$account_array[0]['last_name'].'</br>'.$account_array[0]['number'],
@@ -1307,7 +1307,7 @@  discard block
 block discarded – undo
1307 1307
         		'',
1308 1308
         		'',
1309 1309
         		'',
1310
-        		"<b>". $grand_total."</b>",
1310
+        		"<b>".$grand_total."</b>",
1311 1311
         		"<b>".$grand_credit."<b>",
1312 1312
         		'',
1313 1313
         		
@@ -1315,19 +1315,19 @@  discard block
 block discarded – undo
1315 1315
         echo json_encode($json_data);
1316 1316
     }
1317 1317
      
1318
-     function invoice_logo_delete($accountid){
1318
+     function invoice_logo_delete($accountid) {
1319 1319
     
1320
-     $invoiceconf  = $this->db_model->getSelect("*", "invoice_conf", array("id"=> $accountid));
1321
-     $result=$invoiceconf->result_array();
1322
-     $logo=$result[0]['logo'];
1323
-     $post_arr=array('logo'=>'');
1324
-     $where_arr=array('logo'=>$logo);
1320
+     $invoiceconf = $this->db_model->getSelect("*", "invoice_conf", array("id"=> $accountid));
1321
+     $result = $invoiceconf->result_array();
1322
+     $logo = $result[0]['logo'];
1323
+     $post_arr = array('logo'=>'');
1324
+     $where_arr = array('logo'=>$logo);
1325 1325
      $this->db->where($where_arr);
1326
-     $this->db->update('invoice_conf',$post_arr);
1326
+     $this->db->update('invoice_conf', $post_arr);
1327 1327
     // redirect(base_url() . 'invoices/invoice_conf/');
1328 1328
      
1329 1329
      }
1330
-    function invoice_list_view_invoice($invoiceid=false) {
1330
+    function invoice_list_view_invoice($invoiceid = false) {
1331 1331
         
1332 1332
         $data['username'] = $this->session->userdata('user_name');
1333 1333
         $data['page_title'] = 'Invoice Detail';
@@ -1359,7 +1359,7 @@  discard block
 block discarded – undo
1359 1359
         $data['invoiceid'] = @$invoicedata[0]['invoiceid'];
1360 1360
         $data['invoicedate'] = @$invoicedata[0]['date'];
1361 1361
         $data['accountid'] = @$invoicedata[0]['accountid'];
1362
-        if(!empty($invoicedata)){
1362
+        if ( ! empty($invoicedata)) {
1363 1363
 		$accountinfo = $this->invoices_model->get_account_including_closed(@$invoicedata[0]['accountid']);
1364 1364
 		$data['accountinfo'] = $accountinfo;
1365 1365
         }
@@ -1368,97 +1368,97 @@  discard block
 block discarded – undo
1368 1368
         $this->load->view('view_account_invoice_detail', $data);
1369 1369
     }
1370 1370
     
1371
-    function invoice_download($invoiceid){   
1372
-     $this->db->where('id',$invoiceid);
1371
+    function invoice_download($invoiceid) {   
1372
+     $this->db->where('id', $invoiceid);
1373 1373
      $this->db->select('type');
1374 1374
      $this->db->from('invoices');
1375
-     $result=$this->db->get();
1376
-     if($result->num_rows() > 0 ){
1377
-      $result=$result->result_array();
1378
-      $type= $result[0]['type'];
1379
-      if($type=='I'){
1375
+     $result = $this->db->get();
1376
+     if ($result->num_rows() > 0) {
1377
+      $result = $result->result_array();
1378
+      $type = $result[0]['type'];
1379
+      if ($type == 'I') {
1380 1380
 	       $this->invoice_main_download($invoiceid);
1381 1381
       }
1382
-      if($type=='R'){
1382
+      if ($type == 'R') {
1383 1383
 	       $this->receipt_download($invoiceid);
1384 1384
       }
1385
-     }else{
1386
-      redirect(base_url() . 'invoices/invoice_list/');
1385
+     } else {
1386
+      redirect(base_url().'invoices/invoice_list/');
1387 1387
      }
1388 1388
     }
1389 1389
   
1390
-function invoice_screen(){
1390
+function invoice_screen() {
1391 1391
 	$login_type = $this->session->userdata['userlevel_logintype'];
1392
-	if($login_type == -1 || $login_type == 2 ||$login_type == 1 || $login_type == 4){
1393
-         if($this->input->post()){
1392
+	if ($login_type == -1 || $login_type == 2 || $login_type == 1 || $login_type == 4) {
1393
+         if ($this->input->post()) {
1394 1394
 	     $data = $this->input->post();
1395
-	     if($data['accountid'] == ''  || $data['accountid'] == '-Select-' ){
1395
+	     if ($data['accountid'] == '' || $data['accountid'] == '-Select-') {
1396 1396
  	     	 $this->session->set_flashdata('astpp_notification', 'Please select accounts');  
1397 1397
 	         redirect(base_url()."invoices/invoice_list/");
1398 1398
 	     }
1399
-	     if(!empty($data)){
1400
-		 if(isset($data['notes']) && $data['notes'] !=''){
1401
-	                 $this->session->set_userdata('invoice_note',$data['notes']);
1399
+	     if ( ! empty($data)) {
1400
+		 if (isset($data['notes']) && $data['notes'] != '') {
1401
+	                 $this->session->set_userdata('invoice_note', $data['notes']);
1402 1402
 		 }
1403
-	         $date=date('Y-m-d');
1404
-	         $feture_date=date('Y-m-d', strtotime($date));
1405
- 	     	 $from_date=$data['fromdate'];
1406
- 	     	 $genrated_date=$data['todate'];
1407
- 	     	 $to_date=date('Y-m-d', strtotime($genrated_date));
1408
- 	     	 if( $to_date > $feture_date){
1403
+	         $date = date('Y-m-d');
1404
+	         $feture_date = date('Y-m-d', strtotime($date));
1405
+ 	     	 $from_date = $data['fromdate'];
1406
+ 	     	 $genrated_date = $data['todate'];
1407
+ 	     	 $to_date = date('Y-m-d', strtotime($genrated_date));
1408
+ 	     	 if ($to_date > $feture_date) {
1409 1409
  	     	 $this->session->set_flashdata('astpp_notification', 'To date should not be greater than current date.');  
1410 1410
 	         redirect(base_url()."invoices/invoice_list/");
1411
- 	     	 }else{
1412
-	         $todate=$data['todate'].' '.'23:59:59';
1413
-	         $from_date=$data['fromdate'].' '.'00:00:01';
1414
-	         $accountid=$data['accountid'];
1411
+ 	     	 } else {
1412
+	         $todate = $data['todate'].' '.'23:59:59';
1413
+	         $from_date = $data['fromdate'].' '.'00:00:01';
1414
+	         $accountid = $data['accountid'];
1415 1415
 	         $acc_query = $this->db_model->getSelect("*", "accounts", array("id" => $accountid));
1416 1416
 		 $accountdata = $acc_query->result_array();
1417
-		 $accountdata=$accountdata[0];
1417
+		 $accountdata = $accountdata[0];
1418 1418
 		 $screen_path = getcwd()."/cron";
1419 1419
                $screen_filename = "Email_Broadcast_".strtotime('now');
1420 1420
                $command = "cd ".$screen_path." && /usr/bin/screen -d -m -S  $screen_filename php cron.php BroadcastEmail";
1421 1421
                exec($command);
1422 1422
 		$invoice_data_count = 0;
1423
-		$invoice_conf =  array();
1424
-		if($accountdata['reseller_id'] == 0){
1423
+		$invoice_conf = array();
1424
+		if ($accountdata['reseller_id'] == 0) {
1425 1425
  			$where = array("accountid"=> 1);
1426
-		}else{
1426
+		} else {
1427 1427
 			$where = array("accountid"=> $accountdata['reseller_id']);    
1428 1428
 		}
1429 1429
 		$query = $this->db_model->getSelect("*", "invoice_conf", $where);
1430
-		if($query->num_rows >0){
1430
+		if ($query->num_rows > 0) {
1431 1431
 			$invoice_conf = $query->result_array();
1432 1432
 			$invoice_conf = $invoice_conf[0];
1433
-		}else{
1434
-			$query = $this->db_model->getSelect("*", "invoice_conf",array("accountid"=> 1));
1433
+		} else {
1434
+			$query = $this->db_model->getSelect("*", "invoice_conf", array("accountid"=> 1));
1435 1435
 			$invoice_conf = $query->result_array();
1436 1436
 			$invoice_conf = $invoice_conf[0];            
1437 1437
 		}
1438 1438
 		$last_invoice_ID = $this->get_invoice_date("invoiceid");
1439
-		if($last_invoice_ID && $last_invoice_ID > 0){
1440
-			$last_invoice_ID = ($last_invoice_ID+1);
1441
-		}else{
1439
+		if ($last_invoice_ID && $last_invoice_ID > 0) {
1440
+			$last_invoice_ID = ($last_invoice_ID + 1);
1441
+		} else {
1442 1442
 			$last_invoice_ID = $invoice_conf['invoice_start_from'];
1443 1443
 		}
1444
-		$last_invoice_ID =str_pad($last_invoice_ID,(strlen($last_invoice_ID)+4),'0',STR_PAD_LEFT);
1445
-		if($accountdata['posttoexternal'] == 1){
1446
-       		    $balance = ($accountdata['credit_limit']-$accountdata['balance']);
1447
-		}else{
1444
+		$last_invoice_ID = str_pad($last_invoice_ID, (strlen($last_invoice_ID) + 4), '0', STR_PAD_LEFT);
1445
+		if ($accountdata['posttoexternal'] == 1) {
1446
+       		    $balance = ($accountdata['credit_limit'] - $accountdata['balance']);
1447
+		} else {
1448 1448
        		    $balance = $accountdata['balance'];
1449 1449
 		}
1450
-		if($accountdata['invoice_interval'] > 0){
1451
-			$due_date = gmdate("Y-m-d H:i:s",strtotime(gmdate("Y-m-d H:i:s")." +".$accountdata['invoice_interval']." days"));
1452
-		}else{
1453
-			$due_date = gmdate("Y-m-d H:i:s",strtotime(gmdate("Y-m-d H:i:s")." +7 days"));
1450
+		if ($accountdata['invoice_interval'] > 0) {
1451
+			$due_date = gmdate("Y-m-d H:i:s", strtotime(gmdate("Y-m-d H:i:s")." +".$accountdata['invoice_interval']." days"));
1452
+		} else {
1453
+			$due_date = gmdate("Y-m-d H:i:s", strtotime(gmdate("Y-m-d H:i:s")." +7 days"));
1454 1454
 		}	
1455
-		$invoice_data = array("accountid"=>$accountdata['id'],"invoice_prefix" =>$invoice_conf['invoice_prefix'],"invoiceid"=>$last_invoice_ID,"reseller_id"=>   
1456
-		$accountdata['reseller_id'],"invoice_date"=>gmdate("Y-m-d H:i:s"),"from_date"=>$from_date,"to_date"=>$todate,"due_date"=>$due_date,"status"=>1,"amount"=>"0.00","balance"=>$balance,'generate_type'=>1,'confirm'=>0,'notes'=>$data['notes']);
1455
+		$invoice_data = array("accountid"=>$accountdata['id'], "invoice_prefix" =>$invoice_conf['invoice_prefix'], "invoiceid"=>$last_invoice_ID, "reseller_id"=>   
1456
+		$accountdata['reseller_id'], "invoice_date"=>gmdate("Y-m-d H:i:s"), "from_date"=>$from_date, "to_date"=>$todate, "due_date"=>$due_date, "status"=>1, "amount"=>"0.00", "balance"=>$balance, 'generate_type'=>1, 'confirm'=>0, 'notes'=>$data['notes']);
1457 1457
 		// echo "<pre>"; print_r($invoice_data); exit;
1458 1458
 		$invoice_note = $this->session->userdata('invoice_note');
1459 1459
 		$this->session->unset_userdata('invoice_note');
1460
-		$invoice_data['invoice_note']=$invoice_note;
1461
-		$this->db->insert("invoices",$invoice_data);
1460
+		$invoice_data['invoice_note'] = $invoice_note;
1461
+		$this->db->insert("invoices", $invoice_data);
1462 1462
 		$invoiceid = $this->db->insert_id();
1463 1463
                  //$generateInvoice->process_invoice($accountdata,$from_date,$todate);
1464 1464
                  $this->session->set_flashdata('astpp_errormsg', 'Invoice generation completed .');  
@@ -1466,7 +1466,7 @@  discard block
 block discarded – undo
1466 1466
 	         
1467 1467
 	       }
1468 1468
 	        } 
1469
-	     } else{
1469
+	     } else {
1470 1470
 	         $this->session->set_flashdata('astpp_errormsg', 'No data found.....');  
1471 1471
 	         redirect(base_url()."invoices/invoice_list/");
1472 1472
 	     }
@@ -1478,144 +1478,144 @@  discard block
 block discarded – undo
1478 1478
 	   redirect(base_url()."invoices/invoice_list/");
1479 1479
 	}          
1480 1480
     }
1481
-     function get_invoice_date($select,$accountid=false){
1482
-	if($accountid){
1483
-	        $where = array('type'=>"I","accountid"=>$accountid);
1484
-        $query = $this->db_model->select($select, "invoices", $where,"to_date","DESC","1","0");
1485
-	}else{
1481
+     function get_invoice_date($select, $accountid = false) {
1482
+	if ($accountid) {
1483
+	        $where = array('type'=>"I", "accountid"=>$accountid);
1484
+        $query = $this->db_model->select($select, "invoices", $where, "to_date", "DESC", "1", "0");
1485
+	} else {
1486 1486
 		 $where = array('type'=>"I");
1487
-        $query = $this->db_model->select($select, "invoices", $where,"id","DESC","1","0");
1487
+        $query = $this->db_model->select($select, "invoices", $where, "id", "DESC", "1", "0");
1488 1488
 	}
1489
-        if($query->num_rows >0){
1489
+        if ($query->num_rows > 0) {
1490 1490
             $invoiceid = $query->result_array();
1491
-            $invoice_date=$invoiceid[0][$select];
1491
+            $invoice_date = $invoiceid[0][$select];
1492 1492
             return  $invoice_date;
1493 1493
         }
1494 1494
         return false;
1495 1495
     }   
1496 1496
      function invoice_main_download($invoiceid) {
1497 1497
 
1498
-        $invoicedata  = $this->db_model->getSelect("*", "invoices", array("id"=> $invoiceid));
1498
+        $invoicedata = $this->db_model->getSelect("*", "invoices", array("id"=> $invoiceid));
1499 1499
         $invoicedata = $invoicedata->result_array();
1500
-        $invoicedata=$invoicedata[0];
1501
-	$invoice_path='';
1500
+        $invoicedata = $invoicedata[0];
1501
+	$invoice_path = '';
1502 1502
         $accountid = $invoicedata['accountid'];
1503
-        $acc_file=$invoice_path.$accountid.'/'.$invoiceid;  
1504
-        $accountdata = $this->db_model->getSelect("*","accounts",array("id"=>$accountid));
1505
-        $accountdata =  $accountdata->result_array();
1503
+        $acc_file = $invoice_path.$accountid.'/'.$invoiceid;  
1504
+        $accountdata = $this->db_model->getSelect("*", "accounts", array("id"=>$accountid));
1505
+        $accountdata = $accountdata->result_array();
1506 1506
         $accountdata = $accountdata[0];
1507 1507
 
1508 1508
         $login_type = $this->session->userdata['userlevel_logintype'];
1509
-        $query="select item_type,credit from invoice_details where invoiceid = ".$invoicedata['id']." and item_type='INVPAY' Group By id order by item_type desc"; 
1509
+        $query = "select item_type,credit from invoice_details where invoiceid = ".$invoicedata['id']." and item_type='INVPAY' Group By id order by item_type desc"; 
1510 1510
             // echo  $query; exit;
1511
-        $invoice_total_query=$this->db->query($query);
1512
-         if($invoice_total_query->num_rows() > 0){
1513
-        $total=$invoice_total_query->result_array();
1514
-        foreach($total as $key => $value){
1515
-        $debit=$value['credit'];
1511
+        $invoice_total_query = $this->db->query($query);
1512
+         if ($invoice_total_query->num_rows() > 0) {
1513
+        $total = $invoice_total_query->result_array();
1514
+        foreach ($total as $key => $value) {
1515
+        $debit = $value['credit'];
1516 1516
         }
1517
-         if($debit){
1517
+         if ($debit) {
1518 1518
        // echo 'debit'; exit;
1519
-           $invoice_path=$this->config->item('invoices_path');
1519
+           $invoice_path = $this->config->item('invoices_path');
1520 1520
            $download_path = $invoice_path.$accountdata["id"].'/'.$invoicedata['invoice_prefix'].$invoicedata['invoiceid']."_invoice.pdf";
1521 1521
            unlink($download_path);
1522
-           $res = $this->common->get_invoice_template($invoicedata,$accountdata,"TRUE");
1522
+           $res = $this->common->get_invoice_template($invoicedata, $accountdata, "TRUE");
1523 1523
           }
1524 1524
           }
1525
-         $invoice_path=$this->config->item('invoices_path');
1525
+         $invoice_path = $this->config->item('invoices_path');
1526 1526
          $download_path = $invoice_path.$accountdata["id"].'/'.$invoicedata['invoice_prefix'].$invoicedata['invoiceid']."_invoice.pdf";
1527
-        $res = $this->common->get_invoice_template($invoicedata,$accountdata,"TRUE");
1527
+        $res = $this->common->get_invoice_template($invoicedata, $accountdata, "TRUE");
1528 1528
     }
1529
-  function Sec2Minutes( $seconds )
1529
+  function Sec2Minutes($seconds)
1530 1530
   {
1531
-      return sprintf( "%02.2d:%02.2d", floor( $seconds / 60 ), $seconds % 60 );
1531
+      return sprintf("%02.2d:%02.2d", floor($seconds / 60), $seconds % 60);
1532 1532
   }
1533 1533
   function receipt_download($invoiceid) {
1534 1534
         $login_info = $this->session->userdata('accountinfo');
1535 1535
        ob_start();
1536 1536
        $this->load->library('/html2pdf/html2pdf');
1537
-       $template_config=$this->config->item('invoice_template');
1537
+       $template_config = $this->config->item('invoice_template');
1538 1538
        include($template_config.'invoice_template_receipt.php');
1539 1539
        $content = ob_get_clean();
1540 1540
        ob_clean();
1541 1541
         $accountid = $this->common->get_field_name('accountid', 'invoices', $invoiceid);	
1542
-        $accountdata = $this->db_model->getSelect("*","accounts",array("id"=>$accountid));
1543
-        $accountdata =  $accountdata->result_array();
1542
+        $accountdata = $this->db_model->getSelect("*", "accounts", array("id"=>$accountid));
1543
+        $accountdata = $accountdata->result_array();
1544 1544
         $accountdata = $accountdata[0];
1545 1545
 //        $accountdata["currency_id"] = $this->common->get_field_name('currency', 'currency', $accountdata["currency_id"]);
1546 1546
 	//$currency = $accountdata["currency_id"];
1547
-      if($login_info['type'] == -1){
1547
+      if ($login_info['type'] == -1) {
1548 1548
 	  $data["to_currency"] = Common_model::$global_config['system_config']['base_currency'];
1549 1549
           $currency = $data["to_currency"];
1550
-      }elseif($login_info['type'] == 1){
1550
+      }elseif ($login_info['type'] == 1) {
1551 1551
 	  $accountdata["currency_id"] = $this->common->get_field_name('currency', 'currency', $login_info["currency_id"]);
1552 1552
           $currency = $accountdata["currency_id"];
1553
-      }else{
1553
+      } else {
1554 1554
 	  $accountdata["currency_id"] = $this->common->get_field_name('currency', 'currency', $login_info["currency_id"]);
1555 1555
           $currency = $accountdata["currency_id"];
1556 1556
       }
1557 1557
         $invoice_cdr_list = array();
1558
-        $invoicedata  = $this->db_model->getSelect("*", "invoices", array("id"=> $invoiceid));
1558
+        $invoicedata = $this->db_model->getSelect("*", "invoices", array("id"=> $invoiceid));
1559 1559
         $invoicedata = $invoicedata->result_array();
1560
-        $invoicedata=$invoicedata[0];
1560
+        $invoicedata = $invoicedata[0];
1561 1561
        
1562 1562
         $data['invoiceid'] = @$invoicedata[0]['id'];
1563
-        $data['id']	 = @$invoicedata['invoiceid'];
1563
+        $data['id'] = @$invoicedata['invoiceid'];
1564 1564
         
1565 1565
         $data['invoice_date'] = @$invoicedata[0]['invoice_date'];
1566 1566
         $data['accountid'] = @$invoicedata[0]['accountid'];
1567 1567
 	$data['from_date'] = @$invoicedata[0]['from_date'];
1568 1568
 	$data['to_date'] = @$invoicedata[0]['to_date'];
1569 1569
         $total_list = array();
1570
-        $data['description']='';
1571
-        $data['item_type']='';
1572
-        $data['debit']='';
1570
+        $data['description'] = '';
1571
+        $data['item_type'] = '';
1572
+        $data['debit'] = '';
1573 1573
         $invoice_total_list = array();
1574
-	$query="select item_type,description,created_date,invoiceid,debit,credit from invoice_details where invoiceid = ".$invoiceid." And ( item_type='POSTCHARG' Or item_type='Refill') Group By item_type"; 	
1575
-	$invoice_total_query=$this->db->query($query);
1576
-	if($invoice_total_query ->num_rows() > 0) {
1577
-		  $invoice_total_query= $invoice_total_query->result_array();
1578
-		  foreach($invoice_total_query as $key=>$value){
1579
-			  $data['item_type']=$value['item_type'];
1580
-			  $data['description']=$value['description'];
1581
-			  if($value['item_type'] == 'Refill'){
1582
-				  $data['debit']=$value['credit'];
1583
-			  }else{
1584
-				  $data['debit']=$value['debit'];
1574
+	$query = "select item_type,description,created_date,invoiceid,debit,credit from invoice_details where invoiceid = ".$invoiceid." And ( item_type='POSTCHARG' Or item_type='Refill') Group By item_type"; 	
1575
+	$invoice_total_query = $this->db->query($query);
1576
+	if ($invoice_total_query ->num_rows() > 0) {
1577
+		  $invoice_total_query = $invoice_total_query->result_array();
1578
+		  foreach ($invoice_total_query as $key=>$value) {
1579
+			  $data['item_type'] = $value['item_type'];
1580
+			  $data['description'] = $value['description'];
1581
+			  if ($value['item_type'] == 'Refill') {
1582
+				  $data['debit'] = $value['credit'];
1583
+			  } else {
1584
+				  $data['debit'] = $value['debit'];
1585 1585
 			  }	   
1586
-			  $created_date=$value['created_date'];
1587
-			  $invoicedata['invoiceid']=$value['invoiceid'];
1586
+			  $created_date = $value['created_date'];
1587
+			  $invoicedata['invoiceid'] = $value['invoiceid'];
1588 1588
 		  }
1589
-          }else{
1590
-		$query="select item_type,description,created_date,invoiceid,debit,credit from invoice_details where invoiceid = ".$invoiceid." And item_type='SUBCHRG' Group By item_type"; 	
1591
-		$invoice_total_query=$this->db->query($query);
1592
-		if($invoice_total_query ->num_rows() > 0) {
1593
-		  $invoice_total_query= $invoice_total_query->result_array();
1594
-		  foreach($invoice_total_query as $key=>$value){
1595
-			  $data['item_type']=$value['item_type'];
1596
-			  $data['description']=$value['description'];
1597
-			  if($value['item_type'] == 'Refill'){
1598
-				  $data['debit']=$value['credit'];
1599
-			  }else{
1600
-				  $data['debit']=$value['debit'];
1589
+          } else {
1590
+		$query = "select item_type,description,created_date,invoiceid,debit,credit from invoice_details where invoiceid = ".$invoiceid." And item_type='SUBCHRG' Group By item_type"; 	
1591
+		$invoice_total_query = $this->db->query($query);
1592
+		if ($invoice_total_query ->num_rows() > 0) {
1593
+		  $invoice_total_query = $invoice_total_query->result_array();
1594
+		  foreach ($invoice_total_query as $key=>$value) {
1595
+			  $data['item_type'] = $value['item_type'];
1596
+			  $data['description'] = $value['description'];
1597
+			  if ($value['item_type'] == 'Refill') {
1598
+				  $data['debit'] = $value['credit'];
1599
+			  } else {
1600
+				  $data['debit'] = $value['debit'];
1601 1601
 			  }	   
1602
-			  $created_date=$value['created_date'];
1603
-			  $invoicedata['invoiceid']=$value['invoiceid'];
1602
+			  $created_date = $value['created_date'];
1603
+			  $invoicedata['invoiceid'] = $value['invoiceid'];
1604 1604
 		  }
1605 1605
 		}
1606 1606
 	  }
1607 1607
           $data['accountinfo'] = $accountdata;
1608 1608
          //Get invoice header information
1609
-        if($accountdata['reseller_id']=='0')
1609
+        if ($accountdata['reseller_id'] == '0')
1610 1610
 	      $accountid = '1';
1611 1611
         else
1612 1612
             $accountid = $accountdata['reseller_id'];
1613
-            $invoiceconf  = $this->db_model->getSelect("*", "invoice_conf", array("accountid"=> $accountid));
1613
+            $invoiceconf = $this->db_model->getSelect("*", "invoice_conf", array("accountid"=> $accountid));
1614 1614
             $invoiceconf = $invoiceconf->result_array();
1615
-            if(!empty($invoiceconf)){
1615
+            if ( ! empty($invoiceconf)) {
1616 1616
                 $data['invoiceconf'] = $invoiceconf[0];
1617
-            }else{
1618
-            $invoiceconf  = $this->db_model->getSelect("*", "invoice_conf", array("accountid"=> "1"));
1617
+            } else {
1618
+            $invoiceconf = $this->db_model->getSelect("*", "invoice_conf", array("accountid"=> "1"));
1619 1619
             $invoiceconf = $invoiceconf->result_array();
1620 1620
             $data['invoiceconf'] = $invoiceconf[0];
1621 1621
             }
@@ -1624,133 +1624,133 @@  discard block
 block discarded – undo
1624 1624
         
1625 1625
       // echo '<pre>'; print_r($accountdata); exit;
1626 1626
         //FOR the Customer Address
1627
-        $customer_address="<div style='font-size:12px;' >";
1628
-        if ( $accountdata['company_name'] != "")
1629
-            $customer_address .= $accountdata['company_name'] . "<br/>";
1630
-        if ( $accountdata['address_1'] != "")
1631
-            $customer_address .= $accountdata['address_1'] . "," .$accountdata['address_2'] .",". "<br/>";
1632
-        if ( $accountdata['city'] != "")
1633
-            $customer_address .= $accountdata['city'] . "<br/>";
1634
-        if ( $accountdata['province'] != "")
1627
+        $customer_address = "<div style='font-size:12px;' >";
1628
+        if ($accountdata['company_name'] != "")
1629
+            $customer_address .= $accountdata['company_name']."<br/>";
1630
+        if ($accountdata['address_1'] != "")
1631
+            $customer_address .= $accountdata['address_1'].",".$accountdata['address_2'].","."<br/>";
1632
+        if ($accountdata['city'] != "")
1633
+            $customer_address .= $accountdata['city']."<br/>";
1634
+        if ($accountdata['province'] != "")
1635 1635
             $customer_address .= $accountdata['province']."<br/>";
1636
-        if ( $accountdata['country_id'] != "")
1636
+        if ($accountdata['country_id'] != "")
1637 1637
             $customer_address .= $this->common->get_field_name('country', 'countrycode', $accountdata['country_id'])."<br/>";            
1638
-        if ( $accountdata['postal_code'] != "")
1639
-            $customer_address .= "Pincode - " . $accountdata['postal_code'] . "<br/>";
1638
+        if ($accountdata['postal_code'] != "")
1639
+            $customer_address .= "Pincode - ".$accountdata['postal_code']."<br/>";
1640 1640
         else
1641 1641
             $customer_address .= "\n";
1642 1642
            // $customer_address .= "Date of Invoice: " .date('d/m/Y', strtotime($invoicedata['invoice_date']))."<br/>";
1643 1643
 $customer_address .= "</div>";
1644 1644
 
1645
-    $reseller_id=$accountdata['reseller_id'];     
1646
-        $logo='';
1647
-        if(!empty($invoiceconf) && $invoiceconf != ''){
1648
-        $logo= $invoiceconf[0]['logo'];
1649
-        $dir_path= getcwd()."/assets/Logo/";
1645
+    $reseller_id = $accountdata['reseller_id'];     
1646
+        $logo = '';
1647
+        if ( ! empty($invoiceconf) && $invoiceconf != '') {
1648
+        $logo = $invoiceconf[0]['logo'];
1649
+        $dir_path = getcwd()."/assets/Logo/";
1650 1650
        // echo $dir_path; exit;
1651
-        $path =$dir_path. $logo;
1652
-        if($logo != ''){
1653
-        $src=$path;
1651
+        $path = $dir_path.$logo;
1652
+        if ($logo != '') {
1653
+        $src = $path;
1654 1654
         $logo = "<img style='height:50px; width:180px; margin-left:70px;' alt='logo' src='".$src."'>";
1655
-        }else{
1655
+        } else {
1656 1656
         $path = getcwd()."/assets/images/logo.png";
1657
-        $src=$path;
1657
+        $src = $path;
1658 1658
         $logo = "<img style='height:50px; width:180px; margin-left:70px;' alt='logo' src='".$src."'>";
1659 1659
         }
1660 1660
         }
1661 1661
         
1662 1662
         
1663
-        $CALL_DETAILS_TABLE=null;
1663
+        $CALL_DETAILS_TABLE = null;
1664 1664
         $CALL_DETAILS_TABLE .= "<tr style='font-family:arial;'>";
1665 1665
         $CALL_DETAILS_TABLE .= "<td style='font-size:12px;padding:7px 5px;width: 35%;text-align:right;border-bottom:1px solid black;border-left:1px solid #000;border-right:1px solid #000;'>".$accountdata['number']."</td>";
1666 1666
         $CALL_DETAILS_TABLE .= "<td style='font-size:12px;padding:7px 5px;width: 25%;border-bottom:1px solid black;text-align:right;border-right:1px solid #000;'>".$invoicedata['invoice_prefix'].$data['id']."</td>";
1667 1667
         $CALL_DETAILS_TABLE .= "<td style='font-size:12px;padding:7px 5px;width: 20%;border-bottom:1px solid black;text-align:right;border-right:1px solid #000;'>".date('Y-m-d', strtotime($invoicedata['from_date']))."</td>";
1668 1668
         $CALL_DETAILS_TABLE .= "<td style='font-size:12px;padding:7px 5px;width: 20%;border-bottom:1px solid black;text-align:right;border-right:1px solid #000;'>".date('Y-m-d', strtotime($invoicedata['from_date']))."</td>";
1669
-        $CALL_DETAILS_TABLE .='</tr>';
1669
+        $CALL_DETAILS_TABLE .= '</tr>';
1670 1670
         
1671 1671
         
1672
-        $RECEIPT_DETAILS_TABLE=null;
1672
+        $RECEIPT_DETAILS_TABLE = null;
1673 1673
         $RECEIPT_DETAILS_TABLE .= "<tr style='font-family:arial;'>";
1674 1674
         $RECEIPT_DETAILS_TABLE .= "<td style='font-size:12px;padding:7px 5px;width: 35%;text-align:right;border-bottom:1px solid black;border-left:1px solid #000;border-right:1px solid #000;'>".date('Y-m-d', strtotime($invoicedata['from_date']))."</td>";
1675 1675
         $RECEIPT_DETAILS_TABLE .= "<td style='font-size:12px;padding:7px 5px;width: 25%;border-bottom:1px solid black;text-align:right;border-right:1px solid #000;'>".$data['description']."</td>";
1676 1676
         $RECEIPT_DETAILS_TABLE .= "<td style='font-size:12px;padding:7px 5px;width: 20%;border-bottom:1px solid black;text-align:right;border-right:1px solid #000;'>".$data['item_type']."</td>";
1677 1677
         $RECEIPT_DETAILS_TABLE .= "<td style='font-size:12px;padding:7px 5px;width: 20%;border-bottom:1px solid black;text-align:right;border-right:1px solid #000;'>".$this->common->currency_decimal($this->common_model->calculate_currency($data['debit']))."</td>";
1678
-        $RECEIPT_DETAILS_TABLE .='</tr>';
1678
+        $RECEIPT_DETAILS_TABLE .= '</tr>';
1679 1679
        
1680 1680
        
1681 1681
         //echo '<pre>'; print_r($data['id']); exit;
1682 1682
         
1683
-        $MONTHLY_DESC=null;
1684
-        $MONTHLY_DESC .= "<div style='font-size:12px;' ><b>Account Number :</b> " . $accountdata['number']."<br/>";               
1685
-        $MONTHLY_DESC .= "<b>Receipt Number  :</b> " .$invoicedata['invoice_prefix'].$data['id']."<br/>";        
1686
-        $MONTHLY_DESC .= "<b>Receipt Date :</b>  " .date('Y-m-d', strtotime($invoicedata['from_date']))."<br/></div>";  
1683
+        $MONTHLY_DESC = null;
1684
+        $MONTHLY_DESC .= "<div style='font-size:12px;' ><b>Account Number :</b> ".$accountdata['number']."<br/>";               
1685
+        $MONTHLY_DESC .= "<b>Receipt Number  :</b> ".$invoicedata['invoice_prefix'].$data['id']."<br/>";        
1686
+        $MONTHLY_DESC .= "<b>Receipt Date :</b>  ".date('Y-m-d', strtotime($invoicedata['from_date']))."<br/></div>";  
1687 1687
         
1688 1688
         $COMPANY_DETAILS_TABLE = null;
1689
-	$COMPANY_DETAILS_SET=null;
1690
-	$COMPANY_DETAILS_SET.= $data['invoiceconf']['company_name']."<br/>";
1691
-	$COMPANY_DETAILS_SET.= $data['invoiceconf']['address'].",<br/>";
1692
-	$COMPANY_DETAILS_SET.= $data['invoiceconf']['city'];
1693
-	$COMPANY_DETAILS_SET.= $data['invoiceconf']['zipcode'].",<br/>";
1694
-	$COMPANY_DETAILS_SET.= $data['invoiceconf']['province'].",<br/>";
1689
+	$COMPANY_DETAILS_SET = null;
1690
+	$COMPANY_DETAILS_SET .= $data['invoiceconf']['company_name']."<br/>";
1691
+	$COMPANY_DETAILS_SET .= $data['invoiceconf']['address'].",<br/>";
1692
+	$COMPANY_DETAILS_SET .= $data['invoiceconf']['city'];
1693
+	$COMPANY_DETAILS_SET .= $data['invoiceconf']['zipcode'].",<br/>";
1694
+	$COMPANY_DETAILS_SET .= $data['invoiceconf']['province'].",<br/>";
1695 1695
 
1696
-	$COMPANY_DETAILS_SET.= $data['invoiceconf']['country']."<br/>";
1697
-	$COMPANY_DETAILS_SET.= $data['invoiceconf']['telephone']." <br/>";
1698
-	$COMPANY_DETAILS_SET.= $data['invoiceconf']['fax']." <br/>";
1699
-	$COMPANY_DETAILS_SET.= $data['invoiceconf']['emailaddress']."<br/>";
1700
-	$COMPANY_DETAILS_SET.= $data['invoiceconf']['website']."<br/>";
1696
+	$COMPANY_DETAILS_SET .= $data['invoiceconf']['country']."<br/>";
1697
+	$COMPANY_DETAILS_SET .= $data['invoiceconf']['telephone']." <br/>";
1698
+	$COMPANY_DETAILS_SET .= $data['invoiceconf']['fax']." <br/>";
1699
+	$COMPANY_DETAILS_SET .= $data['invoiceconf']['emailaddress']."<br/>";
1700
+	$COMPANY_DETAILS_SET .= $data['invoiceconf']['website']."<br/>";
1701 1701
         
1702
-        if(!empty($data['invoiceconf']) && $data['invoiceconf'] != ''){
1703
-        $logo= $data['invoiceconf']['logo'];
1702
+        if ( ! empty($data['invoiceconf']) && $data['invoiceconf'] != '') {
1703
+        $logo = $data['invoiceconf']['logo'];
1704 1704
        
1705
-        $dir_path= base_url()."upload/";
1705
+        $dir_path = base_url()."upload/";
1706 1706
       // echo $dir_path; exit;
1707
-        $path =$dir_path.$data['invoiceconf']['accountid']."_".$data['invoiceconf']['logo'];
1708
-	if(file_exists($path)){
1709
-		if($logo != ''){
1710
-			$src=$path;
1707
+        $path = $dir_path.$data['invoiceconf']['accountid']."_".$data['invoiceconf']['logo'];
1708
+	if (file_exists($path)) {
1709
+		if ($logo != '') {
1710
+			$src = $path;
1711 1711
 			$logo = "<img style='height:50px; width:180px; margin-left:70px;' alt='logo' src='".$src."'>";
1712
-		}else{
1712
+		} else {
1713 1713
 			$path = base_url()."/assets/images/logo.png";
1714
-			$src=$path;
1714
+			$src = $path;
1715 1715
 			$logo = "<img style='height:50px; width:180px; margin-left:70px;' alt='logo' src='".$src."'>";
1716 1716
 		}
1717
-	}else{
1718
-		$dir_path= base_url()."/upload/logo.png";
1719
-		$src=$dir_path;
1717
+	} else {
1718
+		$dir_path = base_url()."/upload/logo.png";
1719
+		$src = $dir_path;
1720 1720
 		$logo = "<img style='height:50px; width:180px; margin-left:70px;' alt='logo' src='".$src."'>";
1721 1721
 	}
1722 1722
         }
1723
-	$content = str_replace("<CURRENCY>",$currency,$content);
1724
-	$content = str_replace("<LOGO>",$src,$content);
1725
-	$content = str_replace("<MONTHLY_DESC>",$MONTHLY_DESC,$content);   
1726
-        $content = str_replace("<COMPANY_ADD>",$customer_address,$content);
1727
-        $content = str_replace("<RECEIPT_DETAILS_TABLE>",rtrim($RECEIPT_DETAILS_TABLE,""),$content);
1728
-        $content = str_replace("<COMPANY_DETAILS_TABLE>",$COMPANY_DETAILS_TABLE,$content);
1729
-        $content = str_replace("<COMPANY_DETAILS_SET>",$COMPANY_DETAILS_SET,$content);
1730
-        $content = str_replace("<CALL_DETAILS_TABLE>",$CALL_DETAILS_TABLE,$content);    
1723
+	$content = str_replace("<CURRENCY>", $currency, $content);
1724
+	$content = str_replace("<LOGO>", $src, $content);
1725
+	$content = str_replace("<MONTHLY_DESC>", $MONTHLY_DESC, $content);   
1726
+        $content = str_replace("<COMPANY_ADD>", $customer_address, $content);
1727
+        $content = str_replace("<RECEIPT_DETAILS_TABLE>", rtrim($RECEIPT_DETAILS_TABLE, ""), $content);
1728
+        $content = str_replace("<COMPANY_DETAILS_TABLE>", $COMPANY_DETAILS_TABLE, $content);
1729
+        $content = str_replace("<COMPANY_DETAILS_SET>", $COMPANY_DETAILS_SET, $content);
1730
+        $content = str_replace("<CALL_DETAILS_TABLE>", $CALL_DETAILS_TABLE, $content);    
1731 1731
        
1732 1732
        
1733 1733
        // echo $content ; exit;
1734
-        $invoice_path=$this->config->item('invoices_path');
1734
+        $invoice_path = $this->config->item('invoices_path');
1735 1735
         $download_path = $invoicedata['invoice_prefix'].$data['id'].".pdf";
1736 1736
         $this->html2pdf->pdf->SetDisplayMode('fullpage');
1737 1737
         $this->html2pdf->writeHTML($content);
1738 1738
         
1739
-        $this->html2pdf->Output($download_path,"D");        
1739
+        $this->html2pdf->Output($download_path, "D");        
1740 1740
       
1741 1741
         
1742 1742
     } 
1743 1743
 
1744
-    function calculate_currency($amount,$accountdata){
1745
-        $base_currency=Common_model::$global_config['system_config']['base_currency'];
1746
-        $from_currency=Common_model::$global_config['currency_list'][$base_currency];
1747
-        $to_currency =  $this->db_model->getSelect("currencyrate", "currency", array("currency"=> $accountdata["currency_id"]));
1748
-        if($to_currency->num_rows() > 0){
1744
+    function calculate_currency($amount, $accountdata) {
1745
+        $base_currency = Common_model::$global_config['system_config']['base_currency'];
1746
+        $from_currency = Common_model::$global_config['currency_list'][$base_currency];
1747
+        $to_currency = $this->db_model->getSelect("currencyrate", "currency", array("currency"=> $accountdata["currency_id"]));
1748
+        if ($to_currency->num_rows() > 0) {
1749 1749
             $to_currency_arr = $to_currency->result_array();
1750 1750
             $to_currency = $to_currency_arr[0]["currencyrate"];
1751 1751
         }
1752
-        else{
1753
-            $to_currency= $from_currency;
1752
+        else {
1753
+            $to_currency = $from_currency;
1754 1754
         }
1755 1755
 
1756 1756
         $cal_amount = ($amount * $to_currency) / $from_currency;
@@ -1758,22 +1758,22 @@  discard block
 block discarded – undo
1758 1758
     }
1759 1759
     
1760 1760
     function format_currency($amount) {
1761
-	$dp =  $this->db_model->getSelect("value", "system", array("name"=> "decimalpoints"));
1761
+	$dp = $this->db_model->getSelect("value", "system", array("name"=> "decimalpoints"));
1762 1762
         $dp = $dp->result_array();
1763 1763
         $dp = $dp[0]["value"];
1764 1764
 	
1765
-        return money_format('%.' . $dp . 'n', $amount);
1765
+        return money_format('%.'.$dp.'n', $amount);
1766 1766
     }
1767 1767
     
1768
-    function date_diff_custom($end='2020-06-09 10:30:00', $out_in_array=false){
1768
+    function date_diff_custom($end = '2020-06-09 10:30:00', $out_in_array = false) {
1769 1769
         $intervalo = date_diff(date_create(), date_create($end));
1770 1770
         $out = $intervalo->format("Years:%Y,Months:%M,Days:%d,Hours:%H,Minutes:%i,Seconds:%s");
1771
-        if(!$out_in_array)
1771
+        if ( ! $out_in_array)
1772 1772
             return $out;
1773 1773
         $a_out = array();
1774
-        array_walk(explode(',',$out),
1775
-        function($val,$key) use(&$a_out){
1776
-            $v=explode(':',$val);
1774
+        array_walk(explode(',', $out),
1775
+        function($val, $key) use(&$a_out){
1776
+            $v = explode(':', $val);
1777 1777
             $a_out[$v[0]] = $v[1];
1778 1778
         });
1779 1779
         return $a_out;
@@ -1789,12 +1789,12 @@  discard block
 block discarded – undo
1789 1789
 print_r($action);
1790 1790
             unset($action['action']);
1791 1791
             unset($action['advance_search']);
1792
-            $action['from_date'][0]=$action['from_date'][0] ? $action['from_date'][0]." 00:00:00" :'';
1793
- 	    $action['invoice_date'][0]=$action['invoice_date'][0] ? $action['invoice_date'][0]." 00:00:00" : '';
1792
+            $action['from_date'][0] = $action['from_date'][0] ? $action['from_date'][0]." 00:00:00" : '';
1793
+ 	    $action['invoice_date'][0] = $action['invoice_date'][0] ? $action['invoice_date'][0]." 00:00:00" : '';
1794 1794
             $this->session->set_userdata('invoice_list_search', $action);
1795 1795
         }
1796 1796
         if (@$ajax_search != 1) {
1797
-            redirect(base_url() . 'invoices/invoice_list/');
1797
+            redirect(base_url().'invoices/invoice_list/');
1798 1798
         }
1799 1799
     }
1800 1800
  function invoice_list_clearsearchfilter() {
@@ -1802,67 +1802,67 @@  discard block
 block discarded – undo
1802 1802
         $this->session->set_userdata('invoice_list_search', "");
1803 1803
     }
1804 1804
      /**============ From below code developed for ASTPP version 2.0 ======================================**/
1805
-    function generate_receipt($accountid,$amount,$accountinfo,$last_invoice_ID,$invoice_prefix,$due_date){
1806
-       $invoice_data = array("accountid"=>$accountid,"invoice_prefix" =>$invoice_prefix,"invoiceid"=>'0000'.$last_invoice_ID,"reseller_id"=>$accountinfo['reseller_id'],"invoice_date"=>gmdate("Y-m-d H:i:s"),"from_date"=>  gmdate("Y-m-d H:i:s"),"to_date"=>gmdate("Y-m-d H:i:s"),"due_date"=>$due_date,"status"=>1,"balance"=>$accountinfo['balance'],"amount"=>$amount,"type"=>'R',"confirm"=>'1');            
1807
-        $this->db->insert("invoices",$invoice_data);
1805
+    function generate_receipt($accountid, $amount, $accountinfo, $last_invoice_ID, $invoice_prefix, $due_date) {
1806
+       $invoice_data = array("accountid"=>$accountid, "invoice_prefix" =>$invoice_prefix, "invoiceid"=>'0000'.$last_invoice_ID, "reseller_id"=>$accountinfo['reseller_id'], "invoice_date"=>gmdate("Y-m-d H:i:s"), "from_date"=>  gmdate("Y-m-d H:i:s"), "to_date"=>gmdate("Y-m-d H:i:s"), "due_date"=>$due_date, "status"=>1, "balance"=>$accountinfo['balance'], "amount"=>$amount, "type"=>'R', "confirm"=>'1');            
1807
+        $this->db->insert("invoices", $invoice_data);
1808 1808
         $invoiceid = $this->db->insert_id();    
1809 1809
         return  $invoiceid;     
1810 1810
     }
1811
-    function insert_invoice_total_data($invoiceid,$sub_total,$sort_order){
1812
-        $invoice_total_arr = array("invoiceid"=>$invoiceid,"sort_order"=>$sort_order,
1813
-            "value"=>$sub_total, "title"=>"Sub Total","text"=>"Sub Total","class"=>"1");
1814
-        $this->db->insert("invoices_total",$invoice_total_arr);
1811
+    function insert_invoice_total_data($invoiceid, $sub_total, $sort_order) {
1812
+        $invoice_total_arr = array("invoiceid"=>$invoiceid, "sort_order"=>$sort_order,
1813
+            "value"=>$sub_total, "title"=>"Sub Total", "text"=>"Sub Total", "class"=>"1");
1814
+        $this->db->insert("invoices_total", $invoice_total_arr);
1815 1815
         return $sort_order++;
1816 1816
     }
1817 1817
     
1818
-    function apply_invoice_taxes($invoiceid,$accountid,$sort_order){
1819
-        $tax_priority="";
1818
+    function apply_invoice_taxes($invoiceid, $accountid, $sort_order) {
1819
+        $tax_priority = "";
1820 1820
         $where = array("accountid"=>$accountid);
1821
-        $accounttax_query = $this->db_model->getSelectWithOrder("*", "taxes_to_accounts", $where,"ASC","taxes_priority");
1822
-        if($accounttax_query->num_rows > 0){
1821
+        $accounttax_query = $this->db_model->getSelectWithOrder("*", "taxes_to_accounts", $where, "ASC", "taxes_priority");
1822
+        if ($accounttax_query->num_rows > 0) {
1823 1823
             $accounttax_query = $accounttax_query->result_array();
1824
-            foreach($accounttax_query as $tax_key => $tax_value){ 
1825
-            $taxes_info=$this->db->get_where('taxes',array('id'=>$tax_value['taxes_id']));
1826
-            if($taxes_info->num_rows() > 0 ){
1827
-                    $tax_value=$taxes_info->result_array();
1828
-                    $tax_value=$tax_value[0];
1829
-                 if($tax_value["taxes_priority"] == ""){
1824
+            foreach ($accounttax_query as $tax_key => $tax_value) { 
1825
+            $taxes_info = $this->db->get_where('taxes', array('id'=>$tax_value['taxes_id']));
1826
+            if ($taxes_info->num_rows() > 0) {
1827
+                    $tax_value = $taxes_info->result_array();
1828
+                    $tax_value = $tax_value[0];
1829
+                 if ($tax_value["taxes_priority"] == "") {
1830 1830
                      $tax_priority = $tax_value["taxes_priority"];
1831
-                 }else if($tax_value["taxes_priority"] > $tax_priority){
1831
+                 } else if ($tax_value["taxes_priority"] > $tax_priority) {
1832 1832
                      $query = $this->db_model->getSelect("SUM(value) as total", "invoices_total", array("invoiceid"=> $invoiceid));
1833
-                     $query =  $query->result_array();
1833
+                     $query = $query->result_array();
1834 1834
                      $sub_total = $query["0"]["total"];
1835 1835
                  }
1836
-                $tax_total = (($sub_total * ( $tax_value['taxes_rate'] / 100 )) + $tax_value['taxes_amount'] );
1837
-                $tax_array = array("invoiceid"=>$invoiceid,"title"=>"TAX","text"=>$tax_value['taxes_description'],
1838
-                    "value"=>$tax_total,"class"=>"2","sort_order"=>$sort_order);
1839
-                $this->db->insert("invoices_total",$tax_array);
1836
+                $tax_total = (($sub_total * ($tax_value['taxes_rate'] / 100)) + $tax_value['taxes_amount']);
1837
+                $tax_array = array("invoiceid"=>$invoiceid, "title"=>"TAX", "text"=>$tax_value['taxes_description'],
1838
+                    "value"=>$tax_total, "class"=>"2", "sort_order"=>$sort_order);
1839
+                $this->db->insert("invoices_total", $tax_array);
1840 1840
                 $sort_order++;
1841 1841
             }
1842 1842
             }
1843 1843
         }
1844 1844
         return $sort_order;
1845 1845
     }
1846
-    function set_invoice_total($invoiceid,$sort_order){
1846
+    function set_invoice_total($invoiceid, $sort_order) {
1847 1847
         $query = $this->db_model->getSelect("SUM(value) as total", "invoices_total", array("invoiceid"=> $invoiceid));
1848
-        $query =  $query->result_array();
1848
+        $query = $query->result_array();
1849 1849
         $sub_total = $query["0"]["total"];
1850 1850
         
1851
-        $invoice_total_arr = array("invoiceid"=>$invoiceid,"sort_order"=>$sort_order,
1852
-            "value"=>$sub_total,"title"=>"Total","text"=>"Total","class"=>"9");
1853
-        $this->db->insert("invoices_total",$invoice_total_arr);
1851
+        $invoice_total_arr = array("invoiceid"=>$invoiceid, "sort_order"=>$sort_order,
1852
+            "value"=>$sub_total, "title"=>"Total", "text"=>"Total", "class"=>"9");
1853
+        $this->db->insert("invoices_total", $invoice_total_arr);
1854 1854
         return true;
1855 1855
     }
1856
-    function invoice_delete_statically($inv_id){
1857
-	$data=array('deleted'=>1);
1858
-        $this->db->where('id',$inv_id);
1859
-        $this->db->update("invoices",$data);
1856
+    function invoice_delete_statically($inv_id) {
1857
+	$data = array('deleted'=>1);
1858
+        $this->db->where('id', $inv_id);
1859
+        $this->db->update("invoices", $data);
1860 1860
 	$this->session->set_flashdata('astpp_notification', 'Invoices removed successfully');
1861
-	redirect(base_url() . 'invoices/invoice_list/');
1861
+	redirect(base_url().'invoices/invoice_list/');
1862 1862
     }
1863
-    function invoice_delete_massege(){
1863
+    function invoice_delete_massege() {
1864 1864
 	$this->session->set_flashdata('astpp_notification', 'Invoices removed successfully');
1865
-	redirect(base_url() . 'invoices/invoice_list/');
1865
+	redirect(base_url().'invoices/invoice_list/');
1866 1866
     }
1867 1867
 }
1868 1868
 
Please login to merge, or discard this patch.
astpp/application/modules/invoices/libraries/invoices_form.php 1 patch
Spacing   +100 added lines, -100 removed lines patch added patch discarded remove patch
@@ -22,74 +22,74 @@  discard block
 block discarded – undo
22 22
 ###############################################################################
23 23
 
24 24
 if ( ! defined('BASEPATH')) exit('No direct script access allowed'); 
25
-class invoices_form{
25
+class invoices_form {
26 26
      function __construct($library_name = '') {
27 27
         $this->CI = & get_instance();
28 28
     }
29
-     function build_invoices_list_for_admin(){
29
+     function build_invoices_list_for_admin() {
30 30
     $account_info = $accountinfo = $this->CI->session->userdata('accountinfo');
31
-    $currency_id=$account_info['currency_id'];
32
-    $currency=$this->CI->common->get_field_name('currency', 'currency', $currency_id);
31
+    $currency_id = $account_info['currency_id'];
32
+    $currency = $this->CI->common->get_field_name('currency', 'currency', $currency_id);
33 33
 
34 34
       $logintype = $this->CI->session->userdata('logintype');
35
-      $url= ($logintype==0 ||$logintype==3 ) ? "/user/user_invoice_download/":'/invoices/invoice_main_download/';
36
-      $grid_field_arr  = json_encode(array(
37
-          array("Number","110","id","id,'',type","invoices","build_concat_string","","true","center"),
38
-          array("Type","130","id","id,'',type","invoices","build_concat_string","","true","center"),
39
-          array("Account","130","accountid","first_name,last_name,number","accounts","build_concat_string","","true","center"),
40
-          array("Generated<br/> Date","140","invoice_date","invoice_date","","get_invoice_date","","true","center"),
41
-	  array("From Date","120","from_date","from_date","","get_from_date","","true","center"),
42
-	  array("Due Date","130","","","","","","true","center"),
43
-	  array("Last <br/>Pay Date","100","","","","","","true","center"),
44
-          array("Amount($currency)","120","id","id","id","get_invoice_total","","true","right"),
35
+      $url = ($logintype == 0 || $logintype == 3) ? "/user/user_invoice_download/" : '/invoices/invoice_main_download/';
36
+      $grid_field_arr = json_encode(array(
37
+          array("Number", "110", "id", "id,'',type", "invoices", "build_concat_string", "", "true", "center"),
38
+          array("Type", "130", "id", "id,'',type", "invoices", "build_concat_string", "", "true", "center"),
39
+          array("Account", "130", "accountid", "first_name,last_name,number", "accounts", "build_concat_string", "", "true", "center"),
40
+          array("Generated<br/> Date", "140", "invoice_date", "invoice_date", "", "get_invoice_date", "", "true", "center"),
41
+	  array("From Date", "120", "from_date", "from_date", "", "get_from_date", "", "true", "center"),
42
+	  array("Due Date", "130", "", "", "", "", "", "true", "center"),
43
+	  array("Last <br/>Pay Date", "100", "", "", "", "", "", "true", "center"),
44
+          array("Amount($currency)", "120", "id", "id", "id", "get_invoice_total", "", "true", "right"),
45 45
 	 
46
-	    array("Outstanding <br/>Amount($currency)","140","","","","","","true","right"),
46
+	    array("Outstanding <br/>Amount($currency)", "140", "", "", "", "", "", "true", "right"),
47 47
 	  // array("Payment", "110", "payment", "", "", ""),
48
-          array("Action","120","","","",array(
49
-		     "DOWNLOAD"=>array("url"=>$url,"mode"=>"single"),
48
+          array("Action", "120", "", "", "", array(
49
+		     "DOWNLOAD"=>array("url"=>$url, "mode"=>"single"),
50 50
 		    // "VIEW" => array("url" => "invoices/invoice_summary_payment/", "mode" => "popup")
51 51
 		))
52 52
       ));
53 53
       return $grid_field_arr;
54 54
     } 
55
-     function build_invoices_list_for_customer_admin(){
55
+     function build_invoices_list_for_customer_admin() {
56 56
     $account_info = $accountinfo = $this->CI->session->userdata('accountinfo');
57
-    $currency_id=$account_info['currency_id'];
58
-    $currency=$this->CI->common->get_field_name('currency', 'currency', $currency_id);
57
+    $currency_id = $account_info['currency_id'];
58
+    $currency = $this->CI->common->get_field_name('currency', 'currency', $currency_id);
59 59
 
60 60
       $logintype = $this->CI->session->userdata('logintype');
61
-      $url= ($logintype==0 ||$logintype==3 ) ? "/user/user_invoice_download/":'/invoices/invoice_main_download/';
62
-      $grid_field_arr  = json_encode(array(
63
-          array("Number","110","id","id,'',type","invoices","build_concat_string","","true","center"),
64
-          array("Type","110","id","id,'',type","invoices","build_concat_string","","true","center"),
65
-          array("Generated<br/> Date","120","invoice_date","invoice_date","","get_invoice_date","","true","center"),
66
-	  array("From Date","120","from_date","from_date","","get_from_date","","true","center"),
67
-	  array("Due Date","130","","","","","","true","center"),
68
-	  array("Last <br/>Pay Date","100","","","","","","true","center"),
69
-          array("Amount($currency)","100","id","id","id","get_invoice_total","","true","right"),
61
+      $url = ($logintype == 0 || $logintype == 3) ? "/user/user_invoice_download/" : '/invoices/invoice_main_download/';
62
+      $grid_field_arr = json_encode(array(
63
+          array("Number", "110", "id", "id,'',type", "invoices", "build_concat_string", "", "true", "center"),
64
+          array("Type", "110", "id", "id,'',type", "invoices", "build_concat_string", "", "true", "center"),
65
+          array("Generated<br/> Date", "120", "invoice_date", "invoice_date", "", "get_invoice_date", "", "true", "center"),
66
+	  array("From Date", "120", "from_date", "from_date", "", "get_from_date", "", "true", "center"),
67
+	  array("Due Date", "130", "", "", "", "", "", "true", "center"),
68
+	  array("Last <br/>Pay Date", "100", "", "", "", "", "", "true", "center"),
69
+          array("Amount($currency)", "100", "id", "id", "id", "get_invoice_total", "", "true", "right"),
70 70
 	 
71
-	    array("Outstanding <br/>Amount($currency)","100","","","","","","true","right"),
72
-          array("Action","120","","","",array(
73
-		     "DOWNLOAD"=>array("url"=>$url,"mode"=>"single"),
71
+	    array("Outstanding <br/>Amount($currency)", "100", "", "", "", "", "", "true", "right"),
72
+          array("Action", "120", "", "", "", array(
73
+		     "DOWNLOAD"=>array("url"=>$url, "mode"=>"single"),
74 74
 		))
75 75
       ));
76 76
       return $grid_field_arr;
77 77
     } 
78
-    function build_invoices_list_for_customer(){
79
-      $url=($this->CI->session->userdata('logintype')==0 )?"/user/user_invoice_download/":'/invoices/invoice_main_download/';
78
+    function build_invoices_list_for_customer() {
79
+      $url = ($this->CI->session->userdata('logintype') == 0) ? "/user/user_invoice_download/" : '/invoices/invoice_main_download/';
80 80
     // array(display name, width, db_field_parent_table,feidname, db_field_child_table,function name);
81
-      $grid_field_arr  = json_encode(array(
82
-          array("Number","100","id","id,'',type","invoices","build_concat_string","","true","center"),
83
-          array("Account","110","accountid","first_name,last_name,number","accounts","build_concat_string","","true","center"),
84
-          array("Generated Date","140","invoice_date","invoice_date","","get_invoice_date","","true","center"),
85
-	  array("From Date","140","from_date","from_date","","get_from_date","","true","center"),
86
-	  array("Due Date","150","","","","","","true","center"),
87
-	  array("Last Pay Date","150","","","","","","true","center"),
88
-          array("Amount","150","id","id","id","get_invoice_total","","true","center"),
89
-	  array("Outstanding Amount","150","","","",""),
81
+      $grid_field_arr = json_encode(array(
82
+          array("Number", "100", "id", "id,'',type", "invoices", "build_concat_string", "", "true", "center"),
83
+          array("Account", "110", "accountid", "first_name,last_name,number", "accounts", "build_concat_string", "", "true", "center"),
84
+          array("Generated Date", "140", "invoice_date", "invoice_date", "", "get_invoice_date", "", "true", "center"),
85
+	  array("From Date", "140", "from_date", "from_date", "", "get_from_date", "", "true", "center"),
86
+	  array("Due Date", "150", "", "", "", "", "", "true", "center"),
87
+	  array("Last Pay Date", "150", "", "", "", "", "", "true", "center"),
88
+          array("Amount", "150", "id", "id", "id", "get_invoice_total", "", "true", "center"),
89
+	  array("Outstanding Amount", "150", "", "", "", ""),
90 90
 	  // array("Payment", "110", "payment", "", "", ""),
91
-          array("Action","160","","","",array(
92
-		     "DOWNLOAD"=>array("url"=>$url,"mode"=>"single"),
91
+          array("Action", "160", "", "", "", array(
92
+		     "DOWNLOAD"=>array("url"=>$url, "mode"=>"single"),
93 93
 		    // "VIEW" => array("url" => "invoices/invoice_summary_payment/", "mode" => "popup")
94 94
 		))
95 95
 			));
@@ -98,89 +98,89 @@  discard block
 block discarded – undo
98 98
    function get_invoice_search_form()
99 99
     {
100 100
 	$account_data = $this->CI->session->userdata("accountinfo");
101
-        $reseller_id=$account_data['type']==1 ? $account_data['id']:0;
102
-        $form['forms'] = array("",array('id'=>"invoice_search"));
101
+        $reseller_id = $account_data['type'] == 1 ? $account_data['id'] : 0;
102
+        $form['forms'] = array("", array('id'=>"invoice_search"));
103 103
         $form['Search'] = array(
104
-            array('Number', 'INPUT', array('name' => 'invoiceid[invoiceid]','','size' => '20', 'class' => "text field"), '', 'tOOL TIP', '1', 'id[invoiceid-string]', '', '','', 'search_string_type', ''),
105
-	    array('From Date', 'INPUT', array('name' => 'from_date[0]','id'=>'invoice_from_date','size' => '20', 'class' => "text field"), '', 'tOOL TIP', '', 'from_date[from_date-date]'),
106
-	     array('To Date', 'INPUT', array('name' => 'to_date[0]','id'=>'invoice_to_date','size' => '20', 'class' => "text field"), '', 'tOOL TIP', '', 'from_date[from_date-date]'),
104
+            array('Number', 'INPUT', array('name' => 'invoiceid[invoiceid]', '', 'size' => '20', 'class' => "text field"), '', 'tOOL TIP', '1', 'id[invoiceid-string]', '', '', '', 'search_string_type', ''),
105
+	    array('From Date', 'INPUT', array('name' => 'from_date[0]', 'id'=>'invoice_from_date', 'size' => '20', 'class' => "text field"), '', 'tOOL TIP', '', 'from_date[from_date-date]'),
106
+	     array('To Date', 'INPUT', array('name' => 'to_date[0]', 'id'=>'invoice_to_date', 'size' => '20', 'class' => "text field"), '', 'tOOL TIP', '', 'from_date[from_date-date]'),
107 107
 	    
108 108
 	    array('Amount', 'INPUT', array('name' => 'amount[amount]', 'value' => '', 'size' => '20', 'class' => "text field "), '', 'Tool tips info', '1', 'amount[amount-string]', '', '', '', 'search_string_type', ''),
109
-	    array('Generated Date', 'INPUT', array('name' => 'invoice_date[0]','','size' => '20', 'class' => "text field",'id'=>'invoice_date'), '', 'tOOL TIP', '', 'invoice_date[invoice_date-date]'),
109
+	    array('Generated Date', 'INPUT', array('name' => 'invoice_date[0]', '', 'size' => '20', 'class' => "text field", 'id'=>'invoice_date'), '', 'tOOL TIP', '', 'invoice_date[invoice_date-date]'),
110 110
 	    array('Invoice', 'deleted', 'SELECT', '', '', 'tOOL TIP', 'Please Enter account number', '', '', '', 'set_invoice_details'),		   
111
-	    array('Account', 'accountid', 'SELECT', '', '', 'tOOL TIP', 'Please Enter account number', 'id', 'IF(`deleted`=1,concat( first_name, " ", last_name, " ", "(", number, ")^" ),concat( first_name, " ", last_name, " ", "(", number, ")" )) as number', 'accounts', 'build_dropdown_deleted', 'where_arr', array("reseller_id" => $reseller_id,"type"=>"GLOBAL")),
112
-	    array('', 'HIDDEN', 'ajax_search','1', '', '', ''),    
113
-            array('', 'HIDDEN', 'advance_search','1', '', '', ''));
111
+	    array('Account', 'accountid', 'SELECT', '', '', 'tOOL TIP', 'Please Enter account number', 'id', 'IF(`deleted`=1,concat( first_name, " ", last_name, " ", "(", number, ")^" ),concat( first_name, " ", last_name, " ", "(", number, ")" )) as number', 'accounts', 'build_dropdown_deleted', 'where_arr', array("reseller_id" => $reseller_id, "type"=>"GLOBAL")),
112
+	    array('', 'HIDDEN', 'ajax_search', '1', '', '', ''),    
113
+            array('', 'HIDDEN', 'advance_search', '1', '', '', ''));
114 114
         
115
-        $form['button_search'] = array('name' => 'action', 'id'=>"invoice_search_btn",'content' => 'Search', 'value' => 'save', 'type' => 'button', 'class' => 'btn btn-line-parrot pull-right');
116
-        $form['button_reset'] = array('name' => 'action','id'=>"id_reset", 'content' => 'Clear', 'value' => 'cancel', 'type' => 'reset', 'class' => 'btn btn-line-sky pull-right margin-x-10');
115
+        $form['button_search'] = array('name' => 'action', 'id'=>"invoice_search_btn", 'content' => 'Search', 'value' => 'save', 'type' => 'button', 'class' => 'btn btn-line-parrot pull-right');
116
+        $form['button_reset'] = array('name' => 'action', 'id'=>"id_reset", 'content' => 'Clear', 'value' => 'cancel', 'type' => 'reset', 'class' => 'btn btn-line-sky pull-right margin-x-10');
117 117
         
118 118
         return $form;
119 119
     }
120 120
     
121
-    function build_grid_buttons(){
121
+    function build_grid_buttons() {
122 122
 	$buttons_json = json_encode(array(
123 123
 				    ));
124 124
 	return $buttons_json;
125 125
     }
126
-     function get_invoiceconf_form_fields($invoiceconf = '0'){    
127
-     if(!empty($invoiceconf)){
128
-	if($invoiceconf['logo'] != ''){
129
-	     $logo=$invoiceconf['file'];
130
-	}else{
131
-	     $logo=$invoiceconf['logo'];
126
+     function get_invoiceconf_form_fields($invoiceconf = '0') {    
127
+     if ( ! empty($invoiceconf)) {
128
+	if ($invoiceconf['logo'] != '') {
129
+	     $logo = $invoiceconf['file'];
130
+	} else {
131
+	     $logo = $invoiceconf['logo'];
132 132
 	}
133
-     $accountid=$invoiceconf['accountid'];  
134
-          if($logo != ''){        
135
-             $file_name= base_url()."upload/$logo";
136
-             $image_path= array('Existing Image', 'IMAGE', array('type'=>'image','name' => 'image' ,'style'=>'width:100%;margin-top:20px;','src'=> $file_name), '', 'tOOL TIP', '');
137
-              $delete_logo=array('Delete logo', 'DEL_BUTTON', array('value'=>'ankit','style'=>'margin-top:20px;','name' => 'button','id'=>'logo_delete','size' => '20', 'class' => "btn btn-line-parrot"), '', 'tOOL TIP', 'Please Enter account number');
138
-             }else{
139
-              $image_path= array('Existing Image', 'HIDDEN', array('type'=>'','name' => '' ,'style'=>'width:250px;'), '', 'tOOL TIP', '');
140
-              $delete_logo= array('Delete logo', 'HIDDEN', array('value'=>'ankit','style'=>'margin-top:0px;','name' => 'button','id'=>'logo_delete','size' => '20', 'maxlength' => '100', 'class' => "btn btn-line-parrot"), '', 'tOOL TIP', 'Please Enter account number');
133
+     $accountid = $invoiceconf['accountid'];  
134
+          if ($logo != '') {        
135
+             $file_name = base_url()."upload/$logo";
136
+             $image_path = array('Existing Image', 'IMAGE', array('type'=>'image', 'name' => 'image', 'style'=>'width:100%;margin-top:20px;', 'src'=> $file_name), '', 'tOOL TIP', '');
137
+              $delete_logo = array('Delete logo', 'DEL_BUTTON', array('value'=>'ankit', 'style'=>'margin-top:20px;', 'name' => 'button', 'id'=>'logo_delete', 'size' => '20', 'class' => "btn btn-line-parrot"), '', 'tOOL TIP', 'Please Enter account number');
138
+             } else {
139
+              $image_path = array('Existing Image', 'HIDDEN', array('type'=>'', 'name' => '', 'style'=>'width:250px;'), '', 'tOOL TIP', '');
140
+              $delete_logo = array('Delete logo', 'HIDDEN', array('value'=>'ankit', 'style'=>'margin-top:0px;', 'name' => 'button', 'id'=>'logo_delete', 'size' => '20', 'maxlength' => '100', 'class' => "btn btn-line-parrot"), '', 'tOOL TIP', 'Please Enter account number');
141 141
              // $image_path=array();
142 142
              }
143 143
              
144
-             }else{
144
+             } else {
145 145
              $logo = '';
146 146
              $file_name = '';
147
-             $accountid=0;
148
-             $image_path= array('Existing Image', 'HIDDEN', array('type'=>'','name' => '' ), '', 'tOOL TIP', '');
149
-             $delete_logo= array('Delete logo', 'HIDDEN', array('value'=>'','style'=>'margin-top:0px;','name' => 'button','onclick'=>'return image_delete('.$accountid.')','size' => '20', 'maxlength' => '100', 'class' => "btn btn-line-parrot"), '', 'tOOL TIP', 'Please Enter account number');
147
+             $accountid = 0;
148
+             $image_path = array('Existing Image', 'HIDDEN', array('type'=>'', 'name' => ''), '', 'tOOL TIP', '');
149
+             $delete_logo = array('Delete logo', 'HIDDEN', array('value'=>'', 'style'=>'margin-top:0px;', 'name' => 'button', 'onclick'=>'return image_delete('.$accountid.')', 'size' => '20', 'maxlength' => '100', 'class' => "btn btn-line-parrot"), '', 'tOOL TIP', 'Please Enter account number');
150 150
             //$image_path=array();
151 151
              
152 152
              
153 153
              }
154
-	$form['forms'] = array(base_url() . 'invoices/invoice_conf/',array('id'=>'invoice_conf_form','method'=>'POST','name'=>'invoice_conf_form','enctype'=>'multipart/form-data'));
154
+	$form['forms'] = array(base_url().'invoices/invoice_conf/', array('id'=>'invoice_conf_form', 'method'=>'POST', 'name'=>'invoice_conf_form', 'enctype'=>'multipart/form-data'));
155 155
         $form['Configuration '] = array(
156
-            array('', 'HIDDEN', array('name'=>'id'),'', '', '', ''), 
157
-            array('', 'HIDDEN', array('name'=>'accountid'),'', '', '', ''),
156
+            array('', 'HIDDEN', array('name'=>'id'), '', '', '', ''), 
157
+            array('', 'HIDDEN', array('name'=>'accountid'), '', '', '', ''),
158 158
            //  array('', 'HIDDEN', array('name' => 'start_name','value' => '1'), '', '', ''),
159
-            array('Company name', 'INPUT', array('name' => 'company_name','size' => '20',  'class' => "text field medium"), '', 'tOOL TIP', 'Please Enter account number'),
160
-                array('Address', 'INPUT', array('name' => 'address','size' => '20',  'class' => "text field medium"), '', 'tOOL TIP', 'Please Enter account number'),
161
-                array('City', 'INPUT', array('name' => 'city','size' => '20',  'class' => "text field medium"), '', 'tOOL TIP', 'Please Enter account number'),
162
-                array('Province', 'INPUT', array('name' => 'province','size' => '20', 'class' => "text field medium"), '', 'tOOL TIP', 'Please Enter account number'),
163
-                array('Country', 'INPUT', array('name' => 'country','size' => '20',  'class' => "text field medium"), '', 'tOOL TIP', 'Please Enter account number'),
164
-                array('Zipcode', 'INPUT', array('name' => 'zipcode','size' => '20',  'class' => "text field medium"), '', 'tOOL TIP', 'Please Enter account number'),
165
-                array('Telephone', 'INPUT', array('name' => 'telephone','size' => '20',  'class' => "text field medium"), '', 'tOOL TIP', 'Please Enter account number'),
166
-                array('Fax', 'INPUT', array('name' => 'fax','size' => '20',  'class' => "text field medium"), '', 'tOOL TIP', 'Please Enter account number'),
167
-                array('Email Address', 'INPUT', array('name' => 'emailaddress','size' => '20', 'class' => "text field medium"), '', 'tOOL TIP', 'Please Enter account number'),
168
-                array('Website', 'INPUT', array('name' => 'website','size' => '20', 'class' => "text field medium"), '', 'tOOL TIP', 'Please Enter account number'),
159
+            array('Company name', 'INPUT', array('name' => 'company_name', 'size' => '20', 'class' => "text field medium"), '', 'tOOL TIP', 'Please Enter account number'),
160
+                array('Address', 'INPUT', array('name' => 'address', 'size' => '20', 'class' => "text field medium"), '', 'tOOL TIP', 'Please Enter account number'),
161
+                array('City', 'INPUT', array('name' => 'city', 'size' => '20', 'class' => "text field medium"), '', 'tOOL TIP', 'Please Enter account number'),
162
+                array('Province', 'INPUT', array('name' => 'province', 'size' => '20', 'class' => "text field medium"), '', 'tOOL TIP', 'Please Enter account number'),
163
+                array('Country', 'INPUT', array('name' => 'country', 'size' => '20', 'class' => "text field medium"), '', 'tOOL TIP', 'Please Enter account number'),
164
+                array('Zipcode', 'INPUT', array('name' => 'zipcode', 'size' => '20', 'class' => "text field medium"), '', 'tOOL TIP', 'Please Enter account number'),
165
+                array('Telephone', 'INPUT', array('name' => 'telephone', 'size' => '20', 'class' => "text field medium"), '', 'tOOL TIP', 'Please Enter account number'),
166
+                array('Fax', 'INPUT', array('name' => 'fax', 'size' => '20', 'class' => "text field medium"), '', 'tOOL TIP', 'Please Enter account number'),
167
+                array('Email Address', 'INPUT', array('name' => 'emailaddress', 'size' => '20', 'class' => "text field medium"), '', 'tOOL TIP', 'Please Enter account number'),
168
+                array('Website', 'INPUT', array('name' => 'website', 'size' => '20', 'class' => "text field medium"), '', 'tOOL TIP', 'Please Enter account number'),
169 169
                  
170 170
                 
171 171
          );
172 172
          $form['Invoice Configuration '] = array(
173
-            array('', 'HIDDEN', array('name'=>'id'),'', '', '', ''), 
174
-            array('', 'HIDDEN', array('name'=>'accountid'),'', '', '', ''),     
173
+            array('', 'HIDDEN', array('name'=>'id'), '', '', '', ''), 
174
+            array('', 'HIDDEN', array('name'=>'accountid'), '', '', '', ''),     
175 175
                    array('Invoice Notification', 'invoice_notification', 'SELECT', '', '', 'tOOL TIP', '', '', '', '', 'set_allow_invoice'),                
176 176
                   array('Invoice Due Notification', 'invoice_due_notification', 'SELECT', '', '', 'tOOL TIP', '', '', '', '', 'set_allow_invoice'),
177
-                    array('Invoice Date Interval', 'INPUT', array('name' => 'interval','size' => '20',  'class' => "text field medium"), '', 'tOOL TIP', 'Please Enter account number'),
178
-                   array('Notify before days', 'INPUT', array('name' => 'notify_before_day','size' => '20',  'class' => "text field medium"), '', 'tOOL TIP', 'Please Enter account number'),
179
-                    array('Invoice Prefix', 'INPUT', array('name' => 'invoice_prefix','size' => '20', 'class' => "text field medium"), '', 'tOOL TIP', 'Please Enter account number'),
180
-                  array('Invoice Start Form', 'INPUT', array('name' => 'invoice_start_from','size' => '20',  'class' => "text field medium"), '', 'tOOL TIP', 'Please Enter account number'),
181
-                     array('Invoice Taxes number', 'INPUT', array('name' => 'invoice_taxes_number','size' => '20', 'class' => "text field medium"), '', 'tOOL TIP', 'Please Enter account number'),
182
-              array('', 'HIDDEN', array('name'=>''),'', '', '', ''),
183
-                    array('', 'HIDDEN', array('name'=>''),'', '', '', ''),
177
+                    array('Invoice Date Interval', 'INPUT', array('name' => 'interval', 'size' => '20', 'class' => "text field medium"), '', 'tOOL TIP', 'Please Enter account number'),
178
+                   array('Notify before days', 'INPUT', array('name' => 'notify_before_day', 'size' => '20', 'class' => "text field medium"), '', 'tOOL TIP', 'Please Enter account number'),
179
+                    array('Invoice Prefix', 'INPUT', array('name' => 'invoice_prefix', 'size' => '20', 'class' => "text field medium"), '', 'tOOL TIP', 'Please Enter account number'),
180
+                  array('Invoice Start Form', 'INPUT', array('name' => 'invoice_start_from', 'size' => '20', 'class' => "text field medium"), '', 'tOOL TIP', 'Please Enter account number'),
181
+                     array('Invoice Taxes number', 'INPUT', array('name' => 'invoice_taxes_number', 'size' => '20', 'class' => "text field medium"), '', 'tOOL TIP', 'Please Enter account number'),
182
+              array('', 'HIDDEN', array('name'=>''), '', '', '', ''),
183
+                    array('', 'HIDDEN', array('name'=>''), '', '', '', ''),
184 184
          );
185 185
 	 $form['Company personalization'] = array(
186 186
 		
@@ -188,11 +188,11 @@  discard block
 block discarded – undo
188 188
 		 array('Website Domain', 'INPUT', array('name' => 'domain', 'size' => '20', 'maxlength' => '100', 'class' => "text field medium"), '', 'tOOL TIP', ''),
189 189
 	    array('Website Header', 'INPUT', array('name' => 'website_title', 'size' => '100', 'maxlength' => '100', 'class' => "text field medium"), '', 'tOOL TIP', ''),
190 190
             array('Website Footer', 'INPUT', array('name' => 'website_footer', 'size' => '200', 'maxlength' => '200', 'class' => "text field medium"), '', 'tOOL TIP', ''),
191
-	    array('Company logo', 'IMAGE', array('name' => 'file','size' => '20', 'maxlength' => '100', 'class' => "",'id'=>'uploadFile','type'=>'file'),'class' => '', 'tOOL TIP', 'Please Enter account number'),
191
+	    array('Company logo', 'IMAGE', array('name' => 'file', 'size' => '20', 'maxlength' => '100', 'class' => "", 'id'=>'uploadFile', 'type'=>'file'), 'class' => '', 'tOOL TIP', 'Please Enter account number'),
192 192
 		//array('', 'BLANL_DIV', array('name'=>'accountid','id'=>'imagePreview'),'', '', '', ''),
193
-		$delete_logo,$image_path,
193
+		$delete_logo, $image_path,
194 194
                  );
195
-        $form['button_save'] = array('name' => 'action', 'content' =>'Save' , 'value' => 'save', 'type' => 'submit', 'class' => 'btn btn-line-parrot');
195
+        $form['button_save'] = array('name' => 'action', 'content' =>'Save', 'value' => 'save', 'type' => 'submit', 'class' => 'btn btn-line-parrot');
196 196
         
197 197
         return $form;
198 198
         
Please login to merge, or discard this patch.
astpp/application/modules/invoices/views/view_invoices_list.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 <?php
127 127
 $login_type = $this->session->userdata['userlevel_logintype']; 
128 128
  $account_data = $this->session->userdata("accountinfo");
129
- $id= $account_data['id'];
129
+ $id = $account_data['id'];
130 130
 
131 131
 ?>   
132 132
 
@@ -165,15 +165,15 @@  discard block
 block discarded – undo
165 165
 		        </div>
166 166
 	<div class="col-md-5"><label style="text-align:left;float:left;" class="col-md-3"><?php echo gettext('Accounts'); ?> </label>
167 167
 			<?php
168
-			        if($login_type == -1){
169
-				$where="deleted = '0' AND reseller_id = '0' AND status = '0' AND (type= '0' OR type= '3' OR type= '1')";
170
-				}if($login_type == 1){
171
-				 $where="deleted = '0' AND reseller_id = '$id' AND status = '0' AND (type= '0' OR type= '3' OR type='1')";
168
+			        if ($login_type == -1) {
169
+				$where = "deleted = '0' AND reseller_id = '0' AND status = '0' AND (type= '0' OR type= '3' OR type= '1')";
170
+				}if ($login_type == 1) {
171
+				 $where = "deleted = '0' AND reseller_id = '$id' AND status = '0' AND (type= '0' OR type= '3' OR type='1')";
172 172
 				
173 173
 				}
174
-		$account=$this->db_model->build_dropdown_invoices('id,first_name,last_name,number,type', 'accounts', '', $where);?>
174
+		$account = $this->db_model->build_dropdown_invoices('id,first_name,last_name,number,type', 'accounts', '', $where); ?>
175 175
 		    
176
-	   <?php  echo form_dropdown_all('accountid', $account,''); ?>
176
+	   <?php  echo form_dropdown_all('accountid', $account, ''); ?>
177 177
 			</div>
178 178
 	                <div>
179 179
 		        <div><label style="text-align:left;float:left;" class="col-md-1"><?php echo gettext('Notes'); ?>   </label>
Please login to merge, or discard this patch.
astpp/application/modules/invoices/views/view_invoice_payment.php 1 patch
Spacing   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -42,9 +42,9 @@  discard block
 block discarded – undo
42 42
   </h2>	        	        	            
43 43
   </div>
44 44
   <div class="col-md-12" style="border: 1px solid #ccc; border-radius: 5px;">    
45
-    <?php  if($logintype == 0){ ?>  
45
+    <?php  if ($logintype == 0) { ?>  
46 46
     <form name="payment_form" id="payment_form"  method="POST" >
47
-  	<?php } else{?>
47
+  	<?php } else {?>
48 48
             <form name="admin_form" id="admin_form" action="/invoices/invoice_admin_payment/" method="POST">
49 49
    		<?php } ?>
50 50
 	<br/>
@@ -72,10 +72,10 @@  discard block
 block discarded – undo
72 72
 			<td>
73 73
 	 		 <font style="font-weight:bold;" >Email :</font> <font style="color:#a09d9d;" >
74 74
 				 <?php /**** harsh ***/ 
75
-				if($accountdata['email']!=""){
76
-					$attac_exp=explode(",",$accountdata['email']);
77
-					foreach($attac_exp as $key=>$value){
78
-						if($value != ''){
75
+				if ($accountdata['email'] != "") {
76
+					$attac_exp = explode(",", $accountdata['email']);
77
+					foreach ($attac_exp as $key=>$value) {
78
+						if ($value != '') {
79 79
 							echo "<br/>".$value;
80 80
 						}
81 81
 					}
@@ -100,13 +100,13 @@  discard block
 block discarded – undo
100 100
 	        </tr>
101 101
 	<tr>
102 102
 		<td>
103
-		 		<b>From Date : </b><span style="color:#a09d9d;"> <?php echo date('Y-m-d', strtotime($from_date)) ; ?></span>
103
+		 		<b>From Date : </b><span style="color:#a09d9d;"> <?php echo date('Y-m-d', strtotime($from_date)); ?></span>
104 104
 		 </td>
105 105
 	</tr>
106 106
 	<tr>
107 107
 		<td>
108 108
  		<b>Due Date : </b><span style="color:#a09d9d;"><?php 
109
-                echo date('Y-m-d', strtotime($payment_due_date)) ;
109
+                echo date('Y-m-d', strtotime($payment_due_date));
110 110
 		?></span>
111 111
 		 </td>
112 112
 	</tr>
@@ -120,9 +120,9 @@  discard block
 block discarded – undo
120 120
 		<tr style="">
121 121
 		 <td><b >Invoice Amount :</b></td>
122 122
 <?php
123
-if(!empty($invoice_date)){
123
+if ( ! empty($invoice_date)) {
124 124
  ?>
125
-		 <td><span class="pull-right" style="color:#3278b6"><b><?php echo $this->common->currency_decimal($amount); ?> <?php  echo $to_currency;  ?></b> </span></td>
125
+		 <td><span class="pull-right" style="color:#3278b6"><b><?php echo $this->common->currency_decimal($amount); ?> <?php  echo $to_currency; ?></b> </span></td>
126 126
 		 <input type="hidden" name="total_amount" id="total_amount" class="article" value="<?php echo $amount; ?>" >
127 127
 		  <input type="hidden" readonly name="recharge" value="paypal_invoice">
128 128
 	 </tr> 
@@ -140,24 +140,24 @@  discard block
 block discarded – undo
140 140
 	   </th>
141 141
 	 </tr> 
142 142
 	 <?php
143
-$paypal=0;
144
- foreach($invoice_final_query as $value){
143
+$paypal = 0;
144
+ foreach ($invoice_final_query as $value) {
145 145
  
146
-    if($value['item_type'] != 'INVPAY' && $value['item_type'] != 'PAYMENT')    {
147
-       $debit=$value['debit'];
148
-       $credit=$value['credit'];
149
-       $paypal+=$credit;
150
-       $created_date=$value['created_date'];
151
-       $paypalid=$value['item_id'];
152
-       $outstanding=$amount-$paypal;
153
-       $amount_visible='0000';
146
+    if ($value['item_type'] != 'INVPAY' && $value['item_type'] != 'PAYMENT') {
147
+       $debit = $value['debit'];
148
+       $credit = $value['credit'];
149
+       $paypal += $credit;
150
+       $created_date = $value['created_date'];
151
+       $paypalid = $value['item_id'];
152
+       $outstanding = $amount - $paypal;
153
+       $amount_visible = '0000';
154 154
       
155 155
       
156 156
      
157 157
 ?>	
158 158
  	 <tr style="height:20px;">
159 159
 			 <td><?php echo $value['description']; ?>  </td>
160
-			 <td><div class="pull-right"><?php echo $this->common->currency_decimal($this->common_model->calculate_currency($debit)); ?> <?php  echo $to_currency;  ?></div></td>
160
+			 <td><div class="pull-right"><?php echo $this->common->currency_decimal($this->common_model->calculate_currency($debit)); ?> <?php  echo $to_currency; ?></div></td>
161 161
 			 <input type="hidden" name="new_amount" value="<?php echo $this->common->currency_decimal($this->common_model->calculate_currency($debit)); ?>">
162 162
 			 
163 163
 			
@@ -196,18 +196,18 @@  discard block
 block discarded – undo
196 196
 			
197 197
 	 </tr> 
198 198
 	 <?php
199
-$paypal=0;
200
-if($invoice_date){
201
- foreach($invoice_total_query as $value){
199
+$paypal = 0;
200
+if ($invoice_date) {
201
+ foreach ($invoice_total_query as $value) {
202 202
  
203 203
      
204
-       $debit=$value['debit'];
205
-       $credit=$value['credit'];
206
-       $paypal+=$credit;
207
-       $created_date=$value['created_date'];
208
-       $paypalid=$value['item_id'];
209
-       $outstanding=$amount-$paypal;
210
-       $amount_visible='0000';
204
+       $debit = $value['debit'];
205
+       $credit = $value['credit'];
206
+       $paypal += $credit;
207
+       $created_date = $value['created_date'];
208
+       $paypalid = $value['item_id'];
209
+       $outstanding = $amount - $paypal;
210
+       $amount_visible = '0000';
211 211
       
212 212
       
213 213
      
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
  	 <tr>
216 216
 			 <td> <?php echo date('Y-m-d	', strtotime($created_date)) ?></td>
217 217
 			 <td><?php echo $value['description']; ?>  <?php echo $paypalid; ?></td>
218
-			 <td><div class="pull-right"><?php echo $this->common->currency_decimal($this->common_model->calculate_currency($credit)); ?> <?php  echo $to_currency;  ?></div></td>
218
+			 <td><div class="pull-right"><?php echo $this->common->currency_decimal($this->common_model->calculate_currency($credit)); ?> <?php  echo $to_currency; ?></div></td>
219 219
 			 <input type="hidden" name="new_amount" value="<?php echo $this->common->currency_decimal($this->common_model->calculate_currency($debit)); ?>">
220 220
 			 
221 221
 			
@@ -230,7 +230,7 @@  discard block
 block discarded – undo
230 230
 	    	 	</th>
231 231
 	    	 	<td align="right">
232 232
 	    	 	<!--0-->
233
-	    	 	<b><?php if($paypal){ echo   $this->common->currency_decimal($this->common_model->calculate_currency($paypal));  }else { echo $this->common->currency_decimal($this->common_model->calculate_currency($amount_visible)); ;}?> <?php  echo $to_currency;  ?></b>
233
+	    	 	<b><?php if ($paypal) { echo   $this->common->currency_decimal($this->common_model->calculate_currency($paypal)); } else { echo $this->common->currency_decimal($this->common_model->calculate_currency($amount_visible)); ;}?> <?php  echo $to_currency; ?></b>
234 234
 	    	 	</td>
235 235
 	    	 	
236 236
 	    	 	
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
 		
252 252
 		<tr style="">
253 253
 		 <td><b >Outstanding Amount :</b></td>
254
-	<td><span class="pull-right" style="color:#3278b6"><b><?php if($debit == ''){ echo  $this->common->currency_decimal($outstanding); ?> <?php  echo $to_currency; }else {  echo $this->common->currency_decimal($outstanding); ?> <?php  echo $to_currency; } ?></b> </span></td>
254
+	<td><span class="pull-right" style="color:#3278b6"><b><?php if ($debit == '') { echo  $this->common->currency_decimal($outstanding); ?> <?php  echo $to_currency; } else {  echo $this->common->currency_decimal($outstanding); ?> <?php  echo $to_currency; } ?></b> </span></td>
255 255
 		 <input type="hidden" name="total_amount" id="total_amount" class="article" value="<?php echo  $this->common->currency_decimal($amount); ?>" >
256 256
 	 </tr> 
257 257
 </table>
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
 	<td width="50%" valign="top">
263 263
 	</td>
264 264
 	<td width="50%" valign="top" style="border-left:2px solid #ccc;">
265
- <?php  if($logintype == 0 || $logintype == 3){ ?>
265
+ <?php  if ($logintype == 0 || $logintype == 3) { ?>
266 266
 	  <table class="invoice_table1  pull-right">
267 267
 	    <tr style="border-bottom:2px solid #dfdfe1; color:#474747;"><th colspan="2">Payment Amount :</th></tr>
268 268
 	      <tr>
@@ -298,7 +298,7 @@  discard block
 block discarded – undo
298 298
 		</td>
299 299
 	     </tr>
300 300
 	</table>
301
-<?php }elseif($logintype == 1){?>
301
+<?php }elseif ($logintype == 1) {?>
302 302
 	  <table class="invoice_table1  pull-right">
303 303
 	    <tr style="border-bottom:2px solid #dfdfe1; color:#474747;"><th colspan="2">Payment Amount :</th></tr>
304 304
 	      <tr>
@@ -320,7 +320,7 @@  discard block
 block discarded – undo
320 320
 	     </tr>
321 321
 	</table>
322 322
 
323
-<?php }else{ ?>
323
+<?php } else { ?>
324 324
 	<table class="invoice_table1  pull-right">
325 325
   	  <tr style="border-bottom:2px solid #dfdfe1; color:#474747;"><th colspan="2">Payment Amount :</th></tr>
326 326
   	    <tr>
@@ -352,15 +352,15 @@  discard block
 block discarded – undo
352 352
 	
353 353
 <div class="col-md-12 padding-b-20">
354 354
 <div class="" style="margin-left:400px;">
355
- <?php  if($logintype == 0 ){ ?>
355
+ <?php  if ($logintype == 0) { ?>
356 356
 <?php
357
-if($logintype == 0 && $accountdata['paypal_permission']== 0){ 
357
+if ($logintype == 0 && $accountdata['paypal_permission'] == 0) { 
358 358
 ?>
359
-  <input class="btn btn-line-parrot search_generate_bar"  name="Paynow" id="Paynow" value="Pay With Paypal" type="button" onclick="return payment('<?php echo $paypal_url;  ?>'); "> 
359
+  <input class="btn btn-line-parrot search_generate_bar"  name="Paynow" id="Paynow" value="Pay With Paypal" type="button" onclick="return payment('<?php echo $paypal_url; ?>'); "> 
360 360
 <input id="ok" class="btn btn-line-sky margin-x-10" type="button" value="Cancel" onclick="window.history.back();"; name="action">
361 361
  <?php } } ?>
362 362
  <div  class="margin-t-20 ">
363
-  <?php  if($logintype == 2 || $logintype == 1){ ?>
363
+  <?php  if ($logintype == 2 || $logintype == 1) { ?>
364 364
   <input class="btn btn-line-parrot search_generate_bar" name="action" name="save" id="save" value="Pay Now" type="button" onclick="return amidn_pay(); "> 
365 365
 <input id="ok" class="btn btn-line-sky margin-x-10" type="button" value="Cancel" onclick="window.history.back();" name="action">
366 366
   </div>
@@ -398,7 +398,7 @@  discard block
 block discarded – undo
398 398
  		  <input type="hidden" readonly name="quantity" value="1"> 
399 399
 		  <input type="hidden" readonly name="rm" value="2">
400 400
 		  <input type="hidden" readonly name="no_shipping" value="1">
401
-		  <input type="hidden" readonly name="PHPSESSID" value="<?=session_id();?>">
401
+		  <input type="hidden" readonly name="PHPSESSID" value="<?=session_id(); ?>">
402 402
 		  <input type="hidden" readonly name="currency_code" value="USD">
403 403
 		  <input type="hidden" readonly name="notify_url" value="<?=$notify_url?>">
404 404
 		  <input type="hidden" readonly name="return" value="<?=$response_url?>">
Please login to merge, or discard this patch.
astpp/application/modules/invoices/views/view_invoice_edit_manually.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
 		}
46 46
 	}
47 47
 	var taxe_rate=0;
48
-        var taxes_acc='<?= $taxes_to_accounts;?>';
48
+        var taxes_acc='<?= $taxes_to_accounts; ?>';
49 49
 	var tax_per = '<?= $total_tax ?>';
50 50
 	var total_tax=sum*tax_per/100;
51 51
 	$("#total_tax").html(total_tax.toFixed(2));
@@ -133,10 +133,10 @@  discard block
 block discarded – undo
133 133
 		 		 <font style="font-weight:bold;" >Email :</font> <font style="color:#a09d9d;" >
134 134
 
135 135
 			 <?php 
136
-				if($accountdata['email']!=""){
137
-					$attac_exp=explode(",",$accountdata['email']);
138
-					foreach($attac_exp as $key=>$value){
139
-						if($value != ''){
136
+				if ($accountdata['email'] != "") {
137
+					$attac_exp = explode(",", $accountdata['email']);
138
+					foreach ($attac_exp as $key=>$value) {
139
+						if ($value != '') {
140 140
 							echo $value;
141 141
 						}
142 142
 					}
@@ -158,13 +158,13 @@  discard block
 block discarded – undo
158 158
 	        </tr>
159 159
 	<tr>
160 160
 		<td>
161
-		 		<b>From Date : </b><span style="color:#a09d9d;"> <?php echo date('Y-m-d', strtotime($from_date)) ; ?></span>
161
+		 		<b>From Date : </b><span style="color:#a09d9d;"> <?php echo date('Y-m-d', strtotime($from_date)); ?></span>
162 162
 		 </td>
163 163
 	</tr>
164 164
 	<tr>
165 165
 		<td>
166 166
  		<b>Due Date : </b><span style="color:#a09d9d;"><?php 
167
-                echo date('Y-m-d', strtotime($payment_due_date)) ;
167
+                echo date('Y-m-d', strtotime($payment_due_date));
168 168
 		?></span>
169 169
 		 </td>
170 170
 	</tr>
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
 <table width="50%"  border="1" colspan="2" class="invoice_table4 pull-right">
178 178
 		<tr style='border:2px;'>
179 179
 		 <td height=35px style="padding-left:5px;"><b >Invoice Amount :</b></td>
180
-		 <td><span class="pull-right" style="color:#3278b6"><b><?php echo $this->common->currency_decimal($amount); ?> <?php  echo $to_currency;  ?></b> </span></td>
180
+		 <td><span class="pull-right" style="color:#3278b6"><b><?php echo $this->common->currency_decimal($amount); ?> <?php  echo $to_currency; ?></b> </span></td>
181 181
 		 <input type="hidden" name="total_amount" id="total_amount" class="article" value="<?php echo $amount; ?>" >
182 182
 		  <input type="hidden" readonly name="recharge" value="paypal_invoice">
183 183
 	 </tr> 
@@ -195,11 +195,11 @@  discard block
 block discarded – undo
195 195
 	<th >Amount</th>
196 196
 </tr> 
197 197
 <?php
198
-for($i=1;$i <= $row_count ;$i++){
199
-if($get_data['invoice_amount_'.$i] > 0){
200
-$invoice_amt=$this->common->currency_decimal($this->common_model->calculate_currency($get_data['invoice_amount_'.$i]));
201
-}else{
202
-$invoice_amt='';
198
+for ($i = 1; $i <= $row_count; $i++) {
199
+if ($get_data['invoice_amount_'.$i] > 0) {
200
+$invoice_amt = $this->common->currency_decimal($this->common_model->calculate_currency($get_data['invoice_amount_'.$i]));
201
+} else {
202
+$invoice_amt = '';
203 203
 }
204 204
 ?>
205 205
 <tr>
@@ -221,8 +221,8 @@  discard block
 block discarded – undo
221 221
 </td>
222 222
 </tr>
223 223
 <?php
224
-$taxi=0;
225
-foreach($taxes_to_accounts as $tax_val){
224
+$taxi = 0;
225
+foreach ($taxes_to_accounts as $tax_val) {
226 226
 
227 227
 ?>
228 228
 	<input type="hidden" id="total_tax_input_<?= $taxi; ?>" name="total_tax_input_<?= $taxi; ?>" value="<?= $tax_val['taxes_rate']; ?>" >
Please login to merge, or discard this patch.
astpp/application/modules/invoices/views/view_account_invoice_detail.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
 <div align="left">
64 64
 <table border="0"  class="details_table">
65 65
 <tr class="invoice_heading"><td>
66
-To : <?=$accountinfo['first_name'];?> <?=$accountinfo['last_name']?>
66
+To : <?=$accountinfo['first_name']; ?> <?=$accountinfo['last_name']?>
67 67
 </td></tr>
68 68
 <tr><td>
69 69
 Company name : <?=$accountinfo['company_name']?>
@@ -91,8 +91,8 @@  discard block
 block discarded – undo
91 91
     <td width="25%"><div align="center">Invoice Date</div></td>
92 92
   </tr>
93 93
   <tr>
94
-    <td><div align="center"><?=$accountinfo['cc'];?></div></td>
95
-    <td><div align="center"><?=$accountinfo['number'];?></div></td>
94
+    <td><div align="center"><?=$accountinfo['cc']; ?></div></td>
95
+    <td><div align="center"><?=$accountinfo['number']; ?></div></td>
96 96
     <td><div align="center"><?=@$invoiceid?></div></td>
97 97
     <td><div align="center"><?=@$invoicedate?></div></td>
98 98
   </tr>
@@ -109,8 +109,8 @@  discard block
 block discarded – undo
109 109
       </tr>
110 110
      
111 111
       <?php 
112
-	  if(sizeof($invoice_cdr_list)>0) {
113
-	  foreach($invoice_cdr_list as $key => $value) {?>
112
+	  if (sizeof($invoice_cdr_list) > 0) {
113
+	  foreach ($invoice_cdr_list as $key => $value) {?>
114 114
             <TR>
115 115
                <TD><?=$value['callstart']?></TD>
116 116
                <TD><?=$value['callerid']?></TD>
@@ -133,8 +133,8 @@  discard block
 block discarded – undo
133 133
       </tr>
134 134
     
135 135
       <?php 
136
-	   if(sizeof($invoice_total_list)>0) {
137
-	  foreach($invoice_total_list as $key => $value)
136
+	   if (sizeof($invoice_total_list) > 0) {
137
+	  foreach ($invoice_total_list as $key => $value)
138 138
 	  {?>
139 139
             <TR>
140 140
 	       <TD></td>
Please login to merge, or discard this patch.
application/modules/invoices/views/view_invoice_edit_automatically.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -156,10 +156,10 @@  discard block
 block discarded – undo
156 156
 			<td>
157 157
 	 		 <font style="font-weight:bold;" >Email :</font> <font style="color:#a09d9d;" >
158 158
 				 <?php /**** harsh ***/ 
159
-				if($accountdata['email']!=""){
160
-					$attac_exp=explode(",",$accountdata['email']);
161
-					foreach($attac_exp as $key=>$value){
162
-						if($value != ''){
159
+				if ($accountdata['email'] != "") {
160
+					$attac_exp = explode(",", $accountdata['email']);
161
+					foreach ($attac_exp as $key=>$value) {
162
+						if ($value != '') {
163 163
 							echo $value;
164 164
 						}
165 165
 					}
@@ -181,13 +181,13 @@  discard block
 block discarded – undo
181 181
 	        </tr>
182 182
 	<tr>
183 183
 		<td>
184
-		 		<b>From Date : </b><span style="color:#a09d9d;"> <?php echo date('Y-m-d', strtotime($from_date)) ; ?></span>
184
+		 		<b>From Date : </b><span style="color:#a09d9d;"> <?php echo date('Y-m-d', strtotime($from_date)); ?></span>
185 185
 		 </td>
186 186
 	</tr>
187 187
 	<tr>
188 188
 		<td>
189 189
  		<b>Due Date : </b><span style="color:#a09d9d;"><?php 
190
-                echo date('Y-m-d', strtotime($payment_due_date)) ;
190
+                echo date('Y-m-d', strtotime($payment_due_date));
191 191
 		?></span>
192 192
 		 </td>
193 193
 	</tr>
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
 <table width="50%"  border="1" colspan="2" class="invoice_table4 pull-right">
201 201
 		<tr style='background-color:#375c7c;color:#fff;height:30px;'>
202 202
 		 <td><b >Invoice Amount :</b></td>
203
-		 <td><span class="pull-right" style="color:#3278b6"><b><?php echo $this->common->currency_decimal($amount); ?> <?php  echo $to_currency;  ?></b> </span></td>
203
+		 <td><span class="pull-right" style="color:#3278b6"><b><?php echo $this->common->currency_decimal($amount); ?> <?php  echo $to_currency; ?></b> </span></td>
204 204
 		 <input type="hidden" name="total_amount" id="total_amount" class="article" value="<?php echo $amount; ?>" >
205 205
 		  <input type="hidden" readonly name="recharge" value="paypal_invoice">
206 206
 	 </tr> 
@@ -218,12 +218,12 @@  discard block
 block discarded – undo
218 218
 	<th >Amount</th>
219 219
 </tr>
220 220
 <?php
221
-$j=1;
221
+$j = 1;
222 222
 
223
- foreach($invoice_total_query as $value){
224
-       $id=$value['id'];
225
-       $debit=$value['debit'];
226
-       $created_date=$value['created_date'];
223
+ foreach ($invoice_total_query as $value) {
224
+       $id = $value['id'];
225
+       $debit = $value['debit'];
226
+       $created_date = $value['created_date'];
227 227
 ?>	
228 228
 <tr>
229 229
 <td width="20" align="center">
@@ -239,11 +239,11 @@  discard block
 block discarded – undo
239 239
 <?php
240 240
 $j++;
241 241
  }
242
-for($i=1;$i<=$row_count;$i++){
243
-if($get_data['invoice_amount_'.$i] > 0){
244
-$invoice_amt=$this->common->currency_decimal($this->common_model->calculate_currency($get_data['invoice_amount_'.$i]));
245
-}else{
246
-$invoice_amt='';
242
+for ($i = 1; $i <= $row_count; $i++) {
243
+if ($get_data['invoice_amount_'.$i] > 0) {
244
+$invoice_amt = $this->common->currency_decimal($this->common_model->calculate_currency($get_data['invoice_amount_'.$i]));
245
+} else {
246
+$invoice_amt = '';
247 247
 }
248 248
 ?>
249 249
 <tr>
@@ -274,8 +274,8 @@  discard block
 block discarded – undo
274 274
 </tr>
275 275
 -->
276 276
 <?php
277
-$taxi=0;
278
-foreach($taxes_to_accounts as $tax_val){
277
+$taxi = 0;
278
+foreach ($taxes_to_accounts as $tax_val) {
279 279
 
280 280
 ?>
281 281
 	<input type="hidden" id="total_tax_input_<?= $taxi; ?>" name="total_tax_input_<?= $taxi; ?>" value="<?= $tax_val['taxes_rate']; ?>" >
Please login to merge, or discard this patch.
web_interface/astpp/application/modules/invoices/views/view_invoiceconf.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <? extend('master.php') ?>
2
-<?php error_reporting(E_ERROR);?>
2
+<?php error_reporting(E_ERROR); ?>
3 3
 <? startblock('extra_head') ?>
4 4
 
5 5
 <?php endblock() ?>
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
         <div class="w-section inverse no-padding">
15 15
             <?php echo $form; ?>
16 16
             <?php
17
-            if(isset($validation_errors) && $validation_errors != ''){ ?>
17
+            if (isset($validation_errors) && $validation_errors != '') { ?>
18 18
                 <script>
19 19
                 var ERR_STR = '<?php echo $validation_errors; ?>';
20 20
                 print_error(ERR_STR);
Please login to merge, or discard this patch.