fetchByAssoc($GLOBALS['db']->query("select total from ecmpayments_ecminvoiceouts where id='".$c1[$j]."'")); $tot_t+=$r['total']; } } for($j=0;$jfetchByAssoc($GLOBALS['db']->query("select value from ecmpayments where id='".$c2[$j]."'")); $tot_v+=$r['value']; } } if(round($tot_t,2)-round($tot_v,2)> abs(0.5)){ echo "Error: totals not match, invoices: ".$tot_t.", payments: ".$tot_v; die(); } else{ for($j=0;$jquery("update ecmpayments_ecminvoiceouts set paid='1',payment_date='".date("Y-m-d")."' where id='".$c1[$j]."'"); $GLOBALS['db']->query("update ecminvoiceouts as i inner join ecmpayments_ecminvoiceouts as pi on i.id=pi.ecminvoiceout_id set i.paid=pi.paid where pi.id='".$c1[$j]."'"); } } for($j=0;$jquery("update ecmpayments set paid='1' where id='".$c2[$j]."'"); $GLOBALS['db']->query("update ecminvoiceouts as i inner join ecmpayments_ecminvoiceouts as pi on i.id=pi.ecminvoiceout_id set i.paid=pi.paid where pi.id='".$c2[$j]."'"); } } $str=""; foreach($_POST as $k => $v){ $str.="&".$k."=".$v; } for($j=0;$jquery("insert into ecmpayments_ecminvoiceouts_rel(id,ee_id,ecmpayment_id) values('".create_guid()."','".$c1[$j]."','".$c2[$i]."');"); } } header("Location: index.php?module=EcmPaymentStates&action=index&account_id=".$account_id); } ?>