// Stock decrementation when order is shipped

git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@9486 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
mDeflotte
2011-10-20 09:08:59 +00:00
parent 06564db555
commit 78ddaa120c
17 changed files with 212 additions and 125 deletions
+1 -1
View File
@@ -38,7 +38,7 @@ class AdminAccess extends AdminTab
if (!in_array($perm, array('view', 'add', 'edit', 'delete', 'all')))
throw new PrestashopException('permission not exists');
$enabled = (int)Tools::getValue('enabled') ;
$enabled = (int)Tools::getValue('enabled');
$id_tab = (int)(Tools::getValue('id_tab'));
$id_profile = (int)(Tools::getValue('id_profile'));
$res = true;
+1 -1
View File
@@ -984,7 +984,7 @@ class AdminImport extends AdminTab
$this->_warnings[] = sprintf(Tools::displayError('No image found for combination with id_product = %s and image position = %s.'), $product->id, (int)$info['image_position']);
}
$id_product_attribute = $product->addProductAttribute((float)($info['price']), (float)($info['weight']), 0, (float)($info['ecotax']), (int)($info['quantity']), $id_image, strval($info['reference']), strval($info['supplier_reference']), strval($info['ean13']), (int)($info['default_on']), strval($info['upc']));
$id_product_attribute = $product->addProductAttribute((float)($info['price']), (float)($info['weight']), 0, (float)($info['ecotax']), $id_image, strval($info['reference']), strval($info['supplier_reference']), strval($info['ean13']), (int)($info['default_on']), strval($info['upc']));
$id_attribute_group = 0;
$group = '';
foreach (explode($fsep, $info['group']) as $group)
+79 -47
View File
@@ -30,19 +30,19 @@ class AdminOrders extends AdminTab
public function __construct()
{
$this->context = Context::getContext();
$this->table = 'order';
$this->className = 'Order';
$this->view = true;
$this->table = 'order';
$this->className = 'Order';
$this->view = true;
$this->colorOnBackground = true;
$this->_select = '
$this->_select = '
a.id_order AS id_pdf,
CONCAT(LEFT(c.`firstname`, 1), \'. \', c.`lastname`) AS `customer`,
osl.`name` AS `osname`,
os.`color`,
IF((SELECT COUNT(so.id_order) FROM `'._DB_PREFIX_.'orders` so WHERE so.id_customer = a.id_customer) > 1, 0, 1) as new,
(SELECT COUNT(od.`id_order`) FROM `'._DB_PREFIX_.'order_detail` od WHERE od.`id_order` = a.`id_order` GROUP BY `id_order`) AS product_number';
$this->_join = 'LEFT JOIN `'._DB_PREFIX_.'customer` c ON (c.`id_customer` = a.`id_customer`)
LEFT JOIN `'._DB_PREFIX_.'order_history` oh ON (oh.`id_order` = a.`id_order`)
$this->_join = 'LEFT JOIN `'._DB_PREFIX_.'customer` c ON (c.`id_customer` = a.`id_customer`)
LEFT JOIN `'._DB_PREFIX_.'order_history` oh ON (oh.`id_order` = a.`id_order`)
LEFT JOIN `'._DB_PREFIX_.'order_state` os ON (os.`id_order_state` = oh.`id_order_state`)
LEFT JOIN `'._DB_PREFIX_.'order_state_lang` osl ON (os.`id_order_state` = osl.`id_order_state` AND osl.`id_lang` = '.(int)$this->context->language->id.')';
$this->_where = 'AND oh.`id_order_history` = (SELECT MAX(`id_order_history`) FROM `'._DB_PREFIX_.'order_history` moh WHERE moh.`id_order` = a.`id_order` GROUP BY moh.`id_order`)';
@@ -52,7 +52,7 @@ class AdminOrders extends AdminTab
foreach ($states AS $state)
$statesArray[$state['id_order_state']] = $state['name'];
$this->fieldsDisplay = array(
$this->fieldsDisplay = array(
'id_order' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25),
'new' => array('title' => $this->l('New'), 'width' => 25, 'align' => 'center', 'type' => 'bool', 'filter_key' => 'new', 'tmpTableFilter' => true, 'icon' => array(0 => 'blank.gif', 1 => 'news-new.gif'), 'orderby' => false),
'customer' => array('title' => $this->l('Customer'), 'widthColumn' => 160, 'width' => 140, 'filter_key' => 'customer', 'tmpTableFilter' => true),
@@ -61,14 +61,13 @@ class AdminOrders extends AdminTab
'osname' => array('title' => $this->l('Status'), 'widthColumn' => 230, 'type' => 'select', 'select' => $statesArray, 'filter_key' => 'os!id_order_state', 'filter_type' => 'int', 'width' => 200),
'date_add' => array('title' => $this->l('Date'), 'width' => 35, 'align' => 'right', 'type' => 'datetime', 'filter_key' => 'a!date_add'),
'id_pdf' => array('title' => $this->l('PDF'), 'callback' => 'printPDFIcons', 'orderby' => false, 'search' => false));
$this->shopLinkType = 'shop';
$this->shopShareDatas = Shop::SHARE_ORDER;
$this->shopLinkType = 'shop';
$this->shopShareDatas = Shop::SHARE_ORDER;
parent::__construct();
}
public function postProcess()
{
/* Update shipping number */
if (Tools::isSubmit('submitShippingNumber') AND ($id_order = (int)(Tools::getValue('id_order'))) AND Validate::isLoadedObject($order = new Order($id_order)))
{
@@ -116,24 +115,29 @@ class AdminOrders extends AdminTab
$history = new OrderHistory();
$history->id_order = (int)$id_order;
$history->id_employee = (int)$this->context->employee->id;
$history->changeIdOrderState((int)($newOrderStatusId), (int)($id_order));
$order = new Order((int)$order->id);
$carrier = new Carrier((int)($order->id_carrier), (int)($order->id_lang));
$templateVars = array();
if ($history->id_order_state == Configuration::get('PS_OS_SHIPPING') AND $order->shipping_number)
$templateVars = array('{followup}' => str_replace('@', $order->shipping_number, $carrier->url));
elseif ($history->id_order_state == Configuration::get('PS_OS_CHEQUE'))
$templateVars = array(
'{cheque_name}' => (Configuration::get('CHEQUE_NAME') ? Configuration::get('CHEQUE_NAME') : ''),
'{cheque_address_html}' => (Configuration::get('CHEQUE_ADDRESS') ? nl2br(Configuration::get('CHEQUE_ADDRESS')) : ''));
elseif ($history->id_order_state == Configuration::get('PS_OS_BANKWIRE'))
$templateVars = array(
'{bankwire_owner}' => (Configuration::get('BANK_WIRE_OWNER') ? Configuration::get('BANK_WIRE_OWNER') : ''),
'{bankwire_details}' => (Configuration::get('BANK_WIRE_DETAILS') ? nl2br(Configuration::get('BANK_WIRE_DETAILS')) : ''),
'{bankwire_address}' => (Configuration::get('BANK_WIRE_ADDRESS') ? nl2br(Configuration::get('BANK_WIRE_ADDRESS')) : ''));
if ($history->addWithemail(true, $templateVars))
Tools::redirectAdmin(self::$currentIndex.'&id_order='.$id_order.'&vieworder'.'&token='.$this->token);
$this->_errors[] = Tools::displayError('An error occurred while changing the status or was unable to send e-mail to the customer.');
if (!(int)Tools::getValue('id_warehouse'))
$this->_errors[] = Tools::displayError('An error occurred while changing the status.');
else
{
$history->changeIdOrderState((int)($newOrderStatusId), (int)($id_order), (int)Tools::getValue('id_warehouse'));
$order = new Order((int)$order->id);
$carrier = new Carrier((int)($order->id_carrier), (int)($order->id_lang));
$templateVars = array();
if ($history->id_order_state == Configuration::get('PS_OS_SHIPPING') AND $order->shipping_number)
$templateVars = array('{followup}' => str_replace('@', $order->shipping_number, $carrier->url));
else if ($history->id_order_state == Configuration::get('PS_OS_CHEQUE'))
$templateVars = array(
'{cheque_name}' => (Configuration::get('CHEQUE_NAME') ? Configuration::get('CHEQUE_NAME') : ''),
'{cheque_address_html}' => (Configuration::get('CHEQUE_ADDRESS') ? nl2br(Configuration::get('CHEQUE_ADDRESS')) : ''));
elseif ($history->id_order_state == Configuration::get('PS_OS_BANKWIRE'))
$templateVars = array(
'{bankwire_owner}' => (Configuration::get('BANK_WIRE_OWNER') ? Configuration::get('BANK_WIRE_OWNER') : ''),
'{bankwire_details}' => (Configuration::get('BANK_WIRE_DETAILS') ? nl2br(Configuration::get('BANK_WIRE_DETAILS')) : ''),
'{bankwire_address}' => (Configuration::get('BANK_WIRE_ADDRESS') ? nl2br(Configuration::get('BANK_WIRE_ADDRESS')) : ''));
if ($history->addWithemail(true, $templateVars))
Tools::redirectAdmin(self::$currentIndex.'&id_order='.$id_order.'&vieworder'.'&token='.$this->token);
$this->_errors[] = Tools::displayError('An error occurred while changing the status or was unable to send e-mail to the customer.');
}
}
}
else
@@ -144,7 +148,7 @@ class AdminOrders extends AdminTab
elseif (isset($_POST['submitMessage']))
{
$_GET['view'.$this->table] = true;
if ($this->tabAccess['edit'] === '1')
if ($this->tabAccess['edit'] === '1')
{
if (!($id_order = (int)(Tools::getValue('id_order'))) OR !($id_customer = (int)(Tools::getValue('id_customer'))))
$this->_errors[] = Tools::displayError('An error occurred before sending message');
@@ -232,14 +236,14 @@ class AdminOrders extends AdminTab
$full_product_list = $productList;
$full_quantity_list = $qtyList;
if ($customizationList)
{
foreach ($customizationList as $key => $id_order_detail)
{
$full_product_list[$id_order_detail] = $id_order_detail;
$full_quantity_list[$id_order_detail] = $customizationQtyList[$key];
}
}
if ($customizationList)
{
foreach ($customizationList as $key => $id_order_detail)
{
$full_product_list[$id_order_detail] = $id_order_detail;
$full_quantity_list[$id_order_detail] = $customizationQtyList[$key];
}
}
if ($productList OR $customizationList)
{
@@ -575,9 +579,37 @@ class AdminOrders extends AdminTab
<select name="id_order_state">';
$currentStateTab = $order->getCurrentStateFull($this->context->language->id);
foreach ($states AS $state)
echo '<option value="'.$state['id_order_state'].'"'.(($state['id_order_state'] == $currentStateTab['id_order_state']) ? ' selected="selected"' : '').'>'.stripslashes($state['name']).'</option>';
{
if ($currentStateTab['shipped'] == 0 && $state['shipped'] == 1)
$needWarehouse = true;
else
$needWarehouse = false;
echo '<option onclick="'.($needWarehouse ? 'showWarehouseList()' : 'hideWarehouseList()').'" value="'.$state['id_order_state'].'"'.(($state['id_order_state'] == $currentStateTab['id_order_state']) ? ' selected="selected"' : '').'>'.stripslashes($state['name']).'</option>';
}
echo '
</select>';
$warehouse_list = Warehouse::getWarehouseList();
echo '<select name="id_warehouse" id="warehouse">';
foreach ($warehouse_list as $warehouse)
echo '<option value="'.$warehouse['id_warehouse'].'">'.$warehouse['name'].'</option>';
echo '</select>';
echo '
</select>
<script type="text/javascript">
function showWarehouseList()
{';
if (count($warehouse_list) > 1)
echo '
$(\'#warehouse\').show();';
echo '
}
function hideWarehouseList()
{
$(\'#warehouse\').hide();
}
hideWarehouseList();
</script>
<input type="hidden" name="id_order" value="'.$order->id.'" />
<input type="submit" name="submitState" value="'.$this->l('Change').'" class="button" />
</form>';
@@ -594,7 +626,7 @@ class AdminOrders extends AdminTab
{
echo '
'.$this->l('This order has been placed by a').' <b>'.$this->l('guest').'</b>';
if(!Customer::customerExists($customer->email))
if (!Customer::customerExists($customer->email))
{
echo '<form method="POST" action="index.php?tab=AdminCustomers&id_customer='.(int)$customer->id.'&token='.Tools::getAdminTokenLite('AdminCustomers').'">
<input type="hidden" name="id_lang" value="'.(int)$order->id_lang.'" />
@@ -764,10 +796,10 @@ class AdminOrders extends AdminTab
$tokenCatalog = Tools::getAdminToken('AdminCatalog'.(int)(Tab::getIdFromClassName('AdminCatalog')).(int)$this->context->employee->id);
foreach ($products as $k => $product)
{
if ($order->getTaxCalculationMethod() == PS_TAX_EXC)
$product_price = $product['product_price'] + $product['ecotax'];
else
$product_price = $product['product_price_wt'];
if ($order->getTaxCalculationMethod() == PS_TAX_EXC)
$product_price = $product['product_price'] + $product['ecotax'];
else
$product_price = $product['product_price_wt'];
$image = array();
if (isset($product['product_attribute_id']) AND (int)($product['product_attribute_id']))
@@ -775,13 +807,13 @@ class AdminOrders extends AdminTab
SELECT id_image
FROM '._DB_PREFIX_.'product_attribute_image
WHERE id_product_attribute = '.(int)($product['product_attribute_id']));
if (!isset($image['id_image']) OR !$image['id_image'])
if (!isset($image['id_image']) OR !$image['id_image'])
$image = Db::getInstance()->getRow('
SELECT id_image
FROM '._DB_PREFIX_.'image
WHERE id_product = '.(int)($product['product_id']).' AND cover = 1');
// @FIXME
$stock = StockManagerFactory::getManager()->getProductRealQuantities($product['product_id'], $product['product_attribute_id'], null, true);
$stock = StockManagerFactory::getManager()->getProductRealQuantities($product['product_id'], $product['product_attribute_id'], null, true);
if (isset($image['id_image']))
{
$target = _PS_TMP_IMG_DIR_.'product_mini_'.(int)($product['product_id']).(isset($product['product_attribute_id']) ? '_'.(int)($product['product_attribute_id']) : '').'.jpg';
@@ -897,8 +929,8 @@ class AdminOrders extends AdminTab
<select name="order_message" id="order_message" onchange="orderOverwriteMessage(this, \''.$this->l('Do you want to overwrite your existing message?').'\')">
<option value="0" selected="selected">-- '.$this->l('Choose a standard message').' --</option>';
$orderMessages = OrderMessage::getOrderMessages((int)($order->id_lang));
foreach ($orderMessages AS $orderMessage)
echo ' <option value="'.htmlentities($orderMessage['message'], ENT_COMPAT, 'UTF-8').'">'.$orderMessage['name'].'</option>';
foreach ($orderMessages AS $orderMessage)
echo ' <option value="'.htmlentities($orderMessage['message'], ENT_COMPAT, 'UTF-8').'">'.$orderMessage['name'].'</option>';
echo ' </select><br /><br />
<b>'.$this->l('Display to consumer?').'</b>
<input type="radio" name="visibility" id="visibility" value="0" /> '.$this->l('Yes').'
+8 -1
View File
@@ -59,6 +59,7 @@ class AdminOrdersStates extends AdminTab
$_POST['logable'] = Tools::getValue('logable');
$_POST['send_email'] = Tools::getValue('send_email');
$_POST['hidden'] = Tools::getValue('hidden');
$_POST['shipped'] = Tools::getValue('shipped');
if (!$_POST['send_email'])
{
$languages = Language::getLanguages(false);
@@ -164,7 +165,13 @@ class AdminOrdersStates extends AdminTab
(($this->getFieldValue($obj, 'send_email')) ? 'checked="checked"' : '').' value="1" />
<label class="t" for="send_email"> '.$this->l('Send e-mail to customer when order is changed to this status').'</label>
</p>
</div>
</div>
<div class="margin-form">
<p>'.elog($this->getFieldValue($obj, 'shipped')).'
<input type="checkbox" style="vertical-align: text-bottom;" name="shipped"'.(($this->getFieldValue($obj, 'shipped') == 1) ? ' checked="checked"' : '').' id="shipped_on" value="1" />
<label class="t" for="shipped_on"> '.$this->l('Set order as shipped').'</label>
</p>
</div>
<div id="tpl" style="display: '.($this->getFieldValue($obj, 'send_email') ? 'block' : 'none').';">
<label>'.$this->l('Template').'</label>
<div class="margin-form">';
-2
View File
@@ -514,7 +514,6 @@ class AdminProducts extends AdminTab
Tools::getValue('attribute_weight') * Tools::getValue('attribute_weight_impact'),
Tools::getValue('attribute_unity') * Tools::getValue('attribute_unit_impact'),
Tools::getValue('attribute_ecotax'),
false,
Tools::getValue('id_image_attr'),
Tools::getValue('attribute_reference'),
Tools::getValue('attribute_supplier_reference'),
@@ -556,7 +555,6 @@ class AdminProducts extends AdminTab
Tools::getValue('attribute_weight') * Tools::getValue('attribute_weight_impact'),
Tools::getValue('attribute_unity') * Tools::getValue('attribute_unit_impact'),
Tools::getValue('attribute_ecotax'),
Tools::getValue('attribute_quantity'),
Tools::getValue('id_image_attr'),
Tools::getValue('attribute_reference'),
Tools::getValue('attribute_supplier_reference'),
+34 -34
View File
@@ -27,50 +27,50 @@
class CurrencyCore extends ObjectModel
{
public $id;
public $id;
/** @var string Name */
public $name;
public $name;
/** @var string Iso code */
public $iso_code;
public $iso_code;
/** @var string Iso code numeric */
public $iso_code_num;
public $iso_code_num;
/** @var string Symbol for short display */
public $sign;
public $sign;
/** @var int bool used for displaying blank between sign and price */
public $blank;
public $blank;
/** @var string Conversion rate from euros */
public $conversion_rate;
public $conversion_rate;
/** @var boolean True if currency has been deleted (staying in database as deleted) */
public $deleted = 0;
public $deleted = 0;
/** @var int ID used for displaying prices */
public $format;
public $format;
/** @var int bool Display decimals on prices */
public $decimals;
public $decimals;
/** @var int bool active */
public $active;
public $active;
protected $fieldsRequired = array('name', 'iso_code', 'sign', 'conversion_rate', 'format', 'decimals');
protected $fieldsSize = array('name' => 32, 'iso_code' => 3, 'iso_code_num' => 3, 'sign' => 8);
protected $fieldsValidate = array('name' => 'isGenericName', 'iso_code' => 'isLanguageIsoCode', 'iso_code_num' => 'isNumericIsoCode', 'blank' => 'isInt', 'sign' => 'isGenericName',
protected $fieldsRequired = array('name', 'iso_code', 'sign', 'conversion_rate', 'format', 'decimals');
protected $fieldsSize = array('name' => 32, 'iso_code' => 3, 'iso_code_num' => 3, 'sign' => 8);
protected $fieldsValidate = array('name' => 'isGenericName', 'iso_code' => 'isLanguageIsoCode', 'iso_code_num' => 'isNumericIsoCode', 'blank' => 'isInt', 'sign' => 'isGenericName',
'format' => 'isUnsignedId', 'decimals' => 'isBool', 'conversion_rate' => 'isFloat', 'deleted' => 'isBool', 'active' => 'isBool');
protected $table = 'currency';
protected $identifier = 'id_currency';
protected $table = 'currency';
protected $identifier = 'id_currency';
/** @var array Currency cache */
static protected $currencies = array();
static protected $currencies = array();
protected $webserviceParameters = array(
protected $webserviceParameters = array(
'objectsNodeName' => 'currencies',
);
@@ -152,11 +152,11 @@ class CurrencyCore extends ObjectModel
}
/**
* Return formated sign
*
* @param string $side left or right
* @return string formated sign
*/
* Return formated sign
*
* @param string $side left or right
* @return string formated sign
*/
public function getSign($side=NULL)
{
if (!$side)
@@ -175,10 +175,10 @@ class CurrencyCore extends ObjectModel
}
/**
* Return available currencies
*
* @return array Currencies
*/
* Return available currencies
*
* @return array Currencies
*/
static public function getCurrencies($object = false, $active = 1, Shop $shop = null)
{
if (!$shop)
@@ -267,13 +267,13 @@ class CurrencyCore extends ObjectModel
}
/**
* Refresh the currency conversion rate
* The XML file define conversion rate for each from a default currency ($isoCodeSource).
*
* @param $data XML content which contains all the conversion rates
* @param $isoCodeSource The default currency used in the XML file
* @param $defaultCurrency The default currency object
*/
* Refresh the currency conversion rate
* The XML file define conversion rate for each from a default currency ($isoCodeSource).
*
* @param $data XML content which contains all the conversion rates
* @param $isoCodeSource The default currency used in the XML file
* @param $defaultCurrency The default currency object
*/
public function refreshCurrency($data, $isoCodeSource, $defaultCurrency)
{
// fetch the conversion rate of the default currency
+1 -1
View File
@@ -607,7 +607,7 @@ class OrderCore extends ObjectModel
public function getCurrentStateFull($id_lang)
{
return Db::getInstance()->getRow('
SELECT oh.`id_order_state`, osl.`name`, os.`logable`
SELECT oh.`id_order_state`, osl.`name`, os.`logable`, os.`shipped`
FROM `'._DB_PREFIX_.'order_history` oh
LEFT JOIN `'._DB_PREFIX_.'order_state_lang` osl ON (osl.`id_order_state` = oh.`id_order_state`)
LEFT JOIN `'._DB_PREFIX_.'order_state` os ON (os.`id_order_state` = oh.`id_order_state`)
+6 -6
View File
@@ -70,7 +70,7 @@ class OrderHistoryCore extends ObjectModel
return $fields;
}
public function changeIdOrderState($new_order_state, $id_order)
public function changeIdOrderState($new_order_state, $id_order, $id_warehouse = null)
{
if ($new_order_state != NULL)
{
@@ -89,12 +89,12 @@ class OrderHistoryCore extends ObjectModel
if ($newOS->logable AND (!$oldOrderStatus OR !$oldOrderStatus->logable))
ProductSale::addProductSale($product['id_product'], $product['cart_quantity']);
/* If becoming unlogable => removing sale */
elseif (!$newOS->logable AND ($oldOrderStatus AND $oldOrderStatus->logable))
else if (!$newOS->logable AND ($oldOrderStatus AND $oldOrderStatus->logable))
ProductSale::removeProductSale($product['id_product'], $product['cart_quantity']);
if (!$isValidated AND $newOS->logable AND isset($oldOrderStatus) AND $oldOrderStatus AND $oldOrderStatus->id == Configuration::get('PS_OS_ERROR'))
{
Product::updateQuantity($product);
}
// The product is removed from the physical stock. $id_warehouse is needed
if ($newOS->shipped == 1 && $oldOrderStatus->shipped == 0)
Stock::updateQuantity($product['id_product'], $product['id_product_attribute'], -$product['cart_quantity'], $id_warehouse, $id_order);
// @todo If the old order states was "shipped" and the new is "not shipped" the stock is not decremented
}
$this->id_order_state = (int)($new_order_state);
+20 -16
View File
@@ -28,40 +28,43 @@
class OrderStateCore extends ObjectModel
{
/** @var string Name */
public $name;
public $name;
/** @var string Template name if there is any e-mail to send */
public $template;
public $template;
/** @var boolean Send an e-mail to customer ? */
public $send_email;
public $send_email;
/** @var boolean Allow customer to view and download invoice when order is at this state */
public $invoice;
public $invoice;
/** @var string Display state in the specified color */
public $color;
public $color;
public $unremovable;
public $unremovable;
/** @var boolean Log authorization */
public $logable;
public $logable;
/** @var boolean Delivery */
public $delivery;
public $delivery;
/** @var boolean Hidden */
public $hidden;
public $hidden;
/** @var boolean Shipped */
public $shipped;
protected $fieldsValidate = array('send_email' => 'isBool', 'invoice' => 'isBool', 'color' => 'isColor', 'logable' => 'isBool');
protected $fieldsRequiredLang = array('name');
protected $fieldsSizeLang = array('name' => 64, 'template' => 64);
protected $fieldsValidateLang = array('name' => 'isGenericName', 'template' => 'isTplName');
protected $fieldsValidate = array('send_email' => 'isBool', 'invoice' => 'isBool', 'color' => 'isColor', 'logable' => 'isBool', 'shipped' => 'isBool');
protected $fieldsRequiredLang = array('name');
protected $fieldsSizeLang = array('name' => 64, 'template' => 64);
protected $fieldsValidateLang = array('name' => 'isGenericName', 'template' => 'isTplName');
protected $table = 'order_state';
protected $identifier = 'id_order_state';
protected $table = 'order_state';
protected $identifier = 'id_order_state';
protected $webserviceParameters = array(
protected $webserviceParameters = array(
'fields' => array(
'unremovable' => array(),
'delivery' => array(),
@@ -79,6 +82,7 @@ class OrderStateCore extends ObjectModel
$fields['logable'] = (int)($this->logable);
$fields['delivery'] = (int)($this->delivery);
$fields['hidden'] = (int)($this->hidden);
$fields['shipped'] = (int)($this->shipped);
return $fields;
}
+2
View File
@@ -2156,6 +2156,8 @@ class ProductCore extends ObjectModel
/**
* Update available product quantities
*
* @deprecated since 1.5.0
*
* @param array $product Array with ordered product (quantity, id_product_attribute if applicable)
* @return mixed Query result
*/
+25
View File
@@ -73,4 +73,29 @@ class StockCore extends ObjectModel
$fields['price_te'] = (float)round($this->price_te, 6);
return $fields;
}
/**
* For a given id_product and id_product_attribute update the quantity in stock
*/
public static function updateQuantity($id_product, $id_product_attribute, $delta_quantity, $id_warehouse, $id_order = null)
{
$warehouse = new Warehouse($id_warehouse);
// Update quantity of the pack products
if (Pack::isPack($id_product))
{
$products_pack = Pack::getItems((int)($product['id_product']), (int)(Configuration::get('PS_LANG_DEFAULT')));
foreach ($products_pack as $product_pack)
{
$pack_id_product_attribute = Product::getDefaultAttribute($tab_product_pack['id_product'], 1);
self::updateQuantity($product_pack->id, $pack_id_product_attribute, $product_pack->pack_quantity * $delta_quantity, $id_warehouse, $id_order);
}
}
if ($delta_quantity > 0)
$id_stock_mvt_reason = Configuration::get('PS_STOCK_MVT_INC_REASON_DEFAULT');
else
$id_stock_mvt_reason = Configuration::get('PS_STOCK_MVT_DEC_REASON_DEFAULT');
StockManagerFactory::getManager()
->removeProduct($id_product, $id_product_attribute, $warehouse, $delta_quantity, $id_stock_mvt_reason, true, (int)$id_order);
}
}
+12 -1
View File
@@ -265,7 +265,7 @@ class StockAvailableCore extends ObjectModel
}
/**
* For a given id_product and id_product_attribute update quantity the quantity available
* For a given id_product and id_product_attribute update the quantity available
*/
public static function updateQuantity($id_product, $id_product_attribute, $delta_quantity, $id_shop = null)
{
@@ -274,6 +274,17 @@ class StockAvailableCore extends ObjectModel
if (!$id_stock)
return false;
// Update quantity of the pack products
if (Pack::isPack($id_product))
{
$products_pack = Pack::getItems((int)($product['id_product']), (int)(Configuration::get('PS_LANG_DEFAULT')));
foreach ($products_pack as $product_pack)
{
$pack_id_product_attribute = Product::getDefaultAttribute($tab_product_pack['id_product'], 1);
self::updateQuantity($product_pack->id, $pack_id_product_attribute, $product_pack->pack_quantity * $delta_quantity, $id_shop);
}
}
$stock_available = new StockAvailable($id_stock);
$stock_available->quantity = $stock_available->quantity + $delta_quantity;
$stock_available->save();
+9
View File
@@ -241,4 +241,13 @@ class WarehouseCore extends ObjectModel
return (Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($query));
}
public static function getWarehouseList()
{
$query = new DbQuery();
$query->select('w.id_warehouse, name');
$query->from('warehouse w');
$query->innerJoin('warehouse_shop ws ON ws.id_warehouse = w.id_warehouse AND ws.id_shop = '.Context::getContext()->shop->getID(true));
return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($query);
}
}
@@ -93,12 +93,7 @@ class AdminStockInstantStateControllerCore extends AdminController
public function initContent()
{
$query = new DbQuery();
$query->select('w.id_warehouse, name');
$query->from('warehouse w');
$query->innerJoin('warehouse_shop ws ON ws.id_warehouse = w.id_warehouse AND ws.id_shop = '.Context::getContext()->shop->getID(true));
$this->context->smarty->assign('warehouse_list', Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($query));
$this->context->smarty->assign('warehouse_list', Warehouse::getWarehouseList());
$this->context->smarty->assign('current_warehouse', $this->getCurrentWarehouseId());
parent::initContent();
+6 -5
View File
@@ -1118,14 +1118,15 @@ CREATE TABLE `PREFIX_order_slip_detail` (
) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8;
CREATE TABLE `PREFIX_order_state` (
`id_order_state` int(10) unsigned NOT NULL auto_increment,
`invoice` tinyint(1) unsigned default '0',
`send_email` tinyint(1) unsigned NOT NULL default '0',
`id_order_state` int(10) UNSIGNED NOT NULL auto_increment,
`invoice` tinyint(1) UNSIGNED default '0',
`send_email` tinyint(1) UNSIGNED NOT NULL default '0',
`color` varchar(32) default NULL,
`unremovable` tinyint(1) unsigned NOT NULL,
`unremovable` tinyint(1) UNSIGNED NOT NULL,
`hidden` tinyint(1) UNSIGNED NOT NULL default '0',
`logable` tinyint(1) NOT NULL default '0',
`delivery` tinyint(1) unsigned NOT NULL default '0',
`delivery` tinyint(1) UNSIGNED NOT NULL default '0',
`shipped` tinyint(1) UNSIGNED NOT NULL default '0',
PRIMARY KEY (`id_order_state`)
) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8;
+4 -4
View File
@@ -265,9 +265,9 @@ INSERT INTO `PREFIX_category` (`id_category`, `id_parent`, `level_depth`, `nleft
INSERT INTO `PREFIX_category_lang` (`id_category`, `id_lang`, `name`, `description`, `link_rewrite`, `meta_title`, `meta_keywords`, `meta_description`) VALUES
(1, 1, 'Home', '', 'home', NULL, NULL, NULL),(1, 2, 'Accueil', '', 'home', NULL, NULL, NULL),(1, 3, 'Inicio', '', 'home', NULL, NULL, NULL),(1, 4, 'Start', '', 'home', NULL, NULL, NULL),(1, 5, 'Home page', '', 'home', NULL, NULL, NULL);
INSERT INTO `PREFIX_order_state` (`id_order_state`, `invoice`, `send_email`, `color`, `unremovable`, `logable`, `delivery`) VALUES
(1, 0, 1, 'lightblue', 1, 0, 0),(2, 1, 1, '#DDEEFF', 1, 1, 0),(3, 1, 1, '#FFDD99', 1, 1, 1),(4, 1, 1, '#EEDDFF', 1, 1, 1),(5, 1, 0, '#DDFFAA', 1, 1, 1),
(6, 0, 1, '#DADADA', 1, 0, 0),(7, 1, 1, '#FFFFBB', 1, 0, 0),(8, 0, 1, '#FFDFDF', 1, 0, 0),(9, 1, 1, '#FFD3D3', 1, 0, 0),(10, 0, 1, 'lightblue', 1, 0, 0),(11, 0, 0, 'lightblue', 1, 0, 0),(12, 1, 0, '#DDEEFF', 1, 1, 0);
INSERT INTO `PREFIX_order_state` (`id_order_state`, `invoice`, `send_email`, `color`, `unremovable`, `logable`, `delivery`, `shipped`) VALUES
(1, 0, 1, 'lightblue', 1, 0, 0, 0),(2, 1, 1, '#DDEEFF', 1, 1, 0, 0),(3, 1, 1, '#FFDD99', 1, 1, 1, 0),(4, 1, 1, '#EEDDFF', 1, 1, 1, 1),(5, 1, 0, '#DDFFAA', 1, 1, 1, 1),
(6, 0, 1, '#DADADA', 1, 0, 0, 0),(7, 1, 1, '#FFFFBB', 1, 0, 0, 0),(8, 0, 1, '#FFDFDF', 1, 0, 0, 0),(9, 1, 1, '#FFD3D3', 1, 0, 0, 0),(10, 0, 1, 'lightblue', 1, 0, 0, 0),(11, 0, 0, 'lightblue', 1, 0, 0, 0),(12, 1, 0, '#DDEEFF', 1, 1, 0, 0);
INSERT INTO `PREFIX_order_state_lang` (`id_order_state`, `id_lang`, `name`, `template`) VALUES
(1, 1, 'Awaiting cheque payment', 'cheque'),
@@ -1370,7 +1370,7 @@ INSERT INTO `PREFIX_stock_available` (`id_stock_available`, `id_product`, `id_pr
(38, 9, 0, 1, 1, 0, 2);
INSERT INTO `PREFIX_warehouse` (`id_warehouse`, `id_currency`, `id_address`, `id_employee`, `reference`, `name`, `management_type`) VALUES
(1, 1, 0, 1, 'default_warehouse', 'default warehous', 'FIFO');
(1, 1, 0, 1, 'default_warehouse', 'default warehouse', 'FIFO');
INSERT INTO `PREFIX_warehouse_shop` (`id_warehouse`, `id_shop`) VALUES
(1, 1);
+3
View File
@@ -218,3 +218,6 @@ INSERT INTO `PREFIX_module_access` (`id_profile`, `id_module`, `configure`, `vie
ALTER TABLE `PREFIX_carrier` ADD `position` INT( 10 ) UNSIGNED NOT NULL DEFAULT '0';
/* PHP:add_carrier_position();*/
ALTER TABLE `PREFIX_order_state` ADD COLUMN `shipped` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0 AFTER `delivery`;
UPDATE `PREFIX_order_state` SET `shipped` = 1 WHERE id_order_states IN (4, 5);