109 lines
3.4 KiB
PHP
Executable File
109 lines
3.4 KiB
PHP
Executable File
<?php
|
|
// partie
|
|
//include 'EcmConfig.php';
|
|
|
|
ini_set('memory_limit','-1');
|
|
ini_set('max_execution_time','-1');
|
|
ini_set('display_errors' ,'1');
|
|
error_reporting(LC_ALL);
|
|
|
|
if (! defined ( 'sugarEntry' ) || ! sugarEntry)
|
|
die ( 'Not A Valid Entry Point' );
|
|
|
|
$db = $GLOBALS['db'];
|
|
global $app_list_strings;
|
|
$doc_name=array('EcmStockDocInsideIns'=>'PW','EcmStockDocMoves'=>'MM','EcmStockDocCorrects'=>'KS','EcmStockDocIns'=>'PZ','EcmStockDocOuts'=>'WZ','EcmStockDocInsideOuts'=>'RW','EcmInvoiceOuts'=>"FK");
|
|
/*
|
|
* Magazyny
|
|
*/
|
|
$datastocks = array ();
|
|
$users = array ();
|
|
$queryStocks = "SELECT
|
|
name,
|
|
id
|
|
FROM ecmstocks
|
|
where deleted= 0";
|
|
$rowsStocks = $db->query ( $queryStocks );
|
|
$s=array();
|
|
while ( $rowStocks = $db->fetchByAssoc ( $rowsStocks ) ) {
|
|
$stocks ["name"] = $rowStocks ["name"];
|
|
$stocks ["id"] = $rowStocks ["id"];
|
|
$datastocks [] = $stocks;
|
|
$s[$stocks ["id"]]['name']=$stocks ["name"];
|
|
}
|
|
if($_GET['date_from']==''){
|
|
$_GET['date_from']=date('01.m.Y');
|
|
} else {
|
|
$date_from=date('Y-m-d 00:00:01',strtotime($_GET['date_from']));
|
|
}
|
|
if( $_GET['date_to']==''){
|
|
$_GET['date_to']=date('t.m.Y');
|
|
} else {
|
|
$date_to=date('Y-m-d 00:00:01',strtotime($_GET['date_to']));
|
|
}
|
|
|
|
$where = "";
|
|
if ($_GET['selectDocType']!="") {
|
|
$docType = $_GET['selectDocType'];
|
|
$where = " AND parent_type = '".$docType."' ";
|
|
}
|
|
|
|
/*
|
|
* Dodatkowe parametry do zapytania
|
|
*/
|
|
if ($_GET ['selectStock'] != "")
|
|
$where .= " and stock_id = '" . $_GET ["selectStock"] . "' ";
|
|
|
|
|
|
$query = "SELECT parent_type, parent_id, sum(quantity), sum(price * quantity), type
|
|
FROM ecmstockoperations WHERE (date_entered BETWEEN '$date_from' AND '$date_to')";
|
|
if (strlen($where) > 0) $query.=$where;
|
|
$query.=" group by parent_id, type";
|
|
echo $query;
|
|
//Get ProductStockIndexes
|
|
$res = $db->query("SELECT id, name FROM ecmproductstockindexs");
|
|
$si = array();
|
|
while ($row = $db->fetchByAssoc($res))
|
|
$si[$row['id']] = $row['name'];
|
|
|
|
$res = $db->query($query);
|
|
$data = array();
|
|
|
|
while ($row = $db->fetchByAssoc($res)) {
|
|
$q = "SELECT ecmproductstockindex_id FROM ".strtolower($row['parent_type'])." WHERE id='".$row['parent_id']."'";
|
|
echo $q."<br>";
|
|
}
|
|
|
|
|
|
// create & execute smarty
|
|
$smarty = new Sugar_Smarty ();
|
|
global $mod_strings;
|
|
$smarty->assign ( "MOD", $mod_strings );
|
|
$smarty->assign ( "DATA", $doc );
|
|
$smarty->assign ( "DOCTYPES", $doc_name );
|
|
$smarty->assign ( "date_from", $_GET['date_from'] );
|
|
$smarty->assign ( "date_to", $_GET['date_to'] );
|
|
$smarty->assign ( "STOCKS", $datastocks );
|
|
$smarty->assign ( "selectStock", $_GET ["selectStock"]);
|
|
$smarty->assign( "selectDocType", $_GET['selectDocType']);
|
|
|
|
|
|
// Eksport do PDF
|
|
if( $_GET['toPDF'] == '1' ) {
|
|
$output = $smarty->fetch( 'modules/EcmReports/tpls/PDF//Kartoteka.tpl' );
|
|
include_once ("include/MPDF57/mpdf.php");
|
|
unset($smarty);
|
|
$p = new mPDF ( '', 'A4', null, 'helvetica', 10, 10, 25, 10, 5, 5 );
|
|
$p->setFooter('Strona {PAGENO} z {nbpg}');
|
|
$p->SetHTMLHeader('<p style="text-align:left;font-size: 10px;">Cros Wood Sp. z o.o.<br>
|
|
Kartoteka ruchu towarów - Podsumowanie<br>Data wydruku: '.date("d.m.Y").'<br>Stan magazynowy za okres: '.$_GET['date_from'].' - '.$_GET['date_to'].'<br>Magazyn: '.$s[$_GET ["selectStock"]]['name']. '<br>Strona {PAGENO} z {nbpg}</p>');
|
|
//$p->setTitle($mod_strings["LBL_REPORT_STOCKS_DOCS"]);
|
|
//echo $output;
|
|
$p->writeHTML( $output );
|
|
|
|
$p->Output ();
|
|
} else {
|
|
$smarty->display ( 'modules/EcmReports/tpls/ReportStockByStockIndexes.tpl' );
|
|
}
|
|
|
|
?>
|