* @copyright 2014 Yuri Denisov * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) * International Registered Trademark & Property of PrestaShop SA */ class OrderInOneClick extends Module { public function __construct() { $this->name = 'orderinoneclick'; $this->tab = 'front_office_features'; $this->version = '1.2.0'; $this->author = 'Yuri Denisov'; $this->module_key = 'ac9b2f9b0fd746ba8b60d6f2b115f20f'; $this->need_instance = 0; $this->bootstrap = true; parent::__construct(); $this->_files = array( 'name' => array('mail_to_customer','mail_to_admin'), 'ext' => array( 0 => 'html', 1 => 'txt' ) ); $this->displayName = $this->l('Order In One Click (Quick order)'); $this->description = $this->l( 'Allows customers or guests to create a quick orders in one click. You can use as a service of pre-orders.' ); $this->ps_versions_compliancy = array('min' => '1.6', 'max' => _PS_VERSION_); $this->confirmUninstall = $this->l('Are you sure you want to uninstall?'); $this->arrayTypesOfAF = array('Address', 'Message', 'Date', 'Int', 'CityName', 'CountryName'); include_once dirname(__FILE__).'/OrderInOneClickClass.php'; } public function install() { if (Shop::isFeatureActive()) { Shop::setContext(Shop::CONTEXT_ALL); } foreach (Language::getLanguages(false) as $lang) { Configuration::updateValue('SM_ORDER_IN_ONE_CLICK_AF1_NAME_'.$lang['id_lang'], 'Additional field 1'); Configuration::updateValue('SM_ORDER_IN_ONE_CLICK_AF2_NAME_'.$lang['id_lang'], 'Additional field 2'); Configuration::updateValue('SM_ORDER_IN_ONE_CLICK_AF3_NAME_'.$lang['id_lang'], 'Additional field 3'); Configuration::updateValue('SM_ORDER_IN_ONE_CLICK_AF4_NAME_'.$lang['id_lang'], 'Additional field 4'); Configuration::updateValue('SM_ORDER_IN_ONE_CLICK_AF5_NAME_'.$lang['id_lang'], 'Additional field 5'); } return parent::install() && $this->registerHook('displayShoppingCartFooter') && $this->registerHook('displayHeader') && $this->registerHook('displayBackOfficeTop') && $this->registerHook('displayBackOfficeHeader') && $this->registerHook('displayProductButtons') && Db::getInstance()->Execute(' CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'sm_order_in_one_click` ( `id_oc_cart` INT(10) unsigned NOT NULL auto_increment, `archive` bool NOT NULL DEFAULT false, `viewed` bool NOT NULL DEFAULT false, `id_user` INT(10) unsigned NULL, `id_guest` INT(10) unsigned NULL, `id_currency` INT(10) unsigned NULL, `name` VARCHAR(160) NOT NULL, `email` VARCHAR(80) NOT NULL, `phone` VARCHAR(80) NOT NULL, `date` DATETIME NOT NULL, `order_price` DECIMAL(20,6) NOT NULL, `comment` MEDIUMTEXT DEFAULT NULL, `a_field1` VARCHAR(250) DEFAULT NULL, `a_field2` VARCHAR(250) DEFAULT NULL, `a_field3` VARCHAR(250) DEFAULT NULL, `a_field4` VARCHAR(250) DEFAULT NULL, `a_field5` VARCHAR(250) DEFAULT NULL, `a_field1_name` VARCHAR(250) DEFAULT NULL, `a_field2_name` VARCHAR(250) DEFAULT NULL, `a_field3_name` VARCHAR(250) DEFAULT NULL, `a_field4_name` VARCHAR(250) DEFAULT NULL, `a_field5_name` VARCHAR(250) DEFAULT NULL, PRIMARY KEY (`id_oc_cart`), KEY (`viewed`), KEY(`archive`)) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=utf8') && Db::getInstance()->Execute(' CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'sm_order_in_one_click_products` ( `id_oc_cart` INT(10) unsigned NOT NULL, `id_product` INT(10) unsigned NOT NULL, `id_product_attribute` INT(10) unsigned NULL, `cart_quantity` INT(10) unsigned NOT NULL, KEY (`id_oc_cart`)) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=utf8') && Db::getInstance()->Execute(' CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'sm_order_in_one_click_vouchers` ( `id_oc_cart` INT(10) unsigned NOT NULL, `id_voucher` INT(10) unsigned NOT NULL, KEY (`id_oc_cart`)) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=utf8') && Configuration::updateValue('SM_ORDER_IN_ONE_CLICK_SHOW', 3) && Configuration::updateValue('SM_ORDER_IN_ONE_CLICK_SEND_EMAIL', true) && Configuration::updateValue('SM_ORDER_IN_ONE_CLICK_SHOW_IN_TOP', true) && Configuration::updateValue('SM_ORDER_IN_ONE_CLICK_NOTIFY_EMAIL', null) && Configuration::updateValue('SM_ORDER_IN_ONE_CLICK_ALLOW_REGISTERED', true) && Configuration::updateValue('SM_ORDER_IN_ONE_CLICK_ALLOW_GUEST', true) && Configuration::updateValue('SM_ORDER_IN_ONE_CLICK_ALLOW_ONPPAGE', false) && Configuration::updateValue('SM_ORDER_IN_ONE_CLICK_CMS_ID', 0) && Configuration::updateValue('SM_ORDER_IN_ONE_CLICK_AF1_ENABLE', false) && Configuration::updateValue('SM_ORDER_IN_ONE_CLICK_AF2_ENABLE', false) && Configuration::updateValue('SM_ORDER_IN_ONE_CLICK_AF3_ENABLE', false) && Configuration::updateValue('SM_ORDER_IN_ONE_CLICK_AF4_ENABLE', false) && Configuration::updateValue('SM_ORDER_IN_ONE_CLICK_AF5_ENABLE', false) && Configuration::updateValue('SM_ORDER_IN_ONE_CLICK_AF1_REQUIRED', false) && Configuration::updateValue('SM_ORDER_IN_ONE_CLICK_AF2_REQUIRED', false) && Configuration::updateValue('SM_ORDER_IN_ONE_CLICK_AF3_REQUIRED', false) && Configuration::updateValue('SM_ORDER_IN_ONE_CLICK_AF4_REQUIRED', false) && Configuration::updateValue('SM_ORDER_IN_ONE_CLICK_AF5_REQUIRED', false) && Configuration::updateValue('SM_ORDER_IN_ONE_CLICK_AF1_TYPE', 'Message') && Configuration::updateValue('SM_ORDER_IN_ONE_CLICK_AF2_TYPE', 'Message') && Configuration::updateValue('SM_ORDER_IN_ONE_CLICK_AF3_TYPE', 'Message') && Configuration::updateValue('SM_ORDER_IN_ONE_CLICK_AF4_TYPE', 'Message') && Configuration::updateValue('SM_ORDER_IN_ONE_CLICK_AF5_TYPE', 'Message') && $this->context->cookie->{'submitFilter'.$this->name} = 1 && $this->context->cookie->{$this->name.'_pagination'} = 20; } public function uninstall() { unset($this->context->cookie->{$this->name.'_pagination'}); unset($this->context->cookie->{'submitFilter'.$this->name}); unset($this->context->cookie->{$this->name.'Orderby'}); unset($this->context->cookie->{$this->name.'Orderway'}); unset($this->context->cookie->{$this->name.'Filter_id_user'}); unset($this->context->cookie->{$this->name.'Filter_id_guest'}); unset($this->context->cookie->{$this->name.'Filter_name'}); unset($this->context->cookie->{$this->name.'Filter_email'}); unset($this->context->cookie->{$this->name.'Filter_phone'}); foreach (Language::getLanguages(false) as $lang) { Configuration::deleteByName('SM_ORDER_IN_ONE_CLICK_AF1_NAME_'.$lang['id_lang']); Configuration::deleteByName('SM_ORDER_IN_ONE_CLICK_AF2_NAME_'.$lang['id_lang']); Configuration::deleteByName('SM_ORDER_IN_ONE_CLICK_AF3_NAME_'.$lang['id_lang']); Configuration::deleteByName('SM_ORDER_IN_ONE_CLICK_AF4_NAME_'.$lang['id_lang']); Configuration::deleteByName('SM_ORDER_IN_ONE_CLICK_AF5_NAME_'.$lang['id_lang']); } return parent::uninstall() && Db::getInstance()->Execute('DROP TABLE IF EXISTS `'._DB_PREFIX_.'sm_order_in_one_click`') && Db::getInstance()->Execute('DROP TABLE IF EXISTS `'._DB_PREFIX_.'sm_order_in_one_click_products`') && Db::getInstance()->Execute('DROP TABLE IF EXISTS `'._DB_PREFIX_.'sm_order_in_one_click_vouchers`') && Configuration::deleteByName('SM_ORDER_IN_ONE_CLICK_SHOW') && Configuration::deleteByName('SM_ORDER_IN_ONE_CLICK_SEND_EMAIL') && Configuration::deleteByName('SM_ORDER_IN_ONE_CLICK_CMS_ID') && Configuration::deleteByName('SM_ORDER_IN_ONE_CLICK_NOTIFY_EMAIL') && Configuration::deleteByName('SM_ORDER_IN_ONE_CLICK_ALLOW_REGISTERED') && Configuration::deleteByName('SM_ORDER_IN_ONE_CLICK_ALLOW_GUEST') && Configuration::deleteByName('SM_ORDER_IN_ONE_CLICK_ALLOW_ONPPAGE') && Configuration::deleteByName('SM_ORDER_IN_ONE_CLICK_AF1_ENABLE') && Configuration::deleteByName('SM_ORDER_IN_ONE_CLICK_AF2_ENABLE') && Configuration::deleteByName('SM_ORDER_IN_ONE_CLICK_AF3_ENABLE') && Configuration::deleteByName('SM_ORDER_IN_ONE_CLICK_AF4_ENABLE') && Configuration::deleteByName('SM_ORDER_IN_ONE_CLICK_AF5_ENABLE') && Configuration::deleteByName('SM_ORDER_IN_ONE_CLICK_AF1_TYPE') && Configuration::deleteByName('SM_ORDER_IN_ONE_CLICK_AF2_TYPE') && Configuration::deleteByName('SM_ORDER_IN_ONE_CLICK_AF3_TYPE') && Configuration::deleteByName('SM_ORDER_IN_ONE_CLICK_AF4_TYPE') && Configuration::deleteByName('SM_ORDER_IN_ONE_CLICK_AF5_TYPE'); } public function hookDisplayHeader() { $this->context->controller->addCSS(($this->_path).'views/css/orderinoneclick.css', 'all'); } public function hookDisplayBackOfficeHeader() { $this->context->controller->addCSS(($this->_path).'views/css/orderinoneclick_admin.css', 'all'); } public function hookDisplayProductButtons() { $id_customer = $this->context->cart->id_customer; if ((int)Configuration::get('SM_ORDER_IN_ONE_CLICK_ALLOW_ONPPAGE') && ((int)Configuration::get('SM_ORDER_IN_ONE_CLICK_ALLOW_REGISTERED') && $id_customer || (int)Configuration::get('SM_ORDER_IN_ONE_CLICK_ALLOW_GUEST') && !$id_customer)) { $id_cms = (int)Configuration::get('SM_ORDER_IN_ONE_CLICK_CMS_ID'); if ($id_cms > 0) { $cmslinks = CMS::getLinks($this->context->language->id); foreach ($cmslinks as $link) { if ($link['id_cms'] == $id_cms) { $href_agree = $link['link']; } } $this->context->smarty->assign( array( 'href_agree' => $href_agree, ) ); } if ($id_customer) { $this->context->smarty->assign( array( 'customer_name' => $this->context->customer->firstname.' '.$this->context->customer->lastname, 'email' => $this->context->customer->email, 'orderinproductpage' => true, 'oc_currency_id' => $this->context->cart->id_currency, ) ); } else { $this->context->smarty->assign( array( 'orderinproductpage' => true, 'oc_currency_id' => $this->context->cart->id_currency, ) ); } $additional_fields = $this->getAdditionalFields(); $this->context->smarty->assign( array( 'additional_fields' => $additional_fields ) ); $result = $this->display(__FILE__, 'views/templates/front/orderinoneclick.tpl'); } else { $result = null; } return $result; } public function hookDisplayBackOfficeTop() { if (Configuration::get('SM_ORDER_IN_ONE_CLICK_SHOW_IN_TOP')) { $there_orders = OrderInOneClickCLass::numNewOrders(); if ($there_orders > 0) { $a_href = 'href="index.php?controller=AdminModules&token='. Tools::getAdminTokenLite('AdminModules').'&configure='.$this->name.'&show=1"'; $num_warn = ''.$there_orders.''; } else { $num_warn = ''; $a_href = 'href="index.php?controller=AdminModules&token='. Tools::getAdminTokenLite('AdminModules').'&configure='.$this->name.'&show=3"'; } $result = ' Quick '.$num_warn.' '; } else { $result = null; } return $result; } public function hookDisplayShoppingCartFooter() { $id_customer = $this->context->cart->id_customer; if ((int)Configuration::get('SM_ORDER_IN_ONE_CLICK_ALLOW_REGISTERED') && $id_customer || (int)Configuration::get('SM_ORDER_IN_ONE_CLICK_ALLOW_GUEST') && !$id_customer) { $lang_id = $this->context->language->id; $id_cms = (int)Configuration::get('SM_ORDER_IN_ONE_CLICK_CMS_ID'); if ($id_cms > 0) { $cmslinks = CMS::getLinks($lang_id); foreach ($cmslinks as $link) { if ($link['id_cms'] == $id_cms) { $href_agree = $link['link']; } } $this->context->smarty->assign( array( 'href_agree' => $href_agree, ) ); } if ($id_customer) { $this->context->smarty->assign( array( 'customer_name' => $this->context->customer->firstname.' '.$this->context->customer->lastname, 'email' => $this->context->customer->email, ) ); } $additional_fields = $this->getAdditionalFields(); $this->context->smarty->assign( array( 'additional_fields' => $additional_fields ) ); $result = $this->display(__FILE__, 'views/templates/front/orderinoneclick.tpl'); } else { $result = null; } return $result; } public function getContent() { $result = false; $message = ''; if (Tools::isSubmit('view'.$this->name)) { OrderInOneClickCLass::markAsViewed(Tools::getValue('id_oc_cart')); $result = $this->renderDetailViewOcCart(Tools::getValue('id_oc_cart')); } elseif (Tools::isSubmit('assigntocustomer'.$this->name)) { $id_oc_cart = (int)Tools::getValue('id_oc_cart'); $ic_customer = (int)Tools::getValue('id_customer'); if ($id_oc_cart && $ic_customer) { OrderInOneClickCLass::assignToCustomer($id_oc_cart, $ic_customer); } $result = $this->renderDetailViewOcCart($id_oc_cart); } elseif (Tools::isSubmit('addcustomer'.$this->name)) { $id_oc_cart = (int)Tools::getValue('id_oc_cart'); $new_customer_firstname = Tools::getValue('firstname'); $new_customer_lastname = Tools::getValue('lastname'); $new_customer_email = Tools::getValue('email'); $new_customer_password = Tools::getValue('passwd'); $error = true; $error_firstname = ''; $error_lastname = ''; $error_email = ''; $error_password = ''; if (!Validate::isName($new_customer_firstname)) { $error_firstname = $this->l('Customer firstname is incorrect'); $error = $error && false; } if (!$new_customer_firstname) { $error_firstname = $this->l('Customer firstname is empty'); $error = $error && false; } if (!Validate::isName($new_customer_lastname)) { $error_lastname = $this->l('Customer lastname is incorrect'); $error = $error && false; } if (!$new_customer_lastname) { $error_lastname = $this->l('Customer lastname is empty'); $error = $error && false; } if (!Validate::isEmail($new_customer_email)) { $error_email = $this->l('Email is incorrect'); $error = $error && false; } if (Validate::isEmail($new_customer_email) && Customer::customerExists($new_customer_email)) { $error_email = $this->l('Email is already exist in another customer'); $error = $error && false; } if (!$new_customer_email) { $error_email = $this->l('Email is empty'); $error = $error && false; } if (!Validate::isPasswd($new_customer_password)) { $error_password = $this->l('Password is incorrect'); $error = $error && false; } if (!$new_customer_password) { $error_password = $this->l('Password is empty'); $error = $error && false; } if ($error) { $customer = new Customer(); $customer->is_guest = true; $customer->firstname = $new_customer_firstname; $customer->lastname = $new_customer_lastname; $customer->email = $new_customer_email; $customer->transformToCustomer(Configuration::get('PS_LANG_DEFAULT'), $new_customer_password); $customer->add(); OrderInOneClickCLass::assignToCustomer($id_oc_cart, $customer->id); $message = '
'. ''. $this->l('New customer adding succesfully'). '
'; } else { $message = '
'. ''. $this->l('Error adding customer'). '
'; $this->context->smarty->assign( array( 'form_firstname' => $new_customer_firstname, 'form_lastname' => $new_customer_lastname, 'form_email' => $new_customer_email, 'form_passwd' => $new_customer_password, 'errorfirstname' => $error_firstname, 'errorlastname' => $error_lastname, 'erroremail' => $error_email, 'errorpasswd' => $error_password, ) ); } $result = $message.$this->renderDetailViewOcCart($id_oc_cart); } elseif (Tools::isSubmit('delete'.$this->name)) { $success = OrderInOneClickCLass::deleteOcCart(Tools::getValue('id_oc_cart')); if ($success) { $message = '
'. ''. $this->l('Orders deleted successfully'). '
'; } else { $message = '
'. ''. $this->l('Error deleting'). '
'; } } elseif (Tools::isSubmit('submitBulkdelete'.$this->name)) { $success = true; $bulk_del_oc_orders = Tools::getValue($this->name.'Box'); foreach ($bulk_del_oc_orders as $d_i) { $success = $success && OrderInOneClickCLass::deleteOcCart($d_i); } if ($success) { $message = '
'. ''. $this->l('Orders delete successfully'). '
'; } else { $message = '
'. ''. $this->l('Error deleting'). '
'; } } elseif (Tools::isSubmit('movetoarchive'.$this->name)) { $success = OrderInOneClickCLass::moveOcCartToArchive(Tools::getValue('id_oc_cart')); Configuration::updateValue('SM_ORDER_IN_ONE_CLICK_SHOW', 2); if ($success) { $message = '
'. ''. $this->l('Order moving successfully'). '
'; } else { $message = '
'. ''. $this->l('Error moving to archive'). '
'; } } elseif (Tools::isSubmit('removefromarchive'.$this->name)) { $success = OrderInOneClickCLass::removeOcCartFromArchive(Tools::getValue('id_oc_cart')); Configuration::updateValue('SM_ORDER_IN_ONE_CLICK_SHOW', 3); if ($success) { $message = '
'. ''. $this->l('Order removing from archive successfully'). '
'; } else { $message = '
'. ''. $this->l('Error moving from archive'). '
'; } } elseif (Tools::isSubmit('submitBulkmarkasviewed'.$this->name)) { $success = true; $bulk_move_oc_orders = Tools::getValue($this->name.'Box'); foreach ($bulk_move_oc_orders as $d_i) { $success = $success && OrderInOneClickCLass::markAsViewed($d_i); } if ($success) { $message = '
'. ''. $this->l('Orders moved to viewed successfully'). '
'; } else { $message = '
'. ''. $this->l('Error moving'). '
'; } Configuration::updateValue('SM_ORDER_IN_ONE_CLICK_SHOW', 3); } elseif (Tools::isSubmit('submitBulkmovetoarchive'.$this->name)) { $success = true; $bulk_move_oc_orders = Tools::getValue($this->name.'Box'); foreach ($bulk_move_oc_orders as $d_i) { $success = $success && OrderInOneClickCLass::moveOcCartToArchive($d_i); } if ($success) { $message = '
'. ''. $this->l('Orders moved successfully'). '
'; } else { $message = '
'. ''. $this->l('Error moving'). '
'; } Configuration::updateValue('SM_ORDER_IN_ONE_CLICK_SHOW', 2); } elseif (Tools::isSubmit('submitBulkremovefromarchive'.$this->name)) { $success = true; $bulk_move_oc_orders = Tools::getValue($this->name.'Box'); foreach ($bulk_move_oc_orders as $d_i) { $success = $success && OrderInOneClickCLass::removeOcCartFromArchive($d_i); } if ($success) { $message = '
'. ''. $this->l('Orders removed from archive successfully'). '
'; } else { $message = '
'. ''. $this->l('Error removing'). '
'; } Configuration::updateValue('SM_ORDER_IN_ONE_CLICK_SHOW', 3); } elseif (Tools::isSubmit('createorder'.$this->name)) { $id_oc_cart = Tools::getValue('id_cart'); $oc_cart = OrderInOneClickCLass::getOcCart($id_oc_cart); $new_cart = new Cart(); $new_cart->id_currency = $oc_cart['id_currency']; $new_cart->id_customer = $oc_cart['id_user']; $new_cart->add(); $oc_cart_products = OrderInOneClickCLass::getProductsFromOcCart($id_oc_cart); foreach ($oc_cart_products as $line_product) { $new_cart->updateQty( $line_product['cart_quantity'], $line_product['id_product'], $line_product['id_product_attribute'] ); } $cart_rules = OrderInOneClickCLass::getVouchersFromOcCart($id_oc_cart); if ($cart_rules) { foreach ($cart_rules as $rule) { $new_cart->addCartRule($rule['id_voucher']); } } OrderInOneClickCLass::moveOcCartToArchive($id_oc_cart); Tools::redirectAdmin( 'index.php?controller=AdminOrders&token='. Tools::getAdminTokenLite('AdminOrders'). '&id_cart='. $new_cart->id. '&addorder&' ); } elseif (Tools::isSubmit('configoptions'.$this->name)) { $helper = $this->renderConfig(); $helper->fields_value['show_in_top'] = (int)Configuration::get('SM_ORDER_IN_ONE_CLICK_SHOW_IN_TOP'); $helper->fields_value['send_email'] = (int)Configuration::get('SM_ORDER_IN_ONE_CLICK_SEND_EMAIL'); $helper->fields_value['show_agree_cms_page'] = (int)Configuration::get('SM_ORDER_IN_ONE_CLICK_CMS_ID'); $helper->fields_value['notify_email'] = Configuration::get('SM_ORDER_IN_ONE_CLICK_NOTIFY_EMAIL'); $helper->fields_value['allow_registered'] = (int)Configuration::get( 'SM_ORDER_IN_ONE_CLICK_ALLOW_REGISTERED' ); $helper->fields_value['allow_onppage'] = (int)Configuration::get('SM_ORDER_IN_ONE_CLICK_ALLOW_ONPPAGE'); $helper->fields_value['allow_guest'] = (int)Configuration::get('SM_ORDER_IN_ONE_CLICK_ALLOW_GUEST'); $result = $helper->generateForm($this->fields_form); } elseif (Tools::isSubmit('updatesettings'.$this->name)) { $res = Configuration::updateValue( 'SM_ORDER_IN_ONE_CLICK_SHOW_IN_TOP', (int)Tools::getValue('show_in_top') ? 1 : 0 ) && Configuration::updateValue( 'SM_ORDER_IN_ONE_CLICK_SEND_EMAIL', (int)Tools::getValue('send_email') ? 1 : 0 ) && Configuration::updateValue( 'SM_ORDER_IN_ONE_CLICK_ALLOW_REGISTERED', (int)Tools::getValue('allow_registered') ? 1 : 0 ) && Configuration::updateValue( 'SM_ORDER_IN_ONE_CLICK_ALLOW_GUEST', (int)Tools::getValue('allow_guest') ? 1 : 0 ) && Configuration::updateValue( 'SM_ORDER_IN_ONE_CLICK_ALLOW_ONPPAGE', (int)Tools::getValue('allow_onppage') ? 1 : 0 ) && Configuration::updateValue( 'SM_ORDER_IN_ONE_CLICK_CMS_ID', (int)Tools::getValue('show_agree_cms_page') ); $notify_email = Tools::truncate(Tools::getValue('notify_email'), 80); if (Validate::isEmail($notify_email)) { $res = $res && Configuration::updateValue('SM_ORDER_IN_ONE_CLICK_NOTIFY_EMAIL', $notify_email); } elseif (!$notify_email) { Configuration::updateValue('SM_ORDER_IN_ONE_CLICK_NOTIFY_EMAIL', null); } if ($res) { $message = '
'. '
'. ''. $this->l('Settings updated successfully'). '
'; } else { $message = '
'. '
'. ''. $this->l('Error in update settings'). '
'; } $helper = $this->renderConfig(); $helper->fields_value['show_in_top'] = (int)Configuration::get('SM_ORDER_IN_ONE_CLICK_SHOW_IN_TOP'); $helper->fields_value['send_email'] = (int)Configuration::get('SM_ORDER_IN_ONE_CLICK_SEND_EMAIL'); $helper->fields_value['show_agree_cms_page'] = (int)Configuration::get('SM_ORDER_IN_ONE_CLICK_CMS_ID'); $helper->fields_value['notify_email'] = Configuration::get('SM_ORDER_IN_ONE_CLICK_NOTIFY_EMAIL'); $helper->fields_value['allow_registered'] = (int)Configuration::get( 'SM_ORDER_IN_ONE_CLICK_ALLOW_REGISTERED' ); $helper->fields_value['allow_onppage'] = (int)Configuration::get('SM_ORDER_IN_ONE_CLICK_ALLOW_ONPPAGE'); $helper->fields_value['allow_guest'] = (int)Configuration::get('SM_ORDER_IN_ONE_CLICK_ALLOW_GUEST'); $result = $message.$helper->generateForm($this->fields_form); } elseif (Tools::isSubmit('addcomment'.$this->name)) { $id_oc_cart = Tools::getValue('id_oc_cart'); $oc_cart = new OrderInOneClickClass($id_oc_cart); $oc_cart->comment = Tools::getValue('comment'); $success = $oc_cart->save(); if ($success) { $message = '
'. ''. $this->l('Comment edited successfully'). '
'; } else { $message = '
'. ''. $this->l('Error edit comment'). '
'; } $result = $message.$this->renderDetailViewOcCart($id_oc_cart); } elseif (Tools::isSubmit('configfields'.$this->name)) { $result = $this->renderConfigAFields(); } elseif (Tools::isSubmit('findcustomer'.$this->name)) { $result = "В разработке"; } elseif (Tools::isSubmit('updateconfigfields'.$this->name)) { $success = true; foreach (Language::getLanguages(false) as $lang) { $current_value = Tools::getValue('af1_name_'.$lang['id_lang']); if ($current_value) { if (Validate::isCleanHtml($current_value)) { $success = $success && Configuration::updateValue( 'SM_ORDER_IN_ONE_CLICK_AF1_NAME_'.$lang['id_lang'], $current_value ); } else { $message = $message. '
'. ''. $this->l('Additional field 1 ').$lang['name'].$this->l(' Name is invalid'). '
'; $success = false; } } $current_value = Tools::getValue('af2_name_'.$lang['id_lang']); if ($current_value) { if (Validate::isCleanHtml($current_value)) { $success = $success && Configuration::updateValue( 'SM_ORDER_IN_ONE_CLICK_AF2_NAME_'.$lang['id_lang'], $current_value ); } else { $message = $message. '
'. ''. $this->l('Additional field 2 ').$lang['name'].$this->l(' Name is invalid'). '
'; $success = false; } } $current_value = Tools::getValue('af3_name_'.$lang['id_lang']); if ($current_value) { if (Validate::isCleanHtml($current_value)) { $success = $success && Configuration::updateValue( 'SM_ORDER_IN_ONE_CLICK_AF3_NAME_'.$lang['id_lang'], $current_value ); } else { $message = $message. '
'. ''. $this->l('Additional field 3 ').$lang['name'].$this->l(' Name is invalid'). '
'; $success = false; } } $current_value = Tools::getValue('af4_name_'.$lang['id_lang']); if ($current_value) { if (Validate::isCleanHtml($current_value)) { $success = $success && Configuration::updateValue( 'SM_ORDER_IN_ONE_CLICK_AF4_NAME_'.$lang['id_lang'], $current_value ); } else { $message = $message. '
'. ''. $this->l('Additional field 4 ').$lang['name'].$this->l(' Name is invalid'). '
'; $success = false; } } $current_value = Tools::getValue('af5_name_'.$lang['id_lang']); if ($current_value) { if (Validate::isCleanHtml($current_value)) { $success = $success && Configuration::updateValue( 'SM_ORDER_IN_ONE_CLICK_AF5_NAME_'.$lang['id_lang'], $current_value ); } else { $message = $message. '
'. ''. $this->l('Additional field 5 ').$lang['name'].$this->l(' Name is invalid'). '
'; $success = false; } } } $current_value = Tools::getValue('af1_type'); if (in_array($current_value, $this->arrayTypesOfAF)) { Configuration::updateValue('SM_ORDER_IN_ONE_CLICK_AF1_TYPE', $current_value); } else { $message = $message. '
'. ''. $this->l('Type of Additional field 1 is invalid'). '
'; $success = false; } $current_value = Tools::getValue('af2_type'); if (in_array($current_value, $this->arrayTypesOfAF)) { Configuration::updateValue('SM_ORDER_IN_ONE_CLICK_AF2_TYPE', $current_value); } else { $message = $message. '
'. ''. $this->l('Type of Additional field 2 is invalid'). '
'; $success = false; } $current_value = Tools::getValue('af3_type'); if (in_array($current_value, $this->arrayTypesOfAF)) { Configuration::updateValue('SM_ORDER_IN_ONE_CLICK_AF3_TYPE', $current_value); } else { $message = $message. '
'. ''. $this->l('Type of Additional field 3 is invalid'). '
'; $success = false; } $current_value = Tools::getValue('af4_type'); if (in_array($current_value, $this->arrayTypesOfAF)) { Configuration::updateValue('SM_ORDER_IN_ONE_CLICK_AF4_TYPE', $current_value); } else { $message = $message. '
'. ''. $this->l('Type of Additional field 4 is invalid'). '
'; $success = false; } $current_value = Tools::getValue('af5_type'); if (in_array($current_value, $this->arrayTypesOfAF)) { Configuration::updateValue('SM_ORDER_IN_ONE_CLICK_AF5_TYPE', $current_value); } else { $message = $message. '
'. ''. $this->l('Type of Additional field 5 is invalid'). '
'; $success = false; } $current_value = Tools::getValue('af1_enable'); if ($current_value == 1) { Configuration::updateValue('SM_ORDER_IN_ONE_CLICK_AF1_ENABLE', true); } elseif ($current_value == 0) { Configuration::updateValue('SM_ORDER_IN_ONE_CLICK_AF1_ENABLE', false); } else { $message = $message. '
'. ''. $this->l('Admin status of field 1 is invalid'). '
'; $success = false; } $current_value = Tools::getValue('af2_enable'); if ($current_value == 1) { Configuration::updateValue('SM_ORDER_IN_ONE_CLICK_AF2_ENABLE', true); } elseif ($current_value == 0) { Configuration::updateValue('SM_ORDER_IN_ONE_CLICK_AF2_ENABLE', false); } else { $message = $message. '
'. ''. $this->l('Admin status of field 2 is invalid'). '
'; $success = false; } $current_value = Tools::getValue('af3_enable'); if ($current_value == 1) { Configuration::updateValue('SM_ORDER_IN_ONE_CLICK_AF3_ENABLE', true); } elseif ($current_value == 0) { Configuration::updateValue('SM_ORDER_IN_ONE_CLICK_AF3_ENABLE', false); } else { $message = $message. '
'. ''. $this->l('Admin status of field 3 is invalid'). '
'; $success = false; } $current_value = Tools::getValue('af4_enable'); if ($current_value == 1) { Configuration::updateValue('SM_ORDER_IN_ONE_CLICK_AF4_ENABLE', true); } elseif ($current_value == 0) { Configuration::updateValue('SM_ORDER_IN_ONE_CLICK_AF4_ENABLE', false); } else { $message = $message. '
'. ''. $this->l('Admin status of field 4 is invalid'). '
'; $success = false; } $current_value = Tools::getValue('af5_enable'); if ($current_value == 1) { Configuration::updateValue('SM_ORDER_IN_ONE_CLICK_AF5_ENABLE', true); } elseif ($current_value == 0) { Configuration::updateValue('SM_ORDER_IN_ONE_CLICK_AF5_ENABLE', false); } else { $message = $message. '
'. ''. $this->l('Admin status of field 5 is invalid'). '
'; $success = false; } $current_value = Tools::getValue('af1_required'); if ($current_value == 1) { Configuration::updateValue('SM_ORDER_IN_ONE_CLICK_AF1_REQUIRED', true); } elseif ($current_value == 0) { Configuration::updateValue('SM_ORDER_IN_ONE_CLICK_AF1_REQUIRED', false); } else { $message = $message. '
'. ''. $this->l('"Require" status of field 1 is invalid'). '
'; $success = false; } $current_value = Tools::getValue('af2_required'); if ($current_value == 1) { Configuration::updateValue('SM_ORDER_IN_ONE_CLICK_AF2_REQUIRED', true); } elseif ($current_value == 0) { Configuration::updateValue('SM_ORDER_IN_ONE_CLICK_AF2_REQUIRED', false); } else { $message = $message. '
'. ''. $this->l('"Require" status of field 2 is invalid'). '
'; $success = false; } $current_value = Tools::getValue('af3_required'); if ($current_value == 1) { Configuration::updateValue('SM_ORDER_IN_ONE_CLICK_AF3_REQUIRED', true); } elseif ($current_value == 0) { Configuration::updateValue('SM_ORDER_IN_ONE_CLICK_AF3_REQUIRED', false); } else { $message = $message. '
'. ''. $this->l('"Require" status of field 3 is invalid'). '
'; $success = false; } $current_value = Tools::getValue('af4_required'); if ($current_value == 1) { Configuration::updateValue('SM_ORDER_IN_ONE_CLICK_AF4_REQUIRED', true); } elseif ($current_value == 0) { Configuration::updateValue('SM_ORDER_IN_ONE_CLICK_AF4_REQUIRED', false); } else { $message = $message. '
'. ''. $this->l('"Require" status of field 4 is invalid'). '
'; $success = false; } $current_value = Tools::getValue('af5_required'); if ($current_value == 1) { Configuration::updateValue('SM_ORDER_IN_ONE_CLICK_AF5_REQUIRED', true); } elseif ($current_value == 0) { Configuration::updateValue('SM_ORDER_IN_ONE_CLICK_AF5_REQUIRED', false); } else { $message = $message. '
'. ''. $this->l('"Require" status of field 5 is invalid'). '
'; $success = false; } if ($success) { $message = '
'. ''. $this->l('Configuration saved successfully'). '
'; } $result = $message.$this->renderConfigAFields(); } if (!$result) { $result = $message.$this->renderOrderList(); } return $result; } public function cutt($massiv, $page, $numofpage) { if ($page) { $start = $page * $numofpage - $numofpage - 1; } else { $start = 0; } for ($n = 0; $n <= $start; $n++) { array_shift($massiv); } $count_massiv = count($massiv); for ($n = ($start + $numofpage); $n < $count_massiv; $n++) { array_pop($massiv); } return $massiv; } public function renderDetailViewOcCart($id_cart) { if (Configuration::get('PS_TAX')) { $snoska = ' *'; $snoska1 = '
'. '* '. $this->l('Prices are inclusive of taxes'). '

'; } else { $snoska = null; $snoska1 = null; } $products_oc_cart = OrderInOneClickCLass::getProductsFromOcCart($id_cart); foreach ($products_oc_cart as $key => $curr_product) { if ($curr_product['id_product_attribute'] != 0) { $products_oc_cart[$key]['name'] .= OrderInOneClickCLass::getProductAttributeName( $curr_product['id_product'], $curr_product['id_product_attribute'], $this->context->language->id ); } $row_image = Image::getCover($curr_product['id_product']); $image = new Image($row_image['id_image']); $path_to_image = _PS_PROD_IMG_DIR_.$image->getExistingImgPath().'.'.$this->context->controller->imageType; $products_oc_cart[$key]['image'] = OrderInOneClickCLass::thumbnail( $path_to_image, 'product_mini_'.$curr_product['id_product'].'.'.$this->context->controller->imageType, 30, $this->context->controller->imageType ); $products_oc_cart[$key]['total'] = $curr_product['price'] * $curr_product['cart_quantity']; } $vouch_table = null; $vouchers = OrderInOneClickCLass::getVouchersFromOcCart($id_cart); if ($vouchers) { $voucher_list = array(); foreach ($vouchers as $key => $voucher) { $vouch = new CartRule($voucher['id_voucher']); $voucher_list[$key]['id_cart_rule'] = $voucher['id_voucher']; $voucher_list[$key]['name'] = $vouch->name[$this->context->language->id]; $voucher_list[$key]['code'] = $vouch->code; $voucher_list[$key]['description'] = $vouch->description; unset($vouch); } $list_discounts = new HelperList(); $list_discounts->shopLinkType = ''; $list_discounts->simple_header = true; $list_discounts->identifier = 'id_cart_rule'; $list_discounts->title = $this->l('List of used coupons'); $list_discounts->token = Tools::getAdminTokenLite('AdminCartRules'); $list_discounts->currentIndex = 'index.php?controller=AdminCartRules&token='. Tools::getAdminTokenLite('AdminCartRules').'&updatecart_rule'; $list_discounts_fields = array( 'name' => array( 'title' => $this->l('Name'), 'width' => 10, 'align' => 'center', 'type' => 'text', 'filter' => false, 'search' => false, 'orderby' => false, 'align' => 'center', ), 'description' => array( 'title' => $this->l('Description'), 'type' => 'text', 'filter' => false, 'search' => false, 'orderby' => false, 'align' => 'center', ), 'code' => array( 'title' => $this->l('Code'), 'width' => 10, 'type' => 'text', 'align' => 'center', 'filter' => false, 'search' => false, 'orderby' => false, 'align' => 'center', ), ); $vouch_table = $list_discounts->generateList($voucher_list, $list_discounts_fields); } $helper = new HelperList(); $helper->shopLinkType = ''; $helper->simple_header = true; $helper->identifier = 'id_product'; $helper->title = $this->l('List of Products from this "Quick" order'); $helper->table = $this->name; $helper->show_toolbar = true; $helper->token = Tools::getAdminTokenLite('AdminProducts'); $helper->currentIndex = 'index.php?controller=AdminProducts&token='. Tools::getAdminTokenLite('AdminOrders').'&updateproduct'; $helper->toolbar_btn = array( 'back' => array( 'href' => AdminController::$currentIndex.'&token='. Tools::getAdminTokenLite('AdminModules').'&configure='.$this->name, 'desc' => $this->l('Back to list Orders') ), ); $this->fields_list = array( 'id_product' => array( 'title' => $this->l('ID'), 'width' => 50, 'type' => 'text', 'filter' => false, 'search' => false, 'orderby' => false, 'align' => 'center', ), 'image' => array( 'title' => $this->l('Image'), 'align' => 'center', 'filter' => false, 'search' => false, 'orderby' => false, 'prefix' => '', ), 'name' => array( 'title' => $this->l('Name'), 'align' => 'center', 'filter' => false, 'search' => false, 'orderby' => false, 'type' => 'text', ), 'price' => array( 'title' => $this->l('Price (without discounts)'), 'align' => 'center', 'filter' => false, 'search' => false, 'orderby' => false, 'type' => 'price', ), 'cart_quantity' => array( 'title' => $this->l('Quantity'), 'align' => 'center', 'width' => 'auto', 'filter' => false, 'search' => false, 'orderby' => false, 'type' => 'text', ), 'available' => array( 'title' => $this->l('Available'), 'align' => 'center', 'width' => 'auto', 'filter' => false, 'search' => false, 'orderby' => false, 'type' => 'text', ), 'total' => array( 'title' => $this->l('Total (without discounts)').$snoska, 'align' => 'center', 'width' => 'auto', 'filter' => false, 'search' => false, 'orderby' => false, 'type' => 'price', ), ); $helper->listTotal = count($products_oc_cart); $oc_cart = new OrderInOneClickCLass($id_cart); if ($oc_cart->id_user) { $customer = new Customer($oc_cart->id_user); if ($customer->id) { $this->context->smarty->assign( array( 'customer_name' => $customer->firstname.' '.$customer->lastname, ) ); } } if (isset($oc_cart->email)) { if ($oc_cart->email != '') { $already_exist = Customer::customerExists($oc_cart->email, true); } else { $already_exist = ''; } } if ($already_exist && $oc_cart->id_guest) { $assigntocustomer = AdminController::$currentIndex.'&token='. Tools::getAdminTokenLite('AdminModules').'&configure='.$this->name. '&assigntocustomer'.$this->name.'&id_oc_cart='.$id_cart.'&id_customer='.$already_exist; } else { $assigntocustomer = ''; } $exist_customers = Customer::getCustomers(); $exist_c = null; foreach ($exist_customers as $key => $ex_customer) { $exist_c[$key]['id'] = $ex_customer['id_customer']; $exist_c[$key]['name'] = $ex_customer['firstname'].' '.$ex_customer['lastname'].', '.$ex_customer['email']; } $link_assigntoexist = AdminController::$currentIndex.'&token='.Tools::getAdminTokenLite('AdminModules'). '&configure='.$this->name.'&assigntocustomer'.$this->name.'&id_oc_cart='.$id_cart; $link_find_customer = AdminController::$currentIndex.'&token='.Tools::getAdminTokenLite('AdminModules'). '&configure='.$this->name.'&findcustomer'.$this->name.'&id_oc_cart='.$id_cart; if ($oc_cart->archive) { $this->context->smarty->assign( array( 'link_archive' => AdminController::$currentIndex.'&configure='.$this->name. '&token='.Tools::getAdminTokenLite('AdminModules'). '&removefromarchive'.$this->name.'&id_oc_cart='.$id_cart, 'desc_link_archive' => $this->l('Remove from the archive') ) ); } else { $this->context->smarty->assign( array( 'link_archive' => AdminController::$currentIndex.'&configure='.$this->name. '&token='.Tools::getAdminTokenLite('AdminModules').'&movetoarchive'.$this->name. '&id_oc_cart='.$id_cart, 'desc_link_archive' => $this->l('Move to the archive') ) ); } $additional_fields = array(); if ($oc_cart->a_field1) { $additional_fields[] = array( 'name' => $oc_cart->a_field1_name, 'value' => $oc_cart->a_field1, ); } if ($oc_cart->a_field2) { $additional_fields[] = array( 'name' => $oc_cart->a_field2_name, 'value' => $oc_cart->a_field2, ); } if ($oc_cart->a_field3) { $additional_fields[] = array( 'name' => $oc_cart->a_field3_name, 'value' => $oc_cart->a_field3, ); } if ($oc_cart->a_field4) { $additional_fields[] = array( 'name' => $oc_cart->a_field4_name, 'value' => $oc_cart->a_field4, ); } if ($oc_cart->a_field5) { $additional_fields[] = array( 'name' => $oc_cart->a_field5_name, 'value' => $oc_cart->a_field5, ); } $found_customer = Tools::getValue('found_customer') ? (int)Tools::getValue('found_customer') : null; $this->context->smarty->assign( array( 'id_cart' => $id_cart, 'date_cart' => $oc_cart->date, 'total' => Tools::displayPrice($oc_cart->order_price), 'id_customer' => $oc_cart->id_user, 'name' => $oc_cart->name, 'link_customer' => 'index.php?controller=AdminCustomers&token='. Tools::getAdminTokenLite('AdminCustomers').'&id_customer='.$oc_cart->id_user.'&viewcustomer', 'link_adduser' => AdminController::$currentIndex.'&configure='.$this->name. '&token='.Tools::getAdminTokenLite('AdminModules').'&addcustomer'.$this->name, 'link_createorder' => AdminController::$currentIndex.'&configure='.$this->name. '&token='.Tools::getAdminTokenLite('AdminModules').'&createorder'.$this->name.'&id_cart='.$id_cart, 'link_module' => dirname(__FILE__).'/orderinoneclick_sendorder.php', 'phone' => $oc_cart->phone, 'email' => $oc_cart->email, 'assigntocustomer' => $assigntocustomer, 'passwd' => Tools::passwdGen(), 'existscustomers' => $exist_c, 'link_assigntoexist' => $link_assigntoexist, 'link_delete' => AdminController::$currentIndex.'&configure='.$this->name. '&token='.Tools::getAdminTokenLite('AdminModules').'&delete'.$this->name.'&id_oc_cart='.$id_cart, 'additional_fields' => $additional_fields, 'found_customer' => $found_customer, 'link_find_customer' => $link_find_customer, ) ); $comment = '
'. ''.$this->l('Add comments to this "quick" order (not display for customer):').''. '
'. ''. '
'. '
'. ''. '
'. '
'; return $this->display(__FILE__, 'views/templates/admin/orderinoneclick_view.tpl'). $helper->generateList($products_oc_cart, $this->fields_list). $snoska1. $vouch_table. $comment; } public function renderOrderList() { $there_orders = OrderInOneClickCLass::numNewOrders(); if ($there_orders == 0 && Configuration::get('SM_ORDER_IN_ONE_CLICK_SHOW') == 1) { Configuration::updateValue('SM_ORDER_IN_ONE_CLICK_SHOW', 3); } if (Configuration::get('PS_TAX')) { $snoska = ' *'; $snoska1 = '
'. '* '. $this->l('Prices are inclusive of taxes').'
'; } else { $snoska = null; $snoska1 = null; } if (Tools::getValue('show')) { Configuration::updateValue('SM_ORDER_IN_ONE_CLICK_SHOW', (int)Tools::getValue('show')); $this->context->cookie->{'submitFilter'.$this->name} = 1; } if (Configuration::get('SM_ORDER_IN_ONE_CLICK_SHOW') == 1) { $but1 = 'btn-warning'; $but1_href = ''; $title = $this->l('List of new "Quick" Orders'); } else { $but1 = 'btn-info'; $but1_href = 'href="'.AdminController::$currentIndex.'&configure='.$this->name. '&token='.Tools::getAdminTokenLite('AdminModules').'&show=1"'; } if (Configuration::get('SM_ORDER_IN_ONE_CLICK_SHOW') == 2) { $but2 = 'btn-warning'; $but2_href = ''; $title = $this->l('List of archived "Quick" Orders'); } else { $but2 = 'btn-info'; $but2_href = 'href="'.AdminController::$currentIndex.'&configure='.$this->name. '&token='.Tools::getAdminTokenLite('AdminModules').'&show=2"'; } if (Configuration::get('SM_ORDER_IN_ONE_CLICK_SHOW') == 3) { $but3 = 'btn-warning'; $but3_href = ''; $title = $this->l('List of viewed "Quick" Orders'); } else { $but3 = 'btn-info'; $but3_href = 'href="'.AdminController::$currentIndex.'&configure='.$this->name. '&token='.Tools::getAdminTokenLite('AdminModules').'&show=3"'; } $buttons = '
'. ''. $this->l('New'). ' ('.$there_orders.')'. ''. $this->l('Viewed'). ' ('.OrderInOneClickCLass::numAllOrders().')'. ''. $this->l('Archive'). ' ('.OrderInOneClickCLass::numArchiveOrders().')'. ''.$this->l('Configuration').''. ''.$this->l('Additional fields').'
'; if (!$this->context->cookie->{$this->name.'Orderby'}) { $this->context->cookie->{$this->name.'Orderby'} = 'id_oc_cart'; } if (!$this->context->cookie->{$this->name.'Orderway'}) { $this->context->cookie->{$this->name.'Orderway'} = 'asc'; } if (Tools::isSubmit('submitReset'.$this->name)) { $this->context->cookie->{$this->name.'Orderby'} = 'id_oc_cart'; $this->context->cookie->{$this->name.'Orderway'} = 'asc'; $this->context->cookie->{$this->name.'Filter_id_user'} = null; $this->context->cookie->{$this->name.'Filter_id_guest'} = null; $this->context->cookie->{$this->name.'Filter_name'} = null; $this->context->cookie->{$this->name.'Filter_email'} = null; $this->context->cookie->{$this->name.'Filter_phone'} = null; } else { if (Tools::getValue($this->name.'Orderby') && Tools::getValue($this->name.'Orderway')) { $this->context->cookie->{$this->name.'Orderby'} = Tools::getValue($this->name.'Orderby'); $this->context->cookie->{$this->name.'Orderway'} = Tools::getValue($this->name.'Orderway'); } else { if (Tools::getValue($this->name.'_pagination')) { $this->context->cookie->{$this->name.'_pagination'} = Tools::getValue($this->name.'_pagination'); $this->context->cookie->{'submitFilter'.$this->name} = 1; } if (Tools::getValue('submitFilter'.$this->name)) { $this->context->cookie->{'submitFilter'.$this->name} = Tools::getValue('submitFilter'.$this->name); } $this->context->cookie->{$this->name.'Filter_id_user'} = (string)Tools::getValue( $this->name.'Filter_id_user' ); $this->context->cookie->{$this->name.'Filter_id_guest'} = (string)Tools::getValue( $this->name.'Filter_id_guest' ); $this->context->cookie->{$this->name.'Filter_name'} = (string)Tools::getValue( $this->name.'Filter_name' ); } } if (!$this->context->cookie->{$this->name.'_pagination'}) { $this->context->cookie->{$this->name.'_pagination'} = 20; } $helper = new HelperList(); $helper->shopLinkType = ''; $helper->simple_header = false; $helper->identifier = 'id_oc_cart'; $helper->title = $title; $helper->table = $this->name; $helper->show_toolbar = true; $helper->orderBy = $this->context->cookie->{$this->name.'Orderby'}; $helper->orderWay = Tools::strtoupper($this->context->cookie->{$this->name.'Orderway'}); $helper->toolbar_btn = array( 'back' => array( 'href' => AdminController::$currentIndex.'&token='.Tools::getAdminTokenLite('AdminModules'), 'desc' => $this->l('Back to Modules') ), ); $helper->token = Tools::getAdminTokenLite('AdminModules'); $helper->currentIndex = AdminController::$currentIndex.'&configure='.$this->name; $helper->actions = array('view','delete'); $this->fields_list = array( 'id_oc_cart' => array( 'title' => $this->l('ID'), 'width' => 50, 'type' => 'text', 'filter' => false, 'search' => false, 'orderby' => true, 'align' => 'center', ), 'id_user' => array( 'title' => $this->l('ID customer'), 'align' => 'center', 'width' => 70, 'filter' => false, 'search' => true, 'orderby' => true, 'type' => 'text', ), 'id_guest' => array( 'title' => $this->l('ID guest'), 'align' => 'center', 'width' => 50, 'filter' => false, 'search' => true, 'orderby' => true, 'type' => 'text' ), 'name' => array( 'title' => $this->l('Contact name'), 'align' => 'left', 'width' => 'auto', 'filter' => true, 'search' => true, 'orderby' => true, 'type' => 'text' ), 'date' => array( 'title' => $this->l('Date'), 'align' => 'center', 'width' => 100, 'filter' => false, 'search' => false, 'orderby' => true, 'type' => 'datetime' ), 'total' => array( 'title' => $this->l('Total').$snoska, 'align' => 'left', 'width' => 'auto', 'filter' => false, 'search' => false, 'orderby' => false, 'type' => 'price' ), ); $helper->bulk_actions = array( 'delete' => array( 'text' => $this->l('Delete selected'), 'confirm' => $this->l('Delete selected items?'), 'width' => 50, ), 'movetoarchive' => array( 'text' => $this->l('Move selected to the archive'), 'confirm' => $this->l('Move selected items?'), 'width' => 50, ), ); if (Configuration::get('SM_ORDER_IN_ONE_CLICK_SHOW') == 2) { $helper->bulk_actions = array( 'delete' => array( 'text' => $this->l('Delete selected'), 'confirm' => $this->l('Delete selected items?'), 'width' => 50, ), 'removefromarchive' => array( 'text' => $this->l('Remove selected from the archive'), 'confirm' => $this->l('Remove selected items?'), 'width' => 50, ), ); } if (Configuration::get('SM_ORDER_IN_ONE_CLICK_SHOW') == 1) { $helper->bulk_actions = array( 'delete' => array( 'text' => $this->l('Delete selected'), 'confirm' => $this->l('Delete selected items?'), 'width' => 50, ), 'movetoarchive' => array( 'text' => $this->l('Move selected to the archive'), 'confirm' => $this->l('Move selected items?'), 'width' => 50, ), 'markasviewed' => array( 'text' => $this->l('Mark as viewed'), 'confirm' => $this->l('Mark as viewed selected items?'), 'width' => 50, ), ); } $list_orders = OrderInOneClickCLass::getOrders( $helper->orderBy, $helper->orderWay, $this->context->cookie->{$this->name.'Filter_id_user'}, $this->context->cookie->{$this->name.'Filter_id_guest'}, $this->context->cookie->{$this->name.'Filter_name'}, Configuration::get('SM_ORDER_IN_ONE_CLICK_SHOW') ); $helper->listTotal = count($list_orders); if ($helper->listTotal <= $this->context->cookie->{$this->name.'_pagination'}) { $this->context->cookie->{'submitFilter'.$this->name} = 1; } $list_orders = $this->cutt( $list_orders, $this->context->cookie->{'submitFilter'.$this->name}, $this->context->cookie->{$this->name.'_pagination'} ); return $buttons.$helper->generateList($list_orders, $this->fields_list).$snoska1; } public function renderConfigAFields() { $languages = Language::getLanguages(false); $cf_helper = new HelperForm(); $cf_helper->module = $this; $cf_helper->name_controller = $this->name; $cf_helper->token = Tools::getAdminTokenLite('AdminModules'); $cf_helper->languages = $languages; $cf_helper->currentIndex = AdminController::$currentIndex.'&configure='.$this->name; $cf_helper->default_form_language = (int)Configuration::get('PS_LANG_DEFAULT'); $cf_helper->allow_employee_form_lang = true; $cf_helper->title = $this->displayName; $cf_helper->show_toolbar = true; $cf_helper->toolbar_scroll = true; $cf_helper->submit_action = 'submit'.$this->name; $cf_helper_fields = array(); $cf_helper_fields[0]['form'] = array( 'legend' => array( 'title' => $this->l('Configuration fields'), ), 'input' => array( array( 'type' => 'switch', 'label' => $this->l('Enable'), 'name' => 'af1_enable', 'values' => array( array( 'id' => 'active_on', 'value' => 1, ), array( 'id' => 'active_off', 'value' => 0, ) ), ), array( 'type' => 'switch', 'label' => $this->l('Required'), 'name' => 'af1_required', 'values' => array( array( 'id' => 'active_on', 'value' => 1, ), array( 'id' => 'active_off', 'value' => 0, ) ), ), array( 'type' => 'select', 'label' => $this->l('Field type'), 'name' => 'af1_type', 'options' => array( 'query' => array( array( 'id_option' => 'Address', 'name' => 'Address', ), array( 'id_option' => 'Message', 'name' => 'Generic Message', ), array( 'id_option' => 'Date', 'name' => 'Date', ), array( 'id_option' => 'Int', 'name' => 'Number', ), array( 'id_option' => 'CityName', 'name' => 'City', ), array( 'id_option' => 'CountryName', 'name' => 'Country', ), ), 'id' => 'id_option', 'name' => 'name' ) ), array( 'type' => 'text', 'label' => $this->l('Additional field 1 Name'), 'desc' => $this->l('Name will be show in frontend').'
', 'name' => 'af1_name', 'size' => 255, 'lang' => true, ), array( 'type' => 'switch', 'label' => $this->l('Enable'), 'name' => 'af2_enable', 'values' => array( array( 'id' => 'active_on', 'value' => 1, ), array( 'id' => 'active_off', 'value' => 0, ) ), ), array( 'type' => 'switch', 'label' => $this->l('Required'), 'name' => 'af2_required', 'values' => array( array( 'id' => 'active_on', 'value' => 1, ), array( 'id' => 'active_off', 'value' => 0, ) ), ), array( 'type' => 'select', 'label' => $this->l('Field type'), 'name' => 'af2_type', 'options' => array( 'query' => array( array( 'id_option' => 'Address', 'name' => 'Address', ), array( 'id_option' => 'Message', 'name' => 'Generic Message', ), array( 'id_option' => 'Date', 'name' => 'Date', ), array( 'id_option' => 'Int', 'name' => 'Number', ), array( 'id_option' => 'CityName', 'name' => 'City', ), array( 'id_option' => 'CountryName', 'name' => 'Country', ), ), 'id' => 'id_option', 'name' => 'name' ) ), array( 'type' => 'text', 'label' => $this->l('Additional field 2 Name'), 'desc' => $this->l('Name will be show in frontend').'
', 'name' => 'af2_name', 'size' => 255, 'lang' => true, ), array( 'type' => 'switch', 'label' => $this->l('Enable'), 'name' => 'af3_enable', 'values' => array( array( 'id' => 'active_on', 'value' => 1, ), array( 'id' => 'active_off', 'value' => 0, ) ), ), array( 'type' => 'switch', 'label' => $this->l('Required'), 'name' => 'af3_required', 'values' => array( array( 'id' => 'active_on', 'value' => 1, ), array( 'id' => 'active_off', 'value' => 0, ) ), ), array( 'type' => 'select', 'label' => $this->l('Field type'), 'name' => 'af3_type', 'options' => array( 'query' => array( array( 'id_option' => 'Address', 'name' => 'Address', ), array( 'id_option' => 'Message', 'name' => 'Generic Message', ), array( 'id_option' => 'Date', 'name' => 'Date', ), array( 'id_option' => 'Int', 'name' => 'Number', ), array( 'id_option' => 'CityName', 'name' => 'City', ), array( 'id_option' => 'CountryName', 'name' => 'Country', ), ), 'id' => 'id_option', 'name' => 'name' ) ), array( 'type' => 'text', 'label' => $this->l('Additional field 3 Name'), 'desc' => $this->l('Name will be show in frontend').'
', 'name' => 'af3_name', 'size' => 255, 'lang' => true, ), array( 'type' => 'switch', 'label' => $this->l('Enable'), 'name' => 'af4_enable', 'values' => array( array( 'id' => 'active_on', 'value' => 1, ), array( 'id' => 'active_off', 'value' => 0, ) ), ), array( 'type' => 'switch', 'label' => $this->l('Required'), 'name' => 'af4_required', 'values' => array( array( 'id' => 'active_on', 'value' => 1, ), array( 'id' => 'active_off', 'value' => 0, ) ), ), array( 'type' => 'select', 'label' => $this->l('Field type'), 'name' => 'af4_type', 'options' => array( 'query' => array( array( 'id_option' => 'Address', 'name' => 'Address', ), array( 'id_option' => 'Message', 'name' => 'Generic Message', ), array( 'id_option' => 'Date', 'name' => 'Date', ), array( 'id_option' => 'Int', 'name' => 'Number', ), array( 'id_option' => 'CityName', 'name' => 'City', ), array( 'id_option' => 'CountryName', 'name' => 'Country', ), ), 'id' => 'id_option', 'name' => 'name' ) ), array( 'type' => 'text', 'label' => $this->l('Additional field 4 Name'), 'desc' => $this->l('Name will be show in frontend').'
', 'name' => 'af4_name', 'size' => 255, 'lang' => true, ), array( 'type' => 'switch', 'label' => $this->l('Enable'), 'name' => 'af5_enable', 'values' => array( array( 'id' => 'active_on', 'value' => 1, ), array( 'id' => 'active_off', 'value' => 0, ) ), ), array( 'type' => 'switch', 'label' => $this->l('Required'), 'name' => 'af5_required', 'values' => array( array( 'id' => 'active_on', 'value' => 1, ), array( 'id' => 'active_off', 'value' => 0, ) ), ), array( 'type' => 'select', 'label' => $this->l('Field type'), 'name' => 'af5_type', 'options' => array( 'query' => array( array( 'id_option' => 'Address', 'name' => 'Address', ), array( 'id_option' => 'Message', 'name' => 'Generic Message', ), array( 'id_option' => 'Date', 'name' => 'Date', ), array( 'id_option' => 'Int', 'name' => 'Number', ), array( 'id_option' => 'CityName', 'name' => 'City', ), array( 'id_option' => 'CountryName', 'name' => 'Country', ), ), 'id' => 'id_option', 'name' => 'name' ) ), array( 'type' => 'text', 'label' => $this->l('Additional field 5 Name'), 'desc' => $this->l('Name will be show in frontend'), 'name' => 'af5_name', 'size' => 255, 'lang' => true, ), ), 'submit' => array( 'name' => 'updateconfigfields'.$this->name, 'title' => $this->l('Save settings'), 'class' => 'btn btn-warning pull-right' ), ); $cf_helper_fields[0]['form']['buttons'] = array( 'back' => array( 'href' => AdminController::$currentIndex.'&configure='.$this->name. '&token='.Tools::getAdminTokenLite('AdminModules'), 'title' => $this->l('Back to list Orders'), 'icon' => 'process-icon-back', 'class' => 'btn btn-default pull-left', ), ); $af1_name = array(); $af2_name = array(); $af3_name = array(); $af4_name = array(); $af5_name = array(); foreach (Language::getLanguages(false) as $lang) { $af1_name[$lang['id_lang']] = Configuration::get('SM_ORDER_IN_ONE_CLICK_AF1_NAME_'.$lang['id_lang']); $af2_name[$lang['id_lang']] = Configuration::get('SM_ORDER_IN_ONE_CLICK_AF2_NAME_'.$lang['id_lang']); $af3_name[$lang['id_lang']] = Configuration::get('SM_ORDER_IN_ONE_CLICK_AF3_NAME_'.$lang['id_lang']); $af4_name[$lang['id_lang']] = Configuration::get('SM_ORDER_IN_ONE_CLICK_AF4_NAME_'.$lang['id_lang']); $af5_name[$lang['id_lang']] = Configuration::get('SM_ORDER_IN_ONE_CLICK_AF5_NAME_'.$lang['id_lang']); } $cf_helper->tpl_vars = array( 'fields_value' => array( 'af1_name' => $af1_name, 'af1_required' => Configuration::get('SM_ORDER_IN_ONE_CLICK_AF1_REQUIRED'), 'af1_enable' => Configuration::get('SM_ORDER_IN_ONE_CLICK_AF1_ENABLE'), 'af1_type' => Configuration::get('SM_ORDER_IN_ONE_CLICK_AF1_TYPE'), 'af2_name' => $af2_name, 'af2_required' => Configuration::get('SM_ORDER_IN_ONE_CLICK_AF2_REQUIRED'), 'af2_enable' => Configuration::get('SM_ORDER_IN_ONE_CLICK_AF2_ENABLE'), 'af2_type' => Configuration::get('SM_ORDER_IN_ONE_CLICK_AF2_TYPE'), 'af3_name' => $af3_name, 'af3_required' => Configuration::get('SM_ORDER_IN_ONE_CLICK_AF3_REQUIRED'), 'af3_enable' => Configuration::get('SM_ORDER_IN_ONE_CLICK_AF3_ENABLE'), 'af3_type' => Configuration::get('SM_ORDER_IN_ONE_CLICK_AF3_TYPE'), 'af4_name' => $af4_name, 'af4_required' => Configuration::get('SM_ORDER_IN_ONE_CLICK_AF4_REQUIRED'), 'af4_enable' => Configuration::get('SM_ORDER_IN_ONE_CLICK_AF4_ENABLE'), 'af4_type' => Configuration::get('SM_ORDER_IN_ONE_CLICK_AF4_TYPE'), 'af5_name' => $af5_name, 'af5_required' => Configuration::get('SM_ORDER_IN_ONE_CLICK_AF5_REQUIRED'), 'af5_enable' => Configuration::get('SM_ORDER_IN_ONE_CLICK_AF5_ENABLE'), 'af5_type' => Configuration::get('SM_ORDER_IN_ONE_CLICK_AF5_TYPE'), ), ); $result = $cf_helper->generateForm($cf_helper_fields); return $result; } public function renderConfig() { $cms_tab = array( 0 => array( 'id' => 0, 'name' => $this->l('None'), ), ); foreach (CMS::listCms(Configuration::get('PS_LANG_DEFAULT')) as $cms_file) { $cms_tab[] = array('id' => $cms_file['id_cms'], 'name' => $cms_file['meta_title']); } $helper = new HelperForm(); $helper->module = $this; $helper->name_controller = $this->name; $helper->token = Tools::getAdminTokenLite('AdminModules'); $helper->currentIndex = AdminController::$currentIndex.'&configure='.$this->name; $helper->default_form_language = (int)Configuration::get('PS_LANG_DEFAULT'); $helper->allow_employee_form_lang = true; $helper->title = $this->displayName; $helper->show_toolbar = true; $helper->toolbar_scroll = true; $helper->submit_action = 'submit'.$this->name; $this->fields_form[0]['form'] = array( 'legend' => array( 'title' => $this->l('General settings'), ), 'input' => array( array( 'type' => 'switch', 'label' => $this->l('Show in backoffice top'), 'desc' => $this->l('Show icon that notifies of new orders'), 'name' => 'show_in_top', 'values' => array( array( 'id' => 'active_on', 'value' => 1, ), array( 'id' => 'active_off', 'value' => 0, ), ), ), array( 'type' => 'switch', 'label' => $this->l('Show on Product page'), 'desc' => $this->l( 'Experimental. Allows "quick order" directly on the product page. '. '(Tested only at the default template)' ), 'name' => 'allow_onppage', 'values' => array( array( 'id' => 'active_on', 'value' => 1, ), array( 'id' => 'active_off', 'value' => 0, ), ), ), array( 'type' => 'switch', 'label' => $this->l('Send email to customer (if known)'), 'name' => 'send_email', 'values' => array( array( 'id' => 'active_on', 'value' => 1, ), array( 'id' => 'active_off', 'value' => 0, ), ), ), array( 'type' => 'switch', 'label' => $this->l('Allow for registered users'), 'name' => 'allow_registered', 'values' => array( array( 'id' => 'active_on', 'value' => 1, ), array( 'id' => 'active_off', 'value' => 0, ), ), ), array( 'type' => 'switch', 'label' => $this->l('Allow for guest'), 'name' => 'allow_guest', 'values' => array( array( 'id' => 'active_on', 'value' => 1, ), array( 'id' => 'active_off', 'value' => 0, ), ), ), array( 'type' => 'select', 'label' => $this->l('CMS page for the Conditions of use'), 'desc' => $this->l('If NONE is selected that is not visible to the customer'), 'name' => 'show_agree_cms_page', 'options' => array( 'query' => $cms_tab, 'id' => 'id', 'name' => 'name' ), 'cast' => 'intval' ), array( 'type' => 'text', 'label' => $this->l('Notify the store administrator for a new order'), 'desc' => $this->l('Leave blank to disable option'), 'name' => 'notify_email', 'size' => 50, ), ), 'submit' => array( 'name' => 'updatesettings'.$this->name, 'title' => $this->l('Save settings'), 'class' => 'btn btn-warning pull-right' ), ); $this->fields_form[0]['form']['buttons'] = array( 'back' => array( 'href' => AdminController::$currentIndex.'&configure='.$this->name. '&token='.Tools::getAdminTokenLite('AdminModules'), 'title' => $this->l('Back to list Orders'), 'icon' => 'process-icon-back', 'class' => 'btn btn-default pull-left', ), ); return $helper; } private function getAdditionalFields() { $lang_id = $this->context->language->id; $additional_fields = array(); if (Configuration::get('SM_ORDER_IN_ONE_CLICK_AF1_ENABLE')) { $additional_fields[] = array( 'id' => 'af1', 'name' => Configuration::get('SM_ORDER_IN_ONE_CLICK_AF1_NAME_'.$lang_id), 'required' => Configuration::get('SM_ORDER_IN_ONE_CLICK_AF1_REQUIRED'), ); } if (Configuration::get('SM_ORDER_IN_ONE_CLICK_AF2_ENABLE')) { $additional_fields[] = array( 'id' => 'af2', 'name' => Configuration::get('SM_ORDER_IN_ONE_CLICK_AF2_NAME_'.$lang_id), 'required' => Configuration::get('SM_ORDER_IN_ONE_CLICK_AF2_REQUIRED'), ); } if (Configuration::get('SM_ORDER_IN_ONE_CLICK_AF3_ENABLE')) { $additional_fields[] = array( 'id' => 'af3', 'name' => Configuration::get('SM_ORDER_IN_ONE_CLICK_AF3_NAME_'.$lang_id), 'required' => Configuration::get('SM_ORDER_IN_ONE_CLICK_AF3_REQUIRED'), ); } if (Configuration::get('SM_ORDER_IN_ONE_CLICK_AF4_ENABLE')) { $additional_fields[] = array( 'id' => 'af4', 'name' => Configuration::get('SM_ORDER_IN_ONE_CLICK_AF4_NAME_'.$lang_id), 'required' => Configuration::get('SM_ORDER_IN_ONE_CLICK_AF4_REQUIRED'), ); } if (Configuration::get('SM_ORDER_IN_ONE_CLICK_AF5_ENABLE')) { $additional_fields[] = array( 'id' => 'af5', 'name' => Configuration::get('SM_ORDER_IN_ONE_CLICK_AF5_NAME_'.$lang_id), 'required' => Configuration::get('SM_ORDER_IN_ONE_CLICK_AF5_REQUIRED'), ); } return $additional_fields; } }