diff --git a/modules/EcmProducts/DetailView.php b/modules/EcmProducts/DetailView.php
index 4a609098..059ba974 100755
--- a/modules/EcmProducts/DetailView.php
+++ b/modules/EcmProducts/DetailView.php
@@ -14,14 +14,15 @@ require_once('modules/EcmProducts/Forms.php');
require_once('include/time.php');
require_once('include/json_config.php');
-function getConsignmentsDocs($prod_id, $stock_id, $jm) {
- $documents_map = array (
- 'EcmStockDocIns' => 'PZ',
- 'EcmStockDocCorrects' => 'KS',
- 'EcmStockDocMoves' => 'MM',
- 'EcmStockDocInsideIns' => 'PW'
+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
@@ -37,48 +38,47 @@ function getConsignmentsDocs($prod_id, $stock_id, $jm) {
i.type='0'
group by i.id
order by i.date_entered;";
- $res = $db->query ( $query );
- $result = array ();
+ $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'] ));
+ 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'){
-
+ $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'] = '';
+ 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'] . "'";
+ } 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'] = '' . $accountRow['parent_name'] . ' ';
-
- }else{
- $tmp ['account_name'] = '';
+ if ($accountResult->num_rows > 0) {
+ $accountRow = $db->fetchByAssoc($accountResult);
+ $tmp['account_name'] = '' . $accountRow['parent_name'] . ' ';
+ } else {
+ $tmp['account_name'] = '';
}
}
- $tmp ['operation_id'] = $row ['id'];
- $tmp ['parent_name'] = '' . $documents_map [$row ['parent_type']] . ' ' . $row ['parent_name'] . ' ';
- $tmp ['part_no'] = $row['part_no'];
- $tmp ['availability'] = $availability;
- $tmp ['parent_id'] = $row ['parent_id'];
- $tmp ['parent_type'] = $row ['parent_type'];
+ $tmp['operation_id'] = $row['id'];
+ $tmp['parent_name'] = '' . $documents_map[$row['parent_type']] . ' ' . $row['parent_name'] . ' ';
+ $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;
+ $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, ",", ".")
$html = '
@@ -92,27 +92,28 @@ function getConsignmentsDocs($prod_id, $stock_id, $jm) {
Cena
Wartość
';
-
- foreach($result as $key => $value){
- $tmp = $value['availability']*$value['price'];
- $html.='';
- $html.='' . $value['parent_name'] .' ';
- $html.='' . $value['account_name'] .' ';
- $html.='' . $value['part_no'] .' ';
- $html.='' . number_format($value['availability'], $app_list_strings['ecmproducts_unit_dom_precision'][$jm], ",", ".") .' ' . $value['unit'].' '; //FormatNumber(c.availability) + ' ' + c.unit
- $html.='' . number_format($value['price'], 2, ",", ".") . ' ' . $value['currency'] . ' / ' . $value['unit'] . ' '; //FormatNumber(c.price) + ' ' + c.currency + ' / ' + c.unit
- $html.=''. number_format($tmp, 2, ",", ".") .' zł ';
- $html.=' ';
+
+ foreach ($result as $key => $value) {
+ $tmp = $value['availability'] * $value['price'];
+ $html .= '';
+ $html .= '' . $value['parent_name'] . ' ';
+ $html .= '' . $value['account_name'] . ' ';
+ $html .= '' . $value['part_no'] . ' ';
+ $html .= '' . number_format($value['availability'], $app_list_strings['ecmproducts_unit_dom_precision'][$jm], ",", ".") . ' ' . $value['unit'] . ' '; //FormatNumber(c.availability) + ' ' + c.unit
+ $html .= '' . number_format($value['price'], 2, ",", ".") . ' ' . $value['currency'] . ' / ' . $value['unit'] . ' '; //FormatNumber(c.price) + ' ' + c.currency + ' / ' + c.unit
+ $html .= '' . number_format($tmp, 2, ",", ".") . ' zł ';
+ $html .= ' ';
}
$html .= ' ';
return $html;
}
-function getStockOperations($product_id, $stock_id, $jm){
- global $db,$app_list_strings;
+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 ();
+ $res = $db->query($query);
+ $result = array();
$html = '
Operacje magazynowe
@@ -124,58 +125,58 @@ function getStockOperations($product_id, $stock_id, $jm){
Ilość
Stan po
';
- $stanpo =0;
- $doc_name=array(
- 'EcmStockDocInsideIns'=>'PW',
- 'EcmStockDocMoves'=>'MM',
- 'EcmStockDocCorrects'=>'KS',
- 'EcmStockDocIns'=>'PZ',
- 'EcmStockDocOuts'=>'WZ',
- 'EcmStockDocInsideOuts'=>'RW',
- 'EcmInvoiceOuts'=>'FK'
+ $stanpo = 0;
+ $doc_name = array(
+ 'EcmStockDocInsideIns' => 'PW',
+ 'EcmStockDocMoves' => 'MM',
+ 'EcmStockDocCorrects' => 'KS',
+ 'EcmStockDocIns' => 'PZ',
+ 'EcmStockDocOuts' => 'WZ',
+ 'EcmStockDocInsideOuts' => 'RW',
+ 'EcmInvoiceOuts' => 'FK'
);
- while ( $row = $db->fetchByAssoc ( $res ) ) {
+ 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 );
+ $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 = '' . $kontrahent['parent_name'] . ' ';
- break;
- }
- default :{
- $tmp = $kontrahent['parent_name'];
- }
+ $kontrahent = $db->fetchByAssoc($result);
+ if ($kontrahent['parent_type'] == NULL || $kontrahent['parent_type'] == '') {
+ switch ($row['parent_type']) {
+ case 'EcmStockDocIns': {
+ $kontrahent['parent_type'] = 'Accounts';
+ $tmp = '' . $kontrahent['parent_name'] . ' ';
+ break;
+ }
+ default: {
+ $tmp = $kontrahent['parent_name'];
+ }
}
- }else{
- $tmp = '' . $kontrahent['parent_name'] . ' ';
+ } else {
+ $tmp = '' . $kontrahent['parent_name'] . ' ';
}
$nazwa = '';
- if($row['type']==0){
- $nazwa = '' . $doc_name[$row['parent_type']] . ' ' . $row['parent_name'] . ' ';
- $stanpo +=$row['quantity'];
- }elseif($row['type']==1){
- $nazwa = '' . $doc_name[$row['parent_type']] . ' ' . $row['parent_name'] . ' ';
- $stanpo -=$row['quantity'];
+ if ($row['type'] == 0) {
+ $nazwa = '' . $doc_name[$row['parent_type']] . ' ' . $row['parent_name'] . ' ';
+ $stanpo += $row['quantity'];
+ } elseif ($row['type'] == 1) {
+ $nazwa = '' . $doc_name[$row['parent_type']] . ' ' . $row['parent_name'] . ' ';
+ $stanpo -= $row['quantity'];
}
- $data = substr($row['date_entered'],0,10);
+ $data = substr($row['date_entered'], 0, 10);
$data = explode('-', $data);
- $data = $data[2] . '.' .$data[1] . '.' .$data[0];
- $html.='';
- $html.='' . $nazwa .' ';
- $html.='' . $tmp .' ';
- $html.='' . $data . ' '; //FormatNumber(c.availability) + ' ' + c.unit
- $html.='' . number_format($row['price'], 2, ",", ".") . ' ';
- $html.=''. number_format($row['quantity'], $app_list_strings['ecmproducts_unit_dom_precision'][$jm], ",", ".") .' ';
- $html.=''. number_format($stanpo, $app_list_strings['ecmproducts_unit_dom_precision'][$jm], ",", ".") .' ';
- $html.=' ';
+ $data = $data[2] . '.' . $data[1] . '.' . $data[0];
+ $html .= '';
+ $html .= '' . $nazwa . ' ';
+ $html .= '' . $tmp . ' ';
+ $html .= '' . $data . ' '; //FormatNumber(c.availability) + ' ' + c.unit
+ $html .= '' . number_format($row['price'], 2, ",", ".") . ' ';
+ $html .= '' . number_format($row['quantity'], $app_list_strings['ecmproducts_unit_dom_precision'][$jm], ",", ".") . ' ';
+ $html .= '' . number_format($stanpo, $app_list_strings['ecmproducts_unit_dom_precision'][$jm], ",", ".") . ' ';
+ $html .= ' ';
}
$html .= '
';
return $html;
@@ -204,11 +205,11 @@ $uunit_array = array();
$uunit = '';
$result = $db->query("select id,name from ecmproductusageunits order by name asc");
foreach ($app_list_strings['ecmproducts_unit_dom'] as $key => $value) {
- $uunit.='usage_unit_id == $key) {
- $uunit.=' selected';
+ $uunit .= ' selected';
}
- $uunit.='>' . $value . ' ';
+ $uunit .= '>' . $value . '';
$uunit_array[$key] = $value;
}
$detail->ss->assign("USAGE_UNIT_ID", $uunit);
@@ -216,20 +217,20 @@ $detail->ss->assign("USAGE_UNIT_ID", $uunit);
$fbas = '';
$result = $db->query("select id,name from ecmproductbasis order by name asc");
while (($row = $db->fetchByAssoc($result)) != null) {
- $fbas.='fob_basis_id == $row['id'])
- $fbas.=' selected';
- $fbas.='>' . $row['name'] . ' ';
+ $fbas .= ' selected';
+ $fbas .= '>' . $row['name'] . '';
}
$detail->ss->assign("FOB_BASIS_ID", $fbas);
$pack = '';
$result = $db->query("select id,name from ecmproductpackingtypes order by name asc");
while (($row = $db->fetchByAssoc($result)) != null) {
- $pack.='packing_type_id == $row['id'])
- $pack.=' selected';
- $pack.='>' . $row['name'] . ' ';
+ $pack .= ' selected';
+ $pack .= '>' . $row['name'] . '';
}
$detail->ss->assign("PACKING_TYPE_ID", $pack);
@@ -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) {
@@ -261,7 +263,7 @@ function show_image($img) {
}
$height = $obraz[1] + 20;
$width = $obraz[0] + 20;
- return ' ';
+ return ' ';
}
}
@@ -281,46 +283,39 @@ $pl4 = $this->bean->showPrices();
$detail->ss->assign('POSITIONS4', $pl4);
$ii = '
- ' . $mod_strings['LBL_II_STOCK'] . '
- ' . $mod_strings['LBL_II_QTY'] . '
- Wartość
-
+ ' . $mod_strings['LBL_II_STOCK'] . '
+ ' . $mod_strings['LBL_II_QTY'] . '
+ Cena
';
-
$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){
- // if ($value['quantity'] > 0){
- $ii.='
+
+ $ii .= '
+
+ '.$r['stockname'].'
+ '.$r['quantity'].'
+ '.$r['price'].'
+
+ ';
+ /*
+
+// if ($value['quantity'] > 0){
+$ii .= '
' . $value['stockname'] . "
- " . number_format($value['quantity'], $app_list_strings['ecmproducts_unit_dom_precision'][$focus->unit_id], ",", ".") .' '. $app_list_strings ['ecmproducts_unit_dom'] [$focus->unit_id] . "
+ " . number_format($value['quantity'], $app_list_strings['ecmproducts_unit_dom_precision'][$focus->unit_id], ",", ".") . ' ' . $app_list_strings['ecmproducts_unit_dom'][$focus->unit_id] . "
" . number_format($value['pricequantity'], 2, ",", ".") . " zł
@@ -328,10 +323,11 @@ if(count($stocksplus)==0){
" . getConsignmentsDocs($focus->id, $value['stockid'], $focus->unit_id) . "
" . getStockOperations($focus->id, $value['stockid'], $focus->unit_id) . " ";
- // }
- }
- $ii.='
';
+';
+*/
}
+$ii .= '';
+
unset($stocksplus);
@@ -399,33 +395,33 @@ else
global $mod_strings;
$desc = '';
-$desc.=' ';
-$desc.='';
-$desc.='Zdjęcie:
Tak Nie ';
-$desc.='Pokaż cene:
Tak Nie ';
-$desc.='Cena:
SRP Price ';
-$desc.='Język:
pl en ';
-$desc.='EAN:
1 2 ';
+$desc .= '
';
+$desc .= '
';
+$desc .= 'Zdjęcie: Tak Nie ';
+$desc .= 'Pokaż cene: Tak Nie ';
+$desc .= 'Cena: SRP Price ';
+$desc .= 'Język: pl en ';
+$desc .= 'EAN: 1 2 ';
-$desc.='
';
+$desc .= '
';
$detail->ss->assign("CATALOGUE_NEW", $desc);
$desc = '';
-$desc.=' Show attributes ';
-$desc.=' Show description ';
-$desc.=' Show specification ';
-$desc.=' Print version ';
-$desc.='Language: pl en ';
-$desc.='
';
+$desc .= ' Show attributes ';
+$desc .= ' Show description ';
+$desc .= ' Show specification ';
+$desc .= ' Print version ';
+$desc .= 'Language: pl en ';
+$desc .= ' ';
$detail->ss->assign("DIV_DESC", $desc);
$desc = '';
-$desc.=' Show attributes ';
-$desc.=' Show description ';
-$desc.=' Show specification ';
-$desc.='Language: pl en ';
-$desc.='
';
+$desc .= ' Show attributes ';
+$desc .= ' Show description ';
+$desc .= ' Show specification ';
+$desc .= 'Language: pl en ';
+$desc .= ' ';
$detail->ss->assign("DIV_DESC_CARD", $desc);
//Added for Graduated Prices - Begin
@@ -499,4 +495,3 @@ echo $detail->display();
require_once('include/SubPanel/SubPanelTiles.php');
$subpanel = new SubPanelTiles($focus, "EcmProducts");
echo $subpanel->display();
-?>
\ No newline at end of file