Compare commits
6 Commits
ticket/r16
...
master
Author | SHA1 | Date | |
---|---|---|---|
|
1d5578d66b | ||
|
922de8200a | ||
|
7699f86acd | ||
|
76b26ac6b4 | ||
|
305234f74f | ||
|
197f4161d1 |
@ -79,7 +79,16 @@ class AdminImport extends AdminTab
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->entities = array_flip(array($this->l('Categories'), $this->l('Products'), $this->l('Combinations'), $this->l('Customers'), $this->l('Addresses'), $this->l('Manufacturers'), $this->l('Suppliers')));
|
||||
$this->entities = array_flip(array(
|
||||
$this->l('Categories'),
|
||||
$this->l('Products'),
|
||||
$this->l('Combinations'),
|
||||
$this->l('Customers'),
|
||||
$this->l('Addresses'),
|
||||
$this->l('Manufacturers'),
|
||||
$this->l('Suppliers'),
|
||||
$this->l('Pack'),
|
||||
));
|
||||
|
||||
switch ((int)(Tools::getValue('entity')))
|
||||
{
|
||||
@ -280,7 +289,19 @@ class AdminImport extends AdminTab
|
||||
'meta_keywords' => array('label' => $this->l('Meta-keywords')),
|
||||
'meta_description' => array('label' => $this->l('Meta-description')));
|
||||
break;
|
||||
|
||||
case $this->entities[$this->l('Pack')]:
|
||||
|
||||
self::$required_fields = array('id_product_item', 'qty', 'id');
|
||||
|
||||
$this->available_fields = array(
|
||||
'id_product_item' => array('label' => $this->l('ID Item')),
|
||||
'qty' => array('label' => $this->l('Quantity Item')),
|
||||
'id' => array('label' => $this->l('ID Pack')),
|
||||
);
|
||||
break;
|
||||
}
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
@ -1292,6 +1313,51 @@ class AdminImport extends AdminTab
|
||||
}
|
||||
$this->closeCsvFile($handle);
|
||||
}
|
||||
|
||||
public function packImport()
|
||||
{
|
||||
$this->receiveTab();
|
||||
$handle = $this->openCsvFile();
|
||||
self::setLocale();
|
||||
for ($current_line = 0; $line = fgetcsv($handle, MAX_LINE_SIZE, Tools::getValue('separator')); $current_line++)
|
||||
{
|
||||
if (Tools::getValue('convert')) {
|
||||
$line = $this->utf8_encode_array($line);
|
||||
}
|
||||
$info = self::getMaskedRow($line);
|
||||
|
||||
self::setDefaultValues($info);
|
||||
|
||||
// Is product a pack
|
||||
if (array_key_exists('id', $info) && (int)($info['id']) && Pack::isPack((int)($info['id']))) {
|
||||
$pack = new Pack((int)($info['id']));
|
||||
}
|
||||
else {
|
||||
$pack = new Pack();
|
||||
}
|
||||
|
||||
self::array_walk($info, array('AdminImport', 'fillInfo'), $pack);
|
||||
if (($fieldError = $pack->validateFields(UNFRIENDLY_ERROR, true)) === true && is_numeric($info['qty']))
|
||||
{
|
||||
$res = false;
|
||||
// Is product item in pack
|
||||
if ($pack->isPacked($info['id_product_item'])) {
|
||||
$res = $pack->updateItem($info['id'], $info['id_product_item'], $info['qty']);
|
||||
}
|
||||
// Insert
|
||||
if (!$res) {
|
||||
$res = $pack->addItem($info['id'], $info['id_product_item'], $info['qty']);
|
||||
}
|
||||
if (!$res) {
|
||||
$this->_errors[] = mysql_error().' '.$info['id_product_item'].(isset($info['id']) ? ' (ID '.$info['id'].')' : '').' '.Tools::displayError('Cannot be saved');
|
||||
}
|
||||
}
|
||||
else {
|
||||
$this->_errors[] = ($fieldError !== true ? $fieldError : '').($langFieldError !== true ? $langFieldError : '');
|
||||
}
|
||||
}
|
||||
$this->closeCsvFile($handle);
|
||||
}
|
||||
|
||||
public function display()
|
||||
{
|
||||
@ -1824,6 +1890,9 @@ class AdminImport extends AdminTab
|
||||
case $this->entities[$this->l('Suppliers')]:
|
||||
$this->supplierImport();
|
||||
break;
|
||||
case $this->entities[$this->l('Pack')]:
|
||||
$this->packImport();
|
||||
break;
|
||||
default:
|
||||
$this->_errors[] = $this->l('no entity selected');
|
||||
}
|
||||
|
@ -174,18 +174,30 @@ class PackCore extends Product
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an item to the pack
|
||||
*
|
||||
* @param integer $id_product
|
||||
* @param integer $id_item
|
||||
* @param integer $qty
|
||||
* @return boolean true if everything was fine
|
||||
*/
|
||||
* Add an item to the pack
|
||||
* @param integer $id_product
|
||||
* @param integer $id_item
|
||||
* @param integer $qty
|
||||
* @return boolean true if everything was fine
|
||||
*/
|
||||
public static function addItem($id_product, $id_item, $qty)
|
||||
{
|
||||
Db::getInstance()->Execute('UPDATE '._DB_PREFIX_.'product SET cache_is_pack = 1 WHERE id_product = '.(int)($id_product).' LIMIT 1');
|
||||
return Db::getInstance()->AutoExecute(_DB_PREFIX_.'pack', array('id_product_pack' => (int)($id_product), 'id_product_item' => (int)($id_item), 'quantity' => (int)($qty)), 'INSERT');
|
||||
}
|
||||
|
||||
/**
|
||||
* Update item and his pack association
|
||||
* @param integer $id_product
|
||||
* @param integer $id_item
|
||||
* @param integer $qty
|
||||
* @return boolean true if everything was fine
|
||||
*/
|
||||
public static function updateItem($id_product, $id_item, $qty)
|
||||
{
|
||||
return Db::getInstance()->AutoExecute(_DB_PREFIX_.'pack', array('quantity' => (int)($qty)),
|
||||
'UPDATE', 'id_product_pack='.(int)($id_product).' AND id_product_item='.(int)($id_item));
|
||||
}
|
||||
|
||||
public static function duplicate($id_product_old, $id_product_new)
|
||||
{
|
||||
|
@ -1,13 +1,14 @@
|
||||
<?php
|
||||
if(!defined('_PS_VERSION_')) {
|
||||
if (!defined('_PS_VERSION_')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
class Logistics extends Module {
|
||||
class Logistics extends Module
|
||||
{
|
||||
public $_html = '';
|
||||
|
||||
public function __construct() {
|
||||
public function __construct()
|
||||
{
|
||||
$this->name = 'logistics';
|
||||
$this->tab = 'shipping_logistics';
|
||||
$this->version = '2.0';
|
||||
@ -20,7 +21,8 @@ class Logistics extends Module {
|
||||
$this->description = $this->l('Allows to manage parcels');
|
||||
}
|
||||
|
||||
public function install() {
|
||||
public function install()
|
||||
{
|
||||
# Add admin tabs
|
||||
$tabs_i18n = array(
|
||||
'fr' => 'Gestion des envois',
|
||||
@ -33,8 +35,8 @@ class Logistics extends Module {
|
||||
$t->active = TRUE;
|
||||
$t->module = 'logistics';
|
||||
$t->class_name = 'AdminLogistics';
|
||||
foreach(Language::getLanguages() as $lang) {
|
||||
if(isset($tabs_i18n[$lang['iso_code']])) {
|
||||
foreach (Language::getLanguages() as $lang) {
|
||||
if (isset($tabs_i18n[$lang['iso_code']])) {
|
||||
$t->name[$lang['id_lang']] = $tabs_i18n[$lang['iso_code']];
|
||||
} else {
|
||||
$t->name[$lang['id_lang']] = $tabs_i18n['en'];
|
||||
@ -47,7 +49,8 @@ class Logistics extends Module {
|
||||
&& $this->registerHook('updateCarrier');
|
||||
}
|
||||
|
||||
private function installCarriers() {
|
||||
private function installCarriers()
|
||||
{
|
||||
return
|
||||
// La Poste
|
||||
Db::getInstance()->Execute('
|
||||
@ -150,7 +153,8 @@ class Logistics extends Module {
|
||||
');
|
||||
}
|
||||
|
||||
private function uninstallCarriers() {
|
||||
private function uninstallCarriers()
|
||||
{
|
||||
/*Db::getInstance()->ExecuteS('DROP TABLE IF EXISTS `'._DB_PREFIX_.'lapostews`');
|
||||
Db::getInstance()->ExecuteS('DROP TABLE IF EXISTS `'._DB_PREFIX_.'lapostews_pr`');
|
||||
Db::getInstance()->ExecuteS('DROP TABLE IF EXISTS `'._DB_PREFIX_.'exapaqws`');
|
||||
@ -161,14 +165,16 @@ class Logistics extends Module {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
public function uninstall() {
|
||||
public function uninstall()
|
||||
{
|
||||
return $this->uninstallCarriers() && parent::uninstall();
|
||||
}
|
||||
|
||||
public function getContent() {
|
||||
public function getContent()
|
||||
{
|
||||
global $cookie;
|
||||
|
||||
if(Tools::isSubmit('submitUpdate')) {
|
||||
if (Tools::isSubmit('submitUpdate')) {
|
||||
/* La Poste */
|
||||
Configuration::updateValue('LAPOSTEWS_CARRIERS', serialize(Tools::getValue('laposte_carriers', array())));
|
||||
|
||||
@ -326,13 +332,13 @@ class Logistics extends Module {
|
||||
Configuration::updateValue('MONDIALRELAYWS_FTP_LOGIN', Tools::getValue('mondialrelay_ftp_login'));
|
||||
Configuration::updateValue('MONDIALRELAYWS_FTP_PASSWORD', Tools::getValue('mondialrelay_ftp_password'));
|
||||
|
||||
|
||||
// foreach(Tools::getValue('employee', array()) as $id_employee => $queue) {
|
||||
// Configuration::updateValue('LOGISTICS_QUEUE_'.(int) $id_employee, $queue);
|
||||
// }
|
||||
// Set print queue - employe : name
|
||||
foreach (Tools::getValue('employee', array()) as $id_employee => $queue) {
|
||||
Configuration::updateValue('LOGISTICS_QUEUE_'.(int)$id_employee, $queue);
|
||||
}
|
||||
|
||||
$lock = array();
|
||||
foreach(explode(', ', Tools::getValue('lock_products')) as $item) {
|
||||
foreach (explode(', ', Tools::getValue('lock_products')) as $item) {
|
||||
$lock[] = (int) $item;
|
||||
}
|
||||
Configuration::updateValue('LOGISTICS_LOCK', serialize(implode(',', $lock)));
|
||||
@ -459,7 +465,7 @@ class Logistics extends Module {
|
||||
<label for="laposte_exp_country">'.$this->l('Country:').'</label>
|
||||
<select name="laposte_exp_country">';
|
||||
|
||||
foreach(Country::getCountries((int) $cookie->id_lang) as $country) {
|
||||
foreach (Country::getCountries((int) $cookie->id_lang) as $country) {
|
||||
$this->_html .= '<option value="'.$country['id_country'].'"'.(Configuration::get('LAPOSTEWS_EXP_COUNTRY') == $country['id_country']? ' selected="selected"': '').'>'.$country['name'].'</option>';
|
||||
}
|
||||
|
||||
@ -557,7 +563,7 @@ class Logistics extends Module {
|
||||
';
|
||||
|
||||
$laposte_carriers = unserialize(Configuration::get('LAPOSTEWS_CARRIERS', serialize(array())));
|
||||
foreach(Db::getInstance()->ExecuteS('
|
||||
foreach (Db::getInstance()->ExecuteS('
|
||||
SELECT c.*
|
||||
FROM `'._DB_PREFIX_.'carrier` c
|
||||
') as $carrier) {
|
||||
@ -603,7 +609,7 @@ class Logistics extends Module {
|
||||
<label for="exapaq_exp_country">'.$this->l('Country:').'</label>
|
||||
<select name="exapaq_exp_country">';
|
||||
|
||||
foreach(Country::getCountries((int) $cookie->id_lang) as $country) {
|
||||
foreach (Country::getCountries((int) $cookie->id_lang) as $country) {
|
||||
$this->_html .= '<option value="'.$country['id_country'].'"'.(Configuration::get('EXAPAQWS_EXP_COUNTRY') == $country['id_country']? ' selected="selected"': '').'>'.$country['name'].'</option>';
|
||||
}
|
||||
|
||||
@ -695,7 +701,7 @@ class Logistics extends Module {
|
||||
';
|
||||
|
||||
$exapaq_carriers = unserialize(Configuration::get('EXAPAQWS_CARRIERS', serialize(array())));
|
||||
foreach(Db::getInstance()->ExecuteS('
|
||||
foreach (Db::getInstance()->ExecuteS('
|
||||
SELECT c.*
|
||||
FROM `'._DB_PREFIX_.'carrier` c
|
||||
') as $carrier) {
|
||||
@ -743,7 +749,7 @@ class Logistics extends Module {
|
||||
<label for="mondialrelay_exp_country">'.$this->l('Country:').'</label>
|
||||
<select name="mondialrelay_exp_country">';
|
||||
|
||||
foreach(Country::getCountries((int) $cookie->id_lang) as $country) {
|
||||
foreach (Country::getCountries((int) $cookie->id_lang) as $country) {
|
||||
$this->_html .= '<option value="'.$country['id_country'].'"'.(Configuration::get('MONDIALRELAY_EXP_COUNTRY') == $country['id_country']? ' selected="selected"': '').'>'.$country['name'].'</option>';
|
||||
}
|
||||
|
||||
@ -804,7 +810,7 @@ class Logistics extends Module {
|
||||
';
|
||||
|
||||
$mondialrelay_carriers = unserialize(Configuration::get('MONDIALRELAYWS_CARRIERS', serialize(array())));
|
||||
foreach(Db::getInstance()->ExecuteS('
|
||||
foreach (Db::getInstance()->ExecuteS('
|
||||
SELECT c.*
|
||||
FROM `'._DB_PREFIX_.'carrier` c
|
||||
') as $carrier) {
|
||||
@ -820,9 +826,9 @@ class Logistics extends Module {
|
||||
<fieldset id="tab-4" style="line-height: 1.5em; display: none;">
|
||||
';
|
||||
|
||||
foreach(Employee::getEmployees() as $employee) {
|
||||
foreach (Employee::getEmployees() as $employee) {
|
||||
$value = Configuration::get('LOGISTICS_QUEUE_'.(int) $employee['id_employee']);
|
||||
// if($value === FALSE) {
|
||||
// if ($value === FALSE) {
|
||||
// $value = Configuration::get('LAPOSTEWS_EMPL_'.(int) $employee['id_employee']);
|
||||
// }
|
||||
|
||||
@ -834,7 +840,7 @@ class Logistics extends Module {
|
||||
}
|
||||
|
||||
$lock = Configuration::get('LOGISTICS_LOCK');
|
||||
if($lock === FALSE || empty($lock)) {
|
||||
if ($lock === false || empty($lock)) {
|
||||
$lock = serialize(array());
|
||||
}
|
||||
|
||||
@ -862,21 +868,21 @@ class Logistics extends Module {
|
||||
|
||||
$carriers = Configuration::get('LAPOSTEWS_CARRIERS');
|
||||
|
||||
if(in_array((int) $params['id_carrier'], $carriers)) {
|
||||
if (in_array((int) $params['id_carrier'], $carriers)) {
|
||||
$carriers[] = (int) $new_carrier_id;
|
||||
Configuration::updateValue('LAPOSTEWS_CARRIERS', serialize($carriers));
|
||||
}
|
||||
|
||||
$carriers = Configuration::get('EXAPAQWS_CARRIERS');
|
||||
|
||||
if(in_array((int) $params['id_carrier'], $carriers)) {
|
||||
if (in_array((int) $params['id_carrier'], $carriers)) {
|
||||
$carriers[] = (int) $new_carrier_id;
|
||||
Configuration::updateValue('EXAPAQWS_CARRIERS', serialize($carriers));
|
||||
}
|
||||
|
||||
$carriers = Configuration::get('MONDIALRELAYWS_CARRIERS');
|
||||
|
||||
if(in_array((int) $params['id_carrier'], $carriers)) {
|
||||
if (in_array((int) $params['id_carrier'], $carriers)) {
|
||||
$carriers[] = (int) $new_carrier_id;
|
||||
Configuration::updateValue('MONDIALRELAYWS_CARRIERS', serialize($carriers));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user