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