public function import_orders()
 {
     if (strpos($_SERVER['SCRIPT_FILENAME'], 'solr_auto_import_orders.php') === FALSE) {
         exit;
     }
     $end_time = date('Y-m-d H:i:s');
     set_time_limit(0);
     $limit = 1000;
     $end_time = get_current_time();
     $offset = 0;
     $order_table = 'order_list_completed';
     $order_id = 'order_id';
     $start_time = $this->solr_order_model->fetch_solr_order_updated_date();
     $start_time = date('Y-m-d H:i:s', mktime(substr($start_time, 11, 2), substr($start_time, 14, 2), substr($start_time, 17, 2), substr($start_time, 5, 2), substr($start_time, 8, 2) - 45, substr($start_time, 0, 4)));
     echo $start_time;
     $successful = TRUE;
     $successful1 = TRUE;
     //$this->_process_import_order($order_table, $order_id, $start_time, $end_time, $limit, $offset);
     $offset = 0;
     $order_table = 'order_list';
     $order_id = 'id';
     $successful2 = $this->_process_import_order($order_table, $order_id, $start_time, $end_time, $limit, $offset);
     if ($successful1 && $successful2) {
         $this->solr_order_model->update_solr_order_updated_date($end_time);
     }
 }
Esempio n. 2
0
 private function _proccess_track_ebay_competitor($id)
 {
     $ebay_url_base = 'http://cgi.ebay.com/ws/eBayISAPI.dll?ViewItem&item=';
     $competitor = $this->ebay_model->fetch_competitor_by_id($id);
     $item_id = $competitor->item_id;
     //$item_id = 270801805639;
     $ebay_item = $this->ebay_model->fetch_ebay_item_by_item_id($item_id);
     if ($ebay_item->currency == 'EUR') {
         $ebay_url_base = 'http://www.ebay.de/itm/ws/eBayISAPI.dll?ViewItem&item=';
     }
     if ($ebay_item->currency == 'GBP') {
         $ebay_url_base = 'http://www.ebay.co.uk/itm/ws/eBayISAPI.dll?ViewItem&item=';
     }
     if ($ebay_item->currency == 'AUD') {
         $ebay_url_base = 'http://www.ebay.com.au/itm/ws/eBayISAPI.dll?ViewItem&item=';
     }
     if (empty($ebay_item)) {
         //$this->ebay_model->drop_competitor_by_item_id($item_id);
         return;
     }
     $competitor_result = fetch_ebay_competitor_price($competitor->url);
     if (empty($competitor_result)) {
         return;
     }
     $our_result = fetch_ebay_competitor_price($ebay_url_base . $ebay_item->item_id);
     if (empty($our_result)) {
         return;
     }
     //var_dump($our_result);die();
     $price = $competitor_result['total'];
     $our_price = $our_result['total'] + $competitor->allowed_difference;
     if ($our_price > $price) {
         $balance = $price - $our_price;
         $status = 1;
     } else {
         $balance = '+' . ($price - $our_price);
         $status = 0;
     }
     $competitor_data = array('balance' => $balance, 'status' => $status, 'track_time' => get_current_time());
     $this->ebay_model->update_competitor($competitor->id, $competitor_data);
     var_dump($competitor_data);
     /*
      * warn our saler
      */
     if ($status && $ebay_item->alarm != 1) {
         $this->ebay_model->update_ebay_by_item_id($item_id, array('alarm' => 1));
     }
     /**
      * update our item price.
      **/
     $this->ebay_model->update_ebay_by_item_id($item_id, array('price' => $our_result['product'], 'shipping_price' => $our_result['shipping']));
     if ($status) {
         $click_url = $competitor->url;
         $saler_ids = $this->ebay_model->fetch_saler_ids_by_ebay_id($ebay_item->ebay_id);
         var_dump($saler_ids);
         $this->events->trigger('ebay_item_price_too_high', array('type' => 'ebay_item_price_too_high_notify', 'click_url' => $click_url, 'content' => sprintf(lang('competitor_has_lower_price'), $competitor->seller_id), 'owner_id' => 0, 'allowed_user_ids' => $saler_ids));
     }
 }
function start_execution()
{
    $unix = new unix();
    BuildingExecRightStatus("Building postfix status...", 20);
    postfix_status();
    BuildingExecRightStatus("Building postfix status...", 55);
    events("postfix_status() OK");
    get_current_time();
    events("get_current_time() OK");
    BuildingExecRightStatus("Building postfix status...", 90);
    BuildingExecRightStatus("done...", 100);
}
Esempio n. 4
0
 public function add_new_template()
 {
     $user_id = get_current_user_id();
     $created_date = get_current_time();
     $data = array('template_name' => '[edit]', 'template_content' => '[edit]', 'user' => $user_id, 'template_subject' => '[edit]', 'created_date ' => $created_date);
     try {
         $this->ebay_model->add_ebay_message_template($data);
         echo $this->create_json(1, lang('configuration_accepted'));
     } catch (Exception $e) {
         $this->ajax_failed();
         echo lang('error_msg');
     }
 }
 public function add_new_email_template()
 {
     $user_id = get_current_user_id();
     $update_time = get_current_time();
     $name = get_current_user_name();
     $created_date = get_current_time();
     $remark = $name . lang('on') . $update_time . lang('create_template') . "<br>";
     $data = array('title' => '', 'content' => '', 'code' => '', 'creator' => $user_id, 'remark' => $remark, 'created_date ' => $created_date);
     try {
         $this->edm_email_model->add_edm_email($data);
         echo $this->create_json(1, lang('configuration_accepted'));
     } catch (Exception $e) {
         $this->ajax_failed();
         echo lang('error_msg');
     }
 }
Esempio n. 6
0
 public function move_save()
 {
     if ($this->input->is_post()) {
         $ship_order_no = $this->input->post('ship_order_no');
         $log_type = $this->input->post('log_type');
         $storage_code = $this->input->post('storage_code');
         $ship_confirm_date = $this->input->post('ship_confirm_date');
         $locale = $this->input->post('locale');
         $collect_address = $this->input->post('collect_address');
         $ship_confirm_user = $this->input->post('ship_confirm_user');
         $transaction_number = $this->input->post('transaction_number');
         $abroad_stock_remark = $this->input->post('abroad_stock_remark');
         $sku_arr = $this->input->post('sku');
         $qty_arr = $this->input->post('qty');
     }
     $sku_str = '';
     $qty_str = '';
     foreach ($sku_arr as $val => $sku) {
         if (!$this->product_model->check_exists('product_basic', array('sku' => $sku))) {
             echo $this->create_json(0, lang('product_sku_nonentity'));
             return;
         } else {
             $sku_str = $sku_str . $sku . ',';
         }
     }
     foreach ($qty_arr as $qty) {
         if (!is_positive($qty)) {
             echo $this->create_json(0, lang('qty_not_natural'));
             return;
         } else {
             $qty_str = $qty_str . $qty . ',';
         }
     }
     $sku_str = substr($sku_str, 0, strlen($sku_str) - 1);
     $qty_str = substr($qty_str, 0, strlen($qty_str) - 1);
     $creator = $this->get_current_login_name();
     $created_date = get_current_time();
     $data = array('ship_order_no' => $ship_order_no, 'log_type' => $log_type, 'storage_code' => $storage_code, 'ship_confirm_date' => $ship_confirm_date, 'locale' => $locale, 'remark' => $abroad_stock_remark, 'collect_address' => $collect_address, 'ship_confirm_user' => $ship_confirm_user, 'transaction_number' => $transaction_number, 'sku_str' => $sku_str, 'qty_str' => $qty_str, 'creator' => $creator, 'created_date' => $created_date);
     $this->product_model->save_move_stock($data);
     foreach ($sku_arr as $val => $sku) {
         $count = $qty_arr[$val];
         $this->change_stock_count($sku, $storage_code, $count);
     }
     echo $this->create_json(1, lang('purchase_apply_saved'));
 }
Esempio n. 7
0
 public function trade_get()
 {
     $now = get_current_time();
     $top_client = get_top_client();
     $tids = $this->taobao_model->get_order_tid();
     foreach ($tids as $tid) {
         $tid = $tid->tid;
         $req = new TradeGetRequest();
         $req->setFields("tid, status");
         $req->setTid($tid);
         try {
             $resp = $top_client->execute($req);
         } catch (Exception $e) {
             echo lang('error_msg');
         }
         $this->taobao_model->trade_get($resp, $now);
     }
 }
Esempio n. 8
0
 function writeLog()
 {
     $date = get_current_date();
     $filename = ROOT_DIR . 'log/log_info' . $date;
     if (!file_exists($filename)) {
         $fp = fopen($filename, "wa");
         fclose($fp);
     }
     $data = get_current_time() . " " . $this->getIp() . " " . $this->getInfo() . PHP_EOL;
     try {
         file_put_contents($filename, $data, FILE_APPEND | LOCK_EX);
     } catch (Exception $ex) {
         print_r("<pre>");
         print_r($ex->getMessage());
         print_r($ex->getTrace());
         print_r("</pre>");
         die;
     }
 }
 public function save_accounting_costs()
 {
     $order_count = $this->input->post('order_count');
     $user_id = get_current_user_id();
     for ($i = 0; $i < $order_count; $i++) {
         $order_id = $this->input->post('order_id_' . $i);
         $shipping_cost = trim($this->input->post('shipping_cost_' . $i));
         $product_cost = trim($this->input->post('product_cost_' . $i));
         $product_cost_string = trim(trim($this->input->post('product_cost_string_' . $i)), ',');
         if (!is_numeric($shipping_cost) || !is_numeric($product_cost) || $shipping_cost <= 0 || $product_cost <= 0) {
             continue;
         }
         try {
             $data = array('cost_user' => $user_id, 'cost_date' => get_current_time(), 'cost' => $shipping_cost + $product_cost, 'shipping_cost' => $shipping_cost, 'product_cost_all' => $product_cost, 'product_cost' => $product_cost_string);
             $this->order_model->update_order_information($order_id, $data);
             calculate_order_profit_rate($order_id);
         } catch (Exception $e) {
             echo lang('error_msg');
             $this->ajax_failed();
         }
     }
     echo $this->create_json(1, lang('stock_check_or_count_successfully'));
 }
Esempio n. 10
0
File: UI.php Progetto: Kaelcao/cbir
 function new_dataset()
 {
     $data['content'] = 'dataset-new';
     $data['nav'] = 'dataset';
     $data['title'] = 'Add Data Set';
     if ($this->input->post()) {
         $dataset = array('dataset_name' => $this->input->post('datasetname'), 'create_at' => get_current_time());
         if ($dataset['dataset_name'] == "") {
             $data['status'] = 0;
             $data['message'] = 'The name of dataset cannot be empty';
         } else {
             $num_rows = $this->db->where('dataset_name', $dataset['dataset_name'])->from('dataset')->count_all_results();
             if ($num_rows > 0) {
                 $data['status'] = 0;
                 $data['message'] = $dataset['dataset_name'] . ' has already existed';
             } else {
                 $data['status'] = 1;
                 $data['message'] = $dataset['dataset_name'] . ' dataset added successfully';
                 $this->db->insert('dataset', $dataset);
             }
         }
     }
     $this->load->view('/template/header', $data);
 }
Esempio n. 11
0
function stChangeOrderStatus($orderID, $statusID, $comment = '', $notify = 0)
{
    $q_status_name = db_query("select status_name from " . ORDER_STATUES_TABLE . " where statusID=" . (int) $statusID);
    list($status_name) = db_fetch_row($q_status_name);
    $sql = "insert into " . ORDER_STATUS_CHANGE_LOG_TABLE . " ( orderID, status_name, status_change_time, status_comment ) " . " values( " . (int) $orderID . ", '" . xToText($status_name) . "', '" . xEscSQL(get_current_time()) . "', '" . xToText(trim($comment)) . "' ) ";
    db_query($sql);
    if ($notify) {
        $Order = ordGetOrder($orderID);
        $t = '';
        $Email = '';
        $FirstName = '';
        regGetContactInfo(regGetLoginById($Order['customerID']), $t, $Email, $FirstName, $t, $t, $t);
        if (!$Email) {
            $Email = $Order['customer_email'];
        }
        if (!$FirstName) {
            $FirstName = $Order['customer_firstname'];
        }
        xMailTxt($Email, STRING_CHANGE_ORDER_STATUS, 'customer.order.change_status.tpl', array('customer_firstname' => $FirstName, '_MSG_CHANGE_ORDER_STATUS' => str_replace(array('{STATUS}', '{ORDERID}'), array($status_name == 'STRING_CANCELED_ORDER_STATUS' ? STRING_CANCELED_ORDER_STATUS : $status_name, $orderID), MSG_CHANGE_ORDER_STATUS), '_ADMIN_COMMENT' => $comment));
    }
}
Esempio n. 12
0
 public function save_return_order($tag = NULL)
 {
     $id = $this->input->post('id');
     $item_no = $this->input->post('item_no');
     //        $view_return_cost = $this ->input ->post('view_return_cost');
     $order = $this->order_model->get_order_with_id($id);
     if (!empty($order->return_cost)) {
         $return_cost = $this->input->post('return_cost') + $order->return_cost;
     } else {
         $return_cost = $this->input->post('return_cost');
     }
     $return_type = $this->input->post('return_type');
     $return_type_string = $this->order_model->fetch_status_name('order_status', $return_type);
     $sys_remark = $order->sys_remark;
     $sys_remark .= sprintf(lang('apply_action_by_sys_remark'), get_current_user_name(), get_current_time(), lang($return_type_string), $return_cost . "( {$order->currency})");
     $status_id_wfa = $this->order_model->fetch_status_id('order_status', 'wait_for_assignment');
     $status_id_wfc = $this->order_model->fetch_status_id('order_status', 'wait_for_confirmation');
     $status_id_h = $this->order_model->fetch_status_id('order_status', 'holded');
     /*
      * 当申请未发货-申请退款时(待客服分配,待客服确认,客服暂不确认), 状态直接改为未发货-申请退款。
      * **/
     if ($order->order_status == $status_id_wfa || $order->order_status == $status_id_wfc || $order->order_status == $status_id_h) {
         $return_type = $this->order_model->fetch_status_id('order_status', 'not_shipped_apply_for_refund');
         $sys_remark = $order->sys_remark;
         $sys_remark .= sprintf(lang('apply_action_by_sys_remark'), get_current_user_name(), get_current_time(), lang('not_shipped_apply_for_refund'), $return_cost . "( {$order->currency})");
     }
     $status_id = $this->order_model->get_one('order_list', 'order_status', array('id' => $id));
     $return_status = $this->order_model->fetch_status_name('order_status', $status_id);
     /**
      * 前:已发货时的几种状态, 中: 未发货时的状态 , 后:二次退款的。
      */
     $return_status_arr = array('wait_for_purchase', 'wait_for_shipping_label', 'wait_for_shipping_confirmation', 'wait_for_feedback', 'received', 'wait_for_assignment', 'wait_for_confirmation', 'holded', 'not_received_partial_refunded', 'received_partial_refunded');
     $rules = array(array('field' => 'remark', 'label' => lang('remark'), 'rules' => 'trim|required'));
     $return_type_nrar = $this->order_model->fetch_status_id('order_status', 'not_received_apply_for_partial_refund');
     $return_type_rar = $this->order_model->fetch_status_id('order_status', 'received_apply_for_partial_refund');
     $status = $this->order_model->fetch_status_name('order_status', $return_type);
     /**
      * Form 验证。
      */
     $this->form_validation->set_rules($rules);
     if ($this->form_validation->run() == FALSE) {
         $error = validation_errors();
         echo $this->create_json(0, $error);
         return;
     }
     /**
      *   这里是申请审核的。
      */
     $user_priority = $this->user_model->fetch_user_priority_by_system_code('order');
     //        if($user_priority+1 >= 2)//Test
     if ($user_priority >= 2) {
         if ($tag == 'approved') {
             $order_status_approved = $this->order_model->get_one('order_list', 'order_status', array('id' => $id));
             $return_type_string = $this->order_model->fetch_status_name('order_status', $order_status_approved);
             if ($return_type_string == 'not_received_approved_resending' || $return_type_string == 'received_approved_resending') {
                 echo $this->create_json(0, lang('review_finish'));
                 return;
             }
             switch ($return_type_string) {
                 case 'not_received_apply_for_partial_refund':
                     $return_type = $this->order_model->fetch_status_id('order_status', 'not_received_partial_refunded');
                     break;
                 case 'not_received_apply_for_full_refund':
                     $return_type = $this->order_model->fetch_status_id('order_status', 'not_received_full_refunded');
                     //                        $return_cost = $view_return_cost;
                     break;
                 case 'not_received_apply_for_resending':
                     $return_type = $this->order_model->fetch_status_id('order_status', 'not_received_approved_resending');
                     break;
                 case 'received_apply_for_partial_refund':
                     $return_type = $this->order_model->fetch_status_id('order_status', 'received_partial_refunded');
                     break;
                 case 'received_apply_for_full_refund':
                     $return_type = $this->order_model->fetch_status_id('order_status', 'received_full_refunded');
                     //                        $return_cost = $view_return_cost;
                     break;
                 case 'received_apply_for_resending':
                     $return_type = $this->order_model->fetch_status_id('order_status', 'received_approved_resending');
                     break;
                 case 'not_shipped_apply_for_refund':
                     $return_type = $this->order_model->fetch_status_id('order_status', 'not_shipped_agree_to_refund');
                     break;
                 default:
                     echo $this->create_json(0, lang('no_return'));
                     return;
             }
             $return_cost = $this->input->post('return_cost');
             $sys_remark = $order->sys_remark;
             //                $sys_remark .= sprintf(lang('approved_by_sys_remark'), get_current_time(), get_current_user_name());
             $sys_remark .= sprintf(lang('approved_by_sys_remark_for_one'), get_current_time(), get_current_user_name(), $return_cost . "( {$order->currency})");
             $descript = $order->descript;
             $descript .= sprintf(lang('approved_by_sys_remark_for_one'), get_current_time(), get_current_user_name(), $return_cost . "( {$order->currency})");
         } elseif ($tag == 'rejected') {
             $not_ship_id = $this->order_model->fetch_status_id('order_status', 'not_shipped_apply_for_refund');
             if ($order->order_status == $not_ship_id) {
                 $holded_id = $this->order_model->fetch_status_id('order_status', 'holded');
                 $order_status_rejected = $holded_id;
                 $sys_remark = $order->sys_remark;
                 $sys_remark .= sprintf(lang('rejected_by_sys_remark'), get_current_user_name(), get_current_time(), lang('not_shipped_apply_for_refund'), lang('holded'));
                 $descript = $order->descript;
                 $descript .= sprintf(lang('rejected_by_sys_remark'), get_current_user_name(), get_current_time(), lang('not_shipped_apply_for_refund'), lang('holded'));
             } else {
                 $apply_status = array('not_received_apply_for_partial_refund', 'not_received_apply_for_full_refund', 'not_received_apply_for_resending', 'received_apply_for_partial_refund', 'received_apply_for_full_refund', 'received_apply_for_resending', 'not_shipped_apply_for_refund');
                 $order_status_string = $this->order_model->fetch_status_name('order_status', $order->order_status);
                 if (!in_array($order_status_string, $apply_status)) {
                     echo $this->create_json(0, lang('no_rejected'));
                     return;
                 }
                 $margin_arr = explode('|', $order->return_why);
                 if (count($margin_arr) == 2) {
                     $return_cost = $order->return_cost - $margin_arr[1];
                 }
                 $return_why = $margin_arr[0];
                 $order_status_rejected = $this->order_model->fetch_status_id('order_status', 'wait_for_feedback');
                 $sys_remark = $order->sys_remark;
                 $sys_remark .= sprintf(lang('rejected_by_sys_remark'), get_current_user_name(), get_current_time(), lang($order_status_string), lang('wait_for_feedback'));
                 $descript = $order->descript;
                 $descript .= sprintf(lang('rejected_by_sys_remark'), get_current_user_name(), get_current_time(), lang($order_status_string), lang('wait_for_feedback'));
             }
         } else {
             if (!in_array($return_status, $return_status_arr)) {
                 echo $this->create_json(0, lang('no_return'));
                 return;
             }
             if (!$return_type) {
                 echo $this->create_json(0, lang('please_select_return_type'));
                 return;
             }
         }
     } else {
         if (!in_array($return_status, $return_status_arr)) {
             echo $this->create_json(0, lang('order_not_return'));
             return;
         }
     }
     $is_return = $this->input->post('is_return');
     $remark = $this->input->post('remark');
     $refund_verify_type = $this->input->post('refund_verify_type');
     $refund_verify_content = $this->input->post('refund_verify_content');
     $person_responsible = $this->input->post('person_responsible');
     $refund_sku = $this->input->post('refund_sku');
     $refund_sku_str = '';
     if (!empty($refund_sku)) {
         foreach ($refund_sku as $sku) {
             $refund_sku_str .= $sku . ',';
         }
     }
     if (!empty($person_responsible) && strpos($person_responsible, '#') !== 0) {
         if (!$this->order_model->check_exists('user', array('name' => $person_responsible))) {
             echo $this->create_json(0, lang('name_no_exists'));
             return;
         }
     }
     $data = array('return_why' => $order->order_status . '|' . $this->input->post('return_cost'), 'return_cost' => $return_cost, 'return_remark' => $remark, 'descript' => $order->descript . $remark, 'return_date' => get_current_time(), 'return_user' => get_current_user_name(), 'order_status' => $return_type, 'refund_verify_type' => $refund_verify_type, 'refund_verify_content' => $refund_verify_content, 'refund_duty' => $person_responsible, 'refund_sku_str' => trim($refund_sku_str, ','));
     if ($tag == 'approved' || $tag == 'rejected') {
         unset($data['return_date']);
     }
     if (isset($sys_remark)) {
         $data['sys_remark'] = $sys_remark;
     }
     if (isset($order_status_rejected)) {
         $data['order_status'] = $order_status_rejected;
     }
     if (isset($descript)) {
         $data['descript'] = $sys_remark;
     }
     if (isset($return_why)) {
         $data['return_why'] = $return_why;
     }
     /*
      * 未发货-申请退款时, 金额为全额。
      * **/
     if ($order->order_status == $status_id_wfa || $order->order_status == $status_id_wfc || $order->order_status == $status_id_h) {
         //            $data['return_cost'] = $order->gross;
         //            $data['return_cost'] = $order->gross && $order->gross != '0'?$order->gross:$order->net;
     }
     /**
      * 申请重发时录入订单号
      */
     if ($status == 'not_received_apply_for_resending' || $status == 'received_apply_for_resending') {
         $gross = $this->order_model->get_one('order_list', 'gross', array('id' => $id));
         $net = $this->order_model->get_one('order_list', 'net', array('id' => $id));
         $cost = 0;
         if ($gross && $gross != '0') {
             $cost = $gross;
         } else {
             $cost = $net;
         }
         if ($return_cost > $cost) {
             echo $this->create_json(0, lang('return_cost_is_too_big'));
             return;
         } else {
             $rules[] = array('field' => 'return_cost', 'label' => lang('return_cost'), 'rules' => 'trim|required|positive_numeric');
         }
         $data['return_order'] = $item_no;
         // id;
         $data['return_why'] = $order->order_status;
     }
     try {
         if ($this->order_model->check_exists('order_list', array('id' => $id, 'item_no' => $item_no))) {
             $update_tag = $this->order_model->update_order_information($id, $data);
         } else {
             //$update_tag = $this->order_model->update_order_information_from_completed($id, $data);
         }
         $stratus_array = array('not_received_apply_for_partial_refund', 'not_received_apply_for_full_refund', 'not_received_apply_for_resending', 'received_apply_for_partial_refund', 'received_apply_for_full_refund', 'received_apply_for_resending');
         /**
          * 发送申请提示。
          */
         if (in_array($status, $stratus_array)) {
             $message = $this->messages->load('apply_return');
             $this->events->trigger('apply_return_after', array('type' => 'apply_return', 'click_url' => site_url('order/special_order/view_list_return_order', array($id)), 'content' => lang($message['message']), 'owner_id' => $this->get_current_user_id()));
         }
         /**
          * 发送重发提示。
          */
         if ($status == 'not_received_approved_resending' || $status == 'received_approved_resending') {
             $message = $this->messages->load('return_apply_permit');
             $this->events->trigger('return_apply_permit_after', array('type' => 'return_apply_permit', 'click_url' => site_url('order/regular_order/view_order', array($id)), 'content' => lang($message['message']), 'owner_id' => $this->get_current_user_id()));
         }
         echo $this->create_json(1, lang('return_option_saved'));
     } catch (Exception $e) {
         echo lang('error_msg');
         $this->ajax_failed();
     }
 }
Esempio n. 13
0
 public function verify_order_before_print_label($order_id)
 {
     if (strpos($_SERVER['SCRIPT_FILENAME'], 'auto_verify_order_after_change.php') === FALSE) {
         exit;
     }
     if (empty($order_id)) {
         return;
     }
     $order = $this->order_model->get_order($order_id);
     $wait_for_purchase_status = fetch_status_id('order_status', 'wait_for_purchase');
     $wait_for_finance_status = fetch_status_id('order_status', 'wait_for_finance_confirmation');
     $sys_remark = $order->sys_remark . sprintf(lang('purchase_to_finance_confirmation_note_due_to_profit_rate'), get_current_time(), lang('system'));
     $skus = explode(',', $order->sku_str);
     $qties = explode(',', $order->qty_str);
     $product_price = 0;
     $shipping_weight = 0;
     $i = 0;
     foreach ($skus as $sku) {
         $qty = $qties[$i];
         $i++;
         $product = $this->product_model->fetch_product_by_sku($sku);
         $product_price += $product->price * $qty;
         $shipping_weight += $product->total_weight * $qty;
     }
     $order_data = array('item_id_str' => $order->item_id_str, 'gross' => $order->gross, 'net' => $order->net, 'currency' => $order->currency, 'transaction_ids' => $order->transaction_id, 'shipping_code' => $order->is_register, 'price' => $product_price, 'shipping_weight' => $shipping_weight, 'country' => $order->country);
     $result = $this->_calculate_profit_rate($order_data);
     if (isset($result['profit_rate'])) {
         $data = array();
         $profit = $result['profit'];
         $profit_rate = $result['profit_rate'];
         if ($profit < -1 or $profit_rate < -0.1 or $profit_rate > 0.3) {
             if ($order->order_status == $wait_for_purchase_status) {
                 $data = array('order_status' => $wait_for_finance_status, 'sys_remark' => $sys_remark);
             }
         }
         $data['profit_rate'] = $result['profit_rate'];
         $data['shipping_cost'] = $result['shipping_cost'];
         $data['product_cost_all'] = $result['product_cost'];
         $data['trade_fee'] = $result['trade_fee'];
         $data['listing_fee'] = $result['listing_fee'];
         /*  Not activate it currently.
              *
             $order_role = $this->_get_order_role($order->sku_str, $order->to_email);
             $data['stock_user_id'] = $order_role['stock_user_id'];
             $data['purchaser_id_str'] = $order_role['purchaser_id_str'];
             $data['developer_id'] = $order_role['developer_id'];
             $data['saler_id'] = $order_role['saler_id'];
             */
         $this->order_model->update_order_information($order_id, $data);
     }
 }
 public function auditing_order_rejecteds($tag = NULL)
 {
     $order_id = $this->input->post('order_id');
     $order = $this->order_model->get_order_with_id($order_id);
     if (empty($order)) {
         return;
     }
     $sys_remark = $order->sys_remark;
     $sys_remark .= sprintf(lang('batch_rejected_by_sys_remark_one'), get_current_time(), get_current_user_name());
     $descript = $order->descript;
     $descript .= sprintf(lang('batch_rejected_by_sys_remark_one'), get_current_time(), get_current_user_name());
     $margin_arr = explode('|', $order->return_why);
     if (count($margin_arr) == 2) {
         $return_cost = $order->return_cost - $margin_arr[1];
     }
     $return_why = $margin_arr[0];
     try {
         $data = array('order_status' => $this->order_model->fetch_status_id('order_status', 'wait_for_feedback'), 'sys_remark' => $sys_remark, 'descript' => $descript, 'return_why' => $return_why);
         if (isset($return_cost)) {
             $data['return_cost'] = $return_cost;
         }
         $order_status_no_ship = $this->order_model->fetch_status_name('order_status', $order->order_status);
         if ($order_status_no_ship == 'not_shipped_apply_for_refund') {
             $data['order_status'] = $this->order_model->fetch_status_id('order_status', 'holded');
         }
         $this->order_model->update_order_information($order_id, $data);
         echo $this->create_json(1, 'ok');
     } catch (Exception $e) {
         echo lang('error_msg');
         $this->ajax_failed();
     }
 }
Esempio n. 15
0
function ordAccessToLoadFile($orderID, $productID, &$pathToProductFile, &$productFileShortName)
{
    $order = ordGetOrder($orderID);
    $product = GetProduct($productID);
    if (strlen($product['eproduct_filename']) == 0 || !file_exists('core/files/' . $product['eproduct_filename']) || $product['eproduct_filename'] == null) {
        return 4;
    }
    if ((int) $order['statusID'] != (int) ostGetCompletedOrderStatus()) {
        return 3;
    }
    $orderContent = ordGetOrderContent($orderID);
    foreach ($orderContent as $item) {
        if (GetProductIdByItemId($item['itemID']) == $productID) {
            if ($item['load_counter'] < $product['eproduct_download_times'] || $product['eproduct_download_times'] == 0) {
                $date1 = dtGetParsedDateTime($order['order_time_mysql']);
                //$order['order_time']
                $date2 = dtGetParsedDateTime(get_current_time());
                $countDay = _getDayBetweenDate($date1, $date2);
                if ($countDay >= $product['eproduct_available_days']) {
                    return 2;
                }
                if ($product['eproduct_download_times'] != 0) {
                    db_query('update ' . ORDERED_CARTS_TABLE . ' set load_counter=load_counter+1 ' . ' where itemID=' . (int) $item['itemID'] . ' AND orderID=' . (int) $orderID);
                }
                $pathToProductFile = 'core/files/' . $product['eproduct_filename'];
                $productFileShortName = $product['eproduct_filename'];
                return 0;
            } else {
                return 1;
            }
        }
    }
    return -1;
}
 public function edit_save_order_ship_remark()
 {
     $cur_time = get_current_time();
     $cur_date = date("Y-m-d");
     $id = $this->order_shipping_record_model->fetch_id_of_record();
     $data = array('date' => $cur_date, 'stock_note' => trim($this->input->post('stock_remark')), 'shipping_note' => trim($this->input->post('ship_remark')), 'created_date' => $cur_time);
     try {
         if ($id) {
             $this->order_shipping_record_model->delete_ship_record_remark($id);
             $this->order_shipping_record_model->save_ship_record_remark($data);
             echo $this->create_json(1, lang('remark_saved'));
         } else {
             $this->order_shipping_record_model->save_ship_record_remark($data);
             echo $this->create_json(1, lang('remark_saved'));
         }
     } catch (Exception $e) {
         echo lang('error_msg');
         $this->ajax_failed();
     }
 }
Esempio n. 17
0
 public function modification_order_status()
 {
     $item_no = $this->input->post('item_no');
     $order_status = $this->input->post('order_status');
     if (empty($item_no)) {
         echo $this->create_json(0, lang('item_no_is_null'));
         return;
     }
     $order = $this->order_model->get_order_with_item_no($item_no);
     if (!$order) {
         $order = $this->order_model->get_order_with_item_no_from_completed($item_no);
     }
     if (empty($order)) {
         echo $this->create_json(0, lang('order_not_exists'));
         return;
     } else {
         $status = $order->order_status;
     }
     $not_shipped = fetch_status_id('order_status', 'not_shipped_agree_to_refund');
     $ok_arr = array(fetch_status_id('order_status', 'not_received_partial_refunded'), fetch_status_id('order_status', 'not_received_full_refunded'), fetch_status_id('order_status', 'not_received_approved_resending'), fetch_status_id('order_status', 'received_partial_refunded'), fetch_status_id('order_status', 'received_full_refunded'), fetch_status_id('order_status', 'received_approved_resending'));
     if (empty($status)) {
         $lang_string = 'NULL';
     } else {
         $status_string = fetch_status_name('order_status', $order->order_status);
         $lang_string = lang($status_string);
     }
     $sys_remark = $order->sys_remark;
     $sys_remark .= sprintf(lang('modification_by_sys_remark'), get_current_time(), get_current_user_name(), $lang_string, lang('wait_for_feedback'));
     $data = array('order_status' => fetch_status_id('order_status', 'wait_for_feedback'), 'sys_remark' => $sys_remark);
     try {
         if (in_array($status, $ok_arr) || empty($status)) {
             $this->order_model->update_order_information_by_item_no($item_no, $data);
             $this->order_model->update_order_information_by_item_no_from_completed($item_no, $data);
             echo $this->create_json(1, lang('ok'));
         } else {
             if ($status == $not_shipped) {
                 $this->order_model->update_order_information_by_item_no($item_no, $data);
                 $this->order_model->update_order_information_by_item_no_from_completed($item_no, $data);
                 echo $this->create_json(1, lang('ok'));
             } else {
                 echo $this->create_json(0, lang('no_update_this_status_order'));
             }
         }
     } catch (Exception $ex) {
         echo lang('error_msg');
         $this->ajax_failed();
     }
 }
Esempio n. 18
0
function regRegisterCustomer($login, $cust_password, $Email, $first_name, $last_name, $subscribed4news, $additional_field_values, $affiliateLogin = '')
{
    $affiliateID = 0;
    if ($affiliateLogin) {
        $sql = "select customerID  FROM " . CUSTOMERS_TABLE . "\n                        WHERE Login='******'";
        list($affiliateID) = db_fetch_row(db_query($sql));
    }
    foreach ($additional_field_values as $key => $val) {
        $additional_field_values[$key] = $val;
    }
    $currencyID = CONF_DEFAULT_CURRENCY;
    $cust_password = cryptPasswordCrypt($cust_password, null);
    // add customer to CUSTOMERS_TABLE
    $custgroupID = CONF_DEFAULT_CUSTOMER_GROUP;
    if ($custgroupID == 0) {
        $custgroupID = "NULL";
    }
    /**
     * Activation code
     */
    $ActivationCode = '';
    if (CONF_ENABLE_REGCONFIRMATION) {
        $CodeExists = true;
        while ($CodeExists) {
            $ActivationCode = generateRndCode(16);
            $sql = 'SELECT 1 FROM ' . CUSTOMERS_TABLE . '
                                WHERE ActivationCode="' . xEscapeSQLstring($ActivationCode) . '"';
            @(list($CodeExists) = db_fetch_row(db_query($sql)));
        }
    }
    db_query("insert into " . CUSTOMERS_TABLE . "( Login, cust_password, Email, first_name, last_name, subscribed4news, reg_datetime, CID, custgroupID, affiliateID, ActivationCode )" . "values( '" . xToText(trim($login)) . "', '" . xEscSQL(trim($cust_password)) . "', '" . xToText(trim($Email)) . "', " . " '" . xToText(trim($first_name)) . "', '" . xToText(trim($last_name)) . "', '" . (int) $subscribed4news . "', '" . xEscSQL(get_current_time()) . "', " . (int) $currencyID . ", " . (int) $custgroupID . ", " . xEscSQL(trim($affiliateID)) . ", '" . xEscSQL(trim($ActivationCode)) . "' )");
    // add additional values to CUSTOMER_REG_FIELDS_TABLE
    foreach ($additional_field_values as $key => $val) {
        SetRegField($key, $login, $val["additional_field"]);
    }
    $customerID = regGetIdByLogin($login);
    //db_query("update ".CUSTOMERS_TABLE." set addressID='".$addressID.
    //        "' where Login='******'" );
    if ($subscribed4news) {
        subscrAddRegisteredCustomerEmail($customerID);
    }
    return true;
}
Esempio n. 19
0
 public function auto_update_order_status()
 {
     if (strpos($_SERVER['SCRIPT_FILENAME'], 'auto_abroad_update_order_status.php') === FALSE) {
         exit;
     }
     define('SHIPPED_STATUS', 7);
     $status = 0;
     $outstocks = $this->abroad_stock_model->fetch_cky_outstock_by_status($status);
     $update_status_flag = TRUE;
     $wait_for_feedback_status = fetch_status_id('order_status', 'wait_for_feedback');
     $user_name = 'chukou1';
     foreach ($outstocks as $outstock) {
         $order_sign = $outstock->order_sign;
         $data = array('order_no' => $order_sign);
         $result = $this->cky_order->outstore_product_list($data);
         var_dump($result);
         if ($result && $result['status']) {
             $result = $result['result'];
             foreach ($result as $order_id => $value) {
                 if ($value['state'] == SHIPPED_STATUS) {
                     $shipping_status = $this->order_model->check_order_shipped_or_not($order_id);
                     // not shipped ?
                     if (!$shipping_status) {
                         // update shipping status
                         $datetime = get_current_time();
                         $order = $this->order_model->get_order($order_id);
                         if (empty($order)) {
                             continue;
                         }
                         $remark = $order->sys_remark;
                         $remark .= sprintf(lang('confirm_shipped_remark'), $datetime, $user_name);
                         $data = array('track_number' => $value['track_number'], 'ship_confirm_user' => $user_name, 'ship_confirm_date' => $datetime, 'order_status' => $wait_for_feedback_status, 'sys_remark' => $remark);
                         echo "updating order {$order_id},\n";
                         var_dump($data);
                         $this->order_model->update_order_information($order_id, $data);
                         // notify customer by email in backend.
                         $this->events->trigger('shipping_confirmation_after', array('order_id' => $order_id));
                     }
                 } else {
                     $update_status_flag = FALSE;
                 }
             }
         } else {
             $update_status_flag = FALSE;
             var_dump($result);
         }
         if ($update_status_flag) {
             $data = array('status' => 1);
             $this->abroad_stock_model->update_outstock($order_sign, $data);
         }
     }
 }
Esempio n. 20
0
 public function update_how_number()
 {
     $id = $this->input->post('id');
     $type = $this->input->post('type');
     $value = trim($this->input->post('value'));
     $order_sku = $this->purchase_order_model->fetch_sku($id);
     $sku = $order_sku->sku;
     $sku_arrival_quantity = $order_sku->sku_arrival_quantity;
     $product_how = $this->purchase_order_model->fetch_purchase_how($id);
     $product_basic = $this->purchase_order_model->fetch_product_id($sku);
     $product_id = $product_basic->b_id;
     $user_id = get_current_user_id();
     try {
         switch ($type) {
             case 'qualified_number':
                 if (!is_numeric($value) || $value <= 0) {
                     echo $this->create_json(0, lang('your_input_is_not_positive_numeric'), $value);
                     return;
                 }
                 break;
         }
         if (isset($product_how->order_sku_id)) {
             $qualified_number = $this->purchase_order_model->fetch_purchase_how($id)->qualified_number;
             if ($type == 'qualified_number') {
                 $order_id = $this->purchase_order_model->get_purchase_order_id($id);
                 $item_no = $this->purchase_order_model->get_item_no($order_id);
                 $number = $qualified_number + $value;
                 $this->purchase_order_model->update_how_number($id, $type, $number);
                 $stock_count = $this->product_model->fetch_stock_count($product_id);
                 $after_change_count = $stock_count + $value;
                 $data = array('stock_type' => 'product_instock', 'product_id' => $product_id, 'user_id' => $user_id, 'order_sku_id' => $id, 'change_count' => $value, 'type_extra' => $item_no, 'type' => 'purchase_order', 'before_change_count' => $stock_count, 'after_change_count' => $after_change_count, 'updated_time' => get_current_time());
                 $this->product_model->save_product_instock_apply($data);
                 if ($sku_arrival_quantity == $number) {
                     $this->purchase_order_model->update_reset_fcommitqty($id);
                 }
             } else {
                 $this->purchase_order_model->update_how_way($id, $type, $value);
             }
         } else {
             if ($type == 'how_way') {
                 $data = array('how_way' => $value, 'sku' => $sku, 'order_sku_id' => $id);
                 $this->purchase_order_model->add_how_number($data);
             }
             if ($type == 'qualified_number') {
                 $data = array('qualified_number' => $value, 'sku' => $sku, 'how_state' => '1', 'order_sku_id' => $id);
                 $order_id = $this->purchase_order_model->get_purchase_order_id($id);
                 $item_no = $this->purchase_order_model->get_item_no($order_id);
                 $this->purchase_order_model->add_how_number($data);
                 $stock_count = $this->product_model->fetch_stock_count($product_id);
                 $after_change_count = $stock_count + $value;
                 $data = array('stock_type' => 'product_instock', 'product_id' => $product_id, 'user_id' => $user_id, 'order_sku_id' => $id, 'before_change_count' => $stock_count, 'change_count' => $value, 'type_extra' => $item_no, 'type' => 'purchase_order', 'after_change_count' => $after_change_count, 'updated_time' => get_current_time());
                 $this->product_model->save_product_instock_apply($data);
                 if ($sku_arrival_quantity == $value) {
                     $this->purchase_order_model->update_reset_fcommitqty($id);
                 }
             }
         }
         echo $this->create_json(1, lang('ok'), 'how_way' == $type ? $value . '%' : $value);
     } catch (Exception $e) {
         $this->ajax_failed();
         echo lang('error_msg');
     }
 }
<?php

require_once "../php/main.php";
$id = argreq("id");
$time = get_current_time($id);
if (is_null($time)) {
    api_error();
}
api_done(array("half" => $time[0], "time" => $time[1], "overtime" => $time[2]));
Esempio n. 22
0
 function do_import_stock_count_upload()
 {
     setlocale(LC_ALL, 'en_US.UTF-8');
     $config['upload_path'] = '/tmp/';
     $config['allowed_types'] = '*';
     $config['max_size'] = '100000';
     $config['max_width'] = '1024';
     $config['max_height'] = '7680';
     $this->load->library('upload', $config);
     if (!$this->upload->do_upload()) {
         $error = array('error' => $this->upload->display_errors());
         $this->load->view('stock/stock_check/import_stock_count', $error);
     } else {
         $data = array('upload_data' => $this->upload->data());
         $file_path = $data['upload_data']['full_path'];
         $before_file_arr = $this->excel->csv_to_array($file_path);
         $output_data = array();
         $i = 0;
         $user_id = get_current_user_id();
         foreach ($before_file_arr as $row) {
             $i++;
             //$output_data["$number"] = sprintf(lang('start_number_note'), $number);
             $data = array();
             if ($i == 1 or $row[0] == '') {
                 continue;
             }
             $sku = $row[0];
             $product = $this->product_model->fetch_product_by_sku($sku);
             if ($product) {
                 $product_id = $product->id;
             } else {
                 $output_data[$row[0]] = $row[0] . ' not exist!';
                 continue;
             }
             $count = $row[1];
             //$shelf_code = trim($this->input->post('shelf_code_' . $i));
             //$stock_code = trim($this->input->post('stock_code_' . $i));
             $type = 'correct';
             $duty = '-1';
             $type_extra = '';
             $before_change_count = $this->product_model->fetch_product($product_id)->stock_count;
             if ($count < 0) {
                 continue;
             }
             $data = array('stock_count' => $count, 'stock_check_date' => get_current_time());
             $this->product_model->verify_product_stock($product_id, $data);
             $stock_data = array('product_id' => $product_id, 'user_id' => $user_id, 'before_change_count' => $before_change_count, 'change_count' => abs($count - $before_change_count), 'after_change_count' => $count, 'type' => $type, 'type_extra' => $type_extra, 'stock_type' => 'product_check_count');
             $this->stock_model->save_stock_check_or_count($stock_data);
             //$sku = $this->stock_model->get_one('product_basic', 'sku', array('id' => $product_id));
             if (abs($count - $before_change_count) != 0) {
                 $duty_data = array('sku' => $sku, 'stock_checker' => $user_id, 'differences_remark' => $type, 'remark' => $type_extra, 'before_change_count' => $before_change_count, 'change_count' => abs($count - $before_change_count), 'after_change_count' => $count, 'duty' => $duty, 'update_time' => get_current_time());
                 $this->stock_model->save_stock_check_duty($duty_data);
             }
             $output_data[$row[0]] = $row[1];
         }
         $data_page = array('data' => $output_data);
         $this->template->write_view('content', 'pi/import_product_success', $data_page);
         $this->template->render();
     }
 }
Esempio n. 23
0
     $statusID = 0;
 } else {
     $statusID = ostGetNewOrderStatus();
 }
 $currencyID = currGetCurrentCurrencyUnitID();
 if ($currencyID != 0) {
     $currentCurrency = currGetCurrencyByID($currencyID);
     $currency_code = $currentCurrency["currency_iso_3"];
     $currency_value = $currentCurrency["currency_value"];
     $currency_round = $currentCurrency["roundval"];
 } else {
     $currency_code = "";
     $currency_value = 1;
     $currency_round = 2;
 }
 $order_time = get_current_time();
 $customer_ip = stGetCustomerIP_Address();
 $sql = '
     INSERT INTO ' . ORDERS_TABLE . '
     SET
     customerID = 0,
     order_time = "' . xEscSQL($order_time) . '",
     customer_ip ="' . xToText($customer_ip) . '",
     customers_comment="' . xToText($comment) . '",
     statusID=' . (int) $statusID . ',
     order_amount="' . xEscSQL($offer['price']) . '",
     currency_code="' . xEscSQL($currency_code) . '",
     currency_value="' . (double) $currency_value . '",
     customer_firstname="' . $name . '",
     shipping_firstname="' . $name . '",
     billing_firstname="' . $name . '",
Esempio n. 24
0
 public function merge_order_for_auto_assign($order_id)
 {
     $order = $this->get_order($order_id);
     if (empty($order)) {
         return FALSE;
     }
     $epacket_shipping_code = 'H';
     $status = fetch_status_id('order_status', 'wait_for_confirmation');
     $can_merge_where = array('id !=' => $order_id, 'name' => $order->name, 'country' => $order->country, 'state_province' => $order->state_province, 'town_city' => $order->town_city, 'address_line_1' => $order->address_line_1, 'address_line_2' => $order->address_line_2, 'input_user' => $order->input_user, 'order_status' => $status, 'is_register !=' => $epacket_shipping_code, 'ebay_id' => $order->ebay_id);
     $this->db->select('*');
     $this->db->where($can_merge_where);
     $this->db->from('order_list');
     $query = $this->db->get();
     $to_merge_order = $query->row();
     if (empty($to_merge_order->id)) {
         return FALSE;
     }
     // starting merging
     if ($to_merge_order->currency == $order->currency) {
         $new_gross = $to_merge_order->gross + $order->gross;
         $new_fee = $to_merge_order->fee + $order->fee;
     } else {
         $tmp_rmb = calc_currency($order->currency, $order->gross);
         $new_gross = $to_merge_order->gross + price(to_foreigh_currency($to_merge_order->currency, $tmp_rmb));
         $tmp_rmb = calc_currency($order->currency, $order->fee);
         $new_fee = $to_merge_order->fee + price(to_foreigh_currency($to_merge_order->currency, $tmp_rmb));
     }
     echo "new gross: {$new_gross}\n";
     echo "new fee: {$new_fee}\n";
     echo "to merge gross: {$to_merge_order->gross}\n";
     echo "to merge fee: {$to_merge_order->fee}\n";
     echo "to merge currency: {$to_merge_order->currency}\n";
     echo "order gross: {$order->gross}\n";
     echo "order gross: {$order->fee}\n";
     echo "gross: {$order->currency}\n";
     $new_net = $new_gross - $new_fee;
     $new_title = $to_merge_order->item_title_str . ITEM_TITLE_SEP . $order->item_title_str;
     $new_id = $to_merge_order->item_id_str . ',' . $order->item_id_str;
     $new_sku_str = $to_merge_order->sku_str . ',' . $order->sku_str;
     $new_amount = $to_merge_order->qty_str . ',' . $order->qty_str;
     $sys_remark = $to_merge_order->sys_remark . ', ' . sprintf(lang('merge_log'), get_current_time(), $order->transaction_id);
     $data = array('gross' => $new_gross, 'fee' => $new_fee, 'net' => $new_net, 'item_title_str' => $new_title, 'item_id_str' => $new_id, 'sku_str' => $new_sku_str, 'qty_str' => $new_amount, 'sys_remark' => $sys_remark);
     $this->update('order_list', array('id' => $to_merge_order->id), $data);
     $this->db->insert('order_merged_list', array('transaction_id' => $order->transaction_id));
     $this->delete('order_list', array('id' => $order->id));
     if (!isset($this->CI->order_role_model)) {
         $this->CI->load->model('order_role_model');
     }
     $this->CI->order_role_model->add_order_role($order_id);
     $data = array('import_date' => get_current_time(), 'user_name' => lang('program'), 'descript' => sprintf(lang('merge_log'), get_current_time(), $order->transaction_id), 'user_login' => lang('program'));
     $this->import_log($data);
     echo 'auto merge: to merge id: ', $to_merge_order->id, "\n";
     return TRUE;
 }
Esempio n. 25
0
/**
 * @param int id The liveticker's id.
 * @param string code The passcode for the liveticker.
 * @return bool Whether or not the ticker is running after the toggle, or null if toggling failed.
 */
function toggle_ticker_running($id, $code)
{
    //this is only possible under the following circumstances:
    //
    //1. The current event hasn't started yet. In this case, the first half will be started.
    //
    //2. The current event is in overtime (either first or second half). in this case,
    //	 the event is going to be stopped. If it's in the second half's overtime, the
    //	 event is going to be marked as finished. TODO: if tie, ask for match extension
    //
    //3. the current event is in the half time break. In this case, the second half will be started.
    global $con;
    if (check_ticker_finished($id)) {
        error_log("ticker finished");
        return null;
        //disallow if finished
    }
    $curtime = get_current_time($id);
    if (check_ticker_running($id)) {
        //if ticker is running, it can only be toggled if in overtime
        if ($curtime["overtime"] == 0) {
            error_log("not in overtime");
            return null;
        }
    }
    $running = check_ticker_running($id);
    $new_running = !$running;
    $timestamp = time();
    $sql = "INSERT INTO timer VALUES (?, ?, ?)";
    $stmt = $con->prepare($sql);
    $stmt->bindParam(1, $id);
    $stmt->bindParam(2, $timestamp);
    $stmt->bindParam(3, $new_running);
    $stmt->execute();
    if (sizeof(get_timing_values($id)) >= 4) {
        $sql = "UPDATE tickers SET finished=1 WHERE id=?";
        $stmt = $con->prepare($sql);
        $stmt->bindParam(1, $id);
        $stmt->execute();
    }
    $sql = "UPDATE tickers SET running=? WHERE id=?";
    $stmt = $con->prepare($sql);
    $stmt->bindParam(1, $new_running);
    $stmt->bindParam(2, $id);
    $stmt->execute();
    error_log("ne running " . $new_running);
    return $new_running;
}
Esempio n. 26
0
 public function customer_second_glance_rate_check()
 {
     set_time_limit(0);
     $year = date('Y');
     $month = date('m', strtotime('-1 month'));
     $now = get_current_time();
     $rates = $this->order_model->fetch_currency();
     foreach ($rates as $rate) {
         $cur_rates[$rate->name_en] = $rate->ex_rate;
     }
     $user_amount = array();
     $saler_ids = $this->purchase_statistics_model->fetch_saler_id();
     foreach ($saler_ids as $saler_id) {
         $cur_m_total_amount = $this->purchase_statistics_model->fetch_cur_month_sales_total_amount($saler_id->saler_id);
         $amount_t = "";
         foreach ($cur_m_total_amount as $total) {
             $amount_t = $amount_t + $cur_rates[$total->currency] * $total->total_amount;
         }
         if (empty($amount_t)) {
             $amount_t = "0";
         }
         $user_amount[$saler_id->saler_id] = $amount_t;
         var_dump($saler_id);
     }
     var_dump($user_amount);
     foreach ($saler_ids as $saler_id) {
         $buyer_ids = $this->purchase_statistics_model->fetch_buyer_id_in_saler_id($saler_id->saler_id);
         if (empty($buyer_ids)) {
             $grance_amount[$saler_id->saler_id] = "0";
             continue;
         }
         $saler_amount_t = "";
         foreach ($buyer_ids as $buyer_id) {
             $chk_ksk = $this->purchase_statistics_model->check_second_ksk_in_past_six_month($buyer_id->buyer_id);
             if (count($chk_ksk) > 0) {
                 $saler_amounts = $this->purchase_statistics_model->fetch_amount_by_buyer_id($buyer_id->saler_id, $buyer_id->buyer_id);
                 if (!isset($chk_buyer_id)) {
                     $chk_buyer_id = "";
                 }
                 if ($buyer_id->buyer_id == $chk_buyer_id) {
                     continue;
                 }
                 foreach ($saler_amounts as $amount) {
                     $saler_amount_t = $saler_amount_t + $cur_rates[$amount->currency] * $amount->gross;
                 }
                 $chk_buyer_id = $buyer_id->buyer_id;
                 $grance_amount[$buyer_id->saler_id] = $saler_amount_t;
             } else {
                 $grance_amount[$buyer_id->saler_id] = "0";
             }
             var_dump($buyer_id);
         }
     }
     foreach ($user_amount as $key_saler_id => $month_total_amount) {
         $where = array('saler_id' => $key_saler_id, 'year' => $year, 'month' => $month);
         if ($this->stock_model->check_customer_second_glance_rate_exists($where)) {
             continue;
         }
         if ($month_total_amount == "0") {
             $rate = 0;
         } else {
             $rate = $grance_amount[$key_saler_id] / $month_total_amount;
         }
         $rate = number_format($rate, '4', '.', '');
         $data = array('year' => $year, 'month' => $month, 'second_glance_amount' => $grance_amount[$key_saler_id], 'totable_amount' => $month_total_amount, 'second_glance_rate' => $rate, 'saler_id' => $key_saler_id, 'created_date' => $now);
         $this->stock_model->save_customer_second_glance_rate($data);
     }
 }
Esempio n. 27
0
<?php

include_once dirname(__FILE__) . "/ressources/class.user.inc";
include_once dirname(__FILE__) . "/ressources/class.templates.inc";
if (isset($_GET["current-time"])) {
    get_current_time();
    exit;
}
if (isset($_GET["settings"])) {
    set_current_date_js();
    exit;
}
if (isset($_GET["date-settings"])) {
    set_current_date_page();
    exit;
}
if (isset($_GET["year"])) {
    save_currenttime();
    exit;
}
die("Wrong commands");
function set_current_date_js()
{
    $tpl = new templates();
    $title = $tpl->_ENGINE_parse_body('{server_time2}');
    $page = CurrentPageName();
    $user = new usersMenus();
    if (!$user->AsArticaAdministrator) {
        echo $tpl->_ENGINE_parse_body("alert('{ERROR_NO_PRIVS}')");
        die;
    }
Esempio n. 28
0
     Redirect(ADMIN_FILE . "?dpt=modules&sub=survey&save_successful=yes");
 }
 if (isset($_POST["save_voting"]) && isset($_POST["question"]) && isset($_POST["answers"])) {
     if (CONF_BACKEND_SAFEMODE) {
         Redirect(ADMIN_FILE . "?dpt=modules&sub=survey&safemode=yes");
     }
     $answers = explode("\n", chop($_POST["answers"]));
     $answers_cm = array();
     for ($i = 0; $i < count($answers); $i++) {
         if (rtrim($answers[$i]) !== "" && $i < 10) {
             $answers_cm[] = xToText(rtrim($answers[$i]));
         }
     }
     $answers = serialize($answers_cm);
     db_query("UPDATE " . SURVEY_TABLE . " SET active=0 WHERE active=1");
     db_query("insert into " . SURVEY_TABLE . " (poll_date, poll_title, poll_ans, active) values('" . xEscSQL(get_current_time()) . "','" . xToText(trim($_POST["question"])) . "','" . $answers . "',1)");
     Redirect(ADMIN_FILE . "?dpt=modules&sub=survey&save_successful=yes");
 }
 if (isset($_GET["start_new_poll"])) {
     $smarty->assign("start_new_poll", "yes");
 } else {
     $result = db_query("SELECT poll_title, all_poll, active, poll_id, poll_date FROM " . SURVEY_TABLE . " ORDER BY poll_id DESC");
     $surveys = array();
     while ($data = db_fetch_row($result)) {
         $data["poll_ans"] = unserialize($data["poll_ans"]);
         $surveys[] = $data;
         $smarty->assign("surveys", $surveys);
     }
 }
 //set sub-department template
 $smarty->assign("admin_sub_dpt", "modules_survey.tpl");
Esempio n. 29
0
 public function save_specification_download_url($download_url, $track_code)
 {
     $data = array('lable_download_url' => $download_url, 'input_date' => get_current_time());
     $this->db->where(array('track_number' => $track_code));
     $this->db->update('specification_epacket_confirm_list', $data);
 }
Esempio n. 30
0
<?php

// customer survey processing
if ((isset($_GET["save_voting_results"]) || isset($_GET["view_voting_results"])) && isset($_SESSION)) {
    $result = db_query("select poll_id, poll_title, poll_ans, ans_0, ans_1, ans_2, ans_3, ans_4,\n                ans_5, ans_6, ans_7, ans_8, ans_9, iplog, tdate FROM " . SURVEY_TABLE . " WHERE active=1");
    $data = db_fetch_row($result);
    if ($data["tdate"] != date('Y-m-d', time())) {
        db_query("UPDATE " . SURVEY_TABLE . " SET iplog='', tdate='" . xEscSQL(get_current_time()) . "'  WHERE active=1");
        $data["iplog"] = "";
    }
    $answers_results = unserialize($data["poll_ans"]);
    if ($data["iplog"] != "") {
        $iplogs = unserialize($data["iplog"]);
    } else {
        $iplogs = array();
    }
    $ipaddr = stGetCustomerIP_Address();
    if (!isset($iplogs[$ipaddr])) {
        $iplogs[$ipaddr] = 0;
    }
    //increase voters count for current option
    if ((!isset($_SESSION["vote_completed"][$data[0]]) || $_SESSION["vote_completed"][$data[0]] != 1) && isset($_GET["answer"]) && isset($answers_results[$_GET["answer"]]) && $iplogs[$ipaddr] < 3) {
        $anscol = (int) $_GET["answer"];
        $iplogs[$ipaddr]++;
        $iplogs = serialize($iplogs);
        db_query("UPDATE " . SURVEY_TABLE . " SET ans_" . $anscol . "=ans_" . $anscol . "+1, all_poll=all_poll+1, iplog='" . xEscSQL($iplogs) . "'  WHERE active=1");
        $data["ans_" . $anscol]++;
        //don't allow user to vote more than 1 time
        $_SESSION["vote_completed"][$data[0]] = 1;
    } else {
        if (!isset($_GET["view_voting_results"])) {