Code Duplication    Length = 12-14 lines in 2 locations

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

@@ 522-533 (lines=12) @@
519
		  $this->db->update("invoices", $data);
520
	if($confirm == 1){
521
		$invoice_details = $this->db_model->getSelect("*", "invoice_details", array("invoiceid" => $response_arr["invoiceid"]));
522
		if($invoice_details->num_rows >0){
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'];
530
				$this->db->where("id", $details_value['id']);
531
				$this->db->update("invoice_details", $balnace_update);       
532
			}
533
		}
534
535
		$account_data = $this->db_model->getSelect("*", "accounts", array("id" => $response_arr["accountid"]));
536
		$account_data = $account_data->result_array();
@@ 634-647 (lines=14) @@
631
		$this->db->update("invoices", $data);
632
	if($confirm == 1){
633
		$invoice_details = $this->db_model->getSelect("*", "invoice_details", array("invoiceid" => $response_arr["invoiceid"]));
634
		if($invoice_details->num_rows >0){
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'];
643
				$this->db->where("id", $details_value['id']);
644
				$this->db->update("invoice_details", $balnace_update);       
645
			   }			   
646
			}
647
		}
648
		$account_data = $this->db_model->getSelect("*", "accounts", array("id" => $response_arr["accountid"]));
649
		$account_data = $account_data->result_array();
650
		$invoice_not_deduct= $this->db_model->getSelect("*", "invoice_details", array("invoiceid" =>$response_arr['invoiceid']));