/**
  * @param Offer $obj
  * @throws Exception
  * @throws PrestaShopException
  * @throws SmartyException
  */
 public function initFormProducts($obj)
 {
     $employee = $obj;
     $data = $this->createTemplate('products.tpl');
     // Selected products
     $selected_products = array();
     $products = AphEmployeeProduct::getProductsByEmployee($employee->id);
     if (!empty($products)) {
         foreach ($products as $product) {
             $selected_products[] = $product['id_product'];
         }
     }
     // Generate category selection tree
     $tree = new HelperTreeProducts('products-tree', $this->l('Seleziona servizio'));
     $tree->setAttribute('selected_products', $selected_products);
     $tree->setInputName('checkBoxProductAsso_employee');
     $tree->setSelectedProducts($selected_products);
     $tree->setUseShopRestriction(true);
     if (!empty($employee->id)) {
         $shops = $employee->getAssociatedShops();
         if (!empty($shops)) {
             $tree->setShop(new Shop($shops[0]));
         }
     }
     $data->assign('product_tree', $tree->render());
     $data->assign(array('dipendente' => $employee, 'link' => $this->context->link, 'is_shop_context' => Shop::getContext() == Shop::CONTEXT_SHOP));
     $this->tpl_form_vars['custom_form'] = $data->fetch();
 }