Example #1
0
     continue;
 }
 $p = new Product($pid);
 //Skip product if it's a wholesale product
 if ($p->is_wholesale) {
     $logger->write("Product {$pid} skipped (wholesale)");
     continue;
 }
 foreach ($p->articles as $aid => $a) {
     //Only create refill for active article
     if ($a['active_status'] != '1') {
         continue;
     }
     $stock_id = $p->id . '-' . $aid;
     //CURRENT STOCK TARGET
     $target_stock = $p->getDIOHstockTarget($aid);
     //CURRENT STOCK (ALREADY RETRIEVED ABOVE)
     $current_stock = intval($products_stock[$stock_id]);
     //CURRENT OPEN ORDERS
     $already_ordered = $class_do->refillOpenOrdersQuantity($segment_id, $p->id, $aid);
     //Check if we have missing qty
     $missing_quantity = $target_stock - ($current_stock + $already_ordered);
     if ($missing_quantity > 0) {
         $products_with_missing_qty[] = $p->id;
         $articles_with_missing_qty[] = $stock_id;
         $total_qty += $missing_quantity;
         $log_message = "Product {$stock_id} - Missing:{$missing_quantity}";
         //Create depot orders of the needed qty
         $class_do->newOrderAutoRefill($segment_id, $p->id, $aid, $a['products_ean'], $missing_quantity, depot_orders::AUTO_REFILL_ID_DAILYCRON);
         $log_message .= " - Refill created";
         //If needed qty is too big, send an email notification
Example #2
0
 $order_qty = array();
 $product_stock_target = 0;
 $product_missing_qty = 0;
 if (count($p['articles']) > 1) {
     $size[$a_counter] = '';
     $stock[$a_counter] = '<b>' . intval($p['qty_stock']) . '</b>';
     $qty_ordered[$a_counter] = '<b>' . intval($p['qty_order']) . '</b>';
     $qty_min[$a_counter] = '<b>-</b>';
     $sold_last_month[$a_counter] = '<b>' . intval($p['sold_monthly_1']) . '</b>';
     $sold_last_week[$a_counter] = '<b>' . intval($p['sold_weekly']) . '</b>';
     $missing_qty[$a_counter] = '<b>-</b>';
     $order_qty[$a_counter] = '';
 }
 foreach ($p['articles'] as $aid => $a) {
     $a_counter++;
     $a_stock_target = $obj_product->getDIOHstockTarget($aid);
     $a_missing_qty = $a_stock_target - ($a['article_stock'] + $a['article_orders_qty']);
     if ($a_missing_qty < 0) {
         $a_missing_qty = 0;
     }
     $size[$a_counter] = $a['article_length'] > 0 ? textLength($a['article_length']) : '<span class="notice">None</span>';
     $stock[$a_counter] = intval($a['article_stock']);
     $qty_ordered[$a_counter] = intval($a['article_orders_qty']);
     $qty_min[$a_counter] = $a_stock_target;
     $sold_last_month[$a_counter] = intval($a['article_sold_monthly_1']);
     $sold_last_week[$a_counter] = intval($a['article_weekly_sold']);
     $missing_qty[$a_counter] = $a_missing_qty;
     if ($special_mode == 'outsourced') {
         $qty_form = '<span>';
         $qty_form .= '<input type="button" name="os-create" value="Form" title="Open form to create new order" />';
         $qty_form .= '<input type="hidden" name="pid" value="' . $pid . '" />';
     $levelling_orders_ptb[$a_counter] = '<b>-</b>';
     $levelling_orders_os[$a_counter] = '<b>-</b>';
     $total_target[$a_counter] = '<b>-</b>';
     $total_qty_missing[$a_counter] = '<b>-</b>';
     $levelling_orders_today[$a_counter] = '<b>-</b>';
     $order_qty[$a_counter] = '<b>-</b>';
 }
 foreach ($p['articles'] as $aid => $a) {
     $a_counter++;
     $fc_base_daily = $obj_product->getForecastDailyBaseValue($aid);
     $size[$a_counter] = $a['article_length'] > 0 ? textLength($a['article_length']) : 'None';
     $ean[$a_counter] = $a['article_ean'];
     $sold_last_month_nopromo[$a_counter] = intval($a['article_fc_base_monthly']);
     $sold_last_month[$a_counter] = intval($a['article_sold_monthly_1']);
     $stock[$a_counter] = intval($a['article_stock']);
     $stock_target[$a_counter] = $obj_product->getDIOHstockTarget($aid);
     $qty_ordered[$a_counter] = intval($a['article_orders_qty']);
     $qty_missing[$a_counter] = $stock_target[$a_counter] - ($stock[$a_counter] + $qty_ordered[$a_counter]);
     if ($qty_missing[$a_counter] < 0) {
         $qty_missing[$a_counter] = 0;
     }
     $levelling_target[$a_counter] = $fc->calcLevellingTarget($fc_base_daily, $current_month);
     $count_levelling_orders = $class_do->countOrdersLevellingDetailsByArticle($pid, $aid);
     $count_levelling_orders_today = $class_do->countOrdersLevellingByArticleAndDate($pid, $aid, 'today');
     $levelling_orders[$a_counter] = $count_levelling_orders['total'];
     $levelling_orders_ptb[$a_counter] = $count_levelling_orders['internal'];
     $levelling_orders_os[$a_counter] = $count_levelling_orders['outsourcing'];
     //DURING OVERLAP PERIOD WE MUST USE ONLY THE LEVELLING
     //TARGET BECAUSE STOCK TARGET IS ALREADY INCLUDED THERE
     $total_target[$a_counter] = $target_is_overlap ? $levelling_target[$a_counter] : $levelling_target[$a_counter] + $stock_target[$a_counter];
     $total_qty_missing[$a_counter] = $total_target[$a_counter] - ($stock[$a_counter] + $qty_ordered[$a_counter]);
$content .= '<tr><td>L30D Daily average</td><td>=</td><td>' . $daily_sold . '</td></tr>';
$content .= '<tr><td>L30D Weekly average</td><td>=</td><td>' . $last_week_sold . '</td></tr>';
$content .= '<tr><td>Today</td><td>=</td><td class="w080">KW ' . $kw_now . '</td></tr>';
$content .= '<tr><td colspan="3" class="bold">Graph is using product level forecasting (not article level)</td></tr>';
$content .= '</table></div>';
$content .= '</div>';
$content .= '<div style="clear:both;padding-top:20px;">';
$content .= '<h2>Depot Refill using Forecast';
if ($articles_id != '*' && count($p->articles) > 0) {
    $content .= ' <span id="txt-show-all-articles" class="pointer blue smallText">&laquo;show all articles&raquo;</span>';
}
$content .= '</h2>';
foreach ($p->articles as $aid => $a) {
    $a_title = $a['length'] > 0 ? textLength($a['length']) : '<span class="notice">No Length</span>';
    $daily_sold = $p->log_articles[$aid][Product::FORECAST_DAILY_COLUMN_NAME];
    $stock_target = $p->getDIOHstockTarget($aid);
    $stock_available = $p->retrieveStockQuantity($aid);
    $stock_available_dioh = $p->displayDIOH($aid, $stock_available);
    $refill_ordered = $p->retrieveRefillQuantity($aid);
    $missing_qty = $stock_target - ($stock_available + $refill_ordered);
    if ($missing_qty < 0) {
        $missing_qty = 0;
    }
    $show_box = $articles_id == '*' || $articles_id == $aid ? '' : 'display:none;';
    $content .= '<div class="float-box w300 ui-corner-all" style="padding:5px;margin:0 10px 10px 0;' . $show_box . '"><table border="0" cellspacing="0" cellpadding="0">';
    $content .= '<tr><td colspan="3" class="bold">EAN ' . $a['products_ean'] . ' - ' . $a_title . '</td></tr>';
    $content .= '<tr><td>Daily Average <span class="red" title="' . $forecasting_conf['promotion-orders-desc'] . '">(!)</span></td><td>=</td><td>' . $daily_sold . '</td></tr>';
    $content .= '<tr><td title="Stock Target based on DIOH Target Settings">Stock Target (' . Product::$diohStopLevel[$p->stars] . ' days)</td><td>=</td><td>' . $stock_target . '</td></tr>';
    $content .= '<tr><td>Stock Available</td><td>=</td><td>' . $stock_available . '&nbsp;<span class="notice">(' . $stock_available_dioh . ')</span></td></tr>';
    $content .= '<tr><td>Refill Ordered</td><td>=</td><td>' . $refill_ordered . '</td></tr>';
    $content .= '<tr><td class="bold">Missing Quantity</td><td class="bold">=</td><td class="bold">' . $missing_qty . '</td></tr>';