diff --git a/htdocs/langs/en_US/stocks.lang b/htdocs/langs/en_US/stocks.lang index e6b9f82730c..3416d1b1909 100644 --- a/htdocs/langs/en_US/stocks.lang +++ b/htdocs/langs/en_US/stocks.lang @@ -139,3 +139,7 @@ WarehouseMustBeSelectedAtFirstStepWhenProductBatchModuleOn=Source warehouse must InventoryCodeShort=Inv./Mov. code NoPendingReceptionOnSupplierOrder=No pending reception due to open supplier order ThisSerialAlreadyExistWithDifferentDate=This lot/serial number (%s) already exists but with different eatby or sellby date (found %s but you enter %s). +OpenAll=Open for all actions +OpenInternal=Open for internal actions +OpenShipping=Open for shippings +OpenDispatch=Open for dispatch \ No newline at end of file diff --git a/htdocs/product/class/html.formproduct.class.php b/htdocs/product/class/html.formproduct.class.php index 24a7506882b..a69880f7fa5 100644 --- a/htdocs/product/class/html.formproduct.class.php +++ b/htdocs/product/class/html.formproduct.class.php @@ -1,5 +1,6 @@ + * Copyright (C) 2016 Francis Appels * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -53,20 +54,20 @@ class FormProduct * * @param int $fk_product Add quantity of stock in label for product with id fk_product. Nothing if 0. * @param string $batch Add quantity of batch stock in label for product with batch name batch, batch name precedes batch_id. Nothing if ''. - * @param int $fk_product_batch Add quantity of batch stock in label for product with batch id fk_product_batch. Nothing if 0. + * @param int $status additional filter on status other then 1 * @param boolean $sumStock sum total stock of a warehouse, default true * @return int Nb of loaded lines, 0 if already loaded, <0 if KO */ - function loadWarehouses($fk_product=0, $batch = '', $fk_product_batch=0, $sumStock = true) + function loadWarehouses($fk_product=0, $batch = '', $status=null, $sumStock = true) { global $conf, $langs; if (empty($fk_product) && count($this->cache_warehouses)) return 0; // Cache already loaded and we do not want a list with information specific to a product - $sql = "SELECT e.rowid, e.label"; + $sql = "SELECT e.rowid, e.label, e.description"; if (!empty($fk_product)) { - if (!empty($fk_product_batch) || !empty($batch)) + if (!empty($batch)) { $sql.= ", pb.qty as stock"; } @@ -87,13 +88,18 @@ class FormProduct if (!empty($batch)) { $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_batch as pb on pb.fk_product_stock = ps.rowid AND pb.batch = '".$batch."'"; - } else if (!empty($fk_product_batch)) - { - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_batch as pb on pb.fk_product_stock = ps.rowid AND pb.rowid = '".$fk_product_batch."'"; - } + } } $sql.= " WHERE e.entity IN (".getEntity('stock', 1).")"; - $sql.= " AND e.statut = 1"; + if (!empty($status)) + { + $sql.= " AND e.statut IN (1, ".$status.")"; + } + else + { + $sql.= " AND e.statut = 1"; + } + if ($sumStock && empty($fk_product)) $sql.= " GROUP BY e.rowid, e.label, e.description"; $sql.= " ORDER BY e.label"; @@ -127,7 +133,7 @@ class FormProduct * * @param int $selected Id of preselected warehouse ('' for no value, 'ifone'=select value if one value otherwise no value) * @param string $htmlname Name of html select html - * @param string $filtertype For filter + * @param string $filtertype For filter, additional filter on status other then 1 * @param int $empty 1=Can be empty, 0 if not * @param int $disabled 1=Select is disabled * @param int $fk_product Add quantity of stock in label for product with id fk_product. Nothing if 0. @@ -142,11 +148,11 @@ class FormProduct { global $conf,$langs,$user; - dol_syslog(get_class($this)."::selectWarehouses $selected, $htmlname, $filtertype, $empty, $disabled, $fk_product",LOG_DEBUG); + dol_syslog(get_class($this)."::selectWarehouses $selected, $htmlname, $filtertype, $empty, $disabled, $fk_product, $empty_label, $showstock, $forcecombo, $morecss",LOG_DEBUG); $out=''; - $this->loadWarehouses($fk_product); + $this->loadWarehouses($fk_product, '', + $filtertype); // filter on numeric status $nbofwarehouses=count($this->cache_warehouses); if ($conf->use_javascript_ajax && ! $forcecombo) diff --git a/htdocs/product/stock/card.php b/htdocs/product/stock/card.php index 430e042c202..f34f4482a49 100644 --- a/htdocs/product/stock/card.php +++ b/htdocs/product/stock/card.php @@ -3,6 +3,7 @@ * Copyright (C) 2004-2011 Laurent Destailleur * Copyright (C) 2005 Simon Tosser * Copyright (C) 2005-2014 Regis Houssin + * Copyright (C) 2016 Francis Appels * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -53,6 +54,7 @@ $result=restrictedArea($user,'stock'); // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array $hookmanager->initHooks(array('warehousecard','globalcard')); +$object = new Entrepot($db); /* * Actions @@ -61,8 +63,6 @@ $hookmanager->initHooks(array('warehousecard','globalcard')); // Ajout entrepot if ($action == 'add' && $user->rights->stock->creer) { - $object = new Entrepot($db); - $object->ref = GETPOST("ref"); $object->libelle = GETPOST("libelle"); $object->description = GETPOST("desc"); @@ -107,7 +107,6 @@ if ($action == 'add' && $user->rights->stock->creer) // Delete warehouse if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->stock->supprimer) { - $object = new Entrepot($db); $object->fetch($_REQUEST["id"]); $result=$object->delete($user); if ($result > 0) @@ -125,7 +124,6 @@ if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->stock->su // Modification entrepot if ($action == 'update' && $cancel <> $langs->trans("Cancel")) { - $object = new Entrepot($db); if ($object->fetch($id)) { $object->libelle = GETPOST("libelle"); @@ -215,11 +213,20 @@ if ($action == 'create') print $form->select_country((!empty($object->country_id)?$object->country_id:$mysoc->country_code),'country_id'); if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); print ''; - + // Status print ''.$langs->trans("Status").''; print ''; print ''; @@ -558,8 +565,17 @@ else print ''.$langs->trans("Status").''; print ''; print ''; diff --git a/htdocs/product/stock/class/entrepot.class.php b/htdocs/product/stock/class/entrepot.class.php index 0f88792f2e4..afcaec0bc6b 100644 --- a/htdocs/product/stock/class/entrepot.class.php +++ b/htdocs/product/stock/class/entrepot.class.php @@ -3,6 +3,7 @@ * Copyright (C) 2004-2010 Laurent Destailleur * Copyright (C) 2005-2008 Regis Houssin * Copyright (C) 2011 Juanjo Menent + * Copyright (C) 2016 Francis Appels * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -34,18 +35,45 @@ class Entrepot extends CommonObject { public $element='stock'; public $table_element='entrepot'; + + /** + * Warehouse closed, inactive + */ + const STATUS_CLOSED = 0; + + /** + * Warehouse open and operations for customer shipping, supplier dispatch, internal stock transfers/corrections allowed. + */ + const STATUS_OPEN_ALL = 1; + + /** + * Warehouse open and operations for stock transfers/corrections allowed (not for customer shipping and supplier dispatch). + */ + const STATUS_OPEN_INTERNAL = 2; + + /** + * Warehouse open and operations for customer shipping and internal stock transfers/corrections allowed (not for supplier dispatch). + */ + const STATUS_OPEN_SHIPPING = 3; + + /** + * Warehouse open and operations for supplier dispatch internal stock transfers/corrections allowed (not for customer shipping). + */ + const STATUS_OPEN_DISPATCH = 4; + var $libelle; var $description; - //! Statut 1 pour ouvert, 0 pour ferme var $statut; var $lieu; var $address; //! Code Postal var $zip; var $town; - - + + // List of short language codes for status + var $statuts = array(); + /** * Constructor * @@ -53,11 +81,22 @@ class Entrepot extends CommonObject */ function __construct($db) { + global $conf; $this->db = $db; - // List of short language codes for status - $this->statuts[0] = 'Closed2'; - $this->statuts[1] = 'Opened'; + $this->statuts[self::STATUS_CLOSED] = 'Closed2'; + if ($conf->global->ENTREPOT_EXTRA_STATUS) + { + $this->statuts[self::STATUS_OPEN_ALL] = 'OpenAll'; + $this->statuts[self::STATUS_OPEN_INTERNAL] = 'OpenInternal'; + $this->statuts[self::STATUS_OPEN_SHIPPING] = 'OpenShipping'; + $this->statuts[self::STATUS_OPEN_DISPATCH] = 'OpenDispatch'; + } + else + { + $this->statuts[self::STATUS_OPEN_ALL] = 'Opened'; + } + } /** @@ -455,42 +494,40 @@ class Entrepot extends CommonObject function LibStatut($statut,$mode=0) { global $langs; + $langs->load('stocks'); + + $picto = 'statut5'; + $label = $langs->trans($this->statuts[$statut]); + if ($mode == 0) { - $prefix=''; - if ($statut == 0) return $langs->trans($this->statuts[$statut]); - if ($statut == 1) return $langs->trans($this->statuts[$statut]); + return $label; } if ($mode == 1) { - $prefix='Short'; - if ($statut == 0) return $langs->trans($this->statuts[$statut]); - if ($statut == 1) return $langs->trans($this->statuts[$statut]); + return $label; } if ($mode == 2) { - $prefix='Short'; - if ($statut == 0) return img_picto($langs->trans($this->statuts[$statut]),'statut5').' '.$langs->trans($this->statuts[$statut]); - if ($statut == 1) return img_picto($langs->trans($this->statuts[$statut]),'statut4').' '.$langs->trans($this->statuts[$statut]); + if ($statut > 0) $picto = 'statut4'; + return img_picto($label, $picto).' '.$label; } if ($mode == 3) { - $prefix='Short'; - if ($statut == 0) return img_picto($langs->trans($this->statuts[$statut]),'statut5'); - if ($statut == 1) return img_picto($langs->trans($this->statuts[$statut]),'statut4'); + if ($statut > 0) $picto = 'statut4'; + return img_picto($label, $picto).' '.$label; } if ($mode == 4) { - if ($statut == 0) return img_picto($langs->trans($this->statuts[$statut]),'statut5').' '.$langs->trans($this->statuts[$statut]); - if ($statut == 1) return img_picto($langs->trans($this->statuts[$statut]),'statut4').' '.$langs->trans($this->statuts[$statut]); + if ($statut > 0) $picto = 'statut4'; + return img_picto($label, $picto).' '.$label; } if ($mode == 5) { - $prefix='Short'; - if ($statut == 0) return $langs->trans($this->statuts[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]),'statut5'); - if ($statut == 1) return $langs->trans($this->statuts[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]),'statut4'); + if ($statut > 0) $picto = 'statut4'; + return $label.' '.img_picto($label, $picto); } }