Jump to content


  • Posts

  • Joined

  • Last visited

About DrGren

  • Birthday 10/16/1966

Contact Methods

Profile Information

  • Location
    Milano - Italy
  • Activity

DrGren's Achievements


Newbie (1/14)



  1. Hello everyone! Here comes something for you: I have introduced an attribute (Cost Account Center) for both customers and employees. Now I want the employee of CAC x to see only the orders from customers with CAC x. So I thought I'd hack the AdminOrdersController.php just a little, introducing on row 44 just before the select: $employee = new Employee((int)$this->context->cookie->id_employee); and then adding one join: INNER JOIN `'._DB_PREFIX_.'customer` cu ON (cu.`id_costcenter` = '.$employee->id_costcenter.') No effect! Every employee continues seeing all orders. But it doesn't stop here. I also need to display order statuses according to the profile of the employee. I thought this was simple and I spent many hours on trying without success. I modified all the calls to Orderstate like this 'states' => OrderState::getOrderStates($this->context->language->id, $this->context->cookie->profile) In the getOrderStates function I read the variable $profile = 1 and then I add a limitation to the query based on the profile id, But it remains always the default 1. The profile id of the employee is never passed. Any help with this would be much appreciated. Thank you very much! Henrik
  2. Hello everyone! At the very beginning of list_content.tpl there is a very useful piece of code for anybody who wants to modify each line of a list in the admin interface: {if isset($tr.class)} {$tr.class}{/if} In my case I just want to change the background-color in the order list, based on some product category in the order. Could anybody tell me where I set the $tr.class, please? I have looked throught the entire installation of v1.6 but I cannot find it. Best Regards Henrik
  3. Great work! I had to redirect to an external url after logout and this guide solved it for me. Thank you very much!
  4. Excellent piece of useful code that you can use a little bit of everywhere. In my case I put it in ProductController.php here: 'ENT_NOQUOTES' => ENT_NOQUOTES, 'privilegedcustomer' =>($this->context->customer->logged AND (Customer::getDefaultGroupId((int)$this->context->customer->id) == 7) ? true : false), 'outOfStockAllowed' => (int)Configuration::get('PS_ORDER_OUT_OF_STOCK'), So I can use it anywhere in the product.tpl, displaying different versions of the page depending on the default group of the user. Thanks Pascal!
  5. Dear Statictic, Thanks for your help, but the solution was another: For some reason you cannot call the Mail::Send defining the $fileAttachment the way I did: array('{content}' => $content,'{mime}' => 'application/xml', '{name}' => $file), Instead you should populate the array before and use it in the call to Mail::Send like this: $attach['content'] = $content; $attach['name'] = $file; $attach['mime'] = 'application/xml'; then: Mail::Send( 5, 'new_order', 'New Order', array(), '[email protected]', 'Provider', NULL, 'My ePortal', $attach, NULL, _PS_MAIL_DIR_, false ); Thanks again. All the best Henrik
  6. Dear All! This is the situation: For every order whose status is changed to the custom status "Confirmed" an email should leave to the supplier with an xml file in attach (it contains addresses, product details etc). Now, I implemented a function in Order.php of which I show you the relevant parts: /* Attachment File */ // Attachment location $file_name = $order_id.".xml"; $path = "../orders/"; // Read the file content $file = $path.$file_name; $file_size = filesize($file); $handle = fopen($file, "r"); $content = fread($handle, $file_size); fclose($handle); $content = chunk_split(base64_encode($content)); ... Mail::Send( 5, 'new_order', 'New Order', array(), '[email protected]', 'Provider', NULL, 'My ePortal', array('{content}' => $content,'{mime}' => 'application/xml', '{name}' => $file), NULL, _PS_MAIL_DIR_ ); The email is sent correctly to [email protected] but WITHOUT the attachment. Could anyone tell me what I am doing wrong here? Thank you very much Best Regards Henrik
  7. Hello everyone, In version 1.5 there is a field "outstanding balance" in the admincustomers controller. I think that is a great B2B feature (many times it is a requirement on a b2b platform). However, the only problem here: It doesn't seem to be activated!! Or am I missing something here? Anybody got the feature working? In my opinion it should work like this: The customer places an order Prestashop sums up the customer's orders that have never been in "payment accepted" status. If the sum including the recent order is larger than the allowed outstanding balance the system puts the order in a particular status like "waiting for large balance approval". An employee is notified. The customer is notified that his order is on hold. Has anybody seen anything similar to this process working in version 1.5? The field is there, but I think the functionality is not. Or it is well hidden. Any ideas? Best Regards Henrik
  8. Now that was a piece of very useful information. I couldn't understand why the passwords weren't working anymore. Great! Thank you Paul!
  9. With third level domains: shop 1 -> shop1.mydomain.com shop 2 -> shop2.mydomain.com shop 3 -> shop3.mydomain.com shop 4 -> shop4.mydomain.com I cannot add shop5. If I delete one of the four shops/domains I created however, then I can add the new shop. I guess I could try adding it directly in the database, but I would rather avoid it if possible. Best Regards Henrik
  10. Hello guys! I have successfully added four shops with different URLs and everything works beautifully. Then I try to add a fifth and I get a 500 server error. Is this due to a memory problem on my server or is there a limit on how many shops you can create? Best Regards Henrik
  11. Hello PrestArchitecte! This doesn't seem to work. The following gives me an error: <?php AddressCore::$definition['fields']['contactemail'] => array('type' => ObjectModel::TYPE_STRING, 'validate' => 'isEmail', 'required' => true, 'size' => 128); AddressCore::$definition['fields']['subsidiary'] => array('type' => ObjectModel::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true); AddressCore::$definition['fields']['agency'] => array('type' => ObjectModel::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true); class Address extends AddressCore { } Best Regards Henrik
  12. To sum up this thread (and I think that the moderator then can mark it as SOLVED): In order to create an ADMIN tab you should create 1. Example.php in /classes/ 2. AdminExampleController.php in /controllers/admin/ 3. a ps_example table 4. a tab Example in the admin interface. Here comes the working code: 1. The class: <?php class Example extends ObjectModel { public $id; public $name; public static $definition = array( 'table' => 'example', 'primary' => 'id_example', 'multilang' => false, 'fields' => array( 'name' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'required' => true, 'size' => 64), ), ); public static function getCompanies() { return Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS(' SELECT e.`id_example`, c.`name` FROM `'._DB_PREFIX_.'example` c ORDER BY c.`name` ASC'); } } ?> 2. The Controller: <?php class AdminExampleControllerCore extends AdminController { public function __construct() { $this->table = 'example'; $this->className = 'Example'; $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?'))); $this->fieldsDisplay = array( 'id_example' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25), 'name' => array('title' => $this->l('Title'), 'width' => 130), ); parent::__construct(); } public function renderForm() { $this->fields_form = array( 'legend' => array( 'title' => $this->l('Examples'), 'image' => '../img/admin/example.gif' ), 'input' => array( array( 'type' => 'text', 'label' => $this->l('Title:'), 'name' => 'name', 'size' => 33, 'required' => true, 'desc' => $this->l('Example name'), ), ), 'submit' => array( 'title' => $this->l(' Save '), 'class' => 'button' ) ); return parent::renderForm(); } } 3. DB: CREATE TABLE IF NOT EXISTS `ps_example` ( `id_example` int(11) NOT NULL auto_increment, `name` varchar(128) character set utf8 NOT NULL, PRIMARY KEY (`id_example`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=5 ; 4: Add TAB: Note that in my case I don't use translations since the site will never be in any other language than italian. Check the small differences in, for instance, Contact.php and AdminContactsController.php for the code. Hope this will help someone. Best Regards Henrik
  13. Hi Dominic! There are two problems with what you want to accomplish: 1. The employees don't belong to any group. That's precisely why I implemented the company model. An alternative is to optionally attach each employee to a group. This can make sense in situations where you want to segment the customers and each employee should only see his own segment (and I believe this could be what you are trying to accomplish). So you must modify ps_employee and override the employee class like I did above. 2. You join on two different values in your code id_default_group and id_customer. It cannot work. Once you have done the things in step 1 your filter should read something like: $this->filter = 'AND a.id_default_group IN (SELECT e.id_group from '._DB_PREFIX_.'employee e where e.id_employee = '.$cookie->id_employee); considering that the name of your new field in ps_employee is id_group. Hope this can help. Best Regards Henrik
  • Create New...