本文整理汇总了PHP中Warehouse::getWarehouses方法的典型用法代码示例。如果您正苦于以下问题:PHP Warehouse::getWarehouses方法的具体用法?PHP Warehouse::getWarehouses怎么用?PHP Warehouse::getWarehouses使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Warehouse
的用法示例。
在下文中一共展示了Warehouse::getWarehouses方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: renderList
/**
* AdminController::renderList() override
* @see AdminController::renderList()
*/
public function renderList()
{
// removes toolbar btn
$this->toolbar_btn = array();
// overrides select
$this->_select = '
CONCAT(pl.name, \' \', GROUP_CONCAT(IFNULL(al.name, \'\'), \'\')) product_name,
CONCAT(a.employee_lastname, \' \', a.employee_firstname) as employee,
mrl.name as reason,
stock.reference as product_reference,
stock.ean13 as product_ean13,
stock.upc as product_upc,
w.id_currency as id_currency,
w.name as warehouse_name';
// overrides join
$this->_join = 'INNER JOIN ' . _DB_PREFIX_ . 'stock stock ON a.id_stock = stock.id_stock
LEFT JOIN `' . _DB_PREFIX_ . 'product_lang` pl ON (
stock.id_product = pl.id_product
AND pl.id_lang = ' . (int) $this->context->language->id . Shop::addSqlRestrictionOnLang('pl') . '
)
LEFT JOIN `' . _DB_PREFIX_ . 'stock_mvt_reason_lang` mrl ON (
a.id_stock_mvt_reason = mrl.id_stock_mvt_reason
AND mrl.id_lang = ' . (int) $this->context->language->id . '
)
LEFT JOIN `' . _DB_PREFIX_ . 'warehouse` w ON (w.id_warehouse = stock.id_warehouse)
LEFT JOIN `' . _DB_PREFIX_ . 'product_attribute_combination` pac ON (pac.id_product_attribute = stock.id_product_attribute)
LEFT JOIN `' . _DB_PREFIX_ . 'attribute_lang` al ON (
al.id_attribute = pac.id_attribute
AND pac.id_product_attribute <> 0
AND al.id_lang = ' . (int) $this->context->language->id . '
)';
// overrides group
$this->_group = 'GROUP BY a.id_stock_mvt';
// overrides where depending on the warehouse
$id_warehouse = (int) $this->getCurrentWarehouseId();
if ($id_warehouse > 0) {
$this->_where = ' AND w.id_warehouse = ' . $id_warehouse;
self::$currentIndex .= '&id_warehouse=' . $id_warehouse;
}
// sets the current warehouse
$this->tpl_list_vars['current_warehouse'] = $this->getCurrentWarehouseId();
// sets the list of warehouses
$warehouses = Warehouse::getWarehouses(true);
array_unshift($warehouses, array('id_warehouse' => -1, 'name' => $this->l('All Warehouses')));
$this->tpl_list_vars['list_warehouses'] = $warehouses;
// sets toolbar
$this->initToolbar();
// renders list
$list = parent::renderList();
// if export requested
if (Tools::isSubmit('csv')) {
if (count($this->_list) > 0) {
$this->renderCSV();
die;
} else {
$this->displayWarning($this->l('There is nothing to export as a CSV.'));
}
}
return $list;
}
示例2: renderForm
public function renderForm()
{
$warehouses = Warehouse::getWarehouses();
$this->fields_form = array('legend' => array('title' => $this->l('States'), 'icon' => 'icon-globe'), 'input' => array(array('type' => 'text', 'label' => 'Название', 'name' => 'name', 'lang' => true, 'required' => true, 'class' => 'copy2friendlyUrl', 'hint' => $this->l('Invalid characters:') . ' <>;=#{}'), array('type' => 'text', 'label' => 'Порядок сортировки', 'name' => 'sort', 'class' => 'copy2friendlyUrl', 'hint' => $this->l('Invalid characters:') . ' <>;=#{}'), array('type' => 'text', 'label' => 'Стоимость доставки в разделе декор', 'name' => 'price_decor', 'class' => 'copy2friendlyUrl', 'hint' => $this->l('Invalid characters:') . ' <>;=#{}'), array('type' => 'text', 'label' => 'Стоимость доставки обычная', 'name' => 'price_main', 'class' => 'copy2friendlyUrl', 'hint' => $this->l('Invalid characters:') . ' <>;=#{}'), array('type' => 'text', 'label' => 'Адрес склада', 'name' => 'address_warehouse', 'class' => 'copy2friendlyUrl', 'hint' => $this->l('Invalid characters:') . ' <>;=#{}'), array('type' => 'text', 'label' => 'Режим работы', 'name' => 'mode', 'class' => 'copy2friendlyUrl', 'hint' => $this->l('Invalid characters:') . ' <>;=#{}'), array('type' => 'switch', 'label' => 'Главный', 'name' => 'is_main', 'required' => true, 'values' => array(array('id' => 'active_on', 'value' => 1, 'label' => '<img src="../img/admin/enabled.gif" alt="' . $this->l('Enabled') . '" title="' . $this->l('Enabled') . '" />'), array('id' => 'active_off', 'value' => 0, 'label' => '<img src="../img/admin/disabled.gif" alt="' . $this->l('Disabled') . '" title="' . $this->l('Disabled') . '" />'))), array('type' => 'switch', 'label' => 'Московская обл', 'name' => 'is_msk', 'required' => true, 'values' => array(array('id' => 'active_on', 'value' => 1, 'label' => '<img src="../img/admin/enabled.gif" alt="' . $this->l('Enabled') . '" title="' . $this->l('Enabled') . '" />'), array('id' => 'active_off', 'value' => 0, 'label' => '<img src="../img/admin/disabled.gif" alt="' . $this->l('Disabled') . '" title="' . $this->l('Disabled') . '" />')))), 'submit' => array('title' => $this->l('Save')));
// foreach ($warehouses as $warehous){
// $this->fields_form['input'][] = array(
// 'type' => 'text',
// 'label' => 'Время доставки со скдада '.$warehous['name'],
// 'name' => 'distance_'.$warehous['id_warehouse'],
// 'hint' => 'Время доставки в днях',
// );
// $this->fields_form['input'][] = array(
// 'type' => 'text',
// 'label' => 'Стоимость доставки со склада '.$warehous['name'],
// 'name' => 'price_'.$warehous['id_warehouse'],
// 'hint' => 'Стоимость доставки в рублях',
// );
// if(!empty($this->object->id_city)){
// $fields_value = Db::getInstance()->getRow("SELECT distance,price FROM "._DB_PREFIX_."city_warehous
// WHERE id_warehouse={$warehous['id_warehouse']} AND id_city={$this->object->id_city}");
//
// $this->fields_value['distance_'.$warehous['id_warehouse']] = isset($fields_value['distance']) ? $fields_value['distance'] : '';
// $this->fields_value['price_'.$warehous['id_warehouse']] = isset($fields_value['price']) ? $fields_value['price'] : '';
// }
// }
return parent::renderForm();
}
示例3: __construct
public function __construct()
{
$this->bootstrap = true;
$this->className = 'Configuration';
$this->table = 'configuration';
parent::__construct();
$warehouse_list = Warehouse::getWarehouses();
$warehouse_no = array(array('id_warehouse' => 0, 'name' => $this->l('No default warehouse (default setting)')));
$warehouse_list = array_merge($warehouse_no, $warehouse_list);
$this->fields_options = array('products' => array('title' => $this->l('Products (general)'), 'fields' => array('PS_CATALOG_MODE' => array('title' => $this->l('Catalog mode'), 'hint' => $this->l('When active, all shopping features will be disabled.'), 'validation' => 'isBool', 'cast' => 'intval', 'required' => false, 'type' => 'bool'), 'PS_COMPARATOR_MAX_ITEM' => array('title' => $this->l('Product comparison'), 'hint' => $this->l('Set the maximum number of products that can be selected for comparison. Set to "0" to disable this feature.'), 'validation' => 'isUnsignedId', 'required' => true, 'cast' => 'intval', 'type' => 'text'), 'PS_NB_DAYS_NEW_PRODUCT' => array('title' => $this->l('Number of days for which the product is considered \'new\''), 'validation' => 'isUnsignedInt', 'cast' => 'intval', 'type' => 'text'), 'PS_CART_REDIRECT' => array('title' => $this->l('Redirect after adding product to cart'), 'hint' => $this->l('Only for non-AJAX versions of the cart.'), 'cast' => 'intval', 'show' => true, 'required' => false, 'type' => 'radio', 'validation' => 'isBool', 'choices' => array(0 => $this->l('Previous page'), 1 => $this->l('Cart summary'))), 'PS_PRODUCT_SHORT_DESC_LIMIT' => array('title' => $this->l('Max size of short description'), 'hint' => $this->l('Set the maximum size of product short description (in characters).'), 'validation' => 'isInt', 'cast' => 'intval', 'type' => 'text', 'suffix' => $this->l('characters')), 'PS_QTY_DISCOUNT_ON_COMBINATION' => array('title' => $this->l('Quantity discounts based on'), 'hint' => $this->l('How to calculate quantity discounts.'), 'cast' => 'intval', 'show' => true, 'required' => false, 'type' => 'radio', 'validation' => 'isBool', 'choices' => array(0 => $this->l('Products'), 1 => $this->l('Combinations'))), 'PS_FORCE_FRIENDLY_PRODUCT' => array('title' => $this->l('Force update of friendly URL'), 'hint' => $this->l('When active, friendly URL will be updated on every save.'), 'validation' => 'isBool', 'cast' => 'intval', 'required' => false, 'type' => 'bool')), 'submit' => array('title' => $this->l('Save'))), 'order_by_pagination' => array('title' => $this->l('Pagination'), 'fields' => array('PS_PRODUCTS_PER_PAGE' => array('title' => $this->l('Products per page'), 'hint' => $this->l('Number of products displayed per page. Default is 10.'), 'validation' => 'isUnsignedInt', 'cast' => 'intval', 'type' => 'text'), 'PS_PRODUCTS_ORDER_BY' => array('title' => $this->l('Default order by'), 'hint' => $this->l('The order in which products are displayed in the product list.'), 'type' => 'select', 'list' => array(array('id' => '0', 'name' => $this->l('Product name')), array('id' => '1', 'name' => $this->l('Product price')), array('id' => '2', 'name' => $this->l('Product add date')), array('id' => '3', 'name' => $this->l('Product modified date')), array('id' => '4', 'name' => $this->l('Position inside category')), array('id' => '5', 'name' => $this->l('Manufacturer')), array('id' => '6', 'name' => $this->l('Product quantity')), array('id' => '7', 'name' => $this->l('Product reference'))), 'identifier' => 'id'), 'PS_PRODUCTS_ORDER_WAY' => array('title' => $this->l('Default order method'), 'hint' => $this->l('Default order method for product list.'), 'type' => 'select', 'list' => array(array('id' => '0', 'name' => $this->l('Ascending')), array('id' => '1', 'name' => $this->l('Descending'))), 'identifier' => 'id')), 'submit' => array('title' => $this->l('Save'))), 'fo_product_page' => array('title' => $this->l('Product page'), 'fields' => array('PS_DISPLAY_QTIES' => array('title' => $this->l('Display available quantities on the product page'), 'validation' => 'isBool', 'cast' => 'intval', 'required' => false, 'type' => 'bool'), 'PS_LAST_QTIES' => array('title' => $this->l('Display remaining quantities when the quantity is lower than'), 'hint' => $this->l('Set to "0" to disable this feature.'), 'validation' => 'isUnsignedId', 'required' => true, 'cast' => 'intval', 'type' => 'text'), 'PS_DISPLAY_JQZOOM' => array('title' => $this->l('Enable JqZoom instead of Fancybox on the product page'), 'validation' => 'isBool', 'cast' => 'intval', 'required' => false, 'type' => 'bool'), 'PS_DISP_UNAVAILABLE_ATTR' => array('title' => $this->l('Display unavailable product attributes on the product page'), 'validation' => 'isBool', 'cast' => 'intval', 'required' => false, 'type' => 'bool'), 'PS_ATTRIBUTE_CATEGORY_DISPLAY' => array('title' => $this->l('Display the "add to cart" button when a product has attributes'), 'hint' => $this->l('Display or hide the "add to cart" button on category pages for products that have attributes forcing customers to see product details.'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool'), 'PS_ATTRIBUTE_ANCHOR_SEPARATOR' => array('title' => $this->l('Separator of attribute anchor on the product links'), 'type' => 'select', 'list' => array(array('id' => '-', 'name' => '-'), array('id' => ',', 'name' => ',')), 'identifier' => 'id'), 'PS_DISPLAY_DISCOUNT_PRICE' => array('title' => $this->l('Display discounted price'), 'desc' => $this->l('In the volume discounts board, display the new price with the applied discount instead of showing the discount (ie. "-5%").'), 'validation' => 'isBool', 'cast' => 'intval', 'required' => false, 'type' => 'bool')), 'submit' => array('title' => $this->l('Save'))), 'stock' => array('title' => $this->l('Products stock'), 'fields' => array('PS_ORDER_OUT_OF_STOCK' => array('title' => $this->l('Allow ordering of out-of-stock products'), 'hint' => $this->l('By default, the Add to Cart button is hidden when a product is unavailable. You can choose to have it displayed in all cases.'), 'validation' => 'isBool', 'cast' => 'intval', 'required' => false, 'type' => 'bool'), 'PS_STOCK_MANAGEMENT' => array('title' => $this->l('Enable stock management'), 'validation' => 'isBool', 'cast' => 'intval', 'required' => false, 'type' => 'bool', 'js' => array('on' => 'onchange="stockManagementActivationAuthorization()"', 'off' => 'onchange="stockManagementActivationAuthorization()"')), 'PS_ADVANCED_STOCK_MANAGEMENT' => array('title' => $this->l('Enable advanced stock management'), 'hint' => $this->l('Allows you to manage physical stock, warehouses and supply orders in a new Stock menu.'), 'validation' => 'isBool', 'cast' => 'intval', 'required' => false, 'type' => 'bool', 'visibility' => Shop::CONTEXT_ALL, 'js' => array('on' => 'onchange="advancedStockManagementActivationAuthorization()"', 'off' => 'onchange="advancedStockManagementActivationAuthorization()"')), 'PS_FORCE_ASM_NEW_PRODUCT' => array('title' => $this->l('New products use advanced stock management'), 'hint' => $this->l('New products will automatically use advanced stock management and depends on stock, but no warehouse will be selected'), 'validation' => 'isBool', 'cast' => 'intval', 'required' => false, 'type' => 'bool', 'visibility' => Shop::CONTEXT_ALL), 'PS_DEFAULT_WAREHOUSE_NEW_PRODUCT' => array('title' => $this->l('Default warehouse on new products'), 'hint' => $this->l('Automatically set a default warehouse when new product is created'), 'type' => 'select', 'list' => $warehouse_list, 'identifier' => 'id_warehouse'), 'PS_PACK_STOCK_TYPE' => array('title' => $this->l('Default pack stock management'), 'type' => 'select', 'list' => array(array('pack_stock' => 0, 'name' => $this->l('Decrement pack only.')), array('pack_stock' => 1, 'name' => $this->l('Decrement products in pack only.')), array('pack_stock' => 2, 'name' => $this->l('Decrement both.'))), 'identifier' => 'pack_stock')), 'bottom' => '<script type="text/javascript">stockManagementActivationAuthorization();advancedStockManagementActivationAuthorization();</script>', 'submit' => array('title' => $this->l('Save'))));
}
示例4: __construct
public function __construct()
{
$this->context = Context::getContext();
$this->table = 'stock';
$this->className = 'Stock';
$this->lang = false;
$this->multishop_context = Shop::CONTEXT_ALL;
$this->fields_list = array('reference' => array('title' => $this->l('Reference'), 'align' => 'center', 'width' => 200, 'havingFilter' => true), 'ean13' => array('title' => $this->l('EAN13'), 'align' => 'center', 'width' => 100), 'upc' => array('title' => $this->l('UPC'), 'align' => 'center', 'width' => 100), 'name' => array('title' => $this->l('Name'), 'havingFilter' => true), 'price_te' => array('title' => $this->l('Price (tax excl.)'), 'width' => 150, 'orderby' => true, 'search' => false, 'type' => 'price', 'currency' => true), 'valuation' => array('title' => $this->l('Valuation'), 'width' => 150, 'orderby' => true, 'search' => false, 'type' => 'price', 'currency' => true, 'hint' => $this->l('Total value of the physical quantity. The sum (for all prices) is not available for all warehouses, please filter by warehouse.')), 'physical_quantity' => array('title' => $this->l('Physical quantity'), 'width' => 80, 'orderby' => true, 'search' => false), 'usable_quantity' => array('title' => $this->l('Usable quantity'), 'width' => 80, 'orderby' => true, 'search' => false), 'real_quantity' => array('title' => $this->l('Real quantity'), 'width' => 80, 'orderby' => true, 'search' => false, 'hint' => $this->l('Pysical qty (usable) - Clients orders + Supply Orders')));
$this->addRowAction('details');
$this->stock_instant_state_warehouses = Warehouse::getWarehouses(true);
array_unshift($this->stock_instant_state_warehouses, array('id_warehouse' => -1, 'name' => $this->l('All Warehouses')));
parent::__construct();
}
示例5: renderForm
/**
* AdminController::renderForm() override
* @see AdminController::renderForm()
*/
public function renderForm()
{
// gets the product
$id_product = (int) Tools::getValue('id_product');
$id_product_attribute = (int) Tools::getValue('id_product_attribute');
// gets warehouses
$warehouses_add = Warehouse::getWarehouses(true);
$warehouses_remove = Warehouse::getWarehousesByProductId($id_product, $id_product_attribute);
// displays warning if no warehouses
if (!$warehouses_add) {
$this->displayWarning($this->l('You must choose a warehouses before adding stock. See Stock/Warehouses'));
}
//get currencies list
$currencies = Currency::getCurrencies();
$id_default_currency = Configuration::get('PS_CURRENCY_DEFAULT');
$default_currency = Currency::getCurrency($id_default_currency);
if ($default_currency) {
$currencies = array_merge(array($default_currency, '-'), $currencies);
}
// switch, in order to display the form corresponding to the current action
switch ($this->display) {
case 'addstock':
// gets the last stock mvt for this product, so we can display the last unit price te and the last quantity added
$last_sm_unit_price_te = $this->l('N/A');
$last_sm_quantity = 0;
$last_sm_quantity_is_usable = -1;
$last_sm = StockMvt::getLastPositiveStockMvt($id_product, $id_product_attribute);
// if there is a stock mvt
if ($last_sm != false) {
$last_sm_currency = new Currency((int) $last_sm['id_currency']);
$last_sm_quantity = (int) $last_sm['physical_quantity'];
$last_sm_quantity_is_usable = (int) $last_sm['is_usable'];
if (Validate::isLoadedObject($last_sm_currency)) {
$last_sm_unit_price_te = Tools::displayPrice((double) $last_sm['price_te'], $last_sm_currency);
}
}
$this->displayInformation($this->l('Rolling over the quantity and price fields will give you the details about the last stock movement.'));
// fields in the form
$this->fields_form[]['form'] = array('legend' => array('title' => $this->l('Add a product to your stock.'), 'image' => '../img/admin/add_stock.png'), 'input' => array(array('type' => 'hidden', 'name' => 'is_post'), array('type' => 'hidden', 'name' => 'id_product'), array('type' => 'hidden', 'name' => 'id_product_attribute'), array('type' => 'hidden', 'name' => 'check'), array('type' => 'text', 'label' => $this->l('Product reference:'), 'name' => 'reference', 'size' => 30, 'disabled' => true), array('type' => 'text', 'label' => $this->l('EAN13:'), 'name' => 'ean13', 'size' => 15, 'disabled' => true), array('type' => 'text', 'label' => $this->l('UPC:'), 'name' => 'upc', 'size' => 15, 'disabled' => true), array('type' => 'text', 'label' => $this->l('Name:'), 'name' => 'name', 'size' => 75, 'disabled' => true), array('type' => 'text', 'label' => $this->l('Quantity to add:'), 'name' => 'quantity', 'size' => 10, 'maxlength' => 6, 'required' => true, 'desc' => $this->l('Physical quantity to add'), 'hint' => sprintf($this->l('Last physical quantity added : %s (%s)'), $last_sm_quantity > 0 ? $last_sm_quantity : $this->l('N/A'), $last_sm_quantity > 0 ? $last_sm_quantity_is_usable >= 0 ? $this->l('Usable') : $this->l('Not usable') : $this->l('N/A'))), array('type' => 'radio', 'label' => $this->l('Usable for sale?'), 'name' => 'usable', 'required' => true, 'class' => 't', 'is_bool' => true, 'values' => array(array('id' => 'active_on', 'value' => 1, 'label' => $this->l('Enabled')), array('id' => 'active_off', 'value' => 0, 'label' => $this->l('Disabled'))), 'desc' => $this->l('Is this quantity ready to be displayed in your shop, or is it reserved in the warehouse for other purposes?')), array('type' => 'select', 'label' => $this->l('Warehouse:'), 'name' => 'id_warehouse', 'required' => true, 'options' => array('query' => $warehouses_add, 'id' => 'id_warehouse', 'name' => 'name'), 'desc' => $this->l('Please select the warehouse that you\'ll be adding products to. ')), array('type' => 'text', 'label' => $this->l('Unit price (tax excl.):'), 'name' => 'price', 'required' => true, 'size' => 10, 'maxlength' => 10, 'desc' => $this->l('Unit purchase price or unit manufacturing cost for this product (tax excl.)'), 'hint' => sprintf($this->l('Last unit price (tax excl.): %s'), $last_sm_unit_price_te)), array('type' => 'select', 'label' => $this->l('Currency:'), 'name' => 'id_currency', 'required' => true, 'options' => array('query' => $currencies, 'id' => 'id_currency', 'name' => 'name'), 'desc' => $this->l('The currency associated to the product unit price.')), array('type' => 'select', 'label' => $this->l('Label:'), 'name' => 'id_stock_mvt_reason', 'required' => true, 'options' => array('query' => StockMvtReason::getStockMvtReasonsWithFilter($this->context->language->id, array(Configuration::get('PS_STOCK_MVT_TRANSFER_TO')), 1), 'id' => 'id_stock_mvt_reason', 'name' => 'name'), 'desc' => $this->l('Label used in stock movements'))), 'submit' => array('title' => $this->l('Add to stock'), 'class' => 'button'));
$this->fields_value['usable'] = 1;
break;
case 'removestock':
$this->fields_form[]['form'] = array('legend' => array('title' => $this->l('Remove the product from your stock.'), 'image' => '../img/admin/remove_stock.png'), 'input' => array(array('type' => 'hidden', 'name' => 'is_post'), array('type' => 'hidden', 'name' => 'id_product'), array('type' => 'hidden', 'name' => 'id_product_attribute'), array('type' => 'hidden', 'name' => 'check'), array('type' => 'text', 'label' => $this->l('Product reference:'), 'name' => 'reference', 'size' => 30, 'disabled' => true), array('type' => 'text', 'label' => $this->l('EAN13:'), 'name' => 'ean13', 'size' => 15, 'disabled' => true), array('type' => 'text', 'label' => $this->l('Name:'), 'name' => 'name', 'size' => 75, 'disabled' => true), array('type' => 'text', 'label' => $this->l('Quantity to remove:'), 'name' => 'quantity', 'size' => 10, 'maxlength' => 6, 'required' => true, 'desc' => $this->l('Physical quantity to remove')), array('type' => 'radio', 'label' => $this->l('Usable for sale:'), 'name' => 'usable', 'required' => true, 'class' => 't', 'is_bool' => true, 'values' => array(array('id' => 'active_on', 'value' => 1, 'label' => $this->l('Enabled')), array('id' => 'active_off', 'value' => 0, 'label' => $this->l('Disabled'))), 'desc' => $this->l('Do you want to remove this quantity from the usable quantity (yes) or the physical quantity (no)?')), array('type' => 'select', 'label' => $this->l('Warehouse:'), 'name' => 'id_warehouse', 'required' => true, 'options' => array('query' => $warehouses_remove, 'id' => 'id_warehouse', 'name' => 'name'), 'desc' => $this->l('Select the warehouse you\'d like to remove the product from.')), array('type' => 'select', 'label' => $this->l('Label:'), 'name' => 'id_stock_mvt_reason', 'required' => true, 'options' => array('query' => StockMvtReason::getStockMvtReasonsWithFilter($this->context->language->id, array(Configuration::get('PS_STOCK_MVT_TRANSFER_FROM')), -1), 'id' => 'id_stock_mvt_reason', 'name' => 'name'), 'desc' => $this->l('Label used in stock movements'))), 'submit' => array('title' => $this->l('Remove from stock'), 'class' => 'button'));
break;
case 'transferstock':
$this->fields_form[]['form'] = array('legend' => array('title' => $this->l('Transfer a product from one warehouse to another'), 'image' => '../img/admin/transfer_stock.png'), 'input' => array(array('type' => 'hidden', 'name' => 'is_post'), array('type' => 'hidden', 'name' => 'id_product'), array('type' => 'hidden', 'name' => 'id_product_attribute'), array('type' => 'hidden', 'name' => 'check'), array('type' => 'text', 'label' => $this->l('Product reference:'), 'name' => 'reference', 'size' => 30, 'disabled' => true), array('type' => 'text', 'label' => $this->l('EAN13:'), 'name' => 'ean13', 'size' => 15, 'disabled' => true), array('type' => 'text', 'label' => $this->l('Name:'), 'name' => 'name', 'size' => 75, 'disabled' => true), array('type' => 'text', 'label' => $this->l('Quantity to transfer:'), 'name' => 'quantity', 'size' => 10, 'maxlength' => 6, 'required' => true, 'desc' => $this->l('Quantity to transfer:')), array('type' => 'select', 'label' => $this->l('Source Warehouse:'), 'name' => 'id_warehouse_from', 'required' => true, 'options' => array('query' => $warehouses_remove, 'id' => 'id_warehouse', 'name' => 'name'), 'desc' => $this->l('Select the warehouse you\'d like to transfer the product from.')), array('type' => 'radio', 'label' => $this->l('Is this product usable in your source warehouse?'), 'name' => 'usable_from', 'required' => true, 'class' => 't', 'is_bool' => true, 'values' => array(array('id' => 'active_on', 'value' => 1, 'label' => $this->l('Enabled')), array('id' => 'active_off', 'value' => 0, 'label' => $this->l('Disabled'))), 'desc' => $this->l('Is this the usable quantity for sale?')), array('type' => 'select', 'label' => $this->l('Destination warehouse:'), 'name' => 'id_warehouse_to', 'required' => true, 'options' => array('query' => $warehouses_add, 'id' => 'id_warehouse', 'name' => 'name'), 'desc' => $this->l('Select the warehouse you\'d like to transfer your product(s) to. ')), array('type' => 'radio', 'label' => $this->l('Is this product for sale in your destination warehouse?'), 'name' => 'usable_to', 'required' => true, 'class' => 't', 'is_bool' => true, 'values' => array(array('id' => 'active_on', 'value' => 1, 'label' => $this->l('Enabled')), array('id' => 'active_off', 'value' => 0, 'label' => $this->l('Disabled'))), 'desc' => $this->l('Do you want it to be for sale/useable?'))), 'submit' => array('title' => $this->l('Transfer'), 'class' => 'button'));
break;
}
$this->initToolbar();
}
示例6: __construct
public function __construct()
{
$this->context = Context::getContext();
$this->table = 'product';
$this->className = 'Product';
$this->lang = true;
$this->colorOnBackground = true;
$this->multishop_context = Shop::CONTEXT_ALL;
$this->fields_list = array('reference' => array('title' => $this->l('Reference'), 'align' => 'center', 'width' => 200, 'filter_key' => 'a!reference'), 'ean13' => array('title' => $this->l('EAN13'), 'align' => 'center', 'width' => 100, 'filter_key' => 'a!ean13'), 'upc' => array('title' => $this->l('UPC'), 'align' => 'center', 'width' => 100, 'filter_key' => 'a!upc'), 'name' => array('title' => $this->l('Name'), 'filter_key' => 'b!name'), 'qty_sold' => array('title' => $this->l('Quantity sold'), 'width' => 160, 'orderby' => false, 'search' => false, 'hint' => $this->l('Quantity sold during the defined period.')), 'coverage' => array('title' => $this->l('Coverage'), 'width' => 160, 'orderby' => false, 'search' => false, 'hint' => $this->l('Days left before your stock runs out.')), 'stock' => array('title' => $this->l('Quantity'), 'width' => 80, 'orderby' => false, 'search' => false, 'hint' => $this->l('Physical (usable) quantity.')));
// pre-defines coverage periods
$this->stock_cover_periods = array($this->l('One week') => 7, $this->l('Two weeks') => 14, $this->l('Three weeks') => 21, $this->l('One month') => 31, $this->l('Six months') => 186, $this->l('One year') => 365);
// gets the list of warehouses available
$this->stock_cover_warehouses = Warehouse::getWarehouses(true);
// gets the final list of warehouses
array_unshift($this->stock_cover_warehouses, array('id_warehouse' => -1, 'name' => $this->l('All Warehouses')));
parent::__construct();
}
示例7: process
//.........这里部分代码省略.........
return new Carton($this->data->id, $session->warehouseId);
}
break;
case 'addCarton':
$locationId = null;
$paletteId = null;
if (isset($this->data->location)) {
$locationId = $this->data->location;
}
if (isset($this->data->palette)) {
$paletteId = $this->data->palette;
}
$carton = new Carton(null, $session->warehouseId, $locationId, $paletteId);
return $carton->id;
case 'deleteCarton':
if (isset($this->data->id)) {
$carton = new Carton($this->data->id, $session->warehouseId);
return $carton->delete();
}
break;
case 'editCarton':
if (isset($this->data->id)) {
$carton = new Carton($this->data->id, $session->warehouseId);
if (isset($this->data->location)) {
$carton->locationId = $this->data->location;
} else {
$carton->locationId = null;
}
if (isset($this->data->palette)) {
$carton->paletteId = $this->data->palette;
} else {
$carton->paletteId = null;
}
return $carton->edit();
}
break;
case 'addArticle':
if (isset($this->data->carton) && isset($this->data->category) && isset($this->data->amount)) {
return Stock::addArticle($this->data->carton, $this->data->category, isset($this->data->male) ? $this->data->male : false, isset($this->data->female) ? $this->data->female : false, isset($this->data->children) ? $this->data->children : false, isset($this->data->baby) ? $this->data->baby : false, isset($this->data->winter) ? $this->data->winter : false, isset($this->data->summer) ? $this->data->summer : false, $this->data->amount >= 0 ? $this->data->amount : 0, $this->data->amount < 0 ? $this->data->amount : 0);
}
break;
case 'getStock':
return Stock::getStock($session->warehouseId, isset($this->data->carton) ? $this->data->carton : null, isset($this->data->category) ? $this->data->category : null, isset($this->data->palette) ? $this->data->palette : null, isset($this->data->location) ? $this->data->location : null, isset($this->data->male) ? $this->data->male : false, isset($this->data->female) ? $this->data->female : false, isset($this->data->children) ? $this->data->children : false, isset($this->data->baby) ? $this->data->male : false, isset($this->data->summer) ? $this->data->male : false, isset($this->data->winter) ? $this->data->male : false, isset($this->data->details) ? $this->data->details : false);
case 'getBarcodeUri':
if (isset($this->data->text)) {
// create barcode object
$bc = new Barcode39($this->data->text);
if (isset($this->data->textSize)) {
$bc->barcode_text_size = $this->data->textSize;
}
if (isset($this->data->barThin)) {
$bc->barcode_bar_thin = $this->data->barThin;
}
if (isset($this->data->barThick)) {
$bc->barcode_bar_thick = $this->data->barThick;
}
// generate barcode image
$img = "barcode_" . mt_rand(0, 100) . ".png";
$bc->draw($img);
// get data uri
$uri = Barcode39::getDataURI($img);
unlink($img);
return $uri;
}
break;
}
} else {
// process unrestricted function
switch ($this->f) {
case 'getActiveSessions':
return Session::getActiveSessionsNumber();
case 'getWarehouses':
return Warehouse::getWarehouses();
case 'addWarehouse':
$data = $this->data;
if (isset($data->name) && isset($data->description) && isset($data->country) && isset($data->city) && isset($data->password) && isset($data->mail)) {
$warehouse = new Warehouse();
Log::debug('new warehouse' . $warehouse->id);
$warehouse->name = $data->name;
$warehouse->description = $data->description;
$warehouse->country = $data->country;
$warehouse->city = $data->city;
$warehouse->setPassword($data->password);
$warehouse->setMail($data->mail);
return $warehouse->edit();
}
break;
case 'getCountries':
return getCountries();
break;
case 'getCountryCode':
$data = $this->data;
if (isset($data->name)) {
return getCountryCode(null, $data->name);
}
return false;
}
}
return false;
}
示例8: renderForm
public function renderForm()
{
// loads current warehouse
if (!$this->loadObject(true)) {
return;
}
// get the current warehouse areas
$zones = ErpZone::getZonesByWarehouse(Tools::getValue('id_warehouse'));
array_unshift($zones, array('name' => $this->l('Home'), 'id_erpip_zone' => 0));
// gets warehouses
$warehouses_add = Warehouse::getWarehouses(true);
// displays warning if no warehouses
if (!$warehouses_add) {
$this->displayWarning($this->l('You must choose a warehouse before adding areas. See Stock/Warehouses'));
}
// Default values
if (Tools::isSubmit('id_zone_parent') && Tools::getValue('id_zone_parent') != '') {
$this->fields_value['id_parent'] = Tools::getValue('id_zone_parent');
}
if (Tools::isSubmit('id_warehouse') && Tools::getValue('id_warehouse') != '') {
$this->fields_value['id_warehouse'] = Tools::getValue('id_warehouse');
}
$this->fields_value['active'] = true;
// form fields définition
// Name
$base = array(array('type' => 'text', 'label' => $this->l('Name'), 'name' => 'name', 'size' => 40, 'required' => true, 'hint' => $this->l('Invalid characters:') . ' <>;=#{}'));
// warehouse
// select warehouse only if create area level 1
if (Tools::getValue('id_zone_parent') == '' && Tools::getValue('id_warehouse') == '') {
$warehouse = array(array('type' => 'select', 'label' => $this->l('Warehouse'), 'name' => 'id_warehouse', 'class' => 'chosen', 'required' => true, 'options' => array('query' => $warehouses_add, 'id' => 'id_warehouse', 'name' => 'name')));
} else {
$warehouse = array(array('type' => 'text', 'label' => $this->l('Warehouse'), 'name' => 'warehouse_name', 'disabled' => true, 'size' => 40, 'required' => true), array('type' => 'hidden', 'name' => 'id_warehouse', 'required' => true));
}
// Show area (level1) and select active/inactive
// If we re on an create area (lvl1) --> set used variables by helperform on home (force to create a new area)
if (Tools::getValue('id_parent') == '' && Tools::getValue('id_zone_parent') == '') {
$_GET['zone_name'] = 'Accueil';
$_GET['id_parent'] = '0';
}
$areaAndActive = array(array('type' => 'text', 'label' => $this->l('Parent zone'), 'name' => 'zone_name', 'disabled' => true, 'size' => 40, 'required' => true), array('type' => 'hidden', 'name' => 'id_parent', 'required' => true), array('type' => $this->is_1_6 ? 'switch' : 'radio', 'label' => $this->l('Enable:'), 'name' => 'active', 'required' => false, 'class' => 't', 'is_bool' => true, 'values' => array(array('id' => 'active_on', 'value' => 1, 'label' => $this->l('Enabled')), array('id' => 'active_off', 'value' => 0, 'label' => $this->l('Disabled')))));
// full form
$this->fields_form = array('legend' => array('title' => $this->l('Add or edit an area'), 'image' => '../img/admin/suppliers.gif'), 'input' => array_merge($base, $warehouse, $areaAndActive), 'submit' => array('title' => $this->l(' Save ')));
return parent::renderForm();
}
示例9: postProcess
public function postProcess()
{
// Warehouse
$warehouses = Warehouse::getWarehouses(true);
// if we already pick a warehouse source and location, we filter on twice to not display selections of the other
if (Tools::isSubmit('warehouseA') && Tools::getValue('warehouseA') != -1 && Tools::isSubmit('warehouseB') && Tools::getValue('warehouseB') != -1) {
$warehouseA = Tools::getValue('warehouseA');
$warehouseB = Tools::getValue('warehouseB');
$warehousesA = array();
$warehousesB = array();
foreach ($warehouses as $warehouse) {
if ($warehouse['id_warehouse'] != $warehouseA) {
array_push($warehousesB, $warehouse);
}
if ($warehouse['id_warehouse'] != $warehouseB) {
array_push($warehousesA, $warehouse);
}
}
} elseif (Tools::isSubmit('warehouseA') && Tools::getValue('warehouseA') != -1) {
$warehouseA = Tools::getValue('warehouseA');
$warehousesB = array();
foreach ($warehouses as $warehouse) {
if ($warehouse['id_warehouse'] != $warehouseA) {
array_push($warehousesB, $warehouse);
}
}
$warehousesA = $warehouses;
// Restaure B list on no selection
$this->context->smarty->assign(array('warehouseB' => -1));
} elseif (Tools::isSubmit('warehouseB') && Tools::getValue('warehouseB') != -1) {
$warehouseB = Tools::getValue('warehouseB');
$warehousesA = array();
foreach ($warehouses as $warehouse) {
if ($warehouse['id_warehouse'] != $warehouseB) {
array_push($warehousesA, $warehouse);
}
}
$warehousesB = $warehouses;
} else {
$warehousesA = $warehouses;
$warehousesB = $warehouses;
}
// validate_transfer
if (Tools::isSubmit('validate_transfer')) {
$transfer_ok = false;
if (Tools::isSubmit('id_stockA') && Tools::isSubmit('id_stockB') && Tools::isSubmit('id_employee') && Tools::isSubmit('firstname') && Tools::isSubmit('lastname') && Tools::isSubmit('values')) {
// After transfert, delete cookies to get a blank display
if (Tools::isSubmit('deleteCookie')) {
$cookie = new Cookie('psAdmin');
$cookie->warehouseA = '';
$cookie->warehouseB = '';
}
/* Initialisation */
$ids_mvt = array();
// Call the helper "traducteur" of the chain transfert
require_once _PS_MODULE_DIR_ . 'erpillicopresta/classes/helpers/StockTransferHelper.php';
require_once _PS_MODULE_DIR_ . 'erpillicopresta/classes/stock/ErpStock.php';
$values = StockTransferHelper::getTransfertDataAsArray(Tools::getValue('values'));
/* For each movement recorded */
foreach ($values as $value) {
$id_product = $value['id_product'];
$id_product_attribute = $value['id_product_attribute'];
$transfer_quantity = $value['quantity'];
$id_stock_s1 = $value['id_stock_s1'];
$id_stock_s2 = $value['id_stock_s2'];
if (empty($id_stock_s1)) {
$this->errors[] = 'Error while updating the stock for a product : stock id missing !';
return true;
}
// update stock un warehouse A (source)
$stock = new ErpStock((int) $id_stock_s1);
$stock->physical_quantity -= $transfer_quantity;
$stock->usable_quantity -= $transfer_quantity;
if ($stock->physical_quantity < 0) {
$stock->physical_quantity = 0;
}
if ($stock->usable_quantity < 0) {
$stock->usable_quantity = 0;
}
/* Update Stock */
if ($stock->update()) {
/* Movment A to B */
$stock_mvt = new ErpStockMvt();
$stock_mvt->id_stock = $stock->id;
$stock_mvt->id_order = 0;
$stock_mvt->id_supply_order = 0;
$stock_mvt->id_stock_mvt_reason = 6;
$stock_mvt->id_employee = Tools::getValue('id_employee');
$stock_mvt->employee_firstname = Tools::getValue('firstname');
$stock_mvt->employee_lastname = Tools::getValue('lastname');
$stock_mvt->price_te = $stock->getPriceTe();
$stock_mvt->current_wa = $stock->getPriceTe();
$stock_mvt->sign = -1;
$stock_mvt->physical_quantity = $transfer_quantity;
// if movment OK, update stock in B warehouse (location)
if ($stock_mvt->add(true)) {
// add id movment stock generated (useful to generate the warehouse delivery notice)
array_push($ids_mvt, $stock_mvt->getLastId());
if ((int) $id_stock_s2 > 0) {
$stock_s2 = new ErpStock((int) $id_stock_s2);
//.........这里部分代码省略.........
示例10: renderForm
/**
* AdminController::renderForm() override
* @see AdminController::renderForm()
*/
public function renderForm()
{
if (Tools::isSubmit('addsupply_order') || Tools::isSubmit('updatesupply_order') || Tools::isSubmit('submitAddsupply_order') || Tools::isSubmit('submitUpdatesupply_order')) {
if (Tools::isSubmit('addsupply_order') || Tools::isSubmit('submitAddsupply_order')) {
$this->toolbar_title = $this->l('Stock: Create a new supply order');
}
$update = false;
if (Tools::isSubmit('updatesupply_order') || Tools::isSubmit('submitUpdatesupply_order')) {
$this->toolbar_title = $this->l('Stock: Manage supply orders');
$update = true;
}
if (Tools::isSubmit('mod') && Tools::getValue('mod') === 'template' || $this->object->is_template) {
$this->toolbar_title .= ' (' . $this->l('template') . ')';
}
$this->addJqueryUI('ui.datepicker');
//get warehouses list
$warehouses = Warehouse::getWarehouses(true);
// displays warning if there are no warehouses
if (!$warehouses) {
$this->displayWarning($this->l('You must have at least one warehouse. See Stock/Warehouses'));
}
//get currencies list
$currencies = Currency::getCurrencies(false, true, true);
//get suppliers list
$suppliers = array_unique(Supplier::getSuppliers(), SORT_REGULAR);
//get languages list
$languages = Language::getLanguages(true);
$this->fields_form = array('legend' => array('title' => $this->l('Order information'), 'icon' => 'icon-pencil'), 'input' => array(array('type' => 'text', 'label' => $this->l('Reference'), 'name' => 'reference', 'required' => true, 'hint' => $this->l('The reference number for your order.')), array('type' => 'select', 'label' => $this->l('Supplier'), 'name' => 'id_supplier', 'required' => true, 'options' => array('query' => $suppliers, 'id' => 'id_supplier', 'name' => 'name'), 'hint' => array($this->l('Select the supplier you\'ll be purchasing from.'), $this->l('Warning: All products already added to the order will be removed.'))), array('type' => 'select', 'label' => $this->l('Warehouse'), 'name' => 'id_warehouse', 'required' => true, 'options' => array('query' => $warehouses, 'id' => 'id_warehouse', 'name' => 'name'), 'hint' => $this->l('Which warehouse will the order be sent to?')), array('type' => 'select', 'label' => $this->l('Currency'), 'name' => 'id_currency', 'required' => true, 'options' => array('query' => $currencies, 'id' => 'id_currency', 'name' => 'name'), 'hint' => array($this->l('The currency of the order.'), $this->l('Warning: All products already added to the order will be removed.'))), array('type' => 'select', 'label' => $this->l('Order Language'), 'name' => 'id_lang', 'required' => true, 'options' => array('query' => $languages, 'id' => 'id_lang', 'name' => 'name'), 'hint' => $this->l('The language of the order.')), array('type' => 'text', 'label' => $this->l('Global discount percentage'), 'name' => 'discount_rate', 'required' => false, 'hint' => $this->l('This is the global discount percentage for the order.')), array('type' => 'text', 'label' => $this->l('Automatically load products'), 'name' => 'load_products', 'required' => false, 'hint' => array($this->l('This will reset the order.'), $this->l('If a value specified, each of your current product (from the selected supplier and warehouse) with a quantity lower than or equal to this value will be loaded. This means that PrestaShop will pre-fill this order with the products that are low on quantity.')))), 'submit' => !$update ? array('title' => $this->l('Save order')) : array(), 'buttons' => !$update ? array('save-and-stay' => array('title' => $this->l('Save order and stay'), 'name' => 'submitAddsupply_orderAndStay', 'type' => 'submit', 'class' => 'btn btn-default pull-right', 'icon' => 'process-icon-save')) : array());
if (Tools::isSubmit('mod') && Tools::getValue('mod') === 'template' || $this->object->is_template) {
$this->fields_form['input'][] = array('type' => 'hidden', 'name' => 'is_template');
$this->fields_form['input'][] = array('type' => 'hidden', 'name' => 'date_delivery_expected');
} else {
$this->fields_form['input'][] = array('type' => 'date', 'label' => $this->l('Expected delivery date'), 'name' => 'date_delivery_expected', 'required' => true, 'desc' => $this->l('The expected delivery date for this order is...'));
}
//specific discount display
if (isset($this->object->discount_rate)) {
$this->object->discount_rate = Tools::ps_round($this->object->discount_rate, 4);
}
//specific date display
if (isset($this->object->date_delivery_expected)) {
$date = explode(' ', $this->object->date_delivery_expected);
if ($date) {
$this->object->date_delivery_expected = $date[0];
}
}
$this->displayInformation($this->l('If you wish to order products, they have to be available for the specified supplier/warehouse.') . ' ' . $this->l('See Catalog/Products/[Your Product]/Suppliers & Warehouses.') . '<br />' . $this->l('Changing the currency or the supplier will reset the order.') . '<br />' . '<br />' . $this->l('Please note that you can only order from one supplier at a time.'));
return parent::renderForm();
}
}
示例11: synchronize
public static function synchronize($id_product, $order_id_shop = null)
{
if (!Validate::isUnsignedId($id_product)) {
return false;
}
if (Pack::isPack($id_product)) {
if (Validate::isLoadedObject($product = new Product((int) $id_product))) {
if ($product->pack_stock_type == 1 || $product->pack_stock_type == 2 || $product->pack_stock_type == 3 && Configuration::get('PS_PACK_STOCK_TYPE') > 0) {
$products_pack = Pack::getItems($id_product, (int) Configuration::get('PS_LANG_DEFAULT'));
foreach ($products_pack as $product_pack) {
StockAvailable::synchronize($product_pack->id, $order_id_shop);
}
}
} else {
return false;
}
}
$ids_warehouse = Warehouse::getWarehousesGroupedByShops();
if ($order_id_shop !== null) {
$order_warehouses = array();
$wh = Warehouse::getWarehouses(false, (int) $order_id_shop);
foreach ($wh as $warehouse) {
$order_warehouses[] = $warehouse['id_warehouse'];
}
}
$ids_product_attribute = array();
foreach (Product::getProductAttributesIds($id_product) as $id_product_attribute) {
$ids_product_attribute[] = $id_product_attribute['id_product_attribute'];
}
$out_of_stock = StockAvailable::outOfStock($id_product);
$manager = StockManagerFactory::getManager();
foreach ($ids_warehouse as $id_shop => $warehouses) {
if (StockAvailable::dependsOnStock($id_product, $id_shop)) {
$product_quantity = 0;
if (empty($ids_product_attribute)) {
$allowed_warehouse_for_product = WareHouse::getProductWarehouseList((int) $id_product, 0, (int) $id_shop);
$allowed_warehouse_for_product_clean = array();
foreach ($allowed_warehouse_for_product as $warehouse) {
$allowed_warehouse_for_product_clean[] = (int) $warehouse['id_warehouse'];
}
$allowed_warehouse_for_product_clean = array_intersect($allowed_warehouse_for_product_clean, $warehouses);
if ($order_id_shop != null && !count(array_intersect($allowed_warehouse_for_product_clean, $order_warehouses))) {
continue;
}
$product_quantity = $manager->getProductRealQuantities($id_product, null, $allowed_warehouse_for_product_clean, true);
Hook::exec('actionUpdateQuantity', array('id_product' => $id_product, 'id_product_attribute' => 0, 'quantity' => $product_quantity));
} else {
foreach ($ids_product_attribute as $id_product_attribute) {
$allowed_warehouse_for_combination = WareHouse::getProductWarehouseList((int) $id_product, (int) $id_product_attribute, (int) $id_shop);
$allowed_warehouse_for_combination_clean = array();
foreach ($allowed_warehouse_for_combination as $warehouse) {
$allowed_warehouse_for_combination_clean[] = (int) $warehouse['id_warehouse'];
}
$allowed_warehouse_for_combination_clean = array_intersect($allowed_warehouse_for_combination_clean, $warehouses);
if ($order_id_shop != null && !count(array_intersect($allowed_warehouse_for_combination_clean, $order_warehouses))) {
continue;
}
$quantity = $manager->getProductRealQuantities($id_product, $id_product_attribute, $allowed_warehouse_for_combination_clean, true);
$query = new DbQuery();
$query->select('COUNT(*)');
$query->from('stock_available');
$query->where('id_product = ' . (int) $id_product . ' AND id_product_attribute = ' . (int) $id_product_attribute . StockAvailable::addSqlShopRestriction(null, $id_shop));
if ((int) Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($query)) {
$query = array('table' => 'stock_available', 'data' => PP::hydrateQty(array(), 'quantity', $quantity), 'where' => 'id_product = ' . (int) $id_product . ' AND id_product_attribute = ' . (int) $id_product_attribute . StockAvailable::addSqlShopRestriction(null, $id_shop));
Db::getInstance()->update($query['table'], $query['data'], $query['where']);
} else {
$query = array('table' => 'stock_available', 'data' => PP::hydrateQty(array('depends_on_stock' => 1, 'out_of_stock' => $out_of_stock, 'id_product' => (int) $id_product, 'id_product_attribute' => (int) $id_product_attribute), 'quantity', $quantity));
StockAvailable::addSqlShopParams($query['data']);
Db::getInstance()->insert($query['table'], $query['data']);
}
$product_quantity += $quantity;
Hook::exec('actionUpdateQuantity', array('id_product' => $id_product, 'id_product_attribute' => $id_product_attribute, 'quantity' => $quantity));
}
}
$query = array('table' => 'stock_available', 'data' => PP::hydrateQty(array(), 'quantity', $product_quantity), 'where' => 'id_product = ' . (int) $id_product . ' AND id_product_attribute = 0' . StockAvailable::addSqlShopRestriction(null, $id_shop));
Db::getInstance()->update($query['table'], $query['data'], $query['where']);
}
}
if (count($ids_warehouse) == 0 && StockAvailable::dependsOnStock((int) $id_product)) {
Db::getInstance()->update('stock_available', array('quantity' => 0, 'quantity_remainder' => 0), 'id_product = ' . (int) $id_product);
}
Cache::clean('StockAvailable::getQuantityAvailableByProduct_' . (int) $id_product . '*');
}
示例12: getCustomListInstantStock
public function getCustomListInstantStock()
{
$this->context = Context::getContext();
$this->lang = false;
$this->multishop_context = Shop::CONTEXT_ALL;
$this->list_no_link = true;
$this->show_toolbar = true;
// retrieving the type of inventory management and send to template
$this->advanced_stock_management = Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT');
$this->context->smarty->assign(array('advanced_stock_management' => $this->advanced_stock_management));
// smarty values
$this->context->smarty->assign(array('advanced_stock_management' => $this->advanced_stock_management, 'warehouses' => Warehouse::getWarehouses(), 'categories' => Category::getSimpleCategories((int) $this->context->language->id), 'suppliers' => Supplier::getSuppliers(), 'manufacturers' => Manufacturer::getManufacturers(), 'controller_status' => $this->controller_status, 'quantity_filter' => 0, 'tokens' => array(array('value' => '=', 'label' => $this->l('Equal')), array('value' => '>', 'label' => $this->l('Strictly greater than')), array('value' => '<', 'label' => $this->l('Strictly less than'))), 'list' => 'first'));
// if advanced stock, we work in stock table
if ($this->advanced_stock_management) {
$this->table = 'product';
$this->className = 'Product';
$this->identifier = 'id_product';
$this->_orderBy = 'id_product';
// determination of the warehouse, if no selected warehouse, select the first
if (($id_warehouse = $this->getCurrentValue('id_warehouse')) == false) {
$id_warehouse = -1;
}
$this->fields_list = array('ids' => array('title' => $this->l('#'), 'search' => false), 'name' => array('title' => $this->l('Name'), 'havingFilter' => true, 'width' => 200, 'callback' => 'renderNameColumn'), 'reference' => array('title' => $this->l('Reference'), 'align' => 'center', 'width' => 50, 'havingFilter' => true), 'first_supplier_ref' => array('title' => $this->l('Supplier reference'), 'search' => false, 'callback' => 'renderFirstSupplierRefColumn'), 'category_name' => array('title' => $this->l('Categorie'), 'search' => false, 'callback' => 'renderCategoryNameColumn'), 'manufacturer' => array('title' => $this->l('Manufacturer'), 'search' => false), 'first_supplier_price' => array('title' => $this->l('Supplier price'), 'width' => 80, 'orderby' => true, 'search' => false, 'align' => 'right', 'callback' => 'renderSupplierPriceColumn'), 'price' => array('title' => $this->l('Price(te)'), 'width' => 80, 'orderby' => true, 'search' => false, 'type' => 'price', 'align' => 'right'), 'price_ttc' => array('title' => $this->l('Price(ti)'), 'width' => 80, 'type' => 'price', 'search' => false, 'align' => 'right', 'orderby' => false), 'valuation' => array('title' => $this->l('Valuation'), 'width' => 150, 'orderby' => false, 'search' => false, 'type' => 'price', 'currency' => true, 'hint' => $this->l('Total value of the physical quantity. The sum (for all prices) is not available for all warehouses, please filter by warehouse.')), 'physical_quantity' => array('title' => $this->l('Physical quantity'), 'width' => 50, 'search' => false, 'align' => 'right'), 'usable_quantity' => array('title' => $this->l('Usable quantity'), 'width' => 50, 'search' => false, 'align' => 'right'), 'real_quantity' => array('title' => $this->l('Real quantity'), 'width' => 50, 'align' => 'right', 'hint' => $this->l('Physical quantity (usable) - Customer orders + suppliers orders'), 'search' => false, 'orderby' => false), 'advanced_stock_management' => array('title' => $this->l('Stock management'), 'width' => 70, 'align' => 'center', 'hint' => $this->l('Adv stock mgt ? (Product->Quantities)'), 'search' => false, 'callback' => 'renderAdvancedStockManagementColumn'));
if ($this->controller_status) {
$this->fields_list = array_merge($this->fields_list, array('id_product' => array('title' => $this->l('Location'), 'width' => 70, 'align' => 'center', 'search' => false, 'class' => 'location_column', 'callback' => 'renderLocationColumn', 'orderby' => false)));
}
// building query
$this->_select = ' IFNULL(CONCAT(pl.name, \' : \', GROUP_CONCAT(DISTINCT agl.`name`, \' - \', al.name SEPARATOR \', \')),pl.name) as name,
IFNULL(CONCAT(a.id_product, ";", pa.id_product_attribute), a.id_product) as ids,
ps.product_supplier_reference as first_supplier_ref,
ps.product_supplier_price_te as first_supplier_price,
w.id_currency,
cl.name as category_name,
m.name as manufacturer,
if (pa.wholesale_price = 0.000000, a.wholesale_price, pa.wholesale_price) as wholesale_price,
IFNULL(pa.reference, a.reference) as reference,
pa.price as price_attribute,
a.price as price_product,
a.id_tax_rules_group,
IFNULL(pa.id_product_attribute, 0) as id_product_attribute,
wpl.id_warehouse_product_location,
ewpl.id_erpip_warehouse_product_location,
area.id_erpip_zone as id_area,
area.name as area_name,
sub_area.id_erpip_zone as id_sub_area,
sub_area.name as sub_area_name,
wpl.location as location';
$this->_group = 'GROUP BY a.id_product, pa.id_product_attribute';
$this->_join .= 'LEFT JOIN ' . _DB_PREFIX_ . 'product_attribute pa ON a.id_product = pa.id_product ';
$this->_join .= ' LEFT JOIN `' . _DB_PREFIX_ . 'product_lang` pl ON (
a.id_product = pl.id_product
AND pl.id_lang = ' . (int) $this->context->language->id . '
)';
$this->_join .= ' LEFT JOIN `' . _DB_PREFIX_ . 'product_attribute_combination` pac ON (pac.id_product_attribute = pa.id_product_attribute)';
$this->_join .= ' LEFT JOIN `' . _DB_PREFIX_ . 'attribute` atr ON (atr.id_attribute = pac.id_attribute)';
$this->_join .= ' LEFT JOIN `' . _DB_PREFIX_ . 'attribute_lang` al ON (
al.id_attribute = pac.id_attribute
AND al.id_lang = ' . (int) $this->context->language->id . '
)';
$this->_join .= ' LEFT JOIN `' . _DB_PREFIX_ . 'attribute_group_lang` agl ON (
agl.id_attribute_group = atr.id_attribute_group
AND agl.id_lang = ' . (int) $this->context->language->id . '
)';
$this->_join .= 'LEFT JOIN ' . _DB_PREFIX_ . 'stock s ON (a.id_product = s.id_product AND s.id_product_attribute = IFNULL(pa.id_product_attribute, 0)';
//Si le filtre par entrepôt a été sélectionné, alors il ne faut prendre les quantités que dans cet entrepôt
if ($id_warehouse != -1) {
$this->_join .= 'AND s.id_warehouse = ' . $id_warehouse;
}
$this->_join .= ') ';
$this->_join .= 'LEFT JOIN ' . _DB_PREFIX_ . 'warehouse_product_location wpl ON (wpl.id_product = a.id_product AND wpl.id_product_attribute = IFNULL(pa.id_product_attribute, 0)) ';
if ($id_warehouse != -1) {
$this->_join .= ' AND wpl.id_warehouse=' . $id_warehouse . ' ';
}
$this->_join .= 'LEFT JOIN ' . _DB_PREFIX_ . 'erpip_warehouse_product_location ewpl ON wpl.id_warehouse_product_location = ewpl.id_warehouse_product_location ';
$this->_join .= 'LEFT JOIN ' . _DB_PREFIX_ . 'erpip_zone area ON area.id_erpip_zone = ewpl.id_zone_parent ';
$this->_join .= 'LEFT JOIN ' . _DB_PREFIX_ . 'erpip_zone sub_area ON sub_area.id_erpip_zone = ewpl.id_zone ';
$this->_join .= 'LEFT JOIN `' . _DB_PREFIX_ . 'warehouse` w ON (w.id_warehouse = s.id_warehouse) ';
$this->_join .= 'INNER JOIN ' . _DB_PREFIX_ . 'category_lang cl ON (a.id_category_default = cl.id_category AND cl.id_lang = ' . (int) $this->context->language->id . ')';
$this->_join .= 'LEFT JOIN ' . _DB_PREFIX_ . 'manufacturer m ON m.id_manufacturer = a.id_manufacturer ';
$this->_join .= 'LEFT JOIN ' . _DB_PREFIX_ . 'product_supplier ps ON
ps.id_product = a.id_product
AND ps.id_product_attribute = IFNULL(pa.id_product_attribute,0) ';
$this->context->smarty->assign(array('sub_title' => $this->l('List of products available in stock')));
// SPECIFIC FILTER
$area = $this->getCurrentValue('area');
$subarea = $this->getCurrentValue('subarea');
if ($id_warehouse > 0) {
// treatment of filters
$this->context->smarty->assign(array('areas' => ErpZone::getZonesName($id_warehouse), 'sub_areas' => $area ? ErpZone::getZonesName($id_warehouse, 'sub_area', $area) : array(), 'id_warehouse' => $id_warehouse));
}
// If area and sub area specified, filter on warehouse, area and subarea
if ($area != false && $subarea != false) {
$this->_where .= ' AND (s.id_warehouse = ' . $id_warehouse . ' OR wpl.id_warehouse=' . $id_warehouse . ')
AND area.id_erpip_zone = "' . (int) $area . '" AND sub_area.id_erpip_zone = ' . (int) $subarea;
} elseif ($area != false) {
$this->_where .= ' AND (s.id_warehouse = ' . $id_warehouse . ' OR wpl.id_warehouse=' . $id_warehouse . ')
AND area.id_erpip_zone = ' . (int) $area;
} else {
// if id = -1 :no filter because all warehouse
if ($id_warehouse != -1) {
//.........这里部分代码省略.........
示例13: renderDetails
public function renderDetails()
{
if (Tools::isSubmit('id_product')) {
// override attributes
$this->identifier = 'id_product_attribute';
$this->list_id = 'product_attribute';
$this->lang = false;
$this->addRowAction('addstock');
$this->addRowAction('removestock');
if (count(Warehouse::getWarehouses()) > 1) {
$this->addRowAction('transferstock');
}
// no link on list rows
$this->list_no_link = true;
// inits toolbar
$this->toolbar_btn = array();
// get current lang id
$lang_id = (int) $this->context->language->id;
// Get product id
$product_id = (int) Tools::getValue('id_product');
// Load product attributes with sql override
$this->table = 'product_attribute';
$this->list_id = 'product_attribute';
$this->_select = 'a.id_product_attribute as id, a.id_product, a.reference, a.ean13, a.upc';
$this->_where = 'AND a.id_product = ' . $product_id;
$this->_group = 'GROUP BY a.id_product_attribute';
$this->fields_list = array('reference' => array('title' => $this->l('Product reference'), 'filter_key' => 'a!reference'), 'ean13' => array('title' => $this->l('EAN-13 or JAN barcode'), 'filter_key' => 'a!ean13'), 'upc' => array('title' => $this->l('UPC barcode'), 'filter_key' => 'a!upc'), 'name' => array('title' => $this->l('Name'), 'orderby' => false, 'filter' => false, 'search' => false), 'stock' => array('title' => $this->l('Quantity'), 'orderby' => false, 'filter' => false, 'search' => false, 'class' => 'fixed-width-sm', 'align' => 'center', 'hint' => $this->l('Quantitity total for all warehouses.')));
self::$currentIndex = self::$currentIndex . '&id_product=' . (int) $product_id . '&detailsproduct';
$this->processFilter();
return parent::renderList();
}
}
示例14: initContent
/**
* AdminController::initContent() override
* @see AdminController::initContent()
*/
public function initContent()
{
$this->addJqueryUI('ui.dialog');
$this->addjqueryPlugin('cluetip');
$this->addJqueryUI('ui.datepicker');
$this->addJS(_MODULE_DIR_ . 'erpillicopresta/js/advanced_supply_order.js');
$this->addJS(_MODULE_DIR_ . 'erpillicopresta/js/advanced_supply_order_tools.js');
if (!Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT')) {
$this->warnings[md5('PS_ADVANCED_STOCK_MANAGEMENT')] = $this->l('You need to activate advanced stock management prior to using this feature. (Preferences/Products/Products Stock)');
return false;
}
// displays warning if there are no warehouses
if (!Warehouse::getWarehouses(true)) {
$this->warnings[md5('PS_ADVANCED_STOCK_MANAGEMENT')] = $this->l('You must have at least one warehouse. See Stock/Warehouses');
return false;
}
// Manage the add stock form
if (Tools::isSubmit('changestate')) {
$this->initChangeStateContent();
} elseif (Tools::isSubmit('update_receipt') && Tools::isSubmit('id_supply_order')) {
$this->initUpdateReceiptContent();
} elseif (Tools::isSubmit('viewsupply_order') && Tools::isSubmit('id_supply_order')) {
$this->action = 'view';
$this->display = 'view';
parent::initContent();
} elseif (Tools::isSubmit('updatesupply_order')) {
$this->initUpdateSupplyOrderContent();
} else {
parent::initContent();
}
}
示例15: initSimulateContent
public function initSimulateContent()
{
$this->show_toolbar = false;
// change the display type in order to add specific actions to
$this->display = 'simulate';
if ($this->is_1_6) {
$this->initPageHeaderToolbar();
}
$this->initToolbar();
$result = $this->renderProductSimulationList();
$this->context->smarty->assign(array('content' => $result['content'], 'nbr_commande_genere' => $result['nbr_commande_genere'], 'show_toolbar ' => 'true', 'show_toolbar' => true, 'toolbar_btn' => $this->toolbar_btn, 'title' => $this->l('1 Click ERP ILLICOPRESTA'), 'toolbar_scroll' => $this->toolbar_scroll, 'token' => $this->token, 'warehouses' => Warehouse::getWarehouses(true), 'id_default_currency' => Configuration::get('PS_CURRENCY_DEFAULT'), 'current_date' => date('Y-m-d'), 'url_post' => self::$currentIndex . '&token=' . $this->token, 'url_post_ordering' => $this->context->link->getAdminLink('AdminGenerateSupplyOrders') . '&submitOrdering'));
$this->createTemplate('simulate.tpl');
$this->template = 'simulate.tpl';
}