✏️ 正在编辑: AdminAxeptaRecurring.php
路径:
/home/bpioifn/www/pigmentse/modules/axepta/controllers/admin/AdminAxeptaRecurring.php
提示:
您可以编辑任何文件(包括二进制文件),但请注意不当修改可能导致文件损坏。
<?php /** * 1961-2019 BNP Paribas * * NOTICE OF LICENSE * * This source file is subject to the Open Software License (OSL 3.0) that is available * through the world-wide-web at this URL: http://www.opensource.org/licenses/OSL-3.0 * If you are unable to obtain it through the world-wide-web, please send an email * to modules@quadra-informatique.fr so we can send you a copy immediately. * * @author Quadra Informatique <modules@quadra-informatique.fr> * @copyright 1961-2019 BNP Paribas * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ class AdminAxeptaRecurringController extends ModuleAdminController { public function __construct() { $this->module = 'axepta'; $this->table = 'axepta_customer_payment_recurring'; $this->className = 'AxeptaCustomerPaymentRecurring'; $this->bootstrap = true; $this->add = false; $this->addRowAction('edit'); $this->list_no_link = false; $this->tab_modules_list = false; parent::__construct(); $this->context = Context::getContext(); $list_status = array( 1 => $this->l('Active'), 2 => $this->l('Paused'), ); $this->link = new Link(); $this->fields_list = array( 'id_axepta_customer_payment_recurring' => array( 'title' => $this->l('Id'), 'align' => 'left', 'type' => 'int', 'width' => 30, ), 'id_product' => array( 'title' => $this->l('Product ID'), 'align' => 'center', 'type' => 'int', 'width' => 128, 'callback' => 'getProductLink', 'search' => false, ), 'id_order' => array( 'title' => $this->l('Order Reference'), 'align' => 'center', 'type' => 'int', 'width' => 64, 'search' => false, 'callback' => 'getOrderLink' ), 'id_customer' => array( 'title' => $this->l('Customer ID'), 'align' => 'center', 'type' => 'string', 'width' => 64, 'search' => false, 'callback' => 'getCustomerLink' ), 'amount_tax_exclude' => array( 'title' => $this->l('Amount Tax excluded'), 'align' => 'center', 'type' => 'price', 'search' => false, 'width' => 64, ), 'status' => array( 'filter_key' => 'status', 'type' => 'select', 'list' => $list_status, 'filter_type' => 'int', 'title' => $this->l('Status'), 'align' => 'center', 'callback' => 'getStatusLabel' ), 'next_schedule' => array( 'title' => $this->l('Next schedule'), 'align' => 'center', 'type' => 'date', 'width' => 64, ), ); $this->bulk_actions = array( 'setpause' => array( 'text' => $this->l('Pause the recurring payment'), 'confirm' => $this->l('Change state for the selected items ?') ), 'setstop' => array( 'text' => $this->l('Stop the recurring payment'), 'confirm' => $this->l('Change state for the selected items ?') ), 'setactive' => array( 'text' => $this->l('Active the recurring payment'), 'confirm' => $this->l('Change state for the selected items ?') ), ); } /** * Return the order link * @param type $id_order * @param type $row * @return type */ public function getOrderLink($id_order) { $order = new Order((int)$id_order); return '<a href="'.$this->link->getAdminLink('AdminOrders').'&vieworder&id_order='.(int)$order->id.'">'.$order->reference.'</a>'; } /** * Return the customer link * @param type $id_customer * @param type $row * @return type */ public function getCustomerLink($id_customer) { $customer = new Customer((int)$id_customer); return '<a href="'.$this->link->getAdminLink('AdminCustomers').'&viewcustomer&id_customer='.(int)$customer->id.'">'.$customer->lastname.' '.$customer->firstname.'</a>'; } /** * Return the product link * @param type $id_product * @param type $row * @return type */ public function getProductLink($id_product) { $product_name = Product::getProductName($id_product); return '<a href="'.$this->link->getAdminLink('AdminProducts').'&updateproduct&id_product='.(int)$id_product.'">'.$product_name.'</a>'; } /** * Return the response message * @param type $code * @param type $row * @return type */ public function getStatusLabel($status) { $label = AxeptaCustomerPaymentRecurring::getStatus($status); if ($label) { return $label['name']; } return false; } public function renderForm() { $list_status = $this->getStatusList(); $this->fields_form = array( 'legend' => array( 'title' => $this->l('Axepta Recurring'), 'icon' => 'icon-file' ), 'input' => array( array( 'type' => 'hidden', 'label' => 'id', 'name' => 'id_axepta_customer_payment_recurring' ), array( 'name' => 'status', 'type' => 'select', 'options' => array( 'query' => $list_status, 'id' => 'status', 'name' => 'label' ), 'label' => $this->l('State'), 'desc' => $this->l('Change state') ), ), 'submit' => array( 'title' => $this->l('Save'), 'class' => 'btn btn-default' ) ); return parent::renderForm(); } public function renderList() { return parent::renderList(); } public function postProcess() { // Bulk actions if (Tools::isSubmit('submitBulksetpause'.$this->table)) { $array_id = Tools::getValue($this->table.'Box'); if ($array_id) { foreach ($array_id as $element) { $recurring_payment = new AxeptaCustomerPaymentRecurring((int)$element); $recurring_payment->status = 2; $recurring_payment->save(); } } } if (Tools::isSubmit('submitBulksetactive'.$this->table)) { $array_id = Tools::getValue($this->table.'Box'); if ($array_id) { foreach ($array_id as $element) { $recurring_payment = new AxeptaCustomerPaymentRecurring((int)$element); $recurring_payment->status = 1; $recurring_payment->save(); } } } if (Tools::isSubmit('submitBulksetstop'.$this->table)) { $array_id = Tools::getValue($this->table.'Box'); if ($array_id) { foreach ($array_id as $element) { $recurring_payment = new AxeptaCustomerPaymentRecurring((int)$element); $recurring_payment->status = 3; $recurring_payment->save(); $module = Module::getInstanceByName('axepta'); $customer = new Customer((int)$recurring_payment->id_customer); $order = new Order((int)$recurring_payment->id_order); if (Validate::isEmail($customer->email)) { $data = array( '{firstname}' => $customer->firstname, '{lastname}' => $customer->lastname, '{email}' => $customer->email, '{customer_id}' => $customer->id, '{order_reference}' => $order->reference, ); Mail::Send( (int)Context::getContext()->language->id, 'axepta_payment_recurring_stop_bo', Translate::getModuleTranslation( $module, 'Your reccuring payment has been stopped', 'axepta' ), $data, $customer->email, $customer->email, null, null, null, null, _PS_MODULE_DIR_.'/axepta/mails/' ); } } } } if (Tools::getValue('submitAddaxepta_customer_payment_recurring')) { if (Tools::getValue('status') && Tools::getValue('status') == 3) { $recurring_payment = new AxeptaCustomerPaymentRecurring((int)Tools::getValue('id_axepta_customer_payment_recurring')); if ($recurring_payment->id) { $module = Module::getInstanceByName('axepta'); $customer = new Customer((int)$recurring_payment->id_customer); $order = new Order((int)$recurring_payment->id_order); if (Validate::isEmail($customer->email)) { $data = array( '{firstname}' => $customer->firstname, '{lastname}' => $customer->lastname, '{email}' => $customer->email, '{customer_id}' => $customer->id, '{order_reference}' => $order->reference, ); Mail::Send( (int)Context::getContext()->language->id, 'axepta_payment_recurring_stop_bo', Translate::getModuleTranslation( $module, 'Your reccuring payment has been stopped', 'axepta' ), $data, $customer->email, $customer->email, null, null, null, null, _PS_MODULE_DIR_.'/axepta/mails/' ); } } } } return parent::postProcess(); } /** * No Toolbar * @return type */ public function initToolbar() { return false; } public function getStatusList() { $list_status = array(); $list_status[0]['status'] = 1; $list_status[0]['label'] = $this->l('Active'); $list_status[1]['status'] = 2; $list_status[1]['label'] = $this->l('Paused'); return $list_status; } }
💾 保存文件
← 返回文件管理器