本文整理汇总了PHP中Warehouse类的典型用法代码示例。如果您正苦于以下问题:PHP Warehouse类的具体用法?PHP Warehouse怎么用?PHP Warehouse使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Warehouse类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: login
/**
* Tries to login.
* @param session id if logged in successfull, false otherwise.
*/
public function login()
{
// get warehouse
$warehouse = new Warehouse($this->warehouseId);
$vSession = false;
if ($warehouse->checkPassword($this->pw)) {
$vSession = new Session($warehouse->id, true, false);
} elseif ($warehouse->checkPasswordRestricted($this->pw)) {
$vSession = new Session($warehouse->id, true);
}
return $vSession;
}
示例2: getWarehouseList
public function getWarehouseList()
{
/* Load Model of warehouses and setup the list */
App::import('Model', 'Warehouse');
$warehouse = new Warehouse();
/* Set conditions */
$options = array('fields' => array('City.city_name', 'Warehouse.warehouse_name', 'Warehouse.id'), 'joins' => array(array('alias' => 'City', 'table' => 'cities', 'type' => 'LEFT', 'conditions' => array('City.id = WarehouseDesc.city_id'))), 'conditions' => array('WarehouseDesc.is_deleted' => 0));
$getWarehouseAllWithStatus = $warehouse->find('all', $options);
$newWarehouseList = array();
if ($warehouse->find('count') > 0) {
foreach ($getWarehouseAllWithStatus as $index => $value) {
$newWarehouseList[$value["Warehouse"]["id"]] = $value["Warehouse"]["warehouse_name"] . " (" . $value["City"]["city_name"] . ")";
}
}
return $getWarehouseList = $newWarehouseList;
}
示例3: 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();
}
示例4: testClosestWarehouse
function testClosestWarehouse()
{
$warehouse = Warehouse::closest_to($this->objFromFixture("Address", "customeraddress1"));
$this->assertEquals("Main warehouse", $warehouse->Title);
$warehouse = Warehouse::closest_to($this->objFromFixture("Address", "customeraddress2"));
$this->assertEquals("NSW depot", $warehouse->Title);
}
示例5: getWarehouseList
public function getWarehouseList()
{
/* Load Model of warehouses and setup the list */
App::import('Model', 'Warehouse');
$warehouse = new Warehouse();
$getWarehouseAllWithStatus = $warehouse->find('all');
$newWarehouseList = array();
if ($warehouse->find('count') > 0) {
foreach ($getWarehouseAllWithStatus as $index => $value) {
if ($value["WarehouseDesc"]["is_deleted"] == "1") {
$newWarehouseList[$value["Warehouse"]["id"]] = $value["Warehouse"]["warehouse_name"] . " (Under Deleted)";
} else {
$newWarehouseList[$value["Warehouse"]["id"]] = $value["Warehouse"]["warehouse_name"];
}
}
}
return $getWarehouseList = $newWarehouseList;
}
示例6: run
public function run()
{
//$faker = Faker::create();
//foreach(range(1, 10) as $index)
//{
Warehouse::create(['item' => '158-52A', 'quantity' => 800, 'position' => 205]);
Warehouse::create(['item' => '158-52B', 'quantity' => 900, 'position' => 213]);
Warehouse::create(['item' => '211-19A', 'quantity' => 900, 'position' => 125]);
Warehouse::create(['item' => '211-19B', 'quantity' => 900, 'position' => 126]);
//}
}
示例7: __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'))));
}
示例8: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store()
{
//
$rules = array("warehouseId" => "required", "warehouseName" => "required", "firstAddress" => "required", "area" => "required", "region" => "required", "warehousePhone" => "required|numeric", "warehouseFax" => "required|numeric", "warehouseEmail" => "required|email", "warehousePIC" => "required");
$validator = Validator::make(Input::all(), $rules);
if ($validator->fails()) {
return Redirect::to('/warehouse/create')->withErrors($validator);
}
//
$warehouse = new Warehouse();
$warehouse->warehouseID = Input::get('warehouseId');
$warehouse->warehouseName = Input::get('warehouseName');
$warehouse->warehouseAddress1 = Input::get('firstAddress');
$warehouse->warehouseAddress2 = Input::get('secondAddress');
$warehouse->areaID = Input::get("area");
$warehouse->regionID = Input::get("region");
$warehouse->warehousePhone = Input::get("warehousePhone");
$warehouse->warehouseFax = Input::get("warehouseFax");
$warehouse->warehouseEmail = Input::get("warehouseEmail");
$warehouse->warehousePIC = Input::get("warehousePIC");
$warehouse->save();
return Redirect::to('/warehouse');
}
示例9: postModal
/**
* postModal (入库确认)
*/
public function postModal()
{
//itemReceivedPackageDetail->id
$id = Input::get('id');
$position = Input::get('readyposition');
$itemReceivedPackageDetail = ItemReceivedPackageDetail::find($id);
$itemReceivedPackageDetail->status = 2;
$itemReceivedPackageDetail->readyposition = $position;
$itemReceivedPackageDetail->save();
//历史入库记录
$historyWareHouse = new HistoryWarehouse();
$historyWareHouse->identity = $itemReceivedPackageDetail->identity;
$historyWareHouse->item = $itemReceivedPackageDetail->item;
$historyWareHouse->batch = $itemReceivedPackageDetail->batch;
$historyWareHouse->quantity = $itemReceivedPackageDetail->quantity;
$historyWareHouse->position = $position;
$historyWareHouse->operator = 5;
$historyWareHouse->save();
//库存汇总
$wareHouse = Warehouse::where('item', $itemReceivedPackageDetail->item)->where('position', $position)->first();
if ($wareHouse) {
$wareHouse->quantity = $wareHouse->quantity + $itemReceivedPackageDetail->quantity;
$wareHouse->save();
} else {
$wareHouse = new Warehouse();
$wareHouse->item = $itemReceivedPackageDetail->item;
$wareHouse->position = $position;
$wareHouse->quantity = $itemReceivedPackageDetail->quantity;
$wareHouse->save();
}
//更新item总库存
$items = Item::where('code', $itemReceivedPackageDetail->item)->first();
$items->stock += $itemReceivedPackageDetail->quantity;
$items->readystock -= $itemReceivedPackageDetail->quantity;
$items->save();
return Redirect::back();
}
示例10: generateId
public static function generateId()
{
$warehouse = Warehouse::orderBy('warehouseID', 'DESC')->get()->first();
$warehouseId = $warehouse->warehouseID;
$warehouseId = substr($warehouseId, 2);
$newId = (int) $warehouseId;
$newId++;
$newIdString = (string) $newId;
$newIdString = "000000" . $newIdString;
if (strlen($newIdString) > 3) {
$newIdString = substr($newIdString, strlen($newIdString) - 3);
}
$newIdString = "wa" . $newIdString;
return $newIdString;
}
示例11: __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();
}
示例12: 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();
}
}
示例13: array
}', 'select' => 'js:function(event, ui){
document.getElementById(\'keterangan\').innerHTML = \'Code : \'+ui.item.code;
document.getElementById(\'component_id\').value = ui.item.id;
}'), 'htmlOptions' => array('style' => 'height:25px;width:200px;padding:0px 5px;', 'class' => 'mf'), 'htmlOptions' => array('style' => 'width:50%;')));
?>
<input type="hidden" name="component_id" id="component_id">
</div>
<div class="row">
<b id="keterangan">
</b></div>
<div class="row">
<label>From Warehouse</label>
<?php
echo CHtml::dropDownList('warehouse_from', '', CHtml::listData(Warehouse::model()->findAll(), 'id', 'name_warehouse'), array('empty' => '-- select warehouse --'));
?>
</div>
<div class="row">
<label>To Warehouse</label>
<?php
echo CHtml::dropDownList('warehouse_to', '', CHtml::listData(Warehouse::model()->findAll(), 'id', 'name_warehouse'), array('empty' => '-- select warehouse --'));
?>
</div>
<div class="row">
<label>Qty</label>
<input type="text" id="qty" name="qty" size="8">
</div>
</div>
示例14: getAllocation
public function getAllocation($ProductId)
{
$product = Product::find($ProductId);
$warehouse = Warehouse::where('id', '<>', $product->warehouse_id)->get();
return View::make('goods.allocation')->with('warehouse', $warehouse)->with('product', $product)->with('good', Good::find($product->good_id));
}
示例15: renderCSV
/**
* Exports CSV
*/
public function renderCSV()
{
if (count($this->_list) <= 0) {
return;
}
// sets warehouse id and warehouse name
$id_warehouse = (int) Tools::getValue('id_warehouse');
$warehouse_name = Warehouse::getWarehouseNameById($id_warehouse);
// if quantities requested
if (Tools::isSubmit('csv_quantities')) {
// filename
$filename = $this->l('stock_instant_state_quantities') . '_' . $warehouse_name . '.csv';
// header
header('Content-type: text/csv');
header('Cache-Control: no-store, no-cache must-revalidate');
header('Content-disposition: attachment; filename="' . $filename);
// puts keys
$keys = array('id_product', 'id_product_attribute', 'reference', 'ean13', 'upc', 'name', 'physical_quantity', 'usable_quantity', 'real_quantity');
echo sprintf("%s\n", implode(';', $keys));
// puts rows
foreach ($this->_list as $row) {
$row_csv = array($row['id_product'], $row['id_product_attribute'], $row['reference'], $row['ean13'], $row['upc'], $row['name'], $row['physical_quantity'], $row['usable_quantity'], $row['real_quantity']);
// puts one row
echo sprintf("%s\n", implode(';', array_map(array('CSVCore', 'wrap'), $row_csv)));
}
} elseif (Tools::isSubmit('csv_prices')) {
// sets filename
$filename = $this->l('stock_instant_state_prices') . '_' . $warehouse_name . '.csv';
// header
header('Content-type: text/csv');
header('Cache-Control: no-store, no-cache must-revalidate');
header('Content-disposition: attachment; filename="' . $filename);
// puts keys
$keys = array('id_product', 'id_product_attribute', 'reference', 'ean13', 'upc', 'name', 'price_te', 'physical_quantity', 'usable_quantity');
echo sprintf("%s\n", implode(';', $keys));
foreach ($this->_list as $row) {
$id_product = (int) $row['id_product'];
$id_product_attribute = (int) $row['id_product_attribute'];
// gets prices
$query = new DbQuery();
$query->select('s.price_te, SUM(s.physical_quantity) as physical_quantity, SUM(s.usable_quantity) as usable_quantity');
$query->from('stock', 's');
$query->leftJoin('warehouse', 'w', 'w.id_warehouse = s.id_warehouse');
$query->where('s.id_product = ' . $id_product . ' AND s.id_product_attribute = ' . $id_product_attribute);
$query->where('s.id_warehouse = ' . $id_warehouse);
$query->groupBy('s.price_te');
$datas = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($query);
// puts data
foreach ($datas as $data) {
$row_csv = array($row['id_product'], $row['id_product_attribute'], $row['reference'], $row['ean13'], $row['upc'], $row['name'], $data['price_te'], $data['physical_quantity'], $data['usable_quantity']);
// puts one row
echo sprintf("%s\n", implode(';', array_map(array('CSVCore', 'wrap'), $row_csv)));
}
}
}
}