/**
     * @param Offer $obj
     * @throws Exception
     * @throws SmartyException
     */
    public function initFormImages($obj)
    {
        $data = $this->createTemplate($this->tpl_form);
        if ((bool) $obj->id) {
            // if ($this->offer_exists_in_shop) {
            $data->assign('offer', $this->loadObject());
            $count_images = Db::getInstance()->getValue('
					SELECT COUNT(id_offer)
					FROM ' . _DB_PREFIX_ . 'offer_image
					WHERE id_offer = ' . (int) $obj->id);
            $images = AphOfferImage::getImages($this->context->language->id, $obj->id);
            foreach ($images as $k => $image) {
                $images[$k] = new AphOfferImage($image['id_image']);
            }
            if ($this->context->shop->getContext() == Shop::CONTEXT_SHOP) {
                $current_shop_id = (int) $this->context->shop->id;
            } else {
                $current_shop_id = 0;
            }
            $language = Language::getLanguage(Configuration::get('PS_LANG_DEFAULT'));
            $image_uploader = new HelperImageUploader('file');
            $image_uploader->setTemplateDirectory($this->tpl_dir . 'helpers/uploader/')->setMultiple(!(Tools::getUserBrowser() == 'Apple Safari' && Tools::getUserPlatform() == 'Windows'))->setUseAjax(true)->setUrl(Context::getContext()->link->getAdminLink('AdminAphOffers') . '&ajax=1&id_offer=' . (int) $obj->id . '&action=addOfferImage')->setTemplate('ajax.tpl');
            $data->assign(array('countImages' => $count_images, 'id_offer' => (int) Tools::getValue('id_offer'), 'images' => $images, 'iso_lang' => $language['iso_code'], 'token' => $this->token, 'table' => $this->table, 'max_image_size' => $this->max_image_size / 1024 / 1024, 'currency' => $this->context->currency, 'current_shop_id' => $current_shop_id, 'languages' => $this->_languages, 'default_language' => (int) Configuration::get('PS_LANG_DEFAULT'), 'image_uploader' => $image_uploader->render()));
            $type = ImageType::getByNameNType('%', 'products', 'height');
            if (isset($type['name'])) {
                $data->assign('imageType', $type['name']);
            } else {
                $data->assign('imageType', ImageType::getFormatedName('small'));
            }
            // } else {
            //     $this->displayWarning($this->l('You must save the offer in this shop before adding images.'));
            // }
        } else {
            $this->displayWarning($this->l('You must save this offer before adding images.'));
        }
        $this->tpl_form_vars['custom_form'] = $data->fetch();
    }
 /**
  * @param Store $obj
  * @throws Exception
  * @throws SmartyException
  */
 public function initFormImages($obj)
 {
     if ((bool) $obj->id) {
         $count_images = Db::getInstance()->getValue('
             SELECT COUNT(id_shop)
             FROM ' . _DB_PREFIX_ . 'store_image
             WHERE id_shop = ' . (int) $obj->id_shop);
         $images = AphStoreImage::getImages($this->context->language->id, $obj->id_shop);
         foreach ($images as $k => $image) {
             $images[$k] = new AphStoreImage($image['id_image']);
         }
         $language = Language::getLanguage(Configuration::get('PS_LANG_DEFAULT'));
         $image_uploader = new HelperImageUploader('file');
         $image_uploader->setTemplateDirectory($this->tpl_dir . 'helpers/uploader/')->setMultiple(!(Tools::getUserBrowser() == 'Apple Safari' && Tools::getUserPlatform() == 'Windows'))->setUseAjax(true)->setUrl(Context::getContext()->link->getAdminLink('AdminAphStores') . '&ajax=1&id_store=' . (int) $obj->id . '&action=addStoreImage')->setTemplate('ajax.tpl');
         $this->context->smarty->assign(array('iso_lang' => $language['iso_code'], 'token' => $this->token, 'table' => $this->table, 'countImages' => $count_images, 'images' => $images, 'max_image_size' => $this->max_image_size / 1024 / 1024, "image_uploader" => $image_uploader->render(), 'table' => $this->table, 'default_language' => (int) Configuration::get('PS_LANG_DEFAULT'), 'current_shop_id' => (int) $obj->id_shop, 'id_shop' => (int) $obj->id_shop, 'id_store' => (int) $obj->id));
         $type = ImageType::getByNameNType('%', 'stores', 'height');
         if (isset($type['name'])) {
             $this->context->smarty->assign('imageType', $type['name']);
         } else {
             $this->context->smarty->assign('imageType', ImageType::getFormatedName('medium'));
         }
     }
 }