From c28234a075638e041818b87c436a226eff8ffe3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Zieli=C5=84ski?= Date: Thu, 29 May 2025 20:08:01 +0200 Subject: [PATCH] KS - liquidation --- modules/EcmStockDocCorrects/DetailView.php | 6 + modules/EcmStockDocCorrects/EditView.php | 21 +- .../metadata/detailviewdefs.php | 232 +++++++++--------- 3 files changed, 140 insertions(+), 119 deletions(-) diff --git a/modules/EcmStockDocCorrects/DetailView.php b/modules/EcmStockDocCorrects/DetailView.php index d8b60876..dc4dd6af 100755 --- a/modules/EcmStockDocCorrects/DetailView.php +++ b/modules/EcmStockDocCorrects/DetailView.php @@ -49,6 +49,12 @@ $edit->ss->assign ( "MODIFIED_BY_NAME", $focus->modified_by_name ); $edit->bean = $focus; $edit->tplFile = 'include/ECM/EcmViews/DetailView/Tabs/DetailView.tpl'; +if ($focus->type == '8a6b804b-fac7-5cc2-de19-54c209116b19') { + $r = $db->fetchByAssoc($db->query("SELECT COUNT(id) FROM ecommerce_invoices WHERE ecmstockdoccorrect_id = '".$focus->id."'")); + if ($r['COUNT(id)'] > 0) { + $edit->ss->assign ( "IS_RETURN", true ); + } +} $edit->preDisplay (); echo $edit->display (); diff --git a/modules/EcmStockDocCorrects/EditView.php b/modules/EcmStockDocCorrects/EditView.php index b1598111..a0feb206 100755 --- a/modules/EcmStockDocCorrects/EditView.php +++ b/modules/EcmStockDocCorrects/EditView.php @@ -39,6 +39,8 @@ if (isset($_REQUEST['record']) && $_REQUEST['isDuplicate'] == "false") { $new_number = true; $focus->stock_id = 'cf16804e-f698-5e09-2da3-6553588446ae'; $focus->register_date = date("d.m.Y"); + $focus->type = '8a6b804b-fac7-5cc2-de19-54c209116b19'; + $focus->name = 'Zwrot allegro'; $db = $GLOBALS['db']; $invoiceIds = $_SESSION[$_REQUEST['ecommerceKS']]; @@ -124,9 +126,6 @@ if (isset($_REQUEST['record']) && $_REQUEST['isDuplicate'] == "false") { $edit->ss->assign('ECOMMERCE_PRODUCTS', json_encode($finalProducts)); $edit->ss->assign('ECOMMERCE_INVOICES', json_encode($invoiceIds)); $focus->ecommerce_invoices = $invoiceIds; - $focus->type = '8a6b804b-fac7-5cc2-de19-54c209116b19'; - $focus->stock_id = 'cf16804e-f698-5e09-2da3-6553588446ae'; - $focus->name = 'Zwrot allegro'; $query = "SELECT document_no FROM ecommerce_invoices WHERE id IN ('" . implode('\',\'', $invoiceIds) . "')"; $res = $db->query($query); @@ -135,6 +134,22 @@ if (isset($_REQUEST['record']) && $_REQUEST['isDuplicate'] == "false") { $documentNos[] = $row['document_no']; } $focus->pdf_text = "Dotyczy faktur: " . implode(', ', $documentNos); +} else if (isset($_REQUEST['liquidation'])) { + $new_number = true; + $focus->stock_id = 'cf16804e-f698-5e09-2da3-6553588446ae'; + $focus->register_date = date("d.m.Y"); + $focus->type = '7bb903d0-c296-7d1b-6e50-54c209e30850'; + $focus->name = 'Likwidacja allegro'; + $db = $GLOBALS['db']; + + $ks = new EcmStockDocCorrect(); + $ks->retrieve($_REQUEST['liquidation']); + $products = $ks->getPositionList(true); + foreach ($products as &$item) { + $item['quantity'] = -$item['quantity']; + } + unset($item); + $edit->ss->assign('ECOMMERCE_PRODUCTS', json_encode($products)); } else { $new_number = true; //dates diff --git a/modules/EcmStockDocCorrects/metadata/detailviewdefs.php b/modules/EcmStockDocCorrects/metadata/detailviewdefs.php index fc3f091c..f9451240 100755 --- a/modules/EcmStockDocCorrects/metadata/detailviewdefs.php +++ b/modules/EcmStockDocCorrects/metadata/detailviewdefs.php @@ -69,124 +69,124 @@ * *******************************************************************************/ global $app_list_strings; -$viewdefs ['EcmStockDocCorrects'] ['DetailView'] = array ( - - 'templateMeta' => array ( - - 'form' => array ( - - 'buttons' => array ( - 'CANCEL_DOC', - array ( - 'customCode' => "{include_php file='include/ECM/EcmCreatePdfButton.php'}", - ), - ), - 'hidden' => array ( - '', - '', - '', - '' - ) +$viewdefs['EcmStockDocCorrects']['DetailView'] = array( + + 'templateMeta' => array( + + 'form' => array( + + 'buttons' => array( + 'CANCEL_DOC', + array( + 'customCode' => "{include_php file='include/ECM/EcmCreatePdfButton.php'}", ), - - 'maxColumns' => '2', - - 'widths' => array ( - - array ( - 'label' => '10', - 'field' => '30' - ), - - array ( - 'label' => '10', - 'field' => '30' - ) + array( + 'customCode' => '{if $IS_RETURN}{/if}', ), - - 'includes' => array ( - array ( - 'file' => 'include/JSON.js' - ), - array ( - 'file' => 'modules/EcmStockDocCorrects/javascript/EcmStockDocCorrectsDetail.js' - ), - array ( - 'file' => 'modules/EcmStockDocCorrects/javascript/helper.js' - ), - array ( - 'file' => 'modules/EcmStockDocCorrects/javascript/bimit_table.js' - ), - array ( - 'file' => 'modules/EcmStockDocCorrects/javascript/columndefs-detail.js' - ) - ) + ), + 'hidden' => array( + '', + '', + '', + '' + ) ), - - 'panels' => array ( - - 'LBL_DETAILS_TAB' => array ( - - array ( - 'document_no', - 'assigned_user_name' - ), - - array ( - 'name', - 'stock_name' - ), - - array ( - 'register_date', - 'type' - ), - array ( - 'ecmproductstockindex_name', - ), - array ( - 'pdf_text' - ), - array ( - array ( - - 'name' => 'to_informations', - 'allCols' => true, - - 'hideLabel' => true, - - 'customCode' => '
' - ) - ), - array ( - array ( - 'name' => 'date_modified', - 'label' => 'LBL_DATE_MODIFIED', - 'customCode' => '{$fields.date_modified.value} {$APP.LBL_BY} {$MODIFIED_BY_NAME}' - ), - array ( - 'name' => 'date_entered', - 'customCode' => '{$fields.date_entered.value} {$APP.LBL_BY} {$CREATED_BY_NAME}' - ), - ), + + 'maxColumns' => '2', + + 'widths' => array( + + array( + 'label' => '10', + 'field' => '30' + ), + + array( + 'label' => '10', + 'field' => '30' + ) + ), + + 'includes' => array( + array( + 'file' => 'include/JSON.js' + ), + array( + 'file' => 'modules/EcmStockDocCorrects/javascript/EcmStockDocCorrectsDetail.js' + ), + array( + 'file' => 'modules/EcmStockDocCorrects/javascript/helper.js' + ), + array( + 'file' => 'modules/EcmStockDocCorrects/javascript/bimit_table.js' + ), + array( + 'file' => 'modules/EcmStockDocCorrects/javascript/columndefs-detail.js' + ) + ) + ), + + 'panels' => array( + + 'LBL_DETAILS_TAB' => array( + + array( + 'document_no', + 'assigned_user_name' + ), + + array( + 'name', + 'stock_name' + ), + + array( + 'register_date', + 'type' + ), + array( + 'ecmproductstockindex_name', + ), + array( + 'pdf_text' + ), + array( + array( + + 'name' => 'to_informations', + 'allCols' => true, + + 'hideLabel' => true, + + 'customCode' => '
' + ) + ), + array( + array( + 'name' => 'date_modified', + 'label' => 'LBL_DATE_MODIFIED', + 'customCode' => '{$fields.date_modified.value} {$APP.LBL_BY} {$MODIFIED_BY_NAME}' ), - - 'LBL_ITEMS_TAB' => array ( - - array ( - - array ( - 'name' => 'items_list_panel', - 'allCols' => true, - - 'hideLabel' => true, - - 'customCode' => '
' - ) - ) - ) - ) + array( + 'name' => 'date_entered', + 'customCode' => '{$fields.date_entered.value} {$APP.LBL_BY} {$CREATED_BY_NAME}' + ), + ), + ), + + 'LBL_ITEMS_TAB' => array( + + array( + + array( + 'name' => 'items_list_panel', + 'allCols' => true, + + 'hideLabel' => true, + + 'customCode' => '
' + ) + ) + ) + ) ); - -?> -