Code Duplication    Length = 5-5 lines in 3 locations

web_interface/astpp/application/modules/invoices/controllers/invoices.php 3 locations

@@ 126-130 (lines=5) @@
123
		  $query ="select sum(amount) as grand_total from invoices where reseller_id='0'";
124
		  }
125
		  $ext_query=$this->db->query($query);
126
		  if($ext_query->num_rows() > 0){
127
		  $result_total=$ext_query->result_array();
128
		  $grandtotal=$result_total[0]['grand_total'];
129
		  $grand_total=$this->common->currency_decimal($grandtotal).' '.$currency_id;
130
		  }
131
          
132
          
133
		  if($accountinfo['type'] == 1){
@@ 1151-1155 (lines=5) @@
1148
		  $query ="select sum(amount) as grand_total from invoices where confirm=1 and accountid=$accountid";
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;
1155
		  }
1156
          
1157
		  $invoice_query ="select sum(credit) as grand_credit from invoice_details where accountid=$accountid";
1158
		  $credit_query=$this->db->query($invoice_query);
@@ 1263-1267 (lines=5) @@
1260
		  $query ="select sum(amount) as grand_total from invoices where  confirm=1 and accountid=$accountid";
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;
1267
		  }
1268
          
1269
		  $invoice_query ="select sum(credit) as grand_credit from invoice_details where accountid=$accountid";
1270
		  $credit_query=$this->db->query($invoice_query);