Code Duplication    Length = 15-15 lines in 2 locations

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

@@ 1130-1144 (lines=15) @@
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");
1129
	   // echo $this->db->last_query(); exit;
1130
		  if ($invoice_total_query ->num_rows() > 0){
1131
			$invoice_total_query= $invoice_total_query->result_array();
1132
			//echo '<pre>'; print_r($invoice_total_query); 
1133
			$outstanding -= $invoice_total_query[0]['credit'];
1134
            
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='';
1141
			}
1142
         
1143
            
1144
		  }
1145
		  $invoice_total='';
1146
		  $accountinfo=$this->session->userdata('accountinfo');
1147
		  $id=$accountinfo['id'];
@@ 1238-1252 (lines=15) @@
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");
1237
	   // echo $this->db->last_query(); exit;
1238
		  if ($invoice_total_query ->num_rows() > 0){
1239
			$invoice_total_query= $invoice_total_query->result_array();
1240
			//echo '<pre>'; print_r($invoice_total_query); 
1241
			$outstanding -= $invoice_total_query[0]['credit'];
1242
            
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='';
1249
			}
1250
         
1251
            
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();