// #PSFV-94 : Add possibility to add product in a supplier order
This commit is contained in:
+13
-13
@@ -269,7 +269,7 @@ class AdminControllerCore extends Controller
|
||||
|
||||
/**
|
||||
* set default toolbar_title to admin breadcrumb
|
||||
*
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function initToolbarTitle()
|
||||
@@ -356,12 +356,12 @@ class AdminControllerCore extends Controller
|
||||
|
||||
// Sub included tab postProcessing
|
||||
$this->includeSubTab('postProcess', array('status', 'submitAdd1', 'submitDel', 'delete', 'submitFilter', 'submitReset'));
|
||||
|
||||
|
||||
if (!empty($this->action) && method_exists($this, 'process'.ucfirst(Tools::toCamelCase($this->action))))
|
||||
$this->{'process'.Tools::toCamelCase($this->action)}($token);
|
||||
else if (method_exists($this, $this->action))
|
||||
call_user_func(array($this, $this->action), $this->boxes);
|
||||
|
||||
|
||||
/* Manage list filtering */
|
||||
if ($this->filter)
|
||||
{
|
||||
@@ -429,7 +429,7 @@ class AdminControllerCore extends Controller
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Object Delete images
|
||||
*
|
||||
@@ -450,9 +450,9 @@ class AdminControllerCore extends Controller
|
||||
}
|
||||
$this->_errors[] = Tools::displayError('An error occurred during image deletion (cannot load object).');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Object Delete
|
||||
* Object Delete
|
||||
*
|
||||
* @param string $token
|
||||
*/
|
||||
@@ -492,7 +492,7 @@ class AdminControllerCore extends Controller
|
||||
Tools::displayError('(cannot load object)');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Object update and creation
|
||||
* TODO: split processAdd and processUpdate
|
||||
@@ -614,7 +614,7 @@ class AdminControllerCore extends Controller
|
||||
}
|
||||
$this->_errors = array_unique($this->_errors);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Change object required fields
|
||||
*
|
||||
@@ -631,7 +631,7 @@ class AdminControllerCore extends Controller
|
||||
else
|
||||
Tools::redirectAdmin(self::$currentIndex.'&conf=4&token='.$token);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Change object statuts (active, inactive)
|
||||
*
|
||||
@@ -654,7 +654,7 @@ class AdminControllerCore extends Controller
|
||||
' <b>'.$this->table.'</b> '.
|
||||
Tools::displayError('(cannot load object)');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Change object position
|
||||
*
|
||||
@@ -676,7 +676,7 @@ class AdminControllerCore extends Controller
|
||||
Tools::redirectAdmin($redirect);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Cancel all filters for this tab
|
||||
*
|
||||
@@ -710,7 +710,7 @@ class AdminControllerCore extends Controller
|
||||
unset($_POST);
|
||||
$this->filter = false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Update options and preferences
|
||||
*
|
||||
@@ -2280,7 +2280,7 @@ EOF;
|
||||
return $html;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Overload this method for custom checking
|
||||
|
||||
@@ -246,13 +246,52 @@ class SupplierOrderCore extends ObjectModel
|
||||
$this->discount_value_te = $this->total_te - $this->total_with_discount_te;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the product entries for the current order
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getEntries($id_lang = null)
|
||||
{
|
||||
if ($id_lang == null)
|
||||
$id_lang = Context::getContext()->language->id;
|
||||
|
||||
// build query
|
||||
$query = new DbQuery();
|
||||
|
||||
$query->select('
|
||||
s.*,
|
||||
IFNULL(CONCAT(pl.name, \' : \', GROUP_CONCAT(agl.name, \' - \', al.name SEPARATOR \', \')), pl.name) as name,
|
||||
p.reference as reference,
|
||||
p.ean13 as ean13');
|
||||
|
||||
$query->from('supplier_order_detail s');
|
||||
|
||||
$query->innerjoin('product_lang pl ON (pl.id_product = s.id_product AND pl.id_lang = '.$id_lang.')');
|
||||
|
||||
$query->leftjoin('product p ON p.id_product = s.id_product');
|
||||
$query->leftjoin('product_attribute_combination pac ON (pac.id_product_attribute = s.id_product_attribute)');
|
||||
$query->leftjoin('attribute atr ON (atr.id_attribute = pac.id_attribute)');
|
||||
$query->leftjoin('attribute_lang al ON (al.id_attribute = atr.id_attribute AND al.id_lang = '.$id_lang.')');
|
||||
$query->leftjoin('attribute_group_lang agl ON (agl.id_attribute_group = atr.id_attribute_group AND agl.id_lang = '.$id_lang.')');
|
||||
|
||||
$query->where('s.id_supplier_order = '.(int)$this->id);
|
||||
|
||||
$query->groupBy('s.id_supplier_order_detail');
|
||||
|
||||
return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($query);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the product entries collection for the current order
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getEntriesCollection()
|
||||
public function getEntriesCollection($id_lang = null)
|
||||
{
|
||||
if ($id_lang == null)
|
||||
$id_lang = Context::getContext()->language->id;
|
||||
|
||||
// build query
|
||||
$query = new DbQuery();
|
||||
$query->select('s.*');
|
||||
|
||||
@@ -110,7 +110,7 @@ class SupplierOrderDetailCore extends ObjectModel
|
||||
* @var float This is like $price_with_discount_te, considering the global order discount.
|
||||
* (i.e. if SupplierOrder::discount_rate is set)
|
||||
*/
|
||||
public $price_with_order_discount_te;
|
||||
public $price_with_order_discount_te = 0;
|
||||
|
||||
protected $fieldsRequired = array(
|
||||
'id_supplier_order',
|
||||
@@ -167,13 +167,13 @@ class SupplierOrderDetailCore extends ObjectModel
|
||||
{
|
||||
$this->validateFields();
|
||||
|
||||
$fields['id_supplier_order'] = (int)$this->id_supplier;
|
||||
$fields['id_product'] = (int)$this->id_employee;
|
||||
$fields['id_product_attribute'] = (int)$this->id_warehouse;
|
||||
$fields['id_supplier_order'] = (int)$this->id_supplier_order;
|
||||
$fields['id_product'] = (int)$this->id_product;
|
||||
$fields['id_product_attribute'] = (int)$this->id_product_attribute;
|
||||
$fields['id_currency'] = (int)$this->id_currency;
|
||||
$fields['exchange_rate'] = (float)$this->exchange_rate;
|
||||
$fields['unit_price_te'] = (float)$this->unit_price_te;
|
||||
$fields['quantity'] = (int)$this->id_state;
|
||||
$fields['quantity'] = (int)$this->quantity;
|
||||
$fields['price_te'] = (float)$this->price_te;
|
||||
$fields['discount_rate'] = (float)$this->discount_rate;
|
||||
$fields['discount_value_te'] = (float)$this->discount_value_te;
|
||||
@@ -221,10 +221,10 @@ class SupplierOrderDetailCore extends ObjectModel
|
||||
|
||||
// calcul entry discount value
|
||||
if ($this->discount_rate != null && is_numeric($this->discount_rate) && $this->discount_rate > 0)
|
||||
$htis->discount_value_te = (float)$htis->price_te * ((float)$this->discount_rate / 100);
|
||||
$htis->discount_value_te = (float)$this->price_te * ((float)$this->discount_rate / 100);
|
||||
|
||||
// calcul entry price with discount
|
||||
$this->price_with_discount_te = $htis->price_te - $htis->discount_value_te;
|
||||
$this->price_with_discount_te = $this->price_te - $this->discount_value_te;
|
||||
|
||||
// calcul tax value
|
||||
$this->tax_value = $this->price_with_discount_te * ((float)$this->tax_rate / 100);
|
||||
|
||||
Reference in New Issue
Block a user