JoelWebsites Posted June 17, 2014 Share Posted June 17, 2014 Hi I wanna edit a page (my preferences) it shows index.php?controller=AdminEmployees&token=f698c48265a9b293866cd004a48e1a0f&id_employee=1&updateemployee url in the browser I want to add more content to this and get some information from the database tables to be displayed on the webpage AdminEmployeesController.php Please help me edit and add new content to this page. Link to comment Share on other sites More sharing options...
JoelWebsites Posted June 17, 2014 Author Share Posted June 17, 2014 I am finding it very difficult to edit this page Link to comment Share on other sites More sharing options...
vekia Posted June 17, 2014 Share Posted June 17, 2014 hello what you exactly want to add there? i this case it's necessary to modify controller, but everything depends on what you exactly want to add there 1 Link to comment Share on other sites More sharing options...
JoelWebsites Posted June 17, 2014 Author Share Posted June 17, 2014 Actually I want to add some more details ...In this case I want to add more details to the about the super admin..I have made new colums having reminder details in rows in my mysql database for this super admin..I just want to display this Link to comment Share on other sites More sharing options...
vekia Posted June 17, 2014 Share Posted June 17, 2014 as log as you will not say something more what kind of options you want to add (type like: bool (yes/no) simple input text etc.) it will be a little hard to help. you have to extend this array: $this->fields_form add there your new db fields, like other fields. for example: array( 'type' => 'text', 'class' => 'fixed-width-xl', 'label' => $this->l('My New Field'), 'name' => 'newfield', 'required' => true ), 1 Link to comment Share on other sites More sharing options...
JoelWebsites Posted June 20, 2014 Author Share Posted June 20, 2014 I have now created a module named mymodule' that is displaying some text that is placed in the mymodule.tpl file. I want to display some values of an employee.from my ps_employee table in mySQL.It have colum names name date of joining,end date ,phone no and so on..I want to to display these details...I appreciate your help btw. Link to comment Share on other sites More sharing options...
JoelWebsites Posted June 20, 2014 Author Share Posted June 20, 2014 I tried writing php code on tpl file bt it did not help Link to comment Share on other sites More sharing options...
JoelWebsites Posted June 20, 2014 Author Share Posted June 20, 2014 (edited) I am finding this confusing where should the table name or colum name be mentioned hus fields values are needed? Edited June 20, 2014 by joeljfernandes (see edit history) Link to comment Share on other sites More sharing options...
vekia Posted June 20, 2014 Share Posted June 20, 2014 hello you have to add this code in file that you attached in section $this->field_form Link to comment Share on other sites More sharing options...
JoelWebsites Posted June 21, 2014 Author Share Posted June 21, 2014 Thanks for your help...But I would really appreciate if you could help me with an example Link to comment Share on other sites More sharing options...
vekia Posted June 22, 2014 Share Posted June 22, 2014 in AdminEmployeesController.php you've got: $this->fields_form = array( 'legend' => array( 'title' => $this->l('Employees'), 'icon' => 'icon-user' ), 'input' => array( array( 'type' => 'text', 'class' => 'fixed-width-xl', 'label' => $this->l('First Name'), 'name' => 'firstname', 'required' => true ), in this array, you can define new fields, in that wat: array( 'type' => 'text', 'class' => 'fixed-width-xl', 'label' => $this->l('New variable'), 'name' => 'newvariable', 'required' => true ), so code with new fileld: $this->fields_form = array( 'legend' => array( 'title' => $this->l('Employees'), 'icon' => 'icon-user' ), 'input' => array( array( 'type' => 'text', 'class' => 'fixed-width-xl', 'label' => $this->l('First Name'), 'name' => 'firstname', 'required' => true ), array( 'type' => 'text', 'class' => 'fixed-width-xl', 'label' => $this->l('New variable'), 'name' => 'newvariable', 'required' => true ), 1 Link to comment Share on other sites More sharing options...
JoelWebsites Posted June 23, 2014 Author Share Posted June 23, 2014 and how should one save the values from the database to these defined variables. I am trying to create a module below is the code for mymodule.php <?php if (!defined('_PS_VERSION_')) exit; class MyModule extends Module { public function __construct() { $this->name = 'mymodule'; $this->tab = ''; $this->version = '1.2'; $this->author = 'Joel Fernandes'; $this->need_instance = 0; $this->push_filename = _PS_CACHE_DIR_.'push/activity'; $this->allow_push = true; $this->push_time_limit = 180; parent::__construct(); $this->displayName = $this->l('My module'); $this->description = $this->l('This is a mymodule '); $this->confirmUninstall = $this->l('Are you sure you want to uninstall?'); if (!Configuration::get('MYMODULE_NAME')) $this->warning = $this->l('No name provided'); } // this also works, and is more future-proof public function install() { if (!parent::install() || !$this->registerHook('dashboardZoneTwo') || !$this->registerHook('dashboardData')) return false; return true; } public function uninstall() { if (!parent::uninstall()) Db::getInstance()->Execute('DELETE FROM `'._DB_PREFIX_.'mymodule`'); parent::uninstall(); } public function hookDashboardZoneTwo($params) { echo $this->name = 'mymodule'; return $this->display(__FILE__,'mymodule.tpl'); } } ?> Link to comment Share on other sites More sharing options...
JoelWebsites Posted June 23, 2014 Author Share Posted June 23, 2014 I want details from a table named ps_employee and I also cannot how to display returned values in the .tpl file Link to comment Share on other sites More sharing options...
JoelWebsites Posted June 23, 2014 Author Share Posted June 23, 2014 I want to know how to send the retrieved data (returned sql rows) into the assigned values into the tpl file(mymodule.tpl) Link to comment Share on other sites More sharing options...
vekia Posted June 23, 2014 Share Posted June 23, 2014 im confused a little you asked about controller modification, now you're asking about sql queries to save these datase from your module. so, where you want to manage these datas? in controller, or in module? if you modify controller, datas will be stored automatically in database. Link to comment Share on other sites More sharing options...
JoelWebsites Posted June 23, 2014 Author Share Posted June 23, 2014 I appreciate your patience..and appreciate your attention..Let me explain...I was trying to create a module in the start...Bt I was finding it really difficult to create a module so I had taught to try modifying the controller..but then I had a tough time locating the controller as well...Now since I was successfully able to create a module ( the dashboard module is installed and the hook is registered and is working the hook name is hookDashboardZoneTwo as mentioned in the above mymodule code.)The tpl file is being displayed on the dashboard page.I need code to retrieve rows from the database and display it on the .tpl file(mymodule.tpl)...I have an ps_employee..where all the data I need is stored.I am finding it difficult to create the function to retrieve the data and I also need to know how to display these rows in the .tpl file. Link to comment Share on other sites More sharing options...
JoelWebsites Posted June 23, 2014 Author Share Posted June 23, 2014 for eg in php we use $strSQL = "SELECT * FROM ps_employee"; echo "<table border='1'> <tr> <th> Number of stores </th> <th> Shop name </th> <th> Plan </th> <th> Language </th> <th> Lastname ID </th> <th> Firstname </th> <th> phone1 </th> <th> phone2 </th> <th> email </th> <th> start date </th> <th> Plan end date </th> <th> original cost </th> <th> discounted cost </th> <th>Reseller name</th> <th> edit info </th> </tr>"; // Execute the query (the recordset $rs contains the result) $rs = mysql_query($strSQL); // Loop the recordset $rs // Each row will be made into an array ($row) using mysql_fetch_array while($row = mysql_fetch_array($rs)) { echo "<tr>"; echo "<td>" . $row['id_employee'] . "</td>"; echo "<td>" . $row['shopname'] . "</td>"; echo "<td>" . $row['id_profile'] . "</td>"; echo "<td>" . $row['id_lang'] . "</td>"; echo "<td>" . $row['lastname'] . "</td>"; echo "<td>" . $row['firstname'] . "</td>"; echo "<td>" . $row['phone'] . "</td>"; echo "<td>" . $row['phone2'] . "</td>"; echo "<td>" . $row['email'] . "</td>"; echo "<td>" . $row['stats_date_to'] . "</td>"; echo "<td>" . $row['enddate'] . "</td>"; echo "<td>" . $row['originalcost'] . "</td>"; echo "<td>" . $row['discountedcost'] . "</td>"; echo "<td>" . $row['resellername'] . "</td>"; echo ("<td><a href=\"edit_form.php?id=$row[id_employee]\">Edit Enddate</a></td></tr>"); Link to comment Share on other sites More sharing options...
vekia Posted June 23, 2014 Share Posted June 23, 2014 in this case you can use default prestashop class named Db with this class you can run queries to database in that way: $query=Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('SELECT * FROM ps_employee'); then assign this variable to template file, $this->context->smarty->assign('query',$query); and then you can use foreach loop on this variable {foreach from=$query item=row} do something with $row variable here {/foreach} Link to comment Share on other sites More sharing options...
JoelWebsites Posted June 23, 2014 Author Share Posted June 23, 2014 and how to send these values to the .tpl file? Link to comment Share on other sites More sharing options...
JoelWebsites Posted June 23, 2014 Author Share Posted June 23, 2014 how to get the values of each colum of each row? Link to comment Share on other sites More sharing options...
JoelWebsites Posted June 23, 2014 Author Share Posted June 23, 2014 I also want to fetch the employee id (person who is logged in) so that I can use it my sql query. Link to comment Share on other sites More sharing options...
Xavier du Tertre Posted June 24, 2014 Share Posted June 24, 2014 This is not the right forum for this topic, I'm moving it. Remember: the PrestaShop forum is one of the biggest there is and a wise choice for a new thread means more replies, better replies, neater forums and a more efficient Community! Also, you might wanna be a little more specific in the description of what you're trying to customize. Link to comment Share on other sites More sharing options...
vekia Posted June 25, 2014 Share Posted June 25, 2014 you have to define global cookie. global $cookie; $cokie->id_employee; Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now