Example #1
0
 function attactToArticle($articles_id)
 {
     //check if products already have EAN no
     $q = tep_db_query("SELECT products_ean" . " FROM products_articles" . " WHERE products_articles_id={$articles_id} AND products_ean=''");
     if (tep_db_num_rows($q) == 1) {
         $ean_no = $this->getFreeNo();
         if ($ean_no != '') {
             $q2 = tep_db_query("UPDATE products_articles" . " SET products_ean='{$ean_no}'" . " WHERE products_articles_id={$articles_id}" . " AND products_ean=''");
             if (tep_db_affected_rows() > 0) {
                 $this->setAsUsed($ean_no);
             }
         }
     } else {
         $r = tep_db_fetch_array($q);
         $ean_no = $r['products_ean'];
     }
     return $ean_no;
 }
$modules_query = tep_db_query("select distinct module from " . TABLE_ACTION_RECORDER . " order by module");
while ($modules = tep_db_fetch_array($modules_query)) {
    $modules_array[] = $modules['module'];
    $modules_list_array[] = array('id' => $modules['module'], 'text' => is_object(${$modules['module']}) ? ${$modules['module']}->title : $modules['module']);
}
$action = isset($HTTP_GET_VARS['action']) ? $HTTP_GET_VARS['action'] : '';
if (tep_not_null($action)) {
    switch ($action) {
        case 'expire':
            $expired_entries = 0;
            if (isset($HTTP_GET_VARS['module']) && in_array($HTTP_GET_VARS['module'], $modules_array)) {
                if (is_object(${$HTTP_GET_VARS['module']})) {
                    $expired_entries += ${$HTTP_GET_VARS['module']}->expireEntries();
                } else {
                    $delete_query = tep_db_query("delete from " . TABLE_ACTION_RECORDER . " where module = '" . tep_db_input($HTTP_GET_VARS['module']) . "'");
                    $expired_entries += tep_db_affected_rows();
                }
            } else {
                foreach ($modules_array as $module) {
                    if (is_object(${$module})) {
                        $expired_entries += ${$module}->expireEntries();
                    }
                }
            }
            $messageStack->add_session(sprintf(SUCCESS_EXPIRED_ENTRIES, $expired_entries), 'success');
            tep_redirect(tep_href_link('action_recorder.php'));
            break;
    }
}
require 'includes/template_top.php';
?>
tep_db_connect();
//ACTIVATE 500 PRODUCTS DAILY
$silver_dragon_excl = "15029,15030,15031,15032,15033,15034,15036,15037,15038,15039,15040,15041,15042,15044,15045,15046,15047,15049,15050,15051,15052,15054,15057,15058,15059,15060,15061,15062,15063,15064,15065,15066,15067,15068,15069,15070,15071,15072,15073,15074,15075,15076,15079,15080,15081,15082,15083,15084,15085,15086,15087,15088,15089,15090,15091,15092,15093,15094,15095,15096,15097,15099,15101,15102,15103,15104,15105,15106,15107,15108,15109,15110,15111,15112,15113,15114,15115,15116,15117,15118,15119,15120,15121,15122,15123,15124,15126,15127,15128,15129,15130,15131,15132,15133,15134,15135,15136,15137,15138,15139,15140,15141,15142,15143,15144,15145,15146,15147,15148,15149,15151,15152,15153,15154,15155,15156,15157,15158,15159,15160,15161,15162,15163,15164,15165,15167,15168,15169,15170,15171,15172,15173,15174,15175,15176,15177,15178,15179,15180,15181,15182,15183,15184,15185,15186,15188,15189,15190,15191,15192,15193,15194,15195,15196,15197,15198,15199,15200,15201,15202,15203,15204,15205,15206,15208,16031,16032,16036,16104,16521,16522,16523,16524,16525,16526,16527,16528,16529,16530,16531,16532,16533,16534,18090,18091,18092,18093,18094,18095,18096,18097,18098,18100,18101,18102,18103,18104,18105,18106,18107,18108,18109,18110,18111,18112,18113,18114,18115,18117,18118,18119,18120,18121,18122,18123,18126,18127,18129,18130,18131,18132,18133,18134,18135,18136,20934,20935,20936,20937,20938,20939,20940,20941,20942,20943,20944,20945,20946,20947,20948,20949,20950,20951,20952,20953,20954,20955,20956,20957,20958,20959,20960,20961,20962,20963,20964,20965,20966,20967,20968,20969,20970,20971,20973,20974,20975,20976,20977,20978,20979,20980,20981,20982,20983,20984,20985,20986,20987,20988,20989,20990,20991,20992,20993,20994,20995,20996,20997,20998,20999,21001,21002,21003,21004,21005,21006,21007,21008,21009,21010,21011,21012,21014,22275,22277,22278,22280,22287,22288,22289,22290,22371,22372,22373,22374,22376,22377,22378,22379,22380,22381,22382,22383,22384,22385,24430,24431,24432,24433,24639,24641,24642,24643,24644,24645,24646,24648,24649,24650,24651,24653,24655,24656,24805,24808,24810,24811,24842,24844,24845,24846,24847,24848,24849,24851,24852,24853,24854,24855,24923,24925,24926,24927,24928,24929,24930,24933,24934,24935,24936,24937,24940,24941,24942,24943,24949,24950,24951,24953,24955,24956,25006,25007,25008,25009,25011,25012,25013,25014,25015,25016,25017,25018,25019,25020,25021,25023,25024,25025,25026,25029,25030,25038,25040,25041,25043,25044,25045,25074,25075,25205,25207,25581,25582,25583,25584,25896,25898,25899,25900,25901,25902,25903,25904,25905,27286,27287,27289,27290,27291,27292,27293,27294,27295,27296,27297,27298,27300,27301,27498,27499,27500,27501,27502,27503,27505,27506,27507,27508,27509,27510,27511,27513,27514,27559,27560,27561,27562,27563,27564,27565,27566,27567,27568,27570,27571,27572,27573,27574,27575,27782,27783,27784,27788,29720,29721,29722,29723,29724,29725,29726,29727,29728,29729,29730,29731,29732,29733,29734,29735,29736,29738,30338,30339,30340,30341,30343,30344,30345,30346,30347,30348,30350,30351,30352,30353,30354,30356,30357,41827,41828,41829,41830,41831,41832,43122,43123,43130,43146,43147,44600,44601,44603,44604,44678,44680,44681,44682";
$q = "SELECT jc.products_id FROM jng_sp_catalog jc";
$q .= " INNER JOIN jng_sp_catalog jc2 ON jc2.jng_sp_id=3 AND jc2.products_id=jc.products_id AND jc2.active_status='0'";
$q .= " WHERE jc.jng_sp_id='1' AND jc.active_status='1'";
$q .= " AND jc.products_id NOT IN ({$silver_dragon_excl})";
$q .= " ORDER BY RAND() LIMIT 600";
$r = tep_db_query($q);
$products = array();
while ($row = tep_db_fetch_array($r)) {
    $products[] = $row['products_id'];
}
$products_add = implode(",", $products);
tep_db_query("UPDATE jng_sp_catalog SET active_status='1' WHERE jng_sp_id=3 AND products_id IN ({$products_add})");
$rep_added = tep_db_affected_rows();
echo '<h3>';
echo "{$rep_added} Product(s) is added";
echo '</h3>';
/*
//FIRST COPY QUERY
$navtrans = array();
$navtrans['137638545'] = '10050626';
$navtrans['38585657'] = '10050630';
$navtrans['38585657'] = '10050630';
$navtrans['87425097'] = '10050629';
$navtrans['87425097'] = '10050629';
$navtrans['38585658'] = '10050627';
$navtrans['38585658'] = '10050627';
$navtrans['38585658'] = '10050627';
$navtrans['137638559'] = '10050626';
// total products from both table
$num_total = $num_op + $num_jo;
if ($RUN_UPDATE_QUERY) {
    $logger->write("Running in UPDATE mode (orders will be updated for auto reprint)");
    if ($num_total == 0) {
        $logger->write("No orders found");
    } elseif ($num_total <= $max_total_orders_allowed) {
        // check if total count less than 10 product then reset query
        tep_db_query("UPDATE orders_products SET print_count=0 WHERE status=8 AND print_count>0");
        $total_reset_jg = tep_db_affected_rows();
        $logger->write("- TOTAL RESET JG = {$total_reset_jg} ");
        if ($total_reset_jg > 0) {
            $logger->write(implode(", ", $arr_op));
        }
        tep_db_query("UPDATE jng_sp_orders_items SET print_count=0 WHERE status=8 AND print_count>0");
        $total_reset_sp = tep_db_affected_rows();
        $logger->write("- TOTAL RESET SP = {$total_reset_sp} ");
        if ($total_reset_sp > 0) {
            $logger->write(implode(", ", $arr_jo));
        }
    } else {
        $logger->write("Update is skipped because total products found ({$num_total}) is above the allowed limit ({$max_total_orders_allowed})");
        //Notify IT Team
        $subject = 'IMPORTANT & URGENT:  Reprint Picklist is Skipped!';
        $send_message = "Reprint is running in UPDATE mode. However, triggering Picklist reprint is skipped because total products found ({$num_total}) is above the allowed limit ({$max_total_orders_allowed})";
        $send_message .= '<br /><br />Please check if it is caused by Easylog Upload issue or we really need to reprint them!';
        tep_mail(EMAIL_NAME_DEBUGR, EMAIL_ADDRESS_DEBUGR, $subject, $send_message, FROM_EMAIL_NAME, FROM_EMAIL_ADDRESS, false);
    }
} else {
    $logger->write("Running in MONITORING MODE (orders are not updated for reprint)");
    if ($num_total > 0) {
 function deleteCard($token, $token_id)
 {
     global $customer_id;
     if (MODULE_PAYMENT_SAGE_PAY_DIRECT_TRANSACTION_SERVER == 'Live') {
         $gateway_url = 'https://live.sagepay.com/gateway/service/removetoken.vsp';
     } else {
         $gateway_url = 'https://test.sagepay.com/gateway/service/removetoken.vsp';
     }
     $params = array('VPSProtocol' => $this->api_version, 'TxType' => 'REMOVETOKEN', 'Vendor' => substr(MODULE_PAYMENT_SAGE_PAY_DIRECT_VENDOR_LOGIN_NAME, 0, 15), 'Token' => $token);
     $post_string = '';
     foreach ($params as $key => $value) {
         $post_string .= $key . '=' . urlencode(trim($value)) . '&';
     }
     $response = $this->sendTransactionToGateway($gateway_url, $post_string);
     $string_array = explode(chr(10), $response);
     $sage_pay_response = array();
     foreach ($string_array as $string) {
         if (strpos($string, '=') != false) {
             $parts = explode('=', $string, 2);
             $sage_pay_response[trim($parts[0])] = trim($parts[1]);
         }
     }
     tep_db_query("delete from customers_sagepay_tokens where id = '" . (int) $token_id . "' and customers_id = '" . (int) $customer_id . "' and sagepay_token = '" . tep_db_prepare_input(tep_db_input($token)) . "'");
     return tep_db_affected_rows() === 1;
 }
Example #6
0
 function deleteCard($card, $customer, $token_id)
 {
     global $customer_id;
     $result = $this->sendTransactionToGateway('https://api.stripe.com/v1/customers/' . $customer . '/cards/' . $card, null, array(CURLOPT_CUSTOMREQUEST => 'DELETE'));
     if (!is_array($result) || !isset($result['object']) || $result['object'] != 'card') {
         $this->sendDebugEmail($result);
     }
     tep_db_query("delete from customers_stripe_tokens where id = '" . (int) $token_id . "' and customers_id = '" . (int) $customer_id . "' and stripe_token = '" . tep_db_prepare_input(tep_db_input($customer . ':|:' . $card)) . "'");
     return tep_db_affected_rows() === 1;
 }
 function expireEntries()
 {
     tep_db_query("delete from " . TABLE_ACTION_RECORDER . " where module = '" . $this->code . "' and date_added < date_sub(now(), interval " . (int) $this->minutes . " minute)");
     return tep_db_affected_rows();
 }
Example #8
0
 /**
  * Update selling price for B2B sales partner
  * @param Int $sales_partner_id Sales Partner ID
  * @param Float $price_no_discount Selling price without discount
  * @param Float $price_discount Selling price with discount
  * @param Boolean $activate_discount Activate the discount or not
  */
 public function updatePriceSellingB2B($sales_partner_id, $price_no_discount, $price_discount, $activate_discount)
 {
     if ($activate_discount) {
         $price = $price_discount;
         $price_old = $price_no_discount;
     } else {
         $price = $price_no_discount;
         $price_old = 0;
     }
     $price_uploaded = '0';
     $sda = array();
     $sda['price'] = $price;
     $sda['price_old'] = $price_old;
     $sda['price_uploaded'] = $price_uploaded;
     tep_db_perform('jng_sp_catalog', $sda, 'update', "jng_sp_id={$sales_partner_id} AND products_id={$this->id}");
     if (tep_db_affected_rows() > 0) {
         $this->detail['sp'][$sales_partner_id]['price'] = $price;
         $this->detail['sp'][$sales_partner_id]['price_old'] = $price_old;
         $this->detail['sp'][$sales_partner_id]['price_uploaded'] = $price_uploaded;
     }
 }
    //echo $row['jng_sp_id'] . ' - ' . $row['item_id'] . ' - ' .
    //$row['products_code'] . ' - ' . $matexp;
    if ($matexp > 0 && $cogs > 0) {
        $sda = array();
        if ($row['item_matexp'] == 0) {
            $sda['material_expenses'] = $matexp;
        }
        if ($row['item_cogs'] == 0) {
            $sda['cogs'] = $cogs;
        }
        if ($row['jng_sp_id'] > 0) {
            tep_db_perform('jng_sp_orders_items', $sda, 'update', "jng_sp_orders_items_id = {$row['item_id']}");
            $sp_counter += tep_db_affected_rows();
        } else {
            tep_db_perform('orders_products', $sda, 'update', "orders_products_id = {$row['item_id']}");
            $jg_counter += tep_db_affected_rows();
        }
        //echo ' - updated';
    }
    //echo '<br />';
}
$logger->write("Filling mat-exp & cogs for JG orders: {$jg_counter} updated");
$logger->write("Filling mat-exp & cogs for SP orders: {$sp_counter} updated");
//Initial configuration for COGS calcultion
$bgst = $class_pm->retrieveBestGoodSettings();
$sp_included = $class_sp->retrieveList('sp_type = ' . SalesPartner::TYPE_B2C);
$sp_ids_included = array_keys($sp_included);
$logger->write('SP ID Included: ' . implode(',', $sp_ids_included));
//Set the date range to calculate
if (isset($_GET['start']) && isset($_GET['end'])) {
    //MANUAL SET DATE RANGE
<?php

//SUBMIT ACTION
if (isset($_POST['me_action'])) {
    if ($_POST['me_action'] == 'ORDERSPAIDSTATUS') {
        if (isset($_POST['paid_status']) && $_POST['paid_status'] != '') {
            if (isset($_POST['orders']) && is_array($_POST['orders'])) {
                $paid_status = tep_db_prepare_input($_POST['paid_status']);
                $order_ids = implode(',', $_POST['orders']);
                tep_db_query("UPDATE orders SET paid_status={$paid_status} WHERE orders_id IN ({$order_ids})");
                $updated = tep_db_affected_rows();
                if ($updated > 0) {
                    $messagebox->add($updated . ' order' . ($updated > 1 ? 's are' : ' is ') . ' updated', 'green');
                } else {
                    $messagebox->add("No Order is updated");
                }
            } else {
                $messagebox->add("No Order was checked");
            }
        }
    }
}
//START TEMPLATE
$page = 1;
if (isset($_GET['page'])) {
    $page = $_GET['page'];
}
if (isset($_POST['filterby'])) {
    $_SESSION['paid_filterby'] = tep_db_prepare_input($_POST['filterby']);
} else {
    if (!isset($_SESSION['paid_filterby'])) {
 function deleteCard($token, $token_id)
 {
     global $customer_id;
     Braintree_Configuration::environment(MODULE_PAYMENT_BRAINTREE_CC_TRANSACTION_SERVER == 'Live' ? 'production' : 'sandbox');
     Braintree_Configuration::merchantId(MODULE_PAYMENT_BRAINTREE_CC_MERCHANT_ID);
     Braintree_Configuration::publicKey(MODULE_PAYMENT_BRAINTREE_CC_PUBLIC_KEY);
     Braintree_Configuration::privateKey(MODULE_PAYMENT_BRAINTREE_CC_PRIVATE_KEY);
     try {
         Braintree_CreditCard::delete($token);
     } catch (Exception $e) {
     }
     tep_db_query("delete from customers_braintree_tokens where id = '" . (int) $token_id . "' and customers_id = '" . (int) $customer_id . "' and braintree_token = '" . tep_db_prepare_input(tep_db_input($token)) . "'");
     return tep_db_affected_rows() === 1;
 }
Example #12
0
 /**
  * Set Leadtime Start Date
  * @param String $timestamp
  * @param Array $item
  * @param Int $order_id
  * @return Int
  */
 function leadtimeSetStart($timestamp, $item, $order_id = '', $reset_lsd = false)
 {
     /*
      * Leadtime Start Date for JG orders sets based on below:
      * 1. Non Prepayment > Date when order created = Order Date
      * 2. Prepayment > Date when customer paid full
      */
     $update_all_items = $order_id != '';
     $order_id = $order_id != '' ? $order_id : $item['orders_id'];
     $order = $this->retrieveDetail($order_id, true, true);
     $payment_method = strtoupper(trim($order['payment_method']));
     $cond_filter = $reset_lsd ? '' : " AND IFNULL(leadtime_start_date,'')=''";
     $ok_update = true;
     //Only allowed for Paid Prepayment
     if ($payment_method == strtoupper(PAYMENT_METHOD_BANK_TRANSFER) || $payment_method == strtoupper(PAYMENT_METHOD_PREPAYMENT)) {
         $ok_update = $order['payment_status'] == 1;
     }
     $n_updated = 0;
     if ($ok_update) {
         if ($update_all_items) {
             tep_db_query("UPDATE orders_products SET leadtime_start_date='{$timestamp}' WHERE orders_id={$order_id} {$cond_filter}");
         } else {
             tep_db_query("UPDATE orders_products SET leadtime_start_date='{$timestamp}' WHERE orders_products_id={$item['orders_products_id']} {$cond_filter}");
         }
         $n_updated = tep_db_affected_rows();
     }
     return $n_updated;
 }
Example #13
0
 /**
  * Set Leadtime Start Date
  * @param String $timestamp
  * @param Array $item
  * @param Int $order_id
  */
 function leadTimeSetStart($timestamp, $item, $order_id = '', $reset_lsd = false)
 {
     $order_id = $order_id != '' ? $order_id : $item['depot_orders_id'];
     $cond_filter = $reset_lsd ? '' : " AND IFNULL(leadtime_start_date,'')=''";
     tep_db_query("UPDATE depot_orders SET leadtime_start_date=DATE('{$timestamp}') WHERE depot_orders_id={$order_id} {$cond_filter}");
     return tep_db_affected_rows();
 }
Example #14
0
 /**
  * Update quantity of a booking item. When new quantity is 0 item will be removed instead, when no existing item found item will be added.
  * @param Int $stock_id
  * @param Int $new_quantity
  */
 public function updateItem($stock_id, $new_quantity)
 {
     if ($new_quantity <= 0) {
         $this->removeItem($stock_id);
     } else {
         $sda = array();
         $sda['booking_quantity'] = $new_quantity;
         tep_db_perform('products_stock_booking_items', $sda, 'update', "booking_id='{$this->id}' AND products_stock_id='{$stock_id}'");
         if (tep_db_affected_rows() > 0) {
             $this->items[$stock_id] = $new_quantity;
         } else {
             $this->addItem($stock_id, $new_quantity);
         }
     }
     if ($this->status == '0') {
         $this->recalcActiveBooking();
     }
 }
Example #15
0
 function updatePaymentStatus($orders_id, $status, $update_by = '')
 {
     $order = $this->retrieveDetail($orders_id);
     tep_db_query("UPDATE jng_sp_orders SET payment_status={$status} WHERE jng_sp_orders_id={$orders_id}");
     $n_updated = tep_db_affected_rows();
     $timestamp = date('Y-m-d H:i:s');
     $log_sda = array();
     $log_sda['orders_id'] = $order['jng_sp_orders_id'];
     $log_sda['payment_method'] = $order['payment_method'];
     $log_sda['payment_status'] = $status;
     $log_sda['update_time'] = $timestamp;
     $log_sda['update_by'] = $update_by;
     $log_sda['type'] = 'SP';
     tep_db_perform('log_orders_payment_status', $log_sda);
     //set leadtime start date when payment is done
     if ($status == 1) {
         $this->leadtimeSetStart($timestamp, '', $orders_id);
     }
     return $n_updated;
 }