0) { $where['productName'] = $productName; } if (isset($accountId) && $accountId!='') { $where['accountId'] = $accountId; } else if (!isset($accountId) && isset($accountName) && strlen($accountName) > 0) { $where['accountName'] = $accountName; } try { $tmp = new DateTime(date('Y-m-31')); $tmp2 = new DateTime(date('Y-m-01')); $tmp2->sub(new DateInterval('P1Y')); $where['register_date_to'] = $tmp->format('Y-m-d'); $where['register_date_from'] = $tmp2->format('Y-m-d'); // $where['register_date_to'] = '2015-07-31'; // $where['register_date_from'] = '2015-07-01'; } catch (Exception $e) { echo $e->getMessage(); exit(1); } //$where['type'] = 'correct'; //$where['type'] = 'normal'; $where['deleted'] = 0; $where['canceled'] = 0; $data = AnalysisProductSale($where); $rows = array(); foreach ($data as $key => $value) { $rows['netto'][] = $value['total_netto']; // $rows['total_brutto'][] = $value['total_brutto']; $rows['kupno'][] = $value['total_purchase']; $rows['marza'][] = $value['total_netto'] - $value['total_purchase']; $rows['marzaprocent'][] = (($value['total_netto'] - $value['total_purchase']) * 100) / $value['total_netto']; } $smarty = new Sugar_Smarty (); $smarty->assign("MOD", $mod_strings); $smarty->assign("DATA", $data); $smarty->assign("ROWS", $rows); $smarty->assign("productCategoryList", $productCategoryList); $smarty->assign("productCategorySelected", $productCategorySelected); $smarty->assign("accountName", $accountName); $smarty->assign("accountId", $accountId); $smarty->assign("productName", $productName); $smarty->assign("productId", $productId); if ($_GET ['to_pdf'] == '1') { $output = $smarty->fetch('modules/EcmReports/tpls/PDF/AnalysisProductSale.tpl'); include_once ("include/MPDF57/mpdf.php"); $p = new mPDF('', 'A4', NULL, 'helvetica', 10, 10, 10, 10, 5, 5); $p->writeHTML($output); $p->Output('RaportSprzedazy.pdf', 'I'); } else { echo $smarty->display('modules/EcmReports/tpls/AnalysisProductSale.tpl'); } ?>