<?php

/**
 * Description of sppreordermakepo
 *
 * @author IT TEAM BONOFACTUM
 * @created Jul 15, 2013 3:36:20 PM
 */
use_class('jng_sp_preorders');
use_class('element');
use_class('elements_stock');
use_class('elements_order');
use_class('elements_suppliers');
$class_es = new elements_stock();
$id = isset($_GET['id']) ? tep_db_prepare_input($_GET['id']) : null;
$preorder = new jng_sp_preorders($id);
if (isset($_POST['me_action'])) {
    if ($_POST['me_action'] == 'CHANGESUPPLIER') {
        $eid = tep_db_prepare_input($_POST['eid']);
        $supid_old = tep_db_prepare_input($_POST['supid_old']);
        $supid_new = tep_db_prepare_input($_POST['supid_new']);
        $e = new element($eid);
        $e->getSuppliers();
        $etes_id = null;
        foreach ($e->suppliers as $esid => $es) {
            if ($es['elements_suppliers_id'] == $supid_new) {
                $etes_id = $esid;
                break;
            }
        }
        $ajaxResult = array();
     $content .= '<form name="amvdupload_po" action="?open=sp-orders-amvd-upload' . $addhidemenu . '" method="post" enctype="multipart/form-data">';
     $content .= '<table class="form" border="0" cellpadding="0" cellspacing="0">';
     $content .= '<tr><td colspan="2" class="bold">Browse PO File to upload</td></tr>';
     $content .= '<tr><td colspan="2" style="padding-bottom:10px;"><input type="file" name="amvdpo" /></td></tr>';
     $content .= '<tr><td colspan="2">&nbsp;</td></tr>';
     $content .= '<tr><td colspan="2" class="bold">Select Amazon PO Type</td></tr>';
     $content .= '<tr><td width="20"><input type="radio" name="amvdtype" id="amvdtype-sample" value="' . $amazon_sample_id . '" /></td><td style="padding-top:5px;"><label for="amvdtype-sample" class="blue"><strong>GERMAN</strong> - Amazon Sample</label></td></tr>';
     $content .= '<tr><td><input type="radio" name="amvdtype" id="amvdtype-refill" value="' . $amazon_refill_id . '" /></td><td style="padding-top:5px;"><label for="amvdtype-refill" class="blue"><strong>GERMAN</strong> - Amazon Refill</label></td></tr>';
     //$content .= '<tr><td><input type="radio" name="amvdtype" id="amvdtype-frsm" value="'.$amazon_france_standardmodel_id.'" /></td><td style="padding-top:5px;" class="red"><label for="amvdtype-frsm"><strong>FRANCE</strong> - Amazon Standard Model</label></td></tr>';
     $content .= '<tr><td colspan="2">&nbsp;</td></tr>';
     $content .= '<tr><td colspan="2" class="bold">Select BuyVIP PO Type</td></tr>';
     $content .= '<tr><td><input type="radio" name="amvdtype" id="amvdtype-buyvip_test" value="' . $buyvip_test_id . '" /></td><td style="padding-top:5px;"><label for="amvdtype-buyvip_test" class="green">BuyVIP Test-PO</label></td></tr>';
     //$content .= '<tr><td><input type="radio" name="amvdtype" id="amvdtype-buyvip_block" value="'.$buyvip_block_id.'" /></td><td style="padding-top:5px;"><label for="amvdtype-buyvip_block" class="green">BuyVIP Block-PO</label></td></tr>';
     //$content .= '<tr><td><input type="radio" name="amvdtype" id="amvdtype-buyvip_sample" value="'.$buyvip_sample_id.'" /></td><td style="padding-top:5px;"><label for="amvdtype-buyvip_sample" class="green">BuyVIP Sample-PO</label></td></tr>';
     $content .= '<tr><td><input type="radio" name="amvdtype" id="amvdtype-buyvip_kauf" value="' . $buyvip_kauf_id . '" /></td><td style="padding-top:5px;"><label for="amvdtype-buyvip_kauf" class="green">BuyVIP Kauf-PO</label></td></tr>';
     $content .= '<tr><td colspan="2"><select name="preoder" class="input2"><option value="0">Please select a Preorder...</option>' . loadComboListFromArray(jng_sp_preorders::getOpenConfirmedPreorders('NAME')) . '</select></td></tr>';
     $content .= '</table>';
     $content .= '<div class="buttons-left"><input type="button" id="amvdupload-po-go" value="Upload File" class="button" /></div>';
     $content .= '</form>';
 } elseif ($_GET['tab'] == 'po-cancels') {
     $config_open_orders = load_config('open-orders');
     $header = 'PO Cancelations';
     $paragraphs = array();
     $paragraphs[] = '&sdot; Use this function to cancel Amazon PO before confirming back to Vendor Central.';
     $paragraphs[] = '&sdot; currently available only for Amazon German';
     $style = 'margin:10px 0 20px 0;';
     $content .= drawSOPinfo($header, $paragraphs, $style);
     $content .= '<h3 style="margin-top:10px;">Step 1 &raquo; Extend the 1 hour stock checking delay for non Zalando order (optional)</h3>';
     $content .= '<div class="box ui-corner-all w500">';
     $content .= '<div>To make sure Zalando always has priority in using our stock, we have a rule to process other orders 1 hour after we receive them. Since we want to make sure manobo will not process new amazon orders until we are finish with the cancelations, we could extend the delay to 2-3 hours before we start. You can manage the delay here.</div>';
     $content .= '<div class="bold" style="margin-top:10px;">&raquo; Stock checking delay: <input type="text" id="stock-delay-non-zalando" class="w040 tac" value="' . $config_open_orders['stock-delay-non-zalando'] . '" /> minutes</div>';
     //returned string messages when there invalid data found on certain column
     $logger->write('Invalid column structure or no data found on column');
     logProcess($orders, true);
 } else {
     $total_orders = count($orders);
     $total_orders_created = 0;
     $total_orders_exists = 0;
     $total_rows_manual_cancel = 0;
     $lastOrderCount = null;
     if ($total_orders > 0) {
         $total_files_processedok++;
         foreach ($orders as $o) {
             if ($preorder_id == '') {
                 $preorder_id = null;
             }
             $preorder = new jng_sp_preorders($preorder_id);
             $preorder_items_real = array();
             $orders_id_collection = array();
             $buyvip_lastname = $buyvip_lastname_collection[$amazon_id];
             $import_date = date('Y-m-d H:i:s');
             if ($o['order_quantity'] > 0) {
                 $dateonly = date('Y-m-d', $o['order_date']);
                 if (!in_array($o['customer_shipping_id'], $amazon_shipment_id)) {
                     if (!in_array($o['order_id'], $new_shipping_id_orders)) {
                         $subjet = 'BuyVIP New Shipping ID';
                         $message = 'We have received a new Shipping ID from BuyVIP: ' . $o['customer_shipping_id'] . ' - Please check and update this PO#: ' . $o['order_id'];
                         tep_mail(EMAIL_NAME_DEBUGR, EMAIL_ADDRESS_DEBUGR, $subjet, $message, FROM_EMAIL_NAME, FROM_EMAIL_ADDRESS, false);
                         $new_shipping_id_orders[] = $o['order_id'];
                     }
                 }
                 for ($qty = 1; $qty <= $o['order_quantity']; $qty++) {
Example #4
0
     $ajaxResult = array();
     $ajaxResult['pid'] = $pid;
     $ajaxResult['image'] = $product_image . '<br />' . '<a href="?open=product-detail&amp;products_id=' . $pid . '" target="_blank" title="View / Manage Product Detail" class="pid">' . $pid . '</a>';
     $ajaxResult['arts'] = implode('', $articles_options);
     $ajaxResult['stocks'] = implode('', $articles_stock);
     $ajaxResult['reports'] = implode('', $articles_report);
     $ajaxResult['booked'] = implode('', $articles_book);
     $ajaxResult['preprod'] = implode('', $articles_preprod);
     $ajaxResult['ondemand'] = implode('', $articles_ondemand);
     echo ajaxReturn($ajaxResult);
     exit;
 } elseif ($_POST['me_action'] == 'CREATEPREORDER') {
     $jng_sp_id = '7';
     $new_name = tep_db_prepare_input($_POST['newname']);
     $articles = $_POST['articles'];
     $preorder = new jng_sp_preorders();
     $preorder->create($jng_sp_id, $new_name);
     foreach ($articles as $a) {
         list($products_id, $articles_id, $products_ean, $qty_stock, $qty_reported, $qty_booked, $qty_preproduce, $qty_ondemand) = explode('-', $a);
         $preorder->addItem(false, $products_id, $articles_id, $products_ean, $qty_stock, $qty_reported, $qty_booked, $qty_preproduce, $qty_ondemand);
     }
     echo $preorder->id;
     exit;
 } elseif ($_POST['me_action'] == 'UPDATEITEM') {
     $article = $_POST['article'];
     list($item_id, $pid, $aid, $qty_stock, $qty_reported, $qty_booked, $qty_preproduce, $qty_ondemand) = explode('-', $article);
     $preorder->updateItem($item_id, $qty_stock, $qty_reported, $qty_booked, $qty_preproduce, $qty_ondemand);
     $ajaxResult = array();
     $ajaxResult['pid'] = $pid;
     $ajaxResult['aid'] = $aid;
     $ajaxResult['stock'] = $qty_stock;
Example #5
0
                            $value = '<a href="/print/buyvip-list.php?id=' . $obj->id . '" target="_blank" title="Click here to display raw buyvip list">BuyVIP List</a>';
                        }
                        break;
                    default:
                        $value = '&nbsp;';
                }
                $td[$k] = $value;
            }
            $table_data[] = $td;
        }
        $result .= tep_draw_table('', $table_data);
        echo utf8_encode($result);
        exit;
    } elseif ($_POST['me_action'] == 'DELETEPREORDER') {
        $preorders_id = tep_db_prepare_input($_POST['preorders_id']);
        $preorder = new jng_sp_preorders($preorders_id);
        $delete = false;
        if (!is_null($preorder->id)) {
            $delete = $preorder->delete($session_userinfo['username']);
        }
        echo utf8_encode($delete ? 'OK' : 'FAIL');
        exit;
    }
}
$content .= '<div id="table-list"></div>';
$javascript .= '
            function listLoaded(htmlResult, txtResult) {
                if(txtResult=="success") {
                    $("#table-list").html(htmlResult);
                    $("#table-list").find("th,td").addClass("ui-corner-all");
                    applyFancyBox("#table-list", "view_webpage_full");