sub(new DateInterval('P3Y'));
$currentTo = @$_GET['date_to'] ? : $stop->format('t.m.Y');
$currentFrom = @$_GET['date_from'] ? : $start->format('01.m.Y');
include_once ("include/MPDF57/mpdf.php");
$p = new mPDF ( '', 'A4', null, 'helvetica', 8, 8, 30, 30, 5, 5 );
$mpdf->mirrorMargins = 1;
$i=0;
if(isset($_GET['process'])){
echo 'AAAA';
$additionalWhereConditions = array(
'\'' . $start->format('Y-m-01') . '\'',
'\'' . $stop->format('Y-m-t') . '\'',
);
if($from = @$_GET['date_from']) {
$fromDate = new DateTime($from);
$additionalWhereConditions[0] = '\'' . $fromDate->format('Y-m-d') . '\'';
}
if($to = @$_GET['date_to']) {
$toDate = new DateTime($to);
$additionalWhereConditions[1] = '\'' . $toDate->format('Y-m-d') . '\'';
}
if($_GET['kasjer']!=''){
$kasjer=" and `created_by`='".$_GET['kasjer']."'";
}
$additionalWhere = '`date_entered` BETWEEN ' . implode(' AND ', $additionalWhereConditions)." and `ecmcash_id`='".$_GET['ecmcash_id']."'".$kasjer;
$query = '
SELECT
`description`,`ecmkpkw_name`,`amount`,`document_no`,
`parent_address_street`,`parent_address_city`,`parent_address_postalcode`,
`parent_address_country`,`parent_contact_name`,`parent_contact_title`,
`date_entered`,`dir`,`parent_name`
FROM `ecmkpkw`
WHERE
' . (additionalWhere ? ($additionalWhere) : '') . '
ORDER BY
`date_entered` ASC;
';
$result = $db->query($query);
$query_bo = "SELECT SUM(IF(dir = 0, amount, -amount)) AS `sum` FROM `ecmkpkw` WHERE `date_entered` < ".$additionalWhereConditions[0]." and `ecmcash_id`='".$_GET['ecmcash_id']."'".$kasjer;
//echo $query_bo; exit;
$result_bo = $db->query($query_bo);
if($row_bo = $db->fetchByAssoc($db->query($query_bo)))
{
$bo = $row_bo["sum"];
//ECHO $row["sum"];
}
$tabelka='
| Lp |
Nr dokumentu Data wystawienia |
Tytuł |
Kontrahent |
Przychód |
Rozchód |
';
$suma1=0;
$suma2=0;
while($row = $db->fetchByAssoc($result)){
if($row['dir']==0) { $liczba1=format_number($row['amount']); $suma1 += $row['amount']; } else $liczba1=" ";
if($row['dir']==1) { $liczba2=format_number($row['amount']); $suma2 += $row['amount']; } else $liczba2=" ";
$i++;
$tabelka.='
| '.$i.' |
| '.$row['document_no'].' | | '.date("d.m.Y", strtotime($row['date_entered'])).' |
|
'.$row['ecmkpkw_name'].' |
'.$row['parent_name'].' |
'.$liczba1.' |
'.$liczba2.' |
';
}
$tabelka.='
';
}
$tabelka.='
|
|
|
'.translate('LBL_VALUE', 'EcmKpkw').': |
'.format_number(($suma1)).' |
'.format_number(($suma2)).' |
|
|
|
'.translate('LBL_VALUE_BEFORE', 'EcmKpkw').': |
'.format_number(($bo)).' |
|
|
|
|
'.translate('LBL_VALUE_TOTAL', 'EcmKpkw').': |
'.format_number((($bo+$suma1)-$suma2)).' |
|
';
$header=''.translate('LBL_RAPORT_TITLE2', 'EcmKpkw').'
|
'.translate('LBL_TIME2', 'EcmKpkw').': |
'.$fromDate->format('d.m.Y')." - ".$toDate->format('d.m.Y').' |
|
'.translate('LBL_CASH2', 'EcmKpkw').': |
'.$_GET['cash_name'].' |
|
'.translate('LBL_CURRENCY_PDF2', 'EcmKpkw').': |
'.$_GET['id_currency'].' |
';
if($_GET['kasjer']!=''){
$us=new User;
$us->retrieve($_GET['kasjer']);
$header.='
|
Kasjer: |
'. $us->full_name.' |
';
}
$header.='
';
$p->SetHTMLHeader ( $header );
$p->WriteHTML ($tabelka );
$p->Output ();
echo $header;