Merge pull request #3776 from frederic34/patch-15
Set warehouse for order
This commit is contained in:
commit
ce681081c1
@ -251,6 +251,23 @@ else if ($action == 'set_BANK_ASK_PAYMENT_BANK_DURING_ORDER')
|
||||
}
|
||||
}
|
||||
|
||||
// Activate ask for warehouse
|
||||
else if ($action == 'set_WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER')
|
||||
{
|
||||
$res = dolibarr_set_const($db, "WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER",$value,'chaine',0,'',$conf->entity);
|
||||
|
||||
if (! $res > 0) $error++;
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
setEventMessage($langs->trans("SetupSaved"));
|
||||
}
|
||||
else
|
||||
{
|
||||
setEventMessage($langs->trans("Error"),'errors');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* View
|
||||
@ -630,6 +647,36 @@ else
|
||||
print $langs->trans("BANK_ASK_PAYMENT_BANK_DURING_ORDER").'</td><td> </td><td align="center">'.$langs->trans('NotAvailable').'</td></tr>';
|
||||
}
|
||||
|
||||
// Ask for warehouse during order
|
||||
if ($conf->stock->enabled)
|
||||
{
|
||||
$var=!$var;
|
||||
print '<tr '.$bc[$var].'><td>';
|
||||
print $langs->trans("WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER").'</td><td> </td><td align="center">';
|
||||
if (! empty($conf->use_javascript_ajax))
|
||||
{
|
||||
print ajax_constantonoff('WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER');
|
||||
}
|
||||
else
|
||||
{
|
||||
if (empty($conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER))
|
||||
{
|
||||
print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER&value=1">'.img_picto($langs->trans("Disabled"),'switch_off').'</a>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER&value=0">'.img_picto($langs->trans("Enabled"),'switch_on').'</a>';
|
||||
}
|
||||
}
|
||||
print '</td></tr>';
|
||||
}
|
||||
else
|
||||
{
|
||||
$var=!$var;
|
||||
print '<tr '.$bc[$var].'><td>';
|
||||
print $langs->trans("WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER").'</td><td> </td><td align="center">'.$langs->trans('NotAvailable').'</td></tr>';
|
||||
}
|
||||
|
||||
print '</table>';
|
||||
print '<br>';
|
||||
|
||||
|
||||
@ -702,6 +702,7 @@ class Commande extends CommonOrder
|
||||
$sql.= " ref, fk_soc, date_creation, fk_user_author, fk_projet, date_commande, source, note_private, note_public, ref_ext, ref_client, ref_int";
|
||||
$sql.= ", model_pdf, fk_cond_reglement, fk_mode_reglement, fk_account, fk_availability, fk_input_reason, date_livraison, fk_delivery_address";
|
||||
$sql.= ", fk_shipping_method";
|
||||
$sql.= ", fk_warehouse";
|
||||
$sql.= ", remise_absolue, remise_percent";
|
||||
$sql.= ", fk_incoterms, location_incoterms";
|
||||
$sql.= ", entity";
|
||||
@ -724,6 +725,7 @@ class Commande extends CommonOrder
|
||||
$sql.= ", ".($this->date_livraison?"'".$this->db->idate($this->date_livraison)."'":"null");
|
||||
$sql.= ", ".($this->fk_delivery_address>0?$this->fk_delivery_address:'NULL');
|
||||
$sql.= ", ".($this->shipping_method_id>0?$this->shipping_method_id:'NULL');
|
||||
$sql.= ", ".($this->warehouse_id>0?$this->warehouse_id:'NULL');
|
||||
$sql.= ", ".($this->remise_absolue>0?$this->db->escape($this->remise_absolue):'NULL');
|
||||
$sql.= ", ".($this->remise_percent>0?$this->db->escape($this->remise_percent):0);
|
||||
$sql.= ", ".(int) $this->fk_incoterms;
|
||||
@ -1063,6 +1065,7 @@ class Commande extends CommonOrder
|
||||
$this->demand_reason_id = $object->demand_reason_id;
|
||||
$this->date_livraison = $object->date_livraison;
|
||||
$this->shipping_method_id = $object->shipping_method_id;
|
||||
$this->warehouse_id = $object->warehouse_id;
|
||||
$this->fk_delivery_address = $object->fk_delivery_address;
|
||||
$this->contact_id = $object->contactid;
|
||||
$this->ref_client = $object->ref_client;
|
||||
@ -1432,6 +1435,7 @@ class Commande extends CommonOrder
|
||||
$sql.= ', c.date_commande';
|
||||
$sql.= ', c.date_livraison';
|
||||
$sql.= ', c.fk_shipping_method';
|
||||
$sql.= ', c.fk_warehouse';
|
||||
$sql.= ', c.fk_projet, c.remise_percent, c.remise, c.remise_absolue, c.source, c.facture as billed';
|
||||
$sql.= ', c.note_private, c.note_public, c.ref_client, c.ref_ext, c.ref_int, c.model_pdf, c.fk_delivery_address, c.extraparams';
|
||||
$sql.= ', c.fk_incoterms, c.location_incoterms';
|
||||
@ -1499,6 +1503,7 @@ class Commande extends CommonOrder
|
||||
$this->demand_reason_code = $obj->demand_reason_code;
|
||||
$this->date_livraison = $this->db->jdate($obj->date_livraison);
|
||||
$this->shipping_method_id = ($obj->fk_shipping_method>0)?$obj->fk_shipping_method:null;
|
||||
$this->warehouse_id = ($obj->fk_warehouse>0)?$obj->fk_warehouse:null;
|
||||
$this->fk_delivery_address = $obj->fk_delivery_address;
|
||||
|
||||
//Incoterms
|
||||
|
||||
@ -1507,6 +1507,36 @@ abstract class CommonObject
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Change the warehouse
|
||||
*
|
||||
* @param int $warehouse_id Id of warehouse
|
||||
* @return int 1 if OK, 0 if KO
|
||||
*/
|
||||
function setWarehouse($warehouse_id)
|
||||
{
|
||||
if (! $this->table_element) {
|
||||
dol_syslog(get_class($this)."::setWarehouse was called on objet with property table_element not defined",LOG_ERR);
|
||||
return -1;
|
||||
}
|
||||
if ($warehouse_id<0) $warehouse_id='NULL';
|
||||
dol_syslog(get_class($this).'::setWarehouse('.$warehouse_id.')');
|
||||
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
|
||||
$sql.= " SET fk_warehouse = ".$warehouse_id;
|
||||
$sql.= " WHERE rowid=".$this->id;
|
||||
|
||||
if ($this->db->query($sql)) {
|
||||
$this->warehouse_id = ($warehouse_id=='NULL')?null:$warehouse_id;
|
||||
return 1;
|
||||
} else {
|
||||
dol_syslog(get_class($this).'::setWarehouse Error ', LOG_DEBUG);
|
||||
$this->error=$this->db->error();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set last model used by doc generator
|
||||
*
|
||||
|
||||
@ -143,6 +143,14 @@ if ($action == 'setshippingmethod' && $user->rights->commande->creer) {
|
||||
setEventMessages($commande->error, $commande->errors, 'errors');
|
||||
}
|
||||
|
||||
// warehouse
|
||||
if ($action == 'setwarehouse' && $user->rights->commande->creer) {
|
||||
$commande = new Commande($db);
|
||||
$commande->fetch($id);
|
||||
$result = $commande->setWarehouse(GETPOST('warehouse_id', 'int'));
|
||||
if ($result < 0)
|
||||
setEventMessages($commande->error, $commande->errors, 'errors');
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
@ -184,8 +192,8 @@ if ($id > 0 || ! empty($ref))
|
||||
}
|
||||
|
||||
// Onglet commande
|
||||
$nbrow=8;
|
||||
if (! empty($conf->projet->enabled)) $nbrow++;
|
||||
//$nbrow=8;
|
||||
//if (! empty($conf->projet->enabled)) $nbrow++;
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
@ -306,6 +314,27 @@ if ($id > 0 || ! empty($ref))
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
// Warehouse
|
||||
if (! empty($conf->stock->enabled) && ! empty($conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER)) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
|
||||
$formproduct=new FormProduct($db);
|
||||
print '<tr><td>';
|
||||
print '<table width="100%" class="nobordernopadding"><tr><td>';
|
||||
print $langs->trans('Warehouse');
|
||||
print '</td>';
|
||||
if ($action != 'editwarehouse' && $user->rights->commande->creer)
|
||||
print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editwarehouse&id='.$commande->id.'">'.img_edit($langs->trans('SetWarehouse'),1).'</a></td>';
|
||||
print '</tr></table>';
|
||||
print '</td><td colspan="2">';
|
||||
if ($action == 'editwarehouse') {
|
||||
$formproduct->formSelectWarehouses($_SERVER['PHP_SELF'].'?id='.$commande->id, $commande->warehouse_id, 'warehouse_id', 1);
|
||||
} else {
|
||||
$formproduct->formSelectWarehouses($_SERVER['PHP_SELF'].'?id='.$commande->id, $commande->warehouse_id, 'none');
|
||||
}
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
// Terms of payment
|
||||
print '<tr><td height="10">';
|
||||
print '<table class="nobordernopadding" width="100%"><tr><td>';
|
||||
@ -549,7 +578,7 @@ if ($id > 0 || ! empty($ref))
|
||||
}
|
||||
|
||||
// Qty ordered
|
||||
print '<td align="center">'.$objp->qty.'</td>';
|
||||
print '<td align="center">' . ($objp->qty!=1?'<span class="badge">'.$objp->qty.'</span>':$objp->qty) . '</td>';
|
||||
|
||||
// Qty already shipped
|
||||
$qtyProdCom=$objp->qty;
|
||||
@ -697,7 +726,7 @@ if ($id > 0 || ! empty($ref))
|
||||
|
||||
print '<td'.($warehousecanbeselectedlater?'':' class="fieldrequired"').'>'.$langs->trans("WarehouseSource").'</td>';
|
||||
print '<td>';
|
||||
print $formproduct->selectWarehouses(-1,'entrepot_id','',1);
|
||||
print $formproduct->selectWarehouses(! empty($commande->warehouse_id)?$commande->warehouse_id:-1,'entrepot_id','',1);
|
||||
if (count($formproduct->cache_warehouses) <= 0)
|
||||
{
|
||||
print ' '.$langs->trans("WarehouseSourceNotDefined").' <a href="'.DOL_URL_ROOT.'/product/stock/card.php?action=create">'.$langs->trans("AddOne").'</a>';
|
||||
|
||||
@ -67,7 +67,7 @@ ALTER TABLE llx_prelevement_lignes MODIFY COLUMN code_banque varchar(128);
|
||||
ALTER TABLE llx_societe_rib MODIFY COLUMN code_banque varchar(128);
|
||||
|
||||
ALTER TABLE llx_contrat ADD COLUMN ref_customer varchar(30);
|
||||
|
||||
ALTER TABLE llx_commande ADD COLUMN fk_warehouse integer DEFAULT NULL after fk_shipping_method;
|
||||
|
||||
ALTER TABLE llx_ecm_directories MODIFY COLUMN fullpath varchar(750);
|
||||
|
||||
|
||||
@ -63,6 +63,7 @@ create table llx_commande
|
||||
|
||||
date_livraison date default NULL,
|
||||
fk_shipping_method integer, -- shipping method id
|
||||
fk_warehouse integer default NULL,
|
||||
fk_availability integer NULL,
|
||||
fk_input_reason integer, -- id coming from c_input_reason, '0' if no defined
|
||||
fk_delivery_address integer, -- delivery address (deprecated)
|
||||
|
||||
@ -1204,6 +1204,7 @@ AskPriceSupplierPDFModules=Price requests suppliers documents models
|
||||
FreeLegalTextOnAskPriceSupplier=Free text on price requests suppliers
|
||||
WatermarkOnDraftAskPriceSupplier=Watermark on draft price requests suppliers (none if empty)
|
||||
BANK_ASK_PAYMENT_BANK_DURING_ASKPRICESUPPLIER=Ask for bank account destination of price request
|
||||
WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER=Ask for Warehouse Source for order
|
||||
##### Orders #####
|
||||
OrdersSetup=Order management setup
|
||||
OrdersNumberingModules=Orders numbering models
|
||||
@ -1699,4 +1700,3 @@ TitleExampleForMajorRelease=Example of message you can use to announce this majo
|
||||
TitleExampleForMaintenanceRelease=Example of message you can use to announce this maintenance release (feel free to use it on your web sites)
|
||||
ExampleOfNewsMessageForMajorRelease=Dolibarr ERP & CRM %s is available. Version %s is a major release with a lot of new features for both users and developers. You can download it from the download area of http://www.dolibarr.org portal (subdirectory Stable versions). You can read <a href="https://github.com/Dolibarr/dolibarr/blob/develop/ChangeLog">ChangeLog</a> for complete list of changes.
|
||||
ExampleOfNewsMessageForMaintenanceRelease=Dolibarr ERP & CRM %s is available. Version %s is a maintenance version, so it contains only fixes of bugs. We recommend everybody using an older version to upgrade to this one. As any maintenance release, no new features, nor data structure change is present into this version. You can download it from the download area of http://www.dolibarr.org portal (subdirectory Stable versions). You can read <a href="https://github.com/Dolibarr/dolibarr/blob/develop/ChangeLog">ChangeLog</a> for complete list of changes.
|
||||
|
||||
@ -134,6 +134,40 @@ class FormProduct
|
||||
return $out;
|
||||
}
|
||||
|
||||
/**
|
||||
* Display form to select warehouse
|
||||
*
|
||||
* @param string $page Page
|
||||
* @param int $selected Id of warehouse
|
||||
* @param string $htmlname Name of select html field
|
||||
* @param int $addempty 1=Add an empty value in list, 2=Add an empty value in list only if there is more than 2 entries.
|
||||
* @return void
|
||||
*/
|
||||
function formSelectWarehouses($page, $selected='', $htmlname='warehouse_id', $addempty=0)
|
||||
{
|
||||
global $langs;
|
||||
if ($htmlname != "none") {
|
||||
print '<form method="POST" action="'.$page.'">';
|
||||
print '<input type="hidden" name="action" value="setwarehouse">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<table class="nobordernopadding" cellpadding="0" cellspacing="0">';
|
||||
print '<tr><td>';
|
||||
print $this->selectWarehouses($selected, $htmlname, '', $addempty);
|
||||
print '</td>';
|
||||
print '<td align="left"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>';
|
||||
print '</tr></table></form>';
|
||||
} else {
|
||||
if ($selected) {
|
||||
require_once DOL_DOCUMENT_ROOT .'/product/stock/class/entrepot.class.php';
|
||||
$warehousestatic=new Entrepot($this->db);
|
||||
$warehousestatic->fetch($selected);
|
||||
print $warehousestatic->getNomUrl();
|
||||
} else {
|
||||
print " ";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Output a combo box with list of units
|
||||
* pour l'instant on ne definit pas les unites dans la base
|
||||
|
||||
Loading…
Reference in New Issue
Block a user