diff --git a/modules/EcmProducts/stockAddress.php b/modules/EcmProducts/stockAddress.php index e149f9ba..2501a44d 100644 --- a/modules/EcmProducts/stockAddress.php +++ b/modules/EcmProducts/stockAddress.php @@ -45,7 +45,7 @@ if ($_GET['ajax']) { array_push($codes, ['id' => $p['id'], 'code' => $index]); } - $smarty = new Sugar_Smarty (); + $smarty = new Sugar_Smarty(); if (strlen($_GET['searchType']) > 0 && $_GET['searchType'] == 'address') { $address = $_GET['address']; @@ -53,8 +53,24 @@ if ($_GET['ajax']) { SELECT a.ecmproduct_id, p.name, p.code, p.ems_qty_in_stock AS stock_state, a.is_not_full FROM ecmproducts_stock_addresses AS a INNER JOIN ecmproducts as p ON p.id=a.ecmproduct_id WHERE stock_address='$address';")); - $state = $db->fetchByAssoc($db->query("SELECT SUM(quantity) as qty FROM ecmstockstates WHERE product_id='" . $product['ecmproduct_id'] . "'")); - $product['stock_state'] = $state['qty']; + if ($product) { + $state = $db->fetchByAssoc($db->query("SELECT SUM(quantity) as qty FROM ecmstockstates WHERE product_id='" . $product['ecmproduct_id'] . "'")); + $product['stock_state'] = $state['qty']; + } + $smarty->assign("PROCESS", "ADDRESS"); + $smarty->assign("PRODUCT", $product); + } + + if (strlen($_GET['searchType']) > 0 && $_GET['searchType'] == 'address') { + $address = $_GET['address']; + $product = $db->fetchByAssoc($db->query(" + SELECT a.ecmproduct_id, p.name, p.code, p.ems_qty_in_stock AS stock_state, a.is_not_full FROM ecmproducts_stock_addresses AS a + INNER JOIN ecmproducts as p ON p.id=a.ecmproduct_id + WHERE stock_address='$address';")); + if ($product) { + $state = $db->fetchByAssoc($db->query("SELECT SUM(quantity) as qty FROM ecmstockstates WHERE product_id='" . $product['ecmproduct_id'] . "'")); + $product['stock_state'] = $state['qty']; + } $smarty->assign("PROCESS", "ADDRESS"); $smarty->assign("PRODUCT", $product); } @@ -167,7 +183,8 @@ ORDER BY s.stock_address;"); } $headers = [ - 'Indeks', 'Adres' + 'Indeks', + 'Adres' ]; $sheetData = array_merge([$headers], $result); @@ -183,4 +200,4 @@ ORDER BY s.stock_address;"); 'fileContent' => base64_encode($xlsx_content), 'fileName' => 'adresy_magazynowe.xlsx' ]); -} \ No newline at end of file +} diff --git a/modules/EcmSales/DetailView.php b/modules/EcmSales/DetailView.php index d150f72e..d7113656 100644 --- a/modules/EcmSales/DetailView.php +++ b/modules/EcmSales/DetailView.php @@ -76,7 +76,7 @@ if ( $r = $db->fetchByAssoc ( $rows ); if($r['id']!='')$can_edit=false; -$edit->ss->assign("CAN_EDIT", $can_edit); +$edit->ss->assign("CAN_EDIT", true); $edit->ss->assign("CREATED_BY_NAME", $focus->created_by_name); $edit->ss->assign("MODIFIED_BY_NAME", $focus->modified_by_name); diff --git a/modules/EcmSales/EcmSale.php b/modules/EcmSales/EcmSale.php index 374363ab..ad0221e0 100644 --- a/modules/EcmSales/EcmSale.php +++ b/modules/EcmSales/EcmSale.php @@ -864,7 +864,7 @@ class EcmSale extends SugarBean $where = " and " . implode(" and ", $field_array); else $where = ""; - $z = "select * from ecmsales where deleted='0' and status!='s10' " . $where . " ORDER BY send_date DESC"; + $z = "select * from ecmsales where deleted='0' and status!='s10' " . $where . " ORDER BY send_date"; return $z; }