Add php files
This commit is contained in:
177
modules/EcmReportsBackUp20151106/ReportStocksDoc.php
Executable file
177
modules/EcmReportsBackUp20151106/ReportStocksDoc.php
Executable file
@@ -0,0 +1,177 @@
|
||||
<?php
|
||||
// partie
|
||||
include 'EcmConfig.php';
|
||||
|
||||
ini_set('memory_limit','-1');
|
||||
ini_set('max_execution_time','-1');
|
||||
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');
|
||||
/*
|
||||
* Magazyny
|
||||
*/
|
||||
$datastocks = array ();
|
||||
$users = array ();
|
||||
$queryStocks = "SELECT
|
||||
name,
|
||||
id
|
||||
FROM ecmstocks
|
||||
where deleted= 0";
|
||||
$rowsStocks = $db->query ( $queryStocks );
|
||||
|
||||
while ( $rowStocks = $db->fetchByAssoc ( $rowsStocks ) ) {
|
||||
$stocks ["name"] = $rowStocks ["name"];
|
||||
$stocks ["id"] = $rowStocks ["id"];
|
||||
$datastocks [] = $stocks;
|
||||
}
|
||||
|
||||
/*
|
||||
* Dodatkowe parametry do zapytania
|
||||
*/
|
||||
if ($_GET ['selectStock'] != "")
|
||||
$add_where .= " and stock_id = '" . $_GET ["selectStock"] . "' ";
|
||||
|
||||
if ($_GET ['selectProductActive'] != ""){
|
||||
$where= " WHERE product_active = '" . $_GET ["selectProductActive"] . "' ";
|
||||
} else {
|
||||
$where='';
|
||||
}
|
||||
$_GET['selectShowEmpty']=1;
|
||||
$r1 = $db->query("select id,name,code,unit_id from ecmproducts ".$where." order by name asc");
|
||||
$docs = array();
|
||||
$i=0;
|
||||
$total_quantity=0;
|
||||
$total_value=0;
|
||||
while ($tmp2 = $db->fetchByAssoc($r1)) {
|
||||
if($tmp2['code']=='ZW80438 WHITE') echo "select * from ecmstockoperations where
|
||||
product_id='" . $tmp2['id'] . "'
|
||||
".$add_where."
|
||||
and in_id is null and used=0 and type=0";
|
||||
$r = $db->query(
|
||||
"select * from ecmstockoperations where
|
||||
product_id='" . $tmp2['id'] . "'
|
||||
".$add_where."
|
||||
and in_id is null and used=0 and type=0");
|
||||
|
||||
$l = 0;
|
||||
if ($r->num_rows > 0) {
|
||||
$docs[$i]['unit_id']=$app_list_strings['ecmproducts_unit_dom'][$tmp2['unit_id']];
|
||||
$docs[$i]['product_id']=$tmp2['id'];
|
||||
$docs[$i]['product_name']=$tmp2['name'];
|
||||
$docs[$i]['product_code']=$tmp2['code'];
|
||||
$docs[$i]['total_quantity']=0;
|
||||
$docs[$i]['total_price']=0;
|
||||
$i++;
|
||||
}
|
||||
while ($tmp = $db->fetchByAssoc($r)) {
|
||||
|
||||
$ii = $db->query(
|
||||
"select * from ecmstockoperations where in_id='" . $tmp['id'] .
|
||||
"' and type=1");
|
||||
|
||||
if ($ii->num_rows > 0) {
|
||||
// licz ilość dla użytych
|
||||
$quantity_tmp = $tmp['quantity'];
|
||||
while ($tmp2 = $db->fetchByAssoc($ii)) {
|
||||
|
||||
$quantity_tmp -= $tmp2['quantity'];
|
||||
}
|
||||
if($quantity_tmp==0){
|
||||
$db->query("update ecmstockoperations set used=1 where id='".$tmp['id']."'");
|
||||
continue;
|
||||
}
|
||||
$doc['quantity'] = $quantity_tmp;
|
||||
$doc['parent_name'] = $tmp['parent_name'];
|
||||
$doc['part_no'] = $tmp['part_no'];
|
||||
$doc['price'] = $tmp['price'];
|
||||
$doc['parent_type'] = $doc_name[$tmp['parent_type']];
|
||||
$doc['parent_type2'] = $tmp['parent_type'];
|
||||
$doc['parent_id'] = $tmp['parent_id'];
|
||||
$doc['product_id'] = $tmp2['id'];
|
||||
$doc['date_entered'] = $tmp['date_entered'];
|
||||
$doc['position_value'] = $doc['quantity']*$tmp['price'];
|
||||
$total_quantity+=$doc['quantity'];
|
||||
$total_value+=round($doc['quantity']*$tmp['price'],2);
|
||||
$docs[$i-1]['add'][] = $doc;
|
||||
$docs[$i-1]['total_price']+=($doc['quantity']*$tmp['price'] );
|
||||
$docs[$i-1]['total_quantity']+=($doc['quantity']);
|
||||
} else {
|
||||
// dla całych
|
||||
$doc['quantity'] = $tmp['quantity'];
|
||||
$doc['parent_name'] = $tmp['parent_name'];
|
||||
$doc['price'] = $tmp['price'];
|
||||
$doc['part_no'] = $tmp['part_no'];
|
||||
$doc['parent_type'] = $doc_name[$tmp['parent_type']];
|
||||
$doc['parent_id'] = $tmp['parent_id'];
|
||||
$doc['date_entered'] = $tmp['date_entered'];
|
||||
$doc['product_id'] = $tmp2['id'];
|
||||
$doc['position_value'] = $doc['quantity']*$tmp['price'];
|
||||
$total_quantity+=$doc['quantity'];
|
||||
$total_value+=round($doc['quantity']*$tmp['price'],2);
|
||||
$docs[$i-1]['add'][] = $doc;
|
||||
$docs[$i-1]['total_price']+=($doc['quantity']*$tmp['price'] );
|
||||
$docs[$i-1]['total_quantity']+=($doc['quantity']);
|
||||
|
||||
}
|
||||
|
||||
if ($r->num_rows > 1) {
|
||||
$docs[$i-1]['price']='';
|
||||
$docs[$i-1]['parent_name']='';
|
||||
$docs[$i-1]['parent_type']='';
|
||||
} if ($r->num_rows < 2 ){
|
||||
$docs[$i-1]['price']=$tmp['price'];
|
||||
$doc[$i-1]['part_no'] = $tmp['part_no'];
|
||||
$docs[$i-1]['parent_id'] = $tmp['parent_id'];
|
||||
$docs[$i-1]['parent_name']=$tmp['parent_name'];
|
||||
$docs[$i-1]['date_entered'] = $tmp['date_entered'];
|
||||
$docs[$i-1]['parent_type'] = $doc_name[$tmp['parent_type']];
|
||||
}else {
|
||||
$docs[$i-1]['price']='';
|
||||
$docs[$i-1]['parent_name']='';
|
||||
$docs[$i-1]['parent_type']='';
|
||||
}
|
||||
|
||||
}
|
||||
if( $docs[$i-1]['total_quantity']==0 && $_GET['selectShowEmpty']!='')unset($docs[$i-1]);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
// create & execute smarty
|
||||
$smarty = new Sugar_Smarty ();
|
||||
global $mod_strings;
|
||||
$smarty->assign ( "MOD", $mod_strings );
|
||||
$smarty->assign ( "DATA", $docs );
|
||||
$smarty->assign ( "TOTAL_VALUE", $total_value );
|
||||
$smarty->assign ( "TOTAL_QUANTITY", $total_quantity );
|
||||
$smarty->assign ("CONSIGNMENTS",$EcmConfig['consignments']);
|
||||
$smarty->assign ( "STOCKS", $datastocks );
|
||||
$smarty->assign ( "selectStock", $_GET ["selectStock"]);
|
||||
$smarty->assign ( "selectProductActive", $_GET ["selectProductActive"] );
|
||||
$smarty->assign ( "selectProductEol", $_GET ["selectProductEol"] );
|
||||
$smarty->assign ( "selectShowEmpty", $_GET ["selectShowEmpty"] );
|
||||
|
||||
|
||||
// Eksport do PDF
|
||||
if( $_GET['toPDF'] == '1' ) {
|
||||
$output = $smarty->fetch( 'modules/EcmReports/tpls/PDF/ReportStocksDoc.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;">Saas SystemS Sp. z o.o.<br>
|
||||
Raport stanów magazynowych<br>Data wydruku: '.date("d.m.Y").'<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/ReportStocksDoc.tpl' );
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user