function _updateStatus($id, $data) { global $osC_Database, $osC_Language, $orders_status_array; $error = false; $osC_Database->startTransaction(); $orders_status = osC_OrdersStatus_Admin::getData($data['status_id']); if ($orders_status['downloads_flag'] == 1) { osC_Order::activeDownloadables($id); } if ($orders_status['gift_certificates_flag'] == 1) { osC_Order::activeGiftCertificates($id); } if ($data['status_id'] == ORDERS_STATUS_CANCELLED && $data['restock_products'] == true) { $Qproducts = $osC_Database->query('select orders_products_id, products_id, products_type, products_quantity from :table_orders_products where orders_id = :orders_id'); $Qproducts->bindTable(':table_orders_products', TABLE_ORDERS_PRODUCTS); $Qproducts->bindInt(':orders_id', $id); $Qproducts->execute(); while ($Qproducts->next()) { $result = osC_Product::restock($id, $Qproducts->valueInt('orders_products_id'), $Qproducts->valueInt('products_id'), $Qproducts->valueInt('products_quantity')); if ($result == false) { $error = true; break; } } } $Qupdate = $osC_Database->query('update :table_orders set orders_status = :orders_status, last_modified = now() where orders_id = :orders_id'); $Qupdate->bindTable(':table_orders', TABLE_ORDERS); $Qupdate->bindInt(':orders_status', $data['status_id']); $Qupdate->bindInt(':orders_id', $id); $Qupdate->setLogging($_SESSION['module'], $id); $Qupdate->execute(); if (!$osC_Database->isError()) { $Qupdate = $osC_Database->query('insert into :table_orders_status_history (orders_id, orders_status_id, date_added, customer_notified, comments) values (:orders_id, :orders_status_id, now(), :customer_notified, :comments)'); $Qupdate->bindTable(':table_orders_status_history', TABLE_ORDERS_STATUS_HISTORY); $Qupdate->bindInt(':orders_id', $id); $Qupdate->bindInt(':orders_status_id', $data['status_id']); $Qupdate->bindInt(':customer_notified', $data['notify_customer'] === true ? '1' : '0'); $Qupdate->bindValue(':comments', $data['comment']); $Qupdate->setLogging($_SESSION['module'], $id); $Qupdate->execute(); if ($osC_Database->isError()) { $error = true; } if ($data['notify_customer'] === true) { $Qorder = $osC_Database->query('select o.customers_name, o.customers_email_address, s.orders_status_name, o.date_purchased from :table_orders o, :table_orders_status s where o.orders_status = s.orders_status_id and s.language_id = :language_id and o.orders_id = :orders_id'); $Qorder->bindTable(':table_orders', TABLE_ORDERS); $Qorder->bindTable(':table_orders_status', TABLE_ORDERS_STATUS); $Qorder->bindInt(':language_id', $osC_Language->getID()); $Qorder->bindInt(':orders_id', $id); $Qorder->execute(); require_once '../includes/classes/email_template.php'; $email_template = toC_Email_Template::getEmailTemplate('admin_order_status_updated'); $email_template->setData($id, osc_href_link(FILENAME_ACCOUNT, 'orders=' . $id, 'SSL', false, true, true), osC_DateTime::getLong($Qorder->value('date_purchased')), $data['append_comment'], $data['comment'], $Qorder->value('orders_status_name'), $Qorder->value('customers_name'), $Qorder->value('customers_email_address')); $email_template->buildMessage(); $email_template->sendEmail(); } } else { $error = true; } if ($error === false) { $osC_Database->commitTransaction(); return true; } $osC_Database->rollbackTransaction(); return false; }
<?php /* $Id: $ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright (c) 2007 osCommerce This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License v2 (1991) as published by the Free Software Foundation. */ $osC_ObjectInfo = new osC_ObjectInfo(osC_OrdersStatus_Admin::getData($_GET['osID'])); ?> <h1><?php echo osc_link_object(osc_href_link_admin(FILENAME_DEFAULT, $osC_Template->getModule()), $osC_Template->getPageTitle()); ?> </h1> <?php if ($osC_MessageStack->size($osC_Template->getModule()) > 0) { echo $osC_MessageStack->get($osC_Template->getModule()); } ?> <div class="infoBoxHeading"><?php echo osc_icon('trash.png') . ' ' . $osC_ObjectInfo->get('orders_status_name'); ?>
function __construct() { global $osC_Language, $osC_MessageStack; $this->_page_title = $osC_Language->get('heading_title'); if (!isset($_GET['action'])) { $_GET['action'] = ''; } if (!isset($_GET['page']) || isset($_GET['page']) && !is_numeric($_GET['page'])) { $_GET['page'] = 1; } if (!empty($_GET['action'])) { switch ($_GET['action']) { case 'save': if (isset($_GET['osID']) && is_numeric($_GET['osID'])) { $this->_page_contents = 'edit.php'; } else { $this->_page_contents = 'new.php'; } if (isset($_POST['subaction']) && $_POST['subaction'] == 'confirm') { $data = array('name' => $_POST['name']); if (osC_OrdersStatus_Admin::save(isset($_GET['osID']) ? $_GET['osID'] : null, $data, isset($_POST['default']) && $_POST['default'] == 'on' ? true : false)) { $osC_MessageStack->add($this->_module, $osC_Language->get('ms_success_action_performed'), 'success'); } else { $osC_MessageStack->add($this->_module, $osC_Language->get('ms_error_action_not_performed'), 'error'); } osc_redirect_admin(osc_href_link_admin(FILENAME_DEFAULT, $this->_module . '&page' . $_GET['page'])); } break; case 'delete': $this->_page_contents = 'delete.php'; if (isset($_POST['subaction']) && $_POST['subaction'] == 'confirm') { if (osC_OrdersStatus_Admin::delete($_GET['osID'])) { $osC_MessageStack->add($this->_module, $osC_Language->get('ms_success_action_performed'), 'success'); } else { $osC_MessageStack->add($this->_module, $osC_Language->get('ms_error_action_not_performed'), 'error'); } osc_redirect_admin(osc_href_link_admin(FILENAME_DEFAULT, $this->_module . '&page=' . $_GET['page'])); } break; case 'batchDelete': if (isset($_POST['batch']) && is_array($_POST['batch']) && !empty($_POST['batch'])) { $this->_page_contents = 'batch_delete.php'; if (isset($_POST['subaction']) && $_POST['subaction'] == 'confirm') { $error = false; foreach ($_POST['batch'] as $id) { if (!osC_OrdersStatus_Admin::delete($id)) { $error = true; break; } } if ($error === false) { $osC_MessageStack->add($this->_module, $osC_Language->get('ms_success_action_performed'), 'success'); } else { $osC_MessageStack->add($this->_module, $osC_Language->get('ms_error_action_not_performed'), 'error'); } osc_redirect_admin(osc_href_link_admin(FILENAME_DEFAULT, $this->_module . '&page=' . $_GET['page'])); } } break; } } }
function setStatus() { global $toC_Json, $osC_Language; $flag = $_REQUEST['flag']; $orders_status_id = $_REQUEST['orders_status_id']; $flag_name = $_REQUEST['flag_name']; if (osC_OrdersStatus_Admin::setStatus($orders_status_id, $flag_name, $flag)) { $response = array('success' => true, 'feedback' => $osC_Language->get('ms_success_action_performed')); } else { $response = array('success' => false, 'feedback' => $osC_Language->get('ms_error_action_not_performed')); } echo $toC_Json->encode($response); }