/** * Добавление трекинг номера к заказу * * @param type $order_id * @param type $privider * @return type */ function add($order_id, $provider, $tracknumber, $date = '', $city = '', $name = '') { require_once CLASSPATH . 'ps_orderlog.php'; $orderlog = new ps_orderlog(); $tracking = $this->getTracking($order_id); $dblog = new ps_DB(); $query = "SELECT provider FROM " . $this->_table; $query .= ' WHERE order_id = ' . $order_id; $dblog->query($query); $prev_provider = $dblog->loadResult($query); if (!$tracking) { $query = "INSERT INTO " . $this->_table; $WHERE = ''; } else { $query = "UPDATE " . $this->_table; $WHERE = ' WHERE order_id = ' . $order_id; } $query .= " SET order_id='" . $order_id . "', provider='" . $provider . "', tracknumber='" . $tracknumber . "', date='" . $date . "', city='" . $city . "', name='" . $name . "'"; $query .= $WHERE; $ret = $this->db->setQuery($query); $ret = $this->db->Query($query); if ($this->db->getErrorNum()) { echo $this->db->stderr(); return false; } if ($provider != $prev_provider) { $orderlog->saveLog($order_id, 'Изменение трекинга', '', $prev_provider, $provider); } return $ret; }
function changeShipping($order_id, $r) { global $VM_LANG, $vmLogger; require_once CLASSPATH . 'ps_orderlog.php'; $orderlog = new ps_orderlog(); $d = array(); $ship_method_id = $r['shipping_rate_id']; $ship_method_id = @urldecode($ship_method_id); $d["ship_method_id"] = $ship_method_id; $shipping_rate_id_ar = explode('|', $ship_method_id); //Inf Получение названия ТК $transportnaya_company = htmlspecialchars($r['transportnaya_company'], ENT_QUOTES); if (!empty($transportnaya_company)) { if ($shipping_rate_id_ar[1] == 'Доставка транспортной компанией') { $shipping_rate_id_ar[2] .= $transportnaya_company; } $d["ship_method_id"] = implode('|', $shipping_rate_id_ar); } $d['order_shipping'] = $shipping_rate_id_ar[3]; $db = new ps_DB(); $q = "SELECT ship_method_id FROM #__{vm}_orders WHERE order_id = '" . $order_id . "'"; $db->query($q); $prev_ship_method_id = $db->loadResult(); $db->buildQuery('UPDATE', '#__{vm}_orders', $d, ' WHERE order_id=' . $order_id); $result = $db->query(); $ps_order_change = new ps_order_change($order_id); $ps_order_change->recalc_order($order_id); if ($prev_ship_method_id != $ship_method_id) { $orderlog->saveLog($order_id, 'Изменение варианта доставки', '', $prev_ship_method_id, $ship_method_id); } }