Add php files
This commit is contained in:
189
modules/EcmProducts/infomag.php
Normal file
189
modules/EcmProducts/infomag.php
Normal file
@@ -0,0 +1,189 @@
|
||||
<?php
|
||||
echo '<link rel="stylesheet" type="text/css" href="modules/Accounts/MyTable.css"><link rel="stylesheet" type="text/css" href="modules/EcmReceipts/ListView.css"><link rel="stylesheet" type="text/css" href="themes/Sugar5/css/MyMenu.css"><link rel="stylesheet" type="text/css" href="cache/themes/Sugar5/css/style.css?s=bed8cd35065048ceebdc639ebe305e2c&c=1"><link rel="stylesheet" type="text/css" href="cache/themes/Sugar5/css/deprecated.css?s=bed8cd35065048ceebdc639ebe305e2c&c=1"><link rel="stylesheet" type="text/css" href="cache/themes/Sugar5/css/yui.css?s=bed8cd35065048ceebdc639ebe305e2c&c=1">';
|
||||
$db=$GLOBALS['db'];
|
||||
function getConsignmentsDocs($prod_id, $stock_id, $jm) {
|
||||
$documents_map = array (
|
||||
'EcmStockDocIns' => 'PZ',
|
||||
'EcmStockDocCorrects' => 'KS',
|
||||
'EcmStockDocMoves' => 'MM',
|
||||
'EcmStockDocInsideIns' => 'PW'
|
||||
);
|
||||
|
||||
global $db;
|
||||
$query = "
|
||||
select i.id, i.parent_id, i.parent_type, i.parent_name, i.price, i.quantity as in_qty, i.part_no, ifnull(sum(o.quantity),0) as out_qty, p.unit_id
|
||||
from ecmstockoperations as i
|
||||
left join ecmstockoperations as o
|
||||
on i.id = o.in_id
|
||||
inner join ecmproducts as p
|
||||
on i.product_id = p.id
|
||||
where
|
||||
i.product_id='$prod_id' and
|
||||
i.stock_id='$stock_id' and
|
||||
i.used = '0' and
|
||||
i.type='0'
|
||||
group by i.id
|
||||
order by i.date_entered;";
|
||||
$res = $db->query ( $query );
|
||||
$result = array ();
|
||||
global $app_list_strings, $sugar_config;
|
||||
|
||||
while ( $row = $db->fetchByAssoc ( $res ) ) {
|
||||
$availability = (floatval ( $row ['in_qty'] ) - floatval ( $row ['out_qty'] ));
|
||||
if ($availability <= 0)
|
||||
continue;
|
||||
|
||||
$tmp = array ();
|
||||
if($row ['parent_type'] == 'EcmStockDocInsideIns'){
|
||||
|
||||
$accountQuery = "SELECT name FROM ecmstockdocinsideins WHERE id='" . $row['parent_id'] . "'";
|
||||
$accountResult = $db->query($accountQuery);
|
||||
if($accountResult->num_rows > 0){
|
||||
$accountRow = $db->fetchByAssoc ( $accountResult );
|
||||
$tmp ['account_name'] = $accountRow ['name'];
|
||||
}else{
|
||||
$tmp ['account_name'] = '';
|
||||
}
|
||||
}else{
|
||||
$accountQuery = "SELECT parent_id, parent_name FROM " . strtolower($row ['parent_type']) ." WHERE id='" . $row['parent_id'] . "'";
|
||||
$accountResult = $db->query($accountQuery);
|
||||
if($accountResult->num_rows > 0){
|
||||
$accountRow = $db->fetchByAssoc ( $accountResult );
|
||||
$tmp ['account_name'] = '<a href="index.php?module=Accounts&action=DetailView&record='.$accountRow['parent_id'].'">' . $accountRow['parent_name'] . '</a>';
|
||||
|
||||
}else{
|
||||
$tmp ['account_name'] = '';
|
||||
}
|
||||
}
|
||||
$tmp ['operation_id'] = $row ['id'];
|
||||
$tmp ['parent_name'] = '<a href="index.php?module='.$row ['parent_type'].'&action=DetailView&record='.$row['parent_id'].'">' . $documents_map [$row ['parent_type']] . ' ' . $row ['parent_name'] . '</a>';
|
||||
$tmp ['part_no'] = $row['part_no'];
|
||||
$tmp ['availability'] = $availability;
|
||||
$tmp ['parent_id'] = $row ['parent_id'];
|
||||
$tmp ['parent_type'] = $row ['parent_type'];
|
||||
|
||||
$tmp ['price'] = $row ['price'];
|
||||
$tmp ['unit'] = $app_list_strings ['ecmproducts_unit_dom'] [$row ['unit_id']];
|
||||
$tmp ['currency'] = $sugar_config ['default_currency_iso4217'];
|
||||
|
||||
$result [] = $tmp;
|
||||
}
|
||||
|
||||
// number_format($tmp, 2, ",", ".")
|
||||
$pr = new EcmProduct();
|
||||
$pr->retrieve($product_id);
|
||||
$html = '
|
||||
<div style="text-align: center; display: block;"><font size="4">Struktura zapasu</font><br>
|
||||
<div style="text-align: center; display: block"><font size="4">'.$pr->name.'</font><br>
|
||||
<table name="Pztki" cellspacing="0" cellpadding="0" border="0" width="100%" class="list view">
|
||||
<tr>
|
||||
<td style="padding:5px !important;border-bottom:1px solid #cccccc;vertical-align:top;"><b>Dokument</b></td>
|
||||
<td style="padding:5px !important;border-bottom:1px solid #cccccc;vertical-align:top;"><b>Dostawca/Nazwa dokumentu</b></td>
|
||||
<td style="padding:5px !important;border-bottom:1px solid #cccccc;vertical-align:top;"><b>Partia</b></td>
|
||||
<td style="padding:5px !important;border-bottom:1px solid #cccccc;vertical-align:top;"><b>Ilość</b></td>
|
||||
<td style="padding:5px !important;border-bottom:1px solid #cccccc;vertical-align:top;"><b>Cena</b></td>
|
||||
<td style="padding:5px !important;border-bottom:1px solid #cccccc;vertical-align:top;"><b>Wartość</b></td>
|
||||
</tr>';
|
||||
|
||||
foreach($result as $key => $value){
|
||||
$tmp = $value['availability']*$value['price'];
|
||||
$html.='<tr>';
|
||||
$html.='<td style="padding:5px !important;border-bottom:1px solid #cccccc;vertical-align:top;">' . $value['parent_name'] .'</td>';
|
||||
$html.='<td style="padding:5px !important;border-bottom:1px solid #cccccc;vertical-align:top;">' . $value['account_name'] .'</td>';
|
||||
$html.='<td style="padding:5px !important;border-bottom:1px solid #cccccc;vertical-align:top;">' . $value['part_no'] .'</td>';
|
||||
$html.='<td style="padding:5px !important;border-bottom:1px solid #cccccc;vertical-align:top;">' . number_format($value['availability'], $app_list_strings['ecmproducts_unit_dom_precision'][$jm], ",", ".") .' ' . $value['unit'].'</td>'; //FormatNumber(c.availability) + ' ' + c.unit
|
||||
$html.='<td style="padding:5px !important;border-bottom:1px solid #cccccc;vertical-align:top;">' . number_format($value['price'], 2, ",", ".") . ' ' . $value['currency'] . ' / ' . $value['unit'] . '</td>'; //FormatNumber(c.price) + ' ' + c.currency + ' / ' + c.unit
|
||||
$html.='<td style="padding:5px !important;border-bottom:1px solid #cccccc;vertical-align:top;">'. number_format($tmp, 2, ",", ".") .' zł</td>';
|
||||
$html.='</tr>';
|
||||
}
|
||||
|
||||
$html .= '</table><br><br></div>';
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
function getStockOperations($product_id, $stock_id, $jm){
|
||||
global $db,$app_list_strings;
|
||||
$query = "SELECT date_entered, quantity, type, parent_name, parent_type, parent_id, price FROM ecmstockoperations so where so.product_id='" . $product_id . "' AND so.stock_id ='" . $stock_id . "'order by counter";
|
||||
$res = $db->query ( $query );
|
||||
$result = array ();
|
||||
$pr = new EcmProduct();
|
||||
$pr->retrieve($product_id);
|
||||
$html = '
|
||||
<div style="text-align: center; display: block" cellspacing="0" cellpadding="0" border="0"><font size="4">Operacje magazynowe</font><br>
|
||||
<div style="text-align: center; display: block"><font size="4">'.$pr->name.'</font><br>
|
||||
<table name="stockOperations" cellspacing="0" cellpadding="0" border="0" width="100%" class="list view">
|
||||
<tr>
|
||||
<td style="padding:5px !important;border-bottom:1px solid #cccccc;vertical-align:top;"><b>Dokument</b></td>
|
||||
<td style="padding:5px !important;border-bottom:1px solid #cccccc;vertical-align:top;"><b>Kontrahent</b></td>
|
||||
<td style="padding:5px !important;border-bottom:1px solid #cccccc;vertical-align:top;"><b>Data</b></td>
|
||||
<td style="padding:5px !important;border-bottom:1px solid #cccccc;vertical-align:top;"><b>Cena</b></td>
|
||||
<td style="padding:5px !important;border-bottom:1px solid #cccccc;vertical-align:top;"><b>Ilość</b></td>
|
||||
<td style="padding:5px !important;border-bottom:1px solid #cccccc;vertical-align:top;"><b>Stan po</b></td>
|
||||
</tr>';
|
||||
$stanpo =0;
|
||||
$doc_name=array(
|
||||
'EcmStockDocInsideIns'=>'PW',
|
||||
'EcmStockDocMoves'=>'MM',
|
||||
'EcmStockDocCorrects'=>'KS',
|
||||
'EcmStockDocIns'=>'PZ',
|
||||
'EcmStockDocOuts'=>'WZ',
|
||||
'EcmStockDocInsideOuts'=>'RW',
|
||||
'EcmInvoiceOuts'=>'FK'
|
||||
);
|
||||
while ( $row = $db->fetchByAssoc ( $res ) ) {
|
||||
$subquery = '';
|
||||
$subquery = 'SELECT parent_id, parent_name, parent_type FROM ' . strtolower($row['parent_type']) . ' WHERE id = "'.$row['parent_id'].'"';
|
||||
$result = $db->query ( $subquery );
|
||||
if(!$result){
|
||||
$subquery = 'SELECT parent_id, parent_name FROM ' . strtolower($row['parent_type']) . ' WHERE id = "'.$row['parent_id'].'"';
|
||||
$result = $db->query ( $subquery );
|
||||
}
|
||||
$kontrahent = $db->fetchByAssoc ( $result );
|
||||
if($kontrahent['parent_type']==NULL || $kontrahent['parent_type']==''){
|
||||
switch($row['parent_type']){
|
||||
case 'EcmStockDocIns' :{
|
||||
$kontrahent['parent_type'] = 'Accounts';
|
||||
$tmp = '<a href="index.php?module='.$kontrahent['parent_type'].'&action=DetailView&record='.$kontrahent['parent_id'].'">' . $kontrahent['parent_name'] . '</a>';
|
||||
break;
|
||||
}
|
||||
default :{
|
||||
$tmp = $kontrahent['parent_name'];
|
||||
}
|
||||
}
|
||||
}else{
|
||||
$tmp = '<a href="index.php?module='.$kontrahent['parent_type'].'&action=DetailView&record='.$kontrahent['parent_id'].'">' . $kontrahent['parent_name'] . '</a>';
|
||||
}
|
||||
$nazwa = '';
|
||||
if($row['type']==0){
|
||||
$nazwa = '<a href="index.php?module='.$row['parent_type'].'&action=DetailView&record='.$row['parent_id'].'"><font color="green">' . $doc_name[$row['parent_type']] . ' ' . $row['parent_name'] . '</font></a>';
|
||||
$stanpo +=$row['quantity'];
|
||||
}elseif($row['type']==1){
|
||||
$nazwa = '<a href="index.php?module='.$row['parent_type'].'&action=DetailView&record='.$row['parent_id'].'"><font color="red">' . $doc_name[$row['parent_type']] . ' ' . $row['parent_name'] . '</font></a>';
|
||||
$stanpo -=$row['quantity'];
|
||||
}
|
||||
$data = substr($row['date_entered'],0,10);
|
||||
$data = explode('-', $data);
|
||||
$data = $data[2] . '.' .$data[1] . '.' .$data[0];
|
||||
$html.='<tr>';
|
||||
$html.='<td style="padding:5px !important;border-bottom:1px solid #cccccc;vertical-align:top;">' . $nazwa .'</td>';
|
||||
$html.='<td style="padding:5px !important;border-bottom:1px solid #cccccc;vertical-align:top;">' . $tmp .'</td>';
|
||||
$html.='<td style="padding:5px !important;border-bottom:1px solid #cccccc;vertical-align:top;">' . $data . '</td>'; //FormatNumber(c.availability) + ' ' + c.unit
|
||||
$html.='<td style="padding:5px !important;border-bottom:1px solid #cccccc;vertical-align:top;">' . number_format($row['price'], 2, ",", ".") . '</td>';
|
||||
$html.='<td style="padding:5px !important;border-bottom:1px solid #cccccc;vertical-align:top;">'. number_format($row['quantity'], $app_list_strings['ecmproducts_unit_dom_precision'][$jm], ",", ".") .'</td>';
|
||||
$html.='<td style="padding:5px !important;border-bottom:1px solid #cccccc;vertical-align:top;">'. number_format($stanpo, $app_list_strings['ecmproducts_unit_dom_precision'][$jm], ",", ".") .'</td>';
|
||||
$html.='</tr>';
|
||||
}
|
||||
$html .= '</table><br><br></div>';
|
||||
return $html;
|
||||
}
|
||||
switch ($_REQUEST['type']) {
|
||||
case "0":
|
||||
echo getConsignmentsDocs($_REQUEST['product_id'],$_REQUEST['stock_id']);
|
||||
break;
|
||||
case "1":
|
||||
echo getStockOperations($_REQUEST['product_id'],$_REQUEST['stock_id']);
|
||||
break;
|
||||
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user