public function postProcess()
 {
     global $currentIndex, $cookie, $smarty;
     $product_ids = Tools::getValue('product_ids');
     $group_id = 0;
     if ($product_ids) {
         $group_id = Tools::getValue('group_id');
         $ids = explode(",", $product_ids);
         //update previous curated products
         $sql = "SELECT group_concat(id_product) FROM vb_product_groups WHERE id_group_type = 1 AND id_group = 1";
         $res = Db::getInstance()->ExecuteS($sql);
         $productIds = array();
         foreach ($res as $row) {
             $productIds[] = $row['id_product'];
         }
         SolrSearch::updateProducts($productIds);
         Db::getInstance(_PS_USE_SQL_SLAVE_)->Execute("\r\n\t\t            delete from vb_product_groups where id_group_type = 1 and id_group = " . $group_id);
         Db::getInstance(_PS_USE_SQL_SLAVE_)->Execute("\r\n\t\t    \t\tdelete from ps_category_product where id_category = " . CAT_CURATED);
         foreach ($ids as $product_id) {
             if (!$product_id) {
                 continue;
             }
             Db::getInstance(_PS_USE_SQL_SLAVE_)->Execute("\n\t\t                insert into vb_product_groups (id_group_type, id_group, id_product)\n\t\t                values (1, " . $group_id . ", " . $product_id . ")\n\t\t                ");
             Db::getInstance(_PS_USE_SQL_SLAVE_)->Execute("\r\n\t\t        \t\tinsert into ps_category_product (id_category, id_product, position)\r\n\t\t        \t\tvalues (" . CAT_CURATED . ", " . $product_id . ", 1)\r\n\t\t        \t\t");
             SolrSearch::updateProduct($product_id);
         }
     }
     //home products
     $product_ids = $this->assign_products('curated_products', 'curated_product_ids', 1);
     $smarty->assign('productToken', Tools::getAdminToken('AdminCatalog' . (int) Tab::getIdFromClassName('AdminCatalog') . (int) $cookie->id_employee));
 }
 public function displaySettings($post_action)
 {
     $curr_order_state = new OrderState((int) $this->mondialrelay->account_shop['MR_ORDER_STATE']);
     $order_state = array('id_order_state' => $this->mondialrelay->account_shop['MR_ORDER_STATE'], 'name' => $curr_order_state->name[$this->context->language->id]);
     $this->context->smarty->assign(array('MR_token_admin_mondialrelay' => Tools::getAdminToken('AdminMondialRelay' . (int) Tab::getIdFromClassName('AdminMondialRelay') . (int) $this->context->employee->id), 'MR_account_set' => MondialRelay::isAccountSet(), 'MR_order_state' => $order_state, 'MR_orders_states_list' => OrderState::getOrderStates($this->context->language->id), 'MR_form_action' => $post_action, 'MR_error_list' => $this->post_errors));
     echo $this->mondialrelay->fetchTemplate('/tpl/admintab/', 'settings');
 }
Beispiel #3
0
 public function uninstall()
 {
     Configuration::deleteByName('POSSEQUENCE');
     // Uninstall Tabs
     //$tab = new Tab((int)Tab::getIdFromClassName('AdminPosMenu'));
     //$tab->delete();
     $tab = new Tab((int) Tab::getIdFromClassName('AdminPossequence'));
     $tab->delete();
     Configuration::deleteByName($this->name . '_pause_time');
     Configuration::deleteByName($this->name . '_animation_speed');
     Configuration::deleteByName($this->name . '_show_arrow');
     Configuration::deleteByName($this->name . '_show_navigation');
     Configuration::deleteByName($this->name . '_auto_slide');
     //uninstall db
     include dirname(__FILE__) . '/sql/uninstall_sql.php';
     foreach ($sql as $s) {
         if (!Db::getInstance()->execute($s)) {
             return false;
         }
     }
     // Uninstall Module
     if (!parent::uninstall()) {
         return false;
     }
     // !$this->unregisterHook('actionObjectExampleDataAddAfter')
     return true;
 }
    public function __construct()
    {
        $this->bootstrap = true;
        $this->table = 'image_type';
        $this->className = 'ImageType';
        $this->lang = false;
        $this->addRowAction('edit');
        $this->addRowAction('delete');
        $this->bulk_actions = array('delete' => array('text' => $this->l('Delete selected'), 'confirm' => $this->l('Delete selected items?'), 'icon' => 'icon-trash'));
        $this->fields_list = array('id_image_type' => array('title' => $this->l('ID'), 'align' => 'center', 'class' => 'fixed-width-xs'), 'name' => array('title' => $this->l('Name')), 'width' => array('title' => $this->l('Width'), 'suffix' => ' px'), 'height' => array('title' => $this->l('Height'), 'suffix' => ' px'), 'products' => array('title' => $this->l('Products'), 'align' => 'center', 'type' => 'bool', 'callback' => 'printEntityActiveIcon', 'orderby' => false), 'categories' => array('title' => $this->l('Categories'), 'align' => 'center', 'type' => 'bool', 'callback' => 'printEntityActiveIcon', 'orderby' => false), 'manufacturers' => array('title' => $this->l('Manufacturers'), 'align' => 'center', 'type' => 'bool', 'callback' => 'printEntityActiveIcon', 'orderby' => false), 'suppliers' => array('title' => $this->l('Suppliers'), 'align' => 'center', 'type' => 'bool', 'callback' => 'printEntityActiveIcon', 'orderby' => false), 'stores' => array('title' => $this->l('Stores'), 'align' => 'center', 'type' => 'bool', 'callback' => 'printEntityActiveIcon', 'orderby' => false));
        // Scenes tab has been removed by default from the installation, but may still exists in updates
        if (Tab::getIdFromClassName('AdminScenes')) {
            $this->fields_list['scenes'] = array('title' => $this->l('Scenes'), 'align' => 'center', 'type' => 'bool', 'callback' => 'printEntityActiveIcon', 'orderby' => false);
        }
        // No need to display the old image system migration tool except if product images are in _PS_PROD_IMG_DIR_
        $this->display_move = false;
        $dir = _PS_PROD_IMG_DIR_;
        if (is_dir($dir)) {
            if ($dh = opendir($dir)) {
                while (($file = readdir($dh)) !== false && $this->display_move == false) {
                    if (!is_dir($dir . DIRECTORY_SEPARATOR . $file) && $file[0] != '.' && is_numeric($file[0])) {
                        $this->display_move = true;
                    }
                }
                closedir($dh);
            }
        }
        $this->fields_options = array('images' => array('title' => $this->l('Images generation options'), 'icon' => 'icon-picture', 'top' => '', 'bottom' => '', 'description' => $this->l('JPEG images have a small file size and standard quality. PNG images have a larger file size, a higher quality and support transparency. Note that in all cases the image files will have the .jpg extension.') . '
					<br /><br />' . $this->l('WARNING: This feature may not be compatible with your theme, or with some of your modules. In particular, PNG mode is not compatible with the Watermark module. If you encounter any issues, turn it off by selecting "Use JPEG".'), 'fields' => array('PS_IMAGE_QUALITY' => array('title' => $this->l('Image format'), 'show' => true, 'required' => true, 'type' => 'radio', 'choices' => array('jpg' => $this->l('Use JPEG.'), 'png' => $this->l('Use PNG only if the base image is in PNG format.'), 'png_all' => $this->l('Use PNG for all images.'))), 'PS_JPEG_QUALITY' => array('title' => $this->l('JPEG compression'), 'hint' => $this->l('Ranges from 0 (worst quality, smallest file) to 100 (best quality, biggest file).') . ' ' . $this->l('Recommended: 90.'), 'validation' => 'isUnsignedId', 'required' => true, 'cast' => 'intval', 'type' => 'text'), 'PS_PNG_QUALITY' => array('title' => $this->l('PNG compression'), 'hint' => $this->l('PNG compression is lossless: unlike JPG, you do not lose image quality with a high compression ratio. However, photographs will compress very badly.') . ' ' . $this->l('Ranges from 0 (biggest file) to 9 (smallest file, slowest decompression).') . ' ' . $this->l('Recommended: 7.'), 'validation' => 'isUnsignedId', 'required' => true, 'cast' => 'intval', 'type' => 'text'), 'PS_IMAGE_GENERATION_METHOD' => array('title' => $this->l('Generate images based on one side of the source image'), 'validation' => 'isUnsignedId', 'required' => false, 'cast' => 'intval', 'type' => 'select', 'list' => array(array('id' => '0', 'name' => $this->l('Automatic (longest side)')), array('id' => '1', 'name' => $this->l('Width')), array('id' => '2', 'name' => $this->l('Height'))), 'identifier' => 'id', 'visibility' => Shop::CONTEXT_ALL), 'PS_PRODUCT_PICTURE_MAX_SIZE' => array('title' => $this->l('Maximum file size of product customization pictures'), 'hint' => $this->l('The maximum file size of pictures that customers can upload to customize a product (in bytes).'), 'validation' => 'isUnsignedInt', 'required' => true, 'cast' => 'intval', 'type' => 'text', 'suffix' => $this->l('bytes'), 'visibility' => Shop::CONTEXT_ALL), 'PS_PRODUCT_PICTURE_WIDTH' => array('title' => $this->l('Product picture width'), 'hint' => $this->l('Width of product customization pictures that customers can upload (in pixels).'), 'validation' => 'isUnsignedInt', 'required' => true, 'cast' => 'intval', 'type' => 'text', 'width' => 'px', 'suffix' => $this->l('pixels'), 'visibility' => Shop::CONTEXT_ALL), 'PS_PRODUCT_PICTURE_HEIGHT' => array('title' => $this->l('Product picture height'), 'hint' => $this->l('Height of product customization pictures that customers can upload (in pixels).'), 'validation' => 'isUnsignedInt', 'required' => true, 'cast' => 'intval', 'type' => 'text', 'height' => 'px', 'suffix' => $this->l('pixels'), 'visibility' => Shop::CONTEXT_ALL), 'PS_HIGHT_DPI' => array('type' => 'bool', 'title' => $this->l('Generate high resolution images'), 'required' => false, 'is_bool' => true, 'hint' => $this->l('This will generate an additional file for each image (thus doubling your total amount of images). Resolution of these images will be twice higher.'), 'desc' => $this->l('Enable to optimize the display of your images on high pixel density screens.'), 'visibility' => Shop::CONTEXT_ALL)), 'submit' => array('title' => $this->l('Save'))));
        if ($this->display_move) {
            $this->fields_options['product_images']['fields']['PS_LEGACY_IMAGES'] = array('title' => $this->l('Use the legacy image filesystem'), 'hint' => $this->l('This should be set to yes unless you successfully moved images in "Images" page under the "Preferences" menu.'), 'validation' => 'isBool', 'cast' => 'intval', 'required' => false, 'type' => 'bool', 'visibility' => Shop::CONTEXT_ALL);
        }
        $this->fields_form = array('legend' => array('title' => $this->l('Image type'), 'icon' => 'icon-picture'), 'input' => array(array('type' => 'text', 'label' => $this->l('Name for the image type'), 'name' => 'name', 'required' => true, 'hint' => $this->l('Letters, underscores and hyphens only (e.g. "small_custom", "cart_medium", "large", "thickbox_extra-large").')), array('type' => 'text', 'label' => $this->l('Width'), 'name' => 'width', 'required' => true, 'maxlength' => 5, 'suffix' => $this->l('pixels'), 'hint' => $this->l('Maximum image width in pixels.')), array('type' => 'text', 'label' => $this->l('Height'), 'name' => 'height', 'required' => true, 'maxlength' => 5, 'suffix' => $this->l('pixels'), 'hint' => $this->l('Maximum image height in pixels.')), array('type' => 'switch', 'label' => $this->l('Products'), 'name' => 'products', 'required' => false, 'is_bool' => true, 'hint' => $this->l('This type will be used for Product images.'), 'values' => array(array('id' => 'products_on', 'value' => 1, 'label' => $this->l('Enabled')), array('id' => 'products_off', 'value' => 0, 'label' => $this->l('Disabled')))), array('type' => 'switch', 'label' => $this->l('Categories'), 'name' => 'categories', 'required' => false, 'class' => 't', 'is_bool' => true, 'hint' => $this->l('This type will be used for Category images.'), 'values' => array(array('id' => 'categories_on', 'value' => 1, 'label' => $this->l('Enabled')), array('id' => 'categories_off', 'value' => 0, 'label' => $this->l('Disabled')))), array('type' => 'switch', 'label' => $this->l('Manufacturers'), 'name' => 'manufacturers', 'required' => false, 'is_bool' => true, 'hint' => $this->l('This type will be used for Manufacturer images.'), 'values' => array(array('id' => 'manufacturers_on', 'value' => 1, 'label' => $this->l('Enabled')), array('id' => 'manufacturers_off', 'value' => 0, 'label' => $this->l('Disabled')))), array('type' => 'switch', 'label' => $this->l('Suppliers'), 'name' => 'suppliers', 'required' => false, 'is_bool' => true, 'hint' => $this->l('This type will be used for Supplier images.'), 'values' => array(array('id' => 'suppliers_on', 'value' => 1, 'label' => $this->l('Enabled')), array('id' => 'suppliers_off', 'value' => 0, 'label' => $this->l('Disabled')))), array('type' => 'switch', 'label' => $this->l('Scenes'), 'name' => 'scenes', 'required' => false, 'class' => 't', 'is_bool' => true, 'hint' => $this->l('This type will be used for Scene images.'), 'values' => array(array('id' => 'scenes_on', 'value' => 1, 'label' => $this->l('Enabled')), array('id' => 'scenes_off', 'value' => 0, 'label' => $this->l('Disabled')))), array('type' => 'switch', 'label' => $this->l('Stores'), 'name' => 'stores', 'required' => false, 'is_bool' => true, 'hint' => $this->l('This type will be used for Store images.'), 'values' => array(array('id' => 'stores_on', 'value' => 1, 'label' => $this->l('Enabled')), array('id' => 'stores_off', 'value' => 0, 'label' => $this->l('Disabled'))))), 'submit' => array('title' => $this->l('Save')));
        parent::__construct();
    }
 public function renderForm()
 {
     $this->fields_form = array('legend' => array('title' => $this->l('Addresses'), 'icon' => 'icon-envelope-alt'), 'input' => array(array('type' => 'text_customer', 'label' => $this->l('Customer'), 'name' => 'id_customer', 'required' => false), array('type' => 'text', 'label' => $this->l('Identification Number'), 'name' => 'dni', 'required' => false, 'col' => '4', 'hint' => $this->l('DNI / NIF / NIE')), array('type' => 'text', 'label' => $this->l('Address alias'), 'name' => 'alias', 'required' => true, 'col' => '4', 'hint' => $this->l('Invalid characters:') . ' &lt;&gt;;=#{}'), array('type' => 'textarea', 'label' => $this->l('Other'), 'name' => 'other', 'required' => false, 'cols' => 15, 'rows' => 3, 'hint' => $this->l('Forbidden characters:') . ' &lt;&gt;;=#{}')), 'submit' => array('title' => $this->l('Save')));
     $id_customer = (int) Tools::getValue('id_customer');
     if (!$id_customer && Validate::isLoadedObject($this->object)) {
         $id_customer = $this->object->id_customer;
     }
     if ($id_customer) {
         $customer = new Customer((int) $id_customer);
         $token_customer = Tools::getAdminToken('AdminCustomers' . (int) Tab::getIdFromClassName('AdminCustomers') . (int) $this->context->employee->id);
     }
     $this->tpl_form_vars = array('customer' => isset($customer) ? $customer : null, 'tokenCustomer' => isset($token_customer) ? $token_customer : null);
     // Order address fields depending on country format
     $addresses_fields = $this->processAddressFormat();
     // we use  delivery address
     $addresses_fields = $addresses_fields['dlv_all_fields'];
     // get required field
     $required_fields = AddressFormat::getFieldsRequired();
     // Merge with field required
     $addresses_fields = array_unique(array_merge($addresses_fields, $required_fields));
     $temp_fields = array();
     foreach ($addresses_fields as $addr_field_item) {
         if ($addr_field_item == 'company') {
             $temp_fields[] = array('type' => 'text', 'label' => $this->l('Company'), 'name' => 'company', 'required' => in_array('company', $required_fields), 'col' => '4', 'hint' => $this->l('Invalid characters:') . ' &lt;&gt;;=#{}');
             $temp_fields[] = array('type' => 'text', 'label' => $this->l('VAT number'), 'col' => '2', 'name' => 'vat_number', 'required' => in_array('vat_number', $required_fields));
         } elseif ($addr_field_item == 'lastname') {
             if (isset($customer) && !Tools::isSubmit('submit' . strtoupper($this->table)) && Validate::isLoadedObject($customer) && !Validate::isLoadedObject($this->object)) {
                 $default_value = $customer->lastname;
             } else {
                 $default_value = '';
             }
             $temp_fields[] = array('type' => 'text', 'label' => $this->l('Last Name'), 'name' => 'lastname', 'required' => true, 'col' => '4', 'hint' => $this->l('Invalid characters:') . ' 0-9!&amp;lt;&amp;gt;,;?=+()@#"�{}_$%:', 'default_value' => $default_value);
         } elseif ($addr_field_item == 'firstname') {
             if (isset($customer) && !Tools::isSubmit('submit' . strtoupper($this->table)) && Validate::isLoadedObject($customer) && !Validate::isLoadedObject($this->object)) {
                 $default_value = $customer->firstname;
             } else {
                 $default_value = '';
             }
             $temp_fields[] = array('type' => 'text', 'label' => $this->l('First Name'), 'name' => 'firstname', 'required' => true, 'col' => '4', 'hint' => $this->l('Invalid characters:') . ' 0-9!&amp;lt;&amp;gt;,;?=+()@#"�{}_$%:', 'default_value' => $default_value);
         } elseif ($addr_field_item == 'address1') {
             $temp_fields[] = array('type' => 'text', 'label' => $this->l('Address'), 'name' => 'address1', 'col' => '6', 'required' => true);
         } elseif ($addr_field_item == 'address2') {
             $temp_fields[] = array('type' => 'text', 'label' => $this->l('Address') . ' (2)', 'name' => 'address2', 'col' => '6', 'required' => in_array('address2', $required_fields));
         } elseif ($addr_field_item == 'postcode') {
             $temp_fields[] = array('type' => 'text', 'label' => $this->l('Zip/Postal Code'), 'name' => 'postcode', 'col' => '2', 'required' => true);
         } elseif ($addr_field_item == 'city') {
             $temp_fields[] = array('type' => 'text', 'label' => $this->l('City'), 'name' => 'city', 'col' => '4', 'required' => true);
         } elseif ($addr_field_item == 'country' || $addr_field_item == 'Country:name') {
             $temp_fields[] = array('type' => 'select', 'label' => $this->l('Country'), 'name' => 'id_country', 'required' => in_array('Country:name', $required_fields) || in_array('country', $required_fields), 'col' => '4', 'default_value' => (int) $this->context->country->id, 'options' => array('query' => Country::getCountries($this->context->language->id), 'id' => 'id_country', 'name' => 'name'));
             $temp_fields[] = array('type' => 'select', 'label' => $this->l('State'), 'name' => 'id_state', 'required' => false, 'col' => '4', 'options' => array('query' => array(), 'id' => 'id_state', 'name' => 'name'));
         } elseif ($addr_field_item == 'phone') {
             $temp_fields[] = array('type' => 'text', 'label' => $this->l('Home phone'), 'name' => 'phone', 'required' => in_array('phone', $required_fields) || Configuration::get('PS_ONE_PHONE_AT_LEAST'), 'col' => '4', 'hint' => Configuration::get('PS_ONE_PHONE_AT_LEAST') ? sprintf($this->l('You must register at least one phone number.')) : '');
         } elseif ($addr_field_item == 'phone_mobile') {
             $temp_fields[] = array('type' => 'text', 'label' => $this->l('Mobile phone'), 'name' => 'phone_mobile', 'required' => in_array('phone_mobile', $required_fields) || Configuration::get('PS_ONE_PHONE_AT_LEAST'), 'col' => '4', 'hint' => Configuration::get('PS_ONE_PHONE_AT_LEAST') ? sprintf($this->l('You must register at least one phone number.')) : '');
         }
     }
     // merge address format with the rest of the form
     array_splice($this->fields_form['input'], 3, 0, $temp_fields);
     return parent::renderForm();
 }
 public function renderForm()
 {
     if (!($obj = $this->loadObject(true))) {
         return;
     }
     $post = new BlogPost($obj->id_blog_post);
     $obj->post_title = $post->title;
     if (!is_null($obj->id_customer) && !empty($obj->id_customer)) {
         $tokenCustomer = Tools::getAdminToken('AdminCustomers' . (int) Tab::getIdFromClassName('AdminCustomers') . (int) $this->context->employee->id);
         $linkCustomer = '?tab=AdminCustomers&id_customer=' . $obj->id_customer . '&viewcustomer&token=' . $tokenCustomer;
         $obj->customer_name_label = '<a href="' . $linkCustomer . '"><strong>' . $obj->customer_name . '</strong></a>';
     } else {
         $obj->customer_name_label = $obj->customer_name;
     }
     $iso = $this->context->language->getIsoById($obj->id_lang);
     $obj->iso_code = $iso ? $iso : '&nbsp;';
     $shop = $this->context->shop->getShop($obj->id_shop);
     $obj->shop_name = $shop ? $shop['name'] : '&nbsp;';
     $this->fields_form = array('legend' => array('title' => '<img src="../img/admin/comment.gif"> ' . $this->l('Comment')), 'submit' => array('title' => $this->l('Save'), 'class' => 'button'));
     $this->fields_form['input'][] = array('type' => 'text_label', 'label' => $this->l('Date :'), 'name' => 'date_add');
     $this->fields_form['input'][] = array('type' => 'text_label', 'label' => $this->l('Post title :'), 'name' => 'post_title');
     $this->fields_form['input'][] = array('type' => 'text_label', 'label' => $this->l('Customer :'), 'name' => 'customer_name_label');
     $this->fields_form['input'][] = array('type' => 'text_label', 'label' => $this->l('Shop :'), 'name' => 'shop_name');
     $this->fields_form['input'][] = array('type' => 'text_label', 'label' => $this->l('Lang :'), 'name' => 'iso_code');
     $this->fields_form['input'][] = array('type' => 'hidden', 'name' => 'customer_name');
     $this->fields_form['input'][] = array('type' => 'hidden', 'name' => 'id_blog_post');
     $this->fields_form['input'][] = array('type' => 'textarea', 'label' => $this->l('Message :'), 'rows' => 4, 'cols' => 92, 'id' => 'comment_content', 'name' => 'content');
     $this->fields_form['input'][] = array('type' => 'radio', 'label' => $this->l('Active :'), 'name' => 'active', 'required' => false, 'class' => 't', 'is_bool' => true, 'values' => array(array('id' => 'active_on', 'value' => 1, 'label' => $this->l('Enabled')), array('id' => 'active_off', 'value' => 0, 'label' => $this->l('Disabled'))));
     $this->tpl_form_vars = array('comment' => $obj);
     return parent::renderForm();
 }
Beispiel #7
0
 public function __construct()
 {
     global $cookie;
     parent::__construct();
     $this->is_seller = $cookie->profile == (int) Configuration::get('AGILE_MS_PROFILE_ID');
     Shop::$id_shop_owner = $this->is_seller ? $cookie->id_employee : 0;
     if (Module::isInstalled('agilemultipleseller') and !isset($_GET['logout']) and $this->is_seller and (Tools::getValue("controller") == "" or Tools::getValue("controller") == "adminhome")) {
         $tid = Tab::getIdFromClassName('AdminProducts');
         $token = Tools::getAdminToken('AdminProducts' . intval($tid) . intval($cookie->id_employee));
         Tools::redirectAdmin("./index.php?controller=AdminProducts&token=" . $token);
     }
     if (Module::isInstalled('agilesellerlistoptions')) {
         require_once _PS_ROOT_DIR_ . '/modules/agilesellerlistoptions/agilesellerlistoptions.php';
         $aslo_module = new AgileSellerListOptions();
         $msg = $aslo_module->hookAgileAdminTop(null);
         if (!empty($msg)) {
             $this->displayWarning($msg);
         }
     }
     $tab = Tab::getInstanceFromClassName('AdminShopGroup');
     if (Module::isInstalled('agilemultipleshop')) {
         $tab->active = 1;
     } else {
         $tab->active = 0;
     }
     $tab->update();
 }
Beispiel #8
0
 public function postProcess()
 {
     global $currentIndex, $cookie, $smarty;
     if (Tools::getValue('getReferrerData')) {
         $id_referrer = Tools::getValue('referrer');
         $res = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS("\n\t\t            select o.id_order, concat(c.firstname, ' ', c.lastname) as 'name', concat(a.`address1`, a.`address2`) as 'address', a.`phone_mobile`, o.`total_paid`, date(c.date_add) as 'date_register'\n                    from ps_orders o \n                    inner join ps_customer c on o.id_customer = c.id_customer\n                    inner join ps_address a on a.`id_address` = o.`id_address_delivery`\n                    where o.id_customer in (select id_customer from ps_customer where id_referrer = " . $id_referrer . ")\n\t\t            ");
         $smarty->assign('referredOrders', $res);
         $res = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS("\n\t\t            select id_customer, concat(firstname, ' ', lastname) as 'name', date(date_add) as 'date_add' from ps_customer where id_referrer = " . $id_referrer);
         $smarty->assign('referredCustomers', $res);
         $res = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS("\r\n\t\t            select concat(c.firstname, ' ', c.lastname) as 'name', count(*) as 'total_orders', sum(o.total_paid) as 'total_paid' from ps_orders o \n                    inner join `ps_order_history` oh on oh.id_order = o.id_order\n                    inner join ps_customer c on c.id_customer = o.id_customer\n                    where o.id_customer = " . $id_referrer . "\n                    and oh.id_order_history = (select max(id_order_history) from ps_order_history where id_order = o.id_order)\n                    and oh.id_order_state not in (6, 14, 20)\n\t\t            ");
         $smarty->assign('referrer_details', $res[0]);
         $smarty->assign('orderToken', Tools::getAdminToken('AdminOrders' . (int) Tab::getIdFromClassName('AdminOrders') . (int) $cookie->id_employee));
     }
     $date_from = Tools::getValue('date_from', date('Y-n-j'));
     $date_to = Tools::getValue('date_to', date('Y-n-j'));
     $res = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS("\n\t\t        select c.id_customer `customerID`, concat(c.firstname, ' ', c.lastname) as `name`, \n                count(distinct(c2.id_customer)) as 'total_registered',\n                count(o.id_order) as 'total_orders',\n                count(distinct(o.id_customer)) as 'total_friends_orders',\n                round(coalesce(avg(o.total_paid), 0)) as 'avg_order'\n                from ps_customer c\n                inner join ps_customer c2 on c.id_customer = c2.id_referrer\n                left join ps_orders o on o.id_customer = c2.id_customer\n\t\t        inner join `ps_order_history` oh on oh.id_order = o.id_order\n                where date(c2.`date_add`) between '" . $date_from . "' and '" . $date_to . "'\n\t\t        and  oh.id_order_history = (SELECT MAX(`id_order_history`) FROM `ps_order_history` moh WHERE moh.`id_order` = o.`id_order` GROUP BY moh.`id_order`)\n\t\t\t\tand oh.id_order_state not in (6,8,20)\n                group by c.id_customer  \n\t\t        ");
     $friends_shopped = array();
     $avg_order = array();
     foreach ($res as $key => $row) {
         $friends_shopped[$key] = $row['total_friends_orders'];
         $avg_order[$key] = $row['avg_order'];
     }
     array_multisort($friends_shopped, SORT_DESC, $avg_order, SORT_ASC, $res);
     $smarty->assign('date_from', $date_from);
     $smarty->assign('date_to', $date_to);
     $smarty->assign('referrals', $res);
     $smarty->assign('token', $this->token);
     $smarty->assign('customerToken', Tools::getAdminToken('AdminCustomers' . (int) Tab::getIdFromClassName('AdminCustomers') . (int) $cookie->id_employee));
 }
 /**
  * AdminController::renderForm() override
  * @see AdminController::renderForm()
  */
 public function renderForm()
 {
     $current_profile = (int) $this->getCurrentProfileId();
     $profiles = Profile::getProfiles($this->context->language->id);
     $tabs = Tab::getTabs($this->context->language->id);
     $accesses = array();
     foreach ($profiles as $profile) {
         $accesses[$profile['id_profile']] = Profile::getProfileAccesses($profile['id_profile']);
     }
     // Deleted id_tab that do not have access
     foreach ($tabs as $key => $tab) {
         // Don't allow permissions for unnamed tabs (ie. AdminLogin)
         if (empty($tab['name'])) {
             unset($tabs[$key]);
         }
         foreach ($this->accesses_black_list as $id_tab) {
             if ($tab['id_tab'] == (int) $id_tab) {
                 unset($tabs[$key]);
             }
         }
     }
     $modules = array();
     foreach ($profiles as $profile) {
         $modules[$profile['id_profile']] = Module::getModulesAccessesByIdProfile($profile['id_profile']);
         uasort($modules[$profile['id_profile']], array($this, 'sortModuleByName'));
     }
     $this->fields_form = array('');
     $this->tpl_form_vars = array('profiles' => $profiles, 'accesses' => $accesses, 'id_tab_parentmodule' => (int) Tab::getIdFromClassName('AdminParentModules'), 'id_tab_module' => (int) Tab::getIdFromClassName('AdminModules'), 'tabs' => $this->displayTabs($tabs), 'current_profile' => (int) $current_profile, 'admin_profile' => (int) _PS_ADMIN_PROFILE_, 'access_edit' => $this->access('edit'), 'perms' => array('view', 'add', 'edit', 'delete'), 'modules' => $modules, 'link' => $this->context->link);
     return parent::renderForm();
 }
 public function uninstall()
 {
     Configuration::deleteByName('poslogo');
     // Uninstall Tabs
     $tab = new Tab((int) Tab::getIdFromClassName('AdminPosLogo'));
     $tab->delete();
     Configuration::deleteByName($this->name . '_auto');
     Configuration::deleteByName($this->name . '_speed_slide');
     Configuration::deleteByName($this->name . '_a_speed');
     // Configuration::deleteByName($this->name . '_show_price');
     //Configuration::deleteByName($this->name . '_show_des');
     Configuration::deleteByName($this->name . '_qty_products');
     Configuration::deleteByName($this->name . '_qty_items');
     Configuration::deleteByName($this->name . '_width_item');
     Configuration::deleteByName($this->name . '_show_nextback');
     Configuration::deleteByName($this->name . '_show_control');
     Configuration::deleteByName($this->name . '_min_item');
     Configuration::deleteByName($this->name . '_max_item');
     Configuration::deleteByName($this->name . '_mode_dir');
     include dirname(__FILE__) . '/sql/uninstall_sql.php';
     foreach ($sql as $s) {
         if (!Db::getInstance()->execute($s)) {
             return false;
         }
     }
     // Uninstall Module
     if (!parent::uninstall()) {
         return false;
     }
     // !$this->unregisterHook('actionObjectExampleDataAddAfter')
     return true;
 }
 public function uninstall ()
 {
     $tab = new Tab(Tab::getIdFromClassName('AdminNewsletter'));
     return parent::uninstall()
             && $tab->delete()
             && Configuration::deleteByName('NSletter_id_parent_tab');;
 }
Beispiel #12
0
function upgrade_module_1_0_3($object)
{
    $sql = array();
    $sql[] = 'CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'simpleblog_tag` (
            `id_simpleblog_tag` INT( 11 ) UNSIGNED NOT NULL AUTO_INCREMENT,
            `id_lang` INT( 11 ) unsigned NOT NULL,
            `name` VARCHAR(60) NOT NULL,
            PRIMARY KEY (`id_simpleblog_tag`)
        ) ENGINE = ' . _MYSQL_ENGINE_ . ' DEFAULT CHARSET=utf8';
    $sql[] = 'CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'simpleblog_post_tag` (
            `id_simpleblog_post` INT( 11 ) unsigned NOT NULL,
            `id_simpleblog_tag` INT( 11 ) unsigned NOT NULL,
            PRIMARY KEY (`id_simpleblog_tag`)
        ) ENGINE = ' . _MYSQL_ENGINE_ . ' DEFAULT CHARSET=utf8';
    foreach ($sql as $s) {
        if (!Db::getInstance()->Execute($s)) {
            return false;
        }
    }
    $context = Context::getContext();
    $tab = new Tab();
    $tab->name[$context->language->id] = $object->l('Tags');
    $tab->class_name = 'AdminSimpleBlogTags';
    $tab->id_parent = Tab::getIdFromClassName('AdminSimpleBlog');
    $tab->module = $object->name;
    $tab->add();
    return true;
}
 /**
  * Initialize cms controller
  * @see FrontController::init()
  */
 public function init()
 {
     if ($id_cms = (int) Tools::getValue('id_cms')) {
         $this->cms = new CMS($id_cms, $this->context->language->id);
     } elseif ($id_cms_category = (int) Tools::getValue('id_cms_category')) {
         $this->cms_category = new CMSCategory($id_cms_category, $this->context->language->id);
     }
     if (Configuration::get('PS_SSL_ENABLED') && Tools::getValue('content_only') && Tools::getValue('id_cms') == (int) Configuration::get('PS_CONDITIONS_CMS_ID') && Validate::isLoadedObject($this->cms)) {
         $this->ssl = true;
     }
     parent::init();
     $this->canonicalRedirection();
     // assignCase (1 = CMS page, 2 = CMS category)
     if (Validate::isLoadedObject($this->cms)) {
         $adtoken = Tools::getAdminToken('AdminCmsContent' . (int) Tab::getIdFromClassName('AdminCmsContent') . (int) Tools::getValue('id_employee'));
         if (!$this->cms->isAssociatedToShop() || !$this->cms->active && Tools::getValue('adtoken') != $adtoken) {
             header('HTTP/1.1 404 Not Found');
             header('Status: 404 Not Found');
         } else {
             $this->assignCase = 1;
         }
     } elseif (Validate::isLoadedObject($this->cms_category)) {
         $this->assignCase = 2;
     } else {
         header('HTTP/1.1 404 Not Found');
         header('Status: 404 Not Found');
     }
 }
    public function viewsupplier()
    {
        global $cookie;
        $supplier = $this->loadObject();
        echo '<h2>' . $supplier->name . '</h2>';
        $products = $supplier->getProductsLite(intval($cookie->id_lang));
        echo '<h3>' . $this->l('Total products:') . ' ' . sizeof($products) . '</h3>';
        foreach ($products as $product) {
            $product = new Product($product['id_product'], false, intval($cookie->id_lang));
            echo '<hr />';
            if (!$product->hasAttributes()) {
                echo '
				<table border="0" cellpadding="0" cellspacing="0" class="table width3">
					<tr>
						<th><a href="index.php?tab=AdminCatalog&id_product=' . $product->id . '&addproduct&token=' . Tools::getAdminToken('AdminCatalog' . intval(Tab::getIdFromClassName('AdminCatalog')) . intval($cookie->id_employee)) . '" target="_blank">' . $product->name . '</a></th>
						' . (!empty($product->reference) ? '<th width="150">' . $this->l('Ref:') . ' ' . $product->reference . '</th>' : '') . '
						' . (!empty($product->ean13) ? '<th width="120">' . $this->l('EAN13:') . ' ' . $product->ean13 . '</th>' : '') . '
						' . (Configuration::get('PS_STOCK_MANAGEMENT') ? '<th class="right" width="50">' . $this->l('Qty:') . ' ' . $product->quantity . '</th>' : '') . '
					</tr>
				</table>';
            } else {
                echo '
				<h3><a href="index.php?tab=AdminCatalog&id_product=' . $product->id . '&addproduct&token=' . Tools::getAdminToken('AdminCatalog' . intval(Tab::getIdFromClassName('AdminCatalog')) . intval($cookie->id_employee)) . '" target="_blank">' . $product->name . '</a></h3>
				<table border="0" cellpadding="0" cellspacing="0" class="table" style="width: 600px;">
	                	<tr>
		                    <th>' . $this->l('Attribute name') . '</th>
		                    <th width="80">' . $this->l('Reference') . '</th>
		                    <th width="80">' . $this->l('EAN13') . '</th>
		                   ' . (Configuration::get('PS_STOCK_MANAGEMENT') ? '<th class="right" width="40">' . $this->l('Quantity') . '</th>' : '') . '
	                	</tr>';
                /* Build attributes combinaisons */
                $combinaisons = $product->getAttributeCombinaisons(intval($cookie->id_lang));
                foreach ($combinaisons as $k => $combinaison) {
                    $combArray[$combinaison['id_product_attribute']]['reference'] = $combinaison['reference'];
                    $combArray[$combinaison['id_product_attribute']]['ean13'] = $combinaison['ean13'];
                    $combArray[$combinaison['id_product_attribute']]['quantity'] = $combinaison['quantity'];
                    $combArray[$combinaison['id_product_attribute']]['attributes'][] = array($combinaison['group_name'], $combinaison['attribute_name'], $combinaison['id_attribute']);
                }
                $irow = 0;
                foreach ($combArray as $id_product_attribute => $product_attribute) {
                    $list = '';
                    foreach ($product_attribute['attributes'] as $attribute) {
                        $list .= $attribute[0] . ' - ' . $attribute[1] . ', ';
                    }
                    $list = rtrim($list, ', ');
                    echo '
					<tr' . ($irow++ % 2 ? ' class="alt_row"' : '') . ' >
						<td>' . stripslashes($list) . '</td>
						<td>' . $product_attribute['reference'] . '</td>
						' . (Configuration::get('PS_STOCK_MANAGEMENT') ? '<td>' . $product_attribute['ean13'] . '</td>' : '') . '
						<td class="right">' . $product_attribute['quantity'] . '</td>
					</tr>';
                }
                unset($combArray);
                echo '</table>';
                echo '</td></tr></table>';
            }
        }
    }
Beispiel #15
0
 public function uninstallAdminTab($class_name)
 {
     $id_tab = (int) Tab::getIdFromClassName($class_name);
     if ($id_tab) {
         $tab = new Tab($id_tab);
         return $tab->delete();
     }
     return false;
 }
Beispiel #16
0
 public function uninstall()
 {
     $id_tab = (int) Tab::getIdFromClassName('AdminDashgoals');
     if ($id_tab) {
         $tab = new Tab($id_tab);
         $tab->delete();
     }
     return parent::uninstall();
 }
 public function initProcess()
 {
     parent::initProcess();
     $access = Profile::getProfileAccess($this->context->employee->id_profile, (int) Tab::getIdFromClassName('AdminOrders'));
     if ($access['view'] === '1' && ($action = Tools::getValue('submitAction'))) {
         $this->action = $action;
     } else {
         $this->errors[] = Tools::displayError('You do not have permission to view this.');
     }
 }
 public function initBreadcrumbs($tab_id = null, $tabs = null)
 {
     if (Tools::getValue('id_carrier')) {
         $this->display = 'edit';
     } else {
         $this->display = 'add';
     }
     parent::initBreadcrumbs((int) Tab::getIdFromClassName('AdminCarriers'));
     $this->display = 'view';
 }
 public function checkToken()
 {
     global $cookie;
     if ($parentCheck = parent::checkToken()) {
         return $parentCheck;
     } else {
         $token = Tools::getValue('token');
         return !empty($token) and $token === Tools::getAdminToken('AdminCatalog' . (int) Tab::getIdFromClassName('AdminCatalog') . (int) $cookie->id_employee);
     }
 }
Beispiel #20
0
 public function display()
 {
     global $cookie;
     if (isset($_GET['view' . $this->table])) {
         Tools::redirectAdmin('index.php?tab=AdminOrders&id_order=' . intval($_GET['id_order']) . '&vieworder' . '&token=' . Tools::getAdminToken('AdminOrders' . intval(Tab::getIdFromClassName('AdminOrders')) . intval($cookie->id_employee)));
     } else {
         $this->displayList();
         $this->displayOptionsList();
     }
 }
 public function uninstall()
 {
     include dirname(__FILE__) . '/sql/uninstall.php';
     Configuration::deleteByName('BANDEAUPROMO_LIVE_MODE');
     $tab = new Tab(Tab::getIdFromClassName('AdminBandeauxPromo'));
     if (Validate::isLoadedObject($tab)) {
         $tab->delete();
     }
     return parent::uninstall();
 }
Beispiel #22
0
 private function uninstallModuleTab($tabClass)
 {
     $idTab = Tab::getIdFromClassName($tabClass);
     if ($idTab != 0) {
         $tab = new Tab($idTab);
         $tab->delete();
         return true;
     }
     return false;
 }
Beispiel #23
0
 public function uninstallTab()
 {
     $id_tab = (int) Tab::getIdFromClassName('AdminOnboarding');
     if ($id_tab) {
         $tab = new Tab($id_tab);
         return $tab->delete();
     } else {
         return false;
     }
 }
Beispiel #24
0
    public function hookAdminStatsModules($params)
    {
        global $cookie;
        $customers = $this->getCustomersOnline();
        $totalCustomers = Db::getInstance()->NumRows();
        $visitors = $this->getVisitorsOnline();
        $totalVisitors = Db::getInstance()->NumRows();
        $irow = 0;
        echo '<script type="text/javascript" language="javascript">openCloseLayer(\'calendar\');</script>
		<fieldset class="width3"><legend><img src="../modules/' . $this->name . '/logo.gif" /> ' . $this->l('Customers online') . '</legend>';
        if ($totalCustomers) {
            echo $this->l('Total:') . ' ' . intval($totalCustomers) . '
			<table cellpadding="0" cellspacing="0" class="table space">
				<tr><th>' . $this->l('ID') . '</th><th>' . $this->l('Name') . '</th><th>' . $this->l('Current Page') . '</th><th>' . $this->l('View') . '</th></tr>';
            foreach ($customers as $customer) {
                echo '
				<tr' . ($irow++ % 2 ? ' class="alt_row"' : '') . '>
					<td>' . $customer['id_customer'] . '</td>
					<td style="width: 200px;">' . $customer['firstname'] . ' ' . $customer['lastname'] . '</td>
					<td style="width: 200px;">' . $customer['page'] . '</td>
					<td style="text-align: right; width: 25px;">
						<a href="index.php?tab=AdminCustomers&id_customer=' . $customer['id_customer'] . '&viewcustomer&token=' . Tools::getAdminToken('AdminCustomers' . intval(Tab::getIdFromClassName('AdminCustomers')) . intval($cookie->id_employee)) . '" target="_blank">
							<img src="../modules/' . $this->name . '/logo.gif" />
						</a>
					</td>
				</tr>';
            }
            echo '</table>';
        } else {
            echo $this->l('There is no customer online now.');
        }
        echo '</fieldset>
		<fieldset class="width3 space"><legend><img src="../modules/' . $this->name . '/logo.gif" /> ' . $this->l('Visitors online') . '</legend>';
        if ($totalVisitors) {
            echo $this->l('Total:') . ' ' . intval($totalVisitors) . '
			<div style="overflow-y: scroll; height: 600px;">
			<table cellpadding="0" cellspacing="0" class="table space">
				<tr><th>' . $this->l('Guest') . '</th><th>' . $this->l('IP') . '</th><th>' . $this->l('Since') . '</th><th>' . $this->l('Current page') . '</th><th>' . $this->l('Referrer') . '</th></tr>';
            foreach ($visitors as $visitor) {
                echo '
					<tr' . ($irow++ % 2 ? ' class="alt_row"' : '') . '>
						<td>' . $visitor['id_guest'] . '</td>
						<td style="width: 80px;">' . long2ip($visitor['ip_address']) . '</td>
						<td style="width: 100px;">' . substr($visitor['date_add'], 11) . '</td>
						<td style="width: 200px;">' . $visitor['page'] . '</td>
						<td style="width: 200px;">' . (empty($visitor['http_referer']) ? $this->l('none') : parse_url($visitor['http_referer'], PHP_URL_HOST)) . '</td>
					</tr>';
            }
            echo '</table>
			</div>';
        } else {
            echo $this->l('There is no visitor online now.');
        }
        echo '</fieldset>';
    }
 /**
  * @inheritdoc
  */
 public function initContent()
 {
     if (!$this->viewAccess()) {
         $this->errors[] = Tools::displayError('You do not have permission to view this.');
         return;
     }
     $id_tab = (int) Tab::getIdFromClassName('AdminModules');
     $id_employee = (int) $this->context->cookie->id_employee;
     $token = Tools::getAdminToken('AdminModules' . $id_tab . $id_employee);
     Tools::redirectAdmin('index.php?controller=AdminModules&configure=nostotagging&token=' . $token);
 }
Beispiel #26
0
 public function initProcess()
 {
     parent::initProcess();
     $this->checkCacheFolder();
     $access = Profile::getProfileAccess($this->context->employee->id_profile, (int) Tab::getIdFromClassName('AdminOrders'));
     if ($access['view'] === '1' && ($action = Tools::getValue('submitAction'))) {
         $this->action = $action;
     } else {
         $this->errors[] = $this->trans('You do not have permission to view this.', array(), 'Admin.Notifications.Error');
     }
 }
 public function __construct()
 {
     $this->table = 'access';
     $this->className = 'Profile';
     $this->multishop_context = Shop::CONTEXT_ALL;
     $this->lang = false;
     $this->context = Context::getContext();
     // Blacklist AdminLogin
     $this->accesses_black_list[] = Tab::getIdFromClassName('AdminLogin');
     parent::__construct();
 }
 public function uninstall()
 {
     // Database Table
     include dirname(__FILE__) . '/sql/uninstall.php';
     // Module Tab
     if ($id_tab = (int) Tab::getIdFromClassName('AdminAutozip')) {
         $tab = new Tab($id_tab);
         $tab->delete();
     }
     return parent::uninstall();
 }
Beispiel #29
0
 public function uninstall()
 {
     $id_tab = (int) Tab::getIdFromClassName('AdminBlockCategories');
     if ($id_tab) {
         $tab = new Tab($id_tab);
         $tab->delete();
     }
     if (!parent::uninstall() || !Configuration::deleteByName('BLOCK_CATEG_MAX_DEPTH') || !Configuration::deleteByName('BLOCK_CATEG_DHTML') || !Configuration::deleteByName('BLOCK_CATEG_ROOT_CATEGORY')) {
         return false;
     }
     return true;
 }
Beispiel #30
0
function upgrade_module_1_0_3($object)
{
    $idTabs = array();
    $idTabs[] = Tab::getIdFromClassName('AdminSimpleBlogRelatedPosts');
    foreach ($idTabs as $idTab) {
        if ($idTab) {
            $tab = new Tab($idTab);
            $tab->delete();
        }
    }
    return true;
}