Products states table fix

This commit is contained in:
Michał Zieliński
2025-05-29 20:21:38 +02:00
parent c28234a075
commit 6adf4ff412

View File

@@ -14,7 +14,8 @@ require_once('modules/EcmProducts/Forms.php');
require_once('include/time.php');
require_once('include/json_config.php');
function getConsignmentsDocs($prod_id, $stock_id, $jm) {
function getConsignmentsDocs($prod_id, $stock_id, $jm)
{
$documents_map = array(
'EcmStockDocIns' => 'PZ',
'EcmStockDocCorrects' => 'KS',
@@ -62,7 +63,6 @@ function getConsignmentsDocs($prod_id, $stock_id, $jm) {
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'] = '';
}
@@ -108,7 +108,8 @@ function getConsignmentsDocs($prod_id, $stock_id, $jm) {
return $html;
}
function getStockOperations($product_id, $stock_id, $jm){
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);
@@ -239,9 +240,9 @@ $currency = new Currency();
$currency_list = $currency->get_full_list('name');
$currency->retrieve('-99');
if (is_array($currency_list)) {
$currency_list = array_merge(Array($currency), $currency_list);
$currency_list = array_merge(array($currency), $currency_list);
} else {
$currency_list = Array($currency);
$currency_list = array($currency);
}
$arr = array();
foreach ($currency_list as $key => $value) {
@@ -249,7 +250,8 @@ foreach ($currency_list as $key => $value) {
}
$detail->ss->assign("EXCHANGE_RATE_NAME", $arr[$focus->exchange_rate_id]);
function show_image($img) {
function show_image($img)
{
if (is_file($img)) {
$obraz = @GetImageSize($img);
if ($obraz[0] >= 180) {
@@ -281,40 +283,33 @@ $pl4 = $this->bean->showPrices();
$detail->ss->assign('POSITIONS4', $pl4);
$ii = '<table id="stock_info" cellspacing="0" cellpadding="0" border="0" width="400">
<tr>
<td style="text-align: center"><b>' . $mod_strings['LBL_II_STOCK'] . '</b></td>
<td style="text-align: center; width:10%"><b>' . $mod_strings['LBL_II_QTY'] . '</b></td>
<td style="text-align: center; width:10%"><b>Wartość</b></td>
<td style="text-align: center; width:3%"></td>
<td style="text-align: left"><b>' . $mod_strings['LBL_II_STOCK'] . '</b></td>
<td style="text-align: right; width:10%"><b>' . $mod_strings['LBL_II_QTY'] . '</b></td>
<td style="text-align: right; width:10%"><b>Cena</b></td>
</tr>';
$w = $GLOBALS['db']->query("SELECT
s.name AS stockname,
s.id AS stockid,
so.quantity AS quantity ,
so.price AS price,
so.type AS type
ss.quantity AS quantity ,
ss.price AS price
FROM
ecmstockoperations so,
ecmstockstates ss,
ecmstocks s
WHERE
so.product_id = '".$focus->id."'
AND so.stock_id = s.id");
ss.product_id = '" . $focus->id . "'
AND ss.stock_id = s.id AND ss.quantity IS NOT NULL");
$stocksplus = array();
while ($r = $GLOBALS['db']->fetchByAssoc($w)) {
if($r['type']==0){
$stocksplus[$r['stockid']]['quantity'] += $r['quantity'];
$stocksplus[$r['stockid']]['pricequantity'] += $r['quantity']*$r['price'];
}elseif($r['type']==1){
$stocksplus[$r['stockid']]['quantity'] -= $r['quantity'];
$stocksplus[$r['stockid']]['pricequantity'] -= $r['quantity']*$r['price'];
}
$stocksplus[$r['stockid']]['stockid'] = $r['stockid'];
$stocksplus[$r['stockid']]['stockname'] = $r['stockname'];
}
if(count($stocksplus)==0){
$ii='Brak operacji magazynowych';
}else{
foreach($stocksplus as $key => $value){
$ii .= '
<tr>
<td>'.$r['stockname'].'</td>
<td style="text-align: right">'.$r['quantity'].'</td>
<td style="text-align: right">'.$r['price'].'</td>
<tr>
';
/*
// if ($value['quantity'] > 0){
$ii .= '<tr>
<td>
@@ -328,10 +323,11 @@ if(count($stocksplus)==0){
</tr>
<tr><td colspan='4'>" . getConsignmentsDocs($focus->id, $value['stockid'], $focus->unit_id) . "</td></tr>
<tr><td colspan='4'>" . getStockOperations($focus->id, $value['stockid'], $focus->unit_id) . "</td></tr>";
// }
';
*/
}
$ii .= '</table>';
}
unset($stocksplus);
@@ -499,4 +495,3 @@ echo $detail->display();
require_once('include/SubPanel/SubPanelTiles.php');
$subpanel = new SubPanelTiles($focus, "EcmProducts");
echo $subpanel->display();
?>