Files
crm.e5.pl/modules/EcmInvoiceOuts/ListSales.php
2024-04-27 09:23:34 +02:00

97 lines
2.9 KiB
PHP

<?php
if (! defined ( 'sugarEntry' ) || ! sugarEntry)
die ( 'Not A Valid Entry Point' );
// require_once('modules/EcmGroupSales/HeaderMenu.php');
global $sugar_version, $sugar_config, $current_user, $app_strings, $mod_strings;
require_once ('include/time.php');
require_once ('include/json_config.php');
// add jquery
echo '<link rel="stylesheet" type="text/css" href="modules/EcmSales/css/style.css"/>';
echo '<script type="text/javascript"
src="include/jQuery/jquery-lastes.js"></script>';
echo '<script type="text/javascript"
src="include/jQuery/jquery.tablesorter.pager.js"></script>';
echo '<script type="text/javascript"
src="modules/EcmInvoiceOuts/javascript/ListSales.js"></script>';
$json_config = new json_config ();
$db=$GLOBALS['db'];
$where=false;
$where_c=array();
if($_POST['year']!=''){
$where_c[]='YEAR(faktura.register_date)="'.$_POST['year'].'"';
}
if($_POST['code']!=''){
$where_c[]='pozycja.code like "%'.$_POST['code'].'%"';
}
if($_POST['quantity']!=''){
$where_c[]='pozycja.quantity="'.$_POST['quantity'].'"';
}
if($_POST['price']!=''){
$_POST['price']=str_replace(',','.',$_POST['price']);
$where_c[]='pozycja.price_netto="'.$_POST['price'].'"';
}
if($_POST['account_id']!=''){
$where_c[]='faktura.parent_id="'.$_POST['account_id'].'"';
}
$where_string='';
if(count($where_c)>0){
$where_string.=' where ';
$where_string.=implode(' and ',$where_c);
}
echo $_POST['account_name'];
if($_POST['submit']){
$zap=$db->query("select
pozycja.id,
pozycja.code,
pozycja.name,
pozycja.quantity,
pozycja.price_netto,
faktura.document_no,
faktura.id as fk_id,
faktura.register_date,
faktura.number,
faktura.parent_shipping_address_name,
faktura.parent_name
from
ecminvoiceoutitems pozycja
JOIN
ecminvoiceouts faktura ON pozycja.ecminvoiceout_id = faktura.id
JOIN
ecmproducts produkt ON pozycja.ecmproduct_id = produkt.id
".$where_string);
$position_list=array();
while($dane=$db->fetchByAssoc($zap)){
//if ($dane['parent_shipping_address_name'] && $dane['parent_shipping_address_name']!='' &&
// $dane['parent_shipping_address_name'] != $dane['parent_name'])
$dane['document_no'].='<br>'.$dane['parent_shipping_address_name'];
$position_list[]=$dane;
}
}
//$focus = new EcmInvoiceOut ();
$edit->ss = new Sugar_Smarty ();
$edit->module = 'EcmInvoiceOuts';
//$edit->ss->assign ( "CREATED_BY_NAME", $focus->created_by_name );
//$edit->ss->assign ( "MODIFIED_BY_NAME", $focus->modified_by_name );
//$edit->ss->assign ( 'FOCUS', $focus);
$edit->ss->assign ( 'POST', $_POST);
$edit->ss->assign ( 'LINK', $link);
$edit->ss->assign('POSITION_LIST',$position_list);
$edit->ss->assign ( 'MOD', $mod_strings);
$edit->ss-> display('modules/EcmInvoiceOuts/tpls/ListSales.tpl'); //4
?>