}
    if ($result == '') {
        $result = "ERROR: Status is now " . $status_name[$item_status] . $add_info;
    }
    return $result;
}
$result = array();
$result['status'] = 'NOTFOUND';
$result['barcode_entry'] = "{$order_type}-{$item_id}";
$result['result_msg'] = "";
$refill_type = null;
$refill_qty_request = null;
if (is_numeric($item_id)) {
    if ($order_type == 'SP') {
        //Handle SP Orders
        $item = $class_jo->retrieveItemDetail($item_id);
        $sub_status_different = "{$item['status']}-{$item['prod_status']}" != $status_new;
        if (isset($item['status'])) {
            $refill_qty_request = $item['order_quantity'];
            //Validate current status
            if ($item['status'] != $status_current && $sub_status_different) {
                //Handle invalid current status
                //ex 1: when trying to move from "ready" to "production", but current status is not "ready"
                //ex 2: when trying to move from "production" to "finish", but current status is not "production"
                $oiErrorStatus = oiErrorStatus($item['status']);
                if ($oiErrorStatus == 'MOVEDTODEPOT') {
                    $result['status'] = 'UPDATED';
                } else {
                    $result['status'] = 'BADSTATUS';
                    $result['result_msg'] = $oiErrorStatus;
                }
function getOrderDetail($barcode = '', $idcode_ret = '')
{
    //die("$barcode | $idcode_ret");
    $result = array();
    $result['status'] = 'MCORDERNOTFOUND';
    use_class('jng_sp');
    use_class('jng_sp_orders');
    if ($barcode != '') {
        list($type, $order_product_id) = split('-', strtoupper($barcode));
        //GET order_id
        $order_id = '';
        if ($type == 'SP' || $type == 'JR') {
            $status = 'MCSCANPRODUCT';
            use_class('jng_sp_customers');
            $class_sp = new jng_sp();
            $class_jo = new jng_sp_orders();
            $class_jc = new jng_sp_customers();
            $item = $class_jo->retrieveItemDetail($order_product_id);
            $order_id = $item['jng_sp_orders_id'];
            $order = $class_jo->retrieveDetail($order_id);
            if (count($order) > 0) {
                $sp = $class_sp->retrieveDetail($order['jng_sp_id']);
                $customer = $class_jc->retrieveDetail(null, $order['jng_sp_id'], $order['customer_billing_id']);
                $customer_name = $order['customer_billing_firstname'] . ' ' . $order['customer_billing_lastname'];
                $customers_street_address = $order['customer_billing_address'] . ' ' . $order['customer_billing_address2'];
                $order_type = $sp['name'] . ' Order ' . $order['order_id'];
                $result = setOrderResult($status, 'S', $order_id, $order_type, $customer['jng_sp_customers_id'], $customer_name, $order['customer_billing_email'], $order['customer_billing_phone'], $customers_street_address, $order['customer_billing_postcode'], $order['customer_billing_city'], $order['customer_billing_country']);
            }
        } elseif ($type == 'JG') {
            $status = 'MCSCANPRODUCT';
            use_class('orders');
            $class_o = new orders();
            $item = $class_o->retrieveProductDetail($order_product_id);
            $order_id = $item['orders_id'];
            $order = $class_o->retrieveDetail($order_id);
            if (count($order) > 0) {
                $order_type = 'J&G Order ' . $order['orders_no'];
                $result = setOrderResult($status, 'J', $order_id, $order_type, $order['customers_id'], $order['customers_name'], $order['customers_email_address'], $order['customers_telephone'], $order['customers_street_address'], $order['customers_postcode'], $order['customers_city'], $order['customers_country']);
            }
        }
    } elseif ($idcode_ret != '') {
        //1 idcode_ret utk 1 order
        $qsp = "SELECT j.name AS sp_name, jo.* FROM jng_sp_orders jo INNER JOIN jng_sp j ON j.jng_sp_id = jo.jng_sp_id";
        $qsp .= " WHERE idcode_ret = '{$idcode_ret}' ORDER BY jo.order_date DESC LIMIT 1";
        $rsp = tep_db_query($qsp);
        $dsp = tep_db_num_rows($rsp) > 0 ? tep_db_fetch_array($rsp) : null;
        if (is_null($dsp)) {
            /* 12.05.2015: 
             * If not found, try to search using order number.
             * So far at this time, returns from LZ.ID, ZR.ID, ZR.BR used order number barcode
             */
            $qsp = "SELECT j.name AS sp_name, jo.* FROM jng_sp_orders jo INNER JOIN jng_sp j ON j.jng_sp_id = jo.jng_sp_id";
            $qsp .= " WHERE jo.order_id = '{$idcode_ret}' ORDER BY jo.order_date DESC LIMIT 1";
            $rsp = tep_db_query($qsp);
            $dsp = tep_db_num_rows($rsp) > 0 ? tep_db_fetch_array($rsp) : null;
        }
        $qjg = "SELECT * FROM orders WHERE idcode_ret='{$idcode_ret}' ORDER BY date_purchased DESC  LIMIT 1";
        $rjg = tep_db_query($qjg);
        $djg = tep_db_num_rows($rjg) > 0 ? tep_db_fetch_array($rjg) : null;
        if (!is_null($dsp) || !is_null($djg)) {
            $status = 'MCSCANPRODUCT';
            if (!is_null($dsp) && !is_null($djg)) {
                $dsp_time = strtotime($dsp['order_date']);
                $djg_time = strtotime($djg['date_purchased']);
                $use_data = $dsp_time >= $djg_time ? 'sp' : 'jg';
            } else {
                $use_data = !is_null($dsp) ? 'sp' : 'jg';
            }
            if ($use_data == 'sp') {
                $order_id = $dsp['jng_sp_orders_id'];
                use_class('jng_sp_customers');
                $class_jc = new jng_sp_customers();
                $customer = $class_jc->retrieveDetail(null, $dsp['jng_sp_id'], $dsp['customer_billing_id']);
                $customer_name = $dsp['customer_billing_firstname'] . ' ' . $dsp['customer_billing_lastname'];
                $customers_street_address = $dsp['customer_billing_address'] . ' ' . $dsp['customer_billing_address2'];
                $order_type = $dsp['sp_name'] . ' Order ' . $dsp['order_id'];
                $result = setOrderResult($status, 'S', $order_id, $order_type, $customer['jng_sp_customers_id'], $customer_name, $dsp['customer_billing_email'], $dsp['customer_billing_phone'], $customers_street_address, $dsp['customer_billing_postcode'], $dsp['customer_billing_city'], $dsp['customer_billing_country']);
            } else {
                $order_id = $djg['orders_id'];
                $order_type = 'J&G Order ' . $djg['orders_no'];
                $result = setOrderResult($status, 'J', $order_id, $order_type, $djg['customers_id'], $djg['customers_name'], $djg['customers_email_address'], $djg['customers_telephone'], $djg['customers_street_address'], $djg['customers_postcode'], $djg['customers_city'], $djg['customers_country']);
            }
        }
    }
    return $result;
}
Beispiel #3
0
 $ok_print = false;
 if ($type == 'SP' || $type == 'JG') {
     /*Disabled this, since all orders that goes to ready will directly printed
       //ignore printing pdf for this order if there item that still on cancel request. 
       $ok_print = (!orderItemHaveStatus($oid, 10, $type));
        */
     $ok_print = true;
 } elseif ($type == 'DP') {
     use_class('depot_orders');
     $class_do = new depot_orders();
     $do = $class_do->retrieveDetail($oid);
     if ($do['trans_type'] == 'SP') {
         use_class('jng_sp_orders');
         $class_jo = new jng_sp_orders();
         $oiid = $do['trans_id'];
         $i = $class_jo->retrieveItemDetail($oiid);
         $oid = $i['jng_sp_orders_id'];
         $o = $class_jo->retrieveDetail($oid);
         $sp_id = "{$o['jng_sp_id']}";
     } elseif ($do['trans_type'] == 'JG') {
         $sp_id = '0';
     }
     $is_prioritized = $do['trans_type'] == 'AR' && $do['trans_id'] == depot_orders::AUTO_REFILL_ID_ZALANDO || $is_prioritized || in_array($sp_id, $sp_using_red_paper);
     $ok_print = true;
 }
 if ($ok_print) {
     if ($is_prioritized && !(isset($queue_r[$pid]) && in_array($key, $queue_r[$pid]))) {
         $queue_r[$pid][] = $key;
     } else {
         $queue_w[$pid][] = $key;
     }
    }
} elseif (isset($_GET['opid']) && $_GET['opid'] != '') {
    if ($method == '') {
        use_class('jng_sp_orders');
        use_class('orders');
        use_class('depot_orders');
        use_class('production_instruction_pdf');
        $class_pi = new production_instruction_pdf();
        $opids = explode(',', $_GET['opid']);
        foreach ($opids as $opid) {
            $type = strtoupper($type);
            $orders = array();
            $orders_id = '';
            if ($type == 'SP') {
                $class_jo = new jng_sp_orders();
                $orders = $class_jo->retrieveItemDetail($opid);
                $orders_id = $orders['jng_sp_orders_id'];
            } elseif ($type == 'JG') {
                $class_o = new orders();
                $orders = $class_o->retrieveProductDetail($opid);
                $orders_id = $orders['orders_id'];
            } elseif ($type == 'DP') {
                $class_do = new depot_orders();
                $orders_id = $opid;
            }
            $class_pi->addOrder($type, $orders_id);
        }
        $class_pi->createPDF(false, $output_type);
    } else {
        use_class('production_instruction');
        $class_pi = new production_instruction();
Beispiel #5
0
 $id_raw = strtoupper(tep_db_prepare_input($_POST['id']));
 $id_split = explode('-', $id_raw);
 $result = '<div id="package-tip-header">' . $id_raw . '</div>';
 //Validate barcode
 if (count($id_split) == 1) {
     //Barcode in unknown format
     $errinfo = 'Barcode must have prefix: <strong>"JG-"</strong>, <strong>"SP-"</strong> or <strong>"DP-"</strong><br />';
     //$errinfo .= 'Please switch to <strong>Sales Partner</strong> or <strong>Julie &amp; Grace</strong> for no prefix barcode';
     $result .= printPackageTip('E', $box_date, $errinfo);
 } else {
     //Barcode valid
     //Set type and id for the process
     $type = $id_split[0];
     $id = $id_split[1];
     if ($type == 'SP') {
         $item = $class_jo->retrieveItemDetail($id);
     } elseif ($type == 'JG') {
         $item = $class_o->retrieveProductDetail($id);
     }
     //Check if order is already transfered as depot order
     //and make sure the transfered order is not canceled
     $item_do = $class_do->retrieveDetailTransmigran($type, $id);
     if (!is_null($item_do) && !statusIsCancelled($item_do['status'])) {
         //if yes, handle order as depot
         $type = 'DP';
         $id = $item_do['depot_orders_id'];
     } else {
         //if no, check if need to transfer it as depot order
         $status_create_do = array('8', '9', '10', '11', '12', '20');
         if (in_array($item['status'], $status_create_do)) {
             //yes, we need to transfer it
 function retrieveData($barcode_type, $barcode_id)
 {
     use_class('jng_sp');
     use_class('orders');
     use_class('jng_sp_orders');
     use_class('depot_orders');
     use_class('products_ean');
     use_class('products_minierp');
     $class_sp = new jng_sp();
     $class_orders = new orders();
     $class_jo = new jng_sp_orders();
     $class_do = new depot_orders();
     $class_pean = new products_ean();
     $class_pm = new products_minierp();
     $result = '';
     //list($partner_type,$order_product_id) = split("-",$barcode_id);
     //$partner_type = strtolower($partner_type);
     $tmp_bcid = explode('-', $barcode_id);
     $partner_type = strtolower($tmp_bcid[0]);
     $order_product_id = $tmp_bcid[1];
     if (is_numeric($partner_type)) {
         $order_product_id = $partner_type;
         $partner_type = 'sp';
     }
     //all id without prefix JG or SP indicates as SP
     if (!empty($order_product_id) && $order_product_id != '') {
         $partners_need_ean13 = array('3');
         #switch partner prefix
         switch ($partner_type) {
             case 'jg':
                 $products = $class_orders->retrieveProductDetail($order_product_id);
                 #header("Content-Type: text/plain; charset=utf-8");
                 switch ($barcode_type) {
                     case 'code39':
                         if (count($products) > 0) {
                             #table orders,products,dll.
                             $order_id = $products["orders_id"];
                             $article_number = $products["products_model"];
                             $order_item_count = $products["order_item_count"];
                             $order_item_total = $products["order_item_total"];
                             $order_qty = $products["products_quantity"];
                             #table orders
                             $orders = $class_orders->retrieveDetail($order_id);
                             $order_no = $orders["orders_no"];
                             $order_date = strtotime($orders["date_purchased"]);
                             $day = date("d", $order_date);
                             $month = date("M", $order_date);
                             $daily_count = $orders["daily_count"];
                             #format return label >> date;number;orderseq;nametag;kunde;auftragsnr;lieferscheinnr;qty;artikel
                             $label_date = $day . ". " . $month;
                             $label_order_seq = $order_item_count . "/" . $order_item_total;
                             $label_cust_name = $orders["delivery_name"];
                             $qcountry = "SELECT countries_iso_code_2 FROM countries WHERE countries_name = '{$orders['delivery_country']}'";
                             $dbqcountry = tep_db_query($qcountry);
                             $rescountry = tep_db_fetch_array($dbqcountry);
                             $label_suffix = $rescountry['countries_iso_code_2'] != '' ? ".{$rescountry['countries_iso_code_2']}" : "";
                             $label_numtag = "JG" . $label_suffix;
                             $label_auftragsnr = $order_no == '' ? "-" : $order_no;
                             $label_lieferscheinnr = '';
                             $return_label = $label_date . ";" . $daily_count . ";" . $label_order_seq . ";" . $label_numtag . ";" . $label_cust_name;
                             $return_label .= ";" . $label_auftragsnr . ";" . $label_lieferscheinnr . ";" . $order_qty . ";" . $article_number . ";" . $order_product_id . ";" . $partner_type;
                             $result = $return_label;
                         } else {
                             $result = "no data";
                         }
                         break;
                     case 'ean13':
                         if (count($products) > 0) {
                             $result = $this->getEANReturnResult($partner_type, $products);
                         } else {
                             $result = "no data";
                         }
                         break;
                 }
                 break;
             case 'sp':
                 $oi = $class_jo->retrieveItemDetail($order_product_id);
                 $order_id = $oi["jng_sp_orders_id"];
                 $o = $class_jo->retrieveDetail($order_id);
                 $sp_id = $o["jng_sp_id"];
                 #header("Content-Type: text/plain; charset=utf-8");
                 switch ($barcode_type) {
                     case 'code39':
                         if (count($oi) > 0) {
                             #table jng_sp_orders_items
                             //                            $order_qty = $oi["order_quantity"] * 1;
                             $article_number = $oi["article_number"];
                             $order_item_count = $oi["order_item_count"];
                             $order_item_total = $oi["order_item_total"];
                             $order_qty = intval($oi["order_quantity"]);
                             #table jng_sp_orders
                             $order_no = $o["order_id"];
                             $class_ordersrder_date = strtotime($o["order_date"]);
                             $day = date("d", $class_ordersrder_date);
                             $month = date("M", $class_ordersrder_date);
                             $daily_count = $o["daily_count"];
                             $shipment_id = $o["shipment_id"];
                             $cust_fname = $o["customer_shipping_firstname"];
                             $cust_lname = $o["customer_shipping_lastname"];
                             #table jng_sp
                             $jngsp = $class_sp->retrieveDetail($sp_id);
                             $prefix_num = $jngsp["package_prefix"];
                             #format return label >> date;number;orderseq;nametag;kunde;auftragsnr;lieferscheinnr;qty;artikel
                             $label_date = $day . ". " . $month;
                             $label_order_seq = $order_item_count . "/" . $order_item_total;
                             $label_cust_name = $cust_fname . " " . $cust_lname;
                             $label_numtag = $prefix_num == '' ? "-" : $prefix_num;
                             $label_auftragsnr = $order_no == '' ? "-" : $order_no;
                             $label_lieferscheinnr = $shipment_id;
                             $return_label = $label_date . ";" . $daily_count . ";" . $label_order_seq . ";" . $label_numtag . ";" . $label_cust_name;
                             $return_label .= ";" . $label_auftragsnr . ";" . $label_lieferscheinnr . ";" . $order_qty . ";" . $article_number . ";" . $order_product_id . ";" . $partner_type;
                             if (in_array($sp_id, $partners_need_ean13)) {
                                 if (count($oi) > 0) {
                                     $cats = $class_jo->getCategories($order_id);
                                     $oi_product_id = $oi["products_id"];
                                     $oi_product_article_id = $oi["products_articles_id"];
                                     $ean = $oi_product_article_id != '' ? $class_pean->getEAN($oi_product_id, $oi_product_article_id) : $class_pean->getEAN($oi_product_id);
                                     if ($ean != '') {
                                         $label_material = "925er SILBER";
                                         $return_label .= ";" . $ean . ";" . strtoupper($cats['categories_name']) . ";" . $label_material . ";" . $oi['price'] . " EUR;{$order_qty};{$o['jng_sp_id']}";
                                     }
                                 }
                             }
                             $result = $return_label;
                         } else {
                             $result = "no data";
                         }
                         break;
                     case 'ean13':
                         if (count($oi) > 0) {
                             $result = $this->getEANReturnResult($partner_type, $oi, $sp_id);
                         } else {
                             $result = "no data";
                         }
                         break;
                 }
                 break;
             case 'dp':
                 //ONLY PRODUCT LABEL / ean13
                 $do = $class_do->retrieveDetail($order_product_id);
                 switch ($barcode_type) {
                     case 'code39':
                         $article_number = $do["products_ean"];
                         $order_item_count = '1';
                         $order_item_total = '1';
                         $order_qty = intval($do["quantity"]);
                         $daily_count = $order_qty . 'x';
                         #format return label >> date;number;orderseq;nametag;kunde;auftragsnr;lieferscheinnr;qty;artikel
                         $label_date = "Quantity: ";
                         $label_order_seq = "{$order_item_count}/{$order_item_total}";
                         $label_cust_name = 'Outsourcing';
                         $label_numtag = '-';
                         $label_auftragsnr = '-';
                         $label_lieferscheinnr = '-';
                         $return_label = $label_date . ";" . $daily_count . ";" . $label_order_seq . ";" . $label_numtag . ";" . $label_cust_name;
                         $return_label .= ";" . $label_auftragsnr . ";" . $label_lieferscheinnr . ";" . $order_qty . ";" . $article_number . ";" . $order_product_id . ";" . $partner_type;
                         $result = $return_label;
                         break;
                     case 'ean13':
                     default:
                         if (count($do) > 0) {
                             $do['products_articles_id'] = $do['articles_id'];
                             $result = $this->getEANReturnResult($partner_type, $do);
                         } else {
                             $result = "no data";
                         }
                 }
                 break;
         }
     } else {
         $result = "no data";
     }
     return $result;
 }
Beispiel #7
0
 function createReturnContainerSP($return_id, $return_qty, $joi_id)
 {
     use_class('Order');
     use_class('jng_sp_orders');
     use_class('jng_sp_customers');
     use_class('payone_invoice');
     $class_jcust = new jng_sp_customers();
     $class_jo = new jng_sp_orders();
     $item = $class_jo->retrieveItemDetail($joi_id);
     $oid = $item['jng_sp_orders_id'];
     $order_obj = new Order(Order::ORDER_TYPE_SALES_PARTNER, $oid);
     $order = $class_jo->retrieveDetail($oid);
     if ($order_obj->isPaymentHandledByPayone()) {
         $invoice = new payone_invoice('invoice_order_type', 'S', "invoice_order_id={$oid}");
         //ONLY QUEING JUST FOR TRANSACTION THAT HAVE payone_txid (FIRST GET FROM SUBMITTING INVOICE)
         if ($invoice->detail['payone_txid'] != '') {
             $payone_txid = $invoice->detail['payone_txid'];
             $payment_method = $order_obj->getPaymentMethodRaw();
             $customer = $class_jcust->retrieveDetail(null, $order_obj->sales_partner_id, $order_obj->customer_id);
             $customer_bankdata = $class_jcust->getBankAccountData($customer['jng_sp_customers_id']);
             $data_por = array();
             $data_por['return_id'] = $return_id;
             $data_por['jng_sp_orders_items_id'] = $joi_id;
             $data_por['jng_sp_customers_id'] = $customer['jng_sp_customers_id'];
             $data_por['amount'] = round($return_qty * ($item['price'] * 100));
             $data_por['txid'] = $payone_txid;
             $data_por['invoice_id'] = $invoice->detail['invoice_id'];
             $data_por['invoice_no'] = $invoice->detail['invoice_no'];
             $data_por['id'] = $item['article_number'];
             $data_por['pr'] = round($item['price'] * 100);
             $data_por['no'] = $return_qty;
             $data_por['de'] = strlen($item['billing_text']) > 32 ? substr($item['billing_text'], 0, 32) : $item['billing_text'];
             $data_por['va'] = 0;
             $data_por['payment_method'] = $payment_method;
             $data_por['currency'] = 'EUR';
             if (!is_null($customer_bankdata)) {
                 $data_por['bankcode'] = $customer_bankdata['bank_code'];
                 $data_por['bankcountry'] = $customer_bankdata['bank_country'];
                 $data_por['bankaccount'] = $customer_bankdata['bank_account_number'];
                 $data_por['bankaccountholder'] = $customer_bankdata['bank_account_holder'];
             }
             $this->payoneReturnItemContainer($data_por);
             $items_total = $order_obj->getTotalItemsNotCanceledQuantity();
             $returns_total = $order_obj->getTotalItemsReturnedQuantity();
             if ($items_total == $returns_total) {
                 $amount_paid = $invoice->detail['invoice_amount_paid'];
                 $shipping_cost = $order_obj->getCostShipping();
                 $cod_cost = $order_obj->getCostCOD();
                 $total_costs = $shipping_cost + $cod_cost;
                 if ($shipping_cost > 0) {
                     //if((($amount_paid*1)==0)||(($amount_paid<>$shipping_cost)&&($amount_paid<>$total_costs))){
                     if ($amount_paid * 1 == 0 || $amount_paid > $total_costs) {
                         //HANDLE DOUBLE OR MORE SHIPING RETURN CONTAINER
                         $q_check = "SELECT * FROM payone_orders_return WHERE txid = '{$payone_txid}' AND id = 'Shipping'";
                         $dbc = tep_db_query($q_check);
                         if (tep_db_num_rows($dbc) == 0) {
                             $amount = round($shipping_cost * 100);
                             $data_por = array();
                             $data_por['return_id'] = 0;
                             $data_por['jng_sp_orders_items_id'] = 0;
                             $data_por['jng_sp_customers_id'] = $customer['jng_sp_customers_id'];
                             $data_por['amount'] = $amount;
                             $data_por['txid'] = $payone_txid;
                             $data_por['invoice_id'] = $invoice->detail['invoice_id'];
                             $data_por['invoice_no'] = $invoice->detail['invoice_no'];
                             $data_por['id'] = 'Shipping';
                             $data_por['pr'] = $amount;
                             $data_por['no'] = 1;
                             $data_por['de'] = 'Verpackung & Versand';
                             $data_por['va'] = 0;
                             $data_por['payment_method'] = $payment_method;
                             $data_por['currency'] = 'EUR';
                             $this->payoneReturnItemContainer($data_por);
                         }
                     }
                 }
                 if ($cod_cost > 0) {
                     //if((($amount_paid==0*1))||(($amount_paid<>$cod_cost)&&($amount_paid<>$total_costs))){
                     if ($amount_paid * 1 == 0 || $amount_paid > $total_costs) {
                         $amount = round($cod_cost * 100);
                         $data_por = array();
                         $data_por['return_id'] = 0;
                         $data_por['jng_sp_orders_items_id'] = 0;
                         $data_por['jng_sp_customers_id'] = $customer['jng_sp_customers_id'];
                         $data_por['amount'] = $amount;
                         $data_por['txid'] = $payone_txid;
                         $data_por['invoice_id'] = $invoice->detail['invoice_id'];
                         $data_por['invoice_no'] = $invoice->detail['invoice_no'];
                         $data_por['id'] = 'COD';
                         $data_por['pr'] = $amount;
                         $data_por['no'] = 1;
                         $data_por['de'] = 'Nachnahmegebühren';
                         $data_por['va'] = 0;
                         $data_por['payment_method'] = $payment_method;
                         $data_por['currency'] = 'EUR';
                         $this->payoneReturnItemContainer($data_por);
                     }
                 }
             }
         } else {
             //ORDER NOT SUBMITTED YET TO PAYONE, SO NO TXID CREATED YET. JUST NEED TO EXCLUDE ITEM FROM payone_invoice TABLE COLUMN 'invoice_order_items_id'
             $oids_arr = explode(',', $invoice->detail['invoice_order_items_id']);
             if (is_array($oids_arr)) {
                 $new_amount = $invoice->detail['invoice_amount'] - $return_qty * $item['price'];
                 foreach ($oids_arr as $key => $value) {
                     if ($value == $joi_id) {
                         unset($oids_arr[$key]);
                     }
                 }
                 $oids = implode(',', $oids_arr);
                 if (count($oids_arr) == 0) {
                     //ALL PRODUCTS RETURNED
                     $new_amount = 0;
                     $invoice->updateCompleteStatus('3');
                     //INVOICE CANCELLED
                 }
                 tep_db_perform('payone_invoice', array('invoice_amount' => $new_amount, 'invoice_order_items_id' => $oids), 'update', "invoice_id = '" . $invoice->detail['invoice_id'] . "'");
             }
         }
     }
 }
exit;
global $db;
require_once '../confy.php';
require_once '../functions.php';
require_once '../functions-2.php';
require_once DIR_WS_FUNCTIONS . 'html_output.php';
tep_db_connect();
use_class('jng_sp');
use_class('jng_sp_orders');
use_class('payone_invoice');
$class_sp = new jng_sp();
$class_jo = new jng_sp_orders();
$class_pi = new payone_invoice();
$items_id_returned = array('28801', '28806');
foreach ($items_id_returned as $items_id) {
    $o_oi = $class_jo->retrieveItemDetail($items_id);
    $o_ri_arr = $class_jo->retrieveReturnItem($items_id);
    $o_ri = $o_ri_arr[0];
    $class_pi->retrieveDetail("S", $o_oi['jng_sp_orders_id']);
    //ONLY QUEING JUST FOR TRANSACTION THAT HAVE payone_txid (FIRST GET FROM SUBMITTING INVOICE)
    if ($class_pi->detail['payone_txid'] != '') {
        $data_por = array();
        $data_por['return_id'] = $o_ri['return_id'];
        $data_por['invoice_id'] = $o_oi['jng_sp_orders_id'];
        $data_por['jng_sp_orders_items_id'] = $items_id;
        $data_por['id'] = $o_oi['article_number'];
        $data_por['pr'] = intval($o_oi['price'] * 100);
        $data_por['no'] = $o_ri['return_quantity'];
        $data_por['de'] = $o_oi['billing_text'];
        $data_por['va'] = 0;
        $data_por['amount'] = $data_por['pr'] * $data_por['no'];
$pdf->Cell(40, $line_height, 'RETURNS Invoice');
$xpos += 40;
$pdf->SetXY($xpos, $ypos);
$pdf->Cell(70, $line_height, 'R.-Nr: ' . $package['package_code']);
//CONTENTS
$pdf->setFont('Arial', '', '10');
$contents = array();
$page_counter = 1;
$row_counter = 0;
$n_items = count($items_array);
foreach ($items_array as $item_id) {
    $row_counter++;
    if (!isset($contents[$page_counter])) {
        $contents[$page_counter] = array();
    }
    $contents[$page_counter][] = $class_jo->retrieveItemDetail($item_id);
    $rule1 = $page_counter == 1 && $row_counter == $firstpagecount;
    $rule2 = $page_counter > 1 && $row_counter == $nextpagecount;
    if ($rule1 || $rule2) {
        if ($n_items > $row_counter) {
            $row_counter = 0;
            $page_counter++;
        }
    }
}
$ypos += 10;
$columns = array();
$columns['nos'] = 'No';
$columns['desc'] = 'Description of Rejected Items';
$columns['code'] = 'Artikel No';
$columns['value'] = 'Value in USD';
             $label_lieferscheinnr = '';
             $return_label = $label_date . ";" . $daily_count . ";" . $label_order_seq . ";" . $label_numtag . ";" . $label_cust_name;
             $return_label .= ";" . $label_auftragsnr . ";" . $label_lieferscheinnr . ";" . $order_qty . ";" . $article_number;
             echo $return_label;
             break;
         case 'ean13':
             if (count($products) > 0) {
                 echo getEANReturnResult($partnertype, $products);
             } else {
                 echo "no data";
             }
             break;
     }
     break;
 case 'sp':
     $oi = $class_jo->retrieveItemDetail($reqid);
     $oi_o_id = $oi["jng_sp_orders_id"];
     $o = $class_jo->retrieveDetail($oi_o_id);
     #header("Content-Type: text/plain; charset=utf-8");
     switch ($barcodetype) {
         case 'code39':
             $class_sp = new jng_sp();
             #table jng_sp_orders_items
             $oi_order_qty = $oi["order_quantity"] * 1;
             $oi_article_number = $oi["article_number"];
             $oi_order_item_count = $oi["order_item_count"];
             $oi_order_item_total = $oi["order_item_total"];
             #table jng_sp_orders
             $class_ordersrder_no = $o["order_id"];
             $class_ordersrder_date = strtotime($o["order_date"]);
             $day = date("d", $class_ordersrder_date);
Beispiel #11
0
    } elseif ($status_tab == '4') {
        if (in_array($item_status, $status_depos)) {
            $result = "<strong>SP-{$items_id}</strong> is moved to HH<br /><strong class='red'>REMOVE PI and PUT PRODUCT TO DEPO BOX</strong>";
        }
    }
    if (is_null($result)) {
        $result = "<strong>SP-{$items_id}</strong> Status is now <strong>" . statusName($item_status) . '</strong>';
    }
    return $result;
}
//SUBMIT ACTION
if (isset($_POST['me_action'])) {
    if ($_POST['me_action'] == 'CHECKOISTATUS') {
        $items_id = tep_db_prepare_input($_POST['oi_id']);
        $status_tab = tep_db_prepare_input($_POST['status_tab']);
        $item = $class_jo->retrieveItemDetail($items_id);
        if (count($item) == 0) {
            $result = "<br /><strong>SP-{$items_id}</strong> is not found";
        } else {
            $result = '<br />' . oiErrorStatus($items_id, $item['status'], $status_tab);
        }
        echo utf8_encode($result);
        exit;
    } elseif ($_POST['me_action'] == 'UPDATEOISTATUS') {
        $items_id = tep_db_prepare_input($_POST['oi_id']);
        $old_status = tep_db_prepare_input($_POST['old_status']);
        $new_status = tep_db_prepare_input($_POST['new_status']);
        $item = $class_jo->retrieveItemDetail($items_id);
        if ($item['status'] == $old_status) {
            $status_to_alert_success = array('3', '4');
            if ($new_status == '10') {
 function updateStatus($items_id, $new_status, $updater = '', $add_to_prod_target = true)
 {
     use_class('production_target');
     $pt = new production_target();
     list($new_status, $sub_status) = explode('-', $new_status);
     $item = $this->retrieveDetail($items_id);
     $is_outsourced = $this->isOutsourceOrder($item['trans_type'], $item['trans_id']);
     $timestamp = date('Y-m-d H:i:s');
     $sub_status = trim(strtoupper($sub_status));
     if ($new_status == '10') {
         $this->doCancelOrders($items_id, $item['status'], $updater);
     } else {
         if ($add_to_prod_target) {
             if (!$is_outsourced) {
                 //outsourcing orders should never affect the Finish KPI Graphs
                 if ($new_status == '5') {
                     $pt->addDataToField($timestamp, 'finish', $item['quantity']);
                 }
             }
             if ($new_status == '6') {
                 $pt->addDataToField($timestamp, 'package', $item['quantity']);
             }
             if ($new_status == '7') {
                 $pt->addDataToField($timestamp, 'sent', $item['quantity']);
             }
         }
         if ($new_status == '4' && $sub_status != '') {
             $set_prod_status = ", prod_status = '" . $sub_status . "'";
         }
         //PS: please don't set empty prod_status when it updated to status > 4,...
         //...since this will used for check whether order could transferred to DP or not...
         //...when real order taken over by HH while order still on production
         tep_db_query("UPDATE depot_orders SET status='{$new_status}' {$set_prod_status} WHERE depot_orders_id={$items_id}");
         $save_main_status_history = true;
         //if ( ( in_array($item['status'], array('1','3','4','5')) && $new_status=='4' ) && ( $sub_status!='' && ( trim(strtoupper($item['prod_status'])) != $sub_status ) ) ) {
         /*
         $item['status'] = 1 is included here to also save prod. status history when there's real order cancelled/taken over by hh caused using depot hh stock
         while real order is already processed in production, finish, or in package. The first status created was 1.
         */
         //replace using below, allowing all process which set to production to have a chance saving the prod. status history
         if ($new_status == '4' && $sub_status != '' && trim(strtoupper($item['prod_status'])) != $sub_status) {
             $psh = array();
             $psh['orders_items_id'] = $items_id;
             $psh['type'] = 'DP';
             $psh['status'] = $sub_status;
             $psh['status_quantity'] = $item['quantity'];
             $psh['status_date'] = $timestamp;
             $psh['update_by'] = $updater;
             saveProductionStatusHistory($psh);
             if ($item['status'] == '4') {
                 $save_main_status_history = false;
             }
         }
         if ($save_main_status_history) {
             $sda = array();
             $sda['depot_orders_id'] = $items_id;
             $sda['status'] = $new_status;
             $sda['update_time'] = $timestamp;
             $sda['update_by'] = $updater;
             tep_db_perform('depot_orders_status_history', $sda);
         }
         if (!$is_outsourced) {
             if ($new_status == '2' && $item['stock_status'] != 'S' && $item['stock_status'] != 'W') {
                 $this->updateStockStatus($items_id, false);
                 $this->prodStatusReset($items_id);
                 $this->eanPrintedReset($items_id);
                 //$this->printCountReset($items_id);    //now we don't need to reset print_count for reprint pi when move to ready again.
             } elseif ($new_status == '3' && $item['stock_status'] == 'S' || $new_status == '4' && $item['stock_status'] == 'W') {
                 $eu = $this->countElementsUsage($item['products_id'], $item['articles_id']);
                 if (count($eu) > 0) {
                     $jng_warehouses_id = '1';
                     use_class('elements_stock');
                     $class_es = new elements_stock();
                     foreach ($eu as $elements_id => $euqty) {
                         $reduce_amount = $item['quantity'] * $euqty;
                         $class_es->reduceStockByPieces($jng_warehouses_id, $elements_id, $reduce_amount, 'RED DP-' . $items_id);
                     }
                 }
                 $this->updateStockStatus($items_id, 'R');
             }
         }
     }
     switch ($item['trans_type']) {
         case 'SP':
             use_class('jng_sp_orders');
             $class_jo = new jng_sp_orders();
             $item_sp = $class_jo->retrieveItemDetail($item['trans_id']);
             if ($item['status'] == '1' && ($new_status == '2' || $new_status == '3')) {
                 $class_jo->productionTargetIn($timestamp, $item_sp);
             } elseif ($new_status == '6') {
                 $class_jo->productionTargetOut($timestamp, $item_sp);
             } elseif ($new_status == '12') {
                 $class_jo->productionTargetInReset($item_sp);
             }
             break;
         case 'JG':
             use_class('orders');
             $class_o = new orders();
             $item_jg = $class_o->retrieveProductDetail($item['trans_id']);
             if ($item['status'] == '1' && ($new_status == '2' || $new_status == '3')) {
                 $class_o->productionTargetIn($timestamp, $item_jg);
             } elseif ($new_status == '6') {
                 $class_o->productionTargetOut($timestamp, $item_jg);
             } elseif ($new_status == '12') {
                 $class_o->productionTargetInReset($item_jg);
             }
             break;
         default:
             if ($item['status'] == '1' && ($new_status == '2' || $new_status == '3')) {
                 $this->productionTargetIn($timestamp, $item);
             } elseif ($new_status == '6') {
                 $this->productionTargetOut($timestamp, $item);
             } elseif ($new_status == '12') {
                 $this->productionTargetInReset($item);
             }
     }
     if ($new_status == '3' && !$is_outsourced) {
         //use_class('production_instruction_pdf');
         //$class_pi = new production_instruction_pdf();
         if ($item['print_count'] > 0 && $item['print_confirmed'] > 0) {
             //SECOND OR MORE PI PRINTED, could happen when there product by stock_status is "OK" but in real stock is "0" so this will set back to "NS". And when ready this will reprinted by using this block
             $this->printConfirmReset($items_id);
             $this->printCountReset($items_id);
         }
         /*
         $class_pi->addOrder('DP', $items_id);
         $add_to_daily_statistic = $item['print_count']==0 ? true : false;
         $class_pi->createPDF(false, 'F', $add_to_daily_statistic);
         */
     }
     return $new_status;
 }
    $o['print_label'] = in_array($sp_id, $SP_DOESNT_NEED_EASYLOG) ? '0' : '1';
    $o['reference'] = $reference;
    $o['counter'] = $display_counter;
    $o['shipping_name'] = $name;
    $o['shipping_address'] = $address;
    $o['shipping_city'] = $city;
    $o['shipping_postcode'] = $postcode;
    $o['cod'] = $cod;
    return $o;
}
$result = array();
$result['status'] = 'NONE';
if ($order_type == 'SP') {
    use_class('jng_sp_orders');
    $class_jo = new jng_sp_orders();
    $i_temporary = $class_jo->retrieveItemDetail($item_id);
    if (isset($i_temporary['status']) && $i_temporary['status'] != $REQUIRED_STATUS) {
        $i_status = $class_jo->statusName();
        $result['status'] = 'BADSTATUS';
        $result['badstatus'] = $i_status[$i_temporary['status']];
    } else {
        $order_id = $i_temporary['jng_sp_orders_id'];
        $order = $class_jo->retrieveDetail($order_id);
        if (isset($order['jng_sp_orders_id'])) {
            $display_counter = dailyCounterNo($order['order_date'], $order['daily_count']);
            $shipping_name = $order['customer_shipping_firstname'] . ' ' . $order['customer_shipping_lastname'];
            $shipping_address = $order['customer_shipping_address'];
            $cod_value = 0;
            switch ($order['jng_sp_id']) {
                case '1':
                    //NM.DE
 $table = array();
 if ($total_orders > 0) {
     $t = array();
     $t['d'] = 'Date';
     $t['id1'] = 'Order ID';
     $t['id2'] = 'Order Source';
     $t['id3'] = 'Article No';
     $t['q'] = 'Price';
     $t['s'] = 'Qty';
     $table[] = $t;
     while ($row = tep_db_fetch_array($res)) {
         $type = '<span class="notice">Manual</span>';
         if ($row['trans_type'] == 'SP') {
             use_class('jng_sp_orders');
             $class_jo = new jng_sp_orders();
             $item_source = $class_jo->retrieveItemDetail($row['trans_id']);
             $type = '<a href="/?open=sp-order&amp;id=' . $item_source['jng_sp_orders_id'] . '&amp;oiid=' . $row['trans_id'] . '&amp;hidemenu=true" class="view_webpage">' . $row['trans_type'] . '-' . $row['trans_id'] . '</a>';
         } elseif ($row['trans_type'] == 'JG') {
             use_class('orders');
             $class_o = new orders();
             $item_source = $class_o->retrieveProductDetail($row['trans_id']);
             $type = '<a href="/?open=order&amp;id=' . $item_source['orders_id'] . '&amp;opid=' . $row['trans_id'] . '&amp;hidemenu=true" class="view_webpage">' . $row['trans_type'] . '-' . $row['trans_id'] . '</a>';
         }
         $t = array();
         $t['d'] = date('d-M-y', strtotime($row['order_date']));
         $t['id1'] = '<a href="?open=depot-order&amp;id=' . $row['depot_orders_id'] . '&amp;hidemenu=true" class="view_webpage">DP-' . $row['depot_orders_id'] . '</a>';
         $t['id2'] = $type;
         $length = textLength($row['article_length'] > 0 ? $row['article_length'] : $row['products_length'], false);
         $row['article_number'] = $row['products_model'] . ($length > 0 ? '_' . $length : '');
         $article = '<div><a href="?open=product-detail&amp;products_id=' . $row['products_id'] . '" target="_blank" title="View Product Detail">' . $row['article_number'] . '</a></div>';
         $pimg = webImageSource($row['products_image'], '500');
    $sda_return['return_reason'] = tep_db_prepare_input($_POST['return_reason']);
    $sda_return['return_quantity'] = tep_db_prepare_input($_POST['return_qty']);
    $sda_return['return_comment_customer'] = tep_db_prepare_input(utf8_decode($_POST['comment_c']));
    $sda_return['return_comment_jng'] = tep_db_prepare_input(utf8_decode($_POST['comment_j']));
    $sda_return['shipping_paid'] = tep_db_prepare_input($_POST['shipping_paid']);
    $class_jo->returnItemUpdate($return_id, $sda_return);
    echo '<div class="green">Return detail is successfully saved</div>';
    exit;
}
//START TEMPLATE
$return_id = isset($_GET['id']) ? tep_db_prepare_input($_GET['id']) : '';
if ($return_id == '') {
    exit;
}
$return = $class_jo->retrieveReturnDetail($return_id);
$item = $class_jo->retrieveItemDetail($return['jng_sp_orders_items_id']);
$order = $class_jo->retrieveDetail($item['jng_sp_orders_id']);
$pimg = webImageSource($item['products_image'], '500');
if ($pimg != '') {
    $pimg = webImage($item['products_image'], '120', '120', '', 'img-border img-padding');
}
$content .= '<div style="float:left;">' . $pimg . '</div>';
$content .= '<div style="margin-left:150px;">';
$content .= '<table border="0" cellpadding="0" cellspacing="0">';
$order_id = $order['order_id'] == '' ? 'J&G ID: ' . $order['jng_sp_orders_id'] : $order['order_id'];
if ($return['confirm_return'] == '1') {
    $return_reason = $class_jo->returnReasonText($return['return_reason']);
    $return_qty = $return['return_quantity'];
    $comment_c = nl2br($return['return_comment_customer']);
    $comment_j = nl2br($return['return_comment_jng']);
    $shipping_status = $return['shipping_paid'] == '1' ? 'Paid' : 'Unpaid';
             $label_date = $day . ". " . $month;
             $label_order_seq = $order_item_count . "/" . $order_item_total;
             $label_cust_name = $orders["delivery_name"];
             $label_numtag = "JG";
             $label_auftragsnr = $order_no == '' ? "-" : $order_no;
             $label_lieferscheinnr = '';
             $return_label = $label_date . ";" . $daily_count . ";" . $label_order_seq . ";" . $label_numtag . ";" . $label_cust_name;
             $return_label .= ";" . $label_auftragsnr . ";" . $label_lieferscheinnr . ";" . $order_qty . ";" . $article_number;
             echo $return_label;
             break;
     }
     break;
 case 'sp':
     use_class('jng_sp_orders');
     $o_jngspo = new jng_sp_orders();
     $oi = $o_jngspo->retrieveItemDetail($reqid);
     #header("Content-Type: text/plain; charset=utf-8");
     switch ($barcodetype) {
         case 'code39':
             use_class('jng_sp');
             $o_jngsp = new jng_sp();
             #table jng_sp_orders_items
             $oi_o_id = $oi["jng_sp_orders_id"];
             $oi_order_qty = $oi["order_qty"];
             $oi_article_number = $oi["article_number"];
             $oi_order_item_count = $oi["order_item_count"];
             $oi_order_item_total = $oi["order_item_total"];
             #table jng_sp_orders
             $o = $o_jngspo->retrieveDetail($oi_o_id);
             $o_order_no = $o["order_id"];
             $o_order_date = strtotime($o["order_date"]);
Beispiel #17
0
/**
 * Get vip status of customer from an order
 * @param String $type
 * @param Int $orders_id
 * @return Boolean
 */
function checkCustomerIsVIP($type, $orders_id)
{
    $type = strtoupper($type);
    $is_vip = false;
    if ($type == 'SP') {
        use_class('jng_sp_orders');
        use_class('jng_sp_customers');
        use_class('jng_sp_customers_special');
        $class_jo = new jng_sp_orders();
        $class_jc = new jng_sp_customers();
        $class_jcs = new jng_sp_customers_special();
        $o = $class_jo->retrieveDetail($orders_id);
        //GET CUSTOMER DETAIL VIP OR NOT
        $cust_data = $class_jc->retrieveDetail(null, $o['jng_sp_id'], $o['customer_billing_id']);
        if (is_array($cust_data) && $cust_data['jng_sp_customers_id'] > 0) {
            $cust_detail = $class_jcs->getCustomerDetail($cust_data['jng_sp_customers_id']);
        }
        $is_vip = $cust_detail['list_type'] == 'V';
    } elseif ($type == 'JG') {
        use_class('orders');
        use_class('customers_special_list');
        $class_o = new orders();
        $class_csl = new customers_special_list();
        $o = $class_o->retrieveDetail($orders_id);
        //GET CUSTOMER DETAIL VIP OR NOT
        $cust_detail = $class_csl->getCustomerDetail($o['customers_id']);
        $is_vip = $cust_detail['list_type'] == 'V';
    } elseif ($type == 'DP') {
        use_class('depot_orders');
        $class_do = new depot_orders();
        $do = $class_do->retrieveDetail($orders_id);
        if ($do['trans_type'] == 'SP' || $do['trans_type'] == 'JG') {
            if ($do['trans_type'] == 'SP') {
                use_class('jng_sp_orders');
                $class_jo = new jng_sp_orders();
                $it = $class_jo->retrieveItemDetail($do['trans_id']);
                $orders_id = $it['jng_sp_orders_id'];
            } elseif ($do['trans_type'] == 'JG') {
                use_class('orders');
                $class_o = new orders();
                $it = $class_o->retrieveProductDetail($do['trans_id']);
                $orders_id = $it['orders_id'];
            }
            $is_vip = checkCustomerIsVIP($do['trans_type'], $orders_id);
        }
    }
    return $is_vip;
}
Beispiel #18
0
$do_timestamp = strtotime($do['order_date']);
$product = $class_pm->retrieveDetail($do['products_id']);
$article = $do['articles_id'] == 0 ? null : $class_pa->retrieveDetail($do['articles_id']);
$length = $article == null ? $product['pnc']['products_length'] : $article['length'];
$length_text = $length == 0 ? '' : '<tr><td>Product Length</td><td>' . textLength($length) . '</td></tr>';
$group_name = $do['group_name'];
if (count($do) == 0) {
    $content .= '<h3 class="red">Depot Order ' . $order_id . ' is not found in Database';
} else {
    $statusName = statusNameShort();
    $bih_start_date = $do['order_date'];
    $bih_end_date = null;
    if ($do['trans_type'] == 'SP') {
        use_class('jng_sp_orders');
        $class_jo = new jng_sp_orders();
        $itrans = $class_jo->retrieveItemDetail($do['trans_id']);
        $otrans = $class_jo->retrieveDetail($itrans['jng_sp_orders_id']);
        $bih_start_date = $otrans['order_date'];
        $order_source = $class_do->translateOrderSource($do['trans_type'], $do['trans_id'], false, $itrans['jng_sp_orders_id'], $do['products_id']);
    } elseif ($do['trans_type'] == 'JG') {
        use_class('orders');
        $class_o = new orders();
        $itrans = $class_o->retrieveProductDetail($do['trans_id']);
        $otrans = $class_o->retrieveDetail($itrans['orders_id']);
        $bih_start_date = $otrans['date_purchased'];
        $order_source = $class_do->translateOrderSource($do['trans_type'], $do['trans_id'], false, $itrans['orders_id'], $do['products_id']);
    } else {
        $order_source = $class_do->translateOrderSource($do['trans_type'], $do['trans_id'], false, null, $do['products_id']);
    }
    $status_date = null;
    $history = $class_do->retrieveHistory($order_id);