bean->id)){ global $app_strings; sugar_die($app_strings['ERROR_NO_RECORD']); } global $mod_strings; //add mz $pl = $this->bean->showPositions(); $pl2 = $this->bean->showPositions2(); $pl3 = $this->bean->showPositions3(); $pl55 = $this->bean->showPositions55(); $this->ss->assign('POSITIONS', $pl); $this->ss->assign('POSITIONS2', $pl2); $this->ss->assign('POSITIONS3', $pl3); $this->ss->assign('POSITIONS55', $pl55); $this->ss->assign('URL_ECMPAY', 'Sprawdź'); $this->ss->assign('LBL_PHONE', $app_strings['LBL_PHONE']); $this->ss->assign('LBL_FAX', $app_strings['LBL_FAX']); $this->ss->assign('LBL_SAVE_TO_GOOGLE', $mod_strings['LBL_SAVE_TO_GOOGLE']); $this->ss->assign('MOVE', ''); //end mz $this->dv->process(); global $mod_strings; if(ACLController::checkAccess('Contacts', 'edit', true)) { $push_billing = ''; $push_shipping = ''; } else { $push_billing = ''; $push_shipping = ''; } $query = "select p.id,p.document_no,p.paid,p.register_date,p.payment_date,p.total,p.ecminvoiceout_id from ecmpayments_ecminvoiceouts as p inner join ecminvoiceouts as i on p.ecminvoiceout_id=i.id and i.type!='canceled' where p.deleted='0' and p.account_id='" . $this->bean->id . "' " . $v . " order by p.date_entered desc"; $w = $GLOBALS ['db']->query ( $query ); $winien_roz = 0; $winien_n_roz = 0; while ( $r = $GLOBALS ['db']->fetchByAssoc ( $w ) ) { $str = ""; if ($r ['register_date'] < '2008-12-31' && $r ['paid'] == 0) continue; // if($r['type']!='correct'){ $rinv = $GLOBALS ['db']->fetchByAssoc ( $GLOBALS ['db']->query ( "select description,id from ecminvoiceouts where id='" . $r ['ecminvoiceout_id'] . "'" ) ); if ($r ['paid'] == 0) { $winien_roz += $r['total']; } else { $paid = "*"; $checkbox = ""; $color = ' color: #33FF00; '; $winien_n_roz += $r['total']; } $exp = explode ( "-", $r ['register_date'] ); if ($r ['paid'] == 0) $arrear += $r ['total']; if ($r ['ecminvoiceout_id']) $inv = '' . $r ['document_no'] . ''; else $inv = $r ['document_no']; // } $total_wn += $r ['total']; } $query = "select payment_date,id,description,value,paid,name from ecmpayments where deleted='0' and parent_id='" . $this->bean->id . "' order by date_entered desc"; $w = $GLOBALS ['db']->query ( $query ); $last_date = ""; $ma_roz = 0; $ma_n_roz = 0; while ( $r = $GLOBALS ['db']->fetchByAssoc ( $w ) ) { $str = ""; if ($r ['payment_date'] < '2008-12-31' && $r ['paid'] == 0) continue; if ($r ['paid']) { $paid = "*"; $checkbox = ""; $color = ' color: #33FF00;'; $ma_roz+=$r['value']; } else { $paid = " "; $checkbox = ''; $color = ' color: #FF3333;'; $ma_n_roz+=$r['value']; } if (str_replace ( " ", "", $r ['name'] ) == "" || ! $r ['name']) $r ['name'] = "blank"; if (! $_REQUEST ['document_no'] && $last_date != $r ['payment_date'] && ($r ['paid'] == 0 || ! $wh_paid_p)) { if ($wh_paid_p) $whp = " and paid='0'"; else $whp = ""; $rr = $GLOBALS ['db']->fetchByAssoc ( $GLOBALS ['db']->query ( "select sum(value) as sum from ecmpayments where deleted='0' and parent_id='" . $_REQUEST ['account_id'] . "'" . $whp . " and payment_date='" . $r ['payment_date'] . "'" ) ); $sum_total = $rr ['sum']; } if ($r ['name'] == "blank") $desc_name = $r ['description']; else $desc_name = $r ['name']; $total_ma += $r ['value']; if ($r ['paid'] == 0 || ! $wh_paid_p) $last_date = $r ['payment_date']; if ($r ['paid'] == 0) $total_not_paid += $r ['value']; } $sumr=( $ma_n_roz - $winien_n_roz ); $sumn=($ma_roz + $ma_n_roz) - ($winien_roz + $winien_n_roz); $sumn=number_format($sumn, 2, ',', ' '); if($sumn>0){ $color='FF3333'; } else { $color='000000'; } $sumr='

'.number_format($sumr, 2, ',', ' ').'

'; $this->ss->assign("custom_code_billing", $push_billing); $this->ss->assign("custom_code_shipping", $push_shipping); $this->ss->assign('SUMN',$sumn); $this->ss->assign('SUMR',$sumr); if(empty($this->bean->id)){ global $app_strings; sugar_die($app_strings['ERROR_NO_RECORD']); } echo $this->dv->display(); } } ?>