Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if ( !defined('_CAN_LOAD_FILES_'))
- exit;
- #doc
- # classname: CustomerProfile
- # scope: PUBLIC
- #
- #/doc
- class CustomerProfile extends Module
- {
- # internal variables
- protected $error = false;
- # Constructor
- function __construct ( )
- {
- $this->name = 'customerprofile';
- $this->tableRef = 'refCoiffeur';
- $this->tab = 'front_office_features';
- $this->version = '1.0';
- $this->author = 'Mathieu Basili';
- parent::__construct();
- $this->displayName = $this->l('Customer Profile');
- $this->description = $this->l('Permet de rajouter des infos au profil utilisateur');
- $this->confirmUninstall = $this->l('Vous �tes certain de vouloir desinstaller ce module?');
- }
- public function install ()
- {
- $query = "CREATE TABLE `" . _DB_PREFIX_ . $this->name . "` (
- `id` INT( 22 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
- `name` VARCHAR( 50 ) NOT NULL ,
- `value` TEXT NULL ,
- `description` TEXT NOT NULL
- ) ENGINE = "._MYSQL_ENGINE_." default CHARSET=utf8";
- $queryRefCoiffeurs = "CREATE TABLE `" . _DB_PREFIX_ . $this->tableRef . "` (
- `id` INT( 22 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
- `name` VARCHAR( 50 ) NOT NULL ,
- `ref` TEXT NULL
- ) ENGINE = "._MYSQL_ENGINE_." default CHARSET=utf8";
- echo $query;
- if(!parent::install() ||
- !Db::getInstance()->Execute($query) ||
- !Db::getInstance()->Execute($queryRefCoiffeurs) ||
- !self::registerHook ('backOfficeHeader'))
- return false;
- else
- return true;
- }
- public function hookBackOfficeHeader($params){
- // Assign hook outputs for own hooks
- global $smarty;
- Tools::addCss($this->_path.'/css/ui.jqgrid.css', 'all');
- Tools::addJS(_PS_MODULE_DIR_ . 'customerprofile/js/jquery.jqGrid.min.js', 'all');
- /*
- Tools::addCSS(_THEME_CSS_DIR_ . 'fx/typography.css', 'all');
- Tools::addCSS(_THEME_CSS_DIR_ . 'fx/print.css', 'print');
- Tools::addCSS(_THEME_CSS_DIR_ . 'global.css', 'all');
- */
- }
- public function uninstall ()
- {
- $query = "DROP TABLE `" . _DB_PREFIX_ . $this->name . "`";
- $queryRefCoiffeurs = "DROP TABLE `" . _DB_PREFIX_ . $this->tableRef . "`";
- if(!parent::uninstall() || !Db::getInstance()->Execute($query) || !Db::getInstance()->Execute($queryRefCoiffeurs))
- return false;
- else
- return true;
- }
- public function getContent ()
- {
- if(Tools::isSubmit('submitRef')){
- $name = Tools::getValue('name');
- if(isset($name) && $name != ''){
- $ref = Tools::getValue('ref');
- if(isset($ref) && $ref!= ''){
- $this->addRef(Tools::getValue('name'), Tools::getValue('ref'));
- $html .= $this->displayConfirmation($this->l('Settings updated.'));
- }
- else $html .= $this->displayError($this->l('Invalid ref.'));
- }
- else
- $html .= $this->displayError($this->l('Invalid name.'));
- }
- $this->_html = "<h2>". $this->displayName ."</h2>";
- $this->_displayList();
- $this->_displayForm();
- return $this->_html;
- }
- public function _displayForm ()
- {
- $this->_html .= '
- <fieldset class="space">
- <legend><img src="'.$this->_path.'logo.gif" >Ajouter une référence</legend>
- <form action="'.$_SERVER['REQUEST_URI'].'" method="post">
- <label>'.$this->l('Name').'</label>
- <div class="margin-form">
- <input type="text" name="name" />
- </div>
- <label>'.$this->l('Ref').'</label>
- <div class="margin-form">
- <input type="text" name="ref" />
- </div>
- <div class="clear center">
- <input class="button" type="submit" name="submitRef" value="'.$this->l(' Add ').'" />
- </div>
- </fieldset>
- </form>
- </fieldset>
- ';
- }
- public function _displayList ()
- {
- //$this->addRef('Hello', '12345675432FDSFFD');
- $this->_html .= '
- <fieldset class="space">
- <legend><img src="'.$this->_path.'logo.gif" >Références</legend>
- <label>A label</label><input type="submit" class="button">
- <table>
- <caption>Tableau des références</caption>
- <colgroup />
- <colgroup span="2" title="title" />
- <thead>
- <tr>
- <th scope="col">ID</th>
- <th scope="col">Name</th>
- <th scope="col">Ref</th>
- </tr>
- </thead>
- <tfoot>
- <tr>
- <td>ID</td>
- <td>Name</td>
- <td>Ref</td>
- </tr>
- </tfoot>
- <tbody>
- ';
- $refs = $this->getRefs();
- foreach ($refs as $ref) {
- $this->_html .= '
- <tr>
- <td>' . $ref['id'] . '</td>
- <td>' . $ref['name'] . '</td>
- <td>' . $ref['ref'] . '</td>
- </tr>
- ';
- }
- $this->_html .= '
- </tbody>
- </table>
- </fieldset>
- ';
- }
- public function getRefs (){
- $results = array();
- if (!$refs = Db::getInstance()->ExecuteS('SELECT `id`, `name`, `ref` FROM ' . _DB_PREFIX_ . $this->tableRef . ((int)(Configuration::get('PS_TABLEREF_ORDERWAY')) == 1 ? ' ORDER BY `id` DESC' : '')))
- return false;
- $i = 0;
- foreach ($refs as $ref) {
- $results[$i]['id'] = $ref['id'];
- $results[$i]['name'] = $ref['name'];
- $results[$i++]['ref'] = $ref['ref'];
- if (!$texts) {
- }
- }
- return $results;
- }
- public function addRef ( $name, $ref ){
- if ( !Db::getInstance()->Execute( 'INSERT INTO ' . _DB_PREFIX_ . $this->tableRef . ' VALUES (\'\', \'' . pSQL($name) . '\', \'' . pSQL($ref) . '\' )'))
- return false;
- }
- public function updateRef ( $id, $name, $ref){
- if ( !Db::getInstance()->Execute( 'UPDATE ' . _DB_PREFIX_ . $this->tableRef . 'SET
- `name` = \'' . pSQL($name) . '\',
- `ref` = \'' . pSQL($name) . '\'
- WHERE `id` = ' . (int)($id)))
- return false;
- }
- public function deleteRef ( $id ){
- if ( !Db::getInstance()->Execute( 'DELETE FROM ' . _DB_PREFIX_ . $this->tableRef .' WHERE `id` = ` ' . (int)($id) . '`' ))
- return false;
- }
- }
- ###
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement