66 lines
2.0 KiB
PHP
Executable File
66 lines
2.0 KiB
PHP
Executable File
<?php
|
|
if (! defined ( 'sugarEntry' ) || ! sugarEntry)
|
|
die ( 'Not A Valid Entry Point' );
|
|
|
|
global $app_list_strings;
|
|
|
|
ini_set('max_execution_time', 9999999999);
|
|
|
|
$months = array (
|
|
'01' => "Sty",
|
|
'02' => "Lut",
|
|
'03' => "Mar",
|
|
'04' => "Kwi",
|
|
'05' => "Maj",
|
|
'06' => "Cze",
|
|
'07' => "Lip",
|
|
'08' => "Sie",
|
|
'09' => "Wrz",
|
|
'10' => "Paź",
|
|
'11' => "Lis",
|
|
'12' => "Gru"
|
|
);
|
|
require_once ('include/time.php');
|
|
require_once ('include/json_config.php');
|
|
|
|
$json_config = new json_config ();
|
|
|
|
$db = $GLOBALS['db'];
|
|
|
|
$res = $db->query("SELECT
|
|
si.id as positionId, si.name as pName, si.code as pCode, si.quantity, si.total_netto, si.brand_label, si.description,
|
|
s.document_no, s.register_date, s.send_date, s.parent_name, s.status,
|
|
p.part_no as pSize, p.vendor_part_no as pKind /* <- :( */, p.brand
|
|
FROM ecmsaleitems as si
|
|
INNER JOIN ecmsales AS s on s.id = si.ecmsale_id
|
|
INNER JOIN ecmproducts AS p ON p.id = si.ecmproduct_id
|
|
WHERE s.status='s30' AND s.deleted=0");
|
|
|
|
$data = array();
|
|
|
|
while($r = $db->fetchByAssoc ( $res )) {
|
|
$item = array();
|
|
$item['documentNo'] = $r['document_no'];
|
|
$item['documentDate'] = $r['register_date'];
|
|
$item['sendDate'] = $r['send_date'];
|
|
$item['sendMonth'] = $months[date("m",strtotime($r['send_date']))];
|
|
$item['pName'] = $r['pName'];
|
|
$item['pCode'] = $r['pCode'];
|
|
$item['quantity'] = format_number($r['quantity']);
|
|
$item['totalNetto'] = format_number($r['total_netto']);
|
|
$item['description'] = $r['description'];
|
|
$item['aName'] = $r['parent_name'];
|
|
$item['status'] = $app_list_strings['ecmsales_status_dom'][$r['status']];
|
|
$item['pSize'] = $r['pSize'];
|
|
$item['pKind'] = $r['pKind'];
|
|
$item['pBrand'] = $r['brand'];
|
|
$item['pLabel'] = $r['brand_label'];
|
|
$item['positionId'] = $r['positionId'];
|
|
$item['description'] = $r['description'];
|
|
array_push($data, $item);
|
|
}
|
|
|
|
$edit->ss = new Sugar_Smarty ();
|
|
$edit->ss->assign ( "data", $data );
|
|
$edit->module = 'EcmSales';
|
|
$edit->ss-> display('modules/EcmSales/tpls/Report_ProductsBySales.tpl'); |