local/modules/CreditNote/Hook/Back/OrderEditHook.php line 26

  1. <?php
  2. /*************************************************************************************/
  3. /*      This file is part of the module CreditNote                                   */
  4. /*                                                                                   */
  5. /*      For the full copyright and license information, please view the LICENSE.txt  */
  6. /*      file that was distributed with this source code.                             */
  7. /*************************************************************************************/
  8. namespace CreditNote\Hook\Back;
  9. use CreditNote\CreditNote;
  10. use CreditNote\Model\CreditNoteDetailQuery;
  11. use CreditNote\Model\CreditNoteQuery;
  12. use Propel\Runtime\ActiveQuery\Criteria;
  13. use Thelia\Core\Event\Hook\HookRenderBlockEvent;
  14. use Thelia\Core\Event\Hook\HookRenderEvent;
  15. use Thelia\Core\Hook\BaseHook;
  16. use Thelia\Core\Thelia;
  17. use Thelia\Core\Translation\Translator;
  18. /**
  19.  * @author Gilles Bourgeat >gilles.bourgeat@gmail.com>
  20.  */
  21. class OrderEditHook extends BaseHook
  22. {
  23.     public function onOrderEditProductList(HookRenderEvent $event)
  24.     {
  25.         $creditNoteDetails CreditNoteDetailQuery::create()
  26.             ->filterByQuantity(0Criteria::GREATER_THAN)
  27.             ->filterByOrderProductId($event->getArgument('order_product_id'))
  28.             ->find();
  29.         $event->add($this->render(
  30.             'hook/order-edit.product-list.html',
  31.             $event->getArguments() + ['creditNoteDetails' => $creditNoteDetails]
  32.         ));
  33.     }
  34.     public function onOrderTab(HookRenderBlockEvent $event)
  35.     {
  36.         $count CreditNoteQuery::create()
  37.             ->filterByOrderId($event->getArgument('id'))
  38.             ->count();
  39.         $event->add(
  40.             [
  41.                 "id" => "credit-note",
  42.                 "title" => Translator::getInstance()->trans("Credit Note", [], CreditNote::DOMAIN_MESSAGE) . ($count ' (' $count ')' ''),
  43.                 "content" => $this->render('hook/order.tab.html'array_merge($event->getArguments(), [
  44.                 ]))
  45.             ]
  46.         );
  47.     }
  48.     public function onOrderEditBottom(HookRenderEvent $event)
  49.     {
  50.         $event->add($this->render(
  51.             'includes/credit-note-modal.html',
  52.             array_merge($event->getArguments(), [
  53.                 ])
  54.         ));
  55.     }
  56.     public function onOrderEditJs(HookRenderEvent $event)
  57.     {
  58.         $event->add($this->render(
  59.             'hook/order.edit-js.html',
  60.             array_merge($event->getArguments(), [])
  61.         ));
  62.     }
  63. }