function analysis_overview($period, $price_type) { use_class('jng_warehouses'); $class_jw = new jng_warehouses(); $q = "SELECT jw.name, jw.warehouse_code, jw.warehouse_type"; $q .= ", IF(jw.warehouse_type='E', SUM(mse.stock_open), SUM(msp.stock_open)) AS stock_open"; $q .= ", IF(jw.warehouse_type='E', SUM(mse.stock_close), SUM(msp.stock_close)) AS stock_close"; /* if($price_type=='mat_exp') { $q .= ", IF(jw.warehouse_type='E', SUM(mse.mat_exp_open), SUM(msp.mat_exp_open)) AS stock_value_open"; $q .= ", IF(jw.warehouse_type='E', SUM(mse.mat_exp_close), SUM(msp.mat_exp_close)) AS stock_value_close"; } else { $q .= ", IF(jw.warehouse_type='E', 0, SUM(msp.purchase_price_open)) AS stock_value_open"; $q .= ", IF(jw.warehouse_type='E', 0, SUM(msp.purchase_price_close)) AS stock_value_close"; } */ if ($price_type == 'mat_exp') { $q .= ", IF(jw.warehouse_type='E', SUM(mse.stock_open*mse.mat_exp_open), SUM(msp.stock_open*msp.mat_exp_open)) AS stock_value_open"; $q .= ", IF(jw.warehouse_type='E', SUM(mse.stock_close*mse.mat_exp_close), SUM(msp.stock_close*msp.mat_exp_close)) AS stock_value_close"; } else { $q .= ", IF(jw.warehouse_type='E', 0, SUM(msp.stock_open*msp.purchase_price_open)) AS stock_value_open"; $q .= ", IF(jw.warehouse_type='E', 0, SUM(msp.stock_close*msp.purchase_price_close)) AS stock_value_close"; } $q .= " FROM jng_warehouses jw"; $q .= " LEFT JOIN minierp_stock_elements mse ON mse.jng_warehouses_id=jw.jng_warehouses_id AND mse.stock_period='{$period}'"; $q .= " LEFT JOIN minierp_stock_products msp ON msp.jng_warehouses_id=jw.jng_warehouses_id AND msp.stock_period='{$period}'"; $q .= " GROUP BY jw.jng_warehouses_id"; $q .= " ORDER BY jw.jng_warehouses_id"; $r = tep_db_query($q); $stocks = array(); $s = array(); $s['name'] = 'Warehouse Name'; $s['long_id'] = 'Code'; $s['status'] = 'Type'; $s['price'] = 'Inventory<br />BoP Value'; $s['price2'] = 'Inventory<br />EoP Value'; $s['price3'] = 'Inventory<br />Ave.Value'; $stocks[] = $s; while ($row = tep_db_fetch_array($r)) { $bop = $row['stock_value_open']; $eop = $row['stock_value_close']; $avg = ($bop + $eop) / 2; $s['name'] = $row['name']; $s['long_id'] = $row['warehouse_code']; $s['status'] = $class_jw->typeName($row['warehouse_type']); if ($row['warehouse_type'] == 'E' && $price_type != 'mat_exp') { $s['price'] = '-'; $s['price2'] = '-'; $s['price3'] = '-'; } else { $s['price'] = number_format($bop, 2); $s['price2'] = number_format($eop, 2); $s['price3'] = number_format($avg, 2); } $stocks[] = $s; } $result = tep_draw_table('', $stocks); return $result; }
$g['id'] = 'ID'; $g['name'] = 'Name'; $g['long_id'] = 'Code'; $g['source'] = 'Type'; //$g['nick'] = 'PIC'; //$g['city'] = 'City'; $g['act'] = 'Status'; $wh_table[] = $g; if (count($warehouses) > 0) { foreach ($warehouses as $row) { $detail = '?open=warehouse&id=' . $row['jng_warehouses_id'] . '&hidemenu=true'; $g = array(); $g['id'] = '<a href="' . $detail . '" class="view_webpage" title="Manage warehouse detail">' . $row['jng_warehouses_id'] . '</a>'; $g['name'] = '<a href="' . $detail . '" class="view_webpage" title="Manage warehouse detail">' . $row['name'] . '</a>'; $g['long_id'] = $row['warehouse_code']; $g['source'] = $class_jw->typeName($row['warehouse_type']); //$g['nick'] = '<a href="'.$row['pic'].'">'.$row['pic'].'</a>'; //$g['city'] = $row['address_city']; $g['act'] = '<img src="images/icon-tick' . ($row['is_active'] == '1' ? '' : '-dis') . '.png" />'; $wh_table[] = $g; } } else { $g = array(); $g['id'] = ' '; $g['name'] = ' '; $g['long_id'] = ' '; $g['type'] = ' '; //$g['nick'] = ' '; //$g['city'] = ' '; $g['act'] = ''; $wh_table[] = $g;