diff --git a/htdocs/admin/stock.php b/htdocs/admin/stock.php
index 031b0ef102f..db7f005284f 100644
--- a/htdocs/admin/stock.php
+++ b/htdocs/admin/stock.php
@@ -707,7 +707,15 @@ if (!empty($conf->global->MAIN_DEFAULT_WAREHOUSE_USER)) {
print "\n";
print "\n";
}
-
+print '
';
+print '| '.$langs->trans("WarehouseAskWarehouseDuringPropal").' | ';
+print '';
+if ($conf->use_javascript_ajax) {
+ print ajax_constantonoff('WAREHOUSE_ASK_WAREHOUSE_DURING_PROPAL');
+} else {
+ $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
+ print $form->selectarray("WAREHOUSE_ASK_WAREHOUSE_DURING_PROPAL", $arrval, $conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_PROPAL);
+}
print ' |
';
print '| '.$langs->trans("WarehouseAskWarehouseDuringOrder").' | ';
print '';
diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php
index 9a0861527e5..23c960d3a4b 100644
--- a/htdocs/comm/propal/card.php
+++ b/htdocs/comm/propal/card.php
@@ -130,6 +130,8 @@ $permissiondellink = $usercancreate; // Used by the include of actions_dellink.i
$permissiontoedit = $usercancreate; // Used by the include of actions_lineupdown.inc.php
+//if ($thirdparty->fk_warehouse > 0) $object->warehouse_id = $thirdparty->fk_warehouse;
+
/*
* Actions
*/
@@ -242,6 +244,7 @@ if (empty($reshook))
} // Validation
elseif ($action == 'confirm_validate' && $confirm == 'yes' && $usercanvalidate)
{
+ $idwarehouse = GETPOST('idwarehouse', 'int');
$result = $object->valid($user);
if ($result >= 0)
{
@@ -349,6 +352,7 @@ if (empty($reshook))
$object->demand_reason_id = GETPOST('demand_reason_id');
$object->fk_delivery_address = GETPOST('fk_address', 'int');
$object->shipping_method_id = GETPOST('shipping_method_id', 'int');
+ $object->warehouse_id = GETPOST('warehouse_id', 'int');
$object->duree_validite = $duration;
$object->cond_reglement_id = GETPOST('cond_reglement_id');
$object->mode_reglement_id = GETPOST('mode_reglement_id');
@@ -380,6 +384,7 @@ if (empty($reshook))
$object->demand_reason_id = GETPOST('demand_reason_id', 'int');
$object->fk_delivery_address = GETPOST('fk_address', 'int');
$object->shipping_method_id = GETPOST('shipping_method_id', 'int');
+ $object->warehouse_id = GETPOST('warehouse_id', 'int');
$object->duree_validite = price2num(GETPOST('duree_validite', 'alpha'));
$object->cond_reglement_id = GETPOST('cond_reglement_id', 'int');
$object->mode_reglement_id = GETPOST('mode_reglement_id', 'int');
@@ -1325,6 +1330,9 @@ if (empty($reshook))
} // shipping method
elseif ($action == 'setshippingmethod' && $usercancreate) {
$result = $object->setShippingMethod(GETPOST('shipping_method_id', 'int'));
+ }// warehouse
+ elseif ($action == 'setwarehouse' && $usercancreate) {
+ $result = $object->setWarehouse(GETPOST('warehouse_id', 'int'));
} elseif ($action == 'update_extras') {
$object->oldcopy = dol_clone($object);
@@ -1469,6 +1477,7 @@ if ($action == 'create')
$mode_reglement_id = (!empty($objectsrc->mode_reglement_id) ? $objectsrc->mode_reglement_id : (!empty($soc->mode_reglement_id) ? $soc->mode_reglement_id : 0));
$remise_percent = (!empty($objectsrc->remise_percent) ? $objectsrc->remise_percent : (!empty($soc->remise_percent) ? $soc->remise_percent : 0));
$remise_absolue = (!empty($objectsrc->remise_absolue) ? $objectsrc->remise_absolue : (!empty($soc->remise_absolue) ? $soc->remise_absolue : 0));
+ $warehouse_id = (!empty($objectsrc->warehouse_id) ? $objectsrc->warehouse_id : (!empty($soc->warehouse_id) ? $soc->warehouse_id : 0));
$dateinvoice = (empty($dateinvoice) ? (empty($conf->global->MAIN_AUTOFILL_DATE) ?-1 : '') : $dateinvoice);
// Replicate extrafields
@@ -1485,6 +1494,13 @@ if ($action == 'create')
if (!empty($conf->multicurrency->enabled) && !empty($soc->multicurrency_code)) $currency_code = $soc->multicurrency_code;
}
+ //Warehouse default if null
+ if (!empty($conf->stock->enabled) && empty($warehouse_id) && !empty($conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER))
+ {
+ if (empty($object->warehouse_id) && !empty($conf->global->MAIN_DEFAULT_WAREHOUSE)) $warehouse_id = $conf->global->MAIN_DEFAULT_WAREHOUSE;
+ if (empty($object->warehouse_id) && !empty($conf->global->MAIN_DEFAULT_WAREHOUSE_USER)) $warehouse_id = $user->fk_warehouse;
+ }
+
$object = new Propal($db);
print ' | ';
+ if (!empty($conf->global->SOCIETE_ASK_FOR_SHIPPING_METHOD) && !empty($soc->shipping_method_id)) {
+ $shipping_method_id = $soc->shipping_method_id;
+ }
+ //$warehouse_id = $soc->warehouse_id;
} else {
print '';
- print $form->select_company('', 'socid', '(s.client = 1 OR s.client = 2 OR s.client = 3) AND status=1', 'SelectThirdParty', 0, 0, null, 0, 'minwidth300 maxwidth500');
+ print img_picto('', 'company').$form->select_company('', 'socid', '(s.client = 1 OR s.client = 2 OR s.client = 3) AND status=1', 'SelectThirdParty', 0, 0, null, 0, 'minwidth300 maxwidth500');
// reload page to retrieve customer informations
if (empty($conf->global->RELOAD_PAGE_ON_CUSTOMER_CHANGE_DISABLED))
{
@@ -1543,6 +1563,7 @@ if ($action == 'create')
{
// Contacts (ask contact only if thirdparty already defined).
print " |
| ".$langs->trans("DefaultContact").' | ';
+ print img_picto('', 'contact');
$form->select_contacts($soc->id, $contactid, 'contactid', 1, $srccontactslist);
print ' |
';
@@ -1560,25 +1581,28 @@ if ($action == 'create')
// Date
print '| '.$langs->trans('Date').' | ';
- print $form->selectDate('', '', '', '', '', "addprop", 1, 1);
+ print img_picto('', 'object_calendarday').' '.$form->selectDate('', '', '', '', '', "addprop", 1, 1);
print ' |
';
// Validaty duration
- print '| '.$langs->trans("ValidityDuration").' | '.$langs->trans("days").' |
';
+ print '| '.$langs->trans("ValidityDuration").' | '.img_picto('', 'clock').' '.$langs->trans("days").' |
';
// Terms of payment
print '| '.$langs->trans('PaymentConditionsShort').' | ';
+ print img_picto('', 'paiment');
$form->select_conditions_paiements((GETPOSTISSET('cond_reglement_id') ? GETPOST('cond_reglement_id', 'int') : $soc->cond_reglement_id), 'cond_reglement_id', -1, 1);
print ' |
';
// Mode of payment
print '| '.$langs->trans('PaymentMode').' | ';
+ print img_picto('', 'bank').' ';
$form->select_types_paiements((GETPOSTISSET('mode_reglement_id') ? GETPOST('mode_reglement_id', 'int') : $soc->mode_reglement_id), 'mode_reglement_id');
print ' |
';
// Bank Account
if (!empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL) && !empty($conf->banque->enabled)) {
print '| '.$langs->trans('BankAccount').' | ';
+ print img_picto('', 'bank_account');
$form->select_comptes($soc->fk_account, 'fk_account', 0, '', 1);
print ' |
';
}
@@ -1593,6 +1617,7 @@ if ($action == 'create')
if (!empty($conf->commande->enabled))
print ' ('.$langs->trans('AfterOrder').')';
print '';
+ print img_picto('', 'clock').' ';
$form->selectAvailabilityDelay('', 'availability_id', '', 1);
print ' | ';
@@ -1602,13 +1627,24 @@ if ($action == 'create')
$shipping_method_id = $soc->shipping_method_id;
}
print '| '.$langs->trans('SendingMethod').' | ';
+ print img_picto('', 'object_dollyrevert').' ';
print $form->selectShippingMethod($shipping_method_id, 'shipping_method_id', '', 1);
print ' |
';
}
+ // Warehouse
+ if (!empty($conf->stock->enabled) && !empty($conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_PROPAL)) {
+ require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
+ $formproduct = new FormProduct($db);
+ print '| '.$langs->trans('Warehouse').' | ';
+ print img_picto('', 'stock').$formproduct->selectWarehouses($warehouse_id, 'warehouse_id', '', 1, 0, 0, '', 0, 0, array(), 'maxwidth175 maxwidth500 widthcentpercentminusxx');
+ print ' |
';
+ }
+
// Delivery date (or manufacturing)
print '| '.$langs->trans("DeliveryDate").' | ';
print '';
+ print img_picto('', 'object_calendarday').' ';
if ($conf->global->DATE_LIVRAISON_WEEK_DELAY != "") {
$tmpdte = time() + ((7 * $conf->global->DATE_LIVRAISON_WEEK_DELAY) * 24 * 60 * 60);
$syear = date("Y", $tmpdte);
@@ -1626,6 +1662,7 @@ if ($action == 'create')
$langs->load("projects");
print ' |
';
print '| '.$langs->trans("Project").' | ';
+ print img_picto('', 'project');
$numprojet = $formproject->select_projects(($soc->id > 0 ? $soc->id : -1), $projectid, 'projectid', 0, 0, 1, 1, 0, 0, 0, '', 0, 0, 'maxwidth500');
print ' id).'">';
print ' | ';
@@ -1646,6 +1683,7 @@ if ($action == 'create')
print '
';
print '| '.$langs->trans("DefaultModel").' | ';
print '';
+ print img_picto('', 'pdf').' ';
$liste = ModelePDFPropales::liste_modeles($db);
print $form->selectarray('model', $liste, ($conf->global->PROPALE_ADDON_PDF_ODT_DEFAULT ? $conf->global->PROPALE_ADDON_PDF_ODT_DEFAULT : $conf->global->PROPALE_ADDON_PDF));
print " |
";
@@ -2102,6 +2140,24 @@ if ($action == 'create')
print '';
}
+ // Warehouse
+ if (!empty($conf->stock->enabled) && !empty($conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_PROPAL)) {
+ $langs->load('stocks');
+ require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
+ $formproduct = new FormProduct($db);
+ print '| ';
+ $editenable = $usercancreate;
+ print $form->editfieldkey("Warehouse", 'warehouse', '', $object, $editenable);
+ print ' | ';
+ if ($action == 'editwarehouse') {
+ $formproduct->formSelectWarehouses($_SERVER['PHP_SELF'].'?id='.$object->id, $object->warehouse_id, 'warehouse_id', 1);
+ } else {
+ $formproduct->formSelectWarehouses($_SERVER['PHP_SELF'].'?id='.$object->id, $object->warehouse_id, 'none');
+ }
+ print ' | ';
+ print '
';
+ }
+
// Origin of demand
print '';
print '| ';
diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php
index 10a2238088b..739299f02a1 100644
--- a/htdocs/comm/propal/class/propal.class.php
+++ b/htdocs/comm/propal/class/propal.class.php
@@ -298,6 +298,7 @@ class Propal extends CommonObject
'model_pdf' =>array('type'=>'varchar(255)', 'label'=>'PDFTemplate', 'enabled'=>1, 'visible'=>0, 'position'=>180),
'date_livraison' =>array('type'=>'date', 'label'=>'DateDeliveryPlanned', 'enabled'=>1, 'visible'=>-1, 'position'=>185),
'fk_shipping_method' =>array('type'=>'integer', 'label'=>'ShippingMethod', 'enabled'=>1, 'visible'=>-1, 'position'=>190),
+ 'fk_warehouse' =>array('type'=>'integer:Entrepot:product/stock/class/entrepot.class.php', 'label'=>'Fk warehouse', 'enabled'=>1, 'visible'=>-1, 'position'=>191),
'fk_availability' =>array('type'=>'integer', 'label'=>'Availability', 'enabled'=>1, 'visible'=>-1, 'position'=>195),
'fk_delivery_address' =>array('type'=>'integer', 'label'=>'DeliveryAddress', 'enabled'=>1, 'visible'=>0, 'position'=>200), // deprecated
'fk_input_reason' =>array('type'=>'integer', 'label'=>'InputReason', 'enabled'=>1, 'visible'=>-1, 'position'=>205),
@@ -1051,6 +1052,7 @@ class Propal extends CommonObject
$sql .= ", ref_client";
$sql .= ", date_livraison";
$sql .= ", fk_shipping_method";
+ $sql .= ", fk_warehouse";
$sql .= ", fk_availability";
$sql .= ", fk_input_reason";
$sql .= ", fk_projet";
@@ -1083,6 +1085,7 @@ class Propal extends CommonObject
$sql .= ", '".$this->db->escape($this->ref_client)."'";
$sql .= ", ".(empty($delivery_date) ? "NULL" : "'".$this->db->idate($delivery_date)."'");
$sql .= ", ".($this->shipping_method_id > 0 ? $this->shipping_method_id : 'NULL');
+ $sql .= ", ".($this->warehouse_id > 0 ? $this->warehouse_id : 'NULL');
$sql .= ", ".$this->availability_id;
$sql .= ", ".$this->demand_reason_id;
$sql .= ", ".($this->fk_project ? $this->fk_project : "null");
@@ -1437,6 +1440,7 @@ class Propal extends CommonObject
$sql .= ", p.fk_mode_reglement";
$sql .= ', p.fk_account';
$sql .= ", p.fk_shipping_method";
+ $sql .= ", p.fk_warehouse";
$sql .= ", p.fk_incoterms, p.location_incoterms";
$sql .= ", p.fk_multicurrency, p.multicurrency_code, p.multicurrency_tx, p.multicurrency_total_ht, p.multicurrency_total_tva, p.multicurrency_total_ttc";
$sql .= ", p.tms as date_modification";
@@ -1510,6 +1514,7 @@ class Propal extends CommonObject
$this->date_livraison = $this->db->jdate($obj->delivery_date); // deprecated
$this->delivery_date = $this->db->jdate($obj->delivery_date);
$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->availability_id = $obj->fk_availability;
$this->availability_code = $obj->availability_code;
$this->availability = $obj->availability;
diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php
index 048cd861124..6dd6fc6911a 100644
--- a/htdocs/commande/card.php
+++ b/htdocs/commande/card.php
@@ -113,11 +113,6 @@ $permissionnote = $usercancreate; // Used by the include of actions_setnotes.inc
$permissiondellink = $usercancreate; // Used by the include of actions_dellink.inc.php
$permissiontoadd = $usercancreate; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
-if (!empty($conf->expedition->enabled) && !empty($conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER)) {
- if (empty($object->warehouse_id) && !empty($conf->global->MAIN_DEFAULT_WAREHOUSE)) $object->warehouse_id = $conf->global->MAIN_DEFAULT_WAREHOUSE;
- if (empty($object->warehouse_id) && !empty($conf->global->MAIN_DEFAULT_WAREHOUSE_USER)) $object->warehouse_id = $user->fk_warehouse;
-}
-
$error = 0;
$date_delivery = dol_mktime(GETPOST('liv_hour', 'int'), GETPOST('liv_min', 'int'), 0, GETPOST('liv_month', 'int'), GETPOST('liv_day', 'int'), GETPOST('liv_year', 'int'));
@@ -1538,6 +1533,13 @@ if ($action == 'create' && $usercancreate)
$note_public = $object->getDefaultCreateValueFor('note_public');
}
+ //Warehouse default if null
+ if (!empty($conf->stock->enabled) && empty($warehouse_id) && !empty($conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER))
+ {
+ if (empty($object->warehouse_id) && !empty($conf->global->MAIN_DEFAULT_WAREHOUSE)) $warehouse_id = $conf->global->MAIN_DEFAULT_WAREHOUSE;
+ if (empty($object->warehouse_id) && !empty($conf->global->MAIN_DEFAULT_WAREHOUSE_USER)) $warehouse_id = $user->fk_warehouse;
+ }
+
print ' |
|