diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php
index 0b9863f287b..4945ff63305 100644
--- a/htdocs/comm/propal/class/propal.class.php
+++ b/htdocs/comm/propal/class/propal.class.php
@@ -1138,7 +1138,7 @@ class Propal extends CommonObject
$sql = "UPDATE ".MAIN_DB_PREFIX."propal";
$sql.= " SET fk_delivery_address = ".$this->fk_delivery_address;
$sql.= " WHERE ref = '".$this->db->escape($this->ref)."'";
- $sql.= " AND entity = ".$conf->entity;
+ $sql.= " AND entity = ".$this->entity;
$result=$this->db->query($sql);
}
diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php
index b02f788f040..01b07e0d08d 100644
--- a/htdocs/comm/propal/list.php
+++ b/htdocs/comm/propal/list.php
@@ -998,7 +998,7 @@ if ($resql)
// Extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
// Fields from hook
- $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj);
+ $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i);
$reshook=$hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
// Date creation
diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php
index 05d02c487c0..32863263d7f 100644
--- a/htdocs/commande/card.php
+++ b/htdocs/commande/card.php
@@ -96,9 +96,17 @@ include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be inclu
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$hookmanager->initHooks(array('ordercard','globalcard'));
-$permissionnote = $user->rights->commande->creer; // Used by the include of actions_setnotes.inc.php
-$permissiondellink = $user->rights->commande->creer; // Used by the include of actions_dellink.inc.php
-$permissionedit = $user->rights->commande->creer; // Used by the include of actions_lineupdown.inc.php
+$usercanread = $user->rights->commande->lire;
+$usercancreate = $user->rights->commande->creer;
+$usercanclose = $user->rights->commande->cloturer;
+$usercandelete = $user->rights->commande->supprimer;
+$usercanvalidate = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $usercancreate) || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->commande->order_advance->validate)));
+$usercancancel = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $usercancreate) || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->commande->order_advance->annuler)));
+$usercansend = (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->commande->order_advance->send);
+
+$permissionnote = $usercancreate; // Used by the include of actions_setnotes.inc.php
+$permissiondellink = $usercancreate; // Used by the include of actions_dellink.inc.php
+$permissionedit = $usercancreate; // Used by the include of actions_lineupdown.inc.php
/*
@@ -129,7 +137,7 @@ if (empty($reshook))
include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php'; // Must be include, not include_once
// Action clone object
- if ($action == 'confirm_clone' && $confirm == 'yes' && $user->rights->commande->creer)
+ if ($action == 'confirm_clone' && $confirm == 'yes' && $usercancreate)
{
if (1==0 && ! GETPOST('clone_content') && ! GETPOST('clone_receivers'))
{
@@ -159,7 +167,7 @@ if (empty($reshook))
}
// Reopen a closed order
- elseif ($action == 'reopen' && $user->rights->commande->creer)
+ elseif ($action == 'reopen' && $usercancreate)
{
if ($object->statut == Commande::STATUS_CANCELED || $object->statut == Commande::STATUS_CLOSED)
{
@@ -176,7 +184,7 @@ if (empty($reshook))
}
// Remove order
- elseif ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->commande->supprimer)
+ elseif ($action == 'confirm_delete' && $confirm == 'yes' && $usercandelete)
{
$result = $object->delete($user);
if ($result > 0)
@@ -191,7 +199,7 @@ if (empty($reshook))
}
// Remove a product line
- elseif ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->commande->creer)
+ elseif ($action == 'confirm_deleteline' && $confirm == 'yes' && $usercancreate)
{
$result = $object->deleteline($user, $lineid);
if ($result > 0)
@@ -222,13 +230,13 @@ if (empty($reshook))
}
// Link to a project
- elseif ($action == 'classin' && $user->rights->commande->creer)
+ elseif ($action == 'classin' && $usercancreate)
{
$object->setProject(GETPOST('projectid', 'int'));
}
// Add order
- elseif ($action == 'add' && $user->rights->commande->creer)
+ elseif ($action == 'add' && $usercancreate)
{
$datecommande = dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear'));
$datelivraison = dol_mktime(12, 0, 0, GETPOST('liv_month'), GETPOST('liv_day'), GETPOST('liv_year'));
@@ -252,6 +260,7 @@ if (empty($reshook))
$db->begin();
$object->date_commande = $datecommande;
+ $object->entity = (GETPOSTISSET('entity')?GETPOST('entity', 'int'):$conf->entity);
$object->note_private = GETPOST('note_private', 'none');
$object->note_public = GETPOST('note_public', 'none');
$object->source = GETPOST('source_id');
@@ -481,7 +490,7 @@ if (empty($reshook))
}
}
- elseif ($action == 'classifybilled' && $user->rights->commande->creer)
+ elseif ($action == 'classifybilled' && $usercancreate)
{
$ret=$object->classifyBilled($user);
@@ -489,7 +498,7 @@ if (empty($reshook))
setEventMessages($object->error, $object->errors, 'errors');
}
}
- elseif ($action == 'classifyunbilled' && $user->rights->commande->creer)
+ elseif ($action == 'classifyunbilled' && $usercancreate)
{
$ret=$object->classifyUnBilled();
if ($ret < 0) {
@@ -498,7 +507,7 @@ if (empty($reshook))
}
// Positionne ref commande client
- elseif ($action == 'setref_client' && $user->rights->commande->creer) {
+ elseif ($action == 'setref_client' && $usercancreate) {
$result = $object->set_ref_client($user, GETPOST('ref_client'));
if ($result < 0)
{
@@ -506,7 +515,7 @@ if (empty($reshook))
}
}
- elseif ($action == 'setremise' && $user->rights->commande->creer) {
+ elseif ($action == 'setremise' && $usercancreate) {
$result = $object->set_remise($user, GETPOST('remise'));
if ($result < 0)
{
@@ -514,7 +523,7 @@ if (empty($reshook))
}
}
- elseif ($action == 'setabsolutediscount' && $user->rights->commande->creer) {
+ elseif ($action == 'setabsolutediscount' && $usercancreate) {
if (GETPOST('remise_id')) {
if ($object->id > 0) {
$object->insert_discount(GETPOST('remise_id'));
@@ -524,7 +533,7 @@ if (empty($reshook))
}
}
- elseif ($action == 'setdate' && $user->rights->commande->creer) {
+ elseif ($action == 'setdate' && $usercancreate) {
// print "x ".$_POST['liv_month'].", ".$_POST['liv_day'].", ".$_POST['liv_year'];
$date = dol_mktime(0, 0, 0, GETPOST('order_month'), GETPOST('order_day'), GETPOST('order_year'));
@@ -534,7 +543,7 @@ if (empty($reshook))
}
}
- elseif ($action == 'setdate_livraison' && $user->rights->commande->creer) {
+ elseif ($action == 'setdate_livraison' && $usercancreate) {
// print "x ".$_POST['liv_month'].", ".$_POST['liv_day'].", ".$_POST['liv_year'];
$datelivraison = dol_mktime(0, 0, 0, GETPOST('liv_month'), GETPOST('liv_day'), GETPOST('liv_year'));
@@ -544,35 +553,35 @@ if (empty($reshook))
}
}
- elseif ($action == 'setmode' && $user->rights->commande->creer) {
+ elseif ($action == 'setmode' && $usercancreate) {
$result = $object->setPaymentMethods(GETPOST('mode_reglement_id', 'int'));
if ($result < 0)
setEventMessages($object->error, $object->errors, 'errors');
}
// Multicurrency Code
- elseif ($action == 'setmulticurrencycode' && $user->rights->commande->creer) {
+ elseif ($action == 'setmulticurrencycode' && $usercancreate) {
$result = $object->setMulticurrencyCode(GETPOST('multicurrency_code', 'alpha'));
}
// Multicurrency rate
- elseif ($action == 'setmulticurrencyrate' && $user->rights->commande->creer) {
+ elseif ($action == 'setmulticurrencyrate' && $usercancreate) {
$result = $object->setMulticurrencyRate(price2num(GETPOST('multicurrency_tx')));
}
- elseif ($action == 'setavailability' && $user->rights->commande->creer) {
+ elseif ($action == 'setavailability' && $usercancreate) {
$result = $object->availability(GETPOST('availability_id'));
if ($result < 0)
setEventMessages($object->error, $object->errors, 'errors');
}
- elseif ($action == 'setdemandreason' && $user->rights->commande->creer) {
+ elseif ($action == 'setdemandreason' && $usercancreate) {
$result = $object->demand_reason(GETPOST('demand_reason_id'));
if ($result < 0)
setEventMessages($object->error, $object->errors, 'errors');
}
- elseif ($action == 'setconditions' && $user->rights->commande->creer) {
+ elseif ($action == 'setconditions' && $usercancreate) {
$result = $object->setPaymentTerms(GETPOST('cond_reglement_id', 'int'));
if ($result < 0) {
dol_print_error($db, $object->error);
@@ -604,7 +613,7 @@ if (empty($reshook))
}
// bank account
- elseif ($action == 'setbankaccount' && $user->rights->commande->creer) {
+ elseif ($action == 'setbankaccount' && $usercancreate) {
$result=$object->setBankAccount(GETPOST('fk_account', 'int'));
if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors');
@@ -612,7 +621,7 @@ if (empty($reshook))
}
// shipping method
- elseif ($action == 'setshippingmethod' && $user->rights->commande->creer) {
+ elseif ($action == 'setshippingmethod' && $usercancreate) {
$result = $object->setShippingMethod(GETPOST('shipping_method_id', 'int'));
if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors');
@@ -620,23 +629,23 @@ if (empty($reshook))
}
// warehouse
- elseif ($action == 'setwarehouse' && $user->rights->commande->creer) {
+ elseif ($action == 'setwarehouse' && $usercancreate) {
$result = $object->setWarehouse(GETPOST('warehouse_id', 'int'));
if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors');
}
}
- elseif ($action == 'setremisepercent' && $user->rights->commande->creer) {
+ elseif ($action == 'setremisepercent' && $usercancreate) {
$result = $object->set_remise($user, GETPOST('remise_percent'));
}
- elseif ($action == 'setremiseabsolue' && $user->rights->commande->creer) {
+ elseif ($action == 'setremiseabsolue' && $usercancreate) {
$result = $object->set_remise_absolue($user, GETPOST('remise_absolue'));
}
// Add a new line
- elseif ($action == 'addline' && $user->rights->commande->creer)
+ elseif ($action == 'addline' && $usercancreate)
{
$langs->load('errors');
$error = 0;
@@ -999,7 +1008,7 @@ if (empty($reshook))
/*
* Update a line
*/
- elseif ($action == 'updateline' && $user->rights->commande->creer && GETPOST('save'))
+ elseif ($action == 'updateline' && $usercancreate && GETPOST('save'))
{
// Clean parameters
$date_start='';
@@ -1133,15 +1142,12 @@ if (empty($reshook))
setEventMessages($object->error, $object->errors, 'errors');
}
}
- } elseif ($action == 'updateline' && $user->rights->commande->creer && GETPOST('cancel', 'alpha') == $langs->trans('Cancel')) {
+ } elseif ($action == 'updateline' && $usercancreate && GETPOST('cancel', 'alpha') == $langs->trans('Cancel')) {
header('Location: ' . $_SERVER['PHP_SELF'] . '?id=' . $object->id); // Pour reaffichage de la fiche en cours d'edition
exit();
}
- elseif ($action == 'confirm_validate' && $confirm == 'yes' &&
- ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->commande->creer))
- || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->commande->order_advance->validate)))
- )
+ elseif ($action == 'confirm_validate' && $confirm == 'yes' && $usercanvalidate)
{
$idwarehouse = GETPOST('idwarehouse');
@@ -1195,7 +1201,7 @@ if (empty($reshook))
}
// Go back to draft status
- elseif ($action == 'confirm_modif' && $user->rights->commande->creer) {
+ elseif ($action == 'confirm_modif' && $usercancreate) {
$idwarehouse = GETPOST('idwarehouse');
$qualified_for_stock_change=0;
@@ -1243,17 +1249,14 @@ if (empty($reshook))
}
}
- elseif ($action == 'confirm_shipped' && $confirm == 'yes' && $user->rights->commande->cloturer) {
+ elseif ($action == 'confirm_shipped' && $confirm == 'yes' && $usercanclose) {
$result = $object->cloture($user);
if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors');
}
}
- elseif ($action == 'confirm_cancel' && $confirm == 'yes' &&
- ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->commande->creer))
- || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->commande->order_advance->validate)))
- )
+ elseif ($action == 'confirm_cancel' && $confirm == 'yes' && $usercanvalidate)
{
$idwarehouse = GETPOST('idwarehouse');
@@ -1310,7 +1313,7 @@ if (empty($reshook))
if ($error) $action = 'edit_extras';
}
- if ($action == 'set_thirdparty' && $user->rights->commande->creer)
+ if ($action == 'set_thirdparty' && $usercancreate)
{
$object->fetch($id);
$object->setValueFrom('fk_soc', $socid, '', '', 'date', '', $user, 'ORDER_MODIFY');
@@ -1321,7 +1324,7 @@ if (empty($reshook))
// add lines from objectlinked
if($action == 'import_lines_from_object'
- && $user->rights->commande->creer
+ && $usercancreate
&& $object->statut == Commande::STATUS_DRAFT
)
{
@@ -1405,8 +1408,8 @@ if (empty($reshook))
include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php';
// Actions to build doc
- $upload_dir = $conf->commande->dir_output;
- $permissioncreate = $user->rights->commande->creer;
+ $upload_dir = $conf->commande->multidir_output[$object->entity];
+ $permissioncreate = $usercancreate;
include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
// Actions to send emails
@@ -1417,7 +1420,7 @@ if (empty($reshook))
include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';
- if (! $error && ! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->commande->creer)
+ if (! $error && ! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $usercancreate)
{
if ($action == 'addcontact')
{
@@ -1478,7 +1481,7 @@ $formmargin = new FormMargin($db);
if (! empty($conf->projet->enabled)) { $formproject = new FormProjets($db); }
// Mode creation
-if ($action == 'create' && $user->rights->commande->creer)
+if ($action == 'create' && $usercancreate)
{
print load_fiche_titre($langs->trans('CreateOrder'), '', 'title_commercial.png');
@@ -2069,8 +2072,8 @@ if ($action == 'create' && $user->rights->commande->creer)
$morehtmlref='
';
// Ref customer
- $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, $user->rights->commande->creer, 'string', '', 0, 1);
- $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, $user->rights->commande->creer, 'string', '', null, null, '', 1);
+ $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, $usercancreate, 'string', '', 0, 1);
+ $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, $usercancreate, 'string', '', null, null, '', 1);
// Thirdparty
$morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . $soc->getNomUrl(1);
if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) $morehtmlref.=' (
'.$langs->trans("OtherOrders").')';
@@ -2079,7 +2082,7 @@ if ($action == 'create' && $user->rights->commande->creer)
{
$langs->load("projects");
$morehtmlref.='
'.$langs->trans('Project') . ' ';
- if ($user->rights->commande->creer)
+ if ($usercancreate)
{
if ($action != 'classify')
$morehtmlref.='
' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : ';
@@ -2159,7 +2162,7 @@ if ($action == 'create' && $user->rights->commande->creer)
// Date
print '
| ';
- $editenable = $user->rights->commande->creer && $object->statut == Commande::STATUS_DRAFT;
+ $editenable = $usercancreate && $object->statut == Commande::STATUS_DRAFT;
print $form->editfieldkey("Date", 'date', '', $object, $editenable);
print ' | ';
if ($action == 'editdate') {
@@ -2180,7 +2183,7 @@ if ($action == 'create' && $user->rights->commande->creer)
// Delivery date planed
print ' |
| ';
- $editenable = $user->rights->commande->creer;
+ $editenable = $usercancreate;
print $form->editfieldkey("DateDeliveryPlanned", 'date_livraison', '', $object, $editenable);
print ' | ';
if ($action == 'editdate_livraison') {
@@ -2202,7 +2205,7 @@ if ($action == 'create' && $user->rights->commande->creer)
// Shipping Method
if (! empty($conf->expedition->enabled)) {
print ' |
| ';
- $editenable = $user->rights->commande->creer;
+ $editenable = $usercancreate;
print $form->editfieldkey("SendingMethod", 'shippingmethod', '', $object, $editenable);
print ' | ';
if ($action == 'editshippingmethod') {
@@ -2220,7 +2223,7 @@ if ($action == 'create' && $user->rights->commande->creer)
require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
$formproduct=new FormProduct($db);
print ' |
| ';
- $editenable = $user->rights->commande->creer;
+ $editenable = $usercancreate;
print $form->editfieldkey("Warehouse", 'warehouse', '', $object, $editenable);
print ' | ';
if ($action == 'editwarehouse') {
@@ -2234,7 +2237,7 @@ if ($action == 'create' && $user->rights->commande->creer)
// Terms of payment
print ' |
| ';
- $editenable = $user->rights->commande->creer;
+ $editenable = $usercancreate;
print $form->editfieldkey("PaymentConditionsShort", 'conditions', '', $object, $editenable);
print ' | ';
if ($action == 'editconditions') {
@@ -2248,7 +2251,7 @@ if ($action == 'create' && $user->rights->commande->creer)
// Mode of payment
print ' |
| ';
- $editenable = $user->rights->commande->creer;
+ $editenable = $usercancreate;
print $form->editfieldkey("PaymentMode", 'mode', '', $object, $editenable);
print ' | ';
if ($action == 'editmode') {
@@ -2264,7 +2267,7 @@ if ($action == 'create' && $user->rights->commande->creer)
// Multicurrency code
print ' |
';
print '| ';
- $editenable = $user->rights->commande->creer && $object->statut == Commande::STATUS_DRAFT;
+ $editenable = $usercancreate && $object->statut == Commande::STATUS_DRAFT;
print $form->editfieldkey("Currency", 'multicurrencycode', '', $object, $editenable);
print ' | ';
if ($action == 'editmulticurrencycode') {
@@ -2277,7 +2280,7 @@ if ($action == 'create' && $user->rights->commande->creer)
// Multicurrency rate
print ' |
';
print '| ';
- $editenable = $user->rights->commande->creer && $object->multicurrency_code && $object->multicurrency_code != $conf->currency && $object->statut == Commande::STATUS_DRAFT;
+ $editenable = $usercancreate && $object->multicurrency_code && $object->multicurrency_code != $conf->currency && $object->statut == Commande::STATUS_DRAFT;
print $form->editfieldkey("CurrencyRate", 'multicurrencyrate', '', $object, $editenable);
print ' | ';
if ($action == 'editmulticurrencyrate' || $action == 'actualizemulticurrencyrate') {
@@ -2298,7 +2301,7 @@ if ($action == 'create' && $user->rights->commande->creer)
// Delivery delay
print ' |
| ';
- $editenable = $user->rights->commande->creer;
+ $editenable = $usercancreate;
print $form->editfieldkey("AvailabilityPeriod", 'availability', '', $object, $editenable);
print ' | ';
if ($action == 'editavailability') {
@@ -2310,7 +2313,7 @@ if ($action == 'create' && $user->rights->commande->creer)
// Source reason (why we have an ordrer)
print ' |
| ';
- $editenable = $user->rights->commande->creer;
+ $editenable = $usercancreate;
print $form->editfieldkey("Channel", 'demandreason', '', $object, $editenable);
print ' | ';
if ($action == 'editdemandreason') {
@@ -2323,7 +2326,7 @@ if ($action == 'create' && $user->rights->commande->creer)
// TODO Order mode (how we receive order). Not yet implemented
/*
print ' |
| ';
- $editenable = $user->rights->commande->creer;
+ $editenable = $usercancreate;
print $form->editfieldkey("SourceMode", 'inputmode', '', $object, $editenable);
print ' | ';
if ($action == 'editinputmode') {
@@ -2355,7 +2358,7 @@ if ($action == 'create' && $user->rights->commande->creer)
// Incoterms
if (!empty($conf->incoterm->enabled)) {
print ' |
| ';
- $editenable = $user->rights->commande->creer;
+ $editenable = $usercancreate;
print $form->editfieldkey("IncotermLabel", 'incoterm', '', $object, $editenable);
print ' | ';
print '';
@@ -2373,7 +2376,7 @@ if ($action == 'create' && $user->rights->commande->creer)
// Bank Account
if (! empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_ORDER) && ! empty($conf->banque->enabled)) {
print ' |
| ';
- $editenable = $user->rights->commande->creer;
+ $editenable = $usercancreate;
print $form->editfieldkey("BankAccount", 'bankaccount', '', $object, $editenable);
print ' | ';
if ($action == 'editbankaccount') {
@@ -2497,7 +2500,7 @@ if ($action == 'create' && $user->rights->commande->creer)
/*
* Form to add new line
*/
- if ($object->statut == Commande::STATUS_DRAFT && $user->rights->commande->creer && $action != 'selectlines')
+ if ($object->statut == Commande::STATUS_DRAFT && $usercancreate && $action != 'selectlines')
{
if ($action != 'editline')
{
@@ -2528,22 +2531,19 @@ if ($action == 'create' && $user->rights->commande->creer)
if (empty($reshook)) {
// Send
if ($object->statut > Commande::STATUS_DRAFT) {
- if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->commande->order_advance->send)) {
+ if ($usercansend) {
print '';
} else
print '';
}
// Valid
- if ($object->statut == Commande::STATUS_DRAFT && $object->total_ttc >= 0 && $numlines > 0 &&
- ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->commande->creer))
- || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->commande->order_advance->validate)))
- )
+ if ($object->statut == Commande::STATUS_DRAFT && $object->total_ttc >= 0 && $numlines > 0 && $usercanvalidate)
{
print '';
}
// Edit
- if ($object->statut == Commande::STATUS_VALIDATED && $user->rights->commande->creer) {
+ if ($object->statut == Commande::STATUS_VALIDATED && $usercancreate) {
print '';
}
// Create event
@@ -2597,12 +2597,12 @@ if ($action == 'create' && $user->rights->commande->creer)
}
// Reopen a closed order
- if (($object->statut == Commande::STATUS_CLOSED || $object->statut == Commande::STATUS_CANCELED) && $user->rights->commande->creer) {
+ if (($object->statut == Commande::STATUS_CLOSED || $object->statut == Commande::STATUS_CANCELED) && $usercancreate) {
print '';
}
// Set to shipped
- if (($object->statut == Commande::STATUS_VALIDATED || $object->statut == Commande::STATUS_SHIPMENTONPROCESS) && $user->rights->commande->cloturer) {
+ if (($object->statut == Commande::STATUS_VALIDATED || $object->statut == Commande::STATUS_SHIPMENTONPROCESS) && $usercanclose) {
print '';
}
@@ -2612,31 +2612,28 @@ if ($action == 'create' && $user->rights->commande->creer)
if (! empty($conf->facture->enabled) && $user->rights->facture->creer && empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) {
print '';
}
- if ($user->rights->commande->creer && $object->statut >= Commande::STATUS_VALIDATED && empty($conf->global->WORKFLOW_DISABLE_CLASSIFY_BILLED_FROM_ORDER) && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT)) {
+ if ($usercancreate && $object->statut >= Commande::STATUS_VALIDATED && empty($conf->global->WORKFLOW_DISABLE_CLASSIFY_BILLED_FROM_ORDER) && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT)) {
print '';
}
}
if ($object->statut > Commande::STATUS_DRAFT && $object->billed) {
- if ($user->rights->commande->creer && $object->statut >= Commande::STATUS_VALIDATED && empty($conf->global->WORKFLOW_DISABLE_CLASSIFY_BILLED_FROM_ORDER) && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT)) {
+ if ($usercancreate && $object->statut >= Commande::STATUS_VALIDATED && empty($conf->global->WORKFLOW_DISABLE_CLASSIFY_BILLED_FROM_ORDER) && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT)) {
print '';
}
}
// Clone
- if ($user->rights->commande->creer) {
+ if ($usercancreate) {
print '';
}
// Cancel order
- if ($object->statut == Commande::STATUS_VALIDATED &&
- ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->commande->cloturer))
- || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->commande->order_advance->annuler)))
- )
+ if ($object->statut == Commande::STATUS_VALIDATED && (! empty($usercanclose) || ! empty($usercancancel)))
{
print '';
}
// Delete order
- if ($user->rights->commande->supprimer) {
+ if ($usercandelete) {
if ($numshipping == 0) {
print '';
} else {
@@ -2659,18 +2656,18 @@ if ($action == 'create' && $user->rights->commande->creer)
// Documents
$comref = dol_sanitizeFileName($object->ref);
$relativepath = $comref . '/' . $comref . '.pdf';
- $filedir = $conf->commande->dir_output . '/' . $comref;
+ $filedir = $conf->commande->multidir_output[$object->entity] . '/' . $comref;
$urlsource = $_SERVER["PHP_SELF"] . "?id=" . $object->id;
- $genallowed = $user->rights->commande->lire;
- $delallowed = $user->rights->commande->creer;
- print $formfile->showdocuments('commande', $comref, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang);
+ $genallowed = $usercanread;
+ $delallowed = $usercancreate;
+ print $formfile->showdocuments('commande', $comref, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang, '', $object);
// Show links to link elements
$linktoelem = $form->showLinkToObjectBlock($object, null, array('order'));
$compatibleImportElementsList = false;
- if($user->rights->commande->creer
+ if($usercancreate
&& $object->statut == Commande::STATUS_DRAFT)
{
$compatibleImportElementsList = array('commande','propal'); // import from linked elements
@@ -2707,7 +2704,7 @@ if ($action == 'create' && $user->rights->commande->creer)
// Presend form
$modelmail='order_send';
$defaulttopic='SendOrderRef';
- $diroutput = $conf->commande->dir_output;
+ $diroutput = $conf->commande->multidir_output[$object->entity];
$trackid = 'ord'.$object->id;
include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php';
diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php
index 35cb8335232..fdf9703eb8f 100644
--- a/htdocs/commande/class/commande.class.php
+++ b/htdocs/commande/class/commande.class.php
@@ -427,8 +427,8 @@ class Commande extends CommonOrder
// in order not to lose the attachments
$oldref = dol_sanitizeFileName($this->ref);
$newref = dol_sanitizeFileName($num);
- $dirsource = $conf->commande->dir_output.'/'.$oldref;
- $dirdest = $conf->commande->dir_output.'/'.$newref;
+ $dirsource = $conf->commande->multidir_output[$this->entity].'/'.$oldref;
+ $dirdest = $conf->commande->multidir_output[$this->entity].'/'.$newref;
if (file_exists($dirsource))
{
dol_syslog(get_class($this)."::valid() rename dir ".$dirsource." into ".$dirdest);
@@ -437,7 +437,7 @@ class Commande extends CommonOrder
{
dol_syslog("Rename ok");
// Rename docs starting with $oldref with $newref
- $listoffiles=dol_dir_list($conf->commande->dir_output.'/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/'));
+ $listoffiles=dol_dir_list($conf->commande->multidir_output[$this->entity].'/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/'));
foreach($listoffiles as $fileentry)
{
$dirsource=$fileentry['name'];
@@ -776,6 +776,7 @@ class Commande extends CommonOrder
// Clean parameters
$this->brouillon = 1; // set command as draft
+ if (empty($this->entity)) $this->entity = $conf->entity;
// $date_commande is deprecated
$date = ($this->date_commande ? $this->date_commande : $this->date);
@@ -859,7 +860,7 @@ class Commande extends CommonOrder
$sql.= ", ".($this->remise_percent>0?$this->db->escape($this->remise_percent):0);
$sql.= ", ".(int) $this->fk_incoterms;
$sql.= ", '".$this->db->escape($this->location_incoterms)."'";
- $sql.= ", ".$conf->entity;
+ $sql.= ", ".$this->entity;
$sql.= ", ".($this->module_source ? "'".$this->db->escape($this->module_source)."'" : "null");
$sql.= ", ".($this->pos_source != '' ? "'".$this->db->escape($this->pos_source)."'" : "null");
$sql.= ", ".(int) $this->fk_multicurrency;
@@ -1232,6 +1233,7 @@ class Commande extends CommonOrder
$this->lines[$i] = $line;
}
+ $this->entity = $object->entity;
$this->socid = $object->socid;
$this->fk_project = $object->fk_project;
$this->cond_reglement_id = $object->cond_reglement_id;
@@ -3320,10 +3322,10 @@ class Commande extends CommonOrder
{
// Remove directory with files
$comref = dol_sanitizeFileName($this->ref);
- if ($conf->commande->dir_output && !empty($this->ref))
+ if ($conf->commande->multidir_output[$this->entity] && !empty($this->ref))
{
- $dir = $conf->commande->dir_output . "/" . $comref ;
- $file = $conf->commande->dir_output . "/" . $comref . "/" . $comref . ".pdf";
+ $dir = $conf->commande->multidir_output[$this->entity] . "/" . $comref ;
+ $file = $conf->commande->multidir_output[$this->entity] . "/" . $comref . "/" . $comref . ".pdf";
if (file_exists($file)) // We must delete all files before deleting directory
{
dol_delete_preview($this);
diff --git a/htdocs/commande/document.php b/htdocs/commande/document.php
index 37cbc70cd40..ec6ed2fd91b 100644
--- a/htdocs/commande/document.php
+++ b/htdocs/commande/document.php
@@ -72,7 +72,7 @@ $object = new Commande($db);
if ($object->fetch($id))
{
$object->fetch_thirdparty();
- $upload_dir = $conf->commande->dir_output . "/" . dol_sanitizeFileName($object->ref);
+ $upload_dir = $conf->commande->multidir_output[$object->entity] . "/" . dol_sanitizeFileName($object->ref);
}
include_once DOL_DOCUMENT_ROOT . '/core/actions_linkedfiles.inc.php';
@@ -92,7 +92,7 @@ if ($id > 0 || ! empty($ref))
{
$object->fetch_thirdparty();
- $upload_dir = $conf->commande->dir_output.'/'.dol_sanitizeFileName($object->ref);
+ $upload_dir = $conf->commande->multidir_output[$object->entity].'/'.dol_sanitizeFileName($object->ref);
$head = commande_prepare_head($object);
dol_fiche_head($head, 'documents', $langs->trans('CustomerOrder'), -1, 'order');
@@ -174,7 +174,7 @@ if ($id > 0 || ! empty($ref))
$modulepart = 'commande';
$permission = $user->rights->commande->creer;
$permtoedit = $user->rights->commande->creer;
- $param = '&id=' . $object->id;
+ $param = '&id=' . $object->id.'&entity=' . (! empty($object->entity)?$object->entity:$conf->entity);
include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php';
}
else
diff --git a/htdocs/commande/index.php b/htdocs/commande/index.php
index c0091b43af0..123bb64b837 100644
--- a/htdocs/commande/index.php
+++ b/htdocs/commande/index.php
@@ -235,7 +235,7 @@ $max=5;
* Last modified orders
*/
-$sql = "SELECT c.rowid, c.ref, c.fk_statut, c.facture, c.date_cloture as datec, c.tms as datem,";
+$sql = "SELECT c.rowid, c.entity, c.ref, c.fk_statut, c.facture, c.date_cloture as datec, c.tms as datem,";
$sql.= " s.nom as name, s.rowid as socid";
$sql.= ", s.client";
$sql.= ", s.code_client";
@@ -291,7 +291,7 @@ if ($resql)
print ' | ';
$filename=dol_sanitizeFileName($obj->ref);
- $filedir=$conf->commande->dir_output . '/' . dol_sanitizeFileName($obj->ref);
+ $filedir=$conf->commande->multidir_output[$obj->entity] . '/' . dol_sanitizeFileName($obj->ref);
$urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->rowid;
print $formfile->getDocumentsLink($commandestatic->element, $filename, $filedir);
print ' |
';
@@ -317,7 +317,7 @@ else dol_print_error($db);
*/
if (! empty($conf->commande->enabled))
{
- $sql = "SELECT c.rowid, c.ref, c.fk_statut, c.facture, s.nom as name, s.rowid as socid";
+ $sql = "SELECT c.rowid, c.entity, c.ref, c.fk_statut, c.facture, s.nom as name, s.rowid as socid";
$sql.= ", s.client";
$sql.= ", s.code_client";
$sql.= ", s.canvas";
@@ -371,7 +371,7 @@ if (! empty($conf->commande->enabled))
print '
';
$filename=dol_sanitizeFileName($obj->ref);
- $filedir=$conf->commande->dir_output . '/' . dol_sanitizeFileName($obj->ref);
+ $filedir=$conf->commande->multidir_output[$obj->entity] . '/' . dol_sanitizeFileName($obj->ref);
$urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->rowid;
print $formfile->getDocumentsLink($commandestatic->element, $filename, $filedir);
print ' | ';
@@ -399,7 +399,7 @@ if (! empty($conf->commande->enabled))
*/
if (! empty($conf->commande->enabled))
{
- $sql = "SELECT c.rowid, c.ref, c.fk_statut, c.facture, s.nom as name, s.rowid as socid";
+ $sql = "SELECT c.rowid, c.entity, c.ref, c.fk_statut, c.facture, s.nom as name, s.rowid as socid";
$sql.= ", s.client";
$sql.= ", s.code_client";
$sql.= ", s.canvas";
@@ -453,7 +453,7 @@ if (! empty($conf->commande->enabled))
print '
';
$filename=dol_sanitizeFileName($obj->ref);
- $filedir=$conf->commande->dir_output . '/' . dol_sanitizeFileName($obj->ref);
+ $filedir=$conf->commande->multidir_output[$obj->entity] . '/' . dol_sanitizeFileName($obj->ref);
$urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->rowid;
print $formfile->getDocumentsLink($commandestatic->element, $filename, $filedir);
print ' | ';
diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php
index ad3fd777a5c..073228194b5 100644
--- a/htdocs/commande/list.php
+++ b/htdocs/commande/list.php
@@ -91,7 +91,7 @@ $id = (GETPOST('orderid')?GETPOST('orderid', 'int'):GETPOST('id', 'int'));
if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user, 'commande', $id, '');
-$diroutputmassaction=$conf->commande->dir_output . '/temp/massgeneration/'.$user->id;
+$diroutputmassaction=$conf->commande->multidir_output[$conf->entity] . '/temp/massgeneration/'.$user->id;
// Load variable for pagination
$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit;
@@ -217,7 +217,7 @@ if (empty($reshook))
$objectlabel='Orders';
$permtoread = $user->rights->commande->lire;
$permtodelete = $user->rights->commande->supprimer;
- $uploaddir = $conf->commande->dir_output;
+ $uploaddir = $conf->commande->multidir_output[$conf->entity];
$trigger_name='ORDER_SENTBYMAIL';
include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
}
@@ -928,7 +928,7 @@ if ($resql)
print '
';
$filename=dol_sanitizeFileName($obj->ref);
- $filedir=$conf->commande->dir_output . '/' . dol_sanitizeFileName($obj->ref);
+ $filedir=$conf->commande->multidir_output[$conf->entity] . '/' . dol_sanitizeFileName($obj->ref);
$urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->rowid;
print $formfile->getDocumentsLink($generic_commande->element, $filename, $filedir);
print ' | ';
@@ -1075,7 +1075,7 @@ if ($resql)
// Extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
// Fields from hook
- $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj);
+ $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i);
$reshook=$hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
// Date creation
diff --git a/htdocs/commande/orderstoinvoice.php b/htdocs/commande/orderstoinvoice.php
index fe017a6b1aa..a960c703eba 100644
--- a/htdocs/commande/orderstoinvoice.php
+++ b/htdocs/commande/orderstoinvoice.php
@@ -548,7 +548,7 @@ if (($action != 'create' && $action != 'add') || ($action == 'create' && $error)
';
$filename=dol_sanitizeFileName($objp->ref);
- $filedir=$conf->commande->dir_output . '/' . dol_sanitizeFileName($objp->ref);
+ $filedir=$conf->commande->multidir_output[$objp->entity] . '/' . dol_sanitizeFileName($objp->ref);
$urlsource=$_SERVER['PHP_SELF'].'?id='.$objp->rowid;
print $formfile->getDocumentsLink($generic_commande->element, $filename, $filedir);
print '';
diff --git a/htdocs/compta/facture/document.php b/htdocs/compta/facture/document.php
index 44f69f512bd..9a8f308a0d1 100644
--- a/htdocs/compta/facture/document.php
+++ b/htdocs/compta/facture/document.php
@@ -97,7 +97,7 @@ if ($id > 0 || ! empty($ref))
{
$object->fetch_thirdparty();
- $upload_dir = $conf->facture->dir_output.'/'.dol_sanitizeFileName($object->ref);
+ $upload_dir = $conf->facture->multidir_output[$object->entity].'/'.dol_sanitizeFileName($object->ref);
$head = facture_prepare_head($object);
dol_fiche_head($head, 'documents', $langs->trans('InvoiceCustomer'), -1, 'bill');
diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php
index 05ce6cc3504..b89d257e258 100644
--- a/htdocs/compta/facture/list.php
+++ b/htdocs/compta/facture/list.php
@@ -1202,7 +1202,7 @@ if ($resql)
// Extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
// Fields from hook
- $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj);
+ $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i);
$reshook=$hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
// Date creation
diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php
index 576aff4db66..858d16948e2 100644
--- a/htdocs/core/class/html.formfile.class.php
+++ b/htdocs/core/class/html.formfile.class.php
@@ -1228,7 +1228,7 @@ class FormFile
print '';
}
// Preview link
- if (! $editline) print $this->showPreview($file, $modulepart, $filepath);
+ if (! $editline) print $this->showPreview($file, $modulepart, $filepath, 0, '&entity='.(! empty($object->entity)?$object->entity:$onf->entity));
print "\n";
diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php
index e00f79b27bc..c7585b65254 100644
--- a/htdocs/core/lib/files.lib.php
+++ b/htdocs/core/lib/files.lib.php
@@ -2186,10 +2186,10 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity,
$original_file=$conf->adherent->dir_output.'/'.$original_file;
}
// Wrapping pour les apercu factures
- elseif ($modulepart == 'apercufacture' && !empty($conf->facture->dir_output))
+ elseif ($modulepart == 'apercufacture' && !empty($conf->facture->multidir_output[$entity]))
{
if ($fuser->rights->facture->{$lire}) $accessallowed=1;
- $original_file=$conf->facture->dir_output.'/'.$original_file;
+ $original_file=$conf->facture->multidir_output[$entity].'/'.$original_file;
}
// Wrapping pour les apercu propal
elseif ($modulepart == 'apercupropal' && !empty($conf->propal->multidir_output[$entity]))
@@ -2198,10 +2198,10 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity,
$original_file=$conf->propal->multidir_output[$entity].'/'.$original_file;
}
// Wrapping pour les apercu commande
- elseif ($modulepart == 'apercucommande' && !empty($conf->commande->dir_output))
+ elseif ($modulepart == 'apercucommande' && !empty($conf->commande->multidir_output[$entity]))
{
if ($fuser->rights->commande->{$lire}) $accessallowed=1;
- $original_file=$conf->commande->dir_output.'/'.$original_file;
+ $original_file=$conf->commande->multidir_output[$entity].'/'.$original_file;
}
// Wrapping pour les apercu intervention
elseif (($modulepart == 'apercufichinter' || $modulepart == 'apercuficheinter') && !empty($conf->ficheinter->dir_output))
@@ -2397,13 +2397,13 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity,
}
// Wrapping for invoices
- elseif (($modulepart == 'facture' || $modulepart == 'invoice') && !empty($conf->facture->dir_output))
+ elseif (($modulepart == 'facture' || $modulepart == 'invoice') && !empty($conf->facture->multidir_output[$entity]))
{
if ($fuser->rights->facture->{$lire} || preg_match('/^specimen/i', $original_file))
{
$accessallowed=1;
}
- $original_file=$conf->facture->dir_output.'/'.$original_file;
+ $original_file=$conf->facture->multidir_output[$entity].'/'.$original_file;
$sqlprotectagainstexternals = "SELECT fk_soc as fk_soc FROM ".MAIN_DB_PREFIX."facture WHERE ref='".$db->escape($refname)."' AND entity=".$conf->entity;
}
// Wrapping for mass actions
@@ -2421,7 +2421,7 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity,
{
$accessallowed=1;
}
- $original_file=$conf->commande->dir_output.'/temp/massgeneration/'.$user->id.'/'.$original_file;
+ $original_file=$conf->commande->multidir_output[$entity].'/temp/massgeneration/'.$user->id.'/'.$original_file;
}
elseif ($modulepart == 'massfilesarea_invoices')
{
@@ -2429,7 +2429,7 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity,
{
$accessallowed=1;
}
- $original_file=$conf->facture->dir_output.'/temp/massgeneration/'.$user->id.'/'.$original_file;
+ $original_file=$conf->facture->multidir_output[$entity].'/temp/massgeneration/'.$user->id.'/'.$original_file;
}
elseif ($modulepart == 'massfilesarea_expensereport')
{
@@ -2513,13 +2513,13 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity,
}
// Wrapping pour les commandes
- elseif (($modulepart == 'commande' || $modulepart == 'order') && !empty($conf->commande->dir_output))
+ elseif (($modulepart == 'commande' || $modulepart == 'order') && !empty($conf->commande->multidir_output[$entity]))
{
if ($fuser->rights->commande->{$lire} || preg_match('/^specimen/i', $original_file))
{
$accessallowed=1;
}
- $original_file=$conf->commande->dir_output.'/'.$original_file;
+ $original_file=$conf->commande->multidir_output[$entity].'/'.$original_file;
$sqlprotectagainstexternals = "SELECT fk_soc as fk_soc FROM ".MAIN_DB_PREFIX."commande WHERE ref='".$db->escape($refname)."' AND entity=".$conf->entity;
}
diff --git a/htdocs/core/lib/order.lib.php b/htdocs/core/lib/order.lib.php
index 6e276dcf8f4..5727ececb5e 100644
--- a/htdocs/core/lib/order.lib.php
+++ b/htdocs/core/lib/order.lib.php
@@ -96,7 +96,7 @@ function commande_prepare_head(Commande $object)
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
- $upload_dir = $conf->commande->dir_output . "/" . dol_sanitizeFileName($object->ref);
+ $upload_dir = $conf->commande->multidir_output[$object->entity] . "/" . dol_sanitizeFileName($object->ref);
$nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
$nbLinks=Link::count($db, $object->element, $object->id);
$head[$h][0] = DOL_URL_ROOT.'/commande/document.php?id='.$object->id;
diff --git a/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php b/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php
index 5685a839314..eced22d03d8 100644
--- a/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php
+++ b/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php
@@ -244,7 +244,7 @@ class doc_generic_order_odt extends ModelePDFCommandes
}
}
- $dir = $conf->commande->dir_output;
+ $dir = $conf->commande->multidir_output[$object->entity];
$objectref = dol_sanitizeFileName($object->ref);
if (! preg_match('/specimen/i', $objectref)) $dir.= "/" . $objectref;
$file = $dir . "/" . $objectref . ".odt";
diff --git a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php
index 5975da49fbe..78cb2adc9f9 100644
--- a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php
+++ b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php
@@ -239,13 +239,13 @@ class pdf_einstein extends ModelePDFCommandes
// Definition of $dir and $file
if ($object->specimen)
{
- $dir = $conf->commande->dir_output;
+ $dir = $conf->commande->multidir_output[$conf->entity];
$file = $dir . "/SPECIMEN.pdf";
}
else
{
$objectref = dol_sanitizeFileName($object->ref);
- $dir = $conf->commande->dir_output . "/" . $objectref;
+ $dir = $conf->commande->multidir_output[$object->entity] . "/" . $objectref;
$file = $dir . "/" . $objectref . ".pdf";
}
diff --git a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php
index 1abc6c95e20..d0c5197587f 100644
--- a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php
+++ b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php
@@ -281,13 +281,13 @@ class pdf_eratosthene extends ModelePDFCommandes
// Definition of $dir and $file
if ($object->specimen)
{
- $dir = $conf->commande->dir_output;
+ $dir = $conf->commande->multidir_output[$conf->entity];
$file = $dir . "/SPECIMEN.pdf";
}
else
{
$objectref = dol_sanitizeFileName($object->ref);
- $dir = $conf->commande->dir_output . "/" . $objectref;
+ $dir = $conf->commande->multidir_output[$object->entity] . "/" . $objectref;
$file = $dir . "/" . $objectref . ".pdf";
}
diff --git a/htdocs/core/modules/commande/mod_commande_marbre.php b/htdocs/core/modules/commande/mod_commande_marbre.php
index 28d488eb6fb..160a07635f4 100644
--- a/htdocs/core/modules/commande/mod_commande_marbre.php
+++ b/htdocs/core/modules/commande/mod_commande_marbre.php
@@ -121,7 +121,7 @@ class mod_commande_marbre extends ModeleNumRefCommandes
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
$sql.= " FROM ".MAIN_DB_PREFIX."commande";
$sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
- $sql.= " AND entity = ".$conf->entity;
+ $sql.= " AND entity IN (".getEntity('ordernumber', 1, $object).")";
$resql=$db->query($sql);
if ($resql)
diff --git a/htdocs/core/modules/commande/mod_commande_saphir.php b/htdocs/core/modules/commande/mod_commande_saphir.php
index 8c96c237a0f..f722a017c0b 100644
--- a/htdocs/core/modules/commande/mod_commande_saphir.php
+++ b/htdocs/core/modules/commande/mod_commande_saphir.php
@@ -137,9 +137,12 @@ class mod_commande_saphir extends ModeleNumRefCommandes
return 0;
}
+ // Get entities
+ $entity = getEntity('ordernumber', 1, $object);
+
$date = ($object->date_commande ? $object->date_commande : $object->date);
- $numFinal=get_next_value($db, $mask, 'commande', 'ref', '', $objsoc, $date);
+ $numFinal=get_next_value($db, $mask, 'commande', 'ref', '', $objsoc, $date, 'next', false, null, $entity);
return $numFinal;
}
diff --git a/htdocs/support/index.php b/htdocs/support/index.php
index c5f0494eb59..9bc1027805a 100644
--- a/htdocs/support/index.php
+++ b/htdocs/support/index.php
@@ -73,7 +73,7 @@ print '
'.img_picto('', 'who.png', 'class="valigntex
print ''.$langs->trans("CommunitySupport").'';
print ' '.$langs->trans("TypeOfSupport").': '.$langs->trans("TypeSupportCommunauty").'';
print ' '.$langs->trans("TypeOfHelp").'/'.$langs->trans("Efficiency").'/'.$langs->trans("Price").': ';
-print $langs->trans("TypeHelpDev").'/'.img_picto_common('', 'redstar', 'class="valigntextbottom"', 1).img_picto_common('', 'redstar', 'class="valigntextbottom"', 1).'/'.img_picto_common('', 'star', 'class="valigntextbottom"', 1).img_picto_common('', 'star', 'class="valigntextbottom"', 1).img_picto_common('', 'star', 'class="valigntextbottom"', 1).img_picto_common('', 'star', 'class="valigntextbottom"', 1);
+print $langs->trans("TypeHelpDev").'/'.img_picto_common('', 'redstar', 'class="valigntextbottom minwidth50"', 1).img_picto_common('', 'redstar', 'class="valigntextbottom minwidth50"', 1).'/'.img_picto_common('', 'star', 'class="valigntextbottom"', 1).img_picto_common('', 'star', 'class="valigntextbottom"', 1).img_picto_common('', 'star', 'class="valigntextbottom"', 1).img_picto_common('', 'star', 'class="valigntextbottom"', 1);
print ' |
';
print '';