function getContent()
 {
     $is_one_dot_five = version_compare(_PS_VERSION_, '1.5', '>');
     // Load prestashop ebay's configuration
     $configs = Configuration::getMultiple(array('EBAY_CATEGORY_LOADED_' . $this->ebay_profile->ebay_site_id, 'EBAY_SECURITY_TOKEN'));
     // Check if the module is configured
     if (!$this->ebay_profile->getConfiguration('EBAY_PAYPAL_EMAIL')) {
         return $this->display('error_paypal_email.tpl', array('error_form_category', 'true'));
     }
     // Load categories only if necessary
     if (EbayCategoryConfiguration::getTotalCategoryConfigurations($this->ebay_profile->id) && Tools::getValue('section') != 'category') {
         $template_vars = array('isOneDotFive' => $is_one_dot_five, 'controller' => Tools::getValue('controller'), 'tab' => Tools::getValue('tab'), 'configure' => Tools::getValue('configure'), 'token' => Tools::getValue('token'), 'tab_module' => Tools::getValue('tab_module'), 'module_name' => Tools::getValue('module_name'), 'form_categories' => EbaySynchronizer::getNbSynchronizableEbayCategorie($this->ebay_profile->id));
         return $this->display('pre_form_categories.tpl', $template_vars);
     }
     // Display eBay Categories
     $ebay_site_id = $this->ebay_profile->ebay_site_id;
     if (!isset($configs['EBAY_CATEGORY_LOADED_' . $ebay_site_id]) || !$configs['EBAY_CATEGORY_LOADED_' . $ebay_site_id] || !EbayCategory::areCategoryLoaded($ebay_site_id)) {
         $ebay_request = new EbayRequest();
         EbayCategory::insertCategories($ebay_site_id, $ebay_request->getCategories(), $ebay_request->getCategoriesSkuCompliancy());
         Configuration::updateValue('EBAY_CATEGORY_LOADED_' . $ebay_site_id, 1);
     }
     // Smarty
     $template_vars = array('alerts' => $this->_getAlertCategories(), 'tabHelp' => '&id_tab=7', 'id_lang' => $this->context->cookie->id_lang, 'id_ebay_profile' => $this->ebay_profile->id, '_path' => $this->path, 'configs' => $configs, '_module_dir_' => _MODULE_DIR_, 'isOneDotFive' => $is_one_dot_five, 'request_uri' => $_SERVER['REQUEST_URI'], 'controller' => Tools::getValue('controller'), 'tab' => Tools::getValue('tab'), 'configure' => Tools::getValue('configure'), 'token' => Tools::getValue('token'), 'tab_module' => Tools::getValue('tab_module'), 'module_name' => Tools::getValue('module_name'), 'date' => pSQL(date('Ymdhis')), 'form_categories' => EbaySynchronizer::getNbSynchronizableEbayCategorie($this->ebay_profile->id), 'nb_categorie' => count(Category::getCategories($this->context->cookie->id_lang, true, false)));
     return $this->display('form_categories.tpl', $template_vars);
 }
Example #2
0
function reorderpositions()
{
    $cat = Category::getCategories(1, false, false);
    foreach ($cat as $i => $categ) {
        Product::cleanPositions(intval($categ['id_category']));
    }
}
 public function indexAction()
 {
     $modelCategory = new Category();
     $order = 'path ASC';
     $categories = $modelCategory->getCategories(null, $order, null);
     $this->view->categories = $categories;
 }
 public function listCategories()
 {
     $db = new Category($this->_config);
     $result = $db->getCategories();
     $encodedResult = $this->utf8_converter($result);
     $categories = json_encode($encodedResult);
     echo $categories;
 }
Example #5
0
function displayAllMainPageCategoryItems()
{
    $category_ids = DBHelper::verticalSlice(Category::getCategories(), "id");
    $html = "";
    for ($i = 0; $i < count($category_ids); $i++) {
        $html .= sprintf('<div data-tab="%d" class="category-items hidden">', $i + 1);
        $html .= displayMainPageCategoryItems($category_ids[$i]);
        $html .= '</div>';
    }
    return $html;
}
Example #6
0
 public function init()
 {
     $this->setMethod('post');
     $title = $this->createElement('text', 'title');
     $title->setLabel('ๆ ‡้ข˜๏ผš');
     $title->setRequired(TRUE);
     $title->addValidator('stringLength', false, array(4, 100));
     $title->addErrorMessage('ๆ ‡้ข˜ๅบ”ๆœ‰2-50ไธชๆฑ‰ๅญ—ใ€‚');
     $this->addElement($title);
     // ๅˆ†็ฑป
     $category = $this->createElement('select', 'cid');
     $category->setLabel('ๅˆ†็ฑป๏ผš');
     $category->setRequired(TRUE);
     $modelCategory = new Category();
     $where = array('fid' => 2);
     $categories = $modelCategory->getCategories($where);
     if ($categories != null) {
         foreach ($categories as $value) {
             $category->addMultiOption($value->id, $value->name);
         }
     }
     $this->addElement($category);
     // ๅšๅฎขๅ†…ๅฎน
     $body = $this->createElement('textarea', 'body');
     $body->setLabel('ๅ†…ๅฎน๏ผš');
     $body->setAttribs(array('rows' => 30, 'cols' => 250));
     $body->setRequired(TRUE);
     $this->addElement($body);
     // tagsๆ ‡็ญพ
     $tags = $this->createElement('text', 'tags');
     $tags->setLabel('tags');
     $this->addElement($tags);
     // ๅ‘ๅธƒ็Šถๆ€
     $status = $this->createElement('checkbox', 'status');
     $status->setLabel('ๅ‘ๅธƒ๏ผš');
     $status->setValue(1);
     $this->addElement($status);
     // ่ฏ„่ฎบ
     $allow = $this->createElement('checkbox', 'comment');
     $allow->setLabel('ๅ…่ฎธ่ฏ„่ฎบ๏ผš');
     $allow->setValue(1);
     $this->addElement($allow);
     // ๆไบคๆŒ‰้’ฎ
     $submit = $this->createElement('submit', 'ๆไบค');
     $this->addElement($submit);
     // ่กจๅ•่ฃ…้ฅฐๅ™จ
     $this->setElementDecorators(array('ViewHelper', 'Errors', array(array('data' => 'HtmlTag'), array('tag' => 'td')), array('Label', array('tag' => 'td')), array(array('row' => 'HtmlTag'), array('tag' => 'tr'))));
     $this->setDecorators(array('FormElements', array('HtmlTag', array('tag' => 'table', 'class' => 'sheet')), 'Form'));
 }
 function getContent()
 {
     $configs = Configuration::getMultiple(array('EBAY_CATEGORY_LOADED_' . $this->ebay_profile->ebay_site_id, 'EBAY_SECURITY_TOKEN'));
     $ebay_request = new EbayRequest();
     $user_profile = $ebay_request->getUserProfile($this->ebay_profile->ebay_user_identifier);
     $store_categories = EbayStoreCategory::getStoreCategories($this->ebay_profile->id);
     $not_compatible_names = array();
     if ($store_categories['not_compatible']) {
         foreach ($store_categories['not_compatible'] as $cat) {
             $not_compatible_names[] = $cat['name'];
         }
     }
     $template_vars = array('configs' => $configs, '_path' => $this->path, 'controller' => Tools::getValue('controller'), 'configure' => Tools::getValue('configure'), 'token' => Tools::getValue('token'), 'tab_module' => Tools::getValue('tab_module'), 'module_name' => Tools::getValue('module_name'), 'tab' => Tools::getValue('tab'), 'nb_categorie' => count(Category::getCategories($this->context->cookie->id_lang, true, false)), 'has_store_categories' => count($store_categories['compatible']) > 1, 'not_compatible_store_categories' => implode(', ', $not_compatible_names), 'has_ebay_shop' => (bool) ($user_profile && $user_profile['StoreUrl']), 'ebay_store_url' => EbayCountrySpec::getProUrlBySiteId($this->ebay_profile->ebay_site_id));
     return $this->display('form_store_categories.tpl', $template_vars);
 }
Example #8
0
 public function __construct($id, $module = null)
 {
     // var_dump($this->route);
     parent::__construct($id, $module);
     //var_dump();
     if (Yii::app()->params['installed'] === "yes") {
         $this->settings = (require Yii::getPathOfAlias('application.config.settings') . '.php');
         $this->banners = (include_once Yii::getPathOfAlias('application.config.banners') . '.php');
         //$this->categories = $this->getCategories();
         Yii::app()->params['categories'] = Category::getCategories();
     } elseif (Yii::app()->getRequest()->getPathInfo() !== "site/install") {
         $this->redirect(Yii::app()->baseUrl . '/site/install');
     }
     $this->meta = Yii::app()->params['meta'];
     $this->meta['vars']['site_name'] = Yii::app()->name;
 }
function reorderpositions()
{
    /* Clean products positions */
    if ($cat = Category::getCategories(1, false, false)) {
        foreach ($cat as $i => $categ) {
            Product::cleanPositions((int) $categ['id_category']);
        }
    }
    //clean Category position and delete old position system
    Language::loadLanguages();
    $language = Language::getLanguages();
    $cat_parent = Db::getInstance()->ExecuteS('SELECT DISTINCT c.id_parent FROM `' . _DB_PREFIX_ . 'category` c WHERE id_category != 1');
    foreach ($cat_parent as $parent) {
        $result = Db::getInstance()->ExecuteS('
							SELECT DISTINCT c.*, cl.*
							FROM `' . _DB_PREFIX_ . 'category` c 
							LEFT JOIN `' . _DB_PREFIX_ . 'category_lang` cl ON (c.`id_category` = cl.`id_category` AND `id_lang` = ' . (int) Configuration::get('PS_LANG_DEFAULT') . ')
							WHERE c.id_parent = ' . (int) $parent['id_parent'] . '
							ORDER BY name ASC');
        foreach ($result as $i => $categ) {
            Db::getInstance()->Execute('
			UPDATE `' . _DB_PREFIX_ . 'category`
			SET `position` = ' . (int) $i . '
			WHERE `id_parent` = ' . (int) $categ['id_parent'] . '
			AND `id_category` = ' . (int) $categ['id_category']);
        }
        $result = Db::getInstance()->ExecuteS('
							SELECT DISTINCT c.*, cl.*
							FROM `' . _DB_PREFIX_ . 'category` c 
							LEFT JOIN `' . _DB_PREFIX_ . 'category_lang` cl ON (c.`id_category` = cl.`id_category`)
							WHERE c.id_parent = ' . (int) $parent['id_parent'] . '
							ORDER BY name ASC');
        // Remove number from category name
        foreach ($result as $i => $categ) {
            Db::getInstance()->Execute('UPDATE `' . _DB_PREFIX_ . 'category` c 
			LEFT JOIN `' . _DB_PREFIX_ . 'category_lang` cl ON (c.`id_category` = cl.`id_category`)
			SET `name` = \'' . preg_replace('/^[0-9]+\\./', '', $categ['name']) . '\' 
			WHERE c.id_category = ' . (int) $categ['id_category'] . ' AND id_lang = \'' . (int) $categ['id_lang'] . '\'');
        }
    }
    /* Clean CMS positions */
    if ($cms_cat = CMSCategory::getCategories(1, false, false)) {
        foreach ($cms_cat as $i => $categ) {
            CMS::cleanPositions((int) $categ['id_cms_category']);
        }
    }
}
Example #10
0
 /**
  * Function to scan all the sub directories in the
  * challenges directory and store them in application
  * settings
  */
 public static function run()
 {
     $categoryObj = new Category();
     $categories = $categoryObj->getCategories();
     $categoryLessons = array();
     //Contains all categories and corresponding lessons
     foreach ($categories as $category) {
         $categoryLessons[$category] = array();
     }
     $subDirectories = glob(LESSON_PATH . '*', GLOB_ONLYDIR);
     foreach ($subDirectories as $lessonDir) {
         $className = "\\webgoat\\" . basename($lessonDir);
         if (!class_exists($className)) {
             throw new ClassNotFoundException("No class {$className} exists. Please run loadClasses() first.");
         }
         $obj = new $className();
         $classNameWithoutNamespace = basename($lessonDir);
         //array key contains categories, value contains lessons belonging to that category
         array_push($categoryLessons[$obj->getCategory()], array($classNameWithoutNamespace, $obj));
     }
     \jf::SaveGeneralSetting('categoryLessons', $categoryLessons);
 }
Example #11
0
    public function hookAdminStatsModules()
    {
        $id_category = (int) Tools::getValue('id_category');
        $currency = Context::getContext()->currency;
        if (Tools::getValue('export')) {
            if (!Tools::getValue('exportType')) {
                $this->csvExport(array('layers' => 2, 'type' => 'line', 'option' => '42'));
            }
        }
        $this->html = '
			<div class="panel-heading">
				' . $this->displayName . '
			</div>
			<h4>' . $this->l('Guide') . '</h4>
			<div class="alert alert-warning">
				<h4>' . $this->l('Number of purchases compared to number of views') . '</h4>
				<p>
					' . $this->l('After choosing a category and selecting a product, informational graphs will appear.') . '
					<ul>
						<li class="bullet">' . $this->l('If you notice that a product is often purchased but viewed infrequently, you should display it more prominently in your Front Office.') . '</li>
						<li class="bullet">' . $this->l('On the other hand, if a product has many views but is not often purchased, we advise you to check or modify this product\'s information, description and photography again, see if you can find something better.') . '
						</li>
					</ul>
				</p>
			</div>';
        if ($id_product = (int) Tools::getValue('id_product')) {
            if (Tools::getValue('export')) {
                if (Tools::getValue('exportType') == 1) {
                    $this->csvExport(array('layers' => 2, 'type' => 'line', 'option' => '1-' . $id_product));
                } elseif (Tools::getValue('exportType') == 2) {
                    $this->csvExport(array('type' => 'pie', 'option' => '3-' . $id_product));
                }
            }
            $product = new Product($id_product, false, $this->context->language->id);
            $total_bought = $this->getTotalBought($product->id);
            $total_sales = $this->getTotalSales($product->id);
            $total_viewed = $this->getTotalViewed($product->id);
            $this->html .= '<h4>' . $product->name . ' - ' . $this->l('Details') . '</h4>
			<div class="row row-margin-bottom">
				<div class="col-lg-12">
					<div class="col-lg-8">
						' . $this->engine(array('layers' => 2, 'type' => 'line', 'option' => '1-' . $id_product)) . '
					</div>
					<div class="col-lg-4">
						<ul class="list-unstyled">
							<li>' . $this->l('Total bought') . ' ' . $total_bought . '</li>
							<li>' . $this->l('Sales (tax excluded)') . ' ' . Tools::displayprice($total_sales, $currency) . '</li>
							<li>' . $this->l('Total viewed') . ' ' . $total_viewed . '</li>
							<li>' . $this->l('Conversion rate') . ' ' . number_format($total_viewed ? $total_bought / $total_viewed : 0, 2) . '</li>
						</ul>
						<a class="btn btn-default export-csv" href="' . Tools::safeOutput($_SERVER['REQUEST_URI']) . '&export=1&exportType=1">
							<i class="icon-cloud-upload"></i> ' . $this->l('CSV Export') . '
						</a>
					</div>
				</div>
			</div>';
            if ($has_attribute = $product->hasAttributes() && $total_bought) {
                $this->html .= '<h3 class="space">' . $this->l('Attribute sales distribution') . '</h3><center>' . $this->engine(array('type' => 'pie', 'option' => '3-' . $id_product)) . '</center><br />
			<a href="' . Tools::safeOutput($_SERVER['REQUEST_URI']) . '&export=1&exportType=2"><img src="../img/admin/asterisk.gif" />' . $this->l('CSV Export') . '</a>';
            }
            if ($total_bought) {
                $sales = $this->getSales($id_product);
                $this->html .= '
				<h4>' . $this->l('Sales') . '</h4>
				<div style="overflow-y: scroll; height: ' . min(400, (count($sales) + 1) * 32) . 'px;">
					<table class="table">
						<thead>
							<tr>
								<th>
									<span class="title_box  active">' . $this->l('Date') . '</span>
								</th>
								<th>
									<span class="title_box  active">' . $this->l('Order') . '</span>
								</th>
								<th>
									<span class="title_box  active">' . $this->l('Customer') . '</span>
								</th>
								' . ($has_attribute ? '<th><span class="title_box  active">' . $this->l('Attribute') . '</span></th>' : '') . '
								<th>
									<span class="title_box  active">' . $this->l('Quantity') . '</span>
								</th>
								<th>
									<span class="title_box  active">' . $this->l('Price') . '</span>
								</th>
							</tr>
						</thead>
						<tbody>';
                $token_order = Tools::getAdminToken('AdminOrders' . (int) Tab::getIdFromClassName('AdminOrders') . (int) $this->context->employee->id);
                $token_customer = Tools::getAdminToken('AdminCustomers' . (int) Tab::getIdFromClassName('AdminCustomers') . (int) $this->context->employee->id);
                foreach ($sales as $sale) {
                    $this->html .= '
						<tr>
							<td>' . Tools::displayDate($sale['date_add'], null, false) . '</td>
							<td align="center"><a href="?tab=AdminOrders&id_order=' . $sale['id_order'] . '&vieworder&token=' . $token_order . '">' . (int) $sale['id_order'] . '</a></td>
							<td align="center"><a href="?tab=AdminCustomers&id_customer=' . $sale['id_customer'] . '&viewcustomer&token=' . $token_customer . '">' . (int) $sale['id_customer'] . '</a></td>
							' . ($has_attribute ? '<td>' . $sale['product_name'] . '</td>' : '') . '
							<td>' . (int) $sale['product_quantity'] . '</td>
							<td>' . Tools::displayprice($sale['total'], $currency) . '</td>
						</tr>';
                }
                $this->html .= '
						</tbody>
					</table>
				</div>';
                $cross_selling = $this->getCrossSales($id_product, $this->context->language->id);
                if (count($cross_selling)) {
                    $this->html .= '
					<h4>' . $this->l('Cross selling') . '</h4>
					<div style="overflow-y: scroll; height: 200px;">
						<h4>' . $this->l('Cross selling') . '</h4>
						<table class="table">
							<thead>
								<tr>
									<th>
										<span class="title_box  active">' . $this->l('Product name') . '</span>
									</th>
									<th>
										<span class="title_box  active">' . $this->l('Quantity sold') . '</span>
									</th>
									<th>
										<span class="title_box  active">' . $this->l('Average price') . '</span>
									</th>
								</tr>
							</thead>
						<tbody>';
                    $token_products = Tools::getAdminToken('AdminProducts' . (int) Tab::getIdFromClassName('AdminProducts') . (int) $this->context->employee->id);
                    foreach ($cross_selling as $selling) {
                        $this->html .= '
							<tr>
								<td ><a href="?tab=AdminProducts&id_product=' . (int) $selling['id_product'] . '&addproduct&token=' . $token_products . '">' . $selling['pname'] . '</a></td>
								<td align="center">' . (int) $selling['pqty'] . '</td>
								<td align="right">' . Tools::displayprice($selling['pprice'], $currency) . '</td>
							</tr>';
                    }
                    $this->html .= '
							</tbody>
						</table>
					</div>';
                }
            }
        } else {
            $categories = Category::getCategories((int) $this->context->language->id, true, false);
            $this->html .= '
			<form action="" method="post" id="categoriesForm" class="form-horizontal">
				<div class="row row-margin-bottom">
					<label class="control-label col-lg-3" for="id_category">
						<span title="" data-toggle="tooltip" class="label-tooltip" data-original-title="' . $this->l('Click on a product to access its statistics!') . '">
							' . $this->l('Choose a category') . '
						</span>
					</label>
					<div class="col-lg-3">
						<select name="id_category" onchange="$(\'#categoriesForm\').submit();">
							<option value="0">' . $this->l('All') . '</option>';
            foreach ($categories as $category) {
                $this->html .= '<option value="' . $category['id_category'] . '"' . ($id_category == $category['id_category'] ? ' selected="selected"' : '') . '>' . $category['name'] . '</option>';
            }
            $this->html .= '
						</select>
					</div>
				</div>
			</form>
			<h4>' . $this->l('Products available') . '</h4>
			<table class="table" border="0" cellspacing="0" cellspacing="0">
				<thead>
					<tr>
						<th>
							<span class="title_box  active">' . $this->l('Reference') . '</span>
						</th>
						<th>
							<span class="title_box  active">' . $this->l('Name') . '</span>
						</th>
						<th>
							<span class="title_box  active">' . $this->l('Available quantity for sale') . '</span>
						</th>
					</tr>
				</thead>
				<tbody>';
            foreach ($this->getProducts($this->context->language->id) as $product) {
                $this->html .= '
				<tr>
					<td>' . $product['reference'] . '</td>
					<td>
						<a href="' . AdminController::$currentIndex . '&token=' . Tools::safeOutput(Tools::getValue('token')) . '&module=' . $this->name . '&id_product=' . $product['id_product'] . '">' . $product['name'] . '</a>
					</td>
					<td>' . $product['quantity'] . '</td>
				</tr>';
            }
            $this->html .= '
				</tbody>
			</table>
			<a class="btn btn-default export-csv" href="' . Tools::safeOutput($_SERVER['REQUEST_URI']) . '&export=1">
				<i class="icon-cloud-upload"></i> ' . $this->l('CSV Export') . '
			</a>';
        }
        return $this->html;
    }
    public function hookAdminStatsModules($params)
    {
        global $cookie, $currentIndex;
        $id_category = (int) Tools::getValue('id_category');
        $currency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT'));
        if (Tools::getValue('export')) {
            if (!Tools::getValue('exportType')) {
                $this->csvExport(array('layers' => 2, 'type' => 'line', 'option' => '42'));
            }
        }
        $this->_html = '<fieldset class="width3"><legend><img src="../modules/' . $this->name . '/logo.gif" /> ' . $this->displayName . '</legend>';
        if ($id_product = (int) Tools::getValue('id_product')) {
            if (Tools::getValue('export')) {
                if (Tools::getValue('exportType') == 1) {
                    $this->csvExport(array('layers' => 2, 'type' => 'line', 'option' => '1-' . $id_product));
                } elseif (Tools::getValue('exportType') == 2) {
                    $this->csvExport(array('type' => 'pie', 'option' => '3-' . $id_product));
                }
            }
            $product = new Product($id_product, false, (int) $cookie->id_lang);
            $totalBought = $this->getTotalBought($product->id);
            $totalSales = $this->getTotalSales($product->id);
            $totalViewed = $this->getTotalViewed($product->id);
            $this->_html .= '<h3>' . $product->name . ' - ' . $this->l('Details') . '</h3>
			<p>' . $this->l('Total bought:') . ' ' . $totalBought . '</p>
			<p>' . $this->l('Sales (-Tx):') . ' ' . Tools::displayprice($totalSales, $currency) . '</p>
			<p>' . $this->l('Total viewed:') . ' ' . $totalViewed . '</p>
			<p>' . $this->l('Conversion rate:') . ' ' . number_format($totalViewed ? $totalBought / $totalViewed : 0, 2) . '</p>
			<center>' . ModuleGraph::engine(array('layers' => 2, 'type' => 'line', 'option' => '1-' . $id_product)) . '</center>
			<br />
			<p><a href="' . $_SERVER['REQUEST_URI'] . '&export=1&exportType=1"><img src="../img/admin/asterisk.gif" />' . $this->l('CSV Export') . '</a></p>';
            if ($hasAttribute = $product->hasAttributes() and $totalBought) {
                $this->_html .= '<h3 class="space">' . $this->l('Attribute sales distribution') . '</h3><center>' . ModuleGraph::engine(array('type' => 'pie', 'option' => '3-' . $id_product)) . '</center><br />
			<p><a href="' . $_SERVER['REQUEST_URI'] . '&export=1&exportType=2"><img src="../img/admin/asterisk.gif" />' . $this->l('CSV Export') . '</a></p><br />';
            }
            if ($totalBought) {
                $sales = $this->getSales($id_product, $cookie->id_lang);
                $this->_html .= '<br class="clear" />
				<h3>' . $this->l('Sales') . '</h3>
				<div style="overflow-y: scroll; height: ' . min(400, (count($sales) + 1) * 32) . 'px;">
				<table class="table" border="0" cellspacing="0" cellspacing="0">
				<thead>
					<tr>
						<th>' . $this->l('Date') . '</th>
						<th>' . $this->l('Order') . '</th>
						<th>' . $this->l('Customer') . '</th>
						' . ($hasAttribute ? '<th>' . $this->l('Attribute') . '</th>' : '') . '
						<th>' . $this->l('Qty') . '</th>
						<th>' . $this->l('Price') . '</th>
					</tr>
				</thead><tbody>';
                $tokenOrder = Tools::getAdminToken('AdminOrders' . (int) Tab::getIdFromClassName('AdminOrders') . (int) $cookie->id_employee);
                $tokenCustomer = Tools::getAdminToken('AdminCustomers' . (int) Tab::getIdFromClassName('AdminCustomers') . (int) $cookie->id_employee);
                foreach ($sales as $sale) {
                    $this->_html .= '
					<tr>
						<td>' . Tools::displayDate($sale['date_add'], (int) $cookie->id_lang, false) . '</td>
						<td align="center"><a href="?tab=AdminOrders&id_order=' . $sale['id_order'] . '&vieworder&token=' . $tokenOrder . '">' . (int) $sale['id_order'] . '</a></td>
						<td align="center"><a href="?tab=AdminCustomers&id_customer=' . $sale['id_customer'] . '&viewcustomer&token=' . $tokenCustomer . '">' . (int) $sale['id_customer'] . '</a></td>
						' . ($hasAttribute ? '<td>' . $sale['product_name'] . '</td>' : '') . '
						<td>' . (int) $sale['product_quantity'] . '</td>
						<td>' . Tools::displayprice($sale['total'], $currency) . '</td>
					</tr>';
                }
                $this->_html .= '</tbody></table></div>';
                $crossSelling = $this->getCrossSales($id_product, $cookie->id_lang);
                if (count($crossSelling)) {
                    $this->_html .= '<br class="clear" />
					<h3>' . $this->l('Cross Selling') . '</h3>
					<div style="overflow-y: scroll; height: 200px;">
					<table class="table" border="0" cellspacing="0" cellspacing="0">
					<thead>
						<tr>
							<th>' . $this->l('Product name') . '</th>
							<th>' . $this->l('Quantity sold') . '</th>
							<th>' . $this->l('Average price') . '</th>
						</tr>
					</thead><tbody>';
                    $tokenProducts = Tools::getAdminToken('AdminCatalog' . (int) Tab::getIdFromClassName('AdminCatalog') . (int) $cookie->id_employee);
                    foreach ($crossSelling as $selling) {
                        $this->_html .= '
						<tr>
							<td ><a href="?tab=AdminCatalog&id_product=' . (int) $selling['id_product'] . '&addproduct&token=' . $tokenProducts . '">' . $selling['pname'] . '</a></td>
							<td align="center">' . (int) $selling['pqty'] . '</td>
							<td align="right">' . Tools::displayprice($selling['pprice'], $currency) . '</td>
						</tr>';
                    }
                    $this->_html .= '</tbody></table></div>';
                }
            }
        } else {
            $categories = Category::getCategories((int) $cookie->id_lang, true, false);
            $this->_html .= '
			<label>' . $this->l('Choose a category') . '</label>
			<div class="margin-form">
				<form action="" method="post" id="categoriesForm">
					<select name="id_category" onchange="$(\'#categoriesForm\').submit();">
						<option value="0">' . $this->l('All') . '</option>';
            foreach ($categories as $category) {
                $this->_html .= '<option value="' . $category['id_category'] . '"' . ($id_category == $category['id_category'] ? ' selected="selected"' : '') . '>' . $category['name'] . '</option>';
            }
            $this->_html .= '
					</select>
				</form>
			</div>
			<div class="clear space"></div>
			' . $this->l('Click on a product to access its statistics.') . '
			<div class="clear space"></div>
			<h2>' . $this->l('Products available') . '</h2>
			<div style="overflow-y: scroll; height: 600px;">
			<table class="table" border="0" cellspacing="0" cellspacing="0">
			<thead>
				<tr>
					<th>' . $this->l('Ref.') . '</th>
					<th>' . $this->l('Name') . '</th>
					<th>' . $this->l('Stock') . '</th>
				</tr>
			</thead><tbody>';
            foreach ($this->getProducts($cookie->id_lang) as $product) {
                $this->_html .= '<tr><td>' . $product['reference'] . '</td><td><a href="' . $currentIndex . '&token=' . Tools::getValue('token') . '&module=' . $this->name . '&id_product=' . $product['id_product'] . '">' . $product['name'] . '</a></td><td>' . $product['quantity'] . '</td></tr>';
            }
            $this->_html .= '</tbody></table><br /></div><br />
				<a href="' . $_SERVER['REQUEST_URI'] . '&export=1"><img src="../img/admin/asterisk.gif" />' . $this->l('CSV Export') . '</a><br />';
        }
        $this->_html .= '</fieldset><br />
		<fieldset class="width3"><legend><img src="../img/admin/comment.gif" /> ' . $this->l('Guide') . '</legend>
		<h2>' . $this->l('Number of purchases compared to number of viewings') . '</h2>
			<p>
				' . $this->l('After choosing a category and selecting a product, informational graphs will appear. Then, you will be able to analyze them.') . '
				<ul>
					<li class="bullet">' . $this->l('If you notice that a product is successful and often purchased, but viewed infrequently, you should put it more prominently on your webshop front-office.') . '</li>
					<li class="bullet">' . $this->l('On the other hand, if a product has many viewings but is not often purchased, we advise you to check or modify this product\'s information, description and photography again.') . '
					</li>
				</ul>
			</p>
		</fieldset>';
        return $this->_html;
    }
Example #13
0
 public function generate($cron = false)
 {
     self::setCurrency();
     include 'classes/ymlCatalog.php';
     //ะฏะทั‹ะบ ะฟะพ ัƒะผะพะปั‡ะฐะฝะธัŽ
     $id_lang = (int) Configuration::get('PS_LANG_DEFAULT');
     //ะ’ะฐะปัŽั‚ะฐ ะฟะพ ัƒะผะพะปั‡ะฐะฝะธัŽ
     $currency_default = new Currency($this->context->cookie->id_currency);
     $this->currency_iso = $currency_default->iso_code;
     //ะะดั€ะตั ะผะฐะณะฐะทะธะฝะฐ
     $shop_url = 'http://' . Tools::getHttpHost(false, true) . __PS_BASE_URI__;
     //ะšะฐั‚ะตะณะพั€ะธะธ ะดะปั ัะบัะฟะพั€ั‚ะฐ
     $yamarket_ั_categories = unserialize(Configuration::get('yamarket_ั_categories'));
     //$yamarket_ั_suppliers = unserialize(Configuration::get('yamarket_ั_supplier'));
     $yamarket_ั_combinations = Configuration::get('yamarket_ั_combinations');
     $this->yamarket_ั_availability = Configuration::get('yamarket_ั_availability');
     $this->yamarket_ั_shipping = unserialize(Configuration::get('yamarket_ั_shipping'));
     //ัะพะทะดะฐะตะผ ะฝะพะฒั‹ะน ะผะฐะณะฐะทะธะฝ
     $catalog = new ymlCatalog();
     $catalog->gzip = Configuration::get('yamarket_ั_gzip');
     $shop = new ymlShop();
     $shop->name = Configuration::get('yamarket_ั_shop');
     $shop->company = Configuration::get('yamarket_ั_company');
     $shop->url = $shop_url;
     $shop->platform = 'PrestaShop';
     $shop->version = _PS_VERSION_;
     $shop->agency = 'PrestaLab';
     $shop->email = '*****@*****.**';
     //ะ’ะฐะปัŽั‚ั‹
     $shop->startTag(ymlCurrency::$collectionName);
     if (Configuration::get('yamarket_ั_currencies')) {
         $currencies = Currency::getCurrencies();
         foreach ($currencies as $currency) {
             $shop->add(new ymlCurrency($currency['iso_code'], (double) $currency['conversion_rate']));
         }
         unset($currencies);
     } else {
         $shop->add(new ymlCurrency($currency_default->iso_code, (double) $currency_default->conversion_rate));
     }
     $shop->endTag(ymlCurrency::$collectionName);
     //ะšะฐั‚ะตะณะพั€ะธะธ
     $categories = Category::getCategories($id_lang, false, false);
     $shop->startTag(ymlCategory::$collectionName);
     foreach ($categories as $category) {
         if ($category['active'] && in_array($category['id_category'], $yamarket_ั_categories)) {
             $shop->add(new ymlCategory($category['id_category'], $category['name'], $category['id_parent']));
         }
     }
     $shop->endTag(ymlCategory::$collectionName);
     //ะกั‚ะพะธะผะพัั‚ัŒ ะดะพัั‚ะฐะฒะบะธ
     $shop->addString('<local_delivery_cost>' . Configuration::get('yamarket_ั_shippingcost') . '</local_delivery_cost>');
     //ะขะพะฒะฐั€ั‹
     $shop->startTag(ymlOffer::$collectionName);
     foreach ($categories as $category) {
         if ($category['active'] && in_array($category['id_category'], $yamarket_ั_categories)) {
             $category_object = new Category($category['id_category']);
             $products = $category_object->getProducts($id_lang, 1, 10000);
             if ($products) {
                 foreach ($products as $product) {
                     if ($product['id_category_default'] != $category['id_category']) {
                         continue;
                     }
                     //						if (count($yamarket_ั_suppliers)&&(!in_array($product['id_supplier'], $yamarket_ั_suppliers)))
                     //							continue;
                     //ะ”ะปั ะบะพะผะฑะธะฝะฐั†ะธะน
                     if ($yamarket_ั_combinations) {
                         $product_object = new Product($product['id_product'], false, $id_lang);
                         $combinations = $product_object->getAttributeCombinations($id_lang);
                     } else {
                         $combinations = false;
                     }
                     if (is_array($combinations) && count($combinations) > 0) {
                         $comb_array = array();
                         foreach ($combinations as $combination) {
                             $comb_array[$combination['id_product_attribute']]['id_product_attribute'] = $combination['id_product_attribute'];
                             $comb_array[$combination['id_product_attribute']]['price'] = Product::getPriceStatic($product['id_product'], true, $combination['id_product_attribute']);
                             $comb_array[$combination['id_product_attribute']]['reference'] = $combination['reference'];
                             $comb_array[$combination['id_product_attribute']]['ean13'] = $combination['ean13'];
                             $comb_array[$combination['id_product_attribute']]['quantity'] = $combination['quantity'];
                             $comb_array[$combination['id_product_attribute']]['attributes'][$combination['group_name']] = $combination['attribute_name'];
                             $comb_array[$combination['id_product_attribute']]['oldprice'] = $product['orderprice'] + $combination['price'];
                             if (!isset($comb_array[$combination['id_product_attribute']]['comb_url'])) {
                                 $comb_array[$combination['id_product_attribute']]['comb_url'] = '';
                             }
                             $comb_array[$combination['id_product_attribute']]['comb_url'] .= '/' . (self::combinationUrlPrepare($combination['group_name']) . '-' . self::combinationUrlPrepare($combination['attribute_name']));
                         }
                         foreach ($comb_array as $combination) {
                             self::_addProduct($shop, $product, $combination);
                         }
                     } else {
                         self::_addProduct($shop, $product);
                     }
                 }
             }
             unset($product);
         }
     }
     unset($categories);
     $shop->endTag(ymlOffer::$collectionName);
     $catalog->add($shop);
     if ($cron) {
         if ($fp = fopen(_PS_UPLOAD_DIR_ . 'yml.' . $this->context->shop->id . '.xml' . ($catalog->gzip ? '.gz' : ''), 'w')) {
             fwrite($fp, $catalog->generate());
             fclose($fp);
         }
     } else {
         if ($catalog->gzip) {
             header('Content-type:application/x-gzip');
             header('Content-Disposition: attachment; filename=yml.' . $this->context->shop->id . '.xml.gz');
         } else {
             header('Content-type:application/xml;  charset=utf-8');
         }
         echo $catalog->generate();
     }
 }
 public function edit($id)
 {
     $domain = Domain::find($id);
     $categories = Category::getCategories();
     return View::make('domains.edit')->with(compact('domain', 'categories'));
 }
 public function generate($to_file = true)
 {
     $link = new Link();
     include_once 'YMarket.class.php';
     //ะฏะทั‹ะบ ะฟะพ ัƒะผะพะปั‡ะฐะฝะธัŽ
     $id_lang = intval(Configuration::get('PS_LANG_DEFAULT'));
     //ะ’ะฐะปัŽั‚ะฐ ะฟะพ ัƒะผะพะปั‡ะฐะฝะธัŽ
     $curr_def = new Currency(intval(Configuration::get('PS_CURRENCY_DEFAULT')));
     //ัะพะทะดะฐะตะผ ะฝะพะฒั‹ะน ะผะฐะณะฐะทะธะฝ
     $market = new YMarket($this->_settings['y_sn'], $this->_settings['y_fn'], 'http://' . Tools::getHttpHost(false, true), $this->_settings['y_ldc']);
     //ะ’ะฐะปัŽั‚ั‹
     if ($this->_settings['y_cu']) {
         $currencies = Currency::getCurrencies();
         foreach ($currencies as $currency) {
             $market->add(new yCurrency($currency['iso_code'], floatval($currency['conversion_rate'])));
         }
         unset($currencies);
     } else {
         $market->add(new yCurrency($curr_def->iso_code, floatval($curr_def->conversion_rate)));
     }
     //ะšะฐั‚ะตะณะพั€ะธะธ
     $categories = Category::getCategories($id_lang, false, false);
     foreach ($categories as $category) {
         $catdesc = $category['meta_title'] ? $category['meta_title'] : $category['name'];
         $market->add(new yCategory($category['id_category'], $catdesc, $category['id_parent']));
     }
     unset($categories);
     //ะŸั€ะพะดัƒะบั‚ั‹
     $products = self::getProducts($id_lang);
     while ($product = Db::getInstance()->nextRow($products)) {
         $tmp = new yOffer($product['id_product'], $product['name'], Product::getPriceStatic($product['id_product'], $usetax = true, NULL, $decimals = 2, $divisor = NULL, $only_reduc = false, $usereduc = true, $quantity = 1, $forceAssociatedTax = true));
         $tmp->id = $product['id_product'];
         $tmp->type = '';
         $tmp->sales_notes = $this->_settings['y_sl'];
         $tmp->url = $link->getProductLink((int) $product['id_product'], $product['link_rewrite']);
         //ะšะฐั€ั‚ะธะฝะบะฐ
         if ($cover = self::getCover($product['id_product'])) {
             $tmp->picture = $link->getImageLink($product['link_rewrite'], $cover);
         }
         $tmp->currencyId = $curr_def->iso_code;
         $tmp->categoryId = $product['id_category_default'];
         //$tmp->vendorCode = $product['reference'];
         $tmp->description = $product['description'];
         if ($this->_settings['y_dl']) {
             $tmp->delivery = 'true';
         } else {
             $tmp->delivery = 'false';
         }
         switch ($this->_settings['y_av']) {
             case 1:
                 $tmp->available = $product['quantity'] == 0 ? 'false' : 'true';
                 break;
             case 3:
                 $tmp->available = 'false';
                 break;
             default:
                 $tmp->available = 'true';
         }
         //$tmp->barcode = $product['ean13'];
         if (ProductDownload::getIdFromIdProduct($product['id_product'])) {
             $tmp->downloadable = 'true';
         }
         if (!($this->_settings['y_av'] == 2 and $product['quantity'] == 0)) {
             $market->add($tmp);
         }
     }
     if ($to_file) {
         $fp = fopen(dirname(__FILE__) . '/../../upload/yml.xml' . ($this->_settings['y_gz'] ? '.gz' : ''), 'w');
         fwrite($fp, $market->generate(false, $this->_settings['y_gz']));
         fclose($fp);
     } else {
         $market->generate(true, $this->_settings['y_gz']);
     }
 }
Example #16
0
 public function cleanPositions($table, $shopList = null)
 {
     if ($table == 'category') {
         //clean category position
         $cat = Category::getCategories(1, false, false);
         foreach ($cat as $i => $categ) {
             Category::cleanPositions((int) $categ['id_category']);
         }
     }
     if ($table == 'product') {
         //clean products position
         $cat = Category::getCategories(1, false, false);
         foreach ($cat as $i => $categ) {
             Product::cleanPositions((int) $categ['id_category']);
         }
     }
 }
    function displayFormInformations($obj, $currency, $languages, $defaultLanguage)
    {
        global $currentIndex, $cookie;
        $iso = Language::getIsoById(intval($cookie->id_lang));
        $divLangName = 'cnameยคcdescยคcdesc_shortยคclink_rewriteยคcmeta_descriptionยคcmeta_titleยคcmeta_keywordsยคctagsยคcavailable_nowยคcavailable_later';
        $qty_state = 'readonly';
        $qty = Attribute::getAttributeQty($this->getFieldValue($obj, 'id_product'));
        if ($qty === false) {
            if (Validate::isLoadedObject($obj)) {
                $qty = $this->getFieldValue($obj, 'quantity');
            } else {
                $qty = 1;
            }
            $qty_state = '';
        }
        $cover = Product::getCover($obj->id);
        $link = new Link();
        //includeDatepicker(array('reduction_from', 'reduction_to'));
        echo '
		<div class="tab-page" id="step1">
			<h4 class="tab">1. ' . $this->l('Info.') . '</h4>
			<b>' . $this->l('Product global informations') . '</b>&nbsp;-&nbsp;';
        if (isset($obj->id)) {
            echo '
			<a href="' . $link->getProductLink($this->getFieldValue($obj, 'id'), $this->getFieldValue($obj, 'link_rewrite', $defaultLanguage), Category::getLinkRewrite($this->getFieldValue($obj, 'id_category_default'), intval($cookie->id_lang))) . '"><img src="../img/admin/details.gif" alt="' . $this->l('View product in shop') . '" title="' . $this->l('View product in shop') . '" /> ' . $this->l('View product in shop') . '</a>';
            if (file_exists(_PS_MODULE_DIR_ . 'statsproduct/statsproduct.php')) {
                echo '&nbsp;-&nbsp;
					<a href="index.php?tab=AdminStatsModules&module=statsproduct&id_product=' . $obj->id . '&token=' . Tools::getAdminToken('AdminStatsModules' . intval(Tab::getIdFromClassName('AdminStatsModules')) . intval($cookie->id_employee)) . '"><img src="../modules/statsproduct/logo.gif" alt="' . $this->l('View product sales') . '" title="' . $this->l('View product sales') . '" /> ' . $this->l('View product sales') . '</a>';
            }
        }
        echo '	
			<hr class="clear"/>
			<br />
				<table cellpadding="5" style="width:100%">
					<tr>
						<td class="col-left">' . $this->l('Name:') . '</td>
						<td style="padding-bottom:5px;">';
        foreach ($languages as $language) {
            echo '			<div id="cname_' . $language['id_lang'] . '" style="display: ' . ($language['id_lang'] == $defaultLanguage ? 'block' : 'none') . '; float: left;">
								<input size="55" type="text" id="name_' . $language['id_lang'] . '" name="name_' . $language['id_lang'] . '"
								value="' . stripslashes(htmlspecialchars($this->getFieldValue($obj, 'name', $language['id_lang']))) . '"' . (!$obj->id ? ' onkeyup="copy2friendlyURL();"' : '') . ' onchange="updateCurrentText();" /><sup> *</sup>
								<span class="hint" name="help_box">' . $this->l('Invalid characters:') . ' <>;=#{}<span class="hint-pointer">&nbsp;</span></span>
							</div>';
        }
        $this->displayFlags($languages, $defaultLanguage, $divLangName, 'cname');
        echo '<script type="text/javascript">updateCurrentText();</script>
						</td>
					</tr>
					<tr>
						<td style="vertical-align:top">' . $this->l('Status:') . '</td>
						<td style="padding-bottom:5px;">
							<input style="float:left;" type="radio" name="active" id="active_on" value="1" ' . ($this->getFieldValue($obj, 'active') ? 'checked="checked" ' : '') . '/>
							<label for="active_on" class="t"><img src="../img/admin/enabled.gif" alt="' . $this->l('Enabled') . '" title="' . $this->l('Enabled') . '" style="float:left; padding:0px 5px 0px 5px;" />' . $this->l('Enabled') . '</label>
							<br style="clear:both;" />
							<input style="float:left;" type="radio" name="active" id="active_off" value="0" ' . (!$this->getFieldValue($obj, 'active') ? 'checked="checked" ' : '') . '/>
							<label for="active_off" class="t"><img src="../img/admin/disabled.gif" alt="' . $this->l('Disabled') . '" title="' . $this->l('Disabled') . '" style="float:left; padding:0px 5px 0px 5px" />' . $this->l('Disabled') . '</label>
						</td>
					</tr>
					<tr>
						<td>' . $this->l('Manufacturer:') . '</td>
						<td style="padding-bottom:5px;">
							<select name="id_manufacturer" id="id_manufacturer">
								<option value="0">-- ' . $this->l('Choose (optional)') . ' --</option>';
        if ($id_manufacturer = $this->getFieldValue($obj, 'id_manufacturer')) {
            echo '				<option value="' . $id_manufacturer . '" selected="selected">' . Manufacturer::getNameById($id_manufacturer) . '</option>
								<option disabled="disabled">----------</option>';
        }
        echo '
							</select>&nbsp;&nbsp;&nbsp;<a href="?tab=AdminManufacturers&addmanufacturer&token=' . Tools::getAdminToken('AdminManufacturers' . intval(Tab::getIdFromClassName('AdminManufacturers')) . intval($cookie->id_employee)) . '" onclick="return confirm(\'' . $this->l('Are you sure you want to delete entered product information?', __CLASS__, true, false) . '\');"><img src="../img/admin/add.gif" alt="' . $this->l('Create') . '" title="' . $this->l('Create') . '" /> <b>' . $this->l('Create') . '</b></a>
							<script type="text/javascript">
								var ajaxManufacturersClicked = false;
								$("select#id_manufacturer").focus(
									function() {
										if (ajaxManufacturersClicked == true) return; else ajaxManufacturersClicked = true;
										$.getJSON("' . dirname($currentIndex) . '/ajax.php",{ajaxProductManufacturers:1},
											function(j) {
												var options = \'\';
												for (var i = 0; i < getE("id_manufacturer").options.length; i++)
												{
													if (getE("id_manufacturer").options[i].innerHTML == \'----------\')
														options += \'<option disabled="disabled">----------</option>\';
													else
														options += \'<option value="\' +  getE("id_manufacturer").options[i].value + \'">\' + getE("id_manufacturer").options[i].innerHTML + \'</option>\';
												}
												for (var i = 0; i < j.length; i++)
													options += \'<option value="\' + j[i].optionValue + \'">\' + j[i].optionDisplay + \'</option>\';
												$("select#id_manufacturer").html(options);
											}
										)
									}
								);
							</script>
						</td>
					</tr>
					<tr>
						<td>' . $this->l('Supplier:') . '</td>
						<td style="padding-bottom:5px;">
							<select name="id_supplier" id="id_supplier">
								<option value="0">-- ' . $this->l('Choose (optional)') . ' --</option>';
        if ($id_supplier = $this->getFieldValue($obj, 'id_supplier')) {
            echo '				<option value="' . $id_supplier . '" selected="selected">' . Supplier::getNameById($id_supplier) . '</option>
								<option disabled="disabled">----------</option>';
        }
        echo '
							</select>&nbsp;&nbsp;&nbsp;<a href="?tab=AdminSuppliers&addsupplier&token=' . Tools::getAdminToken('AdminSuppliers' . intval(Tab::getIdFromClassName('AdminSuppliers')) . intval($cookie->id_employee)) . '" onclick="return confirm(\'' . $this->l('Are you sure you want to delete entered product information?', __CLASS__, true, false) . '\');"><img src="../img/admin/add.gif" alt="' . $this->l('Create') . '" title="' . $this->l('Create') . '" /> <b>' . $this->l('Create') . '</b></a>
							<script type="text/javascript">
								var ajaxSuppliersClicked = false;
								$("select#id_supplier").focus(
									function() {
										if (ajaxSuppliersClicked == true) return; else ajaxSuppliersClicked = true;
										$.getJSON("' . dirname($currentIndex) . '/ajax.php",{ajaxProductSuppliers:1},
											function(j) {
												var options = \'\';
												for (var i = 0; i < getE("id_supplier").options.length; i++)
												{
													if (getE("id_supplier").options[i].innerHTML == \'----------\')
														options += \'<option disabled="disabled">----------</option>\';
													else
														options += \'<option value="\' +  getE("id_supplier").options[i].value + \'">\' + getE("id_supplier").options[i].innerHTML + \'</option>\';
												}
												for (var i = 0; i < j.length; i++)
													options += \'<option value="\' + j[i].optionValue + \'">\' + j[i].optionDisplay + \'</option>\';
												$("select#id_supplier").html(options);
											}
										)
									}
								);
							</script>
						</td>
					</tr>
					<tr>
						<td class="col-left">' . $this->l('Reference:') . '</td>
						<td style="padding-bottom:5px;">
							<input size="55" type="text" name="reference" value="' . htmlentities($this->getFieldValue($obj, 'reference'), ENT_COMPAT, 'UTF-8') . '" style="width: 130px; margin-right: 44px;" />
							' . $this->l('EAN13:') . '<input size="55" maxlength="13" type="text" name="ean13" value="' . $this->getFieldValue($obj, 'ean13') . '" style="width: 110px; margin-left: 10px;" />
							<span class="hint" name="help_box">' . $this->l('Special characters allowed:') . ' .-_#\\<span class="hint-pointer">&nbsp;</span></span>
						</td>
					</tr>
                	<tr>
						<td class="col-left">' . $this->l('Supplier Reference:') . '</td>
						<td style="padding-bottom:5px;">
							<input size="55" type="text" name="supplier_reference" value="' . htmlentities($this->getFieldValue($obj, 'supplier_reference'), ENT_COMPAT, 'UTF-8') . '" style="width: 130px; margin-right: 44px;" />
							' . $this->l('Location:') . '<input size="55" type="text" name="location" value="' . $this->getFieldValue($obj, 'location') . '" style="width: 101px; margin-left: 10px;" />
							<span class="hint" name="help_box">' . $this->l('Special characters allowed:') . ' .-_#\\<span class="hint-pointer">&nbsp;</span></span>
						</td>
					</tr>					
					<tr>
						<td class="col-left">' . $this->l('Weight:') . '</td>
						<td style="padding-bottom:5px;">
							<input size="6" maxlength="6" name="weight" type="text" value="' . htmlentities($this->getFieldValue($obj, 'weight'), ENT_COMPAT, 'UTF-8') . '" onKeyUp="javascript:this.value = this.value.replace(/,/g, \'.\');" /> ' . Configuration::get('PS_WEIGHT_UNIT') . '
						</td>
					</tr>
					<tr><td colspan="2"><hr style="width:730px;"></td></tr>';
        $this->displayPack($obj);
        echo '		<tr><td colspan="2"><hr style="width:730px;"></td></tr>';
        /*
         * Form for add a virtual product like software, mp3, etc...
         */
        $productDownload = new ProductDownload();
        if ($id_product_download = $productDownload->getIdFromIdProduct($this->getFieldValue($obj, 'id'))) {
            $productDownload = new ProductDownload($id_product_download);
        }
        ?>
    <script type="text/javascript">
    // <![CDATA[
    	ThickboxI18nImage = '<?php 
        echo $this->l('Image');
        ?>
';
    	ThickboxI18nOf = '<?php 
        echo $this->l('of');
        ?>
';;
    	ThickboxI18nClose = '<?php 
        echo $this->l('Close');
        ?>
';
    	ThickboxI18nOrEscKey = '<?php 
        echo $this->l('(or "Esc")');
        ?>
';
    	ThickboxI18nNext = '<?php 
        echo $this->l('Next >');
        ?>
';
    	ThickboxI18nPrev = '<?php 
        echo $this->l('< Previous');
        ?>
';
    	tb_pathToImage = '../img/loadingAnimation.gif';
    //]]>
    </script>
	<script type="text/javascript" src="<?php 
        echo _PS_JS_DIR_;
        ?>
jquery/thickbox-modified.js"></script>
	<script type="text/javascript" src="<?php 
        echo _PS_JS_DIR_;
        ?>
jquery/ajaxfileupload.js"></script>
	<script type="text/javascript" src="<?php 
        echo _PS_JS_DIR_;
        ?>
date.js"></script>
	<style type="text/css">
		<!--
		@import url(<?php 
        echo _PS_CSS_DIR_;
        ?>
thickbox.css);
		-->
	</style>
	<script type="text/javascript">
	<!--	
	function toggleVirtualProduct(elt)
	{
		if (elt.checked)
		{
			$('#virtual_good').show('slow');
			getE('out_of_stock_1').checked = 'checked';
			getE('out_of_stock_2').readOnly = true;
			getE('out_of_stock_3').readOnly = true;
			getE('label_out_of_stock_2').setAttribute('for', '');
			getE('label_out_of_stock_3').setAttribute('for', '');
		}
		else
		{
			$('#virtual_good').hide('slow');
			getE('out_of_stock_2').readOnly = false;
			getE('out_of_stock_3').readOnly = false;
			getE('label_out_of_stock_2').setAttribute('for', 'out_of_stock_2');
			getE('label_out_of_stock_3').setAttribute('for', 'out_of_stock_3');
		}
	}
	function uploadFile()
	{
		$.ajaxFileUpload (
			{
				url:'./uploadProductFile.php',
				secureuri:false,
				fileElementId:'virtual_product_file',
				dataType: 'xml',

				success: function (data, status)
				{
					data = data.getElementsByTagName('return')[0];
					var result = data.getAttribute("result");
					var msg = data.getAttribute("msg");
					var fileName = data.getAttribute("filename");

					if(result == "error")
					{
						$("#upload-confirmation").html('<p>error: ' + msg + '</p>');
					}
					else
					{
						$('#virtual_product_file').remove();
						$('#virtual_product_file_label').hide();
						$('#virtual_product_name').attr('value', fileName);
						$('#upload-confirmation').html(
							'<a class="link" href="get-file-admin.php?file=' + msg + '"><?php 
        echo $this->l('The file');
        ?>
&nbsp;"' + fileName + '"&nbsp;<?php 
        echo $this->l('has successfully been uploaded');
        ?>
</a>' +
							'<input type="hidden" id="virtual_product_filename" name="virtual_product_filename" value="' + msg + '" />');
					}
				}
			}
		);
	}

	-->
	</script>
	<?php 
        echo '
		<script type="text/javascript">
			var newLabel = \'' . $this->l('New label') . '\';
			var choose_language = \'' . $this->l('Choose language:') . '\';
			var required = \'' . $this->l('required') . '\';
			var customizationUploadableFileNumber = ' . intval($this->getFieldValue($obj, 'uploadable_files')) . ';
			var customizationTextFieldNumber = ' . intval($this->getFieldValue($obj, 'text_fields')) . ';
			var uploadableFileLabel = 0;
			var textFieldLabel = 0;
			var defaultLanguage = ' . intval($defaultLanguage) . ';
			var languages = new Array();';
        $i = 0;
        foreach ($languages as $language) {
            echo 'languages[' . $i++ . '] = new Array(' . intval($language['id_lang']) . ', \'' . $language['iso_code'] . '\', \'' . htmlentities($language['name'], ENT_COMPAT, 'UTF-8') . '\');' . "\n";
        }
        echo '
		</script>';
        ?>
	<tr>
		<td colspan="2">
			<input type="checkbox" id="is_virtual_good" name="is_virtual_good" value="true" onchange="toggleVirtualProduct(this)" onclick="toggleVirtualProduct(this);" <?php 
        if (($productDownload->id or Tools::getValue('is_virtual_good') == 'true') and $productDownload->active) {
            echo 'checked="checked"';
        }
        ?>
 />
			<label for="is_virtual_good" class="t bold"><?php 
        echo $this->l('Is this a downloadable product?');
        ?>
</label>
			<div id="virtual_good" <?php 
        if (!$productDownload->id or !$productDownload->active) {
            echo 'style="display:none;"';
        }
        ?>
 >
	<?php 
        if (!ProductDownload::checkWritableDir()) {
            ?>
		<p class="alert">
			<?php 
            echo $this->l('Your download repository is not writable.');
            ?>
<br/>
			<?php 
            echo realpath(_PS_DOWNLOAD_DIR_);
            ?>
		</p>
	<?php 
        } else {
            ?>
			<?php 
            if ($productDownload->id) {
                echo '<input type="hidden" id="virtual_product_id" name="virtual_product_id" value="' . $productDownload->id . '" />';
            }
            ?>
				<p class="block">
	<?php 
            if (!$productDownload->checkFile()) {
                ?>
		<?php 
                if ($productDownload->id) {
                    ?>
					<p class="alert">
						<?php 
                    echo $this->l('This product is missing');
                    ?>
:<br/>
						<?php 
                    echo realpath(_PS_DOWNLOAD_DIR_) . '/' . $productDownload->physically_filename;
                    ?>
					</p>
		<?php 
                }
                ?>
					<p><?php 
                echo $this->l('Your server\'s maximum upload file size is') . ':&nbsp;' . ini_get('upload_max_filesize');
                ?>
</p>
					<?php 
                if (!strval(Tools::getValue('virtual_product_filename'))) {
                    ?>
					<label id="virtual_product_file_label" for="virtual_product_file" class="t"><?php 
                    echo $this->l('Upload a file');
                    ?>
</label>
					<input type="file" id="virtual_product_file" name="virtual_product_file" value="" class="" onchange="uploadFile()" maxlength="<?php 
                    echo $this->maxFileSize;
                    ?>
" />
					<?php 
                }
                ?>
					<div id="upload-confirmation">
					<?php 
                if ($up_filename = strval(Tools::getValue('virtual_product_filename'))) {
                    ?>
						<input type="hidden" id="virtual_product_filename" name="virtual_product_filename" value="<?php 
                    echo $up_filename;
                    ?>
" />
					<?php 
                }
                ?>
					</div>
	<?php 
            } else {
                ?>
					<input type="hidden" id="virtual_product_filename" name="virtual_product_filename" value="<?php 
                echo $productDownload->physically_filename;
                ?>
" />
					<?php 
                echo $this->l('This is the link') . ':&nbsp;' . $productDownload->getHtmlLink(false, true);
                ?>
					<a href="confirm.php?height=200&amp;width=300&amp;modal=true&amp;referer=<?php 
                echo rawurlencode($_SERVER['REQUEST_URI'] . '&deleteVirtualProduct=true');
                ?>
" class="thickbox red" title="<?php 
                echo $this->l('Delete this file');
                ?>
"><?php 
                echo $this->l('Delete this file');
                ?>
</a>
	<?php 
            }
            // check if file exists
            ?>
				</p>
				<p class="block">
					<label for="virtual_product_name" class="t"><?php 
            echo $this->l('Filename');
            ?>
</label>
					<input type="text" id="virtual_product_name" name="virtual_product_name" class="" value="<?php 
            echo $productDownload->id > 0 ? $productDownload->display_filename : htmlentities(Tools::getValue('virtual_product_name'), ENT_COMPAT, 'UTF-8');
            ?>
" />
					<span class="hint" name="help_box" style="display:none;"><?php 
            echo $this->l('The complete filename with its extension (e.g., Our best song.mp3)');
            ?>
</span>
				</p>
				<p class="block">
					<label for="virtual_product_nb_downloable" class="t"><?php 
            echo $this->l('Number of downloads');
            ?>
</label>
					<input type="text" id="virtual_product_nb_downloable" name="virtual_product_nb_downloable" value="<?php 
            echo $productDownload->id > 0 ? $productDownload->nb_downloadable : htmlentities(Tools::getValue('virtual_product_nb_downloable'), ENT_COMPAT, 'UTF-8');
            ?>
" class="" size="6" />
					<span class="hint" name="help_box" style="display:none"><?php 
            echo $this->l('Number of authorized downloads per customer');
            ?>
</span>
				</p>
				<p class="block">
					<label for="virtual_product_expiration_date" class="t"><?php 
            echo $this->l('Expiration date');
            ?>
</label>
					<input type="text" id="virtual_product_expiration_date" name="virtual_product_expiration_date" value="<?php 
            echo $productDownload->id > 0 ? (!empty($productDownload->date_expiration) and $productDownload->date_expiration != '0000-00-00 00:00:00') ? date('Y-m-d', strtotime($productDownload->date_expiration)) : '' : htmlentities(Tools::getValue('virtual_product_expiration_date'), ENT_COMPAT, 'UTF-8');
            ?>
" size="11" maxlength="10" autocomplete="off" /> <?php 
            echo $this->l('Format: YYYY-MM-DD');
            ?>
					<span class="hint" name="help_box" style="display:none"><?php 
            echo $this->l('No expiration date if you leave this blank');
            ?>
</span>
				</p>
				<p class="block">
					<label for="virtual_product_nb_days" class="t"><?php 
            echo $this->l('Number of days');
            ?>
</label>
					<input type="text" id="virtual_product_nb_days" name="virtual_product_nb_days" value="<?php 
            echo $productDownload->id > 0 ? $productDownload->nb_days_accessible : htmlentities(Tools::getValue('virtual_product_nb_days'), ENT_COMPAT, 'UTF-8');
            ?>
" class="" size="4" /><sup> *</sup>
					<span class="hint" name="help_box" style="display:none"><?php 
            echo $this->l('How many days this file can be accessed by customers');
            ?>
</span>
				</p>
	<?php 
        }
        // check if download directory is writable
        ?>
			</div>
		</td>
	</tr>
	<tr><td colspan="2" style="padding-bottom:5px;"><hr style="width:730px;"></td></tr>
	<script type="text/javascript">
		if ($('#is_virtual_good').attr('checked'))
			$('#virtual_good').show('slow');
	</script>

<?php 
        echo '
					<tr>
						<td class="col-left">' . $this->l('Pre-tax wholesale price:') . '</td>
						<td style="padding-bottom:5px;">
							' . ($currency->format == 1 ? $currency->sign . ' ' : '') . '<input size="11" maxlength="14" name="wholesale_price" type="text" value="' . htmlentities($this->getFieldValue($obj, 'wholesale_price'), ENT_COMPAT, 'UTF-8') . '" onKeyUp="javascript:this.value = this.value.replace(/,/g, \'.\');" />' . ($currency->format == 2 ? ' ' . $currency->sign : '') . '
							<span style="margin-left:10px">' . $this->l('The wholesale price at which you bought this product') . '</span>
						</td>
					</tr>';
        echo '
					<tr>
						<td class="col-left">' . $this->l('Pre-tax retail price:') . '</td>
						<td style="padding-bottom:5px;">
							' . ($currency->format == 1 ? $currency->sign . ' ' : '') . '<input size="11" maxlength="14" id="priceTE" name="price" type="text" value="' . $this->getFieldValue($obj, 'price') . '" onKeyUp="javascript:this.value = this.value.replace(/,/g, \'.\'); calcPriceTI();" />' . ($currency->format == 2 ? ' ' . $currency->sign : '') . '<sup> *</sup>
							<span style="margin-left:2px">' . $this->l('The pre-tax retail price to sell this product') . '</span>
						</td>
					</tr>';
        $taxes = Tax::getTaxes(intval($cookie->id_lang));
        echo '<script type="text/javascript">';
        echo 'noTax = ' . (Tax::excludeTaxeOption() ? 'true' : 'false'), ";\n";
        echo 'taxesArray = new Array ();' . "\n";
        echo 'taxesArray[0] = 0', ";\n";
        foreach ($taxes as $k => $tax) {
            echo 'taxesArray[' . $tax['id_tax'] . ']=' . $tax['rate'] . "\n";
        }
        echo '
					</script>';
        echo '
					<tr>
						<td class="col-left">' . $this->l('Tax:') . '</td>
						<td style="padding-bottom:5px;">
							<select onChange="javascript:calcPriceTI();" name="id_tax" id="id_tax" ' . (Tax::excludeTaxeOption() ? 'disabled="disabled"' : '') . '>
								<option value="0"' . ($this->getFieldValue($obj, 'id_tax') == 0 ? ' selected="selected"' : '') . '>' . $this->l('No tax') . '</option>';
        foreach ($taxes as $k => $tax) {
            echo '
								<option value="' . $tax['id_tax'] . '"' . ($this->getFieldValue($obj, 'id_tax') == $tax['id_tax'] ? ' selected="selected"' : '') . '>' . stripslashes($tax['name']) . ' (' . $tax['rate'] . '%)</option>';
        }
        echo '
							</select>';
        if (Tax::excludeTaxeOption()) {
            echo '<span style="margin-left:10px; color:red;">' . $this->l('Taxes are currently disabled') . '</span> (<b><a href="index.php?tab=AdminTaxes&token=' . Tools::getAdminToken('AdminTaxes' . intval(Tab::getIdFromClassName('AdminTaxes')) . intval($cookie->id_employee)) . '">' . $this->l('Tax options') . '</a></b>)';
            echo '<input type="hidden" value="' . intval($this->getFieldValue($obj, 'id_tax')) . '" name="id_tax" />';
        }
        echo '</td>
					</tr>
					<tr>
						<td class="col-left">' . $this->l('Retail price with tax:') . '</td>
						<td style="padding-bottom:5px;">
							' . ($currency->format == 1 ? ' ' . $currency->sign : '') . ' <input size="11" maxlength="14" id="priceTI" type="text" value="" onKeyUp="noComma(\'priceTI\'); calcPriceTE();" />' . ($currency->format == 2 ? ' ' . $currency->sign : '') . '
							<span style="margin-left:10px">
						</td>
					</tr>
					<tr>
						<td class="col-left">' . $this->l('Eco-tax:') . '</td>
						<td style="padding-bottom:5px;">
							' . ($currency->format == 1 ? $currency->sign . ' ' : '') . '<input size="11" maxlength="14" id="ecotax" name="ecotax" type="text" value="' . $this->getFieldValue($obj, 'ecotax') . '" onKeyUp="javascript:this.value = this.value.replace(/,/g, \'.\'); if (parseInt(this.value) > getE(\'priceTE\').value) this.value = getE(\'priceTE\').value; if (isNaN(this.value)) this.value = 0;" />' . ($currency->format == 2 ? ' ' . $currency->sign : '') . '
							<span style="margin-left:10px">(' . $this->l('already included in price') . ')</span>
						</td>
					</tr>
					<tr>
						<td class="col-left">' . $this->l('Reduction amount:') . '</td>
						<td style="padding-bottom:5px;">
							' . ($currency->format == 1 ? ' ' . $currency->sign . ' ' : '') . '<input size="11" maxlength="14" type="text" name="reduction_price" id="reduction_price" value="' . $this->getFieldValue($obj, 'reduction_price') . '" onkeyup="javascript:this.value = this.value.replace(/,/g, \'.\'); var key = window.event ? window.event.keyCode : event.which; if (key != 9) reductionPrice();" /> ' . ($currency->format == 2 ? ' ' . $currency->sign : '') . '
							<span style="padding-right: 15px; padding-left: 15px; font-weight: bold">' . $this->l('OR') . '</span>
							<input size="10" maxlength="14" type="text" name="reduction_percent" id="reduction_percent" value="' . $this->getFieldValue($obj, 'reduction_percent') . '" onkeyup="javascript:this.value = this.value.replace(/,/g, \'.\'); var key = window.event ? window.event.keyCode : event.which; if (key != 9) reductionPercent();" /> %
						</td>
					</tr>
					<tr>
						<td class="col-left">&nbsp;</td>
						<td>' . $this->l('available from') . ' <input type="text" id="reduction_from" name="reduction_from" value="' . (($from = $this->getFieldValue($obj, 'reduction_from') and $from != '0000-00-00' and $from != '1942-01-01') ? $from : date('Y-m-d')) . '" />
							' . $this->l('to') . ' <input type="text" id="reduction_to" name="reduction_to" value="' . (($to = $this->getFieldValue($obj, 'reduction_to') and $to != '0000-00-00' and $to != '1942-01-01') ? $to : date('Y-m-d')) . '" />
							<p>' . $this->l('Leave same dates for undefined duration') . '</p>
						</td>
					</tr>
					<tr>
						<td class="col-left">&nbsp;</td>
						<td style="padding-bottom:5px;">
							<input type="checkbox" name="on_sale" id="on_sale" style="padding-top: 5px;" ' . ($this->getFieldValue($obj, 'on_sale') ? 'checked="checked"' : '') . 'value="1" />&nbsp;<label for="on_sale" class="t">' . $this->l('Display "on sale" icon on product page and text on product listing') . '</label>
						</td>
					</tr>
					<tr>
						<td class="col-left"><b>' . $this->l('Final retail price:') . '</b></td>
						<td style="padding-bottom:5px;">
							' . ($currency->format == 1 ? $currency->sign . ' ' : '') . '<span id="finalPrice" style="font-weight: bold;"></span>' . ($currency->format == 2 ? ' ' . $currency->sign : '') . '
						</td>
					</tr>
					<tr><td colspan="2" style="padding-bottom:5px;"><hr style="width:730px;"></td></tr>
					<tr>
						<td class="col-left">' . $this->l('Quantity:') . '</td>
						<td style="padding-bottom:5px;"><input size="3" maxlength="6" ' . $qty_state . ' name="quantity" type="text" value="' . $qty . '" ' . ((isset($_POST['attQty']) and $_POST['attQty']) ? 'onclick="alert(\'' . $this->l('Quantity is already defined by Attributes') . '.<br />' . $this->l('Delete attributes first') . '.\');" readonly="readonly" ' : '') . '/><sup> *</sup>
					</tr>
					<tr>
						<td class="col-left">' . $this->l('Displayed text when in-stock:') . '</td>
						<td style="padding-bottom:5px;">';
        foreach ($languages as $language) {
            echo '
							<div id="cavailable_now_' . $language['id_lang'] . '" style="display: ' . ($language['id_lang'] == $defaultLanguage ? 'block' : 'none') . '; float: left;">
								<input size="30" type="text" id="available_now_' . $language['id_lang'] . '" name="available_now_' . $language['id_lang'] . '"
								value="' . stripslashes(htmlentities($this->getFieldValue($obj, 'available_now', $language['id_lang']), ENT_COMPAT, 'UTF-8')) . '" />
								<span class="hint" name="help_box">' . $this->l('Forbidden characters:') . ' <>;=#{}<span class="hint-pointer">&nbsp;</span></span>
							</div>';
        }
        $this->displayFlags($languages, $defaultLanguage, $divLangName, 'cavailable_now');
        echo '			</td>
					</tr>
					<tr>
						<td class="col-left">' . $this->l('Displayed text when allowed to be back-ordered:') . '</td>
						<td style="padding-bottom:5px;">';
        foreach ($languages as $language) {
            echo '
							<div id="cavailable_later_' . $language['id_lang'] . '" style="display: ' . ($language['id_lang'] == $defaultLanguage ? 'block' : 'none') . '; float: left;">
								<input size="30" type="text" id="available_later_' . $language['id_lang'] . '" name="available_later_' . $language['id_lang'] . '"
								value="' . stripslashes(htmlentities($this->getFieldValue($obj, 'available_later', $language['id_lang']), ENT_COMPAT, 'UTF-8')) . '" />
								<span class="hint" name="help_box">' . $this->l('Forbidden characters:') . ' <>;=#{}<span class="hint-pointer">&nbsp;</span></span>
							</div>';
        }
        $this->displayFlags($languages, $defaultLanguage, $divLangName, 'cavailable_later');
        echo '			</td>
					</tr>

					<script type="text/javascript" src="../js/price.js"></script>
					<script type="text/javascript">
						calcPriceTI();
					</script>

					<tr>
						<td class="col-left">' . $this->l('When out of stock:') . '</td>
						<td style="padding-bottom:5px;">
							<input type="radio" name="out_of_stock" id="out_of_stock_1" value="0" ' . (intval($this->getFieldValue($obj, 'out_of_stock')) == 0 ? 'checked="checked"' : '') . '/> <label for="out_of_stock_1" class="t" id="label_out_of_stock_1">' . $this->l('Deny orders') . '</label>
							<br /><input type="radio" name="out_of_stock" id="out_of_stock_2" value="1" ' . ($this->getFieldValue($obj, 'out_of_stock') == 1 ? 'checked="checked"' : '') . '/> <label for="out_of_stock_2" class="t" id="label_out_of_stock_2">' . $this->l('Allow orders') . '</label>
							<br /><input type="radio" name="out_of_stock" id="out_of_stock_3" value="2" ' . ($this->getFieldValue($obj, 'out_of_stock') == 2 ? 'checked="checked"' : '') . '/> <label for="out_of_stock_3" class="t" id="label_out_of_stock_3">' . $this->l('Default:') . ' <i>' . $this->l(intval(Configuration::get('PS_ORDER_OUT_OF_STOCK')) ? 'Allow orders' : 'Deny orders') . '</i> (' . $this->l('as set in') . ' <a href="index.php?tab=AdminPPreferences&token=' . Tools::getAdminToken('AdminPPreferences' . intval(Tab::getIdFromClassName('AdminPPreferences')) . intval($cookie->id_employee)) . '"  onclick="return confirm(\'' . $this->l('Are you sure you want to delete entered product information?', __CLASS__, true, false) . '\');">' . $this->l('Preferences') . '</a>)</label>
						</td>
					</tr>

					<tr><td colspan="2" style="padding-bottom:5px;"><hr style="width:730px;"></td></tr>
					<tr>
						<td class="col-left"><label for="id_category_default" class="t">' . $this->l('Default category:') . '</label></td>
						<td>
							<select id="id_category_default" name="id_category_default" onchange="checkDefaultCategory(this.value);">';
        $categories = Category::getCategories(intval($cookie->id_lang), false);
        Category::recurseCategory($categories, $categories[0][1], 1, $this->getFieldValue($obj, 'id_category_default') ? $this->getFieldValue($obj, 'id_category_default') : Tools::getValue('id_category', 1));
        echo '
							</select>
						</td>
					</tr>
					<tr>
						<td class="col-left">' . $this->l('Catalog:') . '</td>
						<td>
							<div style="overflow: auto; min-height: 300px; padding-top: 0.6em;" id="categoryList">
							<table cellspacing="0" cellpadding="0" class="table">
									<tr>
										<th><input type="checkbox" name="checkme" class="noborder" onclick="checkDelBoxes(this.form, \'categoryBox[]\', this.checked)" /></th>
										<th>' . $this->l('ID') . '</th>
										<th style="width: 400px">' . $this->l('Name') . '</th>
									</tr>';
        $done = array();
        $index = array();
        $indexedCategories = isset($_POST['categoryBox']) ? $_POST['categoryBox'] : ($obj->id ? Product::getIndexedCategories($obj->id) : array());
        foreach ($indexedCategories as $k => $row) {
            $index[] = $row['id_category'];
        }
        $this->recurseCategoryForInclude($index, $categories, $categories[0][1], 1, $obj->id_category_default);
        echo '
							</table>
							<p style="padding:0px; margin:0px 0px 10px 0px;">' . $this->l('Mark all checkbox(es) of categories in which product is to appear') . '<sup> *</sup></p>
							</div>
						</td>
					</tr>
					<tr><td colspan="2" style="padding-bottom:5px;"><hr style="width:730px;"></td></tr>
					<tr><td colspan="2">
						<span onclick="javascript:openCloseLayer(\'seo\');" style="cursor: pointer"><img src="../img/admin/arrow.gif" alt="' . $this->l('SEO') . '" title="' . $this->l('SEO') . '" style="float:left; margin-right:5px;"/>' . $this->l('Click here to improve product\'s rank in search engines (SEO)') . '</span><br />
						<div id="seo" style="display: none; padding-top: 15px;">
							<table>
								<tr>
									<td class="col-left">' . $this->l('Meta title:') . '</td>
									<td>';
        foreach ($languages as $language) {
            echo '
										<div id="cmeta_title_' . $language['id_lang'] . '" style="display: ' . ($language['id_lang'] == $defaultLanguage ? 'block' : 'none') . '; float: left;">
											<input size="55" type="text" id="meta_title_' . $language['id_lang'] . '" name="meta_title_' . $language['id_lang'] . '"
											value="' . htmlentities($this->getFieldValue($obj, 'meta_title', $language['id_lang']), ENT_COMPAT, 'UTF-8') . '" />
											<span class="hint" name="help_box">' . $this->l('Forbidden characters:') . ' <>;=#{}<span class="hint-pointer">&nbsp;</span></span>
										</div>';
        }
        $this->displayFlags($languages, $defaultLanguage, $divLangName, 'cmeta_title');
        echo '
										<p style="clear: both">' . $this->l('Product page title; leave blank to use product name') . '</p>
									</td>
								</tr>
								<tr>
									<td class="col-left">' . $this->l('Meta description:') . '</td>
									<td>';
        foreach ($languages as $language) {
            echo '
										<div id="cmeta_description_' . $language['id_lang'] . '" style="display: ' . ($language['id_lang'] == $defaultLanguage ? 'block' : 'none') . '; float: left;">
											<input size="55" type="text" id="meta_description_' . $language['id_lang'] . '" name="meta_description_' . $language['id_lang'] . '"
											value="' . htmlentities($this->getFieldValue($obj, 'meta_description', $language['id_lang']), ENT_COMPAT, 'UTF-8') . '" />
											<span class="hint" name="help_box">' . $this->l('Forbidden characters:') . ' <>;=#{}<span class="hint-pointer">&nbsp;</span></span>
										</div>';
        }
        $this->displayFlags($languages, $defaultLanguage, $divLangName, 'cmeta_description');
        echo '
										<p style="clear: both">' . $this->l('A single sentence for HTML header') . '</p>
									</td>
								</tr>
								<tr>
									<td class="col-left">' . $this->l('Meta keywords:') . '</td>
									<td>';
        foreach ($languages as $language) {
            echo '
										<div id="cmeta_keywords_' . $language['id_lang'] . '" style="display: ' . ($language['id_lang'] == $defaultLanguage ? 'block' : 'none') . '; float: left;">
											<input size="55" type="text" id="meta_keywords_' . $language['id_lang'] . '" name="meta_keywords_' . $language['id_lang'] . '"
											value="' . htmlentities($this->getFieldValue($obj, 'meta_keywords', $language['id_lang']), ENT_COMPAT, 'UTF-8') . '" />
											<span class="hint" name="help_box">' . $this->l('Forbidden characters:') . ' <>;=#{}<span class="hint-pointer">&nbsp;</span></span>
										</div>';
        }
        $this->displayFlags($languages, $defaultLanguage, $divLangName, 'cmeta_keywords');
        echo '
										<p style="clear: both">' . $this->l('Keywords for HTML header, separated by a comma') . '</p>
									</td>
								</tr>
								<tr>
									<td class="col-left">' . $this->l('Friendly URL:') . '</td>
									<td>';
        foreach ($languages as $language) {
            echo '
										<div id="clink_rewrite_' . $language['id_lang'] . '" style="display: ' . ($language['id_lang'] == $defaultLanguage ? 'block' : 'none') . '; float: left;">
											<input size="55" type="text" id="link_rewrite_' . $language['id_lang'] . '" name="link_rewrite_' . $language['id_lang'] . '"
											value="' . htmlentities($this->getFieldValue($obj, 'link_rewrite', $language['id_lang']), ENT_COMPAT, 'UTF-8') . '" onkeyup="this.value = str2url(this.value); updateFriendlyURL();" /><sup> *</sup>
											<span class="hint" name="help_box">' . $this->l('Only letters and the "less" character are allowed') . '<span class="hint-pointer">&nbsp;</span></span>
										</div>';
        }
        $this->displayFlags($languages, $defaultLanguage, $divLangName, 'clink_rewrite');
        global $cookie;
        $iso = Language::getIsoById(intval($cookie->id_lang));
        echo '
										<p style="clear: both; width: 360px; word-wrap: break-word; overflow: auto;">' . $this->l('Product link will look like this:') . ' ' . (Configuration::get('PS_SSL_ENABLED') ? 'https://' : 'http://') . $_SERVER['SERVER_NAME'] . '/id_product-<span id="friendly-url"></span>.html</p>
									</td>
								</tr>
								<script type="text/javascript">updateFriendlyURL();</script>';
        echo '</td></tr></table>
						</div>
					</td></tr>
					<tr><td colspan="2" style="padding-bottom:5px;"><hr style="width:730px;"></td></tr>
					<tr>
						<td class="col-left">' . $this->l('Short description:') . '<br /><br /><i>(' . $this->l('appears in search results') . ')</i></td>
						<td style="padding-bottom:5px;">';
        foreach ($languages as $language) {
            echo '
							<div id="cdesc_short_' . $language['id_lang'] . '" style="display: ' . ($language['id_lang'] == $defaultLanguage ? 'block' : 'none') . ';float: left;">
								<textarea class="rte" cols="100" rows="10" id="description_short_' . $language['id_lang'] . '" name="description_short_' . $language['id_lang'] . '">' . htmlentities(stripslashes($this->getFieldValue($obj, 'description_short', $language['id_lang'])), ENT_COMPAT, 'UTF-8') . '</textarea>
							</div>';
        }
        $this->displayFlags($languages, $defaultLanguage, $divLangName, 'cdesc_short');
        echo '
						</td>
					</tr>
					<tr>
						<td class="col-left">' . $this->l('Description:') . '</td>
						<td style="padding-bottom:5px;">';
        foreach ($languages as $language) {
            echo '
							<div id="cdesc_' . $language['id_lang'] . '" style="display: ' . ($language['id_lang'] == $defaultLanguage ? 'block' : 'none') . ';float: left;">
								<textarea class="rte" cols="100" rows="20" id="description_' . $language['id_lang'] . '" name="description_' . $language['id_lang'] . '">' . htmlentities(stripslashes($this->getFieldValue($obj, 'description', $language['id_lang'])), ENT_COMPAT, 'UTF-8') . '</textarea>
							</div>';
        }
        $this->displayFlags($languages, $defaultLanguage, $divLangName, 'cdesc');
        echo '
						</td>
					</tr>';
        echo '<tr><td class="col-left">' . $this->l('Tags:') . '</td><td style="padding-bottom:5px;">';
        foreach ($languages as $language) {
            echo '<div id="ctags_' . $language['id_lang'] . '" style="display: ' . ($language['id_lang'] == $defaultLanguage ? 'block' : 'none') . '; float: left;">
							<input size="55" type="text" id="tags_' . $language['id_lang'] . '" name="tags_' . $language['id_lang'] . '"
							value="' . htmlentities(Tools::getValue('tags_' . $language['id_lang'], $obj->getTags($language['id_lang'], true)), ENT_COMPAT, 'UTF-8') . '" />
							<span class="hint" name="help_box">' . $this->l('Forbidden characters:') . ' !<>;?=+#"&deg;{}_$%<span class="hint-pointer">&nbsp;</span></span>
						  </div>';
        }
        $this->displayFlags($languages, $defaultLanguage, $divLangName, 'ctags');
        echo '<p style="clear: both">' . $this->l('Tags separated by commas (e.g., dvd, dvd player, hifi)') . '</p>';
        echo '</td>
					</tr>';
        $accessories = Product::getAccessoriesLight(intval($cookie->id_lang), $obj->id);
        if ($postAccessories = Tools::getValue('inputAccessories')) {
            $postAccessoriesTab = explode('-', Tools::getValue('inputAccessories'));
            foreach ($postAccessoriesTab as $accessoryId) {
                if (!$this->haveThisAccessory($accessoryId, $accessories) and $accessory = Product::getAccessoryById($accessoryId)) {
                    $accessories[] = $accessory;
                }
            }
        }
        echo '
					<tr>
						<td class="col-left">' . $this->l('Accessories:') . '<br /><br /><i>' . $this->l('(Do not forget to Save the product afterward)') . '</i></td>
						<td style="padding-bottom:5px;">
							<div id="divAccessories">';
        foreach ($accessories as $accessory) {
            echo $accessory['name'] . '<span onclick="delAccessory(' . $accessory['id_product'] . ');" style="cursor: pointer;"><img src="../img/admin/delete.gif" /></span><br />';
        }
        echo '</div>
							<input type="hidden" name="inputAccessories" id="inputAccessories" value="';
        foreach ($accessories as $accessory) {
            echo $accessory['id_product'] . '-';
        }
        echo '" />
							<input type="hidden" name="nameAccessories" id="nameAccessories" value="';
        foreach ($accessories as $accessory) {
            echo $accessory['name'] . 'ยค';
        }
        echo '" />
							<script type="text/javascript">
								var formProduct;
								var accessories = new Array();
								
								function fillAccessories()
								{
									$.getJSON("' . dirname($currentIndex) . '/ajax.php",{ajaxProductAccessories:1,id_lang:' . intval($cookie->id_lang) . ',id_product:' . ($obj->id ? intval($obj->id) : 0) . '},
										function(j)
										{
											for (var i = 0; i < j.length; i++)
												accessories[i] = new Array(j[i].value, j[i].text);
												
											formProduct = document.layers ? document.forms.product : document.product;
											formProduct.selectAccessories.length = accessories.length + 1;
											for (i = 0, j = 1; i < accessories.length; i++)
											{
												if (formProduct.filter.value)
													if (accessories[i][1].toLowerCase().indexOf(formProduct.filter.value.toLowerCase()) == -1)
														continue;
												formProduct.selectAccessories.options[j].value = accessories[i][0];
												formProduct.selectAccessories.options[j].text = accessories[i][1];
												j++;
											}
											if (j == 1)
											{
												formProduct.selectAccessories.length = 2;
												formProduct.selectAccessories.options[1].value = -1;
												formProduct.selectAccessories.options[1].text = \'' . $this->l('No match found') . '\';
												formProduct.selectAccessories.options.selectedIndex = 1;
											}
											else
											{
												formProduct.selectAccessories.length = j;
												formProduct.selectAccessories.options.selectedIndex = (formProduct.filter.value == \'\' ? 0 : 1);
											}
										}
									);
								}
							</script>
							<select id="selectAccessories" name="selectAccessories" style="width: 380px;">
								<option value="0" selected="selected">-- ' . $this->l('Choose') . ' --</option>
							</select>
							<script type="text/javascript">
								fillAccessories();
							</script>
							<span onclick="addAccessory();" style="cursor: pointer;"><img src="../img/admin/add.gif" alt="' . $this->l('Add an accessory') . '" title="' . $this->l('Add an accessory') . '" /></span>
							<br />' . $this->l('Filter:') . ' <input type="text" size="25" name="filter" onkeyup="fillAccessories();" class="space" />
						</td>
					</tr>
					<tr><td colspan="2" style="padding-bottom:10px;"><hr style="width:730px;"></td></tr>
					<tr>
						<td colspan="2" style="text-align:center;">
							<input type="submit" value="' . $this->l('Save') . '" name="submitAdd' . $this->table . '" class="button" />
							&nbsp;<input type="submit" value="' . $this->l('Save and stay') . '" name="submitAdd' . $this->table . 'AndStay" class="button" /></td>
					</tr>
				</table>
			</div>

			<script type="text/javascript" src="' . __PS_BASE_URI__ . 'js/tinymce/jscripts/tiny_mce/jquery.tinymce.js"></script>
			<script type="text/javascript">
			function tinyMCEInit(element)
			{
				$().ready(function() {
					$(element).tinymce({
						// Location of TinyMCE script
						script_url : \'' . __PS_BASE_URI__ . 'js/tinymce/jscripts/tiny_mce/tiny_mce.js\',
						// General options
						theme : "advanced",
						plugins : "safari,pagebreak,style,layer,table,advimage,advlink,inlinepopups,media,searchreplace,contextmenu,paste,directionality,fullscreen",
						// Theme options
						theme_advanced_buttons1 : "newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,styleselect,formatselect,fontselect,fontsizeselect",
						theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,,|,forecolor,backcolor",
						theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,media,|,ltr,rtl,|,fullscreen",
						theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,|,cite,abbr,acronym,del,ins,attribs,|,pagebreak",
						theme_advanced_toolbar_location : "top",
						theme_advanced_toolbar_align : "left",
						width : "100",
						theme_advanced_statusbar_location : "bottom",
						theme_advanced_resizing : true,
						content_css : "' . __PS_BASE_URI__ . 'themes/' . _THEME_NAME_ . '/css/global.css",
						// Drop lists for link/image/media/template dialogs
						template_external_list_url : "lists/template_list.js",
						external_link_list_url : "lists/link_list.js",
						external_image_list_url : "lists/image_list.js",
						media_external_list_url : "lists/media_list.js",
						elements : "nourlconvert",
						convert_urls : false,
						language : "' . (file_exists(_PS_ROOT_DIR_ . '/js/tinymce/jscripts/tiny_mce/langs/' . $iso . '.js') ? $iso : 'en') . '"
					});
				});
			}
			tinyMCEInit(\'textarea.rte\');
			toggleVirtualProduct(getE(\'is_virtual_good\'));
			</script>
		';
    }
Example #18
0
 /**
  * Manage page processing
  */
 public function postProcess()
 {
     if (!isset($this->table)) {
         return false;
     }
     // set token
     $token = Tools::getValue('token') ? Tools::getValue('token') : $this->token;
     // Sub included tab postProcessing
     $this->includeSubTab('postProcess', array('status', 'submitAdd1', 'submitDel', 'delete', 'submitFilter', 'submitReset'));
     /* Delete object image */
     if (isset($_GET['deleteImage'])) {
         if (Validate::isLoadedObject($object = $this->loadObject())) {
             /** @var ObjectModel $object */
             if ($object->deleteImage()) {
                 Tools::redirectAdmin(self::$currentIndex . '&add' . $this->table . '&' . $this->identifier . '=' . Tools::getValue($this->identifier) . '&conf=7&token=' . $token);
             }
         }
         $this->_errors[] = Tools::displayError('An error occurred during image deletion (cannot load object).');
     } elseif (isset($_GET['delete' . $this->table])) {
         if ($this->tabAccess['delete'] === '1') {
             if (Validate::isLoadedObject($object = $this->loadObject()) && isset($this->fieldImageSettings)) {
                 /** @var ObjectModel $object */
                 // check if request at least one object with noZeroObject
                 if (isset($object->noZeroObject) && count(call_user_func(array($this->className, $object->noZeroObject))) <= 1) {
                     $this->_errors[] = Tools::displayError('You need at least one object.') . ' <b>' . $this->table . '</b><br />' . Tools::displayError('You cannot delete all of the items.');
                 } else {
                     if ($this->deleted) {
                         $object->deleteImage();
                         $object->deleted = 1;
                         if (method_exists($object, 'cleanPositions')) {
                             $object->cleanPositions();
                         }
                         if ($object->update()) {
                             Tools::redirectAdmin(self::$currentIndex . '&conf=1&token=' . $token);
                         }
                     } elseif ($object->delete()) {
                         if (method_exists($object, 'cleanPositions')) {
                             $object->cleanPositions();
                         }
                         Tools::redirectAdmin(self::$currentIndex . '&conf=1&token=' . $token);
                     }
                     $this->_errors[] = Tools::displayError('An error occurred during deletion.');
                 }
             } else {
                 $this->_errors[] = Tools::displayError('An error occurred while deleting object.') . ' <b>' . $this->table . '</b> ' . Tools::displayError('(cannot load object)');
             }
         } else {
             $this->_errors[] = Tools::displayError('You do not have permission to delete here.');
         }
     } elseif ((isset($_GET['status' . $this->table]) || isset($_GET['status'])) && Tools::getValue($this->identifier)) {
         if ($this->tabAccess['edit'] === '1') {
             if (Validate::isLoadedObject($object = $this->loadObject())) {
                 /** @var ObjectModel $object */
                 if ($object->toggleStatus()) {
                     Tools::redirectAdmin(self::$currentIndex . '&conf=5' . (($id_category = (int) Tools::getValue('id_category')) && Tools::getValue('id_product') ? '&id_category=' . $id_category : '') . '&token=' . $token);
                 } else {
                     $this->_errors[] = Tools::displayError('An error occurred while updating status.');
                 }
             } else {
                 $this->_errors[] = Tools::displayError('An error occurred while updating status for object.') . ' <b>' . $this->table . '</b> ' . Tools::displayError('(cannot load object)');
             }
         } else {
             $this->_errors[] = Tools::displayError('You do not have permission to edit here.');
         }
     } elseif (isset($_GET['position'])) {
         /** @var ObjectModel $object */
         if ($this->tabAccess['edit'] !== '1') {
             $this->_errors[] = Tools::displayError('You do not have permission to edit here.');
         } elseif (!Validate::isLoadedObject($object = $this->loadObject())) {
             $this->_errors[] = Tools::displayError('An error occurred while updating status for object.') . ' <b>' . $this->table . '</b> ' . Tools::displayError('(cannot load object)');
         } elseif (!$object->updatePosition((int) Tools::getValue('way'), (int) Tools::getValue('position'))) {
             $this->_errors[] = Tools::displayError('Failed to update the position.');
         } else {
             Tools::redirectAdmin(self::$currentIndex . '&' . $this->table . 'Orderby=position&' . $this->table . 'Orderway=asc&conf=5' . (($id_identifier = (int) Tools::getValue($this->identifier)) ? '&' . $this->identifier . '=' . $id_identifier : '') . '&token=' . $token);
         }
     } elseif (Tools::getValue('submitDel' . $this->table)) {
         if ($this->tabAccess['delete'] === '1') {
             if (isset($_POST[$this->table . 'Box'])) {
                 /** @var ObjectModel $object */
                 $object = new $this->className();
                 if (isset($object->noZeroObject) && (count(call_user_func(array($this->className, $object->noZeroObject))) <= 1 || count($_POST[$this->table . 'Box']) == count(call_user_func(array($this->className, $object->noZeroObject))))) {
                     $this->_errors[] = Tools::displayError('You need at least one object.') . ' <b>' . $this->table . '</b><br />' . Tools::displayError('You cannot delete all of the items.');
                 } else {
                     $result = true;
                     if ($this->deleted) {
                         foreach (Tools::getValue($this->table . 'Box') as $id) {
                             /** @var ObjectModel $toDelete */
                             $toDelete = new $this->className($id);
                             $toDelete->deleted = 1;
                             $result = $result && $toDelete->update();
                         }
                     } else {
                         $result = $object->deleteSelection(Tools::getValue($this->table . 'Box'));
                     }
                     if ($result) {
                         Tools::redirectAdmin(self::$currentIndex . '&conf=2&token=' . $token);
                     }
                     $this->_errors[] = Tools::displayError('An error occurred while deleting selection.');
                 }
                 // clean carriers positions
                 Carrier::cleanPositions();
             } else {
                 $this->_errors[] = Tools::displayError('You must select at least one element to delete.');
             }
         } else {
             $this->_errors[] = Tools::displayError('You do not have permission to delete here.');
         }
     } elseif (Tools::getValue('submitAdd' . $this->table)) {
         /* Checking fields validity */
         $this->validateRules();
         if (!count($this->_errors)) {
             $id = (int) Tools::getValue($this->identifier);
             /* Object update */
             if (isset($id) && !empty($id)) {
                 if ($this->tabAccess['edit'] === '1' || $this->table == 'employee' && $this->context->employee->id == Tools::getValue('id_employee') && Tools::isSubmit('updateemployee')) {
                     /** @var ObjectModel $object */
                     $object = new $this->className($id);
                     if (Validate::isLoadedObject($object)) {
                         /* Specific to objects which must not be deleted */
                         if ($this->deleted && $this->beforeDelete($object)) {
                             /** @var ObjectModel $objectNew */
                             // Create new one with old objet values
                             $objectNew = new $this->className($object->id);
                             $objectNew->id = null;
                             $objectNew->date_add = '';
                             $objectNew->date_upd = '';
                             // Update old object to deleted
                             $object->deleted = 1;
                             $object->update();
                             // Update new object with post values
                             $this->copyFromPost($objectNew, $this->table);
                             $result = $objectNew->add();
                             if (Validate::isLoadedObject($objectNew)) {
                                 $this->afterDelete($objectNew, $object->id);
                             }
                         } else {
                             $this->copyFromPost($object, $this->table);
                             $result = $object->update();
                             $this->afterUpdate($object);
                         }
                         if ($object->id) {
                             $this->updateAssoShop($object->id);
                         }
                         if (!$result) {
                             $this->_errors[] = Tools::displayError('An error occurred while updating object.') . ' <b>' . $this->table . '</b> (' . Db::getInstance()->getMsgError() . ')';
                         } elseif ($this->postImage($object->id) && !count($this->_errors)) {
                             if ($this->table == 'group') {
                                 $this->updateRestrictions($object->id);
                             }
                             $parent_id = (int) Tools::getValue('id_parent', 1);
                             // Specific back redirect
                             if ($back = Tools::getValue('back')) {
                                 Tools::redirectAdmin(urldecode($back) . '&conf=4');
                             }
                             // Specific scene feature
                             if (Tools::getValue('stay_here') == 'on' || Tools::getValue('stay_here') == 'true' || Tools::getValue('stay_here') == '1') {
                                 Tools::redirectAdmin(self::$currentIndex . '&' . $this->identifier . '=' . $object->id . '&conf=4&updatescene&token=' . $token);
                             }
                             // Save and stay on same form
                             if (Tools::isSubmit('submitAdd' . $this->table . 'AndStay')) {
                                 Tools::redirectAdmin(self::$currentIndex . '&' . $this->identifier . '=' . $object->id . '&conf=4&update' . $this->table . '&token=' . $token);
                             }
                             // Save and back to parent
                             if (Tools::isSubmit('submitAdd' . $this->table . 'AndBackToParent')) {
                                 Tools::redirectAdmin(self::$currentIndex . '&' . $this->identifier . '=' . $parent_id . '&conf=4&token=' . $token);
                             }
                             // Default behavior (save and back)
                             Tools::redirectAdmin(self::$currentIndex . ($parent_id ? '&' . $this->identifier . '=' . $object->id : '') . '&conf=4&token=' . $token);
                         }
                     } else {
                         $this->_errors[] = Tools::displayError('An error occurred while updating object.') . ' <b>' . $this->table . '</b> ' . Tools::displayError('(cannot load object)');
                     }
                 } else {
                     $this->_errors[] = Tools::displayError('You do not have permission to edit here.');
                 }
             } else {
                 if ($this->tabAccess['add'] === '1') {
                     /** @var ObjectModel $object */
                     $object = new $this->className();
                     $this->copyFromPost($object, $this->table);
                     if (!$object->add()) {
                         $this->_errors[] = Tools::displayError('An error occurred while creating object.') . ' <b>' . $this->table . ' (' . Db::getInstance()->getMsgError() . ')</b>';
                     } elseif (($_POST[$this->identifier] = $object->id) && $this->postImage($object->id) && !count($this->_errors) && $this->_redirect) {
                         $parent_id = (int) Tools::getValue('id_parent', 1);
                         $this->afterAdd($object);
                         $this->updateAssoShop($object->id);
                         if ($this->table == 'group') {
                             $this->updateRestrictions($object->id);
                             // assign group access to every categories
                             $categories = Category::getCategories($this->context->language->id, true);
                             $rowList = array();
                             $a = 0;
                             foreach ($categories as $category) {
                                 foreach ($category as $categ_id => $categ) {
                                     if ($categ_id != 1) {
                                         $rowList[] = array('id_category' => $categ_id, 'id_group' => $object->id);
                                     }
                                 }
                             }
                             Db::getInstance()->insert('category_group', $rowList);
                         }
                         // Save and stay on same form
                         if (Tools::isSubmit('submitAdd' . $this->table . 'AndStay')) {
                             Tools::redirectAdmin(self::$currentIndex . '&' . $this->identifier . '=' . $object->id . '&conf=3&update' . $this->table . '&token=' . $token);
                         }
                         // Save and back to parent
                         if (Tools::isSubmit('submitAdd' . $this->table . 'AndBackToParent')) {
                             Tools::redirectAdmin(self::$currentIndex . '&' . $this->identifier . '=' . $parent_id . '&conf=3&token=' . $token);
                         }
                         // Default behavior (save and back)
                         Tools::redirectAdmin(self::$currentIndex . ($parent_id ? '&' . $this->identifier . '=' . $object->id : '') . '&conf=3&token=' . $token);
                     }
                 } else {
                     $this->_errors[] = Tools::displayError('You do not have permission to add here.');
                 }
             }
         }
         $this->_errors = array_unique($this->_errors);
     } elseif (isset($_POST['submitReset' . $this->table])) {
         $filters = $this->context->cookie->getFamily($this->table . 'Filter_');
         foreach ($filters as $cookieKey => $filter) {
             if (strncmp($cookieKey, $this->table . 'Filter_', 7 + Tools::strlen($this->table)) == 0) {
                 $key = Tools::substr($cookieKey, 7 + Tools::strlen($this->table));
                 /* Table alias could be specified using a ! eg. alias!field */
                 $tmpTab = explode('!', $key);
                 $key = count($tmpTab) > 1 ? $tmpTab[1] : $tmpTab[0];
                 if (array_key_exists($key, $this->fieldsDisplay)) {
                     unset($this->context->cookie->{$cookieKey});
                 }
             }
         }
         if (isset($this->context->cookie->{'submitFilter' . $this->table})) {
             unset($this->context->cookie->{'submitFilter' . $this->table});
         }
         if (isset($this->context->cookie->{$this->table . 'Orderby'})) {
             unset($this->context->cookie->{$this->table . 'Orderby'});
         }
         if (isset($this->context->cookie->{$this->table . 'Orderway'})) {
             unset($this->context->cookie->{$this->table . 'Orderway'});
         }
         unset($_POST);
     } elseif (Tools::getValue('submitOptions' . $this->table)) {
         $this->updateOptions($token);
     } elseif (Tools::isSubmit('submitFilter' . $this->table) || $this->context->cookie->{'submitFilter' . $this->table} !== false) {
         $_POST = array_merge($this->context->cookie->getFamily($this->table . 'Filter_'), isset($_POST) ? $_POST : array());
         foreach ($_POST as $key => $value) {
             /* Extracting filters from $_POST on key filter_ */
             if ($value != null && !strncmp($key, $this->table . 'Filter_', 7 + Tools::strlen($this->table))) {
                 $key = Tools::substr($key, 7 + Tools::strlen($this->table));
                 /* Table alias could be specified using a ! eg. alias!field */
                 $tmpTab = explode('!', $key);
                 $filter = count($tmpTab) > 1 ? $tmpTab[1] : $tmpTab[0];
                 if ($field = $this->filterToField($key, $filter)) {
                     $type = array_key_exists('filter_type', $field) ? $field['filter_type'] : (array_key_exists('type', $field) ? $field['type'] : false);
                     if (($type == 'date' || $type == 'datetime') && is_string($value)) {
                         $value = Tools::unSerialize($value);
                     }
                     $key = isset($tmpTab[1]) ? $tmpTab[0] . '.`' . bqSQL($tmpTab[1]) . '`' : '`' . bqSQL($tmpTab[0]) . '`';
                     if (array_key_exists('tmpTableFilter', $field)) {
                         $sqlFilter =& $this->_tmpTableFilter;
                     } elseif (array_key_exists('havingFilter', $field)) {
                         $sqlFilter =& $this->_filterHaving;
                     } else {
                         $sqlFilter =& $this->_filter;
                     }
                     /* Only for date filtering (from, to) */
                     if (is_array($value)) {
                         if (isset($value[0]) && !empty($value[0])) {
                             if (!Validate::isDate($value[0])) {
                                 $this->_errors[] = Tools::displayError('\'From:\' date format is invalid (YYYY-MM-DD)');
                             } else {
                                 $sqlFilter .= ' AND ' . $key . ' >= \'' . pSQL(Tools::dateFrom($value[0])) . '\'';
                             }
                         }
                         if (isset($value[1]) && !empty($value[1])) {
                             if (!Validate::isDate($value[1])) {
                                 $this->_errors[] = Tools::displayError('\'To:\' date format is invalid (YYYY-MM-DD)');
                             } else {
                                 $sqlFilter .= ' AND ' . $key . ' <= \'' . pSQL(Tools::dateTo($value[1])) . '\'';
                             }
                         }
                     } else {
                         $sqlFilter .= ' AND ';
                         if ($type == 'int' || $type == 'bool') {
                             $sqlFilter .= ($key == $this->identifier || $key == '`' . $this->identifier . '`' || $key == '`active`' ? 'a.' : '') . pSQL($key) . ' = ' . (int) $value . ' ';
                         } elseif ($type == 'decimal') {
                             $sqlFilter .= ($key == $this->identifier || $key == '`' . $this->identifier . '`' ? 'a.' : '') . pSQL($key) . ' = ' . (double) $value . ' ';
                         } elseif ($type == 'select') {
                             $sqlFilter .= ($key == $this->identifier || $key == '`' . $this->identifier . '`' ? 'a.' : '') . pSQL($key) . ' = \'' . pSQL($value) . '\' ';
                         } else {
                             $sqlFilter .= ($key == $this->identifier || $key == '`' . $this->identifier . '`' ? 'a.' : '') . pSQL($key) . ' LIKE \'%' . pSQL($value) . '%\' ';
                         }
                     }
                 }
             }
         }
     } elseif (Tools::isSubmit('submitFields') && $this->requiredDatabase && $this->tabAccess['add'] === '1' && $this->tabAccess['delete'] === '1') {
         if (!is_array($fields = Tools::getValue('fieldsBox'))) {
             $fields = array();
         }
         /** @var ObjectModel $object */
         $object = new $this->className();
         if (!$object->addFieldsRequiredDatabase($fields)) {
             $this->_errors[] = Tools::displayError('Error in updating required fields');
         } else {
             Tools::redirectAdmin(self::$currentIndex . '&conf=4&token=' . $token);
         }
     }
 }
Example #19
0
<?php

// This is the scrapper of WUSS
// Author : Quentin BELOT
require_once dirname(__FILE__) . "/php/simple_html_dom.php";
global $bdd;
global $_TABLES;
if (!is_null($bdd) && !is_null($_TABLES)) {
    $website = new Website($bdd, $_TABLES);
    $websites = $website->getWebsites();
    if (!is_null($websites)) {
        foreach ($websites as $key_website => $value_website) {
            $category = new Category($bdd, $_TABLES);
            $categories = $category->getCategories($value_website->id);
            $url = $value_website->url;
            $file = $value_website->file;
            // Try to load json config
            $config = null;
            $json = file_get_contents($file);
            if ($json !== false) {
                // if Valid Config
                $config = json_decode($json);
            } else {
                // Invalid Config
                echo "Website File Not Found";
            }
            if (!is_null($categories)) {
                foreach ($categories as $key_category => $value_category) {
                    $article = new Article($bdd, $_TABLES);
                    if ($value_category->use_url) {
                        $url .= $value_category->url;
 public function setGroups($arrGroups, &$page_content)
 {
     global $_LANGID;
     $objGroup = Group::getGroups(array('id' => $arrGroups));
     $sortOrder = $this->categoriesSortingOptions[$this->arrConfig['categories_sorting_order']];
     while (!$objGroup->EOF) {
         $output = "<ul>\n";
         $objCategory = Category::getCategories(array('id' => $objGroup->getAssociatedCategoryIds()), null, $sortOrder);
         while (!$objCategory->EOF) {
             $output .= '<li><a href="' . CONTREXX_SCRIPT_PATH . '?section=Downloads&amp;category=' . $objCategory->getId() . '" title="' . htmlentities($objCategory->getName($_LANGID), ENT_QUOTES, CONTREXX_CHARSET) . '">' . htmlentities($objCategory->getName($_LANGID), ENT_QUOTES, CONTREXX_CHARSET) . "</a></li>\n";
             $objCategory->next();
         }
         $output .= "</ul>\n";
         $page_content = str_replace('{' . $objGroup->getPlaceholder() . '}', $output, $page_content);
         $objGroup->next();
     }
 }
Example #21
0
 /**
  * Check if currently authenticated user has read access to any
  * of a perticular download's associated categories.
  *
  * @param   Download The download-object of which the access to its
  *                   associated categories shall be checked.
  * @return  boolean  Returns TRUE, if the currently authenticated user
  *                   has read access to at least one of the download's
  *                   associated categories.
  */
 public function hasUserAccessToCategoriesOfDownload($objDownload)
 {
     // user is DAM admin (or superuser)
     if (\Permission::checkAccess(143, 'static', true)) {
         return true;
     }
     $arrCategoryIds = $objDownload->getAssociatedCategoryIds();
     $filter = array('is_active' => true, 'id' => $arrCategoryIds, 'read_access_id' => array(0));
     $objUser = \FWUser::getFWUserObject()->objUser;
     if ($objUser->login()) {
         $filter['read_access_id'] = array_merge($filter['read_access_id'], $objUser->getDynamicPermissionIds());
     }
     $objCategory = Category::getCategories($filter, null, null, null, $limit = 1);
     if (!$objCategory->EOF) {
         return true;
     }
     if ($objUser->login()) {
         // In case the user is logged in, but has no access to any of the
         // download's associated categories, check if any of those categories
         // are owned by the user. If so, we will grant the access to the download anyway.
         unset($filter['read_access_id']);
         $filter['owner_id'] = $objUser->getId();
         $objCategory = Category::getCategories($filter, null, null, null, $limit = 1);
         if (!$objCategory->EOF) {
             return true;
         }
     }
     return false;
 }
Example #22
0
    private function _displayFormCategory()
    {
        // Check if the module is configured
        if (!$this->_webserviceTestResult) {
            return '<p><b>' . $this->l('You have to configure "General Settings" tab before using this tab.') . '</b></p><br />';
        }
        // Display header
        $html = '<p><b>' . $this->l('In this tab, you can set a specific configuration for each category.') . '</b></p><br />
		<table class="table tableDnD" cellpadding="0" cellspacing="0" width="90%">
			<thead>
				<tr class="nodrag nodrop">
					<th>' . $this->l('ID Config') . '</th>
					<th>' . $this->l('Category') . '</th>
					<th>' . $this->l('Pickup type') . '</th>
					<th>' . $this->l('Packaging type') . '</th>
					<th>' . $this->l('Additional charges') . '</th>
					<th>' . $this->l('Services') . '</th>
					<th>' . $this->l('Actions') . '</th>
				</tr>
			</thead>
			<tbody>';
        // Loading config list
        $configCategoryList = Db::getInstance()->executeS('SELECT * FROM `' . _DB_PREFIX_ . 'fedex_rate_config` WHERE `id_category` > 0');
        if (!$configCategoryList) {
            $html .= '<tr><td colspan="6">' . $this->l('There is no specific FEDEX configuration for categories at this point.') . '</td></tr>';
        }
        foreach ($configCategoryList as $k => $c) {
            // Category Path
            $path = '';
            $pathTab = $this->_getPathInTab($c['id_category']);
            foreach ($pathTab as $p) {
                if (!empty($path)) {
                    $path .= ' > ';
                }
                $path .= $p;
            }
            // Loading config currency
            $configCurrency = new Currency($c['id_currency']);
            // Loading services attached to this config
            $services = '';
            $servicesTab = Db::getInstance()->executeS('
			SELECT ursc.`service`
			FROM `' . _DB_PREFIX_ . 'fedex_rate_config_service` urcs
			LEFT JOIN `' . _DB_PREFIX_ . 'fedex_rate_service_code` ursc ON (ursc.`id_fedex_rate_service_code` = urcs.`id_fedex_rate_service_code`)
			WHERE urcs.`id_fedex_rate_config` = ' . (int) $c['id_fedex_rate_config']);
            foreach ($servicesTab as $s) {
                $services .= $s['service'] . '<br />';
            }
            // Display line
            $alt = 0;
            if ($k % 2 != 0) {
                $alt = ' class="alt_row"';
            }
            $html .= '
				<tr' . $alt . '>
					<td>' . $c['id_fedex_rate_config'] . '</td>
					<td>' . $path . '</td>
					<td>' . (isset($this->_pickupTypeList[$c['pickup_type_code']]) ? $this->_pickupTypeList[$c['pickup_type_code']] : '-') . '</td>
					<td>' . (isset($this->_packagingTypeList[$c['packaging_type_code']]) ? $this->_packagingTypeList[$c['packaging_type_code']] : '-') . '</td>
					<td>' . $c['additional_charges'] . ' ' . $configCurrency->sign . '</td>
					<td>' . $services . '</td>
					<td>
						<a href="index.php?tab=' . Tools::safeOutput(Tools::getValue('tab')) . '&configure=' . Tools::safeOutput(Tools::getValue('configure')) . '&token=' . Tools::safeOutput(Tools::getValue('token')) . '&tab_module=' . Tools::safeOutput(Tools::getValue('tab_module')) . '&module_name=' . Tools::safeOutput(Tools::getValue('module_name')) . '&id_tab=2&section=category&action=edit&id_fedex_rate_config=' . (int) $c['id_fedex_rate_config'] . '" style="float: left;">
							<img src="' . _PS_IMG_ . 'admin/edit.gif" />
						</a>
						<form action="index.php?tab=' . Tools::safeOutput(Tools::getValue('tab')) . '&configure=' . Tools::safeOutput(Tools::getValue('configure')) . '&token=' . Tools::safeOutput(Tools::getValue('token')) . '&tab_module=' . Tools::safeOutput(Tools::getValue('tab_module')) . '&module_name=' . Tools::safeOutput(Tools::getValue('module_name')) . '&id_tab=2&section=category&action=delete&id_fedex_rate_config=' . (int) $c['id_fedex_rate_config'] . '&id_category=' . (int) $c['id_category'] . '" method="post" class="form" style="float: left;">
							<input name="submitSave" type="image" src="' . _PS_IMG_ . 'admin/delete.gif" OnClick="return confirm(\'' . $this->l('Are you sure you want to delete this specific FEDEX configuration for this category ?') . '\');" />
						</form>
					</td>
				</tr>';
        }
        $html .= '
			</tbody>
		</table><br /><br />';
        // Add or Edit Category Configuration
        if (Tools::getValue('action') == 'edit' && Tools::getValue('section') == 'category') {
            // Loading config
            $configSelected = Db::getInstance()->getRow('SELECT * FROM `' . _DB_PREFIX_ . 'fedex_rate_config` WHERE `id_fedex_rate_config` = ' . (int) Tools::getValue('id_fedex_rate_config'));
            // Category Path
            $path = '';
            $pathTab = $this->_getPathInTab($configSelected['id_category']);
            foreach ($pathTab as $p) {
                if (!empty($path)) {
                    $path .= ' > ';
                }
                $path .= $p;
            }
            $html .= '<p align="center"><b>' . $this->l('Update a rule') . ' (<a href="index.php?tab=' . Tools::safeOutput(Tools::getValue('tab')) . '&configure=' . Tools::safeOutput(Tools::getValue('configure')) . '&token=' . Tools::safeOutput(Tools::getValue('token')) . '&tab_module=' . Tools::safeOutput(Tools::getValue('tab_module')) . '&module_name=' . Tools::safeOutput(Tools::getValue('module_name')) . '&id_tab=2&section=category&action=add">' . $this->l('Add a rule') . ' ?</a>)</b></p>
					<form action="index.php?tab=' . Tools::safeOutput(Tools::getValue('tab')) . '&configure=' . Tools::safeOutput(Tools::getValue('configure')) . '&token=' . Tools::safeOutput(Tools::getValue('token')) . '&tab_module=' . Tools::safeOutput(Tools::getValue('tab_module')) . '&module_name=' . Tools::safeOutput(Tools::getValue('module_name')) . '&id_tab=2&section=category&action=edit&id_fedex_rate_config=' . (int) Tools::getValue('id_fedex_rate_config') . '" method="post" class="form">
						<label>' . $this->l('Category') . ' :</label>
						<div class="margin-form" style="padding: 0.2em 0.5em 0 0; font-size: 12px;">' . $path . ' <input type="hidden" name="id_category" value="' . (int) $configSelected['id_category'] . '" /></div><br clear="left" />
						<label>' . $this->l('Pickup Type') . ' : </label>
							<div class="margin-form">
								<select name="pickup_type_code">
									<option value="0">' . $this->l('Select a pickup type ...') . '</option>';
            foreach ($this->_pickupTypeList as $kpickup => $vpickup) {
                $html .= '<option value="' . $kpickup . '" ' . ($kpickup == pSQL(Tools::getValue('pickup_type_code', $configSelected['pickup_type_code'])) ? 'selected="selected"' : '') . '>' . $vpickup . '</option>';
            }
            $html .= '</select>
						</div>
						<label>' . $this->l('Packaging Type') . ' : </label>
							<div class="margin-form">
								<select name="packaging_type_code">
									<option value="0">' . $this->l('Select a packaging type ...') . '</option>';
            foreach ($this->_packagingTypeList as $kpackaging => $vpackaging) {
                $html .= '<option value="' . $kpackaging . '" ' . ($kpackaging == pSQL(Tools::getValue('packaging_type_code', $configSelected['packaging_type_code'])) ? 'selected="selected"' : '') . '>' . $vpackaging . '</option>';
            }
            $html .= '</select>
						</div>
						<label>' . $this->l('Additional charges') . ' : </label>
						<div class="margin-form"><input type="text" size="20" name="additional_charges" value="' . Tools::safeOutput(Tools::getValue('additional_charges', $configSelected['additional_charges'])) . '" /></div><br />
						<label>' . $this->l('Delivery Service') . ' : </label>
							<div class="margin-form">';
            $rateServiceList = Db::getInstance()->executeS('SELECT * FROM `' . _DB_PREFIX_ . 'fedex_rate_service_code`');
            foreach ($rateServiceList as $rateService) {
                $configServiceSelected = Db::getInstance()->getValue('SELECT `id_fedex_rate_service_code` FROM `' . _DB_PREFIX_ . 'fedex_rate_config_service` WHERE `id_fedex_rate_config` = ' . (int) Tools::getValue('id_fedex_rate_config') . ' AND `id_fedex_rate_service_code` = ' . (int) $rateService['id_fedex_rate_service_code']);
                $html .= '<input type="checkbox" name="service[]" value="' . $rateService['id_fedex_rate_service_code'] . '" ' . ($this->_isPostCheck($rateService['id_fedex_rate_service_code']) == 1 || $configServiceSelected > 0 ? 'checked="checked"' : '') . ' /> ' . $rateService['service'] . '<br />';
            }
            $html .= '
						<p>' . $this->l('Choose the delivery service which will be available for customers.') . '</p>
						</div>
						<div class="margin-form"><input class="button" name="submitSave" type="submit"></div>
					</form>';
        } else {
            $html .= '<p align="center"><b>' . $this->l('Add a rule') . '</b></p>
					<form action="index.php?tab=' . Tools::safeOutput(Tools::getValue('tab')) . '&configure=' . Tools::safeOutput(Tools::getValue('configure')) . '&token=' . Tools::safeOutput(Tools::getValue('token')) . '&tab_module=' . Tools::safeOutput(Tools::getValue('tab_module')) . '&module_name=' . Tools::safeOutput(Tools::getValue('module_name')) . '&id_tab=2&section=category&action=add" method="post" class="form">
						<label>' . $this->l('Category') . ' : </label>
						<div class="margin-form">
							<select name="id_category">
								<option value="0">' . $this->l('Select a category ...') . '</option>
								' . $this->_getChildCategories(Category::getCategories($this->context->language->id), 0) . '
							</select>
						</div>
						<label>' . $this->l('Pickup Type') . ' : </label>
							<div class="margin-form">
								<select name="pickup_type_code">
									<option value="0">' . $this->l('Select a pickup type ...') . '</option>';
            foreach ($this->_pickupTypeList as $kpickup => $vpickup) {
                $html .= '<option value="' . $kpickup . '" ' . ($kpickup === pSQL(Tools::getValue('pickup_type_code')) ? 'selected="selected"' : '') . '>' . $vpickup . '</option>';
            }
            $html .= '</select>
						</div>
						<label>' . $this->l('Packaging Type') . ' : </label>
							<div class="margin-form">
								<select name="packaging_type_code">
									<option value="0">' . $this->l('Select a packaging type ...') . '</option>';
            foreach ($this->_packagingTypeList as $kpackaging => $vpackaging) {
                $html .= '<option value="' . $kpackaging . '" ' . ($kpackaging == pSQL(Tools::getValue('packaging_type_code')) ? 'selected="selected"' : '') . '>' . $vpackaging . '</option>';
            }
            $html .= '</select>
						</div>
						<label>' . $this->l('Additional charges') . ' : </label>
						<div class="margin-form"><input type="text" size="20" name="additional_charges" value="' . Tools::safeOutput(Tools::getValue('additional_charges')) . '" /></div><br />
						<label>' . $this->l('Delivery Service') . ' : </label>
							<div class="margin-form">';
            $rateServiceList = Db::getInstance()->executeS('SELECT * FROM `' . _DB_PREFIX_ . 'fedex_rate_service_code`');
            foreach ($rateServiceList as $rateService) {
                $html .= '<input type="checkbox" name="service[]" value="' . $rateService['id_fedex_rate_service_code'] . '" ' . ($this->_isPostCheck($rateService['id_fedex_rate_service_code']) == 1 ? 'checked="checked"' : '') . ' /> ' . $rateService['service'] . '<br />';
            }
            $html .= '
						<p>' . $this->l('Choose the delivery service which will be available for customers.') . '</p>
						</div>
						<div class="margin-form"><input class="button" name="submitSave" type="submit"></div>
					</form>';
        }
        return $html;
    }
Example #23
0
<?php

include_once "deny/connector.php";
include_once "administrator/process/class/class.Category.php";
$cate = new Category();
$categories = array();
$categories = $cate->getCategories();
?>
<h3><span><span>Category</span></span></h3>
<div class="boxIndent">
  <div class="width clear">
	<?php 
for ($i = 0; $i < count($categories); $i++) {
    ?>
	<a title="<?php 
    echo $categories[$i]['name'];
    ?>
" style="display: block;" class="mainlevel" href="index.php?page=browse&cid=<?php 
    echo $categories[$i]['id'];
    ?>
"><?php 
    echo $categories[$i]['name'];
    ?>
</a>
    <?php 
}
?>
  </div>
</div>
    public function displayForm($isMainTab = true)
    {
        global $currentIndex, $cookie;
        parent::displayForm();
        if (!($obj = $this->loadObject(true))) {
            return;
        }
        $langtags = 'name';
        $active = $this->getFieldValue($obj, 'active');
        echo '
		<script type="text/javascript">';
        echo 'startingData = new Array();' . "\n";
        foreach ($obj->getProducts() as $key => $product) {
            $productObj = new Product((int) $product['id_product'], true, (int) $cookie->id_lang);
            echo 'startingData[' . $key . '] = new Array(\'' . $productObj->name . '\', ' . $product['id_product'] . ', ' . $product['x_axis'] . ', ' . $product['y_axis'] . ', ' . $product['zone_width'] . ', ' . $product['zone_height'] . ');';
        }
        echo '</script>
		<form id="scenesForm" action="' . $currentIndex . '&submitAdd' . $this->table . '=1&token=' . $this->token . '" method="post" enctype="multipart/form-data">
		' . ($obj->id ? '<input type="hidden" name="id_' . $this->table . '" value="' . $obj->id . '" />' : '') . '
			<fieldset><legend><img src="../img/admin/photo.gif" />' . $this->l('Image Maps') . '</legend>';
        echo '
					<label>' . $this->l('How to map products in the image:') . ' </label>
					<div class="margin-form">
						' . $this->l('When a customer hovers over the image with the mouse, a pop-up appears displaying a brief description of the product. The customer can then click to open the product\'s full product page. To achieve this, please define the \'mapping zone\' that, when hovered over, will display the pop-up. Left-click with your mouse to draw the four-sided mapping zone, then release. Then, begin typing the name of the associated product. A list of products appears. Click the appropriate product, then click OK. Repeat these steps for each mapping zone you wish to create. When you have finished mapping zones, click Save Image Map.') . '
					</div>
					';
        echo '<label>' . $this->l('Image map name:') . ' </label>
				<div class="margin-form">';
        foreach ($this->_languages as $language) {
            echo '
					<div id="name_' . $language['id_lang'] . '" style="display: ' . ($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none') . '; float: left;">
						<input type="text" style="width: 260px" name="name_' . $language['id_lang'] . '" id="name_' . $language['id_lang'] . '" value="' . htmlentities($this->getFieldValue($obj, 'name', (int) $language['id_lang']), ENT_COMPAT, 'UTF-8') . '" /><sup> *</sup>
					</div>';
        }
        $this->displayFlags($this->_languages, $this->_defaultFormLanguage, $langtags, 'name');
        echo '		<div class="clear"></div>
				</div>';
        echo '<label>' . $this->l('Status:') . ' </label>
				<div class="margin-form">
					<input type="radio" name="active" id="active_on" value="1" ' . ((!$obj->id or Tools::getValue('active', $obj->active)) ? 'checked="checked" ' : '') . '/>
					<label class="t" for="active_on"> <img src="../img/admin/enabled.gif" alt="' . $this->l('Activated') . '" title="' . $this->l('Activated') . '" /></label>
					<input type="radio" name="active" id="active_off" value="0" ' . ((!Tools::getValue('active', $obj->active) and $obj->id) ? 'checked="checked" ' : '') . '/>
					<label class="t" for="active_off"> <img src="../img/admin/disabled.gif" alt="' . $this->l('Deactivated') . '" title="' . $this->l('Deactivated') . '" /></label>
					<p>' . $this->l('Activate or deactivate the image map') . '</p>
				</div>';
        $sceneImageTypes = ImageType::getImagesTypes('scenes');
        $largeSceneImageType = NULL;
        $thumbSceneImageType = NULL;
        foreach ($sceneImageTypes as $sceneImageType) {
            if ($sceneImageType['name'] == 'large_scene') {
                $largeSceneImageType = $sceneImageType;
            }
            if ($sceneImageType['name'] == 'thumb_scene') {
                $thumbSceneImageType = $sceneImageType;
            }
        }
        echo '<label>' . $this->l('Image to be mapped:') . ' </label>
				<div class="margin-form">
					<input type="hidden" id="stay_here" name="stay_here" value="" />
					<input type="file" name="image" id="image_input" /> <input type="button" value="' . $this->l('Upload image') . '" onclick="{$(\'#stay_here\').val(\'true\');$(\'#scenesForm\').submit();}" class="button" /><br/>
					<p>' . $this->l('Format:') . ' JPG, GIF, PNG. ' . $this->l('File size:') . ' ' . $this->maxImageSize / 1000 . '' . $this->l('KB max.') . ' ' . $this->l('If larger than the image size setting, the image will be reduced to ') . ' ' . $largeSceneImageType['width'] . 'x' . $largeSceneImageType['height'] . 'px ' . $this->l('(width x height). If smaller than the image-size setting, a white background will be added in order to achieve the correct image size.') . '.<br />' . $this->l('Note: To change image dimensions, please change the \'large_scene\' image type settings to the desired size (in Back Office > Preferences > Images).') . '</p>';
        if ($obj->id && file_exists(_PS_SCENE_IMG_DIR_ . $obj->id . '-large_scene.jpg')) {
            echo '<img id="large_scene_image" style="clear:both;border:1px solid black;" alt="" src="' . _THEME_SCENE_DIR_ . $obj->id . '-large_scene.jpg" /><br />';
            echo '
					<div id="ajax_choose_product" style="display:none; padding:6px; padding-top:2px; width:600px;">
						' . $this->l('Begin typing the first letters of the product name, then select the product from the drop-down list:') . '<br /><input type="text" value="" id="product_autocomplete_input" /> <input type="button" class="button" value="' . $this->l('OK') . '" onclick="$(this).prev().search();" /><input type="button" class="button" value="' . $this->l('Delete') . '" onclick="undoEdit();" />
					</div>
			';
            echo '
					<link rel="stylesheet" type="text/css" href="' . __PS_BASE_URI__ . 'css/jquery.autocomplete.css" />
					<link rel="stylesheet" type="text/css" href="' . __PS_BASE_URI__ . 'js/jquery/imgareaselect/imgareaselect-default.css" />
					<script type="text/javascript" src="' . __PS_BASE_URI__ . 'js/jquery/jquery.autocomplete.js"></script>
					<script type="text/javascript" src="' . __PS_BASE_URI__ . 'js/jquery/imgareaselect/jquery.imgareaselect.pack.js"></script>
					<script type="text/javascript" src="' . __PS_BASE_URI__ . 'js/admin-scene-cropping.js"></script>
		';
            echo '</div>';
            echo '<label>' . $this->l('Alternative thumbnail:') . ' </label>
				<div class="margin-form">
					<input type="file" name="thumb" id="thumb_input" />&nbsp;&nbsp;' . $this->l('(optional)') . '
					<p>' . $this->l('If you want to use a thumbnail other than one generated from simply reducing the mapped image, please upload it here.') . '<br />' . $this->l('Format:') . ' JPG, GIF, PNG. ' . $this->l('Filesize:') . ' ' . $this->maxImageSize / 1000 . '' . $this->l('Kb max.') . ' ' . $this->l('Automatically resized to') . ' ' . $thumbSceneImageType['width'] . 'x' . $thumbSceneImageType['height'] . 'px ' . $this->l('(width x height)') . '.<br />' . $this->l('Note: To change image dimensions, please change the \'thumb_scene\' image type settings to the desired size (in Back Office > Preferences > Images).') . '</p>
					';
            if ($obj->id && file_exists(_PS_SCENE_IMG_DIR_ . 'thumbs/' . $obj->id . '-thumb_scene.jpg')) {
                echo '<img id="large_scene_image" style="clear:both;border:1px solid black;" alt="" src="' . _THEME_SCENE_DIR_ . 'thumbs/' . $obj->id . '-thumb_scene.jpg" /><br />';
            }
            echo '</div>
			 ';
            echo '<label>' . $this->l('Category:') . ' </label>
				<div class="margin-form">
					<div style="overflow: auto; min-height: 300px; padding-top: 0.6em;" id="categoryList">
						<table cellspacing="0" cellpadding="0" class="table" style="width: 600px;">
								<tr>
									<th><input type="checkbox" name="checkme" class="noborder" onclick="checkDelBoxes(this.form, \'categoryBox[]\', this.checked)" /></th>
									<th>' . $this->l('ID') . '</th>
									<th>' . $this->l('Image map name:') . '</th>
								</tr>';
            $categories = Category::getCategories((int) $cookie->id_lang, false);
            $done = array();
            $index = array();
            if (Tools::isSubmit('categoryBox')) {
                foreach (Tools::getValue('categoryBox') as $k => $row) {
                    $index[] = $row;
                }
            } elseif ($obj->id) {
                foreach (Scene::getIndexedCategories($obj->id) as $k => $row) {
                    $index[] = $row['id_category'];
                }
            }
            $this->recurseCategoryForInclude($index, $categories, $categories[0][1], 1, null);
            echo '</table>
						<p style="padding:0px; margin:0px 0px 10px 0px;">' . $this->l('Mark all checkbox(es) of the categories for which the image map is to appear.') . '<sup> *</sup></p>
					</div>
				</div>';
            echo '
					<div id="save_scene" class="margin-form" ' . ($obj->id && file_exists(_PS_SCENE_IMG_DIR_ . $obj->id . '-large_scene.jpg') ? '' : 'style="display:none;"') . '>
						<input type="submit" value="' . $this->l('Save Image Map(s)') . '" class="button" />
					</div>';
        } else {
            echo '
					<br/><span class="bold">' . $this->l('Please add a picture to continue mapping the image...') . '</span><br/><br/>';
        }
        echo '<div class="small"><sup>*</sup> ' . $this->l('Required field') . '</div>
			</fieldset>
		</form>';
    }
Example #25
0
 function getDocBody()
 {
     // Get currencies
     $currencies = Currency::getCurrencies();
     // Get categories
     $categories = Category::getCategories($this->id_lang, true, false);
     // Generate XML here
     $xml = new DomDocument('1.0', 'UTF-8');
     $catalog = $xml->createElement("yml_catalog");
     $catalog->setAttribute("date", date('Y-m-d H:i'));
     $shop = $xml->createElement("shop");
     $elem = $xml->createElement("name");
     $elem->appendChild($xml->createCDATASection(html_entity_decode(Configuration::get('PS_SHOP_NAME'))));
     $shop->appendChild($elem);
     $elem = $xml->createElement("company");
     $elem->appendChild($xml->createCDATASection(Configuration::get('YAMARKET_COMPANY_NAME')));
     $shop->appendChild($elem);
     $shop->appendChild($xml->createElement("url", $this->proto_prefix . __PS_BASE_URI__));
     $shop->appendChild($xml->createElement("platform", "PrestaShop"));
     $elem = $xml->createElement("currencies");
     foreach ($currencies as $cur) {
         if ($cur['iso_code'] != 'GBP') {
             if ($cur['iso_code'] == 'RUB') {
                 $cur['iso_code'] = 'RUR';
             }
             $subelem = $xml->createElement("currency");
             $subelem->setAttribute("id", $cur['iso_code']);
             $subelem->setAttribute("rate", 1 / $cur['conversion_rate']);
             $elem->appendChild($subelem);
         }
     }
     $shop->appendChild($elem);
     $elem = $xml->createElement("categories");
     foreach ($categories as $category) {
         if ($category['id_category'] == 1) {
             continue;
         }
         $subelem = $xml->createElement("category", $category['name']);
         $subelem->setAttribute("id", $category['id_category']);
         if (array_key_exists('id_parent', $category) && $category['id_parent'] != 1) {
             $subelem->setAttribute("parentId", $category['id_parent']);
         }
         $elem->appendChild($subelem);
     }
     $shop->appendChild($elem);
     $local_delivery_price = Configuration::get('YAMARKET_DELIVERY_PRICE');
     if ($local_delivery_price or $local_delivery_price === "0") {
         $shop->appendChild($xml->createElement("local_delivery_cost", $local_delivery_price));
     }
     $catalog->appendChild($shop);
     $xml->appendChild($catalog);
     return $xml;
 }
Example #26
0
 private function storeCategoryAssociations()
 {
     global $objDatabase;
     $arrOldCategories = array();
     $status = true;
     if (!isset($this->categories)) {
         $this->loadCategoryAssociations();
     }
     $objOldCategories = $objDatabase->Execute('SELECT `category_id` FROM `' . DBPREFIX . 'module_downloads_rel_download_category` WHERE `download_id` = ' . $this->id);
     if ($objOldCategories !== false) {
         while (!$objOldCategories->EOF) {
             $arrOldCategories[] = $objOldCategories->fields['category_id'];
             $objOldCategories->MoveNext();
         }
     } else {
         return false;
     }
     $arrNewCategories = array_diff($this->categories, $arrOldCategories);
     $arrRemovedCategories = array_diff($arrOldCategories, $this->categories);
     if (!\Permission::checkAccess(143, 'static', true)) {
         // we have to check if all associations are within the users permissions
         $objFWUser = \FWUser::getFWUserObject();
         $objCategory = Category::getCategories(null, null, array('order' => 'ASC', 'name' => 'ASC', 'id' => 'ASC'));
         while (!$objCategory->EOF) {
             if ($objFWUser->objUser->login() && $objCategory->getOwnerId() == $objFWUser->objUser->getId()) {
                 // the owner of the category is allowed to associated with it whatever he wants
                 $objCategory->next();
                 continue;
             }
             if (in_array($objCategory->getId(), $arrNewCategories)) {
                 // the download has been added to this category
                 if ($objCategory->getAddFilesAccessId() && !\Permission::checkAccess($objCategory->getAddFilesAccessId(), 'dynamic', true)) {
                     // we won't store this association, because the user doesn't have the permission to
                     unset($arrNewCategories[array_search($objCategory->getId(), $arrNewCategories)]);
                 }
             } elseif (in_array($objCategory->getId(), $arrRemovedCategories)) {
                 // the download has been removed from this category
                 if ($objCategory->getManageFilesAccessId() && !\Permission::checkAccess($objCategory->getManageFilesAccessId(), 'dynamic', true) && (!$objFWUser->objUser->login() || $this->owner_id == $objFWUser->objUser->getId())) {
                     // we won't store this association, because the user doesn't have the permission to
                     unset($arrRemovedCategories[array_search($objCategory->getId(), $arrRemovedCategories)]);
                 }
             }
             $objCategory->next();
         }
     }
     foreach ($arrNewCategories as $categoryId) {
         if ($objDatabase->Execute("INSERT INTO `" . DBPREFIX . "module_downloads_rel_download_category` (`download_id`, `category_id`) VALUES (" . $this->id . ", " . $categoryId . ")") === false) {
             $status = false;
         }
     }
     foreach ($arrRemovedCategories as $categoryId) {
         if ($objDatabase->Execute("DELETE FROM `" . DBPREFIX . "module_downloads_rel_download_category` WHERE `download_id` = " . $this->id . " AND `category_id` = " . $categoryId) === false) {
             $status = false;
         }
     }
     return $status;
     return true;
 }
    if (array_key_exists($key, $array)) {
        $new = array();
        foreach ($array as $k => $value) {
            $new[$k] = $value;
            if ($k === $key) {
                $new[$new_key] = $new_value;
            }
        }
        return $new;
    }
    return false;
}
$ebay = new Ebay();
$ebay_profile = new EbayProfile((int) Tools::getValue('profile'));
if (!Configuration::get('EBAY_SECURITY_TOKEN') || Tools::getValue('token') != Configuration::get('EBAY_SECURITY_TOKEN')) {
    return Tools::safeOutput(Tools::getValue('not_logged_str'));
}
$category_list = $ebay->getChildCategories(Category::getCategories(Tools::getValue('id_lang')), version_compare(_PS_VERSION_, '1.5', '>') ? 1 : 0);
$offset = 20;
$page = (int) Tools::getValue('p', 0);
if ($page < 2) {
    $page = 1;
}
$limit = $offset * ($page - 1);
$category_list = array_slice($category_list, $limit, $offset);
$ebay_store_category_list = EbayStoreCategory::getCategoriesWithConfiguration($ebay_profile->id);
$smarty = Context::getContext()->smarty;
/* Smarty datas */
$template_vars = array('tabHelp' => '&id_tab=7', '_path' => $ebay->getPath(), 'categoryList' => $category_list, 'eBayStoreCategoryList' => $ebay_store_category_list, 'request_uri' => $_SERVER['REQUEST_URI'], 'noCatFound' => Tools::getValue('ch_no_cat_str'), 'p' => $page);
$smarty->assign($template_vars);
echo $ebay->display(realpath(dirname(__FILE__) . '/../'), '/views/templates/hook/table_store_categories.tpl');
Example #28
0
                <div class="form-group">
                  <label class='control-label col-xs-3' style="color:<?php 
        if (in_array('cNames_menu_edit', $_SESSION['errors'])) {
            echo 'red';
        } else {
            echo 'black';
        }
        ?>
">Category</label>
                  <div class="col-xs-9">
                    <select id='cNames_menu_edit' class="form-control" name='cNames_menu_edit'>
                      <?php 
        include '../../classes/category.php';
        $category = new Category();
        $cData = $category->getCategories();
        foreach ($cData as $key => $cat) {
            echo "<option value='" . $cat['cID'] . "'>" . $cat['cName'] . "</option>";
        }
        ?>
                    </select>
                  </div>
                </div>
                    
                <div class="form-group">
                  <label class='control-label col-xs-3' style="color:<?php 
        if (in_array('scNames_menu_edit', $_SESSION['errors'])) {
            echo 'red';
        } else {
            echo 'black';
        }
 public function process()
 {
     // check if session is active
     $session = new Session($this->sessionId);
     if ($session->sessionId > 0) {
         // update session
         $session->update();
         // process restricted functions
         switch ($this->f) {
             case 'checkLogin':
                 return Login::checkLogin($session->sessionId);
             case 'getSession':
                 return $session;
             case 'getWarehouse':
                 if (isset($this->data->update)) {
                     $warehouse = new Warehouse($session->warehouseId, $this->data->update);
                 } else {
                     $warehouse = new Warehouse($session->warehouseId);
                 }
                 $warehouse->dMail = $warehouse->getMail();
                 $warehouse->dDisableLocationLess = $warehouse->isLocationLessDisabled();
                 $warehouse->dDisablePaletteLess = $warehouse->isPaletteLessDisabled();
                 return $warehouse;
             case 'editWarehouse':
                 if (!$session->restricted) {
                     $data = $this->data;
                     $warehouse = new Warehouse($session->warehouseId);
                     // update warehouse data
                     if (isset($data->name)) {
                         $warehouse->name = $data->name;
                     }
                     if (isset($data->description)) {
                         $warehouse->description = $data->description;
                     }
                     if (isset($data->country)) {
                         $warehouse->country = $data->country;
                     }
                     if (isset($data->city)) {
                         $warehouse->city = $data->city;
                     }
                     if (isset($data->password)) {
                         $warehouse->setPassword($data->password);
                     }
                     if (isset($data->passwordRestricted)) {
                         $warehouse->setPasswordRestricted($data->passwordRestricted);
                     }
                     if (isset($data->mail)) {
                         $warehouse->setMail($data->mail);
                     }
                     if (isset($data->disableLocationLess)) {
                         $warehouse->setDisableLocationLess($data->disableLocationLess);
                     }
                     if (isset($data->disablePaletteLess)) {
                         $warehouse->setDisablePaletteLess($data->disablePaletteLess);
                     }
                     // update database entry
                     return $warehouse->edit();
                 }
                 break;
             case 'deleteWarehouse':
                 if (!$session->restricted) {
                     $warehouse = new Warehouse($session->warehouseId);
                     if ($warehouse->id > 0 && $warehouse->delete()) {
                         return $session->destroy();
                     }
                 }
                 break;
             case 'addCategory':
                 if (!$session->restricted && isset($this->data->name)) {
                     $category = new Category(null, $session->warehouseId);
                     $category->name = $this->data->name;
                     if (isset($this->data->parent)) {
                         $category->parent = $this->data->parent;
                     }
                     if ($category->edit()) {
                         return $category->id;
                     }
                 }
                 break;
             case 'getCategory':
                 if (isset($this->data->id) && isset($this->data->update)) {
                     return new Category($this->data->id, $session->warehouseId, $this->data->update);
                 } elseif (isset($this->data->id)) {
                     return new Category($this->data->id, $session->warehouseId);
                 }
                 break;
             case 'deleteCategory':
                 if (!$session->restricted && isset($this->data->id)) {
                     $category = new Category($this->data->id, $session->warehouseId);
                     return $category->delete();
                 }
                 break;
             case 'editCategory':
                 if (isset($this->data->id)) {
                     $data = $this->data;
                     $category = new Category($this->data->id, $session->warehouseId);
                     if (!$session->restricted) {
                         if (isset($data->name)) {
                             $category->name = $data->name;
                         }
                         if (isset($data->parent)) {
                             $category->parent = $data->parent;
                         }
                         if (isset($data->male)) {
                             $category->male = $data->male;
                         }
                         if (isset($data->female)) {
                             $category->female = $data->female;
                         }
                         if (isset($data->children)) {
                             $category->children = $data->children;
                         }
                         if (isset($data->baby)) {
                             $category->baby = $data->baby;
                         }
                         if (isset($data->summer)) {
                             $category->summer = $data->summer;
                         }
                         if (isset($data->winter)) {
                             $category->winter = $data->winter;
                         }
                     }
                     if (isset($data->demand)) {
                         $category->demand = $data->demand;
                     }
                     if (isset($data->weight)) {
                         $category->weight = $data->weight;
                     }
                     return $category->edit();
                 }
                 break;
             case 'getCategories':
                 if (isset($this->data->parent)) {
                     return Category::getCategories($session->warehouseId, $this->data->parent);
                 } else {
                     return Category::getCategories($session->warehouseId);
                 }
             case 'addLocation':
                 if (!$session->restricted && isset($this->data->name)) {
                     $location = new Location(null, $session->warehouseId);
                     $location->name = $this->data->name;
                     if ($location->edit()) {
                         return $location->id;
                     }
                     return true;
                 }
                 break;
             case 'getLocation':
                 if (isset($this->data->id) && isset($this->data->update)) {
                     return new Location($this->data->id, $session->warehouseId, $this->data->update);
                 } elseif (isset($this->data->id)) {
                     return new Location($this->data->id, $session->warehouseId);
                 }
                 break;
             case 'deleteLocation':
                 if (!$session->restricted && isset($this->data->id)) {
                     $location = new Location($this->data->id, $session->warehouseId);
                     return $location->delete();
                 }
                 break;
             case 'editLocation':
                 if (!$session->restricted && isset($this->data->id) && isset($this->data->name)) {
                     $location = new Location($this->data->id, $session->warehouseId);
                     $location->name = $this->data->name;
                     return $location->edit();
                 }
                 break;
             case 'getLocations':
                 return Location::getLocations($session->warehouseId);
             case 'addPalette':
                 $palette = new Palette(null, $session->warehouseId);
                 if (isset($this->data->locationId)) {
                     $palette->locationId = $this->data->locationId;
                 }
                 if ($palette->edit()) {
                     return $palette->id;
                 }
                 break;
             case 'getPalette':
                 if (isset($this->data->id) && isset($this->data->update)) {
                     return new Palette($this->data->id, $session->warehouseId, $this->data->update);
                 } elseif (isset($this->data->id)) {
                     return new Palette($this->data->id, $session->warehouseId);
                 }
                 break;
             case 'deletePalette':
                 if (isset($this->data->id)) {
                     $palette = new Palette($this->data->id, $session->warehouseId);
                     return $palette->delete();
                 }
                 break;
             case 'editPalette':
                 if (isset($this->data->id)) {
                     $palette = new Palette($this->data->id, $session->warehouseId);
                     if (isset($this->data->locationId)) {
                         $palette->locationId = $this->data->locationId;
                     }
                     return $palette->edit();
                 }
                 break;
             case 'getPalettes':
                 return Palette::getPalettes($session->warehouseId);
             case 'getCarton':
                 if (isset($this->data->id) && isset($this->data->update)) {
                     return new Carton($this->data->id, $session->warehouseId, null, null, $this->data->update);
                 } elseif (isset($this->data->id)) {
                     return new Carton($this->data->id, $session->warehouseId);
                 }
                 break;
             case 'addCarton':
                 $locationId = null;
                 $paletteId = null;
                 if (isset($this->data->location)) {
                     $locationId = $this->data->location;
                 }
                 if (isset($this->data->palette)) {
                     $paletteId = $this->data->palette;
                 }
                 $carton = new Carton(null, $session->warehouseId, $locationId, $paletteId);
                 return $carton->id;
             case 'deleteCarton':
                 if (isset($this->data->id)) {
                     $carton = new Carton($this->data->id, $session->warehouseId);
                     return $carton->delete();
                 }
                 break;
             case 'editCarton':
                 if (isset($this->data->id)) {
                     $carton = new Carton($this->data->id, $session->warehouseId);
                     if (isset($this->data->location)) {
                         $carton->locationId = $this->data->location;
                     } else {
                         $carton->locationId = null;
                     }
                     if (isset($this->data->palette)) {
                         $carton->paletteId = $this->data->palette;
                     } else {
                         $carton->paletteId = null;
                     }
                     return $carton->edit();
                 }
                 break;
             case 'addArticle':
                 if (isset($this->data->carton) && isset($this->data->category) && isset($this->data->amount)) {
                     return Stock::addArticle($this->data->carton, $this->data->category, isset($this->data->male) ? $this->data->male : false, isset($this->data->female) ? $this->data->female : false, isset($this->data->children) ? $this->data->children : false, isset($this->data->baby) ? $this->data->baby : false, isset($this->data->winter) ? $this->data->winter : false, isset($this->data->summer) ? $this->data->summer : false, $this->data->amount >= 0 ? $this->data->amount : 0, $this->data->amount < 0 ? $this->data->amount : 0);
                 }
                 break;
             case 'getStock':
                 return Stock::getStock($session->warehouseId, isset($this->data->carton) ? $this->data->carton : null, isset($this->data->category) ? $this->data->category : null, isset($this->data->palette) ? $this->data->palette : null, isset($this->data->location) ? $this->data->location : null, isset($this->data->male) ? $this->data->male : false, isset($this->data->female) ? $this->data->female : false, isset($this->data->children) ? $this->data->children : false, isset($this->data->baby) ? $this->data->male : false, isset($this->data->summer) ? $this->data->male : false, isset($this->data->winter) ? $this->data->male : false, isset($this->data->details) ? $this->data->details : false);
             case 'getBarcodeUri':
                 if (isset($this->data->text)) {
                     // create barcode object
                     $bc = new Barcode39($this->data->text);
                     if (isset($this->data->textSize)) {
                         $bc->barcode_text_size = $this->data->textSize;
                     }
                     if (isset($this->data->barThin)) {
                         $bc->barcode_bar_thin = $this->data->barThin;
                     }
                     if (isset($this->data->barThick)) {
                         $bc->barcode_bar_thick = $this->data->barThick;
                     }
                     // generate barcode image
                     $img = "barcode_" . mt_rand(0, 100) . ".png";
                     $bc->draw($img);
                     // get data uri
                     $uri = Barcode39::getDataURI($img);
                     unlink($img);
                     return $uri;
                 }
                 break;
         }
     } else {
         // process unrestricted function
         switch ($this->f) {
             case 'getActiveSessions':
                 return Session::getActiveSessionsNumber();
             case 'getWarehouses':
                 return Warehouse::getWarehouses();
             case 'addWarehouse':
                 $data = $this->data;
                 if (isset($data->name) && isset($data->description) && isset($data->country) && isset($data->city) && isset($data->password) && isset($data->mail)) {
                     $warehouse = new Warehouse();
                     Log::debug('new warehouse' . $warehouse->id);
                     $warehouse->name = $data->name;
                     $warehouse->description = $data->description;
                     $warehouse->country = $data->country;
                     $warehouse->city = $data->city;
                     $warehouse->setPassword($data->password);
                     $warehouse->setMail($data->mail);
                     return $warehouse->edit();
                 }
                 break;
             case 'getCountries':
                 return getCountries();
                 break;
             case 'getCountryCode':
                 $data = $this->data;
                 if (isset($data->name)) {
                     return getCountryCode(null, $data->name);
                 }
                 return false;
         }
     }
     return false;
 }
    public function displayForm($token = NULL)
    {
        global $currentIndex, $cookie;
        parent::displayForm();
        if (!($obj = $this->loadObject(true))) {
            return;
        }
        $active = $this->getFieldValue($obj, 'active');
        $customer_groups = $obj->getGroups();
        echo '
		<form action="' . $currentIndex . '&submitAdd' . $this->table . '=1&token=' . ($token != NULL ? $token : $this->token) . '" method="post" enctype="multipart/form-data">
		' . ($obj->id ? '<input type="hidden" name="id_' . $this->table . '" value="' . $obj->id . '" />' : '') . '
			<fieldset><legend><img src="../img/admin/tab-categories.gif" />' . $this->l('Category') . '</legend>
				<label>' . $this->l('Name:') . ' </label>
				<div class="margin-form translatable">';
        foreach ($this->_languages as $language) {
            echo '
					<div class="lang_' . $language['id_lang'] . '" style="display: ' . ($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none') . '; float: left;">
						<input type="text" style="width: 260px" name="name_' . $language['id_lang'] . '" id="name_' . $language['id_lang'] . '" value="' . htmlentities($this->getFieldValue($obj, 'name', (int) $language['id_lang']), ENT_COMPAT, 'UTF-8') . '" ' . (!$obj->id ? ' onkeyup="copy2friendlyURL();"' : '') . ' /><sup> *</sup>
						<span class="hint" name="help_box">' . $this->l('Invalid characters:') . ' <>;=#{}<span class="hint-pointer">&nbsp;</span></span>
					</div>';
        }
        echo '	<p class="clear"></p>
				</div>
				<label>' . $this->l('Displayed:') . ' </label>
				<div class="margin-form">
					<input type="radio" name="active" id="active_on" value="1" ' . ($active ? 'checked="checked" ' : '') . '/>
					<label class="t" for="active_on"><img src="../img/admin/enabled.gif" alt="' . $this->l('Enabled') . '" title="' . $this->l('Enabled') . '" /></label>
					<input type="radio" name="active" id="active_off" value="0" ' . (!$active ? 'checked="checked" ' : '') . '/>
					<label class="t" for="active_off"><img src="../img/admin/disabled.gif" alt="' . $this->l('Disabled') . '" title="' . $this->l('Disabled') . '" /></label>
				</div>
				<label>' . $this->l('Parent category:') . ' </label>
				<div class="margin-form">
					<select name="id_parent">';
        $categories = Category::getCategories((int) $cookie->id_lang, false);
        Category::recurseCategory($categories, $categories[0][1], 1, $this->getFieldValue($obj, 'id_parent'));
        echo '
					</select>
				</div>
				<label>' . $this->l('Description:') . ' </label>
				<div class="margin-form translatable">';
        foreach ($this->_languages as $language) {
            echo '
					<div class="lang_' . $language['id_lang'] . '" style="display: ' . ($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none') . '; float: left;">
						<textarea name="description_' . $language['id_lang'] . '" rows="5" cols="40">' . htmlentities($this->getFieldValue($obj, 'description', (int) $language['id_lang']), ENT_COMPAT, 'UTF-8') . '</textarea>
					</div>';
        }
        echo '	<p class="clear"></p>
				</div>
				<label>' . $this->l('Image:') . ' </label>
				<div class="margin-form">';
        echo $this->displayImage($obj->id, _PS_IMG_DIR_ . 'c/' . $obj->id . '.jpg', 350, NULL, Tools::getAdminToken('AdminCatalog' . (int) Tab::getIdFromClassName('AdminCatalog') . (int) $cookie->id_employee), true);
        echo '	<br /><input type="file" name="image" />
					<p>' . $this->l('Upload category logo from your computer') . '</p>
				</div>
				<div class="clear"><br /></div>	
				<label>' . $this->l('Meta title:') . ' </label>
				<div class="margin-form translatable">';
        foreach ($this->_languages as $language) {
            echo '
					<div class="lang_' . $language['id_lang'] . '" style="display: ' . ($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none') . '; float: left;">
						<input type="text" name="meta_title_' . $language['id_lang'] . '" id="meta_title_' . $language['id_lang'] . '" value="' . htmlentities($this->getFieldValue($obj, 'meta_title', (int) $language['id_lang']), ENT_COMPAT, 'UTF-8') . '" />
						<span class="hint" name="help_box">' . $this->l('Forbidden characters:') . ' <>;=#{}<span class="hint-pointer">&nbsp;</span></span>
					</div>';
        }
        echo '	<p class="clear"></p>
				</div>
				<label>' . $this->l('Meta description:') . ' </label>
				<div class="margin-form translatable">';
        foreach ($this->_languages as $language) {
            echo '<div class="lang_' . $language['id_lang'] . '" style="display: ' . ($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none') . '; float: left;">
						<input type="text" name="meta_description_' . $language['id_lang'] . '" id="meta_description_' . $language['id_lang'] . '" value="' . htmlentities($this->getFieldValue($obj, 'meta_description', (int) $language['id_lang']), ENT_COMPAT, 'UTF-8') . '" />
						<span class="hint" name="help_box">' . $this->l('Forbidden characters:') . ' <>;=#{}<span class="hint-pointer">&nbsp;</span></span>
				</div>';
        }
        echo '	<p class="clear"></p>
				</div>
				<label>' . $this->l('Meta keywords:') . ' </label>
				<div class="margin-form translatable">';
        foreach ($this->_languages as $language) {
            echo '
					<div class="lang_' . $language['id_lang'] . '" style="display: ' . ($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none') . '; float: left;">
						<input type="text" name="meta_keywords_' . $language['id_lang'] . '" id="meta_keywords_' . $language['id_lang'] . '" value="' . htmlentities($this->getFieldValue($obj, 'meta_keywords', (int) $language['id_lang']), ENT_COMPAT, 'UTF-8') . '" />
						<span class="hint" name="help_box">' . $this->l('Forbidden characters:') . ' <>;=#{}<span class="hint-pointer">&nbsp;</span></span>
					</div>';
        }
        echo '	<p class="clear"></p>
				</div>
				<label>' . $this->l('Friendly URL:') . ' </label>
				<div class="margin-form translatable">';
        foreach ($this->_languages as $language) {
            echo '<div class="lang_' . $language['id_lang'] . '" style="display: ' . ($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none') . '; float: left;">
						<input type="text" name="link_rewrite_' . $language['id_lang'] . '" id="link_rewrite_' . $language['id_lang'] . '" value="' . htmlentities($this->getFieldValue($obj, 'link_rewrite', (int) $language['id_lang']), ENT_COMPAT, 'UTF-8') . '" onchange="this.value = str2url(this.value);" /><sup> *</sup>
						<span class="hint" name="help_box">' . $this->l('Only letters and the minus (-) character are allowed') . '<span class="hint-pointer">&nbsp;</span></span>
					</div>';
        }
        echo '	<p class="clear"></p>
				</div>
				<label>' . $this->l('Groups access:') . ' </label>
				<div class="margin-form">';
        $groups = Group::getGroups((int) $cookie->id_lang);
        if (sizeof($groups)) {
            echo '
					<table cellspacing="0" cellpadding="0" class="table" style="width: 28em;">
						<tr>
							<th><input type="checkbox" name="checkme" class="noborder" onclick="checkDelBoxes(this.form, \'groupBox[]\', this.checked)"' . (!isset($obj->id) ? 'checked="checked" ' : '') . ' /></th>
							<th>' . $this->l('ID') . '</th>
							<th>' . $this->l('Group name') . '</th>
						</tr>';
            $irow = 0;
            foreach ($groups as $group) {
                echo '
							<tr class="' . ($irow++ % 2 ? 'alt_row' : '') . '">
								<td><input type="checkbox" name="groupBox[]" class="groupBox" id="groupBox_' . $group['id_group'] . '" value="' . $group['id_group'] . '" ' . ((in_array($group['id_group'], $customer_groups) or !isset($obj->id)) ? 'checked="checked" ' : '') . '/></td>
								<td>' . $group['id_group'] . '</td>
								<td><label for="groupBox_' . $group['id_group'] . '" class="t">' . $group['name'] . '</label></td>
							</tr>';
            }
            echo '
					</table>
					<p style="padding:0px; margin:10px 0px 10px 0px;">' . $this->l('Mark all groups you want to give access to this category') . '</p>
					';
        } else {
            echo '<p>' . $this->l('No group created') . '</p>';
        }
        echo '
				</div>
				<div class="margin-form">
					<input type="submit" value="' . $this->l('Save and back to parent category') . '" name="submitAdd' . $this->table . 'AndBackToParent" class="button" />
					&nbsp;<input type="submit" class="button" name="submitAdd' . $this->table . '" value="' . $this->l('Save') . '"/>
				</div>
				<div class="small"><sup>*</sup> ' . $this->l('Required field') . '</div>
			</fieldset>
		</form>
		<p class="clear"></p>';
    }