* @copyright 2007-2011 PrestaShop SA * @version Release: $Revision: 7307 $ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) * International Registered Trademark & Property of PrestaShop SA */ /** * @since 1.5.0 */ class AdminWarehouses extends AdminTab { public function __construct() { $this->context = Context::getContext(); $this->table = 'warehouse'; $this->className = 'Warehouse'; $this->edit = true; $this->delete = false; $this->view = false; $this->fieldsDisplay = array( 'reference' => array('title' => $this->l('Reference'), 'width' => 40), 'name' => array('title' => $this->l('Name'), 'width' => 300, 'havingFilter' => true), 'management_type' => array('title' => $this->l('Managment type'), 'width' => 40), 'employee' => array('title' => $this->l('Manager'), 'width' => 150, 'havingFilter' => true), 'location' => array('title' => $this->l('Location'), 'width' => 150), 'contact' => array('title' => $this->l('Phone Number'), 'width' => 50), ); $this->_select = 'reference, name, management_type, CONCAT(e.lastname, \' \', e.firstname) AS employee, ad.phone AS contact, CONCAT(ad.city, \' \', c.iso_code) location'; $this->_join = 'LEFT JOIN `'._DB_PREFIX_.'employee` e ON (e.id_employee = a.id_employee) LEFT JOIN `'._DB_PREFIX_.'address` ad ON (ad.id_address = a.id_address) LEFT JOIN `'._DB_PREFIX_.'country` c ON (c.id_country = ad.id_country)'; // Get countries list for warehouse localisation $countries = Country::getCountries($this->context->language->id); foreach ($countries as $country) $this->countries_array[$country['id_country']] = $country['name']; // Get employee list for warehouse manager $query = new DbQuery(); $query->select('id_employee, CONCAT(lastname," ",firstname) as name'); $query->from('employee'); $query->where('active = 1'); $employees = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($query); foreach ($employees as $employee) $this->employees_array[$employee['id_employee']] = $employee['name']; parent::__construct(); } public function postProcess() { // update/create address if not exists if (isset($_POST['submitAdd'.$this->table])) { if (isset($_POST['id_address']) && $_POST['id_address'] > 0) //update address $address = new Address((int)$_POST['id_address']); else //create address $address = new Address(); $address->alias = $_POST['name']; $address->lastname = $_POST['name']; $address->firstname = $_POST['name']; $address->address1 = $_POST['address1']; $address->address2 = $_POST['address2']; $address->postcode = $_POST['postcode']; $address->phone = $_POST['phone']; $address->id_country = $_POST['id_country']; $address->city = $_POST['city']; if (isset($_POST['id_address']) && $_POST['id_address'] > 0) { //update address $address->update(); } else { $address->save(); $_POST['id_address'] = $address->id; } } return parent::postProcess(); } public function displayForm($is_main_tab = true) { parent::displayForm(); if (!($obj = $this->loadObject(true))) return; if ($obj->id_address > 0) $address = new Address($obj->id_address); echo '
'; } }