query("select id,payment_date,name,parent_name,register_date,value from ecmtransactions WHERE payment_date<'".date('Y-m-d')."' and type=0 and deleted=0 and (settled='' or settled is null) order by payment_date asc"); $i=0; echo "
";
$data=null;
while($r=$GLOBALS['db']->fetchByAssoc($w)){
		$tmp = array();
		
 		$tmp['payment_date']=$r['payment_date'];
 		$tmp['name']=$r['name'];
 		$tmp['parent_name']=$r['parent_name'];
 		$tmp['register_date']=$r['register_date'];
 		if($r['parent_name']=='BSL SP. Z O.O.')continue;
 		if($r['parent_name']=='BSL TRUCK PAWEŁ BARTYŚ')continue;
 		
 
 		$t = new EcmTransaction();
 		$t->retrieve($r['id']);
 		
 		$tmp['value']=$r['value'];
 		$tmp['value2']=$t->getRelations();
 		$tmp['value3']=$r['value']-$t->getRelations();
 		
 		$datetime1 = new DateTime(date('Y-m-d'));
 		$datetime2 = new DateTime($tmp['payment_date']);
 		 
		$interval = $datetime1->diff($datetime2);

 		 
 		$tmp['diff']= abs($interval->format('%R%a')).' dni';
 		
 		unset($t);
 		$data[]=$tmp;
}

//echo '
'.create_guid(); $es = new EcmSysInfo(); $content= "

Raport nierozliczonych transakcji

".$es->getName()."
Data wydruku: ".date("d.m.Y.")."

"; foreach ($data as $k=>$v){ $content.=''; } $content.="
Termin płatności Kontrahent Nr dokumentu Data dokumentu Dni po terminie Kwota Nierozliczone Rozliczone
'.date('d.m.Y',strtotime($v['payment_date'])).' '.$v['parent_name'].' '.$v['name'].' '.($v['register_date']!='01.01.1970' ? date('d.m.Y',strtotime($v['register_date'])) : '').' '.$v['diff'].' '.format_number($v['value']).' '.format_number($v['value2']).' '.format_number($v['value3']).'
"; require_once 'include/ECM/EcmSendPdfButton/EcmSendPdfButton.inc'; $t = new EcmSendPdfButton('Users', $usr_id,$itemail,$type); #$t->setAdress('outtervision@gmail.com'); $t->setAdress('ela_t@bsltparts.pl '); $t->setAdress('pawel_b@bsltruck.pl'); $t->setAdress('windykacja@bsltruck.pl'); #$t->setAdress('ryszard.lisiecki@saas-systems.pl'); $t->setSubject('Raport nierozliczonych transakcji'); $t->setBody(from_html('Lista w załączniku.')); include_once ("include/MPDF57/mpdf.php"); $mPDF = new mPDF ( 'pl', 'A4', 9, 'arial', 10, 10,5, 1, 14, 20); $mPDF->setAutoTopMargi = 'stretch'; $mPDF->setAutoBottomMargin = 'stretch'; $mPDF->mirrorMargins = 1; $mPDF->setFooter('Strona {PAGENO}'); $mPDF->WriteHTML($content); $mPDF->Output('upload/raport_trans_'.date('d_m_Y').'.pdf', "F"); $t->setAttachment('upload/raport_trans_'.date('d_m_Y').'.pdf'); $success = false; $success= $t->sendEmail(); ?>