case 'msws': $q .= " ORDER BY es.stock ASC, el.weekly_sold DESC"; break; default: $q .= " ORDER BY {$sort_option}"; break; } //$q .= " LIMIT 10"; $r = tep_db_query($q); $elements = array(); $total_total = 0; $dioh_collection = array(); while ($row = tep_db_fetch_array($r)) { $listofids[] = $row['elements_id']; $total_total += $row['total']; $dioh_collection[$row['elements_id']] = calculateDIOH($row['stock'], $row[element::DIOH_BASENUMBER_COLUMN_NAME]); } $dioh_average = count($dioh_collection) > 0 ? displayDuration(array_sum($dioh_collection) / count($dioh_collection) * 86400, 'day') : '<span class="notice">N/A</span>'; $table = array(); $table[] = $header; $row_template = '<tr id="id-{ID1}" class="{ODDEVEN}">'; $row_template .= '<td class="img">' . webImage('', '80', '80') . '</td>'; $row_template .= '<td class="id"><a href="?open=element&id={ID2}&hidemenu=true" class="view_webpage">{ID3}</a></td>'; $row_template .= '<td colspan="' . (count($header) - 2) . '" class="load"> </td>'; $row_template .= '</tr>'; $width = $sort_option == 'msws' ? '1030' : '975'; //$content .= '<div style="position:absolute;left:600px;top:85px;"><input type="button" id="print-stock" value="Print Stock List" /></div>'; $content .= '<div style="margin-bottom:10px;width:' . $width . 'px;"><form name="frm_sort" action="?open=elements-stock-list" method="post">'; $content .= '<div style="float:right;">'; $content .= '<table class="form" border="0" cellpadding="0" cellspacing="0" style="margin-bottom:10px;">'; $content .= '<tr><td width="150"><strong>Filter by Category</strong></td>';
/** * DEPRECATED! please use the one in class product as an object * @param Int $products_id * @param Int $articles_id * @param Int $current_stock * @return Int */ function getDIOH($products_id, $articles_id, $current_stock) { $p = $this->retrieveDetail($products_id, 'pal'); // return ($p['pal'][$articles_id]['sold_monthly_1']==0) ? null : floor($current_stock*(30/$p['pal'][$articles_id]['sold_monthly_1'])); return calculateDIOH($current_stock, $p['pal'][$articles_id]['sold_monthly_1']); }
if (!$isdatefiltered) { $q = "SELECT es.elements_id, es.`stock`, es.pieces_per_qty_type, IFNULL(e.`elements_price`, 0) price, el.sold_monthly_1, e.attribute_category_id"; $q .= " FROM element e"; $q .= " INNER JOIN elements_stock es ON es.elements_id = e.elements_id"; $q .= " LEFT JOIN elements_log el ON el.elements_id=e.elements_id"; $q .= " WHERE es.jng_warehouses_id = " . WAREHOUSE_ID_ELEMENTS; $dbq = tep_db_query($q); $el_stock_value = 0; $dioh_collection_all = array(); $dioh_collection_moving = array(); $dioh_collection_supermarkt = array(); $dioh_collection_scheduled = array(); while ($row = tep_db_fetch_array($dbq)) { $el_id = $row['elements_id']; $el_stock_value += $row['stock'] * $row['price']; $dioh = calculateDIOH($row['stock'], $row[element::DIOH_BASENUMBER_COLUMN_NAME]); if ($row['attribute_category_id'] != '6') { $dioh_collection_all[] = $dioh; if ($row['sold_monthly_1'] > 0) { $dioh_collection_moving[] = $dioh; } if ($row['pieces_per_qty_type'] <= 1) { $dioh_collection_supermarkt[] = $dioh; } else { $dioh_collection_scheduled[] = $dioh; } } } $avg_dioh_all = count($dioh_collection_all) > 0 ? displayDuration(array_sum($dioh_collection_all) / count($dioh_collection_all) * 86400, 'day') : '<span class="notice">N/A</span>'; $avg_dioh_moving = count($dioh_collection_moving) > 0 ? displayDuration(array_sum($dioh_collection_moving) / count($dioh_collection_moving) * 86400, 'day') : '<span class="notice">N/A</span>'; $avg_dioh_supermarkt = count($dioh_collection_supermarkt) > 0 ? displayDuration(array_sum($dioh_collection_supermarkt) / count($dioh_collection_supermarkt) * 86400, 'day') : '<span class="notice">N/A</span>';
function getDIOH($current_stock) { return calculateDIOH($current_stock, $this->log[self::DIOH_BASENUMBER_COLUMN_NAME]); }