<?php define('APP_ROOT', "../"); require_once APP_ROOT . "/config/main.php"; require_once APP_ROOT . "/common/commonFunctions.php"; $orderId = $_GET['orderId']; $order = new Cart($orderId); if (isset($_POST['newStatus'])) { $order->changeStatus($npshop['constants']["ORDER_STATUS"][$_POST['newStatus']], null, false); } $user = new User(); $user->_dbLoad($order->user->id); showSkin("admin_" . basename(__FILE__));
$user->password = $_POST['newPassword1']; } else { if ($_POST['newPassword1'] != null || $_POST['newPassword2'] != null) { $msgError = _("Los passwords introducidos no coinciden. No se grabaron los datos."); } } if ($msgError == null) { $user->_dbUpdate(); $user = new User(); $user->_dbLoad($id); } } else { if (isset($_GET["userId"])) { $id = $_GET['userId']; $user = new User(); $user->_dbLoad($id); } } $provinces = array("-1" => "-"); function fetchProvinces($data) { global $provinces; $provinces[$data['PVC_CO_CODIGO']] = $data['PVC_VA_NOMBRE']; } global $ddbb; $sqlProvinces = "SELECT * FROM NPS_PROVINCIAS ORDER BY 2"; $ddbb->executeSelectQuery($sqlProvinces, "fetchProvinces"); $countries = array(); $sqlCountries = "SELECT * FROM NPS_PAISES ORDER BY ISO3"; function fetchCountries($data) {
function changeStatus($status, $tpvData = null, $sendMail = true) { global $ddbb, $npshop; // status changes history if ($this->orderStatus != $status) { $this->orderStatus = $status; if ($this->statusHistory == null || trim($this->statusHistory == "")) { $this->statusHistory = ""; } else { $this->statusHistory .= " @ "; } $this->statusHistory .= "[" . date("d/m/Y H:i:s") . " : " . $this->orderStatus . "]"; } if ($tpvData != null && trim($tpvData) != "") { $tpvData = "[" . trim($tpvData) . "]"; if (isset($this->tpvData) && $this->tpvData != null) { $tpvData = $this->tpvData . " @ " . $tpvData; } $this->tpvData = $tpvData; } /*$sql = "UPDATE ".$ddbb->getTable("Cart"). " SET ".$ddbb->getMapping('Cart','orderStatus')."=".NP_DDBB::encodeSQLValue($status, $ddbb->getType('Cart','orderStatus')).", ". $ddbb->getMapping('Cart','statusHistory')."=".NP_DDBB::encodeSQLValue($this->statusHistory, $ddbb->getType('Cart','statusHistory')).", ". $ddbb->getMapping('Cart','date')."=".NP_DDBB::encodeSQLValue($this->date, $ddbb->getType('Cart','date')); if ($tpvData != null) { $this->tpvData = $tpvData; update_cart($this); $sql.= ", ".$ddbb->getMapping('Cart','tpvData')."=".NP_DDBB::encodeSQLValue($tpvData, $ddbb->getType('Cart','tpvData')); } $sql.= " WHERE ".$ddbb->getMapping('Cart','orderId')."=".NP_DDBB::encodeSQLValue($this->orderId, $ddbb->getType('Cart','orderId')); $ddbb->executeInsertUpdateQuery($sql);*/ $ddbb->updateObject($this); if ($status == $npshop['constants']['ORDER_STATUS']['PAYMENT_OK'] || $status == $npshop["constants"]["ORDER_STATUS"]["PAYMENT_TRANSFER"] || $status == $npshop["constants"]["ORDER_STATUS"]["PENDING_SENT_ONDELIVERY"]) { foreach ($this->items as $item) { $item->addToStock(-1 * $item->quantity); } } update_cart($this); if ($sendMail) { $user = new User(); $user->_dbLoad($this->user->id); $statusKey = array_search($status, $npshop['constants']['ORDER_STATUS']); $mailContent = $this->_buildMail(); if ($statusKey == "PAYMENT_OK" || $statusKey == "PAYMENT_TRANSFER" || $statusKey == "PENDING_SENT_ONDELIVERY") { sendHTMLMail($npshop['constants']['EMAIL_FROM'], $user->email, $npshop['constants']['EMAIL_SUBJECT'] . $this->orderId, $mailContent); sendHTMLMail($npshop['constants']['EMAIL_FROM'], $npshop['constants']['EMAIL_NOTIFICATION'], $npshop['constants']['EMAIL_SUBJECT'] . $this->orderId, $mailContent); } sendHTMLMail($npshop['constants']['EMAIL_FROM'], $npshop['constants']['EMAIL_DEBUG'], "DEBUG (DavidBenavente): " . $npshop['constants']['EMAIL_SUBJECT'] . $this->orderId, $mailContent); } }