Merge pull request #11168 from hregis/develop_menu

NEW add new function "setEntity()" and better compatibility with Multicompany
This commit is contained in:
Laurent Destailleur 2019-08-15 21:00:05 +02:00 committed by GitHub
commit 6430c74793
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
27 changed files with 190 additions and 168 deletions

View File

@ -380,7 +380,6 @@ if (empty($reshook))
} }
} else { } else {
$object->ref = GETPOST('ref'); $object->ref = GETPOST('ref');
$object->entity = (GETPOSTISSET('entity')?GETPOST('entity', 'int'):$conf->entity);
$object->ref_client = GETPOST('ref_client'); $object->ref_client = GETPOST('ref_client');
$object->datep = $datep; $object->datep = $datep;
$object->date_livraison = $date_delivery; $object->date_livraison = $date_delivery;

View File

@ -890,7 +890,6 @@ class Propal extends CommonObject
$now=dol_now(); $now=dol_now();
// Clean parameters // Clean parameters
if (empty($this->entity)) $this->entity = $conf->entity;
if (empty($this->date)) $this->date=$this->datep; if (empty($this->date)) $this->date=$this->datep;
$this->fin_validite = $this->date + ($this->duree_validite * 24 * 3600); $this->fin_validite = $this->date + ($this->duree_validite * 24 * 3600);
if (empty($this->availability_id)) $this->availability_id=0; if (empty($this->availability_id)) $this->availability_id=0;
@ -1000,7 +999,7 @@ class Propal extends CommonObject
$sql.= ", ".($this->fk_project?$this->fk_project:"null"); $sql.= ", ".($this->fk_project?$this->fk_project:"null");
$sql.= ", ".(int) $this->fk_incoterms; $sql.= ", ".(int) $this->fk_incoterms;
$sql.= ", '".$this->db->escape($this->location_incoterms)."'"; $sql.= ", '".$this->db->escape($this->location_incoterms)."'";
$sql.= ", ".$this->entity; $sql.= ", ".setEntity($this);
$sql.= ", ".(int) $this->fk_multicurrency; $sql.= ", ".(int) $this->fk_multicurrency;
$sql.= ", '".$this->db->escape($this->multicurrency_code)."'"; $sql.= ", '".$this->db->escape($this->multicurrency_code)."'";
$sql.= ", ".(double) $this->multicurrency_tx; $sql.= ", ".(double) $this->multicurrency_tx;
@ -1083,7 +1082,7 @@ class Propal extends CommonObject
$vatrate = $line->tva_tx; $vatrate = $line->tva_tx;
if ($line->vat_src_code && ! preg_match('/\(.*\)/', $vatrate)) $vatrate.=' ('.$line->vat_src_code.')'; if ($line->vat_src_code && ! preg_match('/\(.*\)/', $vatrate)) $vatrate.=' ('.$line->vat_src_code.')';
$result = $this->addline( $result = $this->addline(
$line->desc, $line->desc,
$line->subprice, $line->subprice,
$line->qty, $line->qty,
@ -1130,7 +1129,7 @@ class Propal extends CommonObject
$sql = "UPDATE ".MAIN_DB_PREFIX."propal"; $sql = "UPDATE ".MAIN_DB_PREFIX."propal";
$sql.= " SET fk_delivery_address = ".$this->fk_delivery_address; $sql.= " SET fk_delivery_address = ".$this->fk_delivery_address;
$sql.= " WHERE ref = '".$this->db->escape($this->ref)."'"; $sql.= " WHERE ref = '".$this->db->escape($this->ref)."'";
$sql.= " AND entity = ".$conf->entity; $sql.= " AND entity = ".setEntity($this);
$result=$this->db->query($sql); $result=$this->db->query($sql);
} }

View File

@ -1062,7 +1062,7 @@ if ($resql)
// Extra fields // Extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
// Fields from hook // 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 $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint; print $hookmanager->resPrint;
// Date creation // Date creation

View File

@ -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 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$hookmanager->initHooks(array('ordercard','globalcard')); $hookmanager->initHooks(array('ordercard','globalcard'));
$permissionnote = $user->rights->commande->creer; // Used by the include of actions_setnotes.inc.php $usercanread = $user->rights->commande->lire;
$permissiondellink = $user->rights->commande->creer; // Used by the include of actions_dellink.inc.php $usercancreate = $user->rights->commande->creer;
$permissionedit = $user->rights->commande->creer; // Used by the include of actions_lineupdown.inc.php $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 include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php'; // Must be include, not include_once
// Action clone object // 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')) if (1==0 && ! GETPOST('clone_content') && ! GETPOST('clone_receivers'))
{ {
@ -159,7 +167,7 @@ if (empty($reshook))
} }
// Reopen a closed order // 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) if ($object->statut == Commande::STATUS_CANCELED || $object->statut == Commande::STATUS_CLOSED)
{ {
@ -176,7 +184,7 @@ if (empty($reshook))
} }
// Remove order // Remove order
elseif ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->commande->supprimer) elseif ($action == 'confirm_delete' && $confirm == 'yes' && $usercandelete)
{ {
$result = $object->delete($user); $result = $object->delete($user);
if ($result > 0) if ($result > 0)
@ -191,7 +199,7 @@ if (empty($reshook))
} }
// Remove a product line // 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); $result = $object->deleteline($user, $lineid);
if ($result > 0) if ($result > 0)
@ -222,13 +230,13 @@ if (empty($reshook))
} }
// Link to a project // Link to a project
elseif ($action == 'classin' && $user->rights->commande->creer) elseif ($action == 'classin' && $usercancreate)
{ {
$object->setProject(GETPOST('projectid', 'int')); $object->setProject(GETPOST('projectid', 'int'));
} }
// Add order // 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')); $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')); $datelivraison = dol_mktime(12, 0, 0, GETPOST('liv_month'), GETPOST('liv_day'), GETPOST('liv_year'));
@ -481,7 +489,7 @@ if (empty($reshook))
} }
} }
elseif ($action == 'classifybilled' && $user->rights->commande->creer) elseif ($action == 'classifybilled' && $usercancreate)
{ {
$ret=$object->classifyBilled($user); $ret=$object->classifyBilled($user);
@ -489,7 +497,7 @@ if (empty($reshook))
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
} }
elseif ($action == 'classifyunbilled' && $user->rights->commande->creer) elseif ($action == 'classifyunbilled' && $usercancreate)
{ {
$ret=$object->classifyUnBilled(); $ret=$object->classifyUnBilled();
if ($ret < 0) { if ($ret < 0) {
@ -498,7 +506,7 @@ if (empty($reshook))
} }
// Positionne ref commande client // 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')); $result = $object->set_ref_client($user, GETPOST('ref_client'));
if ($result < 0) if ($result < 0)
{ {
@ -506,7 +514,7 @@ if (empty($reshook))
} }
} }
elseif ($action == 'setremise' && $user->rights->commande->creer) { elseif ($action == 'setremise' && $usercancreate) {
$result = $object->set_remise($user, GETPOST('remise')); $result = $object->set_remise($user, GETPOST('remise'));
if ($result < 0) if ($result < 0)
{ {
@ -514,7 +522,7 @@ if (empty($reshook))
} }
} }
elseif ($action == 'setabsolutediscount' && $user->rights->commande->creer) { elseif ($action == 'setabsolutediscount' && $usercancreate) {
if (GETPOST('remise_id')) { if (GETPOST('remise_id')) {
if ($object->id > 0) { if ($object->id > 0) {
$object->insert_discount(GETPOST('remise_id')); $object->insert_discount(GETPOST('remise_id'));
@ -524,7 +532,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']; // 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')); $date = dol_mktime(0, 0, 0, GETPOST('order_month'), GETPOST('order_day'), GETPOST('order_year'));
@ -534,7 +542,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']; // 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')); $datelivraison = dol_mktime(0, 0, 0, GETPOST('liv_month'), GETPOST('liv_day'), GETPOST('liv_year'));
@ -544,35 +552,35 @@ if (empty($reshook))
} }
} }
elseif ($action == 'setmode' && $user->rights->commande->creer) { elseif ($action == 'setmode' && $usercancreate) {
$result = $object->setPaymentMethods(GETPOST('mode_reglement_id', 'int')); $result = $object->setPaymentMethods(GETPOST('mode_reglement_id', 'int'));
if ($result < 0) if ($result < 0)
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
// Multicurrency Code // Multicurrency Code
elseif ($action == 'setmulticurrencycode' && $user->rights->commande->creer) { elseif ($action == 'setmulticurrencycode' && $usercancreate) {
$result = $object->setMulticurrencyCode(GETPOST('multicurrency_code', 'alpha')); $result = $object->setMulticurrencyCode(GETPOST('multicurrency_code', 'alpha'));
} }
// Multicurrency rate // Multicurrency rate
elseif ($action == 'setmulticurrencyrate' && $user->rights->commande->creer) { elseif ($action == 'setmulticurrencyrate' && $usercancreate) {
$result = $object->setMulticurrencyRate(price2num(GETPOST('multicurrency_tx'))); $result = $object->setMulticurrencyRate(price2num(GETPOST('multicurrency_tx')));
} }
elseif ($action == 'setavailability' && $user->rights->commande->creer) { elseif ($action == 'setavailability' && $usercancreate) {
$result = $object->availability(GETPOST('availability_id')); $result = $object->availability(GETPOST('availability_id'));
if ($result < 0) if ($result < 0)
setEventMessages($object->error, $object->errors, 'errors'); 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')); $result = $object->demand_reason(GETPOST('demand_reason_id'));
if ($result < 0) if ($result < 0)
setEventMessages($object->error, $object->errors, 'errors'); 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')); $result = $object->setPaymentTerms(GETPOST('cond_reglement_id', 'int'));
if ($result < 0) { if ($result < 0) {
dol_print_error($db, $object->error); dol_print_error($db, $object->error);
@ -604,7 +612,7 @@ if (empty($reshook))
} }
// bank account // bank account
elseif ($action == 'setbankaccount' && $user->rights->commande->creer) { elseif ($action == 'setbankaccount' && $usercancreate) {
$result=$object->setBankAccount(GETPOST('fk_account', 'int')); $result=$object->setBankAccount(GETPOST('fk_account', 'int'));
if ($result < 0) { if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
@ -612,7 +620,7 @@ if (empty($reshook))
} }
// shipping method // shipping method
elseif ($action == 'setshippingmethod' && $user->rights->commande->creer) { elseif ($action == 'setshippingmethod' && $usercancreate) {
$result = $object->setShippingMethod(GETPOST('shipping_method_id', 'int')); $result = $object->setShippingMethod(GETPOST('shipping_method_id', 'int'));
if ($result < 0) { if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
@ -620,23 +628,23 @@ if (empty($reshook))
} }
// warehouse // warehouse
elseif ($action == 'setwarehouse' && $user->rights->commande->creer) { elseif ($action == 'setwarehouse' && $usercancreate) {
$result = $object->setWarehouse(GETPOST('warehouse_id', 'int')); $result = $object->setWarehouse(GETPOST('warehouse_id', 'int'));
if ($result < 0) { if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors'); 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')); $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')); $result = $object->set_remise_absolue($user, GETPOST('remise_absolue'));
} }
// Add a new line // Add a new line
elseif ($action == 'addline' && $user->rights->commande->creer) elseif ($action == 'addline' && $usercancreate)
{ {
$langs->load('errors'); $langs->load('errors');
$error = 0; $error = 0;
@ -999,7 +1007,7 @@ if (empty($reshook))
/* /*
* Update a line * Update a line
*/ */
elseif ($action == 'updateline' && $user->rights->commande->creer && GETPOST('save')) elseif ($action == 'updateline' && $usercancreate && GETPOST('save'))
{ {
// Clean parameters // Clean parameters
$date_start=''; $date_start='';
@ -1133,15 +1141,12 @@ if (empty($reshook))
setEventMessages($object->error, $object->errors, 'errors'); 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 header('Location: ' . $_SERVER['PHP_SELF'] . '?id=' . $object->id); // Pour reaffichage de la fiche en cours d'edition
exit(); exit();
} }
elseif ($action == 'confirm_validate' && $confirm == 'yes' && elseif ($action == 'confirm_validate' && $confirm == 'yes' && $usercanvalidate)
((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)))
)
{ {
$idwarehouse = GETPOST('idwarehouse'); $idwarehouse = GETPOST('idwarehouse');
@ -1195,7 +1200,7 @@ if (empty($reshook))
} }
// Go back to draft status // Go back to draft status
elseif ($action == 'confirm_modif' && $user->rights->commande->creer) { elseif ($action == 'confirm_modif' && $usercancreate) {
$idwarehouse = GETPOST('idwarehouse'); $idwarehouse = GETPOST('idwarehouse');
$qualified_for_stock_change=0; $qualified_for_stock_change=0;
@ -1243,17 +1248,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); $result = $object->cloture($user);
if ($result < 0) { if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
} }
elseif ($action == 'confirm_cancel' && $confirm == 'yes' && elseif ($action == 'confirm_cancel' && $confirm == 'yes' && $usercanvalidate)
((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)))
)
{ {
$idwarehouse = GETPOST('idwarehouse'); $idwarehouse = GETPOST('idwarehouse');
@ -1310,7 +1312,7 @@ if (empty($reshook))
if ($error) $action = 'edit_extras'; if ($error) $action = 'edit_extras';
} }
if ($action == 'set_thirdparty' && $user->rights->commande->creer) if ($action == 'set_thirdparty' && $usercancreate)
{ {
$object->fetch($id); $object->fetch($id);
$object->setValueFrom('fk_soc', $socid, '', '', 'date', '', $user, 'ORDER_MODIFY'); $object->setValueFrom('fk_soc', $socid, '', '', 'date', '', $user, 'ORDER_MODIFY');
@ -1321,7 +1323,7 @@ if (empty($reshook))
// add lines from objectlinked // add lines from objectlinked
if($action == 'import_lines_from_object' if($action == 'import_lines_from_object'
&& $user->rights->commande->creer && $usercancreate
&& $object->statut == Commande::STATUS_DRAFT && $object->statut == Commande::STATUS_DRAFT
) )
{ {
@ -1405,8 +1407,8 @@ if (empty($reshook))
include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php';
// Actions to build doc // Actions to build doc
$upload_dir = $conf->commande->dir_output; $upload_dir = $conf->commande->multidir_output[$object->entity];
$permissioncreate = $user->rights->commande->creer; $permissioncreate = $usercancreate;
include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
// Actions to send emails // Actions to send emails
@ -1417,7 +1419,7 @@ if (empty($reshook))
include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; 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') if ($action == 'addcontact')
{ {
@ -1478,7 +1480,7 @@ $formmargin = new FormMargin($db);
if (! empty($conf->projet->enabled)) { $formproject = new FormProjets($db); } if (! empty($conf->projet->enabled)) { $formproject = new FormProjets($db); }
// Mode creation // Mode creation
if ($action == 'create' && $user->rights->commande->creer) if ($action == 'create' && $usercancreate)
{ {
print load_fiche_titre($langs->trans('CreateOrder'), '', 'title_commercial.png'); print load_fiche_titre($langs->trans('CreateOrder'), '', 'title_commercial.png');
@ -2069,8 +2071,8 @@ if ($action == 'create' && $user->rights->commande->creer)
$morehtmlref='<div class="refidno">'; $morehtmlref='<div class="refidno">';
// Ref customer // Ref customer
$morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, $user->rights->commande->creer, 'string', '', 0, 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, $user->rights->commande->creer, 'string', '', null, null, '', 1); $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, $usercancreate, 'string', '', null, null, '', 1);
// Thirdparty // Thirdparty
$morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $soc->getNomUrl(1); $morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $soc->getNomUrl(1);
if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) $morehtmlref.=' (<a href="'.DOL_URL_ROOT.'/commande/list.php?socid='.$object->thirdparty->id.'&search_societe='.urlencode($object->thirdparty->name).'">'.$langs->trans("OtherOrders").'</a>)'; if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) $morehtmlref.=' (<a href="'.DOL_URL_ROOT.'/commande/list.php?socid='.$object->thirdparty->id.'&search_societe='.urlencode($object->thirdparty->name).'">'.$langs->trans("OtherOrders").'</a>)';
@ -2079,7 +2081,7 @@ if ($action == 'create' && $user->rights->commande->creer)
{ {
$langs->load("projects"); $langs->load("projects");
$morehtmlref.='<br>'.$langs->trans('Project') . ' '; $morehtmlref.='<br>'.$langs->trans('Project') . ' ';
if ($user->rights->commande->creer) if ($usercancreate)
{ {
if ($action != 'classify') if ($action != 'classify')
$morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : '; $morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
@ -2159,7 +2161,7 @@ if ($action == 'create' && $user->rights->commande->creer)
// Date // Date
print '<tr><td>'; print '<tr><td>';
$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 $form->editfieldkey("Date", 'date', '', $object, $editenable);
print '</td><td>'; print '</td><td>';
if ($action == 'editdate') { if ($action == 'editdate') {
@ -2180,7 +2182,7 @@ if ($action == 'create' && $user->rights->commande->creer)
// Delivery date planed // Delivery date planed
print '<tr><td>'; print '<tr><td>';
$editenable = $user->rights->commande->creer; $editenable = $usercancreate;
print $form->editfieldkey("DateDeliveryPlanned", 'date_livraison', '', $object, $editenable); print $form->editfieldkey("DateDeliveryPlanned", 'date_livraison', '', $object, $editenable);
print '</td><td>'; print '</td><td>';
if ($action == 'editdate_livraison') { if ($action == 'editdate_livraison') {
@ -2202,7 +2204,7 @@ if ($action == 'create' && $user->rights->commande->creer)
// Shipping Method // Shipping Method
if (! empty($conf->expedition->enabled)) { if (! empty($conf->expedition->enabled)) {
print '<tr><td>'; print '<tr><td>';
$editenable = $user->rights->commande->creer; $editenable = $usercancreate;
print $form->editfieldkey("SendingMethod", 'shippingmethod', '', $object, $editenable); print $form->editfieldkey("SendingMethod", 'shippingmethod', '', $object, $editenable);
print '</td><td>'; print '</td><td>';
if ($action == 'editshippingmethod') { if ($action == 'editshippingmethod') {
@ -2220,7 +2222,7 @@ if ($action == 'create' && $user->rights->commande->creer)
require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
$formproduct=new FormProduct($db); $formproduct=new FormProduct($db);
print '<tr><td>'; print '<tr><td>';
$editenable = $user->rights->commande->creer; $editenable = $usercancreate;
print $form->editfieldkey("Warehouse", 'warehouse', '', $object, $editenable); print $form->editfieldkey("Warehouse", 'warehouse', '', $object, $editenable);
print '</td><td>'; print '</td><td>';
if ($action == 'editwarehouse') { if ($action == 'editwarehouse') {
@ -2234,7 +2236,7 @@ if ($action == 'create' && $user->rights->commande->creer)
// Terms of payment // Terms of payment
print '<tr><td>'; print '<tr><td>';
$editenable = $user->rights->commande->creer; $editenable = $usercancreate;
print $form->editfieldkey("PaymentConditionsShort", 'conditions', '', $object, $editenable); print $form->editfieldkey("PaymentConditionsShort", 'conditions', '', $object, $editenable);
print '</td><td>'; print '</td><td>';
if ($action == 'editconditions') { if ($action == 'editconditions') {
@ -2248,7 +2250,7 @@ if ($action == 'create' && $user->rights->commande->creer)
// Mode of payment // Mode of payment
print '<tr><td>'; print '<tr><td>';
$editenable = $user->rights->commande->creer; $editenable = $usercancreate;
print $form->editfieldkey("PaymentMode", 'mode', '', $object, $editenable); print $form->editfieldkey("PaymentMode", 'mode', '', $object, $editenable);
print '</td><td>'; print '</td><td>';
if ($action == 'editmode') { if ($action == 'editmode') {
@ -2264,7 +2266,7 @@ if ($action == 'create' && $user->rights->commande->creer)
// Multicurrency code // Multicurrency code
print '<tr>'; print '<tr>';
print '<td>'; print '<td>';
$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 $form->editfieldkey("Currency", 'multicurrencycode', '', $object, $editenable);
print '</td><td>'; print '</td><td>';
if ($action == 'editmulticurrencycode') { if ($action == 'editmulticurrencycode') {
@ -2277,7 +2279,7 @@ if ($action == 'create' && $user->rights->commande->creer)
// Multicurrency rate // Multicurrency rate
print '<tr>'; print '<tr>';
print '<td>'; print '<td>';
$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 $form->editfieldkey("CurrencyRate", 'multicurrencyrate', '', $object, $editenable);
print '</td><td>'; print '</td><td>';
if ($action == 'editmulticurrencyrate' || $action == 'actualizemulticurrencyrate') { if ($action == 'editmulticurrencyrate' || $action == 'actualizemulticurrencyrate') {
@ -2298,7 +2300,7 @@ if ($action == 'create' && $user->rights->commande->creer)
// Delivery delay // Delivery delay
print '<tr class="fielddeliverydelay"><td>'; print '<tr class="fielddeliverydelay"><td>';
$editenable = $user->rights->commande->creer; $editenable = $usercancreate;
print $form->editfieldkey("AvailabilityPeriod", 'availability', '', $object, $editenable); print $form->editfieldkey("AvailabilityPeriod", 'availability', '', $object, $editenable);
print '</td><td>'; print '</td><td>';
if ($action == 'editavailability') { if ($action == 'editavailability') {
@ -2310,7 +2312,7 @@ if ($action == 'create' && $user->rights->commande->creer)
// Source reason (why we have an ordrer) // Source reason (why we have an ordrer)
print '<tr><td>'; print '<tr><td>';
$editenable = $user->rights->commande->creer; $editenable = $usercancreate;
print $form->editfieldkey("Channel", 'demandreason', '', $object, $editenable); print $form->editfieldkey("Channel", 'demandreason', '', $object, $editenable);
print '</td><td>'; print '</td><td>';
if ($action == 'editdemandreason') { if ($action == 'editdemandreason') {
@ -2323,7 +2325,7 @@ if ($action == 'create' && $user->rights->commande->creer)
// TODO Order mode (how we receive order). Not yet implemented // TODO Order mode (how we receive order). Not yet implemented
/* /*
print '<tr><td>'; print '<tr><td>';
$editenable = $user->rights->commande->creer; $editenable = $usercancreate;
print $form->editfieldkey("SourceMode", 'inputmode', '', $object, $editenable); print $form->editfieldkey("SourceMode", 'inputmode', '', $object, $editenable);
print '</td><td>'; print '</td><td>';
if ($action == 'editinputmode') { if ($action == 'editinputmode') {
@ -2355,7 +2357,7 @@ if ($action == 'create' && $user->rights->commande->creer)
// Incoterms // Incoterms
if (!empty($conf->incoterm->enabled)) { if (!empty($conf->incoterm->enabled)) {
print '<tr><td>'; print '<tr><td>';
$editenable = $user->rights->commande->creer; $editenable = $usercancreate;
print $form->editfieldkey("IncotermLabel", 'incoterm', '', $object, $editenable); print $form->editfieldkey("IncotermLabel", 'incoterm', '', $object, $editenable);
print '</td>'; print '</td>';
print '<td>'; print '<td>';
@ -2373,7 +2375,7 @@ if ($action == 'create' && $user->rights->commande->creer)
// Bank Account // Bank Account
if (! empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_ORDER) && ! empty($conf->banque->enabled)) { if (! empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_ORDER) && ! empty($conf->banque->enabled)) {
print '<tr><td>'; print '<tr><td>';
$editenable = $user->rights->commande->creer; $editenable = $usercancreate;
print $form->editfieldkey("BankAccount", 'bankaccount', '', $object, $editenable); print $form->editfieldkey("BankAccount", 'bankaccount', '', $object, $editenable);
print '</td><td>'; print '</td><td>';
if ($action == 'editbankaccount') { if ($action == 'editbankaccount') {
@ -2497,7 +2499,7 @@ if ($action == 'create' && $user->rights->commande->creer)
/* /*
* Form to add new line * 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') if ($action != 'editline')
{ {
@ -2528,22 +2530,19 @@ if ($action == 'create' && $user->rights->commande->creer)
if (empty($reshook)) { if (empty($reshook)) {
// Send // Send
if ($object->statut > Commande::STATUS_DRAFT) { if ($object->statut > Commande::STATUS_DRAFT) {
if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->commande->order_advance->send)) { if ($usercansend) {
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&action=presend&mode=init#formmailbeforetitle">' . $langs->trans('SendMail') . '</a></div>'; print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&action=presend&mode=init#formmailbeforetitle">' . $langs->trans('SendMail') . '</a></div>';
} else } else
print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#">' . $langs->trans('SendMail') . '</a></div>'; print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#">' . $langs->trans('SendMail') . '</a></div>';
} }
// Valid // Valid
if ($object->statut == Commande::STATUS_DRAFT && $object->total_ttc >= 0 && $numlines > 0 && if ($object->statut == Commande::STATUS_DRAFT && $object->total_ttc >= 0 && $numlines > 0 && $usercanvalidate)
((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)))
)
{ {
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&amp;action=validate">' . $langs->trans('Validate') . '</a></div>'; print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&amp;action=validate">' . $langs->trans('Validate') . '</a></div>';
} }
// Edit // Edit
if ($object->statut == Commande::STATUS_VALIDATED && $user->rights->commande->creer) { if ($object->statut == Commande::STATUS_VALIDATED && $usercancreate) {
print '<div class="inline-block divButAction"><a class="butAction" href="card.php?id=' . $object->id . '&amp;action=modif">' . $langs->trans('Modify') . '</a></div>'; print '<div class="inline-block divButAction"><a class="butAction" href="card.php?id=' . $object->id . '&amp;action=modif">' . $langs->trans('Modify') . '</a></div>';
} }
// Create event // Create event
@ -2597,12 +2596,12 @@ if ($action == 'create' && $user->rights->commande->creer)
} }
// Reopen a closed order // 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 '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&amp;action=reopen">' . $langs->trans('ReOpen') . '</a></div>'; print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&amp;action=reopen">' . $langs->trans('ReOpen') . '</a></div>';
} }
// Set to shipped // 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 '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&amp;action=shipped">' . $langs->trans('ClassifyShipped') . '</a></div>'; print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&amp;action=shipped">' . $langs->trans('ClassifyShipped') . '</a></div>';
} }
@ -2612,31 +2611,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)) { if (! empty($conf->facture->enabled) && $user->rights->facture->creer && empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) {
print '<div class="inline-block divButAction"><a class="butAction" href="' . DOL_URL_ROOT . '/compta/facture/card.php?action=create&amp;origin=' . $object->element . '&amp;originid=' . $object->id . '&amp;socid=' . $object->socid . '">' . $langs->trans("CreateBill") . '</a></div>'; print '<div class="inline-block divButAction"><a class="butAction" href="' . DOL_URL_ROOT . '/compta/facture/card.php?action=create&amp;origin=' . $object->element . '&amp;originid=' . $object->id . '&amp;socid=' . $object->socid . '">' . $langs->trans("CreateBill") . '</a></div>';
} }
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 '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&amp;action=classifybilled">' . $langs->trans("ClassifyBilled") . '</a></div>'; print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&amp;action=classifybilled">' . $langs->trans("ClassifyBilled") . '</a></div>';
} }
} }
if ($object->statut > Commande::STATUS_DRAFT && $object->billed) { 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 '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&amp;action=classifyunbilled">' . $langs->trans("ClassifyUnBilled") . '</a></div>'; print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&amp;action=classifyunbilled">' . $langs->trans("ClassifyUnBilled") . '</a></div>';
} }
} }
// Clone // Clone
if ($user->rights->commande->creer) { if ($usercancreate) {
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&amp;socid=' . $object->socid . '&amp;action=clone&amp;object=order">' . $langs->trans("ToClone") . '</a></div>'; print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&amp;socid=' . $object->socid . '&amp;action=clone&amp;object=order">' . $langs->trans("ToClone") . '</a></div>';
} }
// Cancel order // Cancel order
if ($object->statut == Commande::STATUS_VALIDATED && if ($object->statut == Commande::STATUS_VALIDATED && (! empty($usercanclose) || ! empty($usercancancel)))
((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)))
)
{ {
print '<div class="inline-block divButAction"><a class="butActionDelete" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&amp;action=cancel">' . $langs->trans('Cancel') . '</a></div>'; print '<div class="inline-block divButAction"><a class="butActionDelete" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&amp;action=cancel">' . $langs->trans('Cancel') . '</a></div>';
} }
// Delete order // Delete order
if ($user->rights->commande->supprimer) { if ($usercandelete) {
if ($numshipping == 0) { if ($numshipping == 0) {
print '<div class="inline-block divButAction"><a class="butActionDelete" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&amp;action=delete">' . $langs->trans('Delete') . '</a></div>'; print '<div class="inline-block divButAction"><a class="butActionDelete" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&amp;action=delete">' . $langs->trans('Delete') . '</a></div>';
} else { } else {
@ -2659,18 +2655,18 @@ if ($action == 'create' && $user->rights->commande->creer)
// Documents // Documents
$comref = dol_sanitizeFileName($object->ref); $comref = dol_sanitizeFileName($object->ref);
$relativepath = $comref . '/' . $comref . '.pdf'; $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; $urlsource = $_SERVER["PHP_SELF"] . "?id=" . $object->id;
$genallowed = $user->rights->commande->lire; $genallowed = $usercanread;
$delallowed = $user->rights->commande->creer; $delallowed = $usercancreate;
print $formfile->showdocuments('commande', $comref, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang); 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 // Show links to link elements
$linktoelem = $form->showLinkToObjectBlock($object, null, array('order')); $linktoelem = $form->showLinkToObjectBlock($object, null, array('order'));
$compatibleImportElementsList = false; $compatibleImportElementsList = false;
if($user->rights->commande->creer if($usercancreate
&& $object->statut == Commande::STATUS_DRAFT) && $object->statut == Commande::STATUS_DRAFT)
{ {
$compatibleImportElementsList = array('commande','propal'); // import from linked elements $compatibleImportElementsList = array('commande','propal'); // import from linked elements
@ -2707,7 +2703,7 @@ if ($action == 'create' && $user->rights->commande->creer)
// Presend form // Presend form
$modelmail='order_send'; $modelmail='order_send';
$defaulttopic='SendOrderRef'; $defaulttopic='SendOrderRef';
$diroutput = $conf->commande->dir_output; $diroutput = $conf->commande->multidir_output[$object->entity];
$trackid = 'ord'.$object->id; $trackid = 'ord'.$object->id;
include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php'; include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php';

View File

@ -433,8 +433,8 @@ class Commande extends CommonOrder
// We rename directory ($this->ref = old ref, $num = new ref) in order not to lose the attachments // We rename directory ($this->ref = old ref, $num = new ref) in order not to lose the attachments
$oldref = dol_sanitizeFileName($this->ref); $oldref = dol_sanitizeFileName($this->ref);
$newref = dol_sanitizeFileName($num); $newref = dol_sanitizeFileName($num);
$dirsource = $conf->commande->dir_output.'/'.$oldref; $dirsource = $conf->commande->multidir_output[$this->entity].'/'.$oldref;
$dirdest = $conf->commande->dir_output.'/'.$newref; $dirdest = $conf->commande->multidir_output[$this->entity].'/'.$newref;
if (! $error && file_exists($dirsource)) if (! $error && file_exists($dirsource))
{ {
dol_syslog(get_class($this)."::valid() rename dir ".$dirsource." into ".$dirdest); dol_syslog(get_class($this)."::valid() rename dir ".$dirsource." into ".$dirdest);
@ -443,7 +443,7 @@ class Commande extends CommonOrder
{ {
dol_syslog("Rename ok"); dol_syslog("Rename ok");
// Rename docs starting with $oldref with $newref // 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) foreach($listoffiles as $fileentry)
{ {
$dirsource=$fileentry['name']; $dirsource=$fileentry['name'];
@ -865,7 +865,7 @@ class Commande extends CommonOrder
$sql.= ", ".($this->remise_percent>0?$this->db->escape($this->remise_percent):0); $sql.= ", ".($this->remise_percent>0?$this->db->escape($this->remise_percent):0);
$sql.= ", ".(int) $this->fk_incoterms; $sql.= ", ".(int) $this->fk_incoterms;
$sql.= ", '".$this->db->escape($this->location_incoterms)."'"; $sql.= ", '".$this->db->escape($this->location_incoterms)."'";
$sql.= ", ".$conf->entity; $sql.= ", ".setEntity($this);
$sql.= ", ".($this->module_source ? "'".$this->db->escape($this->module_source)."'" : "null"); $sql.= ", ".($this->module_source ? "'".$this->db->escape($this->module_source)."'" : "null");
$sql.= ", ".($this->pos_source != '' ? "'".$this->db->escape($this->pos_source)."'" : "null"); $sql.= ", ".($this->pos_source != '' ? "'".$this->db->escape($this->pos_source)."'" : "null");
$sql.= ", ".(int) $this->fk_multicurrency; $sql.= ", ".(int) $this->fk_multicurrency;
@ -1238,6 +1238,7 @@ class Commande extends CommonOrder
$this->lines[$i] = $line; $this->lines[$i] = $line;
} }
$this->entity = $object->entity;
$this->socid = $object->socid; $this->socid = $object->socid;
$this->fk_project = $object->fk_project; $this->fk_project = $object->fk_project;
$this->cond_reglement_id = $object->cond_reglement_id; $this->cond_reglement_id = $object->cond_reglement_id;
@ -3335,10 +3336,10 @@ class Commande extends CommonOrder
{ {
// Remove directory with files // Remove directory with files
$comref = dol_sanitizeFileName($this->ref); $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 ; $dir = $conf->commande->multidir_output[$this->entity] . "/" . $comref ;
$file = $conf->commande->dir_output . "/" . $comref . "/" . $comref . ".pdf"; $file = $conf->commande->multidir_output[$this->entity] . "/" . $comref . "/" . $comref . ".pdf";
if (file_exists($file)) // We must delete all files before deleting directory if (file_exists($file)) // We must delete all files before deleting directory
{ {
dol_delete_preview($this); dol_delete_preview($this);

View File

@ -72,7 +72,7 @@ $object = new Commande($db);
if ($object->fetch($id)) if ($object->fetch($id))
{ {
$object->fetch_thirdparty(); $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'; include_once DOL_DOCUMENT_ROOT . '/core/actions_linkedfiles.inc.php';
@ -92,7 +92,7 @@ if ($id > 0 || ! empty($ref))
{ {
$object->fetch_thirdparty(); $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); $head = commande_prepare_head($object);
dol_fiche_head($head, 'documents', $langs->trans('CustomerOrder'), -1, 'order'); dol_fiche_head($head, 'documents', $langs->trans('CustomerOrder'), -1, 'order');
@ -174,7 +174,7 @@ if ($id > 0 || ! empty($ref))
$modulepart = 'commande'; $modulepart = 'commande';
$permission = $user->rights->commande->creer; $permission = $user->rights->commande->creer;
$permtoedit = $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'; include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php';
} }
else else

View File

@ -241,7 +241,7 @@ $max=5;
* Last modified orders * 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.nom as name, s.rowid as socid";
$sql.= ", s.client"; $sql.= ", s.client";
$sql.= ", s.code_client"; $sql.= ", s.code_client";
@ -297,7 +297,7 @@ if ($resql)
print '<td width="16" class="nobordernopadding hideonsmartphone right">'; print '<td width="16" class="nobordernopadding hideonsmartphone right">';
$filename=dol_sanitizeFileName($obj->ref); $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; $urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->rowid;
print $formfile->getDocumentsLink($commandestatic->element, $filename, $filedir); print $formfile->getDocumentsLink($commandestatic->element, $filename, $filedir);
print '</td></tr></table>'; print '</td></tr></table>';
@ -323,7 +323,7 @@ else dol_print_error($db);
*/ */
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.client";
$sql.= ", s.code_client"; $sql.= ", s.code_client";
$sql.= ", s.canvas"; $sql.= ", s.canvas";
@ -377,7 +377,7 @@ if (! empty($conf->commande->enabled))
print '<td width="16" class="nobordernopadding hideonsmartphone right">'; print '<td width="16" class="nobordernopadding hideonsmartphone right">';
$filename=dol_sanitizeFileName($obj->ref); $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; $urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->rowid;
print $formfile->getDocumentsLink($commandestatic->element, $filename, $filedir); print $formfile->getDocumentsLink($commandestatic->element, $filename, $filedir);
print '</td></tr></table>'; print '</td></tr></table>';
@ -405,7 +405,7 @@ if (! empty($conf->commande->enabled))
*/ */
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.client";
$sql.= ", s.code_client"; $sql.= ", s.code_client";
$sql.= ", s.canvas"; $sql.= ", s.canvas";
@ -459,7 +459,7 @@ if (! empty($conf->commande->enabled))
print '<td width="16" class="nobordernopadding hideonsmartphone right">'; print '<td width="16" class="nobordernopadding hideonsmartphone right">';
$filename=dol_sanitizeFileName($obj->ref); $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; $urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->rowid;
print $formfile->getDocumentsLink($commandestatic->element, $filename, $filedir); print $formfile->getDocumentsLink($commandestatic->element, $filename, $filedir);
print '</td></tr></table>'; print '</td></tr></table>';

View File

@ -91,7 +91,7 @@ $id = (GETPOST('orderid')?GETPOST('orderid', 'int'):GETPOST('id', 'int'));
if ($user->societe_id) $socid=$user->societe_id; if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user, 'commande', $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 // Load variable for pagination
$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; $limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit;
@ -218,7 +218,7 @@ if (empty($reshook))
$objectlabel='Orders'; $objectlabel='Orders';
$permtoread = $user->rights->commande->lire; $permtoread = $user->rights->commande->lire;
$permtodelete = $user->rights->commande->supprimer; $permtodelete = $user->rights->commande->supprimer;
$uploaddir = $conf->commande->dir_output; $uploaddir = $conf->commande->multidir_output[$conf->entity];
$trigger_name='ORDER_SENTBYMAIL'; $trigger_name='ORDER_SENTBYMAIL';
include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
} }
@ -934,7 +934,7 @@ if ($resql)
print '<td width="16" class="nobordernopadding hideonsmartphone right">'; print '<td width="16" class="nobordernopadding hideonsmartphone right">';
$filename=dol_sanitizeFileName($obj->ref); $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; $urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->rowid;
print $formfile->getDocumentsLink($generic_commande->element, $filename, $filedir); print $formfile->getDocumentsLink($generic_commande->element, $filename, $filedir);
print '</td>'; print '</td>';
@ -1081,7 +1081,7 @@ if ($resql)
// Extra fields // Extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
// Fields from hook // 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 $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint; print $hookmanager->resPrint;
// Date creation // Date creation

View File

@ -548,7 +548,7 @@ if (($action != 'create' && $action != 'add') || ($action == 'create' && $error)
</script> </script>
<?php <?php
$sql = 'SELECT s.nom, s.rowid as socid, s.client, c.rowid, c.ref, c.total_ht, c.ref_client,'; $sql = 'SELECT s.nom, s.rowid as socid, s.client, c.rowid, c.entity, c.ref, c.total_ht, c.ref_client,';
$sql.= ' c.date_valid, c.date_commande, c.date_livraison, c.fk_statut, c.facture as billed'; $sql.= ' c.date_valid, c.date_commande, c.date_livraison, c.fk_statut, c.facture as billed';
$sql.= ' FROM '.MAIN_DB_PREFIX.'societe as s'; $sql.= ' FROM '.MAIN_DB_PREFIX.'societe as s';
$sql.= ', '.MAIN_DB_PREFIX.'commande as c'; $sql.= ', '.MAIN_DB_PREFIX.'commande as c';
@ -682,7 +682,7 @@ if (($action != 'create' && $action != 'add') || ($action == 'create' && $error)
print '<td width="16" class="nobordernopadding hideonsmartphone right">'; print '<td width="16" class="nobordernopadding hideonsmartphone right">';
$filename=dol_sanitizeFileName($objp->ref); $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; $urlsource=$_SERVER['PHP_SELF'].'?id='.$objp->rowid;
print $formfile->getDocumentsLink($generic_commande->element, $filename, $filedir); print $formfile->getDocumentsLink($generic_commande->element, $filename, $filedir);
print '</td></tr></table>'; print '</td></tr></table>';

View File

@ -945,7 +945,6 @@ if (empty($reshook))
$object->location_incoterms = GETPOST('location_incoterms', 'alpha'); $object->location_incoterms = GETPOST('location_incoterms', 'alpha');
$object->multicurrency_code = GETPOST('multicurrency_code', 'alpha'); $object->multicurrency_code = GETPOST('multicurrency_code', 'alpha');
$object->multicurrency_tx = GETPOST('originmulticurrency_tx', 'int'); $object->multicurrency_tx = GETPOST('originmulticurrency_tx', 'int');
$object->entity = (GETPOSTISSET('entity')?GETPOST('entity', 'int'):$conf->entity);
// Proprietes particulieres a facture de remplacement // Proprietes particulieres a facture de remplacement
$object->fk_facture_source = $_POST['fac_replacement']; $object->fk_facture_source = $_POST['fac_replacement'];
@ -979,7 +978,7 @@ if (empty($reshook))
if (! $error) if (! $error)
{ {
if(!empty($originentity)){ if (!empty($originentity)) {
$object->entity = $originentity; $object->entity = $originentity;
} }
$object->socid = GETPOST('socid', 'int'); $object->socid = GETPOST('socid', 'int');
@ -1001,7 +1000,6 @@ if (empty($reshook))
$object->location_incoterms = GETPOST('location_incoterms', 'alpha'); $object->location_incoterms = GETPOST('location_incoterms', 'alpha');
$object->multicurrency_code = GETPOST('multicurrency_code', 'alpha'); $object->multicurrency_code = GETPOST('multicurrency_code', 'alpha');
$object->multicurrency_tx = GETPOST('originmulticurrency_tx', 'int'); $object->multicurrency_tx = GETPOST('originmulticurrency_tx', 'int');
$object->entity = (GETPOSTISSET('entity')?GETPOST('entity', 'int'):$conf->entity);
// Proprietes particulieres a facture avoir // Proprietes particulieres a facture avoir
$object->fk_facture_source = $sourceinvoice > 0 ? $sourceinvoice : ''; $object->fk_facture_source = $sourceinvoice > 0 ? $sourceinvoice : '';
@ -1183,7 +1181,6 @@ if (empty($reshook))
$object->location_incoterms = GETPOST('location_incoterms', 'alpha'); $object->location_incoterms = GETPOST('location_incoterms', 'alpha');
$object->multicurrency_code = GETPOST('multicurrency_code', 'alpha'); $object->multicurrency_code = GETPOST('multicurrency_code', 'alpha');
$object->multicurrency_tx = GETPOST('originmulticurrency_tx', 'int'); $object->multicurrency_tx = GETPOST('originmulticurrency_tx', 'int');
$object->entity = (GETPOSTISSET('entity')?GETPOST('entity', 'int'):$conf->entity);
// Source facture // Source facture
$object->fac_rec = GETPOST('fac_rec', 'int'); $object->fac_rec = GETPOST('fac_rec', 'int');
@ -1234,7 +1231,6 @@ if (empty($reshook))
$object->location_incoterms = GETPOST('location_incoterms', 'alpha'); $object->location_incoterms = GETPOST('location_incoterms', 'alpha');
$object->multicurrency_code = GETPOST('multicurrency_code', 'alpha'); $object->multicurrency_code = GETPOST('multicurrency_code', 'alpha');
$object->multicurrency_tx = GETPOST('originmulticurrency_tx', 'int'); $object->multicurrency_tx = GETPOST('originmulticurrency_tx', 'int');
$object->entity = (GETPOSTISSET('entity')?GETPOST('entity', 'int'):$conf->entity);
if (GETPOST('type') == Facture::TYPE_SITUATION) if (GETPOST('type') == Facture::TYPE_SITUATION)
{ {
@ -2491,7 +2487,7 @@ if (empty($reshook))
include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';
// Actions to build doc // Actions to build doc
$upload_dir = $conf->facture->dir_output; $upload_dir = $conf->facture->multidir_output[$object->entity];
$permissioncreate=$usercancreate; $permissioncreate=$usercancreate;
include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
@ -5136,12 +5132,12 @@ elseif ($id > 0 || ! empty($ref))
// Documents generes // Documents generes
$filename = dol_sanitizeFileName($object->ref); $filename = dol_sanitizeFileName($object->ref);
$filedir = $conf->facture->dir_output . '/' . dol_sanitizeFileName($object->ref); $filedir = $conf->facture->multidir_output[$object->entity] . '/' . dol_sanitizeFileName($object->ref);
$urlsource = $_SERVER['PHP_SELF'] . '?facid=' . $object->id; $urlsource = $_SERVER['PHP_SELF'] . '?facid=' . $object->id;
$genallowed = $usercanread; $genallowed = $usercanread;
$delallowed = $usercancreate; $delallowed = $usercancreate;
print $formfile->showdocuments('facture', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang); print $formfile->showdocuments('facture', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang, '', $object);
$somethingshown = $formfile->numoffiles; $somethingshown = $formfile->numoffiles;
// Show links to link elements // Show links to link elements
@ -5188,7 +5184,7 @@ elseif ($id > 0 || ! empty($ref))
// Presend form // Presend form
$modelmail='facture_send'; $modelmail='facture_send';
$defaulttopic='SendBillRef'; $defaulttopic='SendBillRef';
$diroutput = $conf->facture->dir_output; $diroutput = $conf->facture->multidir_output[$object->entity];
$trackid = 'inv'.$object->id; $trackid = 'inv'.$object->id;
include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php'; include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php';

View File

@ -318,7 +318,6 @@ class Facture extends CommonInvoice
if (! $this->cond_reglement_id) $this->cond_reglement_id = 0; if (! $this->cond_reglement_id) $this->cond_reglement_id = 0;
if (! $this->mode_reglement_id) $this->mode_reglement_id = 0; if (! $this->mode_reglement_id) $this->mode_reglement_id = 0;
$this->brouillon = 1; $this->brouillon = 1;
if (empty($this->entity)) $this->entity = $conf->entity;
// Multicurrency (test on $this->multicurrency_tx because we should take the default rate only if not using origin rate) // Multicurrency (test on $this->multicurrency_tx because we should take the default rate only if not using origin rate)
if (!empty($this->multicurrency_code) && empty($this->multicurrency_tx)) list($this->fk_multicurrency,$this->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($this->db, $this->multicurrency_code); if (!empty($this->multicurrency_code) && empty($this->multicurrency_tx)) list($this->fk_multicurrency,$this->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($this->db, $this->multicurrency_code);
@ -493,7 +492,7 @@ class Facture extends CommonInvoice
$sql.= ")"; $sql.= ")";
$sql.= " VALUES ("; $sql.= " VALUES (";
$sql.= "'(PROV)'"; $sql.= "'(PROV)'";
$sql.= ", ".$this->entity; $sql.= ", ".setEntity($this);
$sql.= ", ".($this->ref_ext?"'".$this->db->escape($this->ref_ext)."'":"null"); $sql.= ", ".($this->ref_ext?"'".$this->db->escape($this->ref_ext)."'":"null");
$sql.= ", '".$this->db->escape($this->type)."'"; $sql.= ", '".$this->db->escape($this->type)."'";
$sql.= ", '".$socid."'"; $sql.= ", '".$socid."'";
@ -936,8 +935,8 @@ class Facture extends CommonInvoice
$facture->remise_absolue = $this->remise_absolue; $facture->remise_absolue = $this->remise_absolue;
$facture->remise_percent = $this->remise_percent; $facture->remise_percent = $this->remise_percent;
$facture->origin = $this->origin; $facture->origin = $this->origin;
$facture->origin_id = $this->origin_id; $facture->origin_id = $this->origin_id;
$facture->lines = $this->lines; // Array of lines of invoice $facture->lines = $this->lines; // Array of lines of invoice
$facture->products = $this->lines; // Tant que products encore utilise $facture->products = $this->lines; // Tant que products encore utilise
@ -1624,7 +1623,11 @@ class Facture extends CommonInvoice
$this->tab_previous_situation_invoice = array(); $this->tab_previous_situation_invoice = array();
$this->tab_next_situation_invoice = array(); $this->tab_next_situation_invoice = array();
$sql = 'SELECT rowid, situation_counter FROM '.MAIN_DB_PREFIX.'facture WHERE rowid <> '.$this->id.' AND entity = '.$conf->entity.' AND situation_cycle_ref = '.(int) $this->situation_cycle_ref.' ORDER BY situation_counter ASC'; $sql = 'SELECT rowid, situation_counter FROM '.MAIN_DB_PREFIX.'facture';
$sql.= ' WHERE rowid <> '.$this->id;
$sql.= ' AND entity = '.$this->entity;
$sql.= ' AND situation_cycle_ref = '.(int) $this->situation_cycle_ref;
$sql.= ' ORDER BY situation_counter ASC';
dol_syslog(get_class($this).'::fetchPreviousNextSituationInvoice ', LOG_DEBUG); dol_syslog(get_class($this).'::fetchPreviousNextSituationInvoice ', LOG_DEBUG);
$result = $this->db->query($sql); $result = $this->db->query($sql);
@ -3700,11 +3703,11 @@ class Facture extends CommonInvoice
$sql.= " AND ff.type IS NULL"; // Renvoi vrai si pas facture de remplacement $sql.= " AND ff.type IS NULL"; // Renvoi vrai si pas facture de remplacement
$sql.= " AND f.type != ".self::TYPE_CREDIT_NOTE; // Type non 2 si facture non avoir $sql.= " AND f.type != ".self::TYPE_CREDIT_NOTE; // Type non 2 si facture non avoir
if($conf->global->INVOICE_USE_SITUATION_CREDIT_NOTE){ if (! empty($conf->global->INVOICE_USE_SITUATION_CREDIT_NOTE)) {
// Select the last situation invoice // Select the last situation invoice
$sqlSit = 'SELECT MAX(fs.rowid)'; $sqlSit = 'SELECT MAX(fs.rowid)';
$sqlSit.= " FROM ".MAIN_DB_PREFIX."facture as fs"; $sqlSit.= " FROM ".MAIN_DB_PREFIX."facture as fs";
$sqlSit.= " WHERE fs.entity = ".$conf->entity; $sqlSit.= " WHERE fs.entity IN (".getEntity('invoice').")";
$sqlSit.= " AND fs.type = ".self::TYPE_SITUATION; $sqlSit.= " AND fs.type = ".self::TYPE_SITUATION;
$sqlSit.= " AND fs.fk_statut in (".self::STATUS_VALIDATED.",".self::STATUS_CLOSED.")"; $sqlSit.= " AND fs.fk_statut in (".self::STATUS_VALIDATED.",".self::STATUS_CLOSED.")";
$sqlSit.= " GROUP BY fs.situation_cycle_ref"; $sqlSit.= " GROUP BY fs.situation_cycle_ref";
@ -4230,7 +4233,7 @@ class Facture extends CommonInvoice
public function newCycle() public function newCycle()
{ {
$sql = 'SELECT max(situation_cycle_ref) FROM ' . MAIN_DB_PREFIX . 'facture as f'; $sql = 'SELECT max(situation_cycle_ref) FROM ' . MAIN_DB_PREFIX . 'facture as f';
$sql.= " WHERE f.entity in (".getEntity('invoice', 0).")"; $sql.= " WHERE f.entity IN (".getEntity('invoice', 0).")";
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) { if ($resql) {
if ($resql->num_rows > 0) if ($resql->num_rows > 0)
@ -4274,8 +4277,8 @@ class Facture extends CommonInvoice
global $conf; global $conf;
$sql = 'SELECT rowid FROM ' . MAIN_DB_PREFIX . 'facture'; $sql = 'SELECT rowid FROM ' . MAIN_DB_PREFIX . 'facture';
$sql .= ' where situation_cycle_ref = ' . $this->situation_cycle_ref; $sql .= ' WHERE situation_cycle_ref = ' . $this->situation_cycle_ref;
$sql .= ' and situation_counter < ' . $this->situation_counter; $sql .= ' AND situation_counter < ' . $this->situation_counter;
$sql .= ' AND entity = '. ($this->entity > 0 ? $this->entity : $conf->entity); $sql .= ' AND entity = '. ($this->entity > 0 ? $this->entity : $conf->entity);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
$res = array(); $res = array();
@ -4356,7 +4359,9 @@ class Facture extends CommonInvoice
if (!empty($this->situation_cycle_ref)) { if (!empty($this->situation_cycle_ref)) {
// No point in testing anything if we're not inside a cycle // No point in testing anything if we're not inside a cycle
$sql = 'SELECT max(situation_counter) FROM ' . MAIN_DB_PREFIX . 'facture WHERE situation_cycle_ref = ' . $this->situation_cycle_ref . ' AND entity = ' . ($this->entity > 0 ? $this->entity : $conf->entity); $sql = 'SELECT max(situation_counter) FROM ' . MAIN_DB_PREFIX . 'facture';
$sql.= ' WHERE situation_cycle_ref = ' . $this->situation_cycle_ref;
$sql.= ' AND entity = ' . ($this->entity > 0 ? $this->entity : $conf->entity);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql && $resql->num_rows > 0) { if ($resql && $resql->num_rows > 0) {

View File

@ -97,7 +97,7 @@ if ($id > 0 || ! empty($ref))
{ {
$object->fetch_thirdparty(); $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); $head = facture_prepare_head($object);
dol_fiche_head($head, 'documents', $langs->trans('InvoiceCustomer'), -1, 'bill'); dol_fiche_head($head, 'documents', $langs->trans('InvoiceCustomer'), -1, 'bill');

View File

@ -1231,7 +1231,7 @@ if ($resql)
// Extra fields // Extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
// Fields from hook // 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 $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint; print $hookmanager->resPrint;
// Date creation // Date creation

View File

@ -327,6 +327,9 @@ class Conf
} }
// For mycompany storage // For mycompany storage
$this->mycompany->multidir_output = array($this->entity => $rootfordata."/mycompany");
$this->mycompany->multidir_temp = array($this->entity => $rootfordata."/mycompany/temp");
// For backward compatibility
$this->mycompany->dir_output=$rootfordata."/mycompany"; $this->mycompany->dir_output=$rootfordata."/mycompany";
$this->mycompany->dir_temp=$rootfordata."/mycompany/temp"; $this->mycompany->dir_temp=$rootfordata."/mycompany/temp";

View File

@ -1258,7 +1258,7 @@ class FormFile
print '</a>'; print '</a>';
} }
// Preview link // 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:$conf->entity));
print "</td>\n"; print "</td>\n";

View File

@ -2263,10 +2263,10 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity,
$original_file=$conf->adherent->dir_output.'/'.$original_file; $original_file=$conf->adherent->dir_output.'/'.$original_file;
} }
// Wrapping pour les apercu factures // 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; 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 // Wrapping pour les apercu propal
elseif ($modulepart == 'apercupropal' && !empty($conf->propal->multidir_output[$entity])) elseif ($modulepart == 'apercupropal' && !empty($conf->propal->multidir_output[$entity]))
@ -2275,10 +2275,10 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity,
$original_file=$conf->propal->multidir_output[$entity].'/'.$original_file; $original_file=$conf->propal->multidir_output[$entity].'/'.$original_file;
} }
// Wrapping pour les apercu commande // 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; 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 // Wrapping pour les apercu intervention
elseif (($modulepart == 'apercufichinter' || $modulepart == 'apercuficheinter') && !empty($conf->ficheinter->dir_output)) elseif (($modulepart == 'apercufichinter' || $modulepart == 'apercuficheinter') && !empty($conf->ficheinter->dir_output))
@ -2474,13 +2474,13 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity,
} }
// Wrapping for invoices // 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)) if ($fuser->rights->facture->{$lire} || preg_match('/^specimen/i', $original_file))
{ {
$accessallowed=1; $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; $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 // Wrapping for mass actions
@ -2498,7 +2498,7 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity,
{ {
$accessallowed=1; $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_sendings') elseif ($modulepart == 'massfilesarea_sendings')
{ {
@ -2514,7 +2514,7 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity,
{ {
$accessallowed=1; $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') elseif ($modulepart == 'massfilesarea_expensereport')
{ {
@ -2598,13 +2598,13 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity,
} }
// Wrapping pour les commandes // 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)) if ($fuser->rights->commande->{$lire} || preg_match('/^specimen/i', $original_file))
{ {
$accessallowed=1; $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; $sqlprotectagainstexternals = "SELECT fk_soc as fk_soc FROM ".MAIN_DB_PREFIX."commande WHERE ref='".$db->escape($refname)."' AND entity=".$conf->entity;
} }

View File

@ -5,7 +5,7 @@
* Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org> * Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org>
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be> * Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
* Copyright (C) 2004 Christophe Combelles <ccomb@free.fr> * Copyright (C) 2004 Christophe Combelles <ccomb@free.fr>
* Copyright (C) 2005-2017 Regis Houssin <regis.houssin@inodbox.com> * Copyright (C) 2005-2019 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2008 Raphael Bertrand (Resultic) <raphael.bertrand@resultic.fr> * Copyright (C) 2008 Raphael Bertrand (Resultic) <raphael.bertrand@resultic.fr>
* Copyright (C) 2010-2018 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2010-2018 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.fr> * Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.fr>
@ -75,7 +75,7 @@ function getDoliDBInstance($type, $host, $user, $pass, $name, $port)
* @param int $shared 0=Return id of current entity only, * @param int $shared 0=Return id of current entity only,
* 1=Return id of current entity + shared entities (default) * 1=Return id of current entity + shared entities (default)
* @param object $currentobject Current object if needed * @param object $currentobject Current object if needed
* @return mixed Entity id(s) to use * @return mixed Entity id(s) to use ( eg. entity IN ('.getEntity(elementname).')' )
*/ */
function getEntity($element, $shared = 1, $currentobject = null) function getEntity($element, $shared = 1, $currentobject = null)
{ {
@ -95,6 +95,26 @@ function getEntity($element, $shared = 1, $currentobject = null)
} }
} }
/**
* Set entity id to use when to create an object
*
* @param object $currentobject Current object
* @return mixed Entity id to use ( eg. entity = '.setEntity($object) )
*/
function setEntity($currentobject)
{
global $conf, $mc;
if (is_object($mc))
{
return $mc->setEntity($currentobject);
}
else
{
return ((is_object($currentobject) && $currentobject->id > 0 && $currentobject->entity > 0) ? $currentobject->entity : $conf->entity);
}
}
/** /**
* Return information about user browser * Return information about user browser
* *

View File

@ -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/lib/files.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.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)$')); $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
$nbLinks=Link::count($db, $object->element, $object->id); $nbLinks=Link::count($db, $object->element, $object->id);
$head[$h][0] = DOL_URL_ROOT.'/commande/document.php?id='.$object->id; $head[$h][0] = DOL_URL_ROOT.'/commande/document.php?id='.$object->id;

View File

@ -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); $objectref = dol_sanitizeFileName($object->ref);
if (! preg_match('/specimen/i', $objectref)) $dir.= "/" . $objectref; if (! preg_match('/specimen/i', $objectref)) $dir.= "/" . $objectref;
$file = $dir . "/" . $objectref . ".odt"; $file = $dir . "/" . $objectref . ".odt";

View File

@ -239,13 +239,13 @@ class pdf_einstein extends ModelePDFCommandes
// Definition of $dir and $file // Definition of $dir and $file
if ($object->specimen) if ($object->specimen)
{ {
$dir = $conf->commande->dir_output; $dir = $conf->commande->multidir_output[$conf->entity];
$file = $dir . "/SPECIMEN.pdf"; $file = $dir . "/SPECIMEN.pdf";
} }
else else
{ {
$objectref = dol_sanitizeFileName($object->ref); $objectref = dol_sanitizeFileName($object->ref);
$dir = $conf->commande->dir_output . "/" . $objectref; $dir = $conf->commande->multidir_output[$object->entity] . "/" . $objectref;
$file = $dir . "/" . $objectref . ".pdf"; $file = $dir . "/" . $objectref . ".pdf";
} }
@ -290,7 +290,7 @@ class pdf_einstein extends ModelePDFCommandes
// Set path to the background PDF File // Set path to the background PDF File
if (! empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) if (! empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
{ {
$pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND); $pagecount = $pdf->setSourceFile($conf->mycompany->multidir_output[$object->entity].'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
$tplidx = $pdf->importPage(1); $tplidx = $pdf->importPage(1);
} }
@ -1258,7 +1258,7 @@ class pdf_einstein extends ModelePDFCommandes
// Logo // Logo
if (empty($conf->global->PDF_DISABLE_MYCOMPANY_LOGO)) if (empty($conf->global->PDF_DISABLE_MYCOMPANY_LOGO))
{ {
$logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo; $logo=$conf->mycompany->multidir_output[$object->entity].'/logos/'.$this->emetteur->logo;
if ($this->emetteur->logo) if ($this->emetteur->logo)
{ {
if (is_readable($logo)) if (is_readable($logo))

View File

@ -281,13 +281,13 @@ class pdf_eratosthene extends ModelePDFCommandes
// Definition of $dir and $file // Definition of $dir and $file
if ($object->specimen) if ($object->specimen)
{ {
$dir = $conf->commande->dir_output; $dir = $conf->commande->multidir_output[$conf->entity];
$file = $dir . "/SPECIMEN.pdf"; $file = $dir . "/SPECIMEN.pdf";
} }
else else
{ {
$objectref = dol_sanitizeFileName($object->ref); $objectref = dol_sanitizeFileName($object->ref);
$dir = $conf->commande->dir_output . "/" . $objectref; $dir = $conf->commande->multidir_output[$object->entity] . "/" . $objectref;
$file = $dir . "/" . $objectref . ".pdf"; $file = $dir . "/" . $objectref . ".pdf";
} }
@ -331,7 +331,7 @@ class pdf_eratosthene extends ModelePDFCommandes
// Set path to the background PDF File // Set path to the background PDF File
if (! empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) if (! empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
{ {
$pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND); $pagecount = $pdf->setSourceFile($conf->mycompany->multidir_output[$object->entity].'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
$tplidx = $pdf->importPage(1); $tplidx = $pdf->importPage(1);
} }
@ -1393,7 +1393,7 @@ class pdf_eratosthene extends ModelePDFCommandes
// Logo // Logo
if (empty($conf->global->PDF_DISABLE_MYCOMPANY_LOGO)) if (empty($conf->global->PDF_DISABLE_MYCOMPANY_LOGO))
{ {
$logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo; $logo=$conf->mycompany->multidir_output[$object->entity].'/logos/'.$this->emetteur->logo;
if ($this->emetteur->logo) if ($this->emetteur->logo)
{ {
if (is_readable($logo)) if (is_readable($logo))

View File

@ -121,7 +121,7 @@ class mod_commande_marbre extends ModeleNumRefCommandes
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
$sql.= " FROM ".MAIN_DB_PREFIX."commande"; $sql.= " FROM ".MAIN_DB_PREFIX."commande";
$sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; $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); $resql=$db->query($sql);
if ($resql) if ($resql)

View File

@ -137,9 +137,12 @@ class mod_commande_saphir extends ModeleNumRefCommandes
return 0; return 0;
} }
// Get entities
$entity = getEntity('ordernumber', 1, $object);
$date = ($object->date_commande ? $object->date_commande : $object->date); $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; return $numFinal;
} }

View File

@ -342,7 +342,7 @@ class pdf_crabe extends ModelePDFFactures
// Set path to the background PDF File // Set path to the background PDF File
if (! empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) if (! empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
{ {
$pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND); $pagecount = $pdf->setSourceFile($conf->mycompany->multidir_output[$object->entity].'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
$tplidx = $pdf->importPage(1); $tplidx = $pdf->importPage(1);
} }
@ -1611,7 +1611,7 @@ class pdf_crabe extends ModelePDFFactures
// Logo // Logo
if (empty($conf->global->PDF_DISABLE_MYCOMPANY_LOGO)) if (empty($conf->global->PDF_DISABLE_MYCOMPANY_LOGO))
{ {
$logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo; $logo=$conf->mycompany->multidir_output[$object->entity].'/logos/'.$this->emetteur->logo;
if ($this->emetteur->logo) if ($this->emetteur->logo)
{ {
if (is_readable($logo)) if (is_readable($logo))

View File

@ -352,7 +352,7 @@ class pdf_sponge extends ModelePDFFactures
// Set path to the background PDF File // Set path to the background PDF File
if (! empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) if (! empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
{ {
$pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND); $pagecount = $pdf->setSourceFile($conf->mycompany->multidir_output[$object->entity].'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
$tplidx = $pdf->importPage(1); $tplidx = $pdf->importPage(1);
} }
@ -1843,7 +1843,7 @@ class pdf_sponge extends ModelePDFFactures
// Logo // Logo
if (empty($conf->global->PDF_DISABLE_MYCOMPANY_LOGO)) if (empty($conf->global->PDF_DISABLE_MYCOMPANY_LOGO))
{ {
$logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo; $logo=$conf->mycompany->multidir_output[$object->entity].'/logos/'.$this->emetteur->logo;
if ($this->emetteur->logo) if ($this->emetteur->logo)
{ {
if (is_readable($logo)) if (is_readable($logo))

View File

@ -344,7 +344,7 @@ class pdf_azur extends ModelePDFPropales
// Set path to the background PDF File // Set path to the background PDF File
if (! empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) if (! empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
{ {
$pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND); $pagecount = $pdf->setSourceFile($conf->mycompany->multidir_output[$object->entity].'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
$tplidx = $pdf->importPage(1); $tplidx = $pdf->importPage(1);
} }
@ -1459,7 +1459,7 @@ class pdf_azur extends ModelePDFPropales
// Logo // Logo
if (empty($conf->global->PDF_DISABLE_MYCOMPANY_LOGO)) if (empty($conf->global->PDF_DISABLE_MYCOMPANY_LOGO))
{ {
$logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo; $logo=$conf->mycompany->multidir_output[$object->entity].'/logos/'.$this->emetteur->logo;
if ($this->emetteur->logo) if ($this->emetteur->logo)
{ {
if (is_readable($logo)) if (is_readable($logo))

View File

@ -330,7 +330,7 @@ class pdf_cyan extends ModelePDFPropales
// Set path to the background PDF File // Set path to the background PDF File
if (! empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) if (! empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
{ {
$pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND); $pagecount = $pdf->setSourceFile($conf->mycompany->multidir_output[$object->entity].'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
$tplidx = $pdf->importPage(1); $tplidx = $pdf->importPage(1);
} }
@ -1505,7 +1505,7 @@ class pdf_cyan extends ModelePDFPropales
// Logo // Logo
if (empty($conf->global->PDF_DISABLE_MYCOMPANY_LOGO)) if (empty($conf->global->PDF_DISABLE_MYCOMPANY_LOGO))
{ {
$logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo; $logo=$conf->mycompany->multidir_output[$object->entity].'/logos/'.$this->emetteur->logo;
if ($this->emetteur->logo) if ($this->emetteur->logo)
{ {
if (is_readable($logo)) if (is_readable($logo))