public function __construct()
    {
        $this->bootstrap = true;
        $this->context = Context::getContext();
        $this->cxt_lang = $this->context->language->id;
        $this->cxt_shop = $this->context->shop->id;
        $this->table = 'loyaltydiscount';
        $this->_select = 'CONCAT(\'#\', p1.`id_product`, \' \', p1.`name`) AS `product_purchased_name`
						, CONCAT(\'#\', p2.`id_product`, \' \', p2.`name`) AS `product_discounted_name`';
        $this->_join = ' JOIN  `' . _DB_PREFIX_ . 'product_lang` p1 ON (p1.`id_product`=a.`id_product_purchased`
							AND p1.`id_shop`=' . $this->cxt_shop . ' AND p1.`id_lang`=' . $this->cxt_lang . ')
					 	JOIN  `' . _DB_PREFIX_ . 'product_lang` p2 ON (p2.`id_product`=a.`id_product_discounted`
							AND p2.`id_shop`=' . $this->cxt_shop . ' AND p2.`id_lang`=' . $this->cxt_lang . ')';
        $this->className = 'LoyaltyDiscountModel';
        $this->lang = true;
        $this->allow_export = true;
        $this->fields_list = array('id_loyaltydiscount' => array('title' => $this->l('ID'), 'align' => 'center', 'class' => 'fixed-width-xs'), 'name' => array('title' => $this->l('Name')), 'description' => array('title' => $this->l('Description'), 'callback' => 'getDescriptionClean', 'orderby' => false), 'rate' => array('title' => $this->l('Rate'), 'type' => 'decimal'), 'product_purchased_name' => array('title' => $this->l('Product purchased')), 'product_discounted_name' => array('title' => $this->l('Product discounted')), 'active' => array('title' => $this->l('Activated'), 'active' => 'status', 'type' => 'bool', 'class' => 'fixed-width-xs', 'align' => 'center', 'ajax' => false, 'orderby' => false));
        $this->bulk_actions = array('delete' => array('text' => $this->l('Delete selected'), 'icon' => 'icon-trash', 'confirm' => $this->l('Delete selected items?')));
        parent::__construct();
        $this->products_list = array_map(function ($x) {
            $x['name'] = '#' . $x['id_product'] . ' ' . $x['name'];
            return $x;
        }, Product::getSimpleProducts($this->cxt_lang, $this->context));
        if (!$this->module->active) {
            Tools::redirectAdmin($this->context->link->getAdminLink('AdminHome'));
        }
    }
예제 #2
0
    public function displayJavascript()
    {
        global $cookie, $currentIndex;
        $products = Product::getSimpleProducts((int) $cookie->id_lang);
        $productsArray = array();
        foreach ($products as $product) {
            $productsArray[] = $product['id_product'];
        }
        return '
			<script type="text/javascript">
				var productIds = new Array(\'' . implode('\',\'', $productsArray) . '\');
				var referrerStatus = new Array();
				
				function newProductLine(id_referrer, result)
				{
					return \'\'+
					\'<tr id="trprid_\'+id_referrer+\'_\'+result.id_product+\'" style="background-color: rgb(255, 255, 187);">\'+
					\'	<td align="center">--</td>\'+
					\'	<td align="center">\'+result.id_product+\'</td>\'+
					\'	<td>\'+result.product_name+\'</td>\'+
					\'	<td align="center">\'+result.uniqs+\'</td>\'+
					\'	<td align="center">\'+result.visits+\'</td>\'+
					\'	<td align="center">\'+result.pages+\'</td>\'+
					\'	<td align="center">\'+result.registrations+\'</td>\'+
					\'	<td align="center">\'+result.orders+\'</td>\'+
					\'	<td align="right">\'+result.sales+\'</td>\'+
					\'	<td align="right">\'+result.cart+\'</td>\'+
					\'	<td align="center">\'+result.reg_rate+\'</td>\'+
					\'	<td align="center">\'+result.order_rate+\'</td>\'+
					\'	<td align="center">\'+result.click_fee+\'</td>\'+
					\'	<td align="center">\'+result.base_fee+\'</td>\'+
					\'	<td align="center">\'+result.percent_fee+\'</td>\'+
					\'	<td align="center">--</td>\'+
					\'</tr>\';
				}
				
				function showProductLines(id_referrer)
				{
					if (!referrerStatus[id_referrer])
					{
						referrerStatus[id_referrer] = true;
						for (var i = 0; i < productIds.length; ++i)
							$.getJSON("' . dirname($currentIndex) . '/ajax.php",{ajaxReferrers:1, ajaxProductFilter:1,id_employee:' . (int) $cookie->id_employee . ',token:"' . Tools::getValue('token') . '",id_referrer:id_referrer,id_product:productIds[i]},
								function(result) {
									var newLine = newProductLine(id_referrer, result[0]);
									$(newLine).hide().insertAfter(getE(\'trid_\'+id_referrer)).fadeIn();
								}
							);
					}
					else
					{
						referrerStatus[id_referrer] = false;
						for (var i = 0; i < productIds.length; ++i)
							$("#trprid_"+id_referrer+"_"+productIds[i]).fadeOut("fast",	function(){$("#trprid_"+i).remove();});
					}
				}
			</script>';
    }
예제 #3
0
    private function _displayFormApplicationCriterion()
    {
        include_once dirname(__FILE__) . '/ProductCommentCriterion.php';
        $criterions = ProductCommentCriterion::getCriterions($this->context->language->id, false, true);
        $id_criterion = (int) Tools::getValue('updateCriterion');
        if ($id_criterion) {
            $criterion = new ProductCommentCriterion((int) $id_criterion);
            if ($criterion->id_product_comment_criterion_type == 2) {
                $categories = Category::getSimpleCategories($this->context->language->id);
                $criterion_categories = $criterion->getCategories();
            } else {
                if ($criterion->id_product_comment_criterion_type == 3) {
                    $criterion_products = $criterion->getProducts();
                    $products = Product::getSimpleProducts($this->context->language->id);
                }
            }
        }
        foreach ($criterions as $key => $foo) {
            if ($foo['id_product_comment_criterion_type'] == 1) {
                unset($criterions[$key]);
            }
        }
        if (count($criterions)) {
            $this->_html .= '
			<fieldset class="width2">
				<legend><img src="' . $this->_path . 'img/note_go.png" alt="" title="" />' . $this->l('Manage criterions scope') . '</legend>
				<p style="margin-bottom: 15px;">' . $this->l('Only criterions restricted to categories or products can be configured below:') . '</p>
				<form action="' . Tools::safeOutput($this->_baseUrl) . '" method="post" name="product_criterion_form">
					<label>' . $this->l('Criterion') . '</label>
					<div class="margin-form">
">
						<select name="id_product_comment_criterion" id="id_product_comment_criterion" onchange="window.location=\'' . Tools::safeOutput($this->_baseUrl) . '&updateCriterion=\'+$(\'#id_product_comment_criterion option:selected\').val()">
							<option value="--">-- ' . $this->l('Choose a criterion') . ' --</option>';
            foreach ($criterions as $foo) {
                $this->_html .= '<option value="' . (int) $foo['id_product_comment_criterion'] . '" ' . ($foo['id_product_comment_criterion'] == $id_criterion ? 'selected="selected"' : '') . '>' . $foo['name'] . '</option>';
            }
            $this->_html .= '</select>
					</div>
				</form>';
            if ($id_criterion && $criterion->id_product_comment_criterion_type != 1) {
                $this->_html .= '<label for="id_product_comment_criterion">' . ($criterion->id_product_comment_criterion_type == 3 ? $this->l('Products') : $this->l('Categories')) . '</label>
					<form action="' . Tools::safeOutput($this->_baseUrl) . '" method="post" name="comment_form">
						<div id="product_criterions" class="margin-form">
							<input type="hidden" name="id_criterion" id="id_criterion" value="' . (int) $id_criterion . '" />
							<br /><table class="table" border="0" cellspacing="0" cellpadding="0">
							<thead>
							<tr>
								<th><input class="noborder" type="checkbox" name="id_product[]" onclick="checkDelBoxes(this.form, \'id_product[]\', this.checked);" /></th>
								<th style="width: 30px;">' . $this->l('ID') . '</th>
								<th style="width: 550px;">' . ($criterion->id_product_comment_criterion_type == 3 ? $this->l('Product Name') : $this->l('Category Name')) . '</th>
							</tr>
							</thead>
							<tbody>';
                if ($criterion->id_product_comment_criterion_type == 3) {
                    foreach ($products as $product) {
                        $this->_html .= '<tr><td><input class="noborder" type="checkbox" value="' . (int) $product['id_product'] . '" name="id_product[]" ' . (in_array($product['id_product'], $criterion_products) ? 'checked="checked"' : '') . ' /></td>
											<td>' . (int) $product['id_product'] . '</td><td>' . $product['name'] . '</td></tr>';
                    }
                } else {
                    if ($criterion->id_product_comment_criterion_type == 2) {
                        foreach ($categories as $category) {
                            $this->_html .= '<tr><td><input class="noborder" type="checkbox" value="' . (int) $category['id_category'] . '" name="id_product[]" ' . (in_array($category['id_category'], $criterion_categories) ? 'checked="checked"' : '') . ' /></td>
											<td>' . (int) $category['id_category'] . '</td><td>' . $category['name'] . '</td></tr>';
                        }
                    }
                }
                $this->_html .= '</tbody>
						</table>
						</div>
						<div class="margin-form clear">
							<input type="submit" name="submitApplicationCriterion" value="' . $this->l('Save') . '" class="button" />
						</div>
					</form>';
            }
            $this->_html .= '</fieldset>';
        }
    }
예제 #4
0
    public function displayAccount()
    {
        global $smarty, $cookie;
        if (!isset($cookie->stats_date_from)) {
            $cookie->stats_date_from = date('Y-m-d');
        }
        if (!isset($cookie->stats_date_to)) {
            $cookie->stats_date_to = date('Y-m-t');
        }
        $fakeEmployee = new Employee();
        $fakeEmployee->stats_date_from = $cookie->stats_date_from;
        $fakeEmployee->stats_date_to = $cookie->stats_date_to;
        Referrer::refreshCache(array(array('id_referrer' => intval($cookie->tracking_id))), $fakeEmployee);
        $referrer = new Referrer(intval($cookie->tracking_id));
        $smarty->assign('referrer', $referrer);
        $smarty->assign('datepickerFrom', $fakeEmployee->stats_date_from);
        $smarty->assign('datepickerTo', $fakeEmployee->stats_date_to);
        $displayTab = array('uniqs' => $this->l('Unique visitors'), 'visitors' => $this->l('Visitors'), 'visits' => $this->l('Visits'), 'pages' => $this->l('Pages viewed'), 'registrations' => $this->l('Registrations'), 'orders' => $this->l('Orders'), 'base_fee' => $this->l('Base fee'), 'percent_fee' => $this->l('Percent fee'), 'click_fee' => $this->l('Click fee'), 'sales' => $this->l('Sales'), 'cart' => $this->l('Average cart'), 'reg_rate' => $this->l('Registration rate'), 'order_rate' => $this->l('Order rate'));
        $smarty->assign('displayTab', $displayTab);
        $products = Product::getSimpleProducts(intval($cookie->id_lang));
        $productsArray = array();
        foreach ($products as $product) {
            $productsArray[] = $product['id_product'];
        }
        $echo = '
		<script type="text/javascript" src="../../js/jquery/datepicker/ui/i18n/ui.datepicker-' . Db::getInstance()->getValue('SELECT iso_code FROM ' . _DB_PREFIX_ . 'lang WHERE `id_lang` = ' . intval($cookie->id_lang)) . '.js"></script>
		<script type="text/javascript">
			$("#datepickerFrom").datepicker({
				prevText:"",
				nextText:"",
				dateFormat:"yy-mm-dd"});
			$("#datepickerTo").datepicker({
				prevText:"",
				nextText:"",
				dateFormat:"yy-mm-dd"});
			
			function updateValues()
			{
				$.getJSON("stats.php",{ajaxProductFilter:1,id_referrer:' . $referrer->id . ',token:"' . $cookie->tracking_passwd . '",id_product:0},
					function(j) {';
        foreach ($displayTab as $key => $value) {
            $echo .= '$("#' . $key . '").html(j[0].' . $key . ');';
        }
        $echo .= '		}
				)
			}		

			var productIds = new Array(\'' . implode('\',\'', $productsArray) . '\');
			var referrerStatus = new Array();
			
			function newProductLine(id_referrer, result, color)
			{
				return \'\'+
				\'<tr id="trprid_\'+id_referrer+\'_\'+result.id_product+\'" style="background-color: rgb(\'+color+\', \'+color+\', \'+color+\');">\'+
				\'	<td align="center">\'+result.id_product+\'</td>\'+
				\'	<td>\'+result.product_name+\'</td>\'+
				\'	<td align="center">\'+result.uniqs+\'</td>\'+
				\'	<td align="center">\'+result.visits+\'</td>\'+
				\'	<td align="center">\'+result.pages+\'</td>\'+
				\'	<td align="center">\'+result.registrations+\'</td>\'+
				\'	<td align="center">\'+result.orders+\'</td>\'+
				\'	<td align="right">\'+result.sales+\'</td>\'+
				\'	<td align="right">\'+result.cart+\'</td>\'+
				\'	<td align="center">\'+result.reg_rate+\'</td>\'+
				\'	<td align="center">\'+result.order_rate+\'</td>\'+
				\'	<td align="center">\'+result.click_fee+\'</td>\'+
				\'	<td align="center">\'+result.base_fee+\'</td>\'+
				\'	<td align="center">\'+result.percent_fee+\'</td>\'+
				\'</tr>\';
			}
			
			function showProductLines()
			{
				var irow = 0;
				for (var i = 0; i < productIds.length; ++i)
					$.getJSON("stats.php",{ajaxProductFilter:1,token:"' . $cookie->tracking_passwd . '",id_referrer:' . $referrer->id . ',id_product:productIds[i]},
						function(result) {
							var newLine = newProductLine(' . $referrer->id . ', result[0], (irow++%2 ? 204 : 238));
							$(newLine).hide().insertBefore($(\'#trid_dummy\')).fadeIn();
						}
					);
			}
		</script>';
        $echo2 = '
		<script type="text/javascript">
			updateValues();
			//showProductLines();
		</script>';
        return $this->display(__FILE__, 'header.tpl') . $echo . $this->display(__FILE__, 'account.tpl') . $echo2;
    }
 public function generateFlux()
 {
     if (Tools::getValue('token') == '' || Tools::getValue('token') != Configuration::get('SHOPPING_FLUX_TOKEN')) {
         die('Invalid Token');
     }
     $titles = array(0 => 'id_produit', 1 => 'nom_produit', 2 => 'url_produit', 3 => 'url_image', 4 => 'description', 5 => 'description_courte', 6 => 'prix', 7 => 'prix_barre', 8 => 'frais_de_port', 9 => 'delaiLiv', 10 => 'marque', 11 => 'rayon', 12 => 'stock', 13 => 'qte_stock', 14 => 'EAN', 15 => 'poids', 16 => 'ecotaxe', 17 => 'TVA', 18 => 'Reference constructeur', 19 => 'Reference fournisseur');
     echo implode("|", $titles) . "\r\n";
     //For Shipping
     $configuration = Configuration::getMultiple(array('PS_TAX_ADDRESS_TYPE', 'PS_CARRIER_DEFAULT', 'PS_COUNTRY_DEFAULT', 'PS_LANG_DEFAULT', 'PS_SHIPPING_FREE_PRICE', 'PS_SHIPPING_HANDLING', 'PS_SHIPPING_METHOD', 'PS_SHIPPING_FREE_WEIGHT'));
     $products = Product::getSimpleProducts($configuration['PS_LANG_DEFAULT']);
     $defaultCountry = new Country($configuration['PS_COUNTRY_DEFAULT'], Configuration::get('PS_LANG_DEFAULT'));
     $id_zone = (int) $defaultCountry->id_zone;
     $carrier = new Carrier((int) $configuration['PS_CARRIER_DEFAULT']);
     $carrierTax = Tax::getCarrierTaxRate((int) $carrier->id, (int) $this->{$configuration['PS_TAX_ADDRESS_TYPE']});
     foreach ($products as $key => $produit) {
         $product = new Product((int) $produit['id_product'], true, $configuration['PS_LANG_DEFAULT']);
         //For links
         $link = new Link();
         //For images
         $cover = $product->getCover($product->id);
         $ids = $product->id . '-' . $cover['id_image'];
         //For shipping
         if ($product->getPrice(true, NULL, 2, NULL, false, true, 1) >= (double) $configuration['PS_SHIPPING_FREE_PRICE'] and (double) $configuration['PS_SHIPPING_FREE_PRICE'] > 0) {
             $shipping = 0;
         } elseif (isset($configuration['PS_SHIPPING_FREE_WEIGHT']) and $product->weight >= (double) $configuration['PS_SHIPPING_FREE_WEIGHT'] and (double) $configuration['PS_SHIPPING_FREE_WEIGHT'] > 0) {
             $shipping = 0;
         } else {
             if (isset($configuration['PS_SHIPPING_HANDLING']) and $carrier->shipping_handling) {
                 $shipping = (double) $configuration['PS_SHIPPING_HANDLING'];
             }
             if ($carrier->getShippingMethod() == Carrier::SHIPPING_METHOD_WEIGHT) {
                 $shipping += $carrier->getDeliveryPriceByWeight($product->weight, $id_zone);
             } else {
                 $shipping += $carrier->getDeliveryPriceByPrice($product->getPrice(true, NULL, 2, NULL, false, true, 1), $id_zone);
             }
             $shipping *= 1 + $carrierTax / 100;
             $shipping = (double) Tools::ps_round((double) $shipping, 2);
         }
         $data = array();
         $data[0] = $product->id;
         $data[1] = $product->name;
         $data[2] = $link->getProductLink($product);
         $data[3] = $link->getImageLink($product->link_rewrite, $ids, 'large');
         $data[4] = $product->description;
         $data[5] = $product->description_short;
         $data[6] = $product->getPrice(true, NULL, 2, NULL, false, true, 1);
         $data[7] = $product->getPrice(true, NULL, 2, NULL, false, false, 1);
         $data[8] = $shipping;
         $data[9] = $carrier->delay[2];
         $data[10] = $product->manufacturer_name;
         $data[11] = $product->category;
         $data[12] = $product->quantity > 0 ? 'oui' : 'non';
         $data[13] = $product->quantity;
         $data[14] = $product->ean13;
         $data[15] = $product->weight;
         $data[16] = $product->ecotax;
         $data[17] = $product->tax_rate;
         $data[18] = $product->reference;
         $data[19] = $product->supplier_reference;
         foreach ($data as $key => $value) {
             $data[$key] = $this->clean($value);
         }
         echo implode("|", $data) . "\r\n";
     }
 }
 function renderCriterionForm($id_criterion = 0)
 {
     $types = ProductCommentCriterion::getTypes();
     $query = array();
     foreach ($types as $key => $value) {
         $query[] = array('id' => $key, 'label' => $value);
     }
     $criterion = new ProductCommentCriterion((int) $id_criterion);
     $selected_categories = $criterion->getCategories();
     $product_table_values = Product::getSimpleProducts($this->context->language->id);
     $selected_products = $criterion->getProducts();
     foreach ($product_table_values as $key => $product) {
         if (false !== array_search($product['id_product'], $selected_products)) {
             $product_table_values[$key]['selected'] = 1;
         }
     }
     if (version_compare(_PS_VERSION_, '1.6', '<')) {
         $field_category_tree = array('type' => 'categories_select', 'name' => 'categoryBox', 'label' => $this->l('Criterion will be restricted to the following categories'), 'category_tree' => $this->initCategoriesAssociation(null, $id_criterion));
     } else {
         $field_category_tree = array('type' => 'categories', 'label' => $this->l('Criterion will be restricted to the following categories'), 'name' => 'categoryBox', 'desc' => $this->l('Mark the boxes of categories to which this criterion applies.'), 'tree' => array('use_search' => false, 'id' => 'categoryBox', 'use_checkbox' => true, 'selected_categories' => $selected_categories), 'values' => array('trads' => array('Root' => Category::getTopCategory(), 'selected' => $this->l('Selected'), 'Collapse All' => $this->l('Collapse All'), 'Expand All' => $this->l('Expand All'), 'Check All' => $this->l('Check All'), 'Uncheck All' => $this->l('Uncheck All')), 'selected_cat' => $selected_categories, 'input_name' => 'categoryBox[]', 'use_radio' => false, 'use_search' => false, 'disabled_categories' => array(), 'top_category' => Category::getTopCategory(), 'use_context' => true));
     }
     $fields_form_1 = array('form' => array('legend' => array('title' => $this->l('Add new criterion'), 'icon' => 'icon-cogs'), 'input' => array(array('type' => 'hidden', 'name' => 'id_product_comment_criterion'), array('type' => 'text', 'lang' => true, 'label' => $this->l('Criterion name'), 'name' => 'name'), array('type' => 'select', 'name' => 'id_product_comment_criterion_type', 'label' => $this->l('Application scope of the criterion'), 'options' => array('query' => $query, 'id' => 'id', 'name' => 'label')), $field_category_tree, array('type' => 'products', 'label' => $this->l('The criterion will be restricted to the following products'), 'name' => 'ids_product', 'values' => $product_table_values), array('type' => 'switch', 'is_bool' => true, 'label' => $this->l('Active'), 'name' => 'active', 'values' => array(array('id' => 'active_on', 'value' => 1, 'label' => $this->l('Enabled')), array('id' => 'active_off', 'value' => 0, 'label' => $this->l('Disabled'))))), 'submit' => array('title' => $this->l('Save'), 'class' => 'btn btn-default pull-right', 'name' => 'submitEditCriterion')));
     $helper = new HelperForm();
     $helper->show_toolbar = false;
     $helper->table = $this->name;
     $lang = new Language((int) Configuration::get('PS_LANG_DEFAULT'));
     $helper->default_form_language = $lang->id;
     $helper->module = $this;
     $helper->allow_employee_form_lang = Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') ? Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') : 0;
     $helper->identifier = $this->identifier;
     $helper->submit_action = 'submitEditCriterion';
     $helper->currentIndex = $this->context->link->getAdminLink('AdminModules', false) . '&configure=' . $this->name . '&tab_module=' . $this->tab . '&module_name=' . $this->name;
     $helper->token = Tools::getAdminTokenLite('AdminModules');
     $helper->tpl_vars = array('fields_value' => $this->getCriterionFieldsValues($id_criterion), 'languages' => $this->context->controller->getLanguages(), 'id_language' => $this->context->language->id);
     return $helper->generateForm(array($fields_form_1));
 }
 public function generateFeed()
 {
     if (Tools::getValue('token') == '' || Tools::getValue('token') != Configuration::get('SHOPPING_FLUX_TOKEN')) {
         die("<?xml version='1.0' encoding='utf-8'?><error>Invalid Token</error>");
     }
     $configuration = Configuration::getMultiple(array('PS_TAX_ADDRESS_TYPE', 'PS_CARRIER_DEFAULT', 'PS_COUNTRY_DEFAULT', 'PS_LANG_DEFAULT', 'PS_SHIPPING_FREE_PRICE', 'PS_SHIPPING_HANDLING', 'PS_SHIPPING_METHOD', 'PS_SHIPPING_FREE_WEIGHT'));
     $carrier = new Carrier((int) $configuration['PS_CARRIER_DEFAULT']);
     $products = Product::getSimpleProducts($configuration['PS_LANG_DEFAULT'], null, true);
     echo '<?xml version="1.0" encoding="utf-8"?>';
     echo '<produits>';
     foreach ($products as $productArray) {
         $product = new Product((int) $productArray['id_product'], true, $configuration['PS_LANG_DEFAULT']);
         $link = new Link();
         if ($product->active == 1) {
             echo '<produit>';
             echo $this->_getBaseData($product, $configuration, $link, $carrier);
             echo $this->_getImages($product, $configuration, $link);
             echo $this->_getUrlCategories($product, $configuration, $link);
             echo $this->_getFeatures($product, $configuration);
             echo $this->_getCombinaisons($product, $configuration, $link, $carrier);
             echo $this->_getFilAriane($product, $configuration);
             echo '<manufacturer><![CDATA[' . $product->manufacturer_name . ']]></manufacturer>';
             echo '<supplier><![CDATA[' . $product->supplier_name . ']]></supplier>';
             if (is_array($product->specificPrice)) {
                 echo '<from><![CDATA[' . $product->specificPrice['from'] . ']]></from>';
                 echo '<to><![CDATA[' . $product->specificPrice['to'] . ']]></to>';
             } else {
                 echo '<from/>';
                 echo '<to/>';
             }
             echo '<url-fournisseur><![CDATA[' . $link->getSupplierLink($product->id_supplier, NULL, $configuration['PS_LANG_DEFAULT']) . ']]></url-fournisseur>';
             echo '<url-fabricant><![CDATA[' . $link->getManufacturerLink($product->id_manufacturer, NULL, $configuration['PS_LANG_DEFAULT']) . ']]></url-fabricant>';
             echo '</produit>';
         }
     }
     echo '</produits>';
 }
예제 #8
0
 public function displayAccount()
 {
     if (!isset($this->context->cookie->stats_date_from)) {
         $this->context->cookie->stats_date_from = date('Y-m-01');
     }
     if (!isset($this->context->cookie->stats_date_to)) {
         $this->context->cookie->stats_date_to = date('Y-m-t');
     }
     Referrer::refreshCache(array(array('id_referrer' => (int) $this->context->cookie->tracking_id)));
     $referrer = new Referrer((int) $this->context->cookie->tracking_id);
     $this->smarty->assign('referrer', $referrer);
     $this->smarty->assign('datepickerFrom', $this->context->cookie->stats_date_from);
     $this->smarty->assign('datepickerTo', $this->context->cookie->stats_date_to);
     $display_tab = array('uniqs' => $this->l('Unique visitors'), 'visitors' => $this->l('Visitors'), 'visits' => $this->l('Visits'), 'pages' => $this->l('Pages viewed'), 'registrations' => $this->l('Registrations'), 'orders' => $this->l('Orders'), 'base_fee' => $this->l('Base fee'), 'percent_fee' => $this->l('Percent fee'), 'click_fee' => $this->l('Click fee'), 'sales' => $this->l('Sales'), 'cart' => $this->l('Average cart'), 'reg_rate' => $this->l('Registration rate'), 'order_rate' => $this->l('Order rate'));
     $this->smarty->assign('displayTab', $display_tab);
     $products = Product::getSimpleProducts($this->context->language->id);
     $products_array = array();
     foreach ($products as $product) {
         $products_array[] = $product['id_product'];
     }
     $js_files = array();
     $jquery_files = Media::getJqueryPath();
     if (is_array($jquery_files)) {
         $js_files = array_merge($js_files, $jquery_files);
     } else {
         $js_files[] = $jquery_files;
     }
     $jquery_ui_files = Media::getJqueryUIPath('ui.datepicker', 'base', true);
     $js_files = array_merge($js_files, $jquery_ui_files['js']);
     $css_files = $jquery_ui_files['css'];
     $js_files[] = $this->_path . 'js/trackingfront.js';
     $js_tpl_var = array('product_ids' => implode(', ', $products_array), 'referrer_id' => $referrer->id, 'token' => $this->context->cookie->tracking_passwd, 'display_tab' => implode('", "', array_keys($display_tab)));
     $this->smarty->assign(array('js' => $js_files, 'css' => $css_files, 'js_tpl_var' => $js_tpl_var));
     return $this->display(__FILE__, 'views/templates/front/account.tpl');
 }
예제 #9
0
    private function _displayFormProductCriterion()
    {
        global $cookie;
        $products = Product::getSimpleProducts($cookie->id_lang);
        $this->_html .= '<script type="text/javascript" src="' . $this->_path . 'js/productCriterion.js"></script>
		   <form action="' . $_SERVER['REQUEST_URI'] . '" method="post" name="product_criterion_form">
			<fieldset><legend><img src="' . $this->_path . 'img/note_go.png" alt="" title="" />' . $this->l('Product\'s criterions') . '</legend>
				<p>' . $this->l('Select the grading criterions corresponding to each product. You can select multiple criterions by pressing the ctrl key.') . '</p><br />
				<label for="id_product">' . $this->l('Product') . '</label>
				<div class="margin-form">
					<select name="id_product" id="id_product" onchange="getProductCriterion(\'' . $this->_path . '\', this.options[this.selectedIndex].value, \'' . intval($cookie->id_lang) . '\');">';
        foreach ($products as $product) {
            $this->_html .= '<option value="' . intval($product['id_product']) . '">' . htmlspecialchars($product['name'], ENT_COMPAT, 'UTF-8') . '</option>';
        }
        $this->_html .= '</select>
				</div>
				<label for="id_product_comment_criterion">' . $this->l('Grading criterions') . '</label>
				<div id="product_criterions" class="margin-form">
				</div>
				<div class="margin-form clear"><input type="submit" name="submitCriterionProduct" value="' . $this->l('Save') . '" class="button" /></div>
				<script type="text/javascript">
					getProductCriterion(\'' . $this->_path . '\', document.getElementById(\'id_product\').options[0].value, \'' . intval($cookie->id_lang) . '\');
				</script>
			</fieldset>
			</form>';
    }
예제 #10
0
    protected function renderThemeConfiguratorForm()
    {
        $id_shop = (int) $this->context->shop->id;
        $items = array();
        $hooks = array();
        $this->context->smarty->assign('htmlcontent', array('admin_tpl_path' => $this->admin_tpl_path, 'hooks_tpl_path' => $this->hooks_tpl_path, 'info' => array('module' => $this->name, 'name' => $this->displayName, 'version' => $this->version, 'psVersion' => _PS_VERSION_, 'context' => Configuration::get('PS_MULTISHOP_FEATURE_ACTIVE') == 0 ? 1 : $this->context->shop->getTotalShops() != 1 ? $this->context->shop->getContext() : 1)));
        foreach ($this->languages as $language) {
            $hooks[$language['id_lang']] = array('home', 'top', 'left', 'right', 'footer');
            foreach ($hooks[$language['id_lang']] as $hook) {
                $items[$language['id_lang']][$hook] = Db::getInstance()->ExecuteS('
					SELECT * FROM `' . _DB_PREFIX_ . 'themeconfigurator`
					WHERE id_shop = ' . (int) $id_shop . '
					AND id_lang = ' . (int) $language['id_lang'] . '
					AND hook = \'' . pSQL($hook) . '\'
					ORDER BY item_order ASC');
            }
        }
        $this->context->smarty->assign('htmlitems', array('items' => $items, 'theme_url' => $this->context->link->getAdminLink('AdminThemeConfigurator'), 'lang' => array('default' => $this->default_language, 'all' => $this->languages, 'lang_dir' => _THEME_LANG_DIR_, 'user' => $this->context->language->id), 'postAction' => 'index.php?tab=AdminModules&configure=' . $this->name . '&token=' . Tools::getAdminTokenLite('AdminModules') . '&tab_module=other&module_name=' . $this->name . '', 'id_shop' => $id_shop));
        $all_products = Product::getSimpleProducts((int) Configuration::get('PS_LANG_DEFAULT'));
        $this->context->smarty->assign('all_products', $all_products);
        $this->context->controller->addJqueryUI('ui.sortable');
        return $this->display(__FILE__, 'views/templates/admin/admin.tpl');
    }
예제 #11
0
 public function createShopInfo()
 {
     $shopInfo = array('category_count' => count(Category::getSimpleCategories($this->getLanguageId())), 'item_count' => count(Product::getSimpleProducts($this->getLanguageId())));
     if ($this->config->getEnableGetReviewsCsv()) {
         /**
          * set review_count
          */
         $shopInfo['review_count'] = 0;
     }
     if ($this->config->getEnableGetMediaCsv()) {
         /**
          * media_count
          */
         $shopInfo['media_count'] = array();
     }
     $shopInfo['plugins_installed'] = array();
     foreach (Module::getModulesInstalled() as $module) {
         $shopInfo['plugins_installed'][] = array('id' => $module['id_module'], 'name' => $module['name'], 'version' => $module['version'], 'active' => $module['active'] ? 1 : 0);
     }
     return $shopInfo;
 }
예제 #12
0
     }
     self::$prestaprds = array();
     if (!empty($cats)) {
         foreach ($cats as $cat) {
             if ($cat['id_shop'] == Context::getContext()->shop->id) {
                 self::$prestaprds['category_' . $cat['id_category']] = $cat['name'];
             }
             if (isset($cat['children']) && !empty($cat['children'])) {
                 self::getPrestaProdChildCat($cat['children']);
             }
         }
     }
     return self::$prestaprds;
 }
 public static function getPrestaProdduct()
 {
     $prds = array();
     $prducts = array();
     if (method_exists('Product', 'getSimpleProducts')) {
         $id_lang = (int) Context::getContext()->language->id;
         $prds = Product::getSimpleProducts($id_lang);
     } else {
         $prds = self::getSimpleProducts();
     }
     if (isset($prds) && !empty($prds)) {
 public function createDummyDataForProject()
 {
     //delete privious products of prestashop
     $all_products = Product::getSimpleProducts(Configuration::get('PS_LANG_DEFAULT'));
     foreach ($all_products as $key_pro => $value_pro) {
         $obj_product = new Product($value_pro['id_product']);
         $obj_product->delete();
     }
     // first add a hotel.................
     $def_cont_id = Country::getDefaultCountryId();
     $obj_hotel_info = new HotelBranchInformation();
     $obj_hotel_info->active = 1;
     $obj_hotel_info->hotel_name = "The Hotel Prime";
     $obj_hotel_info->phone = 01234567;
     $obj_hotel_info->email = "*****@*****.**";
     $obj_hotel_info->check_in = '12:00';
     $obj_hotel_info->check_out = '12:00';
     $obj_hotel_info->short_description = $this->l('Nice place to stay');
     $obj_hotel_info->description = $this->l('Nice place to stay');
     $obj_hotel_info->rating = 3;
     $obj_hotel_info->city = 'Nainital';
     $states = State::getStatesByIdCountry($def_cont_id);
     $state_id = $states[0]['id_state'];
     $obj_hotel_info->state_id = $state_id;
     $obj_hotel_info->country_id = $def_cont_id;
     $obj_hotel_info->zipcode = 263001;
     $obj_hotel_info->policies = $this->l('1. intelligentsia tattooed pop-up salvia asymmetrical mixtape meggings tousled ramps VHS cred. 2. intelligentsia tattooed pop-up salvia asymmetrical mixtape meggings tousled ramps VHS cred. 3. intelligentsia tattooed pop-up salvia asymmetrical mixtape meggings tousled ramps VHS cred. 4. intelligentsia tattooed pop-up salvia asymmetrical mixtape meggings tousled ramps VHS cred.');
     $obj_hotel_info->address = 'Near post office, Mallital, Nainital';
     $obj_hotel_info->save();
     $htl_id = $obj_hotel_info->id;
     $grp_ids = array();
     $obj_grp = new Group();
     $data_grp_ids = $obj_grp->getGroups(1, $id_shop = false);
     foreach ($data_grp_ids as $key => $value) {
         $grp_ids[] = $value['id_group'];
     }
     $country_name = (new Country())->getNameById(Configuration::get('PS_LANG_DEFAULT'), $def_cont_id);
     $cat_country = $this->addCategory($country_name, false, $grp_ids);
     if ($cat_country) {
         $states = State::getStatesByIdCountry($def_cont_id);
         $state_name = $states[0]['name'];
         $cat_state = $this->addCategory($state_name, $cat_country, $grp_ids);
     }
     if ($cat_state) {
         $cat_city = $this->addCategory('DefCity', $cat_state, $grp_ids);
     }
     if ($cat_city) {
         $cat_hotel = $this->addCategory('The Hotel Prime', $cat_city, $grp_ids, 1, $htl_id);
     }
     if ($cat_hotel) {
         $obj_hotel_info = new HotelBranchInformation($htl_id);
         $obj_hotel_info->id_category = $cat_hotel;
         $obj_hotel_info->save();
     }
     $branch_ftr_ids = array(1, 2, 4, 7, 8, 9, 11, 12, 14, 16, 17, 18, 21);
     foreach ($branch_ftr_ids as $key_ftr => $value_ftr) {
         $htl_ftr_obj = new HotelBranchFeatures();
         $htl_ftr_obj->id_hotel = $htl_id;
         $htl_ftr_obj->feature_id = $value_ftr;
         $htl_ftr_obj->save();
     }
     $prod_arr = array('Delux Rooms', 'Executive Rooms', 'luxury Rooms');
     $img_num = 1;
     foreach ($prod_arr as $key_prod => $value_prod) {
         // Add Product
         $product = new Product();
         $product->name = array();
         $product->description = array();
         $product->description_short = array();
         $product->link_rewrite = array();
         foreach (Language::getLanguages(true) as $lang) {
             $product->name[$lang['id_lang']] = $value_prod;
             $product->description[$lang['id_lang']] = $this->l('Fashion axe kogi yuccie, ramps shabby chic direct trade before they sold out distillery bicycle rights. Slow-carb +1 quinoa VHS. +1 brunch trust fund, meggings chartreuse sustainable everyday carry tumblr hoodie tacos tilde ramps post-ironic fixie.');
             $product->description_short[$lang['id_lang']] = $this->l('Fashion axe kogi yuccie, ramps shabby chic direct trade before they sold out distillery bicycle rights. Slow-carb +1 quinoa VHS. +1 brunch trust fund, meggings chartreuse sustainable everyday carry tumblr hoodie tacos tilde ramps post-ironic fixie.');
             $product->link_rewrite[$lang['id_lang']] = Tools::link_rewrite('Super Delux Rooms');
         }
         $product->id_shop_default = Context::getContext()->shop->id;
         $product->id_category_default = 2;
         $product->price = 1000;
         $product->active = 1;
         $product->quantity = 99999999;
         $product->is_virtual = 1;
         $product->indexed = 1;
         $product->save();
         $product_id = $product->id;
         Search::indexation(Tools::link_rewrite($value_prod), $product_id);
         $product->addToCategories(2);
         StockAvailable::updateQuantity($product_id, null, 99999999);
         //image upload for products
         $count = 0;
         $have_cover = false;
         $old_path = _PS_MODULE_DIR_ . $this->name . '/views/img/prod_imgs/' . $img_num . '.png';
         $image_obj = new Image();
         $image_obj->id_product = $product_id;
         $image_obj->position = Image::getHighestPosition($product_id) + 1;
         if ($count == 0) {
             if (!$have_cover) {
                 $image_obj->cover = 1;
             }
         } else {
             $image_obj->cover = 0;
         }
         $image_obj->add();
         $new_path = $image_obj->getPathForCreation();
         $imagesTypes = ImageType::getImagesTypes('products');
         foreach ($imagesTypes as $image_type) {
             ImageManager::resize($old_path, $new_path . '-' . $image_type['name'] . '.jpg', $image_type['width'], $image_type['height']);
         }
         ImageManager::resize($old_path, $new_path . '.jpg');
         for ($k = 1; $k <= 5; $k++) {
             $htl_room_info_obj = new HotelRoomInformation();
             $htl_room_info_obj->id_product = $product_id;
             $htl_room_info_obj->id_hotel = $htl_id;
             $htl_room_info_obj->room_num = 'A' . $i . '-10' . $k;
             $htl_room_info_obj->id_status = 1;
             $htl_room_info_obj->floor = 'first';
             $htl_room_info_obj->save();
         }
         $htl_rm_type = new HotelRoomType();
         $htl_rm_type->id_product = $product_id;
         $htl_rm_type->id_hotel = $htl_id;
         $htl_rm_type->adult = 2;
         $htl_rm_type->children = 2;
         $htl_rm_type->save();
         $img_num++;
         // Add features to the product
         $ftr_arr = array(0 => 8, 1 => 9, 2 => 10, 3 => 11);
         $ftr_val_arr = array(0 => 34, 1 => 35, 2 => 36, 3 => 37);
         foreach ($ftr_arr as $key_htl_ftr => $val_htl_ftr) {
             $product->addFeaturesToDB($val_htl_ftr, $ftr_val_arr[$key_htl_ftr]);
         }
     }
     return true;
 }