pinarello Posted February 25, 2014 Share Posted February 25, 2014 in a few words I could put in my order detail fieldset with the admin buttons. I tapped, after creating a form, a hook in order detail, and inserted the code in my file. tpl; Now my problem is how do you take such id_order to spend it with my button to another page with PHP? I have to override the controller admin_order? thanks Link to comment Share on other sites More sharing options...
pinarello Posted February 27, 2014 Author Share Posted February 27, 2014 <?php /* * ---------------------------------------------------------------------------- * "THE BEER-WARE LICENSE" (Revision 42): * <[email protected]> wrote this module. As long as you retain this notice you * can do whatever you want with this stuff. If we meet some day, and you think * this stuff is worth it, you can buy me a beer in return. Jevin O. Sewaruth. * ---------------------------------------------------------------------------- */ if (!defined('_PS_VERSION_')) exit; class Skeleton extends module { public function __construct() { $this->name = 'skeleton'; $this->tab = 'front_office_features'; $this->version = '1.0'; $this->author = 'Jevin O. Sewaruth'; parent::__construct(); $this->displayName = $this->l('Skeleton Module'); $this->description = $this->l('This is just an empty module. You should modify it to make your own.'); $this->confirmUninstall = $this->l('Are you sure you want to uninstall this module?'); $this->_checkContent(); $this->context->smarty->assign('module_name', $this->name); } public function install() { if (!parent::install() || !$this->registerHook('displayHeader') || !$this->registerHook('displayLeftColumn') || !$this->registerHook('displayRightColumn') || !$this->registerHook('displayFooter') || !$this->registerHook('displayAdminOrder') || !$this->_createContent()) return false; return true; } public function uninstall() { if (!parent::uninstall() || !$this->_deleteContent()) return false; return true; } //Nel dettaglio ordine Admin /* public function hookDisplayAdminOrder () { return 'BUTTON BACKOFFICE'; } */ //$order = new Order((int)Tools::getValue('id_order')); // $ordine = new Order($id_order); public function hookDisplayAdminOrder($params) //$ordine = new Order($id_order); { //$this->context->smarty->assign('cantidad2', $cantidad); $order = new Order((int)Tools::getValue('id_order')); $this->context->smarty->assign( array( 'my_module_name' => Configuration::get('MYMODULE_NAME'), 'my_module_link' => $this->context->link->getModuleLink('skeleton', 'display'), 'my_module_message' => $this->l('This is a simple text message'), 'numero_ordine' => $this->l('numero di ordine'), 'id_order' => $order ) ); return $this->display(__FILE__, 'order.tpl'); } //$aleatorio = rand(1,10); //$this->context->smarty->assign('numeroaleatorio', $aleatorio); //$aleatorio = rand(1,10); //$smarty->assign('numeroaleatorio', $aleatorio); public function hookDisplayHeader() { $this->context->controller->addCSS($this->_path.'css/style.css', 'all'); $this->context->controller->addJS($this->_path.'js/script.js', 'all'); } public function hookDisplayLeftColumn() { $this->context->smarty->assign(array( 'placement' => 'left', )); return $this->display(__FILE__, 'left.tpl'); } public function hookDisplayRightColumn() { $this->context->smarty->assign(array( 'placement' => 'right', )); return $this->display(__FILE__, 'right.tpl'); } public function hookDisplayFooter() { $this->context->smarty->assign(array( 'module_link' => $this->context->link->getModuleLink('skeleton', 'details'), )); return $this->display(__FILE__, 'footer.tpl'); } public function getContent() { $message = ''; if (Tools::isSubmit('submit_'.$this->name)) $message = $this->_saveContent(); $this->_displayContent($message); return $this->display(__FILE__, 'settings.tpl'); } private function _saveContent() { $message = ''; if (Configuration::updateValue('MOD_SKELETON_NAME', Tools::getValue('MOD_SKELETON_NAME')) && Configuration::updateValue('MOD_SKELETON_COLOR', Tools::getValue('MOD_SKELETON_COLOR'))) $message = $this->displayConfirmation($this->l('Your settings have been saved')); else $message = $this->displayError($this->l('There was an error while saving your settings')); return $message; } private function _displayContent($message) { $this->context->smarty->assign(array( 'message' => $message, 'MOD_SKELETON_NAME' => Configuration::get('MOD_SKELETON_NAME'), 'MOD_SKELETON_COLOR' => Configuration::get('MOD_SKELETON_COLOR'), )); } private function _checkContent() { if (!Configuration::get('MOD_SKELETON_NAME') && !Configuration::get('MOD_SKELETON_COLOR')) $this->warning = $this->l('You need to configure this module.'); } private function _createContent() { if (!Configuration::updateValue('MOD_SKELETON_NAME', '') || !Configuration::updateValue('MOD_SKELETON_COLOR', '')) return false; return true; } private function _deleteContent() { if (!Configuration::deleteByName('MOD_SKELETON_NAME') || !Configuration::deleteByName('MOD_SKELETON_COLOR')) return false; return true; } } ?> This is my module code.....by Skeleton whith my Hook and after i have my controller: <?php /* * 2007-2013 PrestaShop * * NOTICE OF LICENSE */ class AdminCarrierRaf extends AdminOrdersControllerCore{ public function __construct() { $this->table = 'order'; $this->className = 'Order'; $this->lang = false; $this->addRowAction('view'); $this->explicitSelect = true; $this->allow_export = true; $this->deleted = false; $this->context = Context::getContext(); $this->_select = ' a.id_currency, a.id_order AS id_pdf, CONCAT(LEFT(c.`firstname`, 1), \'. \', c.`lastname`) AS `customer`, osl.`name` AS `osname`, os.`color`, IF((SELECT COUNT(so.id_order) FROM `'._DB_PREFIX_.'orders` so WHERE so.id_customer = a.id_customer) > 1, 0, 1) as new'; $this->_join = ' LEFT JOIN `'._DB_PREFIX_.'customer` c ON (c.`id_customer` = a.`id_customer`) LEFT JOIN `'._DB_PREFIX_.'order_state` os ON (os.`id_order_state` = a.`current_state`) LEFT JOIN `'._DB_PREFIX_.'order_state_lang` osl ON (os.`id_order_state` = osl.`id_order_state` AND osl.`id_lang` = '.(int)$this->context->language->id.')'; $this->_orderBy = 'id_order'; $this->_orderWay = 'DESC'; $this->shopLinkType = 'shop'; if (Tools::isSubmit('id_order')) { // Save context (in order to apply cart rule) $order = new Order((int)Tools::getValue('id_order')); if (!Validate::isLoadedObject($order)) throw new PrestaShopException('Cannot load Order object'); $this->context->cart = new Cart($order->id_cart); $this->context->customer = new Customer($order->id_customer); } parent::__construct(); } public function displayContent() { global $cart; $order = new Order((int)Tools::getValue('id_order')); self::$smarty->assign('orderTotal', ($cart->getOrderTotal() / 1.24) - $cart->getOrderShippingCost()); $order = new Order($this->id_order); $cart = new Cart($order->id_cart); $description=""; foreach ($cart->getProducts() AS $k=>$v){ $description.=$v['name']."X".$v['quantity']; } $description=urlencode($description); $this->context->smarty->assign(array( 'total_to_pay'=>$order->getOrdersTotalPaid(), 'description'=>$description )); parent::displayContent(); } public function generateInvoicePDFByIdOrder($id_order) { $order = new Order((int)$id_order); if (!Validate::isLoadedObject($order)) die(Tools::displayError('The order cannot be found within your database.')); $order_invoice_list = $order->getInvoicesCollection(); Hook::exec('actionPDFInvoiceRender', array('order_invoice_list' => $order_invoice_list)); $this->generatePDF($order_invoice_list, PDF::TEMPLATE_INVOICE); } public function processGenerateInvoicesPDF() { $order_invoice_collection = OrderInvoice::getByDateInterval(Tools::getValue('date_from'), Tools::getValue('date_to')); if (!count($order_invoice_collection)) die(Tools::displayError('No invoice was found.')); $this->generatePDF($order_invoice_collection, PDF::TEMPLATE_INVOICE); } } but I can not figure out which class method adminOrdersController I have to implement in order to pass my variable in the template file this order.tpl <script type="text/javascript"> </script> <br /> <fieldset> <legend><img src="../img/admin/tab-customers.gif" />{l s='Esportazione LDV'}</legend> <table class="table" width="100%;" cellspacing="0" cellpadding="0" id="documents_table"> <thead> <tr> <th style="width:10%">{l s='Date'}</th> <th style="">{l s='Document'}</th> <th style="width:20%">{l s='Number'}</th> <th style="width:10%">{l s='Amount'}</th> <th style="width:1%"></th> </tr> </thead> <tbody> <tr> <td colspan="5" class="left"> <h3>{l s='Numero di ordine:'}{$order}{$cantidad}</h3> </td> <td colspan="5" class="left"> <p class="right"> <input type="submit" name="submitEditNote" value="{l s='Save'}" class="button" /> </p> </td> </tr> <tr> <td colspan="5" class="left"> <h3>{l s='Export to SDA'} </h3> <a class="button" href="{$link->getAdminLink('AdminCorrieriRaf')|escape:'htmlall':'UTF-8'}&submitAction=generateInvoicePDF&id_order={$order->id}"> <img src="../img/admin/delivery.gif" alt="{l s='View delivery slip'}" /> {l s='View delivery slip'} </a> </td> <td colspan="5" class="left"> <p class="right"> <input type="submit" name="submitEditNote" value="{l s='Save'}" class="button" /> Numerro:{dateFormat date=$order->date_add full=true} </p> </td> </tr> </tbody> <tr> <td colspan="5" class="center"> <form name="gls" method="post" action="scarica_gls.php"> <input name="invia" type="submit" value="File GLS" style="background-color: #0D006A; color: #ffffff;" /> Prova: {$my_module_message} </form> </td> <td> <form name = "corrieri" method ="post" action="scarica_sda.php"> <input type=submit value="File SDA" style="background-color: #FF0022; color: #ffffff;"> <br> </form> </tr> <tr> Prova: {$my_module_message} <form action="{$link->getPageLink('AdminOrders', true)|escape:'html'}" method="post" class="std" id="markAsReceived"> <input type="hidden" class="hidden" value="{$order->id|intval}" name="id_order" /> <input type="submit" class="exclusive" name="markAsReceived" id="markAsReceivedBtn" value="{l s='I have received this order'}"> <p class="clear"></p> </form> </tr> </table> </fieldset> thanks Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now