NEW: default warehouse field for products + prefill warehouses when dispatching supplier orders
This commit is contained in:
parent
0edba4b4a7
commit
3646374976
@ -484,7 +484,7 @@ if ($id > 0 || ! empty($ref)) {
|
||||
}
|
||||
|
||||
$sql = "SELECT l.rowid, l.fk_product, l.subprice, l.remise_percent, SUM(l.qty) as qty,";
|
||||
$sql .= " p.ref, p.label, p.tobatch";
|
||||
$sql .= " p.ref, p.label, p.tobatch, p.fk_default_warehouse";
|
||||
$sql .= " FROM " . MAIN_DB_PREFIX . "commande_fournisseurdet as l";
|
||||
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON l.fk_product=p.rowid";
|
||||
$sql .= " WHERE l.fk_commande = " . $object->id;
|
||||
@ -676,9 +676,9 @@ if ($id > 0 || ! empty($ref)) {
|
||||
// Warehouse
|
||||
print '<td align="right">';
|
||||
if (count($listwarehouses) > 1) {
|
||||
print $formproduct->selectWarehouses(GETPOST("entrepot" . $suffix), "entrepot" . $suffix, '', 1, 0, $objp->fk_product, '', 1);
|
||||
print $formproduct->selectWarehouses(GETPOST("entrepot" . $suffix)?GETPOST("entrepot" . $suffix):($objp->fk_default_warehouse?$objp->fk_default_warehouse:''), "entrepot" . $suffix, '', 1, 0, $objp->fk_product, '', 1);
|
||||
} elseif (count($listwarehouses) == 1) {
|
||||
print $formproduct->selectWarehouses(GETPOST("entrepot" . $suffix), "entrepot" . $suffix, '', 0, 0, $objp->fk_product, '', 1);
|
||||
print $formproduct->selectWarehouses(GETPOST("entrepot" . $suffix)?GETPOST("entrepot" . $suffix):($objp->fk_default_warehouse?$objp->fk_default_warehouse:''), "entrepot" . $suffix, '', 0, 0, $objp->fk_product, '', 1);
|
||||
} else {
|
||||
$langs->load("errors");
|
||||
print $langs->trans("ErrorNoWarehouseDefined");
|
||||
|
||||
@ -329,3 +329,7 @@ INSERT INTO llx_c_email_templates (entity,module,type_template,lang,private,fk_u
|
||||
INSERT INTO llx_c_email_templates (entity,module,type_template,lang,private,fk_user,datec,label,position,enabled,active,topic,content,content_lines,joinfiles) VALUES (0,'adherent','member','',0,null,null,'(SendingReminderForExpiredSubscription)',40,1,1,'[__[MAIN_INFO_SOCIETE_NOM]__] __(SubscriptionReminderEmail)__', '__(Hello)__ __MEMBER_FULLNAME__,<br><br>\n\n__(ThisIsContentOfSubscriptionReminderEmail)__<br>\n<br>__ONLINE_PAYMENT_TEXT_AND_URL__<br>\n<br><br>\n__(Sincerely)__<br>__USER_SIGNATURE__',null, 1);
|
||||
INSERT INTO llx_c_email_templates (entity,module,type_template,lang,private,fk_user,datec,label,position,enabled,active,topic,content,content_lines,joinfiles) VALUES (0,'adherent','member','',0,null,null,'(SendingEmailOnCancelation)' ,50,1,1,'[__[MAIN_INFO_SOCIETE_NOM]__] __(YourMembershipWasCanceled)__', '__(Hello)__ __MEMBER_FULLNAME__,<br><br>\n\n__(YourMembershipWasCanceled)__<br>\n<br><br>\n__(Sincerely)__<br>__USER_SIGNATURE__',null, 1);
|
||||
INSERT INTO llx_c_email_templates (entity,module,type_template,lang,private,fk_user,datec,label,position,enabled,active,topic,content,content_lines,joinfiles) VALUES (0,'adherent','member','',0,null,null,'(SendingAnEMailToMember)' ,60,1,1,'[__[MAIN_INFO_SOCIETE_NOM]__] __(CardContent)__', '__(Hello)__,<br><br>\n\n__(ThisIsContentOfYourCard)__<br>\n__(ID)__ : __ID__<br>\n__(Civiliyty)__ : __MEMBER_CIVILITY__<br>\n__(Firstname)__ : __MEMBER_FIRSTNAME__<br>\n__(Lastname)__ : __MEMBER_LASTNAME__<br>\n__(Fullname)__ : __MEMBER_FULLNAME__<br>\n__(Company)__ : __MEMBER_COMPANY__<br>\n__(Address)__ : __MEMBER_ADDRESS__<br>\n__(Zip)__ : __MEMBER_ZIP__<br>\n__(Town)__ : __MEMBER_TOWN__<br>\n__(Country)__ : __MEMBER_COUNTRY__<br>\n__(Email)__ : __MEMBER_EMAIL__<br>\n__(Birthday)__ : __MEMBER_BIRTH__<br>\n__(Photo)__ : __MEMBER_PHOTO__<br>\n__(Login)__ : __MEMBER_LOGIN__<br>\n__(Password)__ : __MEMBER_PASSWORD__<br>\n__(Phone)__ : __MEMBER_PHONE__<br>\n__(PhonePerso)__ : __MEMBER_PHONEPRO__<br>\n__(PhoneMobile)__ : __MEMBER_PHONEMOBILE__<br><br>\n__(Sincerely)__<br>__USER_SIGNATURE__',null, 1);
|
||||
|
||||
ALTER TABLE llx_product ADD COLUMN fk_default_warehouse int(11) DEFAULT NULL;
|
||||
ALTER TABLE llx_product ADD CONSTRAINT fk_product_default_warehouse FOREIGN KEY (fk_default_warehouse) REFERENCES llx_entrepot (rowid);
|
||||
|
||||
|
||||
@ -35,3 +35,4 @@ ALTER TABLE llx_product ADD CONSTRAINT fk_product_fk_unit FOREIGN KEY (fk_unit)
|
||||
|
||||
ALTER TABLE llx_product ADD CONSTRAINT fk_product_fk_country FOREIGN KEY (fk_country) REFERENCES llx_c_country (rowid);
|
||||
ALTER TABLE llx_product ADD CONSTRAINT fk_product_barcode_type FOREIGN KEY (fk_barcode_type) REFERENCES llx_c_barcode_type (rowid);
|
||||
ALTER TABLE llx_product ADD CONSTRAINT fk_product_default_warehouse FOREIGN KEY (fk_default_warehouse) REFERENCES llx_entrepot (rowid);
|
||||
|
||||
@ -85,6 +85,7 @@ create table llx_product
|
||||
pmp double(24,8) DEFAULT 0 NOT NULL, -- To store valuation of stock calculated using average price method, for this product
|
||||
fifo double(24,8), -- To store valuation of stock calculated using fifo method, for this product. TODO Not used, should be replaced by stock value stored into movement table.
|
||||
lifo double(24,8), -- To store valuation of stock calculated using lifo method, for this product. TODO Not used, should be replaced by stock value stored into movement table.
|
||||
fk_default_warehouse int(11) DEFAULT NULL,
|
||||
canvas varchar(32) DEFAULT NULL,
|
||||
finished tinyint DEFAULT NULL, -- 1=manufactured product, 0=matiere premiere
|
||||
hidden tinyint DEFAULT 0, -- Not used. Deprecated.
|
||||
|
||||
@ -8,7 +8,9 @@ WarehouseEdit=Modify warehouse
|
||||
MenuNewWarehouse=New warehouse
|
||||
WarehouseSource=Source warehouse
|
||||
WarehouseSourceNotDefined=No warehouse defined,
|
||||
AddWarehouse=Create warehouse
|
||||
AddOne=Add one
|
||||
DefaultWarehouse=Default warehouse
|
||||
WarehouseTarget=Target warehouse
|
||||
ValidateSending=Delete sending
|
||||
CancelSending=Cancel sending
|
||||
|
||||
@ -292,6 +292,7 @@ if (empty($reshook))
|
||||
$object->country_id = GETPOST('country_id');
|
||||
$object->duration_value = $duration_value;
|
||||
$object->duration_unit = $duration_unit;
|
||||
$object->fk_default_warehouse = GETPOST('fk_default_warehouse');
|
||||
$object->seuil_stock_alerte = GETPOST('seuil_stock_alerte')?GETPOST('seuil_stock_alerte'):0;
|
||||
$object->desiredstock = GETPOST('desiredstock')?GETPOST('desiredstock'):0;
|
||||
$object->canvas = GETPOST('canvas');
|
||||
@ -390,6 +391,7 @@ if (empty($reshook))
|
||||
$object->status_buy = GETPOST('statut_buy');
|
||||
$object->status_batch = GETPOST('status_batch');
|
||||
// removed from update view so GETPOST always empty
|
||||
$object->fk_default_warehouse = GETPOST('fk_default_warehouse');
|
||||
/*
|
||||
$object->seuil_stock_alerte = GETPOST('seuil_stock_alerte');
|
||||
$object->desiredstock = GETPOST('desiredstock');
|
||||
@ -995,9 +997,14 @@ else
|
||||
print '<input type="text" name="url" class="quatrevingtpercent" value="'.GETPOST('url').'">';
|
||||
print '</td></tr>';
|
||||
|
||||
// Stock min level
|
||||
if ($type != 1 && ! empty($conf->stock->enabled))
|
||||
{
|
||||
// Default warehouse
|
||||
print '<tr><td>'.$langs->trans("DefaultWarehouse").'</td><td>';
|
||||
print $formproduct->selectWarehouses(GETPOST('fk_default_warehouse'), 'fk_default_warehouse', 'warehouseopen', 1);
|
||||
print ' <a href="'.DOL_URL_ROOT.'/product/stock/card.php?action=create&backtopage='.urlencode($_SERVER['PHP_SELF'].'?id='.$object->id.'&action=edit').'">'.$langs->trans("AddWarehouse").'</a>';
|
||||
print '</td>';
|
||||
// Stock min level
|
||||
print '<tr><td>'.$form->textwithpicto($langs->trans("StockLimit"), $langs->trans("StockLimitDesc"), 1).'</td><td>';
|
||||
print '<input name="seuil_stock_alerte" class="maxwidth50" value="'.GETPOST('seuil_stock_alerte').'">';
|
||||
print '</td>';
|
||||
@ -1351,9 +1358,14 @@ else
|
||||
print '</td></tr>';
|
||||
|
||||
// Stock
|
||||
/*
|
||||
if ($object->isProduct() && ! empty($conf->stock->enabled))
|
||||
{
|
||||
// Default warehouse
|
||||
print '<tr><td>'.$langs->trans("DefaultWarehouse").'</td><td>';
|
||||
print $formproduct->selectWarehouses($object->fk_default_warehouse, 'fk_default_warehouse', 'warehouseopen', 1);
|
||||
print ' <a href="'.DOL_URL_ROOT.'/product/stock/card.php?action=create&backtopage='.urlencode($_SERVER['PHP_SELF'].'?action=create&type='.GETPOST('type', 'int')).'">'.$langs->trans("AddWarehouse").'</a>';
|
||||
print '</td>';
|
||||
/*
|
||||
print "<tr>".'<td>'.$langs->trans("StockLimit").'</td><td>';
|
||||
print '<input name="seuil_stock_alerte" size="4" value="'.$object->seuil_stock_alerte.'">';
|
||||
print '</td>';
|
||||
@ -1361,7 +1373,9 @@ else
|
||||
print '<td>'.$langs->trans("DesiredStock").'</td><td>';
|
||||
print '<input name="desiredstock" size="4" value="'.$object->desiredstock.'">';
|
||||
print '</td></tr>';
|
||||
*/
|
||||
}
|
||||
/*
|
||||
else
|
||||
{
|
||||
print '<input name="seuil_stock_alerte" type="hidden" value="'.$object->seuil_stock_alerte.'">';
|
||||
@ -1757,6 +1771,17 @@ else
|
||||
print dol_print_url($object->url);
|
||||
print '</td></tr>';
|
||||
|
||||
// Default warehouse
|
||||
if ($object->isProduct() && ! empty($conf->stock->enabled))
|
||||
{
|
||||
$warehouse = new Entrepot($db);
|
||||
$warehouse->fetch($object->fk_default_warehouse);
|
||||
|
||||
print '<tr><td>'.$langs->trans("DefaultWarehouse").'</td><td>';
|
||||
print (! empty($warehouse->id) ? $warehouse->getNomUrl(1) : '');
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
//Parent product.
|
||||
if (!empty($conf->variants->enabled) && $object->isProduct()) {
|
||||
|
||||
|
||||
@ -886,6 +886,7 @@ class Product extends CommonObject
|
||||
$sql.= ", surface_units = " . ($this->surface_units!='' ? "'".$this->db->escape($this->surface_units)."'" : 'null');
|
||||
$sql.= ", volume = " . ($this->volume!='' ? "'".$this->db->escape($this->volume)."'" : 'null');
|
||||
$sql.= ", volume_units = " . ($this->volume_units!='' ? "'".$this->db->escape($this->volume_units)."'" : 'null');
|
||||
$sql.= ", fk_default_warehouse = " . (! empty($this->fk_default_warehouse) ? $this->db->escape($this->fk_default_warehouse) : 'null');
|
||||
$sql.= ", seuil_stock_alerte = " . ((isset($this->seuil_stock_alerte) && $this->seuil_stock_alerte != '') ? "'".$this->db->escape($this->seuil_stock_alerte)."'" : "null");
|
||||
$sql.= ", description = '" . $this->db->escape($this->description) ."'";
|
||||
$sql.= ", url = " . ($this->url?"'".$this->db->escape($this->url)."'":'null');
|
||||
@ -1864,7 +1865,7 @@ class Product extends CommonObject
|
||||
|
||||
$sql = "SELECT rowid, ref, ref_ext, label, description, url, note as note_private, customcode, fk_country, price, price_ttc,";
|
||||
$sql.= " price_min, price_min_ttc, price_base_type, cost_price, default_vat_code, tva_tx, recuperableonly as tva_npr, localtax1_tx, localtax2_tx, localtax1_type, localtax2_type, tosell,";
|
||||
$sql.= " tobuy, fk_product_type, duration, seuil_stock_alerte, canvas, weight, weight_units,";
|
||||
$sql.= " tobuy, fk_product_type, duration, fk_default_warehouse, seuil_stock_alerte, canvas, weight, weight_units,";
|
||||
$sql.= " length, length_units, width, width_units, height, height_units,";
|
||||
$sql.= " surface, surface_units, volume, volume_units, barcode, fk_barcode_type, finished,";
|
||||
$sql.= " accountancy_code_buy, accountancy_code_sell, accountancy_code_sell_intra, accountancy_code_sell_export, stock, pmp,";
|
||||
@ -1946,6 +1947,7 @@ class Product extends CommonObject
|
||||
$this->accountancy_code_sell_intra = $obj->accountancy_code_sell_intra;
|
||||
$this->accountancy_code_sell_export = $obj->accountancy_code_sell_export;
|
||||
|
||||
$this->fk_default_warehouse = $obj->fk_default_warehouse;
|
||||
$this->seuil_stock_alerte = $obj->seuil_stock_alerte;
|
||||
$this->desiredstock = $obj->desiredstock;
|
||||
$this->stock_reel = $obj->stock;
|
||||
|
||||
@ -70,7 +70,7 @@ if (empty($conf) || ! is_object($conf))
|
||||
{
|
||||
print '<td class="fieldrequired">'.$langs->trans("Warehouse").'</td>';
|
||||
print '<td>';
|
||||
print $formproduct->selectWarehouses((GETPOST("dwid")?GETPOST("dwid",'int'):(GETPOST('id_entrepot')?GETPOST('id_entrepot','int'):'ifone')), 'id_entrepot', 'warehouseopen,warehouseinternal', 1, 0, 0, '', 0, 0, null, 'minwidth100');
|
||||
print $formproduct->selectWarehouses((GETPOST("dwid")?GETPOST("dwid",'int'):(GETPOST('id_entrepot')?GETPOST('id_entrepot','int'):($object->element=='product' && $object->fk_default_warehouse?$object->fk_default_warehouse:'ifone'))), 'id_entrepot', 'warehouseopen,warehouseinternal', 1, 0, 0, '', 0, 0, null, 'minwidth100');
|
||||
print ' <select name="mouvement" id="mouvement">';
|
||||
print '<option value="0">'.$langs->trans("Add").'</option>';
|
||||
print '<option value="1"'.(GETPOST('mouvement')?' selected="selected"':'').'>'.$langs->trans("Delete").'</option>';
|
||||
|
||||
@ -74,7 +74,7 @@ if (empty($conf) || ! is_object($conf))
|
||||
{
|
||||
print '<td class="fieldrequired">'.$langs->trans("WarehouseSource").'</td>';
|
||||
print '<td>';
|
||||
print $formproduct->selectWarehouses((GETPOST("dwid")?GETPOST("dwid",'int'):(GETPOST('id_entrepot')?GETPOST('id_entrepot','int'):'ifone')), 'id_entrepot', 'warehouseopen,warehouseinternal', 1);
|
||||
print $formproduct->selectWarehouses((GETPOST("dwid")?GETPOST("dwid",'int'):(GETPOST('id_entrepot')?GETPOST('id_entrepot','int'):($object->element=='product' && $object->fk_default_warehouse?$object->fk_default_warehouse:'ifone'))), 'id_entrepot', 'warehouseopen,warehouseinternal', 1);
|
||||
print '</td>';
|
||||
}
|
||||
if ($object->element == 'stock')
|
||||
|
||||
Loading…
Reference in New Issue
Block a user