\n";
- if (!empty($user->rights->accounting->chartofaccount)) {
+ if ($user->hasRight('accounting', 'chartofaccount')) {
print "
'.$langs->trans("AccountancyAreaDescActionOnce"), '', '')."\n";
@@ -165,7 +165,7 @@ if (!empty($conf->global->INVOICE_USE_SITUATION) && $conf->global->INVOICE_USE_S
print $s;
print "
\n";
- if (!empty($conf->tax->enabled)) {
+ if (isModEnabled('tax')) {
$textlink = '
';
$step++;
$s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescContrib", $step, '{s}');
@@ -173,7 +173,7 @@ if (!empty($conf->global->INVOICE_USE_SITUATION) && $conf->global->INVOICE_USE_S
print $s;
print "
\n";
}
- if (!empty($conf->expensereport->enabled)) { // TODO Move this in the default account page because this is only one accounting account per purpose, not several.
+ if (isModEnabled('expensereport')) { // TODO Move this in the default account page because this is only one accounting account per purpose, not several.
$step++;
$s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescExpenseReport", $step, '{s}');
$s = str_replace('{s}', '
', $s);
@@ -212,7 +212,7 @@ if (!empty($conf->global->INVOICE_USE_SITUATION) && $conf->global->INVOICE_USE_S
print $s;
print "
\n";
- if (!empty($conf->expensereport->enabled) || !empty($conf->deplacement->enabled)) {
+ if (isModEnabled('expensereport') || isModEnabled('deplacement')) {
$step++;
$s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescBind", chr(64 + $step), $langs->transnoentitiesnoconv("ExpenseReports"), '{s}')."\n";
$s = str_replace('{s}', '
', $s);
diff --git a/htdocs/accountancy/journal/bankjournal.php b/htdocs/accountancy/journal/bankjournal.php
index 27ffb681ae0..f3049206389 100644
--- a/htdocs/accountancy/journal/bankjournal.php
+++ b/htdocs/accountancy/journal/bankjournal.php
@@ -83,7 +83,7 @@ $now = dol_now();
$action = GETPOST('action', 'aZ09');
// Security check
-if (empty($conf->accounting->enabled)) {
+if (!isModEnabled('accounting')) {
accessforbidden();
}
if ($user->socid > 0) {
diff --git a/htdocs/accountancy/journal/expensereportsjournal.php b/htdocs/accountancy/journal/expensereportsjournal.php
index dbd1c892086..d38e49c390e 100644
--- a/htdocs/accountancy/journal/expensereportsjournal.php
+++ b/htdocs/accountancy/journal/expensereportsjournal.php
@@ -58,7 +58,7 @@ if ($in_bookkeeping == '') {
$now = dol_now();
// Security check
-if (empty($conf->accounting->enabled)) {
+if (!isModEnabled('accounting')) {
accessforbidden();
}
if ($user->socid > 0) {
diff --git a/htdocs/accountancy/journal/purchasesjournal.php b/htdocs/accountancy/journal/purchasesjournal.php
index e4c292d2670..34faba7e27c 100644
--- a/htdocs/accountancy/journal/purchasesjournal.php
+++ b/htdocs/accountancy/journal/purchasesjournal.php
@@ -61,7 +61,7 @@ $hookmanager->initHooks(array('purchasesjournal'));
$parameters = array();
// Security check
-if (empty($conf->accounting->enabled)) {
+if (!isModEnabled('accounting')) {
accessforbidden();
}
if ($user->socid > 0) {
@@ -405,8 +405,18 @@ if ($action == 'writebookkeeping') {
$bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add
$bookkeeping->thirdparty_code = $companystatic->code_fournisseur;
- $bookkeeping->subledger_account = '';
- $bookkeeping->subledger_label = '';
+ if (!empty($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER_USE_AUXILIARY_ON_DEPOSIT)) {
+ if ($k == getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER_DEPOSIT')) {
+ $bookkeeping->subledger_account = $tabcompany[$key]['code_compta'];
+ $bookkeeping->subledger_label = $tabcompany[$key]['name'];
+ } else {
+ $bookkeeping->subledger_account = '';
+ $bookkeeping->subledger_label = '';
+ }
+ } else {
+ $bookkeeping->subledger_account = '';
+ $bookkeeping->subledger_label = '';
+ }
$bookkeeping->numero_compte = $k;
$bookkeeping->label_compte = $label_account;
@@ -952,6 +962,13 @@ if (empty($action) || $action == 'view') {
print "";
// Subledger account
print "
';
$companystatic->id = $tabcompany[$key]['id'];
$companystatic->name = $tabcompany[$key]['name'];
diff --git a/htdocs/accountancy/journal/sellsjournal.php b/htdocs/accountancy/journal/sellsjournal.php
index 599eeb627b5..107dda05f4a 100644
--- a/htdocs/accountancy/journal/sellsjournal.php
+++ b/htdocs/accountancy/journal/sellsjournal.php
@@ -63,7 +63,7 @@ $hookmanager->initHooks(array('sellsjournal'));
$parameters = array();
// Security check
-if (empty($conf->accounting->enabled)) {
+if (!isModEnabled('accounting')) {
accessforbidden();
}
if ($user->socid > 0) {
diff --git a/htdocs/accountancy/journal/variousjournal.php b/htdocs/accountancy/journal/variousjournal.php
index af32b85d8fa..d737925f2c3 100644
--- a/htdocs/accountancy/journal/variousjournal.php
+++ b/htdocs/accountancy/journal/variousjournal.php
@@ -83,7 +83,7 @@ if (!is_array($journal_data)) {
}
// Security check
-if (empty($conf->accounting->enabled)) {
+if (!isModEnabled('accounting')) {
accessforbidden();
}
if ($user->socid > 0) {
diff --git a/htdocs/accountancy/supplier/card.php b/htdocs/accountancy/supplier/card.php
index 05d32d0cec5..306b88d11ea 100644
--- a/htdocs/accountancy/supplier/card.php
+++ b/htdocs/accountancy/supplier/card.php
@@ -42,7 +42,7 @@ $codeventil = GETPOST('codeventil', 'int');
$id = GETPOST('id', 'int');
// Security check
-if (empty($conf->accounting->enabled)) {
+if (!isModEnabled('accounting')) {
accessforbidden();
}
if ($user->socid > 0) {
diff --git a/htdocs/accountancy/supplier/lines.php b/htdocs/accountancy/supplier/lines.php
index c142361155d..1edbe83eefb 100644
--- a/htdocs/accountancy/supplier/lines.php
+++ b/htdocs/accountancy/supplier/lines.php
@@ -89,7 +89,7 @@ if (!$sortorder) {
$formaccounting = new FormAccounting($db);
// Security check
-if (empty($conf->accounting->enabled)) {
+if (!isModEnabled('accounting')) {
accessforbidden();
}
if ($user->socid > 0) {
diff --git a/htdocs/accountancy/supplier/list.php b/htdocs/accountancy/supplier/list.php
index f274a5432dc..d14beb84cc2 100644
--- a/htdocs/accountancy/supplier/list.php
+++ b/htdocs/accountancy/supplier/list.php
@@ -106,7 +106,7 @@ $accountingAccount = new AccountingAccount($db);
$chartaccountcode = dol_getIdFromCode($db, $conf->global->CHARTOFACCOUNTS, 'accounting_system', 'rowid', 'pcg_version');
// Security check
-if (empty($conf->accounting->enabled)) {
+if (!isModEnabled('accounting')) {
accessforbidden();
}
if ($user->socid > 0) {
diff --git a/htdocs/adherents/admin/member.php b/htdocs/adherents/admin/member.php
index 80092ea96a5..2ffed8b8d97 100644
--- a/htdocs/adherents/admin/member.php
+++ b/htdocs/adherents/admin/member.php
@@ -111,7 +111,7 @@ if ($action == 'set_default') {
if (isModEnabled('facture')) {
$res4 = dolibarr_set_const($db, 'ADHERENT_VAT_FOR_SUBSCRIPTIONS', GETPOST('ADHERENT_VAT_FOR_SUBSCRIPTIONS', 'alpha'), 'chaine', 0, '', $conf->entity);
$res5 = dolibarr_set_const($db, 'ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS', GETPOST('ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS', 'alpha'), 'chaine', 0, '', $conf->entity);
- if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) {
+ if (isModEnabled("product") || isModEnabled("service")) {
$res6 = dolibarr_set_const($db, 'ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS', GETPOST('ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS', 'alpha'), 'chaine', 0, '', $conf->entity);
}
}
@@ -238,13 +238,13 @@ print "\n";
// Insert subscription into bank account
print '
\n";
- if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) {
+ if (isModEnabled("product") || isModEnabled("service")) {
print '
';
- if (!empty($conf->socialnetworks->enabled)) {
+ if (isModEnabled('socialnetworks')) {
foreach ($socialnetworks as $key => $value) {
if (!$value['active']) {
break;
@@ -1128,7 +1110,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
print "\n";
// Categories
- if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire)) {
+ if (isModEnabled('categorie') && !empty($user->rights->categorie->lire)) {
print '
';
- if (!empty($conf->socialnetworks->enabled)) {
+ if (isModEnabled('socialnetworks')) {
foreach ($socialnetworks as $key => $value) {
if (!$value['active']) {
break;
@@ -1363,13 +1345,21 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
print $form->selectDate(($object->birth ? $object->birth : -1), 'birth', '', '', 1, 'formsoc');
print "\n";
+ // Default language
+ if (!empty($conf->global->MAIN_MULTILANGS)) {
+ print '
\n";
// Categories
- if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire)) {
+ if (isModEnabled('categorie') && !empty($user->rights->categorie->lire)) {
print '
'.$langs->trans("LinkedToDolibarrThirdParty").' ';
if ($object->socid) {
$company = new Societe($db);
@@ -1459,12 +1449,12 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
$formquestion = array(
array('label' => $langs->trans("LoginToCreate"), 'type' => 'text', 'name' => 'login', 'value' => $login)
);
- if (!empty($conf->societe->enabled) && $object->socid > 0) {
+ if (isModEnabled('societe') && $object->socid > 0) {
$object->fetch_thirdparty();
$formquestion[] = array('label' => $langs->trans("UserWillBe"), 'type' => 'radio', 'name' => 'internalorexternal', 'default'=>'external', 'values' => array('external'=>$langs->trans("External").' - '.$langs->trans("LinkedToDolibarrThirdParty").' '.$object->thirdparty->getNomUrl(1, '', 0, 1), 'internal'=>$langs->trans("Internal")));
}
$text = '';
- if (!empty($conf->societe->enabled) && $object->socid <= 0) {
+ if (isModEnabled('societe') && $object->socid <= 0) {
$text .= $langs->trans("UserWillBeInternalUser").' ';
}
$text .= $langs->trans("ConfirmCreateLogin");
@@ -1549,12 +1539,12 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
// Create form popup
$formquestion = array();
if ($object->email) {
- $formquestion[] = array('type' => 'checkbox', 'name' => 'send_mail', 'label' => $label, 'value' => ($conf->global->ADHERENT_DEFAULT_SENDINFOBYMAIL ?true:false));
+ $formquestion[] = array('type' => 'checkbox', 'name' => 'send_mail', 'label' => $label, 'value' => (getDolGlobalString('ADHERENT_DEFAULT_SENDINFOBYMAIL') ? true : false));
}
- if (!empty($conf->mailman->enabled) && !empty($conf->global->ADHERENT_USE_MAILMAN)) {
+ if (isModEnabled('mailman') && !empty($conf->global->ADHERENT_USE_MAILMAN)) {
$formquestion[] = array('type'=>'other', 'label'=>$langs->transnoentitiesnoconv("SynchroMailManEnabled"), 'value'=>'');
}
- if (!empty($conf->mailman->enabled) && !empty($conf->global->ADHERENT_USE_SPIP)) {
+ if (isModEnabled('mailman') && !empty($conf->global->ADHERENT_USE_SPIP)) {
$formquestion[] = array('type'=>'other', 'label'=>$langs->transnoentitiesnoconv("SynchroSpipEnabled"), 'value'=>'');
}
print $form->formconfirm("card.php?rowid=".$id, $langs->trans("ValidateMember"), $langs->trans("ConfirmValidateMember"), "confirm_valid", $formquestion, 'yes', 1, 220);
@@ -1580,7 +1570,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
$outputlangs->loadLangs(array("main", "members"));
// Get email content from template
$arraydefaultmessage = null;
- $labeltouse = $conf->global->ADHERENT_EMAIL_TEMPLATE_CANCELATION;
+ $labeltouse = getDolGlobalString('ADHERENT_EMAIL_TEMPLATE_CANCELATION');
if (!empty($labeltouse)) {
$arraydefaultmessage = $formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse);
@@ -1702,7 +1692,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) {
$rowspan++;
}
- if (!empty($conf->societe->enabled)) {
+ if (isModEnabled('societe')) {
$rowspan++;
}
@@ -1793,7 +1783,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
print '';
// Tags / Categories
- if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire)) {
+ if (isModEnabled('categorie') && !empty($user->rights->categorie->lire)) {
print ''.$langs->trans("Categories").' ';
print '';
print $form->showCategories($object->id, Categorie::TYPE_MEMBER, 1);
@@ -1803,6 +1793,19 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
// Birth Date
print ' '.$langs->trans("DateOfBirth").' '.dol_print_date($object->birth, 'day').' ';
+ // Default language
+ if (!empty($conf->global->MAIN_MULTILANGS)) {
+ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
+ print ''.$langs->trans("DefaultLang").' ';
+ //$s=picto_from_langcode($object->default_lang);
+ //print ($s?$s.' ':'');
+ $langs->load("languages");
+ $labellang = ($object->default_lang ? $langs->trans('Language_'.$object->default_lang) : '');
+ print picto_from_langcode($object->default_lang, 'class="paddingrightonly saturatemedium opacitylow"');
+ print $labellang;
+ print ' ';
+ }
+
// Public
print ''.$langs->trans("Public").' '.yn($object->public).' ';
@@ -1810,7 +1813,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
// Third party Dolibarr
- if (!empty($conf->societe->enabled)) {
+ if (isModEnabled('societe')) {
print '';
$editenable = $user->rights->adherent->creer;
print $form->editfieldkey('LinkedToDolibarrThirdParty', 'thirdparty', '', $object, $editenable);
@@ -1948,7 +1951,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
}
// Create third party
- if (!empty($conf->societe->enabled) && !$object->socid) {
+ if (isModEnabled('societe') && !$object->socid) {
if ($user->rights->societe->creer) {
if (Adherent::STATUS_DRAFT != $object->statut) {
print 'id.'&action=create_thirdparty" title="'.dol_escape_htmltag($langs->trans("CreateDolibarrThirdPartyDesc")).'">'.$langs->trans("CreateDolibarrThirdParty").' '."\n";
@@ -1974,7 +1977,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
}
// Action SPIP
- if (!empty($conf->mailmanspip->enabled) && !empty($conf->global->ADHERENT_USE_SPIP)) {
+ if (isModEnabled('mailmanspip') && !empty($conf->global->ADHERENT_USE_SPIP)) {
$isinspip = $mailmanspip->is_in_spip($object);
if ($isinspip == 1) {
@@ -2031,7 +2034,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
*/
// Show online payment link
- $useonlinepayment = (!empty($conf->paypal->enabled) || !empty($conf->stripe->enabled) || !empty($conf->paybox->enabled));
+ $useonlinepayment = (isModEnabled('paypal') || isModEnabled('stripe') || isModEnabled('paybox'));
if ($useonlinepayment) {
print ' ';
diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php
index dec7584b68e..5ecf5069915 100644
--- a/htdocs/adherents/class/adherent.class.php
+++ b/htdocs/adherents/class/adherent.class.php
@@ -215,6 +215,12 @@ class Adherent extends CommonObject
*/
public $public;
+ /**
+ * Default language code of member (en_US, ...)
+ * @var string
+ */
+ public $default_lang;
+
/**
* @var string photo of member
*/
@@ -328,6 +334,7 @@ class Adherent extends CommonObject
'photo' => array('type' => 'varchar(255)', 'label' => 'Photo', 'enabled' => 1, 'visible' => -1, 'position' => 135),
'public' => array('type' => 'smallint(6)', 'label' => 'Public', 'enabled' => 1, 'visible' => -1, 'notnull' => 1, 'position' => 145),
'datefin' => array('type' => 'datetime', 'label' => 'DateEnd', 'enabled' => 1, 'visible' => -1, 'position' => 150),
+ 'default_lang' =>array('type'=>'varchar(6)', 'label'=>'Default lang', 'enabled'=>1, 'visible'=>-1, 'position'=> 153),
'note_private' => array('type' => 'text', 'label' => 'NotePublic', 'enabled' => 1, 'visible' => 0, 'position' => 155),
'note_public' => array('type' => 'text', 'label' => 'NotePrivate', 'enabled' => 1, 'visible' => 0, 'position' => 160),
'datevalid' => array('type' => 'datetime', 'label' => 'DateValidation', 'enabled' => 1, 'visible' => -1, 'position' => 165),
@@ -710,9 +717,11 @@ class Adherent extends CommonObject
$sql .= ", photo = ".($this->photo ? "'".$this->db->escape($this->photo)."'" : "null");
$sql .= ", public = '".$this->db->escape($this->public)."'";
$sql .= ", statut = ".$this->db->escape($this->statut);
+ $sql .= ", default_lang = ".(!empty($this->default_lang) ? "'".$this->db->escape($this->default_lang)."'" : "null");
$sql .= ", fk_adherent_type = ".$this->db->escape($this->typeid);
$sql .= ", morphy = '".$this->db->escape($this->morphy)."'";
$sql .= ", birth = ".($this->birth ? "'".$this->db->idate($this->birth)."'" : "null");
+
if ($this->datefin) {
$sql .= ", datefin = '".$this->db->idate($this->datefin)."'"; // Must be modified only when deleting a subscription
}
@@ -833,6 +842,8 @@ class Adherent extends CommonObject
$luser->office_phone = $this->phone;
$luser->user_mobile = $this->phone_mobile;
+ $luser->lang = $this->default_lang;
+
$luser->fk_member = $this->id;
$result = $luser->update($user, 0, 1, 1); // Use nosync to 1 to avoid cyclic updates
@@ -868,6 +879,7 @@ class Adherent extends CommonObject
$lthirdparty->state_id = $this->state_id;
$lthirdparty->country_id = $this->country_id;
//$lthirdparty->phone_mobile=$this->phone_mobile;
+ $lthirdparty->default_lang = $this->default_lang;
$result = $lthirdparty->update($this->fk_soc, $user, 0, 1, 1, 'update'); // Use sync to 0 to avoid cyclic updates
@@ -960,10 +972,10 @@ class Adherent extends CommonObject
}
/**
- * Fonction qui supprime l'adherent et les donnees associees
+ * Fonction to delete a member and its data
*
* @param int $rowid Id of member to delete
- * @param User $user User object
+ * @param User $user User object
* @param int $notrigger 1=Does not execute triggers, 0= execute triggers
* @return int <0 if KO, 0=nothing to do, >0 if OK
*/
@@ -1314,7 +1326,7 @@ class Adherent extends CommonObject
$sql .= " d.photo, d.fk_adherent_type, d.morphy, d.entity,";
$sql .= " d.datec as datec,";
$sql .= " d.tms as datem,";
- $sql .= " d.datefin as datefin,";
+ $sql .= " d.datefin as datefin, d.default_lang,";
$sql .= " d.birth as birthday,";
$sql .= " d.datevalid as datev,";
$sql .= " d.country,";
@@ -1407,6 +1419,8 @@ class Adherent extends CommonObject
$this->date_validation = $this->db->jdate($obj->datev);
$this->birth = $this->db->jdate($obj->birthday);
+ $this->default_lang = $obj->default_lang;
+
$this->note_private = $obj->note_private;
$this->note_public = $obj->note_public;
$this->morphy = $obj->morphy;
@@ -1759,7 +1773,7 @@ class Adherent extends CommonObject
if (!$error) {
// Add line to draft invoice
$idprodsubscription = 0;
- if (!empty($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS) && (!empty($conf->product->enabled) || !empty($conf->service->enabled))) {
+ if (!empty($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS) && (isModEnabled("product") || isModEnabled("service"))) {
$idprodsubscription = $conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS;
}
@@ -1812,7 +1826,7 @@ class Adherent extends CommonObject
if (!$error) {
// Create payment line for invoice
$paiement_id = $paiement->create($user);
- if (!$paiement_id > 0) {
+ if (!($paiement_id > 0)) {
$this->error = $paiement->error;
$this->errors = $paiement->errors;
$error++;
@@ -1851,10 +1865,10 @@ class Adherent extends CommonObject
$outputlangs = $langs;
$newlang = '';
$lang_id = GETPOST('lang_id');
- if ($conf->global->MAIN_MULTILANGS && empty($newlang) && !empty($lang_id)) {
+ if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang) && !empty($lang_id)) {
$newlang = $lang_id;
}
- if ($conf->global->MAIN_MULTILANGS && empty($newlang)) {
+ if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) {
$newlang = $customer->default_lang;
}
if (!empty($newlang)) {
@@ -2556,6 +2570,7 @@ class Adherent extends CommonObject
$this->datefin = $now;
$this->datevalid = $now;
+ $this->default_lang = '';
$this->typeid = 1; // Id type adherent
$this->type = 'Type adherent'; // Libelle type adherent
diff --git a/htdocs/adherents/class/adherent_type.class.php b/htdocs/adherents/class/adherent_type.class.php
index 86ec35139e1..12735e70211 100644
--- a/htdocs/adherents/class/adherent_type.class.php
+++ b/htdocs/adherents/class/adherent_type.class.php
@@ -440,6 +440,7 @@ class AdherentType extends CommonObject
/**
* Function to delete the member's status
+ * TODO Add param "User $user"
*
* @return int > 0 if OK, 0 if not found, < 0 if KO
*/
diff --git a/htdocs/adherents/document.php b/htdocs/adherents/document.php
index 3dcab7a9c4c..c8282179fe5 100644
--- a/htdocs/adherents/document.php
+++ b/htdocs/adherents/document.php
@@ -128,7 +128,7 @@ if ($id > 0) {
$totalsize += $file['size'];
}
- if (!empty($conf->notification->enabled)) {
+ if (isModEnabled('notification')) {
$langs->load("mails");
}
diff --git a/htdocs/adherents/htpasswd.php b/htdocs/adherents/htpasswd.php
index 60639193295..0a7073f96b0 100644
--- a/htdocs/adherents/htpasswd.php
+++ b/htdocs/adherents/htpasswd.php
@@ -33,7 +33,7 @@ $sortfield = GETPOST('sortfield', 'alphanohtml');
$sortorder = GETPOST('sortorder', 'aZ09');
// Security check
-if (empty($conf->adherent->enabled)) {
+if (!isModEnabled('adherent')) {
accessforbidden();
}
if (empty($user->rights->adherent->export)) {
diff --git a/htdocs/adherents/list.php b/htdocs/adherents/list.php
index 1995485eb4e..f9208daf70d 100644
--- a/htdocs/adherents/list.php
+++ b/htdocs/adherents/list.php
@@ -659,7 +659,7 @@ if ($sall) {
// Filter on categories
$moreforfilter = '';
-if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire) {
+if (isModEnabled('categorie') && $user->rights->categorie->lire) {
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
$moreforfilter .= '';
$moreforfilter .= img_picto($langs->trans('Categories'), 'category', 'class="pictofixedlength"').$formother->select_categories(Categorie::TYPE_MEMBER, $search_categ, 'search_categ', 1);
diff --git a/htdocs/adherents/partnership.php b/htdocs/adherents/partnership.php
index a01e7d28ed2..805a3137226 100644
--- a/htdocs/adherents/partnership.php
+++ b/htdocs/adherents/partnership.php
@@ -88,7 +88,7 @@ $upload_dir = $conf->partnership->multidir_output[isset($object->entity) ? $o
if (getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR') != 'member') {
accessforbidden('Partnership module is not activated for members');
}
-if (empty($conf->partnership->enabled)) {
+if (!isModEnabled('partnership')) {
accessforbidden();
}
if (empty($permissiontoread)) {
@@ -151,7 +151,7 @@ if ($id > 0) {
$object = new Adherent($db);
$result = $object->fetch($id);
- if (!empty($conf->notification->enabled)) {
+ if (isModEnabled('notification')) {
$langs->load("mails");
}
diff --git a/htdocs/adherents/subscription.php b/htdocs/adherents/subscription.php
index cf0ad445c92..5779fe036d9 100644
--- a/htdocs/adherents/subscription.php
+++ b/htdocs/adherents/subscription.php
@@ -271,7 +271,7 @@ if ($user->rights->adherent->cotisation->creer && $action == 'subscription' && !
$action = 'addsubscription';
} else {
// If an amount has been provided, we check also fields that becomes mandatory when amount is not null.
- if (!empty($conf->banque->enabled) && GETPOST("paymentsave") != 'none') {
+ if (isModEnabled('banque') && GETPOST("paymentsave") != 'none') {
if (GETPOST("subscription")) {
if (!GETPOST("label")) {
$errmsg = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Label"));
@@ -475,7 +475,7 @@ if ($rowid > 0) {
if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) {
$rowspan++;
}
- if (!empty($conf->societe->enabled)) {
+ if (isModEnabled('societe')) {
$rowspan++;
}
@@ -571,7 +571,7 @@ if ($rowid > 0) {
print '
';
// Tags / Categories
- if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire)) {
+ if (isModEnabled('categorie') && !empty($user->rights->categorie->lire)) {
print ''.$langs->trans("Categories").' ';
print '';
print $form->showCategories($object->id, Categorie::TYPE_MEMBER, 1);
@@ -589,7 +589,7 @@ if ($rowid > 0) {
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
// Third party Dolibarr
- if (!empty($conf->societe->enabled)) {
+ if (isModEnabled('societe')) {
print ' ';
print '';
print $langs->trans("LinkedToDolibarrThirdParty");
@@ -718,7 +718,7 @@ if ($rowid > 0) {
print_liste_field_titre('DateStart', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'center ');
print_liste_field_titre('DateEnd', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'center ');
print_liste_field_titre('Amount', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right ');
- if (!empty($conf->banque->enabled)) {
+ if (isModEnabled('banque')) {
print_liste_field_titre('Account', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right ');
}
print " \n";
@@ -753,7 +753,7 @@ if ($rowid > 0) {
print ''.dol_print_date($db->jdate($objp->dateh), 'day')." \n";
print ''.dol_print_date($db->jdate($objp->datef), 'day')." \n";
print ''.price($objp->subscription).' ';
- if (!empty($conf->banque->enabled)) {
+ if (isModEnabled('banque')) {
print '';
if ($objp->bid) {
$accountstatic->label = $objp->label;
@@ -762,7 +762,7 @@ if ($rowid > 0) {
$accountstatic->account_number = $objp->account_number;
$accountstatic->currency_code = $objp->currency_code;
- if (!empty($conf->accounting->enabled) && $objp->fk_accountancy_journal > 0) {
+ if (isModEnabled('accounting') && $objp->fk_accountancy_journal > 0) {
$accountingjournal = new AccountingJournal($db);
$accountingjournal->fetch($objp->fk_accountancy_journal);
@@ -782,7 +782,7 @@ if ($rowid > 0) {
if (empty($num)) {
$colspan = 6;
- if (!empty($conf->banque->enabled)) {
+ if (isModEnabled('banque')) {
$colspan++;
}
print ' '.$langs->trans("None").' ';
@@ -797,7 +797,7 @@ if ($rowid > 0) {
if (($action != 'addsubscription' && $action != 'create_thirdparty')) {
// Shon online payment link
- $useonlinepayment = (!empty($conf->paypal->enabled) || !empty($conf->stripe->enabled) || !empty($conf->paybox->enabled));
+ $useonlinepayment = (isModEnabled('paypal') || isModEnabled('stripe') || isModEnabled('paybox'));
if ($useonlinepayment) {
print ' ';
@@ -831,11 +831,11 @@ if ($rowid > 0) {
$bankviainvoice = 1;
}
} else {
- if (!empty($conf->global->ADHERENT_BANK_USE) && $conf->global->ADHERENT_BANK_USE == 'bankviainvoice' && !empty($conf->banque->enabled) && !empty($conf->societe->enabled) && isModEnabled('facture')) {
+ if (!empty($conf->global->ADHERENT_BANK_USE) && $conf->global->ADHERENT_BANK_USE == 'bankviainvoice' && isModEnabled('banque') && isModEnabled('societe') && isModEnabled('facture')) {
$bankviainvoice = 1;
- } elseif (!empty($conf->global->ADHERENT_BANK_USE) && $conf->global->ADHERENT_BANK_USE == 'bankdirect' && !empty($conf->banque->enabled)) {
+ } elseif (!empty($conf->global->ADHERENT_BANK_USE) && $conf->global->ADHERENT_BANK_USE == 'bankdirect' && isModEnabled('banque')) {
$bankdirect = 1;
- } elseif (!empty($conf->global->ADHERENT_BANK_USE) && $conf->global->ADHERENT_BANK_USE == 'invoiceonly' && !empty($conf->banque->enabled) && !empty($conf->societe->enabled) && isModEnabled('facture')) {
+ } elseif (!empty($conf->global->ADHERENT_BANK_USE) && $conf->global->ADHERENT_BANK_USE == 'invoiceonly' && isModEnabled('banque') && isModEnabled('societe') && isModEnabled('facture')) {
$invoiceonly = 1;
}
}
@@ -982,7 +982,7 @@ if ($rowid > 0) {
print '">';
// Complementary action
- if ((!empty($conf->banque->enabled) || isModEnabled('facture')) && empty($conf->global->ADHERENT_SUBSCRIPTION_HIDECOMPLEMENTARYACTIONS)) {
+ if ((isModEnabled('banque') || isModEnabled('facture')) && empty($conf->global->ADHERENT_SUBSCRIPTION_HIDECOMPLEMENTARYACTIONS)) {
$company = new Societe($db);
if ($object->fk_soc) {
$result = $company->fetch($object->fk_soc);
@@ -998,12 +998,12 @@ if ($rowid > 0) {
print ' ';
print ' '.$langs->trans("None").' ';
// Add entry into bank accoun
- if (!empty($conf->banque->enabled)) {
+ if (isModEnabled('banque')) {
print ' '.$langs->trans("MoreActionBankDirect").' ';
}
// Add invoice with no payments
- if (!empty($conf->societe->enabled) && isModEnabled('facture')) {
+ if (isModEnabled('societe') && isModEnabled('facture')) {
print ' fk_soc)) print ' disabled';
print '> '.$langs->trans("MoreActionInvoiceOnly");
@@ -1022,7 +1022,7 @@ if ($rowid > 0) {
if (empty($conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS) || $conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS != 'defaultforfoundationcountry') {
print '. '.$langs->trans("NoVatOnSubscription", 0).' ';
}
- if (!empty($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS) && (!empty($conf->product->enabled) || !empty($conf->service->enabled))) {
+ if (!empty($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS) && (isModEnabled('product') || isModEnabled('service'))) {
$prodtmp = new Product($db);
$result = $prodtmp->fetch($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS);
if ($result < 0) {
@@ -1033,7 +1033,7 @@ if ($rowid > 0) {
print ' ';
}
// Add invoice with payments
- if (!empty($conf->banque->enabled) && !empty($conf->societe->enabled) && isModEnabled('facture')) {
+ if (isModEnabled('banque') && isModEnabled('societe') && isModEnabled('facture')) {
print ' fk_soc)) print ' disabled';
print '> '.$langs->trans("MoreActionBankViaInvoice");
@@ -1052,7 +1052,7 @@ if ($rowid > 0) {
if (empty($conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS) || $conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS != 'defaultforfoundationcountry') {
print '. '.$langs->trans("NoVatOnSubscription", 0).' ';
}
- if (!empty($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS) && (!empty($conf->product->enabled) || !empty($conf->service->enabled))) {
+ if (!empty($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS) && (isModEnabled('product')|| isModEnabled('service'))) {
$prodtmp = new Product($db);
$result = $prodtmp->fetch($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS);
if ($result < 0) {
diff --git a/htdocs/adherents/subscription/card.php b/htdocs/adherents/subscription/card.php
index a18259fefe4..439541dff05 100644
--- a/htdocs/adherents/subscription/card.php
+++ b/htdocs/adherents/subscription/card.php
@@ -27,7 +27,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php';
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php';
require_once DOL_DOCUMENT_ROOT.'/adherents/class/subscription.class.php';
-if (!empty($conf->banque->enabled)) {
+if (isModEnabled("banque")) {
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
}
@@ -229,7 +229,7 @@ if ($user->rights->adherent->cotisation->creer && $action == 'edit') {
print ' ';
// Bank line
- if (!empty($conf->banque->enabled) && ($conf->global->ADHERENT_BANK_USE || $object->fk_bank)) {
+ if (isModEnabled("banque") && (!empty($conf->global->ADHERENT_BANK_USE) || $object->fk_bank)) {
print ''.$langs->trans("BankTransactionLine").' ';
if ($object->fk_bank) {
$bankline = new AccountLine($db);
@@ -270,7 +270,7 @@ if ($rowid && $action != 'edit') {
//$formquestion=array();
//$formquestion['text']=''.$langs->trans("ThisWillAlsoDeleteBankRecord").' ';
$text = $langs->trans("ConfirmDeleteSubscription");
- if (!empty($conf->banque->enabled) && !empty($conf->global->ADHERENT_BANK_USE)) {
+ if (isModEnabled("banque") && !empty($conf->global->ADHERENT_BANK_USE)) {
$text .= ' '.img_warning().' '.$langs->trans("ThisWillAlsoDeleteBankRecord");
}
print $form->formconfirm($_SERVER["PHP_SELF"]."?rowid=".$object->id, $langs->trans("DeleteSubscription"), $text, "confirm_delete", $formquestion, 0, 1);
@@ -325,7 +325,7 @@ if ($rowid && $action != 'edit') {
print ' '.$langs->trans("Label").' '.$object->note.' ';
// Bank line
- if (!empty($conf->banque->enabled) && ($conf->global->ADHERENT_BANK_USE || $object->fk_bank)) {
+ if (isModEnabled("banque") && (!empty($conf->global->ADHERENT_BANK_USE) || $object->fk_bank)) {
print ''.$langs->trans("BankTransactionLine").' ';
if ($object->fk_bank) {
$bankline = new AccountLine($db);
diff --git a/htdocs/adherents/subscription/list.php b/htdocs/adherents/subscription/list.php
index 3fa4c4b3e7f..c19fa40c2bc 100644
--- a/htdocs/adherents/subscription/list.php
+++ b/htdocs/adherents/subscription/list.php
@@ -89,7 +89,7 @@ $arrayfields = array(
'd.firstname'=>array('label'=>"Firstname", 'checked'=>1),
'd.login'=>array('label'=>"Login", 'checked'=>1),
't.libelle'=>array('label'=>"Label", 'checked'=>1),
- 'd.bank'=>array('label'=>"BankAccount", 'checked'=>1, 'enabled'=>(!empty($conf->banque->enabled))),
+ 'd.bank'=>array('label'=>"BankAccount", 'checked'=>1, 'enabled'=>(isModEnabled('banque'))),
/*'d.note_public'=>array('label'=>"NotePublic", 'checked'=>0),
'd.note_private'=>array('label'=>"NotePrivate", 'checked'=>0),*/
'c.dateadh'=>array('label'=>"DateSubscription", 'checked'=>1, 'position'=>100),
diff --git a/htdocs/adherents/type.php b/htdocs/adherents/type.php
index f3d5f96a78a..b6463e006a9 100644
--- a/htdocs/adherents/type.php
+++ b/htdocs/adherents/type.php
@@ -41,6 +41,7 @@ $langs->load("members");
$rowid = GETPOST('rowid', 'int');
$action = GETPOST('action', 'aZ09');
$cancel = GETPOST('cancel', 'alpha');
+$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : str_replace('_', '', basename(dirname(__FILE__)).basename(__FILE__, '.php')); // To manage different context of search
$backtopage = GETPOST('backtopage', 'alpha');
$sall = GETPOST("sall", "alpha");
@@ -170,12 +171,14 @@ if ($action == 'add' && $user->rights->adherent->configurer) {
if ($action == 'update' && $user->rights->adherent->configurer) {
$object->fetch($rowid);
- $object->oldcopy = clone $object;
+ $object->oldcopy = dol_clone($object);
+
$object->label= trim($label);
$object->morphy = trim($morphy);
$object->status = (int) $status;
$object->subscription = (int) $subscription;
$object->amount = ($amount == '' ? '' : price2num($amount, 'MT'));
+ $object->caneditamount = $caneditamount;
$object->duration_value = $duration_value;
$object->duration_unit = $duration_unit;
$object->note = trim($comment);
@@ -201,7 +204,7 @@ if ($action == 'update' && $user->rights->adherent->configurer) {
exit;
}
-if ($action == 'confirm_delete' && $user->rights->adherent->configurer) {
+if ($action == 'confirm_delete' && !empty($user->rights->adherent->configurer)) {
$object->fetch($rowid);
$res = $object->delete();
@@ -447,7 +450,7 @@ if ($rowid > 0) {
print '';
print '
';
- print '
';
+ print '';
// Morphy
print ''.$langs->trans("MembersNature").' '.$object->getmorphylib($object->morphy).' ';
@@ -681,20 +684,23 @@ if ($rowid > 0) {
print_liste_field_titre("Action", $_SERVER["PHP_SELF"], "", $param, "", 'width="60" align="center"', $sortfield, $sortorder);
print " \n";
- while ($i < $num && $i < $conf->liste_limit) {
+ $adh = new Adherent($db);
+
+ $imaxinloop = ($limit ? min($num, $limit) : $num);
+ while ($i < $imaxinloop) {
$objp = $db->fetch_object($resql);
$datefin = $db->jdate($objp->datefin);
- $adh = new Adherent($db);
$adh->lastname = $objp->lastname;
$adh->firstname = $objp->firstname;
$adh->datefin = $datefin;
$adh->need_subscription = $objp->subscription;
$adh->statut = $objp->status;
- // Lastname
print '';
+
+ // Lastname
if ($objp->company != '') {
print ''.img_object($langs->trans("ShowMember"), "user", 'class="paddingright"').$adh->getFullName($langs, 0, -1, 20).' / '.dol_trunc($objp->company, 12).' '."\n";
} else {
@@ -702,7 +708,7 @@ if ($rowid > 0) {
}
// Login
- print "".$objp->login." \n";
+ print "".dol_escape_htmltag($objp->login)." \n";
// Type
/*print '';
@@ -759,11 +765,15 @@ if ($rowid > 0) {
$i++;
}
+ if ($i == 0) {
+ print ' '.$langs->trans("None").' ';
+ }
+
print "
\n";
print '';
print '';
- if ($num > $conf->liste_limit) {
+ if ($num > $limit) {
print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, '');
}
} else {
@@ -819,6 +829,10 @@ if ($rowid > 0) {
print '">';
print '';
+ print ''.$form->textwithpicto($langs->trans("CanEditAmountShort"), $langs->transnoentities("CanEditAmountDetail")).' ';
+ print $form->selectyesno("caneditamount", $object->caneditamount);
+ print ' ';
+
print ''.$langs->trans("VoteAllowed").' ';
print $form->selectyesno("vote", $object->vote, 1);
print ' ';
diff --git a/htdocs/adherents/type_translation.php b/htdocs/adherents/type_translation.php
index 72976d4e65f..d7d062a1e5f 100644
--- a/htdocs/adherents/type_translation.php
+++ b/htdocs/adherents/type_translation.php
@@ -34,7 +34,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
// Load translation files required by the page
$langs->loadLangs(array('members', 'languages'));
-$id = GETPOST('rowid', 'int');
+$id = GETPOST('rowid', 'int') ? GETPOST('rowid', 'int') : GETPOST('id', 'int');
$action = GETPOST('action', 'aZ09');
$cancel = GETPOST('cancel', 'alpha');
$ref = GETPOST('ref', 'alphanohtml');
@@ -61,7 +61,12 @@ if ($cancel == $langs->trans("Cancel")) {
if ($action == 'delete' && GETPOST('langtodelete', 'alpha')) {
$object = new AdherentType($db);
$object->fetch($id);
- $object->delMultiLangs(GETPOST('langtodelete', 'alpha'), $user);
+ $result = $object->delMultiLangs(GETPOST('langtodelete', 'alpha'), $user);
+ if ($result > 0) {
+ setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs');
+ header("Location: ".$_SERVER["PHP_SELF"].'?id='.$id);
+ exit;
+ }
}
// Add translation
diff --git a/htdocs/admin/agenda.php b/htdocs/admin/agenda.php
index 52926cf1b19..3221738bcd3 100644
--- a/htdocs/admin/agenda.php
+++ b/htdocs/admin/agenda.php
@@ -184,7 +184,7 @@ if (!empty($triggers)) {
}
//print 'module='.$module.' code='.$trigger['code'].' ';
- if (!empty($conf->$module->enabled)) {
+ if (isModEnabled('module')) {
// Discard special case: If option FICHINTER_CLASSIFY_BILLED is not set, we discard both trigger FICHINTER_CLASSIFY_BILLED and FICHINTER_CLASSIFY_UNBILLED
if ($trigger['code'] == 'FICHINTER_CLASSIFY_BILLED' && empty($conf->global->FICHINTER_CLASSIFY_BILLED)) {
continue;
diff --git a/htdocs/admin/agenda_extsites.php b/htdocs/admin/agenda_extsites.php
index 5567e741272..6e0a6e9085f 100644
--- a/htdocs/admin/agenda_extsites.php
+++ b/htdocs/admin/agenda_extsites.php
@@ -66,7 +66,7 @@ if (preg_match('/set_(.*)/', $action, $reg)) {
$value = (GETPOST($code) ? GETPOST($code) : 1);
$res = dolibarr_set_const($db, $code, $value, 'chaine', 0, '', $conf->entity);
- if (!$res > 0) {
+ if (!($res > 0)) {
$error++;
$errors[] = $db->lasterror();
}
@@ -86,7 +86,7 @@ if (preg_match('/set_(.*)/', $action, $reg)) {
$code = $reg[1];
$res = dolibarr_del_const($db, $code, $conf->entity);
- if (!$res > 0) {
+ if (!($res > 0)) {
$error++;
$errors[] = $db->lasterror();
}
diff --git a/htdocs/admin/agenda_reminder.php b/htdocs/admin/agenda_reminder.php
index 79aa081ddef..166c24f2188 100644
--- a/htdocs/admin/agenda_reminder.php
+++ b/htdocs/admin/agenda_reminder.php
@@ -206,7 +206,7 @@ $job->fetch(0, 'ActionComm', 'sendEmailsReminder');
// AGENDA REMINDER EMAIL
print ''."\n";
print ''.$langs->trans('AGENDA_REMINDER_EMAIL', $langs->transnoentities("Module2300Name"));
-if (!empty($conf->cron->enabled)) {
+if (isModEnabled('cron')) {
if (!empty($conf->global->AGENDA_REMINDER_EMAIL)) {
if ($job->id > 0) {
if ($job->status == $job::STATUS_ENABLED) {
@@ -219,7 +219,7 @@ print ' '."\n";
print ' '."\n";
print ''."\n";
-if (empty($conf->cron->enabled)) {
+if (!isModEnabled('cron')) {
print ''.$langs->trans("WarningModuleNotActive", $langs->transnoentitiesnoconv("Module2300Name")).' ';
} else {
if (empty($conf->global->AGENDA_REMINDER_EMAIL)) {
diff --git a/htdocs/admin/barcode.php b/htdocs/admin/barcode.php
index 1a4f5873e33..4957d5fb513 100644
--- a/htdocs/admin/barcode.php
+++ b/htdocs/admin/barcode.php
@@ -190,7 +190,7 @@ foreach ($dirbarcode as $reldir) {
// Select barcode numbering module
-if ($conf->product->enabled) {
+if (isModEnabled('product')) {
print load_fiche_titre($langs->trans("BarCodeNumberManager")." (".$langs->trans("Product").")", '', '');
print '';
@@ -252,7 +252,7 @@ if ($conf->product->enabled) {
}
// Select barcode numbering module
-if ($conf->societe->enabled) {
+if (isModEnabled('societe')) {
print load_fiche_titre($langs->trans("BarCodeNumberManager")." (".$langs->trans("ThirdParty").")", '', '');
print '
';
@@ -450,7 +450,7 @@ if (!isset($_SERVER['WINDIR'])) {
}
// Module products
-if (!empty($conf->product->enabled)) {
+if (isModEnabled('product')) {
print '
';
print ''.$langs->trans("SetDefaultBarcodeTypeProducts").' ';
print '';
@@ -461,7 +461,7 @@ if (!empty($conf->product->enabled)) {
}
// Module thirdparty
-if (!empty($conf->societe->enabled)) {
+if (isModEnabled('societe')) {
print ' ';
print ''.$langs->trans("SetDefaultBarcodeTypeThirdParties").' ';
print '';
diff --git a/htdocs/admin/commande.php b/htdocs/admin/commande.php
index a2aa663f189..eec8bb16417 100644
--- a/htdocs/admin/commande.php
+++ b/htdocs/admin/commande.php
@@ -507,7 +507,7 @@ print ' ';
print "".$langs->trans("SuggestPaymentByRIBOnAccount")." ";
print "";
if (empty($conf->facture->enabled)) {
- if (!empty($conf->banque->enabled)) {
+ if (isModEnabled("banque")) {
$sql = "SELECT rowid, label";
$sql .= " FROM ".MAIN_DB_PREFIX."bank_account";
$sql .= " WHERE clos = 0";
diff --git a/htdocs/admin/company.php b/htdocs/admin/company.php
index c72976f829e..af44c18bee6 100644
--- a/htdocs/admin/company.php
+++ b/htdocs/admin/company.php
@@ -466,7 +466,7 @@ print ' '."\n";
// Barcode
-if (!empty($conf->barcode->enabled)) {
+if (isModEnabled('barcode')) {
print '
';
print ''.$langs->trans("Gencod").' ';
print ' ';
diff --git a/htdocs/admin/confexped.php b/htdocs/admin/confexped.php
index c2ca271e5ea..6eaeb0bf233 100644
--- a/htdocs/admin/confexped.php
+++ b/htdocs/admin/confexped.php
@@ -44,7 +44,7 @@ $action = GETPOST('action', 'aZ09');
*/
// Shipment note
-if (!empty($conf->expedition->enabled) && empty($conf->global->MAIN_SUBMODULE_EXPEDITION)) {
+if (isModEnabled('expedition') && empty($conf->global->MAIN_SUBMODULE_EXPEDITION)) {
// This option should always be set to on when module is on.
dolibarr_set_const($db, "MAIN_SUBMODULE_EXPEDITION", "1", 'chaine', 0, '', $conf->entity);
}
diff --git a/htdocs/admin/const.php b/htdocs/admin/const.php
index a5a68a0bb49..1354f418967 100644
--- a/htdocs/admin/const.php
+++ b/htdocs/admin/const.php
@@ -26,6 +26,7 @@
require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/security.lib.php';
// Load translation files required by the page
$langs->load("admin");
@@ -185,12 +186,12 @@ print ' ';
print '';
print '
';
print '';
-print getTitleFieldOfList('Name', 0, $_SERVER['PHP_SELF'], 'name', '', $param, '', $sortfield, $sortorder, '')."\n";
+print getTitleFieldOfList('Name', 0, $_SERVER['PHP_SELF'], 'name', '', $param, '', $sortfield, $sortorder, '') . "\n";
print getTitleFieldOfList("Value", 0, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder);
print getTitleFieldOfList("Comment", 0, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder);
-print getTitleFieldOfList('DateModificationShort', 0, $_SERVER['PHP_SELF'], 'tms', '', $param, '', $sortfield, $sortorder, 'center ')."\n";
-if (!empty($conf->multicompany->enabled) && !$user->entity) {
- print getTitleFieldOfList('Entity', 0, $_SERVER['PHP_SELF'], 'tms', '', $param, '', $sortfield, $sortorder, 'center ')."\n";
+print getTitleFieldOfList('DateModificationShort', 0, $_SERVER['PHP_SELF'], 'tms', '', $param, '', $sortfield, $sortorder, 'center ') . "\n";
+if (isModEnabled('multicompany') && !$user->entity) {
+ print getTitleFieldOfList('Entity', 0, $_SERVER['PHP_SELF'], 'tms', '', $param, '', $sortfield, $sortorder, 'center ') . "\n";
}
print getTitleFieldOfList("", 0, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'center ');
print " \n";
@@ -211,14 +212,14 @@ print '';
print '';
print ' ';
// Limit to superadmin
-if (!empty($conf->multicompany->enabled) && !$user->entity) {
+if (isModEnabled('multicompany') && !$user->entity) {
print '';
- print ' ';
+ print ' ';
print ' ';
print '';
} else {
print ' ';
- print ' ';
+ print ' ';
}
print ' ';
print " \n";
@@ -255,16 +256,18 @@ if ($result) {
while ($i < $num) {
$obj = $db->fetch_object($result);
+ $value = dolDecrypt($obj->value);
+
print "\n";
- print ''.$obj->name.' '."\n";
+ print ''.dol_escape_htmltag($obj->name).' '."\n";
// Value
print '';
print ' ';
print ' ';
print ' ';
- print ' ';
+ print ' ';
print ' ';
// Note
@@ -278,14 +281,14 @@ if ($result) {
print '';
// Entity limit to superadmin
- if (!empty($conf->multicompany->enabled) && !$user->entity) {
+ if (isModEnabled('multicompany') && !$user->entity) {
print '';
- print ' ';
+ print ' ';
print ' ';
print '';
} else {
print ' ';
- print ' ';
+ print ' ';
}
if ($conf->use_javascript_ajax) {
diff --git a/htdocs/admin/contract.php b/htdocs/admin/contract.php
index a2db7bf8fcf..31d0776da6b 100644
--- a/htdocs/admin/contract.php
+++ b/htdocs/admin/contract.php
@@ -142,7 +142,7 @@ if ($action == 'updateMask') {
$value = GETPOST('activate_hideClosedServiceByDefault', 'alpha');
$res3 = dolibarr_set_const($db, "CONTRACT_HIDE_CLOSED_SERVICES_BY_DEFAULT", $value, 'chaine', 0, '', $conf->entity);
- if (!$res1 > 0 || !$res2 > 0 || !$res3 > 0) {
+ if (!($res1 > 0) || !($res2 > 0) || !($res3 > 0)) {
$error++;
}
diff --git a/htdocs/admin/dav.php b/htdocs/admin/dav.php
index 698bb187d67..d9825ad6886 100644
--- a/htdocs/admin/dav.php
+++ b/htdocs/admin/dav.php
@@ -185,13 +185,13 @@ $message .= ajax_autoselect('webdavpublicurl');
$message .= ' ';
if (!empty($conf->global->DAV_ALLOW_PUBLIC_DIR)) {
- $urlEntity = (!empty($conf->multicompany->enabled) ? '?entity='.$conf->entity : '');
- $url = ''.$urlwithroot.'/dav/fileserver.php/public/'.$urlEntity.' ';
+ $urlEntity = (isModEnabled('multicompany') ? '?entity=' . $conf->entity : '');
+ $url = '' . $urlwithroot . '/dav/fileserver.php/public/' . $urlEntity . ' ';
- $message .= img_picto('', 'globe').' '.str_replace('{url}', $url, $langs->trans("WebDavServer", 'WebDAV public', ''));
- $message .= '';
- $message .= '
';
- $message .= ' '.img_picto('', 'globe');
+ $message .= img_picto('', 'globe') . ' ' . str_replace('{url}', $url, $langs->trans("WebDavServer", 'WebDAV public', ''));
+ $message .= '';
$message .= ajax_autoselect('webdavurl');
diff --git a/htdocs/admin/debugbar.php b/htdocs/admin/debugbar.php
index 8195683c5ab..6672f04a1af 100644
--- a/htdocs/admin/debugbar.php
+++ b/htdocs/admin/debugbar.php
@@ -90,12 +90,12 @@ print ' ';
print ' ';
print '';
print ''.$langs->trans("Parameter").' '.$langs->trans("Value").' ';
-print ' ';
+print ' ';
print " \n";
print ''.$langs->trans("DEBUGBAR_USE_LOG_FILE").' ';
print '';
-print $form->selectyesno('DEBUGBAR_USE_LOG_FILE', $conf->global->DEBUGBAR_USE_LOG_FILE, 1);
+print $form->selectyesno('DEBUGBAR_USE_LOG_FILE', !empty($conf->global->DEBUGBAR_USE_LOG_FILE), 1);
print ' ';
print ' '.$langs->trans("UsingLogFileShowAllRecordOfSubrequestButIsSlower").' ';
print ' ';
diff --git a/htdocs/admin/defaultvalues.php b/htdocs/admin/defaultvalues.php
index 088c84de3f0..f83b77e67a6 100644
--- a/htdocs/admin/defaultvalues.php
+++ b/htdocs/admin/defaultvalues.php
@@ -306,7 +306,7 @@ if ($mode != 'focus' && $mode != 'mandatory') {
print_liste_field_titre($textvalue, $_SERVER["PHP_SELF"], 'value', '', $param, '', $sortfield, $sortorder);
}
// Entity
-if (!empty($conf->multicompany->enabled) && !$user->entity) {
+if (isModEnabled('multicompany') && !$user->entity) {
print_liste_field_titre("Entity", $_SERVER["PHP_SELF"], 'entity,page', '', $param, '', $sortfield, $sortorder);
} else {
print_liste_field_titre("", $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder);
@@ -335,13 +335,13 @@ if ($mode != 'focus' && $mode != 'mandatory') {
print '';
}
// Limit to superadmin
-if (!empty($conf->multicompany->enabled) && !$user->entity) {
+if (isModEnabled('multicompany') && !$user->entity) {
print '';
- print ' '; // We see environment, but to change it we must switch on other entity
+ print ' '; // We see environment, but to change it we must switch on other entity
print ' ';
} else {
print '';
- print ' ';
+ print ' ';
print ' ';
}
print '';
diff --git a/htdocs/admin/delais.php b/htdocs/admin/delais.php
index 2ae77b03d07..af8fed1c197 100644
--- a/htdocs/admin/delais.php
+++ b/htdocs/admin/delais.php
@@ -172,7 +172,7 @@ if (!isset($conf->global->MAIN_DELAY_ORDERS_TO_PROCESS)) {
if ($action == 'update') {
foreach ($modules as $module => $delays) {
- if (!empty($conf->$module->enabled)) {
+ if (isModEnabled('module')) {
foreach ($delays as $delay) {
if (GETPOST($delay['code']) != '') {
dolibarr_set_const($db, $delay['code'], GETPOST($delay['code']), 'chaine', 0, '', $conf->entity);
@@ -226,13 +226,13 @@ if ($action == 'edit') {
print ' '.$langs->trans("LateWarningAfter").' ';
foreach ($modules as $module => $delays) {
- if (!empty($conf->$module->enabled)) {
+ if (isModEnabled('module')) {
foreach ($delays as $delay) {
- $value = (!empty($conf->global->{$delay['code']}) ? $conf->global->{$delay['code']}:0);
+ $value = (!empty($conf->global->{$delay['code']}) ? $conf->global->{$delay['code']} : 0);
print '';
- print ''.img_object('', $delay['img']).' ';
- print ''.$langs->trans('Delays_'.$delay['code']).' ';
- print ' '.$langs->trans("days").' ';
+ print '' . img_object('', $delay['img']) . ' ';
+ print '' . $langs->trans('Delays_' . $delay['code']) . ' ';
+ print ' ' . $langs->trans("days") . ' ';
}
}
}
@@ -260,13 +260,13 @@ if ($action == 'edit') {
print ''.$langs->trans("DelaysOfToleranceBeforeWarning").' '.$langs->trans("Value").' ';
foreach ($modules as $module => $delays) {
- if (!empty($conf->$module->enabled)) {
+ if (isModEnabled('module')) {
foreach ($delays as $delay) {
- $value = (!empty($conf->global->{$delay['code']}) ? $conf->global->{$delay['code']}:0);
+ $value = (!empty($conf->global->{$delay['code']}) ? $conf->global->{$delay['code']} : 0);
print '';
- print ''.img_object('', $delay['img']).' ';
- print ''.$langs->trans('Delays_'.$delay['code']).' ';
- print ''.$value.' '.$langs->trans("days").' ';
+ print '' . img_object('', $delay['img']) . ' ';
+ print '' . $langs->trans('Delays_' . $delay['code']) . ' ';
+ print '' . $value . ' ' . $langs->trans("days") . ' ';
}
}
}
diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php
index dd29ee1cde3..05f692be526 100644
--- a/htdocs/admin/dict.php
+++ b/htdocs/admin/dict.php
@@ -483,33 +483,33 @@ $tabrowid[44] = "rowid";
// Condition to show dictionary in setup page
$tabcond = array();
-$tabcond[1] = (!empty($conf->societe->enabled));
+$tabcond[1] = (isModEnabled("societe"));
$tabcond[2] = true;
$tabcond[3] = true;
$tabcond[4] = true;
-$tabcond[5] = (!empty($conf->societe->enabled) || !empty($conf->adherent->enabled));
+$tabcond[5] = (isModEnabled("societe") || !empty($conf->adherent->enabled));
$tabcond[6] = isModEnabled('agenda');
$tabcond[7] = !empty($conf->tax->enabled);
-$tabcond[8] = !empty($conf->societe->enabled);
+$tabcond[8] = isModEnabled("societe");
$tabcond[9] = true;
$tabcond[10] = true;
-$tabcond[11] = (!empty($conf->societe->enabled));
-$tabcond[12] = (!empty($conf->commande->enabled) || !empty($conf->propal->enabled) || isModEnabled('facture') || (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_invoice->enabled) || !empty($conf->supplier_order->enabled));
-$tabcond[13] = (!empty($conf->commande->enabled) || !empty($conf->propal->enabled) || isModEnabled('facture') || (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_invoice->enabled) || !empty($conf->supplier_order->enabled));
-$tabcond[14] = (!empty($conf->product->enabled) && (!empty($conf->ecotax->enabled) || !empty($conf->global->MAIN_SHOW_ECOTAX_DICTIONNARY)));
+$tabcond[11] = (isModEnabled("societe"));
+$tabcond[12] = (!empty($conf->commande->enabled) || isModEnabled("propal") || isModEnabled('facture') || (isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_invoice") || isModEnabled("supplier_order"));
+$tabcond[13] = (!empty($conf->commande->enabled) || isModEnabled("propal") || isModEnabled('facture') || (isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_invoice") || isModEnabled("supplier_order"));
+$tabcond[14] = (isModEnabled("product") && (!empty($conf->ecotax->enabled) || !empty($conf->global->MAIN_SHOW_ECOTAX_DICTIONNARY)));
$tabcond[15] = true;
-$tabcond[16] = (!empty($conf->societe->enabled) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS));
+$tabcond[16] = (isModEnabled("societe") && empty($conf->global->SOCIETE_DISABLE_PROSPECTS));
$tabcond[17] = (!empty($conf->deplacement->enabled) || !empty($conf->expensereport->enabled));
-$tabcond[18] = !empty($conf->expedition->enabled) || !empty($conf->reception->enabled);
-$tabcond[19] = !empty($conf->societe->enabled);
-$tabcond[20] = (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled);
-$tabcond[21] = !empty($conf->propal->enabled);
-$tabcond[22] = (!empty($conf->commande->enabled) || !empty($conf->propal->enabled));
+$tabcond[18] = isModEnabled("expedition") || isModEnabled("reception");
+$tabcond[19] = isModEnabled("societe");
+$tabcond[20] = (isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order");
+$tabcond[21] = isModEnabled("propal");
+$tabcond[22] = (!empty($conf->commande->enabled) || isModEnabled("propal"));
$tabcond[23] = true;
$tabcond[24] = !empty($conf->resource->enabled);
$tabcond[25] = !empty($conf->website->enabled);
-//$tabcond[26]= !empty($conf->product->enabled);
-$tabcond[27] = !empty($conf->societe->enabled);
+//$tabcond[26]= isModEnabled("product");
+$tabcond[27] = isModEnabled("societe");
$tabcond[28] = !empty($conf->holiday->enabled);
$tabcond[29] = !empty($conf->project->enabled);
$tabcond[30] = !empty($conf->label->enabled);
@@ -519,13 +519,13 @@ $tabcond[33] = !empty($conf->hrm->enabled);
$tabcond[34] = !empty($conf->hrm->enabled);
$tabcond[35] = !empty($conf->expensereport->enabled) && !empty($conf->global->MAIN_USE_EXPENSE_IK);
$tabcond[36] = !empty($conf->expensereport->enabled) && !empty($conf->global->MAIN_USE_EXPENSE_IK);
-$tabcond[37] = !empty($conf->product->enabled);
+$tabcond[37] = isModEnabled("product");
$tabcond[38] = !empty($conf->socialnetworks->enabled);
-$tabcond[39] = (!empty($conf->societe->enabled) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && !empty($conf->global->THIRDPARTY_ENABLE_PROSPECTION_ON_ALTERNATIVE_ADRESSES));
-$tabcond[40] = (!empty($conf->societe->enabled) && !empty($conf->global->THIRDPARTY_ENABLE_PROSPECTION_ON_ALTERNATIVE_ADRESSES));
+$tabcond[39] = (isModEnabled("societe") && empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && !empty($conf->global->THIRDPARTY_ENABLE_PROSPECTION_ON_ALTERNATIVE_ADRESSES));
+$tabcond[40] = (isModEnabled("societe") && !empty($conf->global->THIRDPARTY_ENABLE_PROSPECTION_ON_ALTERNATIVE_ADRESSES));
$tabcond[41] = !empty($conf->intracommreport->enabled);
-$tabcond[42] = !empty($conf->product->enabled);
-$tabcond[43] = !empty($conf->product->enabled) && !empty($conf->productbatch->enabled) && $conf->global->MAIN_FEATURES_LEVEL >= 2;
+$tabcond[42] = isModEnabled("product");
+$tabcond[43] = isModEnabled("product") && !empty($conf->productbatch->enabled) && $conf->global->MAIN_FEATURES_LEVEL >= 2;
$tabcond[44] = !empty($conf->asset->enabled);
// List of help for fields (no more used, help is defined into tabcomplete)
@@ -1220,14 +1220,16 @@ if ($id > 0) {
$sql .= natural_search("code_iso", $search_code);
} elseif ($search_code != '' && $id == 28) {
$sql .= natural_search("h.code", $search_code);
- } elseif ($search_code != '' && $id == 32) {
+ } elseif ($search_code != '' && ($id == 7 || $id == 32)) {
$sql .= natural_search("a.code", $search_code);
} elseif ($search_code != '' && $id == 3) {
$sql .= natural_search("r.code_region", $search_code);
- } elseif ($search_code != '' && $id == 7) {
- $sql .= natural_search("a.code", $search_code);
- } elseif ($search_code != '' && $id == 10) {
+ } elseif ($search_code != '' && ($id == 8 || $id == 10)) {
$sql .= natural_search("t.code", $search_code);
+ } elseif ($search_code != '' && $id == 1) {
+ $sql .= natural_search("f.code", $search_code);
+ } elseif ($search_code != '' && $id == 2) {
+ $sql .= natural_search("d.code_departement", $search_code);
} elseif ($search_code != '' && $id != 9) {
$sql .= natural_search("code", $search_code);
}
diff --git a/htdocs/admin/emailcollector_card.php b/htdocs/admin/emailcollector_card.php
index bc8267f9ef9..e41777da9d9 100644
--- a/htdocs/admin/emailcollector_card.php
+++ b/htdocs/admin/emailcollector_card.php
@@ -37,7 +37,7 @@ include_once DOL_DOCUMENT_ROOT.'/emailcollector/lib/emailcollector.lib.php';
if (!$user->admin) {
accessforbidden();
}
-if (empty($conf->emailcollector->enabled)) {
+if (!isModEnabled('emailcollector')) {
accessforbidden();
}
@@ -91,9 +91,9 @@ include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be includ
//$isdraft = (($object->statut == MyObject::STATUS_DRAFT) ? 1 : 0);
//$result = restrictedArea($user, 'mymodule', $object->id, '', '', 'fk_soc', 'rowid', $isdraft);
-$permissionnote = $user->rights->emailcollector->write; // Used by the include of actions_setnotes.inc.php
-$permissiondellink = $user->rights->emailcollector->write; // Used by the include of actions_dellink.inc.php
-$permissiontoadd = $user->rights->emailcollector->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
+$permissionnote = $user->admin; // Used by the include of actions_setnotes.inc.php
+$permissiondellink = $user->admin; // Used by the include of actions_dellink.inc.php
+$permissiontoadd = $user->admin; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
$debuginfo = '';
@@ -192,7 +192,7 @@ if ($action == 'updateoperation') {
$emailcollectoroperation = new EmailCollectorAction($db);
$emailcollectoroperation->fetch(GETPOST('rowidoperation2', 'int'));
- $emailcollectoroperation->actionparam = GETPOST('operationparam2', 'restricthtml');
+ $emailcollectoroperation->actionparam = GETPOST('operationparam2', 'alphawithlgt');
if (in_array($emailcollectoroperation->type, array('loadthirdparty', 'loadandcreatethirdparty'))
&& empty($emailcollectoroperation->actionparam)) {
@@ -337,14 +337,12 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
// Confirmation of action process
if ($action == 'collect') {
- $formquestion = array(
- 'text' => $langs->trans("EmailCollectorConfirmCollect"),
- );
- $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('EmailCollectorConfirmCollectTitle'), $text, 'confirm_collect', $formquestion, 0, 1, 220);
+ $formquestion = array();
+ $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('EmailCollectorConfirmCollectTitle'), $langs->trans('EmailCollectorConfirmCollect'), 'confirm_collect', $formquestion, 0, 1, 220);
}
// Call Hook formConfirm
- $parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid);
+ $parameters = array('formConfirm' => $formconfirm);
$reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
if (empty($reshook)) {
$formconfirm .= $hookmanager->resPrint;
@@ -549,20 +547,21 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
print '';
$arrayoftypes = array(
- 'loadthirdparty'=>$langs->trans('LoadThirdPartyFromName', $langs->transnoentities("ThirdPartyName")),
- 'loadandcreatethirdparty'=>$langs->trans('LoadThirdPartyFromNameOrCreate', $langs->transnoentities("ThirdPartyName")),
- 'recordjoinpiece'=>'AttachJoinedDocumentsToObject',
- 'recordevent'=>'RecordEvent');
+ 'loadthirdparty' => $langs->trans('LoadThirdPartyFromName', $langs->transnoentities("ThirdPartyName")),
+ 'loadandcreatethirdparty' => $langs->trans('LoadThirdPartyFromNameOrCreate', $langs->transnoentities("ThirdPartyName")),
+ 'recordjoinpiece' => 'AttachJoinedDocumentsToObject',
+ 'recordevent' => 'RecordEvent'
+ );
$arrayoftypesnocondition = $arrayoftypes;
- if (!empty($conf->project->enabled)) {
+ if (isModEnabled('project')) {
$arrayoftypes['project'] = 'CreateLeadAndThirdParty';
}
$arrayoftypesnocondition['project'] = 'CreateLeadAndThirdParty';
- if (!empty($conf->ticket->enabled)) {
+ if (isModEnabled('ticket')) {
$arrayoftypes['ticket'] = 'CreateTicketAndThirdParty';
}
$arrayoftypesnocondition['ticket'] = 'CreateTicketAndThirdParty';
- if (!empty($conf->recruitment->enabled)) {
+ if (isModEnabled('recruitment')) {
$arrayoftypes['candidature'] = 'CreateCandidature';
}
$arrayoftypesnocondition['candidature'] = 'CreateCandidature';
@@ -620,12 +619,12 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
print '';
print '';
if ($action == 'editoperation' && $ruleaction['id'] == $operationid) {
- print ' ';
+ print ' ';
print ' ';
print ' ';
print ' ';
} else {
- print $ruleaction['actionparam'];
+ print dol_escape_htmltag($ruleaction['actionparam']);
}
print ' ';
// Move up/down
@@ -679,7 +678,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
print '';
// Clone
- print '';
+ print '';
// Collect now
if (count($object->actions) > 0) {
diff --git a/htdocs/admin/emailcollector_list.php b/htdocs/admin/emailcollector_list.php
index 6a980642c5f..a41e57266aa 100644
--- a/htdocs/admin/emailcollector_list.php
+++ b/htdocs/admin/emailcollector_list.php
@@ -142,7 +142,7 @@ $permissiontodelete = $user->admin;
if (!$user->admin) {
accessforbidden();
}
-if (empty($conf->emailcollector->enabled)) {
+if (!isModEnabled('emailcollector')) {
accessforbidden('Module not enabled');
}
diff --git a/htdocs/admin/eventorganization.php b/htdocs/admin/eventorganization.php
index 05df4187130..40c86d79e13 100644
--- a/htdocs/admin/eventorganization.php
+++ b/htdocs/admin/eventorganization.php
@@ -228,14 +228,14 @@ if ($action == 'edit') {
if ($val['type'] == 'textarea') {
print '\n";
} elseif ($val['type']== 'html') {
require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php';
- $doleditor = new DolEditor($constname, $conf->global->{$constname}, '', 160, 'dolibarr_notes', '', false, false, $conf->fckeditor->enabled, ROWS_5, '90%');
+ $doleditor = new DolEditor($constname, getDolGlobalString($constname), '', 160, 'dolibarr_notes', '', false, false, $conf->fckeditor->enabled, ROWS_5, '90%');
$doleditor->Create();
} elseif ($val['type'] == 'yesno') {
- print $form->selectyesno($constname, $conf->global->{$constname}, 1);
+ print $form->selectyesno($constname, getDolGlobalString($constname), 1);
} elseif (preg_match('/emailtemplate:/', $val['type'])) {
include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php';
$formmail = new FormMail($db);
@@ -255,7 +255,7 @@ if ($action == 'edit') {
$arrayofmessagename[$modelmail->id] = $langs->trans(preg_replace('/\(|\)/', '', $modelmail->label)) . $moreonlabel;
}
}
- print $form->selectarray($constname, $arrayofmessagename, $conf->global->{$constname}, 'None', 0, 0, '', 0, 0, 0, '', '', 1);
+ print $form->selectarray($constname, $arrayofmessagename, getDolGlobalString($constname), 'None', 0, 0, '', 0, 0, 0, '', '', 1);
} elseif (preg_match('/category:/', $val['type'])) {
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
@@ -263,13 +263,13 @@ if ($action == 'edit') {
$tmp = explode(':', $val['type']);
print img_picto('', 'category', 'class="pictofixedwidth"');
- print $formother->select_categories($tmp[1], $conf->global->{$constname}, $constname, 0, $langs->trans('CustomersProspectsCategoriesShort'));
+ print $formother->select_categories($tmp[1], getDolGlobalString($constname), $constname, 0, $langs->trans('CustomersProspectsCategoriesShort'));
} elseif (preg_match('/thirdparty_type/', $val['type'])) {
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
$formcompany = new FormCompany($db);
- print $formcompany->selectProspectCustomerType($conf->global->{$constname}, $constname, 'customerorprospect', 'form', '', 1);
+ print $formcompany->selectProspectCustomerType(getDolGlobalString($constname), $constname, 'customerorprospect', 'form', '', 1);
} elseif ($val['type'] == 'securekey') {
- print ' ';
+ print ' ';
if (!empty($conf->use_javascript_ajax)) {
print ' '.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_token'.$constname.'" class="linkobject"');
}
@@ -278,12 +278,12 @@ if ($action == 'edit') {
include_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
print dolJSToSetRandomPassword($constname, 'generate_token'.$constname);
} elseif ($val['type'] == 'product') {
- if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) {
+ if (isModEnabled("product") || isModEnabled("service")) {
$selected = (empty($conf->global->$constname) ? '' : $conf->global->$constname);
$form->select_produits($selected, $constname, '', 0);
}
} else {
- print ' ';
+ print ' ';
}
print '';
}
@@ -309,28 +309,28 @@ if ($action == 'edit') {
print '';
if ($val['type'] == 'textarea') {
- print dol_nl2br($conf->global->{$constname});
+ print dol_nl2br(getDolGlobalString($constname));
} elseif ($val['type']== 'html') {
- print $conf->global->{$constname};
+ print getDolGlobalString($constname);
} elseif ($val['type'] == 'yesno') {
print ajax_constantonoff($constname);
} elseif (preg_match('/emailtemplate:/', $val['type'])) {
- if (!empty($conf->global->{$constname})) {
+ if (getDolGlobalString($constname)) {
include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php';
$formmail = new FormMail($db);
$tmp = explode(':', $val['type']);
- $template = $formmail->getEMailTemplate($db, $tmp[1], $user, $langs, $conf->global->{$constname});
+ $template = $formmail->getEMailTemplate($db, $tmp[1], $user, $langs, getDolGlobalString($constname));
if ($template < 0) {
setEventMessages(null, $formmail->errors, 'errors');
}
print $langs->trans($template->label);
}
} elseif (preg_match('/category:/', $val['type'])) {
- if (!empty($conf->global->{$constname})) {
+ if (getDolGlobalString($constname)) {
$c = new Categorie($db);
- $result = $c->fetch($conf->global->{$constname});
+ $result = $c->fetch(getDolGlobalString($constname));
if ($result < 0) {
setEventMessages(null, $c->errors, 'errors');
}
@@ -342,25 +342,25 @@ if ($action == 'edit') {
print '' . implode(' ', $toprint) . ' ';
}
} elseif (preg_match('/thirdparty_type/', $val['type'])) {
- if ($conf->global->{$constname}==2) {
+ if (getDolGlobalString($constname)==2) {
print $langs->trans("Prospect");
- } elseif ($conf->global->{$constname}==3) {
+ } elseif (getDolGlobalString($constname)==3) {
print $langs->trans("ProspectCustomer");
- } elseif ($conf->global->{$constname}==1) {
+ } elseif (getDolGlobalString($constname)==1) {
print $langs->trans("Customer");
- } elseif ($conf->global->{$constname}==0) {
+ } elseif (getDolGlobalString($constname)==0) {
print $langs->trans("NorProspectNorCustomer");
}
} elseif ($val['type'] == 'product') {
$product = new Product($db);
- $resprod = $product->fetch($conf->global->{$constname});
+ $resprod = $product->fetch(getDolGlobalString($constname));
if ($resprod > 0) {
print $product->getNomUrl(1);
} elseif ($resprod < 0) {
- setEventMessages(null, $object->errors, "errors");
+ setEventMessages($product->error, $product->errors, "errors");
}
} else {
- print $conf->global->{$constname};
+ print getDolGlobalString($constname);
}
print ' ';
}
diff --git a/htdocs/admin/expensereport.php b/htdocs/admin/expensereport.php
index 64cf24ca6fa..2418ec3e26c 100644
--- a/htdocs/admin/expensereport.php
+++ b/htdocs/admin/expensereport.php
@@ -6,7 +6,7 @@
* Copyright (C) 2005-2014 Regis Houssin
* Copyright (C) 2008 Raphael Bertrand (Resultic)
* Copyright (C) 2011-2013 Juanjo Menent
- * Copyright (C) 2011-2018 Philippe Grand
+ * Copyright (C) 2011-2022 Philippe Grand
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -148,7 +148,7 @@ if ($action == 'updateMask') {
$res2 = dolibarr_set_const($db, "EXPENSEREPORT_DRAFT_WATERMARK", trim($draft), 'chaine', 0, '', $conf->entity);
$res3 = 0;
- if (!empty($conf->project->enabled) && GETPOSTISSET('EXPENSEREPORT_PROJECT_IS_REQUIRED')) { // Option may not be provided
+ if (isModEnabled('project') && GETPOSTISSET('EXPENSEREPORT_PROJECT_IS_REQUIRED')) { // Option may not be provided
$res3 = dolibarr_set_const($db, 'EXPENSEREPORT_PROJECT_IS_REQUIRED', GETPOST('EXPENSEREPORT_PROJECT_IS_REQUIRED', 'int'), 'chaine', 0, '', $conf->entity);
}
@@ -471,7 +471,7 @@ print $form->textwithpicto($langs->trans("WatermarkOnDraftExpenseReports"), $htm
print ' ';
print ''."\n";
-if (!empty($conf->project->enabled)) {
+if (isModEnabled('project')) {
print '';
print $langs->trans('ProjectIsRequiredOnExpenseReports');
print ' ';
diff --git a/htdocs/admin/facture.php b/htdocs/admin/facture.php
index f866eef7802..4a8e54589e9 100644
--- a/htdocs/admin/facture.php
+++ b/htdocs/admin/facture.php
@@ -637,7 +637,7 @@ print " \n";
print '';
print "".$langs->trans("SuggestPaymentByRIBOnAccount")." ";
print "";
-if (!empty($conf->banque->enabled)) {
+if (isModEnabled('banque')) {
$sql = "SELECT rowid, label";
$sql .= " FROM ".MAIN_DB_PREFIX."bank_account";
$sql .= " WHERE clos = 0";
diff --git a/htdocs/admin/fckeditor.php b/htdocs/admin/fckeditor.php
index 3ea92bb48ad..04048ac83db 100644
--- a/htdocs/admin/fckeditor.php
+++ b/htdocs/admin/fckeditor.php
@@ -62,11 +62,11 @@ $conditions = array(
'NOTE_PUBLIC' => 1,
'NOTE_PRIVATE' => 1,
'SOCIETE' => 1,
- 'PRODUCTDESC' => (!empty($conf->product->enabled) || !empty($conf->service->enabled)),
- 'DETAILS' => (isModEnabled('facture') || !empty($conf->propal->enabled) || !empty($conf->commande->enabled) || !empty($conf->supplier_proposal->enabled) || (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)),
+ 'PRODUCTDESC' => (isModEnabled("product") || isModEnabled("service")),
+ 'DETAILS' => (isModEnabled('facture') || isModEnabled("propal") || !empty($conf->commande->enabled) || !empty($conf->supplier_proposal->enabled) || (isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")),
'USERSIGN' => 1,
'MAILING' => !empty($conf->mailing->enabled),
- 'MAIL' => (isModEnabled('facture') || !empty($conf->propal->enabled) || !empty($conf->commande->enabled)),
+ 'MAIL' => (isModEnabled('facture') || isModEnabled("propal") || !empty($conf->commande->enabled)),
'TICKET' => !empty($conf->ticket->enabled),
);
// Picto
diff --git a/htdocs/admin/geoipmaxmind.php b/htdocs/admin/geoipmaxmind.php
index e662c0576a2..c002c9059d7 100644
--- a/htdocs/admin/geoipmaxmind.php
+++ b/htdocs/admin/geoipmaxmind.php
@@ -59,12 +59,12 @@ if ($action == 'set') {
if (!$error) {
$res1 = dolibarr_set_const($db, "GEOIP_VERSION", GETPOST('geoipversion', 'aZ09'), 'chaine', 0, '', $conf->entity);
- if (!$res1 > 0) {
+ if (!($res1 > 0)) {
$error++;
}
$res2 = dolibarr_set_const($db, "GEOIPMAXMIND_COUNTRY_DATAFILE", $gimcdf, 'chaine', 0, '', $conf->entity);
- if (!$res2 > 0) {
+ if (!($res2 > 0)) {
$error++;
}
diff --git a/htdocs/admin/holiday.php b/htdocs/admin/holiday.php
index c3c58984dc0..5902402674d 100644
--- a/htdocs/admin/holiday.php
+++ b/htdocs/admin/holiday.php
@@ -141,7 +141,7 @@ if ($action == 'updateMask') {
$draft = GETPOST('HOLIDAY_DRAFT_WATERMARK', 'alpha');
$res2 = dolibarr_set_const($db, "HOLIDAY_DRAFT_WATERMARK", trim($draft), 'chaine', 0, '', $conf->entity);
- if (!$res1 > 0 || !$res2 > 0) {
+ if (!($res1 > 0) || !($res2 > 0)) {
$error++;
}
diff --git a/htdocs/admin/hrm.php b/htdocs/admin/hrm.php
index cfe40c006b7..c568e6de39c 100644
--- a/htdocs/admin/hrm.php
+++ b/htdocs/admin/hrm.php
@@ -492,14 +492,14 @@ if ($action == 'edit') {
print ' ';
if ($val['type'] == 'textarea') {
- print ' ';
}
diff --git a/htdocs/admin/knowledgemanagement.php b/htdocs/admin/knowledgemanagement.php
index 041216014b0..b1710a53839 100644
--- a/htdocs/admin/knowledgemanagement.php
+++ b/htdocs/admin/knowledgemanagement.php
@@ -208,12 +208,12 @@ if ($action == 'edit') {
print '';
if ($val['type'] == 'textarea') {
- print '' . "\n";
+ print '' . "\n";
print $conf->global->{$constname};
print " \n";
- } elseif ($val['type']== 'html') {
+ } elseif ($val['type'] == 'html') {
require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php';
- $doleditor = new DolEditor($constname, $conf->global->{$constname}, '', 160, 'dolibarr_notes', '', false, false, $conf->fckeditor->enabled, ROWS_5, '90%');
+ $doleditor = new DolEditor($constname, $conf->global->{$constname}, '', 160, 'dolibarr_notes', '', false, false, isModEnabled('fckeditor'), ROWS_5, '90%');
$doleditor->Create();
} elseif ($val['type'] == 'yesno') {
print $form->selectyesno($constname, $conf->global->{$constname}, 1);
diff --git a/htdocs/admin/ldap.php b/htdocs/admin/ldap.php
index ef488943a4b..568664b92b7 100644
--- a/htdocs/admin/ldap.php
+++ b/htdocs/admin/ldap.php
@@ -158,24 +158,24 @@ if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && empty($conf->global->LDAP_USER
print ' ';
// Synchro contact active
-if (!empty($conf->societe->enabled)) {
+if (isModEnabled('societe')) {
print ''.$langs->trans("LDAPDnContactActive").' ';
print $formldap->selectLdapDnSynchroActive(getDolGlobalInt('LDAP_CONTACT_ACTIVE'), 'activecontact', array(Ldap::SYNCHRO_LDAP_TO_DOLIBARR));
- print ' '.$langs->trans("LDAPDnContactActiveExample").' ';
+ print '' . $langs->trans("LDAPDnContactActiveExample") . ' ';
}
// Synchro member active
-if (!empty($conf->adherent->enabled)) {
- print ''.$langs->trans("LDAPDnMemberActive").' ';
+if (isModEnabled('adherent')) {
+ print ' ' . $langs->trans("LDAPDnMemberActive") . ' ';
print $formldap->selectLdapDnSynchroActive(getDolGlobalInt('LDAP_MEMBER_ACTIVE'), 'activemembers', array(), 2);
- print ' '.$langs->trans("LDAPDnMemberActiveExample").' ';
+ print '' . $langs->trans("LDAPDnMemberActiveExample") . ' ';
}
// Synchro member type active
-if (!empty($conf->adherent->enabled)) {
- print ''.$langs->trans("LDAPDnMemberTypeActive").' ';
+if (isModEnabled('adherent')) {
+ print ' ' . $langs->trans("LDAPDnMemberTypeActive") . ' ';
print $formldap->selectLdapDnSynchroActive(getDolGlobalInt('LDAP_MEMBER_TYPE_ACTIVE'), 'activememberstypes', array(), 2);
- print ' '.$langs->trans("LDAPDnMemberTypeActiveExample").' ';
+ print '' . $langs->trans("LDAPDnMemberTypeActiveExample") . ' ';
}
// Fields from hook
diff --git a/htdocs/admin/limits.php b/htdocs/admin/limits.php
index 1209f41c48e..d644f2bd2f6 100644
--- a/htdocs/admin/limits.php
+++ b/htdocs/admin/limits.php
@@ -36,7 +36,7 @@ if (!$user->admin) {
$action = GETPOST('action', 'aZ09');
$currencycode = GETPOST('currencycode', 'alpha');
-if (!empty($conf->multicurrency->enabled) && !empty($conf->global->MULTICURRENCY_USE_LIMIT_BY_CURRENCY)) {
+if (isModEnabled('multicompany') && !empty($conf->global->MULTICURRENCY_USE_LIMIT_BY_CURRENCY)) {
// When MULTICURRENCY_USE_LIMIT_BY_CURRENCY is on, we use always a defined currency code instead of '' even for default.
$currencycode = (!empty($currencycode) ? $currencycode : $conf->currency);
}
@@ -105,12 +105,12 @@ print load_fiche_titre($title, '', 'title_setup');
$aCurrencies = array($conf->currency); // Default currency always first position
-if (!empty($conf->multicurrency->enabled) && !empty($conf->global->MULTICURRENCY_USE_LIMIT_BY_CURRENCY)) {
- require_once DOL_DOCUMENT_ROOT.'/core/lib/multicurrency.lib.php';
+if (isModEnabled('multicompany') && !empty($conf->global->MULTICURRENCY_USE_LIMIT_BY_CURRENCY)) {
+ require_once DOL_DOCUMENT_ROOT . '/core/lib/multicurrency.lib.php';
- $sql = "SELECT rowid, code FROM ".MAIN_DB_PREFIX."multicurrency";
- $sql .= " WHERE entity = ".((int) $conf->entity);
- $sql .= " AND code <> '".$db->escape($conf->currency)."'"; // Default currency always first position
+ $sql = "SELECT rowid, code FROM " . MAIN_DB_PREFIX . "multicurrency";
+ $sql .= " WHERE entity = " . ((int) $conf->entity);
+ $sql .= " AND code <> '" . $db->escape($conf->currency) . "'"; // Default currency always first position
$resql = $db->query($sql);
if ($resql) {
while ($obj = $db->fetch_object($resql)) {
@@ -129,11 +129,11 @@ print ''.$langs->trans("LimitsDesc")." \n"
print " \n";
if ($action == 'edit') {
- print '';
- print ' ';
+ print ' ';
+ print ' ';
print ' ';
- if (!empty($conf->multicurrency->enabled) && !empty($conf->global->MULTICURRENCY_USE_LIMIT_BY_CURRENCY)) {
- print ' ';
+ if (isModEnabled('multicompany') && !empty($conf->global->MULTICURRENCY_USE_LIMIT_BY_CURRENCY)) {
+ print ' ';
}
clearstatcache();
@@ -194,7 +194,7 @@ if ($action == 'edit') {
print '';
}
-if (!empty($conf->multicurrency->enabled) && !empty($conf->global->MULTICURRENCY_USE_LIMIT_BY_CURRENCY)) {
+if (isModEnabled('multicompany') && !empty($conf->global->MULTICURRENCY_USE_LIMIT_BY_CURRENCY)) {
if (!empty($aCurrencies) && count($aCurrencies) > 1) {
print dol_get_fiche_end();
}
diff --git a/htdocs/admin/loan.php b/htdocs/admin/loan.php
index 72b2a15d678..3c777e1f187 100644
--- a/htdocs/admin/loan.php
+++ b/htdocs/admin/loan.php
@@ -26,7 +26,7 @@ require '../main.inc.php';
// Class
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
-if (!empty($conf->accounting->enabled)) {
+if (isModEnabled('accounting')) {
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
}
@@ -76,7 +76,7 @@ if ($action == 'update') {
llxHeader();
$form = new Form($db);
-if (!empty($conf->accounting->enabled)) {
+if (isModEnabled('accounting')) {
$formaccounting = new FormAccounting($db);
}
@@ -100,14 +100,14 @@ foreach ($list as $key) {
// Param
$label = $langs->trans($key);
- print ''.$label.' ';
+ print '' . $label . ' ';
// Value
print '';
- if (!empty($conf->accounting->enabled)) {
+ if (isModEnabled('accounting')) {
print $formaccounting->select_account(getDolGlobalString($key), $key, 1, '', 1, 1);
} else {
- print ' ';
+ print ' ';
}
print ' ';
}
diff --git a/htdocs/admin/mailman.php b/htdocs/admin/mailman.php
index 8b003ce2d4e..eca17ea8e76 100644
--- a/htdocs/admin/mailman.php
+++ b/htdocs/admin/mailman.php
@@ -158,7 +158,7 @@ if (!empty($conf->global->ADHERENT_USE_MAILMAN)) {
$link .= '';
// Edition des varibales globales
$constantes = array(
- 'ADHERENT_MAILMAN_ADMINPW',
+ 'ADHERENT_MAILMAN_ADMIN_PASSWORD',
'ADHERENT_MAILMAN_URL',
'ADHERENT_MAILMAN_UNSUB_URL',
'ADHERENT_MAILMAN_LISTS'
diff --git a/htdocs/admin/mails.php b/htdocs/admin/mails.php
index 67bf775bdd9..2f0f4cd3233 100644
--- a/htdocs/admin/mails.php
+++ b/htdocs/admin/mails.php
@@ -88,7 +88,15 @@ if ($action == 'update' && !$cancel) {
dolibarr_set_const($db, "MAIN_MAIL_SMTP_PORT", GETPOST("MAIN_MAIL_SMTP_PORT", 'int'), 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_MAIL_SMTP_SERVER", GETPOST("MAIN_MAIL_SMTP_SERVER", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_MAIL_SMTPS_ID", GETPOST("MAIN_MAIL_SMTPS_ID", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
- dolibarr_set_const($db, "MAIN_MAIL_SMTPS_PW", GETPOST("MAIN_MAIL_SMTPS_PW", 'none'), 'chaine', 0, '', $conf->entity);
+ if (GETPOSTISSET("MAIN_MAIL_SMTPS_PW")) {
+ dolibarr_set_const($db, "MAIN_MAIL_SMTPS_PW", GETPOST("MAIN_MAIL_SMTPS_PW", 'none'), 'chaine', 0, '', $conf->entity);
+ }
+ if (GETPOSTISSET("MAIN_MAIL_SMTPS_AUTH_TYPE")) {
+ dolibarr_set_const($db, "MAIN_MAIL_SMTPS_AUTH_TYPE", GETPOST("MAIN_MAIL_SMTPS_AUTH_TYPE", 'chaine'), 'chaine', 0, '', $conf->entity);
+ }
+ if (GETPOSTISSET("MAIN_MAIL_SMTPS_OAUTH_SERVICE")) {
+ dolibarr_set_const($db, "MAIN_MAIL_SMTPS_OAUTH_SERVICE", GETPOST("MAIN_MAIL_SMTPS_OAUTH_SERVICE", 'chaine'), 'chaine', 0, '', $conf->entity);
+ }
dolibarr_set_const($db, "MAIN_MAIL_EMAIL_TLS", GETPOST("MAIN_MAIL_EMAIL_TLS", 'int'), 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_MAIL_EMAIL_STARTTLS", GETPOST("MAIN_MAIL_EMAIL_STARTTLS", 'int'), 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED", GETPOST("MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED", 'int'), 'chaine', 0, '', $conf->entity);
@@ -171,6 +179,24 @@ if (version_compare(phpversion(), '7.0', '>=')) {
$listofmethods['swiftmailer'] = 'Swift Mailer socket library';
}
+// List of oauth services
+$oauthservices = array();
+
+foreach ($conf->global as $key => $val) {
+ if (!empty($val) && preg_match('/^OAUTH_.*_ID$/', $key)) {
+ $key = preg_replace('/^OAUTH_/', '', $key);
+ $key = preg_replace('/_ID$/', '', $key);
+ if (preg_match('/^.*-/', $key)) {
+ $name = preg_replace('/^.*-/', '', $key);
+ } else {
+ $name = $langs->trans("NoName");
+ }
+ $provider = preg_replace('/-.*$/', '', $key);
+ $provider = ucfirst(strtolower($provider));
+
+ $oauthservices[$key] = $name." (".$provider.")";
+ }
+}
if ($action == 'edit') {
if ($conf->use_javascript_ajax) {
@@ -195,6 +221,7 @@ if ($action == 'edit') {
jQuery("#MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").prop("disabled", true);
jQuery(".smtp_method").hide();
jQuery(".dkim").hide();
+ jQuery(".smtp_auth_method").hide();
';
if ($linuxlike) {
print '
@@ -234,9 +261,10 @@ if ($action == 'edit') {
jQuery("#MAIN_MAIL_SMTP_SERVER").show();
jQuery("#MAIN_MAIL_SMTP_PORT").show();
jQuery("#smtp_server_mess").hide();
- jQuery("#smtp_port_mess").hide();
+ jQuery("#smtp_port_mess").hide();
jQuery(".smtp_method").show();
- jQuery(".dkim").hide();
+ jQuery(".dkim").hide();
+ jQuery(".smtp_auth_method").show();
}
if (jQuery("#MAIN_MAIL_SENDMODE").val()==\'swiftmailer\')
{
@@ -262,14 +290,36 @@ if ($action == 'edit') {
jQuery("#MAIN_MAIL_SMTP_PORT").show();
jQuery("#smtp_server_mess").hide();
jQuery("#smtp_port_mess").hide();
- jQuery(".smtp_method").show();
+ jQuery(".smtp_method").show();
jQuery(".dkim").show();
+ jQuery(".smtp_auth_method").show();
}
}
+ function change_smtp_auth_method() {
+ console.log(jQuery("#radio_pw").prop("checked"));
+ if (jQuery("#MAIN_MAIL_SENDMODE").val()==\'smtps\' && jQuery("#radio_oauth").prop("checked")) {
+ jQuery(".smtp_oauth_service").show();
+ jQuery(".smtp_pw").hide();
+ } else if (jQuery("#MAIN_MAIL_SENDMODE").val()==\'swiftmailer\' && jQuery("#radio_oauth").prop("checked")) {
+ jQuery(".smtp_oauth_service").show();
+ jQuery(".smtp_pw").hide();
+ } else if(jQuery("#MAIN_MAIL_SENDMODE").val()==\'mail\'){
+ jQuery(".smtp_oauth_service").hide();
+ jQuery(".smtp_pw").hide();
+ } else {
+ jQuery(".smtp_oauth_service").hide();
+ jQuery(".smtp_pw").show();
+ }
+ }
initfields();
+ change_smtp_auth_method();
jQuery("#MAIN_MAIL_SENDMODE").change(function() {
initfields();
+ change_smtp_auth_method();
});
+ jQuery("#radio_pw, #radio_oauth").change(function() {
+ change_smtp_auth_method();
+ });
jQuery("#MAIN_MAIL_EMAIL_TLS").change(function() {
if (jQuery("#MAIN_MAIL_EMAIL_TLS").val() == 1)
jQuery("#MAIN_MAIL_EMAIL_STARTTLS").val(0);
@@ -354,7 +404,7 @@ if ($action == 'edit') {
}
print '';
// SuperAdministrator access only
- if (empty($conf->multicompany->enabled) || ($user->admin && !$user->entity)) {
+ if (!isModEnabled('multicompany') || ($user->admin && !$user->entity)) {
print ' ';
print ' ';
print ''.$langs->trans("SeeLocalSendMailSetup").' ';
@@ -385,7 +435,7 @@ if ($action == 'edit') {
}
print ' ';
// SuperAdministrator access only
- if (empty($conf->multicompany->enabled) || ($user->admin && !$user->entity)) {
+ if (!isModEnabled('multicompany') || ($user->admin && !$user->entity)) {
print ' ';
print ' ';
print ''.$langs->trans("SeeLocalSendMailSetup").' ';
@@ -403,7 +453,7 @@ if ($action == 'edit') {
$mainstmpid = (!empty($conf->global->MAIN_MAIL_SMTPS_ID) ? $conf->global->MAIN_MAIL_SMTPS_ID : '');
print ' '.$langs->trans("MAIN_MAIL_SMTPS_ID").' ';
// SuperAdministrator access only
- if (empty($conf->multicompany->enabled) || ($user->admin && !$user->entity)) {
+ if (!isModEnabled('multicompany') || ($user->admin && !$user->entity)) {
print ' ';
} else {
$htmltext = $langs->trans("ContactSuperAdminForChange");
@@ -413,14 +463,33 @@ if ($action == 'edit') {
print ' ';
}
+
+ // OAUTH
+ if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('smtps', 'swiftmailer')))) {
+ print ''.$langs->trans("MAIN_MAIL_SMTPS_AUTH_TYPE").' ';
+ if (!isModEnabled('multicompany') || ($user->admin && !$user->entity)) {
+ print ' ';
+ print ''.$langs->trans("UsePassword").' ';
+ print ' ';
+ print ' ';
+ print ''.$form->textwithpicto($langs->trans("UseOauth"), $langs->trans("OauthNotAvailableForAllAndHadToBeCreatedBefore")).' ';
+ } else {
+ $value = getDolGlobalString('MAIN_MAIL_SMTPS_AUTH_TYPE', 'LOGIN');
+ $htmltext = $langs->trans("ContactSuperAdminForChange");
+ print $form->textwithpicto($langs->trans("MAIN_MAIL_SMTPS_AUTH_TYPE"), $htmltext, 1, 'superadmin');
+ print ' ';
+ }
+ print ' ';
+ }
+
// PW
if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('smtps', 'swiftmailer')))) {
$mainsmtppw = (!empty($conf->global->MAIN_MAIL_SMTPS_PW) ? $conf->global->MAIN_MAIL_SMTPS_PW : '');
- print '';
+ print ' ';
print $form->textwithpicto($langs->trans("MAIN_MAIL_SMTPS_PW"), $langs->trans("WithGMailYouCanCreateADedicatedPassword"));
print ' ';
// SuperAdministrator access only
- if (empty($conf->multicompany->enabled) || ($user->admin && !$user->entity)) {
+ if (!isModEnabled('multicompany') || ($user->admin && !$user->entity)) {
print ' ';
} else {
$htmltext = $langs->trans("ContactSuperAdminForChange");
@@ -430,6 +499,24 @@ if ($action == 'edit') {
print ' ';
}
+ // OAUTH service provider
+ if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('smtps', 'swiftmailer')))) {
+ print ''.$langs->trans("MAIN_MAIL_SMTPS_OAUTH_SERVICE").' ';
+
+ // SuperAdministrator access only
+ if ((empty($conf->global->MAIN_MODULE_MULTICOMPANY)) || ($user->admin && !$user->entity)) {
+ print $form->selectarray('MAIN_MAIL_SMTPS_OAUTH_SERVICE', $oauthservices, $conf->global->MAIN_MAIL_SMTPS_OAUTH_SERVICE);
+ } else {
+ $text = $oauthservices[$conf->global->MAIN_MAIL_SMTPS_OAUTH_SERVICE];
+ if (empty($text)) {
+ $text = $langs->trans("Undefined");
+ }
+ $htmltext = $langs->trans("ContactSuperAdminForChange");
+ print $form->textwithpicto($text, $htmltext, 1, 'superadmin');
+ print ' ';
+ }
+ print ' ';
+ }
// TLS
print ''.$langs->trans("MAIN_MAIL_EMAIL_TLS").' ';
if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('smtps', 'swiftmailer')))) {
@@ -595,29 +682,46 @@ if ($action == 'edit') {
print ' ';
// Host server
- if ($linuxlike && (isset($conf->global->MAIN_MAIL_SENDMODE) && $conf->global->MAIN_MAIL_SENDMODE == 'mail')) {
+ if ($linuxlike && (getDolGlobalString('MAIN_MAIL_SENDMODE') == 'mail')) {
print ''.$langs->trans("MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike").' '.$langs->trans("SeeLocalSendMailSetup").' ';
} else {
print ''.$langs->trans("MAIN_MAIL_SMTP_SERVER", ini_get('SMTP') ?ini_get('SMTP') : $langs->transnoentities("Undefined")).' '.(!empty($conf->global->MAIN_MAIL_SMTP_SERVER) ? $conf->global->MAIN_MAIL_SMTP_SERVER : '').' ';
}
+
// Port
- if ($linuxlike && (isset($conf->global->MAIN_MAIL_SENDMODE) && $conf->global->MAIN_MAIL_SENDMODE == 'mail')) {
+ if ($linuxlike && (getDolGlobalString('MAIN_MAIL_SENDMODE') == 'mail')) {
print ''.$langs->trans("MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike").' '.$langs->trans("SeeLocalSendMailSetup").' ';
} else {
print ''.$langs->trans("MAIN_MAIL_SMTP_PORT", ini_get('smtp_port') ?ini_get('smtp_port') : $langs->transnoentities("Undefined")).' '.(!empty($conf->global->MAIN_MAIL_SMTP_PORT) ? $conf->global->MAIN_MAIL_SMTP_PORT : '').' ';
}
// SMTPS ID
- if (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('smtps', 'swiftmailer'))) {
+ if (in_array(getDolGlobalString('MAIN_MAIL_SENDMODE'), array('smtps', 'swiftmailer'))) {
print ''.$langs->trans("MAIN_MAIL_SMTPS_ID").' '.$conf->global->MAIN_MAIL_SMTPS_ID.' ';
}
+ // AUTH method
+ if (in_array(getDolGlobalString('MAIN_MAIL_SENDMODE'), array('smtps', 'swiftmailer'))) {
+ $authtype = getDolGlobalString('MAIN_MAIL_SMTPS_AUTH_TYPE', 'LOGIN');
+ $text = ($authtype === "LOGIN") ? $langs->trans("UsePassword") : ($authtype === "XOAUTH2" ? $langs->trans("UseOauth") : '') ;
+ print ''.$langs->trans("MAIN_MAIL_SMTPS_AUTH_TYPE").' '.$text.' ';
+ }
+
// SMTPS PW
- if (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('smtps', 'swiftmailer'))) {
+ if (in_array(getDolGlobalString('MAIN_MAIL_SENDMODE'), array('smtps', 'swiftmailer')) && getDolGlobalString('MAIN_MAIL_SMTPS_AUTH_TYPE') != "XOAUTH2") {
print ''.$langs->trans("MAIN_MAIL_SMTPS_PW").' '.preg_replace('/./', '*', $conf->global->MAIN_MAIL_SMTPS_PW).' ';
}
+ // SMTPS oauth service
+ if (in_array(getDolGlobalString('MAIN_MAIL_SENDMODE'), array('smtps', 'swiftmailer')) && getDolGlobalString('MAIN_MAIL_SMTPS_AUTH_TYPE') === "XOAUTH2") {
+ $text = $oauthservices[$conf->global->MAIN_MAIL_SMTPS_OAUTH_SERVICE];
+ if (empty($text)) {
+ $text = $langs->trans("Undefined").img_warning();
+ }
+ print ''.$langs->trans("MAIN_MAIL_SMTPS_OAUTH_SERVICE").' '.$text.' ';
+ }
+
// TLS
print ''.$langs->trans("MAIN_MAIL_EMAIL_TLS").' ';
if (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('smtps', 'swiftmailer'))) {
@@ -807,7 +911,7 @@ if ($action == 'edit') {
print ''.$langs->trans("DoTestSend").' ';
- if (!empty($conf->fckeditor->enabled)) {
+ if (isModEnabled('fckeditor')) {
print ''.$langs->trans("DoTestSendHTML").' ';
}
}
diff --git a/htdocs/admin/mails_emailing.php b/htdocs/admin/mails_emailing.php
index 79ddda792e0..dbdf66f8282 100644
--- a/htdocs/admin/mails_emailing.php
+++ b/htdocs/admin/mails_emailing.php
@@ -71,7 +71,15 @@ if ($action == 'update' && !$cancel) {
dolibarr_set_const($db, "MAIN_MAIL_SMTP_PORT_EMAILING", GETPOST("MAIN_MAIL_SMTP_PORT_EMAILING"), 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_MAIL_SMTP_SERVER_EMAILING", GETPOST("MAIN_MAIL_SMTP_SERVER_EMAILING"), 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_MAIL_SMTPS_ID_EMAILING", GETPOST("MAIN_MAIL_SMTPS_ID_EMAILING"), 'chaine', 0, '', $conf->entity);
- dolibarr_set_const($db, "MAIN_MAIL_SMTPS_PW_EMAILING", GETPOST("MAIN_MAIL_SMTPS_PW_EMAILING"), 'chaine', 0, '', $conf->entity);
+ if (GETPOSTISSET("MAIN_MAIL_SMTPS_PW_EMAILING")) {
+ dolibarr_set_const($db, "MAIN_MAIL_SMTPS_PW_EMAILING", GETPOST("MAIN_MAIL_SMTPS_PW_EMAILING", 'none'), 'chaine', 0, '', $conf->entity);
+ }
+ if (GETPOSTISSET("MAIN_MAIL_SMTPS_AUTH_TYPE_EMAILING")) {
+ dolibarr_set_const($db, "MAIN_MAIL_SMTPS_AUTH_TYPE_EMAILING", GETPOST("MAIN_MAIL_SMTPS_AUTH_TYPE_EMAILING", 'chaine'), 'chaine', 0, '', $conf->entity);
+ }
+ if (GETPOSTISSET("MAIN_MAIL_SMTPS_OAUTH_SERVICE_EMAILING")) {
+ dolibarr_set_const($db, "MAIN_MAIL_SMTPS_OAUTH_SERVICE_EMAILING", GETPOST("MAIN_MAIL_SMTPS_OAUTH_SERVICE_EMAILING", 'chaine'), 'chaine', 0, '', $conf->entity);
+ }
dolibarr_set_const($db, "MAIN_MAIL_EMAIL_TLS_EMAILING", GETPOST("MAIN_MAIL_EMAIL_TLS_EMAILING"), 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_MAIL_EMAIL_STARTTLS_EMAILING", GETPOST("MAIN_MAIL_EMAIL_STARTTLS_EMAILING"), 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING", GETPOST("MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING"), 'chaine', 0, '', $conf->entity);
@@ -145,6 +153,24 @@ if (version_compare(phpversion(), '7.0', '>=')) {
$listofmethods['swiftmailer'] = 'Swift Mailer socket library';
}
+// List of oauth services
+$oauthservices = array();
+
+foreach ($conf->global as $key => $val) {
+ if (!empty($val) && preg_match('/^OAUTH_.*_ID$/', $key)) {
+ $key = preg_replace('/^OAUTH_/', '', $key);
+ $key = preg_replace('/_ID$/', '', $key);
+ if (preg_match('/^.*-/', $key)) {
+ $name = preg_replace('/^.*-/', '', $key);
+ } else {
+ $name = $langs->trans("NoName");
+ }
+ $provider = preg_replace('/-.*$/', '', $key);
+ $provider = ucfirst(strtolower($provider));
+
+ $oauthservices[$key] = $name." (".$provider.")";
+ }
+}
if ($action == 'edit') {
if ($conf->use_javascript_ajax) {
@@ -170,6 +196,8 @@ if ($action == 'edit') {
jQuery("#MAIN_MAIL_EMAIL_STARTTLS_EMAILING").prop("disabled", true);
jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING").val(0);
jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING").prop("disabled", true);
+ jQuery(".smtp_method").hide();
+ jQuery(".smtp_auth_method").hide();
';
if ($linuxlike) {
print '
@@ -201,9 +229,11 @@ if ($action == 'edit') {
jQuery("#MAIN_MAIL_SMTP_PORT_EMAILING").removeAttr("disabled");
jQuery("#MAIN_MAIL_SMTP_SERVER_EMAILING").show();
jQuery("#MAIN_MAIL_SMTP_PORT_EMAILING").show();
+ jQuery("#smtp_port_mess").hide();
jQuery("#smtp_server_mess").hide();
- jQuery("#smtp_port_mess").hide();
- }
+ jQuery(".smtp_method").show();
+ jQuery(".smtp_auth_method").show();
+ }
if (jQuery("#MAIN_MAIL_SENDMODE_EMAILING").val()==\'swiftmailer\')
{
jQuery(".drag").show();
@@ -219,12 +249,35 @@ if ($action == 'edit') {
jQuery("#MAIN_MAIL_SMTP_PORT_EMAILING").show();
jQuery("#smtp_server_mess").hide();
jQuery("#smtp_port_mess").hide();
+ jQuery(".smtp_method").show();
+ jQuery(".smtp_auth_method").show();
}
}
+ function change_smtp_auth_method() {
+ console.log(jQuery("#radio_pw").prop("checked"));
+ if (jQuery("#MAIN_MAIL_SENDMODE_EMAILING").val()==\'smtps\' && jQuery("#radio_oauth").prop("checked")) {
+ jQuery(".smtp_oauth_service").show();
+ jQuery(".smtp_pw").hide();
+ } else if (jQuery("#MAIN_MAIL_SENDMODE_EMAILING").val()==\'swiftmailer\' && jQuery("#radio_oauth").prop("checked")) {
+ jQuery(".smtp_oauth_service").show();
+ jQuery(".smtp_pw").hide();
+ } else if(jQuery("#MAIN_MAIL_SENDMODE_EMAILING").val()==\'mail\' || jQuery("#MAIN_MAIL_SENDMODE_EMAILING").val()==\'default\'){
+ jQuery(".smtp_oauth_service").hide();
+ jQuery(".smtp_pw").hide();
+ } else {
+ jQuery(".smtp_oauth_service").hide();
+ jQuery(".smtp_pw").show();
+ }
+ }
initfields();
- jQuery("#MAIN_MAIL_SENDMODE_EMAILING").change(function() {
+ change_smtp_auth_method();
+ jQuery("#MAIN_MAIL_SENDMODE_EMAILING").change(function() {
initfields();
- });
+ change_smtp_auth_method();
+ });
+ jQuery("#radio_pw, #radio_oauth").change(function() {
+ change_smtp_auth_method();
+ });
jQuery("#MAIN_MAIL_EMAIL_TLS_EMAILING").change(function() {
if (jQuery("#MAIN_MAIL_EMAIL_TLS_EMAILING").val() == 1)
jQuery("#MAIN_MAIL_EMAIL_STARTTLS_EMAILING").val(0);
@@ -237,7 +290,7 @@ if ($action == 'edit') {
else
jQuery("#MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_EMAILING").val(0);
});
- })';
+ })';
print ''."\n";
}
@@ -294,16 +347,16 @@ if ($action == 'edit') {
}
print ' ';
// SuperAdministrator access only
- if (empty($conf->multicompany->enabled) || ($user->admin && !$user->entity)) {
- print ' ';
- print ' ';
- print ''.$langs->trans("SeeLocalSendMailSetup").' ';
- print ' '.$langs->trans("SeeLinkToOnlineDocumentation").' ';
+ if (!isModEnabled('multicompany') || ($user->admin && !$user->entity)) {
+ print ' ';
+ print ' ';
+ print '' . $langs->trans("SeeLocalSendMailSetup") . ' ';
+ print ' ' . $langs->trans("SeeLinkToOnlineDocumentation") . ' ';
} else {
$text = !empty($mainserver) ? $mainserver : $smtpserver;
$htmltext = $langs->trans("ContactSuperAdminForChange");
print $form->textwithpicto($text, $htmltext, 1, 'superadmin');
- print ' ';
+ print ' ';
}
print ' ';
}
@@ -326,15 +379,15 @@ if ($action == 'edit') {
}
print '';
// SuperAdministrator access only
- if (empty($conf->multicompany->enabled) || ($user->admin && !$user->entity)) {
- print ' ';
- print ' ';
- print ''.$langs->trans("SeeLocalSendMailSetup").' ';
+ if (!isModEnabled('multicompany') || ($user->admin && !$user->entity)) {
+ print ' ';
+ print ' ';
+ print '' . $langs->trans("SeeLocalSendMailSetup") . ' ';
} else {
$text = (!empty($mainport) ? $mainport : $smtpport);
$htmltext = $langs->trans("ContactSuperAdminForChange");
print $form->textwithpicto($text, $htmltext, 1, 'superadmin');
- print ' ';
+ print ' ';
}
}
print ' ';
@@ -342,14 +395,32 @@ if ($action == 'edit') {
// ID
if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array('smtps', 'swiftmailer')))) {
$mainstmpid = (!empty($conf->global->MAIN_MAIL_SMTPS_ID_EMAILING) ? $conf->global->MAIN_MAIL_SMTPS_ID_EMAILING : '');
- print ''.$langs->trans("MAIN_MAIL_SMTPS_ID").' ';
+ print ' ' . $langs->trans("MAIN_MAIL_SMTPS_ID") . ' ';
// SuperAdministrator access only
- if (empty($conf->multicompany->enabled) || ($user->admin && !$user->entity)) {
- print ' ';
+ if (!isModEnabled('multicompany') || ($user->admin && !$user->entity)) {
+ print ' ';
} else {
$htmltext = $langs->trans("ContactSuperAdminForChange");
print $form->textwithpicto($conf->global->MAIN_MAIL_SMTPS_ID_EMAILING, $htmltext, 1, 'superadmin');
- print ' ';
+ print ' ';
+ }
+ print ' ';
+ }
+
+ // OAUTH
+ if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array('smtps', 'swiftmailer')))) {
+ print ''.$langs->trans("MAIN_MAIL_SMTPS_AUTH_TYPE").' ';
+ if (empty($conf->multicompany->enabled) || ($user->admin && !$user->entity)) {
+ print ' ';
+ print ''.$langs->trans("UsePassword").' ';
+ print ' ';
+ print ' ';
+ print ''.$form->textwithpicto($langs->trans("UseOauth"), $langs->trans("OauthNotAvailableForAllAndHadToBeCreatedBefore")).' ';
+ } else {
+ $value = getDolGlobalString('MAIN_MAIL_SMTPS_AUTH_TYPE_EMAILING', 'LOGIN');
+ $htmltext = $langs->trans("ContactSuperAdminForChange");
+ print $form->textwithpicto($langs->trans("MAIN_MAIL_SMTPS_AUTH_TYPE"), $htmltext, 1, 'superadmin');
+ print ' ';
}
print ' ';
}
@@ -357,18 +428,38 @@ if ($action == 'edit') {
// PW
if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array('smtps', 'swiftmailer')))) {
$mainsmtppw = (!empty($conf->global->MAIN_MAIL_SMTPS_PW_EMAILING) ? $conf->global->MAIN_MAIL_SMTPS_PW_EMAILING : '');
- print ''.$langs->trans("MAIN_MAIL_SMTPS_PW").' ';
+ print ' ' . $langs->trans("MAIN_MAIL_SMTPS_PW") . ' ';
// SuperAdministrator access only
- if (empty($conf->multicompany->enabled) || ($user->admin && !$user->entity)) {
- print ' ';
+ if (!isModEnabled('multicompany') || ($user->admin && !$user->entity)) {
+ print ' ';
} else {
$htmltext = $langs->trans("ContactSuperAdminForChange");
print $form->textwithpicto($conf->global->MAIN_MAIL_SMTPS_PW_EMAILING, $htmltext, 1, 'superadmin');
- print ' ';
+ print ' ';
}
print ' ';
}
+ // OAUTH service provider
+ if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array('smtps', 'swiftmailer')))) {
+ print ''.$langs->trans("MAIN_MAIL_SMTPS_OAUTH_SERVICE").' ';
+
+ // SuperAdministrator access only
+ if ((empty($conf->global->MAIN_MODULE_MULTICOMPANY)) || ($user->admin && !$user->entity)) {
+ print $form->selectarray('MAIN_MAIL_SMTPS_OAUTH_SERVICE_EMAILING', $oauthservices, $conf->global->MAIN_MAIL_SMTPS_OAUTH_SERVICE_EMAILING);
+ } else {
+ $text = $oauthservices[$conf->global->MAIN_MAIL_SMTPS_OAUTH_SERVICE_EMAILING];
+ if (empty($text)) {
+ $text = $langs->trans("Undefined");
+ }
+ $htmltext = $langs->trans("ContactSuperAdminForChange");
+ print $form->textwithpicto($text, $htmltext, 1, 'superadmin');
+ print ' ';
+ }
+ print ' ';
+ }
+
+
// TLS
print ''.$langs->trans("MAIN_MAIL_EMAIL_TLS").' ';
if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array('smtps', 'swiftmailer')))) {
@@ -458,11 +549,28 @@ if ($action == 'edit') {
print ' '.$langs->trans("MAIN_MAIL_SMTPS_ID").' '.getDolGlobalString('MAIN_MAIL_SMTPS_ID_EMAILING').' ';
}
+ // AUTH method
+ if (in_array(getDolGlobalString('MAIN_MAIL_SENDMODE_EMAILING'), array('smtps', 'swiftmailer'))) {
+ $authtype = getDolGlobalString('MAIN_MAIL_SMTPS_AUTH_TYPE_EMAILING', 'LOGIN');
+ $text = ($authtype === "LOGIN") ? $langs->trans("UsePassword") : ($authtype === "XOAUTH2" ? $langs->trans("UseOauth") : '') ;
+ print ''.$langs->trans("MAIN_MAIL_SMTPS_AUTH_TYPE").' '.$text.' ';
+ }
+
// SMTPS PW
- if (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array('smtps', 'swiftmailer'))) {
+ if (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array('smtps', 'swiftmailer')) && getDolGlobalString('MAIN_MAIL_SMTPS_AUTH_TYPE_EMAILING') != "XOAUTH2") {
print ''.$langs->trans("MAIN_MAIL_SMTPS_PW").' '.preg_replace('/./', '*', getDolGlobalString('MAIN_MAIL_SMTPS_PW_EMAILING')).' ';
}
+ // SMTPS oauth service
+ if (in_array(getDolGlobalString('MAIN_MAIL_SENDMODE_EMAILING'), array('smtps', 'swiftmailer')) && getDolGlobalString('MAIN_MAIL_SMTPS_AUTH_TYPE_EMAILING') === "XOAUTH2") {
+ $text = $oauthservices[$conf->global->MAIN_MAIL_SMTPS_OAUTH_SERVICE_EMAILING];
+ if (empty($text)) {
+ $text = $langs->trans("Undefined").img_warning();
+ }
+ print ''.$langs->trans("MAIN_MAIL_SMTPS_OAUTH_SERVICE_EMAILING").' '.$text.' ';
+ }
+
+
// TLS
print ''.$langs->trans("MAIN_MAIL_EMAIL_TLS").' ';
if (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array('smtps', 'swiftmailer'))) {
@@ -533,16 +641,16 @@ if ($action == 'edit') {
if (!empty($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && $conf->global->MAIN_MAIL_SENDMODE_EMAILING != 'default') {
if ($conf->global->MAIN_MAIL_SENDMODE_EMAILING != 'mail' || !$linuxlike) {
if (function_exists('fsockopen') && $port && $server) {
- print ''.$langs->trans("DoTestServerAvailability").' ';
+ print '' . $langs->trans("DoTestServerAvailability") . ' ';
}
} else {
- print ''.$langs->trans("DoTestServerAvailability").' ';
+ print '' . $langs->trans("DoTestServerAvailability") . ' ';
}
- print ''.$langs->trans("DoTestSend").' ';
+ print '' . $langs->trans("DoTestSend") . ' ';
- if (!empty($conf->fckeditor->enabled)) {
- print ''.$langs->trans("DoTestSendHTML").' ';
+ if (isModEnabled('fckeditor')) {
+ print '' . $langs->trans("DoTestSendHTML") . ' ';
}
}
diff --git a/htdocs/admin/mails_senderprofile_list.php b/htdocs/admin/mails_senderprofile_list.php
index 8e31d0e6d62..db92c33a7fb 100644
--- a/htdocs/admin/mails_senderprofile_list.php
+++ b/htdocs/admin/mails_senderprofile_list.php
@@ -557,6 +557,7 @@ if (!empty($extrafields->attributes[$object->table_element]['computed']) && is_a
// --------------------------------------------------------------------
$i = 0;
$totalarray = array();
+$totalarray['nbfield'] = 0;
while ($i < ($limit ? min($num, $limit) : $num)) {
$obj = $db->fetch_object($resql);
if (empty($obj)) {
diff --git a/htdocs/admin/mails_templates.php b/htdocs/admin/mails_templates.php
index 6d461b525bc..7f60b2260d7 100644
--- a/htdocs/admin/mails_templates.php
+++ b/htdocs/admin/mails_templates.php
@@ -178,63 +178,63 @@ $elementList = array();
$elementList['all'] = '-- '.dol_escape_htmltag($langs->trans("All")).' --';
$elementList['none'] = '-- '.dol_escape_htmltag($langs->trans("None")).' --';
-$elementList['user'] = img_picto('', 'user', 'class="paddingright"').dol_escape_htmltag($langs->trans('MailToUser'));
+$elementList['user'] = img_picto('', 'user', 'class="pictofixedwidth"').dol_escape_htmltag($langs->trans('MailToUser'));
if (!empty($conf->adherent->enabled) && !empty($user->rights->adherent->lire)) {
- $elementList['member'] = img_picto('', 'object_member', 'class="paddingright"').dol_escape_htmltag($langs->trans('MailToMember'));
+ $elementList['member'] = img_picto('', 'object_member', 'class="pictofixedwidth"').dol_escape_htmltag($langs->trans('MailToMember'));
}
if (!empty($conf->recruitment->enabled) && !empty($user->rights->recruitment->recruitmentjobposition->read)) {
- $elementList['recruitmentcandidature_send'] = img_picto('', 'recruitmentcandidature', 'class="paddingright"').dol_escape_htmltag($langs->trans('RecruitmentCandidatures'));
+ $elementList['recruitmentcandidature_send'] = img_picto('', 'recruitmentcandidature', 'class="pictofixedwidth"').dol_escape_htmltag($langs->trans('RecruitmentCandidatures'));
}
-if (!empty($conf->societe->enabled) && !empty($user->rights->societe->lire)) {
- $elementList['thirdparty'] = img_picto('', 'company', 'class="paddingright"').dol_escape_htmltag($langs->trans('MailToThirdparty'));
+if (isModEnabled("societe") && !empty($user->rights->societe->lire)) {
+ $elementList['thirdparty'] = img_picto('', 'company', 'class="pictofixedwidth"').dol_escape_htmltag($langs->trans('MailToThirdparty'));
}
if (!empty($conf->project->enabled)) {
- $elementList['project'] = img_picto('', 'project', 'class="paddingright"').dol_escape_htmltag($langs->trans('MailToProject'));
+ $elementList['project'] = img_picto('', 'project', 'class="pictofixedwidth"').dol_escape_htmltag($langs->trans('MailToProject'));
}
-if (!empty($conf->propal->enabled) && !empty($user->rights->propal->lire)) {
- $elementList['propal_send'] = img_picto('', 'propal', 'class="paddingright"').dol_escape_htmltag($langs->trans('MailToSendProposal'));
+if (isModEnabled("propal") && !empty($user->rights->propal->lire)) {
+ $elementList['propal_send'] = img_picto('', 'propal', 'class="pictofixedwidth"').dol_escape_htmltag($langs->trans('MailToSendProposal'));
}
if (!empty($conf->commande->enabled) && !empty($user->rights->commande->lire)) {
- $elementList['order_send'] = img_picto('', 'order', 'class="paddingright"').dol_escape_htmltag($langs->trans('MailToSendOrder'));
+ $elementList['order_send'] = img_picto('', 'order', 'class="pictofixedwidth"').dol_escape_htmltag($langs->trans('MailToSendOrder'));
}
if (isModEnabled('facture') && !empty($user->rights->facture->lire)) {
- $elementList['facture_send'] = img_picto('', 'bill', 'class="paddingright"').dol_escape_htmltag($langs->trans('MailToSendInvoice'));
+ $elementList['facture_send'] = img_picto('', 'bill', 'class="pictofixedwidth"').dol_escape_htmltag($langs->trans('MailToSendInvoice'));
}
-if (!empty($conf->expedition->enabled)) {
- $elementList['shipping_send'] = img_picto('', 'dolly', 'class="paddingright"').dol_escape_htmltag($langs->trans('MailToSendShipment'));
+if (isModEnabled("expedition")) {
+ $elementList['shipping_send'] = img_picto('', 'dolly', 'class="pictofixedwidth"').dol_escape_htmltag($langs->trans('MailToSendShipment'));
}
-if (!empty($conf->reception->enabled)) {
- $elementList['reception_send'] = img_picto('', 'dollyrevert', 'class="paddingright"').dol_escape_htmltag($langs->trans('MailToSendReception'));
+if (isModEnabled("reception")) {
+ $elementList['reception_send'] = img_picto('', 'dollyrevert', 'class="pictofixedwidth"').dol_escape_htmltag($langs->trans('MailToSendReception'));
}
if (!empty($conf->ficheinter->enabled)) {
- $elementList['fichinter_send'] = img_picto('', 'intervention', 'class="paddingright"').dol_escape_htmltag($langs->trans('MailToSendIntervention'));
+ $elementList['fichinter_send'] = img_picto('', 'intervention', 'class="pictofixedwidth"').dol_escape_htmltag($langs->trans('MailToSendIntervention'));
}
if (!empty($conf->supplier_proposal->enabled)) {
- $elementList['supplier_proposal_send'] = img_picto('', 'propal', 'class="paddingright"').dol_escape_htmltag($langs->trans('MailToSendSupplierRequestForQuotation'));
+ $elementList['supplier_proposal_send'] = img_picto('', 'propal', 'class="pictofixedwidth"').dol_escape_htmltag($langs->trans('MailToSendSupplierRequestForQuotation'));
}
-if ((!empty($conf->fournisseur->enabled) && !empty($user->rights->fournisseur->commande->lire) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || (!empty($conf->supplier_order->enabled) && !empty($user->rights->supplier_order->lire))) {
- $elementList['order_supplier_send'] = img_picto('', 'order', 'class="paddingright"').dol_escape_htmltag($langs->trans('MailToSendSupplierOrder'));
+if ((isModEnabled("fournisseur") && !empty($user->rights->fournisseur->commande->lire) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || (isModEnabled("supplier_order") && !empty($user->rights->supplier_order->lire))) {
+ $elementList['order_supplier_send'] = img_picto('', 'order', 'class="pictofixedwidth"').dol_escape_htmltag($langs->trans('MailToSendSupplierOrder'));
}
-if ((!empty($conf->fournisseur->enabled) && !empty($user->rights->fournisseur->facture->lire) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || (!empty($conf->supplier_invoice->enabled) && !empty($user->rights->supplier_invoice->lire))) {
- $elementList['invoice_supplier_send'] = img_picto('', 'bill', 'class="paddingright"').dol_escape_htmltag($langs->trans('MailToSendSupplierInvoice'));
+if ((isModEnabled("fournisseur") && !empty($user->rights->fournisseur->facture->lire) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || (isModEnabled("supplier_invoice") && !empty($user->rights->supplier_invoice->lire))) {
+ $elementList['invoice_supplier_send'] = img_picto('', 'bill', 'class="pictofixedwidth"').dol_escape_htmltag($langs->trans('MailToSendSupplierInvoice'));
}
if (!empty($conf->contrat->enabled) && !empty($user->rights->contrat->lire)) {
- $elementList['contract'] = img_picto('', 'contract', 'class="paddingright"').dol_escape_htmltag($langs->trans('MailToSendContract'));
+ $elementList['contract'] = img_picto('', 'contract', 'class="pictofixedwidth"').dol_escape_htmltag($langs->trans('MailToSendContract'));
}
if (!empty($conf->ticket->enabled) && !empty($user->rights->ticket->read)) {
- $elementList['ticket_send'] = img_picto('', 'ticket', 'class="paddingright"').dol_escape_htmltag($langs->trans('MailToTicket'));
+ $elementList['ticket_send'] = img_picto('', 'ticket', 'class="pictofixedwidth"').dol_escape_htmltag($langs->trans('MailToTicket'));
}
if (!empty($conf->expensereport->enabled) && !empty($user->rights->expensereport->lire)) {
- $elementList['expensereport_send'] = img_picto('', 'trip', 'class="paddingright"').dol_escape_htmltag($langs->trans('MailToTExpenseReport'));
+ $elementList['expensereport_send'] = img_picto('', 'trip', 'class="pictofixedwidth"').dol_escape_htmltag($langs->trans('MailToExpenseReport'));
}
if (isModEnabled('agenda')) {
- $elementList['actioncomm_send'] = img_picto('', 'action', 'class="paddingright"').dol_escape_htmltag($langs->trans('MailToSendEventPush'));
+ $elementList['actioncomm_send'] = img_picto('', 'action', 'class="pictofixedwidth"').dol_escape_htmltag($langs->trans('MailToSendEventPush'));
}
if (!empty($conf->eventorganization->enabled) && !empty($user->rights->eventorganization->read)) {
- $elementList['conferenceorbooth'] = img_picto('', 'action', 'class="paddingright"').dol_escape_htmltag($langs->trans('MailToSendEventOrganization'));
+ $elementList['conferenceorbooth'] = img_picto('', 'action', 'class="pictofixedwidth"').dol_escape_htmltag($langs->trans('MailToSendEventOrganization'));
}
if (!empty($conf->partnership->enabled) && !empty($user->rights->partnership->read)) {
- $elementList['partnership_send'] = img_picto('', 'partnership', 'class="paddingright"').dol_escape_htmltag($langs->trans('MailToPartnership'));
+ $elementList['partnership_send'] = img_picto('', 'partnership', 'class="pictofixedwidth"').dol_escape_htmltag($langs->trans('MailToPartnership'));
}
$parameters = array('elementList'=>$elementList);
diff --git a/htdocs/admin/mails_ticket.php b/htdocs/admin/mails_ticket.php
index a439bdabcf0..8b0d78132a0 100644
--- a/htdocs/admin/mails_ticket.php
+++ b/htdocs/admin/mails_ticket.php
@@ -66,8 +66,15 @@ if ($action == 'update' && !$cancel) {
dolibarr_set_const($db, "MAIN_MAIL_SMTP_PORT_TICKET", GETPOST("MAIN_MAIL_SMTP_PORT_TICKET"), 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_MAIL_SMTP_SERVER_TICKET", GETPOST("MAIN_MAIL_SMTP_SERVER_TICKET"), 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_MAIL_SMTPS_ID_TICKET", GETPOST("MAIN_MAIL_SMTPS_ID_TICKET"), 'chaine', 0, '', $conf->entity);
- dolibarr_set_const($db, "MAIN_MAIL_SMTPS_PW_TICKET", GETPOST("MAIN_MAIL_SMTPS_PW_TICKET"), 'chaine', 0, '', $conf->entity);
- dolibarr_set_const($db, "MAIN_MAIL_EMAIL_TLS_TICKET", GETPOST("MAIN_MAIL_EMAIL_TLS_TICKET"), 'chaine', 0, '', $conf->entity);
+ if (GETPOSTISSET("MAIN_MAIL_SMTPS_PW_TICKET")) {
+ dolibarr_set_const($db, "MAIN_MAIL_SMTPS_PW_TICKET", GETPOST("MAIN_MAIL_SMTPS_PW_TICKET", 'none'), 'chaine', 0, '', $conf->entity);
+ }
+ if (GETPOSTISSET("MAIN_MAIL_SMTPS_AUTH_TYPE_TICKET")) {
+ dolibarr_set_const($db, "MAIN_MAIL_SMTPS_AUTH_TYPE_TICKET", GETPOST("MAIN_MAIL_SMTPS_AUTH_TYPE_TICKET", 'chaine'), 'chaine', 0, '', $conf->entity);
+ }
+ if (GETPOSTISSET("MAIN_MAIL_SMTPS_OAUTH_SERVICE_TICKET")) {
+ dolibarr_set_const($db, "MAIN_MAIL_SMTPS_OAUTH_SERVICE_TICKET", GETPOST("MAIN_MAIL_SMTPS_OAUTH_SERVICE_TICKET", 'chaine'), 'chaine', 0, '', $conf->entity);
+ }dolibarr_set_const($db, "MAIN_MAIL_EMAIL_TLS_TICKET", GETPOST("MAIN_MAIL_EMAIL_TLS_TICKET"), 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_MAIL_EMAIL_STARTTLS_TICKET", GETPOST("MAIN_MAIL_EMAIL_STARTTLS_TICKET"), 'chaine', 0, '', $conf->entity);
header("Location: ".$_SERVER["PHP_SELF"]."?mainmenu=home&leftmenu=setup");
@@ -139,6 +146,25 @@ if (version_compare(phpversion(), '7.0', '>=')) {
$listofmethods['swiftmailer'] = 'Swift Mailer socket library';
}
+// List of oauth services
+$oauthservices = array();
+
+foreach ($conf->global as $key => $val) {
+ if (!empty($val) && preg_match('/^OAUTH_.*_ID$/', $key)) {
+ $key = preg_replace('/^OAUTH_/', '', $key);
+ $key = preg_replace('/_ID$/', '', $key);
+ if (preg_match('/^.*-/', $key)) {
+ $name = preg_replace('/^.*-/', '', $key);
+ } else {
+ $name = $langs->trans("NoName");
+ }
+ $provider = preg_replace('/-.*$/', '', $key);
+ $provider = ucfirst(strtolower($provider));
+
+ $oauthservices[$key] = $name." (".$provider.")";
+ }
+}
+
if ($action == 'edit') {
if ($conf->use_javascript_ajax) {
@@ -162,6 +188,8 @@ if ($action == 'edit') {
jQuery("#MAIN_MAIL_EMAIL_TLS_TICKET").prop("disabled", true);
jQuery("#MAIN_MAIL_EMAIL_STARTTLS_TICKET").val(0);
jQuery("#MAIN_MAIL_EMAIL_STARTTLS_TICKET").prop("disabled", true);
+ jQuery(".smtp_method").hide();
+ jQuery(".smtp_auth_method").hide();
';
if ($linuxlike) {
print '
@@ -192,7 +220,9 @@ if ($action == 'edit') {
jQuery("#MAIN_MAIL_SMTP_SERVER_TICKET").show();
jQuery("#MAIN_MAIL_SMTP_PORT_TICKET").show();
jQuery("#smtp_server_mess").hide();
- jQuery("#smtp_port_mess").hide();
+ jQuery("#smtp_port_mess").hide();
+ jQuery(".smtp_method").show();
+ jQuery(".smtp_auth_method").show();
}
if (jQuery("#MAIN_MAIL_SENDMODE_TICKET").val()==\'swiftmailer\')
{
@@ -207,12 +237,37 @@ if ($action == 'edit') {
jQuery("#MAIN_MAIL_SMTP_PORT_TICKET").show();
jQuery("#smtp_server_mess").hide();
jQuery("#smtp_port_mess").hide();
+ jQuery(".smtp_method").show();
+ jQuery(".smtp_auth_method").show();
}
}
+ function change_smtp_auth_method() {
+ console.log(jQuery("#radio_pw").prop("checked"));
+ if (jQuery("#MAIN_MAIL_SENDMODE_TICKET").val()==\'smtps\' && jQuery("#radio_oauth").prop("checked")) {
+ jQuery(".smtp_oauth_service").show();
+ jQuery(".smtp_pw").hide();
+ } else if (jQuery("#MAIN_MAIL_SENDMODE_TICKET").val()==\'swiftmailer\' && jQuery("#radio_oauth").prop("checked")) {
+ jQuery(".smtp_oauth_service").show();
+ jQuery(".smtp_pw").hide();
+ } else if(jQuery("#MAIN_MAIL_SENDMODE_TICKET").val()==\'mail\' || jQuery("#MAIN_MAIL_SENDMODE_TICKET").val()==\'default\'){
+ jQuery(".smtp_oauth_service").hide();
+ jQuery(".smtp_pw").hide();
+ } else {
+ jQuery(".smtp_oauth_service").hide();
+ jQuery(".smtp_pw").show();
+ }
+ }
initfields();
+ change_smtp_auth_method();
+
jQuery("#MAIN_MAIL_SENDMODE_TICKET").change(function() {
initfields();
+ change_smtp_auth_method();
+
});
+ jQuery("#radio_pw, #radio_oauth").change(function() {
+ change_smtp_auth_method();
+ });
jQuery("#MAIN_MAIL_EMAIL_TLS").change(function() {
if (jQuery("#MAIN_MAIL_EMAIL_STARTTLS_TICKET").val() == 1)
jQuery("#MAIN_MAIL_EMAIL_STARTTLS_TICKET").val(0);
@@ -275,7 +330,7 @@ if ($action == 'edit') {
}
print ' ';
// SuperAdministrator access only
- if (empty($conf->multicompany->enabled) || ($user->admin && !$user->entity)) {
+ if (!isModEnabled('multicompany') || ($user->admin && !$user->entity)) {
print ' ';
print ' ';
print ''.$langs->trans("SeeLocalSendMailSetup").' ';
@@ -305,7 +360,7 @@ if ($action == 'edit') {
}
print ' ';
// SuperAdministrator access only
- if (empty($conf->multicompany->enabled) || ($user->admin && !$user->entity)) {
+ if (!isModEnabled('multicompany') || ($user->admin && !$user->entity)) {
print ' ';
print ' ';
print ''.$langs->trans("SeeLocalSendMailSetup").' ';
@@ -323,7 +378,7 @@ if ($action == 'edit') {
$mainstmpid = (!empty($conf->global->MAIN_MAIL_SMTPS_ID_TICKET) ? $conf->global->MAIN_MAIL_SMTPS_ID_TICKET : '');
print ' '.$langs->trans("MAIN_MAIL_SMTPS_ID").' ';
// SuperAdministrator access only
- if (empty($conf->multicompany->enabled) || ($user->admin && !$user->entity)) {
+ if (!isModEnabled('multicompany') || ($user->admin && !$user->entity)) {
print ' ';
} else {
$htmltext = $langs->trans("ContactSuperAdminForChange");
@@ -333,12 +388,31 @@ if ($action == 'edit') {
print ' ';
}
+ // OAUTH
+ if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array('smtps', 'swiftmailer')))) {
+ print ''.$langs->trans("MAIN_MAIL_SMTPS_AUTH_TYPE").' ';
+ if (empty($conf->multicompany->enabled) || ($user->admin && !$user->entity)) {
+ print ' ';
+ print ''.$langs->trans("UsePassword").' ';
+ print ' ';
+ print ' ';
+ print ''.$form->textwithpicto($langs->trans("UseOauth"), $langs->trans("OauthNotAvailableForAllAndHadToBeCreatedBefore")).' ';
+ } else {
+ $value = getDolGlobalString('MAIN_MAIL_SMTPS_AUTH_TYPE_TICKET', 'LOGIN');
+ $htmltext = $langs->trans("ContactSuperAdminForChange");
+ print $form->textwithpicto($langs->trans("MAIN_MAIL_SMTPS_AUTH_TYPE"), $htmltext, 1, 'superadmin');
+ print ' ';
+ }
+ print ' ';
+ }
+
+
// PW
if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array('smtps', 'swiftmailer')))) {
$mainsmtppw = (!empty($conf->global->MAIN_MAIL_SMTPS_PW_TICKET) ? $conf->global->MAIN_MAIL_SMTPS_PW_TICKET : '');
- print ''.$langs->trans("MAIN_MAIL_SMTPS_PW").' ';
+ print ' '.$langs->trans("MAIN_MAIL_SMTPS_PW").' ';
// SuperAdministrator access only
- if (empty($conf->multicompany->enabled) || ($user->admin && !$user->entity)) {
+ if (!isModEnabled('multicompany') || ($user->admin && !$user->entity)) {
print ' ';
} else {
$htmltext = $langs->trans("ContactSuperAdminForChange");
@@ -348,6 +422,24 @@ if ($action == 'edit') {
print ' ';
}
+ // OAUTH service provider
+ if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array('smtps', 'swiftmailer')))) {
+ print ''.$langs->trans("MAIN_MAIL_SMTPS_OAUTH_SERVICE").' ';
+ // SuperAdministrator access only
+ if ((empty($conf->global->MAIN_MODULE_MULTICOMPANY)) || ($user->admin && !$user->entity)) {
+ print $form->selectarray('MAIN_MAIL_SMTPS_OAUTH_SERVICE_TICKET', $oauthservices, $conf->global->MAIN_MAIL_SMTPS_OAUTH_SERVICE_TICKET);
+ } else {
+ $text = $oauthservices[$conf->global->MAIN_MAIL_SMTPS_OAUTH_SERVICE_TICKET];
+ if (empty($text)) {
+ $text = $langs->trans("Undefined");
+ }
+ $htmltext = $langs->trans("ContactSuperAdminForChange");
+ print $form->textwithpicto($text, $htmltext, 1, 'superadmin');
+ print ' ';
+ }
+ print ' ';
+ }
+
// TLS
print ''.$langs->trans("MAIN_MAIL_EMAIL_TLS").' ';
@@ -425,11 +517,27 @@ if ($action == 'edit') {
print ' '.$langs->trans("MAIN_MAIL_SMTPS_ID").' '.$conf->global->MAIN_MAIL_SMTPS_ID_TICKET.' ';
}
+ // AUTH method
+ if (in_array(getDolGlobalString('MAIN_MAIL_SENDMODE_TICKET'), array('smtps', 'swiftmailer'))) {
+ $authtype = getDolGlobalString('MAIN_MAIL_SMTPS_AUTH_TYPE_TICKET', 'LOGIN');
+ $text = ($authtype === "LOGIN") ? $langs->trans("UsePassword") : ($authtype === "XOAUTH2" ? $langs->trans("UseOauth") : '') ;
+ print ''.$langs->trans("MAIN_MAIL_SMTPS_AUTH_TYPE").' '.$text.' ';
+ }
+
// SMTPS PW
- if (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array('smtps', 'swiftmailer'))) {
+ if (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array('smtps', 'swiftmailer')) && getDolGlobalString('MAIN_MAIL_SMTPS_AUTH_TYPE_TICKET') != "XOAUTH2") {
print ''.$langs->trans("MAIN_MAIL_SMTPS_PW").' '.preg_replace('/./', '*', $conf->global->MAIN_MAIL_SMTPS_PW_TICKET).' ';
}
+ // SMTPS oauth service
+ if (in_array(getDolGlobalString('MAIN_MAIL_SENDMODE_TICKET'), array('smtps', 'swiftmailer')) && getDolGlobalString('MAIN_MAIL_SMTPS_AUTH_TYPE_TICKET') === "XOAUTH2") {
+ $text = $oauthservices[$conf->global->MAIN_MAIL_SMTPS_OAUTH_SERVICE_TICKET];
+ if (empty($text)) {
+ $text = $langs->trans("Undefined").img_warning();
+ }
+ print ''.$langs->trans("MAIN_MAIL_SMTPS_OAUTH_SERVICE_TICKET").' '.$text.' ';
+ }
+
// TLS
print ''.$langs->trans("MAIN_MAIL_EMAIL_TLS").' ';
if (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array('smtps', 'swiftmailer'))) {
@@ -496,7 +604,7 @@ if ($action == 'edit') {
print ''.$langs->trans("DoTestSend").' ';
- if (!empty($conf->fckeditor->enabled)) {
+ if (isModEnabled('fckeditor')) {
print ''.$langs->trans("DoTestSendHTML").' ';
}
}
diff --git a/htdocs/admin/menus/edit.php b/htdocs/admin/menus/edit.php
index bf4ac3f8979..9378fc28bbe 100644
--- a/htdocs/admin/menus/edit.php
+++ b/htdocs/admin/menus/edit.php
@@ -172,12 +172,12 @@ if ($action == 'add') {
$action = 'create';
$error++;
}
- if (!$error && GETPOST('menuId') && GETPOST('type') == 'top') {
+ if (!$error && GETPOST('menuId', 'alphanohtml', 3) && GETPOST('type') == 'top') {
setEventMessages($langs->trans("ErrorTopMenuMustHaveAParentWithId0"), null, 'errors');
$action = 'create';
$error++;
}
- if (!$error && !GETPOST('menuId') && GETPOST('type') == 'left') {
+ if (!$error && !GETPOST('menuId', 'alphanohtml', 3) && GETPOST('type') == 'left') {
setEventMessages($langs->trans("ErrorLeftMenuMustHaveAParentId"), null, 'errors');
$action = 'create';
$error++;
diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php
index 286ccc424e8..05f7ed441f7 100644
--- a/htdocs/admin/modules.php
+++ b/htdocs/admin/modules.php
@@ -43,10 +43,15 @@ require_once DOL_DOCUMENT_ROOT.'/admin/dolistore/class/dolistore.class.php';
// Load translation files required by the page
$langs->loadLangs(array("errors", "admin", "modulebuilder"));
-$mode = GETPOSTISSET('mode') ? GETPOST('mode', 'alpha') : (empty($conf->global->MAIN_MODULE_SETUP_ON_LIST_BY_DEFAULT) ? 'commonkanban' : 'common');
-if (empty($mode)) {
- $mode = 'common';
+// if we set another view list mode, we keep it (till we change one more time)
+if (GETPOSTISSET('mode')) {
+ $mode = GETPOST('mode', 'alpha');
+ if ($mode =='common' || $mode =='commonkanban')
+ dolibarr_set_const($db, "MAIN_MODULE_SETUP_ON_LIST_BY_DEFAULT", $mode, 'chaine', 0, '', $conf->entity);
+} else {
+ $mode = (empty($conf->global->MAIN_MODULE_SETUP_ON_LIST_BY_DEFAULT) ? 'commonkanban' : $conf->global->MAIN_MODULE_SETUP_ON_LIST_BY_DEFAULT);
}
+
$action = GETPOST('action', 'aZ09');
$value = GETPOST('value', 'alpha');
$page_y = GETPOST('page_y', 'int');
@@ -781,14 +786,14 @@ if ($mode == 'common' || $mode == 'commonkanban') {
if (!empty($objMod->disabled)) {
$codeenabledisable .= $langs->trans("Disabled");
- } elseif (!empty($objMod->always_enabled) || ((!empty($conf->multicompany->enabled) && $objMod->core_enabled) && ($user->entity || $conf->entity != 1))) {
+ } elseif (!empty($objMod->always_enabled) || ((isModEnabled('multicompany') && $objMod->core_enabled) && ($user->entity || $conf->entity != 1))) {
if (method_exists($objMod, 'alreadyUsed') && $objMod->alreadyUsed()) {
$codeenabledisable .= $langs->trans("Used");
} else {
$codeenabledisable .= img_picto($langs->trans("Required"), 'switch_on', '', false, 0, 0, '', 'opacitymedium valignmiddle');
//print $langs->trans("Required");
}
- if (!empty($conf->multicompany->enabled) && $user->entity) {
+ if (isModEnabled('multicompany') && $user->entity) {
$disableSetup++;
}
} else {
@@ -1274,7 +1279,7 @@ if ($mode == 'develop') {
print ' ';
print ''.$langs->trans("TryToUseTheModuleBuilder", $langs->transnoentitiesnoconv("ModuleBuilder")).' ';
print '';
- if (!empty($conf->modulebuilder->enabled)) {
+ if (isModEnabled('modulebuilder')) {
print $langs->trans("SeeTopRightMenu");
} else {
print ''.$langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("ModuleBuilder")).' ';
diff --git a/htdocs/admin/multicurrency.php b/htdocs/admin/multicurrency.php
index d6487093e41..1cf838c08cb 100644
--- a/htdocs/admin/multicurrency.php
+++ b/htdocs/admin/multicurrency.php
@@ -33,7 +33,7 @@ require_once DOL_DOCUMENT_ROOT.'/multicurrency/class/multicurrency.class.php';
$langs->loadLangs(array('admin', 'multicurrency'));
// Access control
-if (!$user->admin || empty($conf->multicurrency->enabled)) {
+if (!$user->admin || !isModEnabled('multicurrency')) {
accessforbidden();
}
diff --git a/htdocs/admin/notification.php b/htdocs/admin/notification.php
index 760df948d34..44b5c104813 100644
--- a/htdocs/admin/notification.php
+++ b/htdocs/admin/notification.php
@@ -177,7 +177,7 @@ print load_fiche_titre($langs->trans("NotificationSetup"), $linkback, 'title_set
print '';
print $langs->trans("NotificationsDesc").' ';
print $langs->trans("NotificationsDescUser").' ';
-if (!empty($conf->societe->enabled)) {
+if (isModEnabled("societe")) {
print $langs->trans("NotificationsDescContact").' ';
}
print $langs->trans("NotificationsDescGlobal").' ';
@@ -361,7 +361,7 @@ print $form->buttonsSaveCancel("Save", '');
print '';
print '* '.$langs->trans("GoOntoUserCardToAddMore").' ';
- if (!empty($conf->societe->enabled)) {
+ if (isModEnabled("societe")) {
print '** '.$langs->trans("GoOntoContactCardToAddMore").' ';
}
print '
';
@@ -384,7 +384,7 @@ print load_fiche_titre($langs->trans("ListOfFixedNotifications"), '', 'email');
print '';
print $langs->trans("Note").': ';
print '* '.$langs->trans("GoOntoUserCardToAddMore").' ';
-if (!empty($conf->societe->enabled)) {
+if (isModEnabled("societe")) {
print '** '.$langs->trans("GoOntoContactCardToAddMore").' ';
}
print '
';
diff --git a/htdocs/admin/oauth.php b/htdocs/admin/oauth.php
index 772055f0809..ade561c4ef1 100644
--- a/htdocs/admin/oauth.php
+++ b/htdocs/admin/oauth.php
@@ -62,7 +62,7 @@ if ($action == 'add') { // $provider is OAUTH_XXX
setEventMessages($langs->trans("AOAuthEntryForThisProviderAndLabelAlreadyHasAKey"), null, 'errors');
$error++;
} else {
- dolibarr_set_const($db, $constname, 'ToComplete', 'chaine', 0, '', $conf->entity);
+ dolibarr_set_const($db, $constname, $langs->trans('ToComplete'), 'chaine', 0, '', $conf->entity);
setEventMessages($langs->trans("OAuthProviderAdded"), null);
}
}
@@ -78,6 +78,16 @@ if ($action == 'update') {
if (!dolibarr_set_const($db, $constvalue.'_SECRET', GETPOST($constvalue.'_ID') ? GETPOST($constvalue.'_SECRET') : '', 'chaine', 0, '', $conf->entity)) {
$error++;
}
+ if (GETPOSTISSET($constvalue.'_URLAUTHORIZE')) {
+ if (!dolibarr_set_const($db, $constvalue.'_URLAUTHORIZE', GETPOST($constvalue.'_URLAUTHORIZE'), 'chaine', 0, '', $conf->entity)) {
+ $error++;
+ }
+ }
+ if (GETPOSTISSET($constvalue.'_SCOPE')) {
+ if (!dolibarr_set_const($db, $constvalue.'_SCOPE', GETPOST($constvalue.'_SCOPE'), 'chaine', 0, '', $conf->entity)) {
+ $error++;
+ }
+ }
}
}
@@ -147,11 +157,17 @@ print '';
$i = 0;
-//var_dump($list);
+// Define $listinsetup
foreach ($conf->global as $key => $val) {
if (!empty($val) && preg_match('/^OAUTH_.*_ID$/', $key)) {
$provider = preg_replace('/_ID$/', '', $key);
- $listinsetup[] = array($provider.'_NAME', $provider.'_ID', $provider.'_SECRET', 'OAUTH Provider '.str_replace('OAUTH_', '', $provider));
+ $listinsetup[] = array(
+ $provider.'_NAME',
+ $provider.'_ID',
+ $provider.'_SECRET',
+ $provider.'_URLAUTHORIZE', // For custom oauth links
+ $provider.'_SCOPE' // For custom oauth links
+ );
}
}
@@ -178,12 +194,16 @@ foreach ($listinsetup as $key) {
$i++;
- print '';
// Api Name
$label = $langs->trans($keyforsupportedoauth2array);
+ print ' ';
print '';
print img_picto('', $supportedoauth2array[$keyforsupportedoauth2array]['picto'], 'class="pictofixedwidth"');
- print $label;
+ if ($label == $keyforsupportedoauth2array) {
+ print $supportedoauth2array[$keyforsupportedoauth2array]['name'];
+ } else {
+ print $label;
+ }
if ($keyforprovider) {
print ' ('.$keyforprovider.' )';
} else {
@@ -201,8 +221,15 @@ foreach ($listinsetup as $key) {
$redirect_uri = $urlwithroot.'/core/modules/oauth/'.$supportedoauth2array[$keyforsupportedoauth2array]['callbackfile'].'_oauthcallback.php';
print ' ';
print ''.$langs->trans("UseTheFollowingUrlAsRedirectURI").' ';
- print ' ';
+ print ' ';
print ' ';
+
+ if ($keyforsupportedoauth2array == 'OAUTH_OTHER_NAME') {
+ print '';
+ print ''.$langs->trans("URLOfServiceForAuthorization").' ';
+ print ' ';
+ print ' ';
+ }
} else {
print '';
print ''.$langs->trans("UseTheFollowingUrlAsRedirectURI").' ';
@@ -213,14 +240,32 @@ foreach ($listinsetup as $key) {
// Api Id
print ' ';
print ''.$langs->trans("OAUTH_ID").' ';
- print ' ';
+ print ' ';
print ' ';
// Api Secret
print '';
print ''.$langs->trans("OAUTH_SECRET").' ';
- print ' ';
+ print ' ';
print ' ';
+
+ // TODO Move this into token generation
+ if ($supported) {
+ if ($keyforsupportedoauth2array == 'OAUTH_OTHER_NAME') {
+ print '';
+ print ''.$langs->trans("Scopes").' ';
+ print '';
+ print ' ';
+ print ' ';
+ } else {
+ print '';
+ print ''.$langs->trans("Scopes").' ';
+ print '';
+ //print ' ';
+ print $supportedoauth2array[$keyforsupportedoauth2array]['defaultscope'];
+ print ' ';
+ }
+ }
}
print '
'."\n";
diff --git a/htdocs/admin/oauthlogintokens.php b/htdocs/admin/oauthlogintokens.php
index b2830f95743..7de4e146595 100644
--- a/htdocs/admin/oauthlogintokens.php
+++ b/htdocs/admin/oauthlogintokens.php
@@ -77,7 +77,7 @@ if ($action == 'setconst' && $user->admin) {
$constnote = dol_escape_htmltag($setupconst['note']);
$result = dolibarr_set_const($db, $constname, $constvalue, $consttype, 0, $constnote, $conf->entity);
- if (!$result > 0) {
+ if (!($result > 0)) {
$error++;
}
}
@@ -96,7 +96,7 @@ if ($action == 'setvalue' && $user->admin) {
$db->begin();
$result = dolibarr_set_const($db, $varname, $value, 'chaine', 0, '', $conf->entity);
- if (!$result > 0) {
+ if (!($result > 0)) {
$error++;
}
@@ -138,11 +138,17 @@ if (GETPOST('error')) {
if ($mode == 'setup' && $user->admin) {
print ''.$langs->trans("OAuthSetupForLogin")." \n";
- //var_dump($list);
+ // Define $listinsetup
foreach ($conf->global as $key => $val) {
if (!empty($val) && preg_match('/^OAUTH_.*_ID$/', $key)) {
$provider = preg_replace('/_ID$/', '', $key);
- $listinsetup[] = array($provider.'_NAME', $provider.'_ID', $provider.'_SECRET', 'OAUTH Provider '.str_replace('OAUTH_', '', $provider));
+ $listinsetup[] = array(
+ $provider.'_NAME',
+ $provider.'_ID',
+ $provider.'_SECRET',
+ $provider.'_URLAUTHORIZE', // For custom oauth links
+ $provider.'_SCOPE' // For custom oauth links
+ );
}
}
@@ -165,46 +171,39 @@ if ($mode == 'setup' && $user->admin) {
$OAUTH_SERVICENAME = (empty($supportedoauth2array[$keyforsupportedoauth2array]['name']) ? 'Unknown' : $supportedoauth2array[$keyforsupportedoauth2array]['name'].($keyforprovider ? '-'.$keyforprovider : ''));
- // Define $shortscope, $urltorenew, $urltodelete, $urltocheckperms
+ $shortscope = $supportedoauth2array[$keyforsupportedoauth2array]['defaultscope'];
+ if (getDolGlobalString($key[4])) {
+ $shortscope = getDolGlobalString($key[4]);
+ }
+ $state = $shortscope; // TODO USe a better state
+
+ // Define $urltorenew, $urltodelete, $urltocheckperms
// TODO Use array $supportedoauth2array
if ($keyforsupportedoauth2array == 'OAUTH_GITHUB_NAME') {
// List of keys that will be converted into scopes (from constants 'SCOPE_state_in_uppercase' in file of service).
// We pass this param list in to 'state' because we need it before and after the redirect.
- $shortscope = 'user,public_repo';
- // Note: github does not accept csrf key inside the state parameter (only know values)
- $urltorenew = $urlwithroot.'/core/modules/oauth/github_oauthcallback.php?shortscope='.$shortscope.'&state='.$shortscope.'&backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php');
+ // Note: github does not accept csrf key inside the state parameter (only known values)
+ $urltorenew = $urlwithroot.'/core/modules/oauth/github_oauthcallback.php?shortscope='.urlencode($shortscope).'&state='.$shortscope.'&backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php');
$urltodelete = $urlwithroot.'/core/modules/oauth/github_oauthcallback.php?action=delete&token='.newToken().'&backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php');
$urltocheckperms = 'https://github.com/settings/applications/';
} elseif ($keyforsupportedoauth2array == 'OAUTH_GOOGLE_NAME') {
// List of keys that will be converted into scopes (from constants 'SCOPE_state_in_uppercase' in file of service).
// List of scopes for Google are here: https://developers.google.com/identity/protocols/oauth2/scopes
// We pass this key list into the param 'state' because we need it before and after the redirect.
- $shortscope = 'userinfo_email,userinfo_profile';
- $shortscope .= ',openid,email,profile'; // For openid connect
- if (!empty($conf->printing->enabled)) {
- $shortscope .= ',cloud_print';
- }
- if (!empty($conf->global->OAUTH_GOOGLE_GSUITE)) {
- $shortscope .= ',admin_directory_user';
- }
- if (!empty($conf->global->OAUTH_GOOGLE_GMAIL)) {
- $shortscope.=',gmail_full';
- }
-
- $urltorenew = $urlwithroot.'/core/modules/oauth/google_oauthcallback.php?shortscope='.$shortscope.'&state='.$shortscope.'-'.$oauthstateanticsrf.'&backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php');
+ $urltorenew = $urlwithroot.'/core/modules/oauth/google_oauthcallback.php?shortscope='.urlencode($shortscope).'&state='.urlencode($state).'-'.$oauthstateanticsrf.'&backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php');
$urltodelete = $urlwithroot.'/core/modules/oauth/google_oauthcallback.php?action=delete&token='.newToken().'&backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php');
$urltocheckperms = 'https://security.google.com/settings/security/permissions';
} elseif ($keyforsupportedoauth2array == 'OAUTH_STRIPE_TEST_NAME') {
- $shortscope = 'none';
-
- $urltorenew = $urlwithroot.'/core/modules/oauth/stripetest_oauthcallback.php?backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php');
+ $urltorenew = $urlwithroot.'/core/modules/oauth/stripetest_oauthcallback.php?shortscope='.urlencode($shortscope).'&state='.urlencode($state).'&backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php');
$urltodelete = '';
$urltocheckperms = '';
} elseif ($keyforsupportedoauth2array == 'OAUTH_STRIPE_LIVE_NAME') {
- $shortscope = 'none';
-
- $urltorenew = $urlwithroot.'/core/modules/oauth/stripelive_oauthcallback.php?backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php');
+ $urltorenew = $urlwithroot.'/core/modules/oauth/stripelive_oauthcallback.php?shortscope='.urlencode($shortscope).'&state='.urlencode($state).'&backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php');
+ $urltodelete = '';
+ $urltocheckperms = '';
+ } elseif ($keyforsupportedoauth2array = 'OAUTH_OTHER_NAME') {
+ $urltorenew = $urlwithroot.'/core/modules/oauth/generic_oauthcallback.php?shortscope='.urlencode($shortscope).'&state='.urlencode($state).'&backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php');
$urltodelete = '';
$urltocheckperms = '';
} else {
@@ -212,13 +211,13 @@ if ($mode == 'setup' && $user->admin) {
$urltodelete = '';
$urltocheckperms = '';
}
- $urltorenew .= '&keyforprovider='.$keyforprovider;
+
+ $urltorenew .= '&keyforprovider='.urlencode($keyforprovider);
// Show value of token
$tokenobj = null;
// Token
require_once DOL_DOCUMENT_ROOT.'/includes/OAuth/bootstrap.php';
- require_once DOL_DOCUMENT_ROOT.'/includes/OAuth/bootstrap.php';
// Dolibarr storage
$storage = new DoliStorage($db, $conf);
try {
@@ -246,7 +245,7 @@ if ($mode == 'setup' && $user->admin) {
} elseif ($endoflife == $tokenobj::EOL_UNKNOWN) {
$expiredat = $langs->trans("Unknown");
} else {
- $expiredat = dol_print_date($endoflife, "dayhour");
+ $expiredat = dol_print_date($endoflife, "dayhour", 'tzuserrel');
}
}
}
@@ -260,10 +259,16 @@ if ($mode == 'setup' && $user->admin) {
print '';
print '
'."\n";
+ // Api Name
+ $label = $langs->trans($keyforsupportedoauth2array);
print '';
print '';
print img_picto('', $supportedoauth2array[$keyforsupportedoauth2array]['picto'], 'class="pictofixedwidth"');
- print $langs->trans($keyforsupportedoauth2array);
+ if ($label == $keyforsupportedoauth2array) {
+ print $supportedoauth2array[$keyforsupportedoauth2array]['name'];
+ } else {
+ print $label;
+ }
if ($keyforprovider) {
print ' ('.$keyforprovider.' )';
} else {
@@ -275,7 +280,7 @@ if ($mode == 'setup' && $user->admin) {
print " \n";
print '';
- print '';
+ print ' ';
//var_dump($key);
print $langs->trans("OAuthIDSecret").' ';
print '';
@@ -286,13 +291,13 @@ if ($mode == 'setup' && $user->admin) {
print ' '."\n";
print '';
- print '';
+ print ' ';
//var_dump($key);
print $langs->trans("IsTokenGenerated");
print ' ';
print '';
if (is_object($tokenobj)) {
- print $langs->trans("HasAccessToken");
+ print $form->textwithpicto(yn(1), $langs->trans("HasAccessToken").' : '.dol_print_date($storage->date_modification, 'dayhour').' state='.dol_escape_htmltag($storage->state));
} else {
print ''.$langs->trans("NoAccessToken").' ';
}
@@ -305,7 +310,9 @@ if ($mode == 'setup' && $user->admin) {
}
// Request remote token
if ($urltorenew) {
- print ''.$langs->trans('RequestAccess').' ';
+ print ''.$langs->trans('GetAccess').' ';
+ print $form->textwithpicto('', $langs->trans('RequestAccess'));
+ print ' ';
}
// Check remote access
if ($urltocheckperms) {
@@ -315,7 +322,7 @@ if ($mode == 'setup' && $user->admin) {
print ' ';
print '';
- print '';
+ print ' ';
//var_dump($key);
print $langs->trans("Token").' ';
print '';
@@ -323,7 +330,7 @@ if ($mode == 'setup' && $user->admin) {
if (is_object($tokenobj)) {
//var_dump($tokenobj);
$tokentoshow = $tokenobj->getAccessToken();
- print ''.showValueWithClipboardCPButton($tokentoshow, 1, dol_trunc($tokentoshow, 32)).' ';
+ print ''.showValueWithClipboardCPButton($tokentoshow, 1, dol_trunc($tokentoshow, 32)).' ';
//print 'Refresh: '.$tokenobj->getRefreshToken().' ';
//print 'EndOfLife: '.$tokenobj->getEndOfLife().' ';
//var_dump($tokenobj->getExtraParams());
@@ -348,7 +355,7 @@ if ($mode == 'setup' && $user->admin) {
// Token expired
print '';
- print '';
+ print ' ';
//var_dump($key);
print $langs->trans("TOKEN_EXPIRED");
print ' ';
@@ -359,7 +366,7 @@ if ($mode == 'setup' && $user->admin) {
// Token expired at
print ' ';
- print '';
+ print ' ';
//var_dump($key);
print $langs->trans("TOKEN_EXPIRE_AT");
print ' ';
@@ -378,8 +385,8 @@ if ($mode == 'setup' && $user->admin) {
}
}
-
print '';
+ print ' ';
}
}
diff --git a/htdocs/admin/pdf.php b/htdocs/admin/pdf.php
index b95f73a399f..f534ff881da 100644
--- a/htdocs/admin/pdf.php
+++ b/htdocs/admin/pdf.php
@@ -108,7 +108,7 @@ if ($action == 'update') {
dolibarr_set_const($db, "MAIN_TVAINTRA_NOT_IN_ADDRESS", GETPOST("MAIN_TVAINTRA_NOT_IN_ADDRESS"), 'chaine', 0, '', $conf->entity);
}
- if (!empty($conf->project->enabled)) {
+ if (isModEnabled('project')) {
if (GETPOST('PDF_SHOW_PROJECT_REF_OR_LABEL') == 'no') {
dolibarr_del_const($db, "PDF_SHOW_PROJECT", $conf->entity);
dolibarr_del_const($db, "PDF_SHOW_PROJECT_TITLE", $conf->entity);
@@ -166,6 +166,10 @@ if ($action == 'update') {
dolibarr_set_const($db, "PDF_SHOW_LINK_TO_ONLINE_PAYMENT", GETPOST('PDF_SHOW_LINK_TO_ONLINE_PAYMENT', 'alpha'), 'chaine', 0, '', $conf->entity);
}
+ if (GETPOSTISSET('DOC_SHOW_FIRST_SALES_REP')) {
+ dolibarr_set_const($db, "DOC_SHOW_FIRST_SALES_REP", GETPOST('DOC_SHOW_FIRST_SALES_REP', 'alpha'), 'chaine', 0, '', $conf->entity);
+ }
+
if (GETPOSTISSET('PDF_INCLUDE_ALIAS_IN_THIRDPARTY_NAME')) {
dolibarr_set_const($db, "PDF_INCLUDE_ALIAS_IN_THIRDPARTY_NAME", GETPOST('PDF_INCLUDE_ALIAS_IN_THIRDPARTY_NAME', 'alpha'), 'chaine', 0, '', $conf->entity);
}
@@ -482,7 +486,7 @@ print ' ';
// Show project
-if (!empty($conf->project->enabled)) {
+if (isModEnabled('project')) {
print ''.$langs->trans("PDF_SHOW_PROJECT").' ';
$tmparray = array('no' => 'No', 'showprojectref' => 'RefProject', 'showprojectlabel' => 'ShowProjectLabel');
$showprojectref = empty($conf->global->PDF_SHOW_PROJECT) ? (empty($conf->global->PDF_SHOW_PROJECT_TITLE) ? 'no' : 'showprojectlabel') : 'showprojectref';
@@ -568,6 +572,18 @@ print ' '.$langs->trans("ShowDetailsInPDFPageFoot").' selectarray('MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS', $arraydetailsforpdffoot, (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS) ? $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS : 0));
print ' ';
+// Show the first sales representative
+
+print ''.$langs->trans("DOC_SHOW_FIRST_SALES_REP");
+print ' ('.$langs->trans("SalesRepresentativeInfo").') ';
+print ' ';
+if ($conf->use_javascript_ajax) {
+ print ajax_constantonoff('DOC_SHOW_FIRST_SALES_REP');
+} else {
+ $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
+ print $form->selectarray("DOC_SHOW_FIRST_SALES_REP", $arrval, $conf->global->DOC_SHOW_FIRST_SALES_REP);
+}
+
// Show alias in thirdparty name
/* Disabled because not yet completely implemented (does not work when we force a contact on object)
diff --git a/htdocs/admin/pdf_other.php b/htdocs/admin/pdf_other.php
index b064cbb8cd8..979edb47de4 100644
--- a/htdocs/admin/pdf_other.php
+++ b/htdocs/admin/pdf_other.php
@@ -102,7 +102,7 @@ print '';
print ' ';
print ' ';
-if (!empty($conf->propal->enabled)) {
+if (isModEnabled('propal')) {
print load_fiche_titre($langs->trans("Proposal"), '', '');
print '';
diff --git a/htdocs/admin/propal.php b/htdocs/admin/propal.php
index c324f33ba92..eea567ea27c 100644
--- a/htdocs/admin/propal.php
+++ b/htdocs/admin/propal.php
@@ -515,7 +515,7 @@ print '
';
print ' ';
print $langs->trans("PaymentMode").' ';
print '';
-if (empty($conf->facture->enabled)) {
+if (!isModEnabled('facture')) {
print ' ';
}
print ' ';
@@ -524,8 +524,8 @@ print " \n";
print '';
print "".$langs->trans("SuggestPaymentByRIBOnAccount")." ";
print "";
-if (empty($conf->facture->enabled)) {
- if (!empty($conf->banque->enabled)) {
+if (!isModEnabled('facture')) {
+ if (isModEnabled("banque")) {
$sql = "SELECT rowid, label";
$sql .= " FROM ".MAIN_DB_PREFIX."bank_account";
$sql .= " WHERE clos = 0";
@@ -563,7 +563,7 @@ print " ";
print '';
print "".$langs->trans("SuggestPaymentByChequeToAddress")." ";
print "";
-if (empty($conf->facture->enabled)) {
+if (!isModEnabled('facture')) {
print '';
print ''.$langs->trans("DoNotSuggestPaymentMode").' ';
print 'global->FACTURE_CHQ_NUMBER ? ' selected' : '').'>'.$langs->trans("MenuCompanySetup").' ('.($mysoc->name ? $mysoc->name : $langs->trans("NotDefined")).') ';
@@ -700,7 +700,7 @@ print " \n";
print '';
/* Seems to be not so used. So kept hidden for the moment to avoid dangerous options inflation.
-if ($conf->banque->enabled)
+if (isModEnabled('facture'))
{
print '';
diff --git a/htdocs/admin/receiptprinter.php b/htdocs/admin/receiptprinter.php
index ac136af0c61..53f0cd9f7f0 100644
--- a/htdocs/admin/receiptprinter.php
+++ b/htdocs/admin/receiptprinter.php
@@ -183,8 +183,8 @@ if ($action == 'testtemplate' && $user->admin) {
// test
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
$object = new Facture($db);
- //$object->initAsSpecimen();
- $object->fetch(18);
+ $object->initAsSpecimen();
+ //$object->fetch(18);
//var_dump($object->lines);
$ret = $printer->sendToPrinter($object, $templateid, 1);
if ($ret == 0) {
diff --git a/htdocs/admin/reception_setup.php b/htdocs/admin/reception_setup.php
index 5479b43f6ca..a06760b9da4 100644
--- a/htdocs/admin/reception_setup.php
+++ b/htdocs/admin/reception_setup.php
@@ -47,7 +47,7 @@ $type = 'reception';
* Actions
*/
-if (!empty($conf->reception->enabled) && empty($conf->global->MAIN_SUBMODULE_RECEPTION)) {
+if (isModEnabled('reception') && empty($conf->global->MAIN_SUBMODULE_RECEPTION)) {
// This option should always be set to on when module is on.
dolibarr_set_const($db, "MAIN_SUBMODULE_RECEPTION", "1", 'chaine', 0, '', $conf->entity);
}
diff --git a/htdocs/admin/security.php b/htdocs/admin/security.php
index 795a0557f16..516197b7a70 100644
--- a/htdocs/admin/security.php
+++ b/htdocs/admin/security.php
@@ -1,5 +1,5 @@
+/* Copyright (C) 2004-2022 Laurent Destailleur
* Copyright (C) 2005-2007 Regis Houssin
* Copyright (C) 2013-2015 Juanjo Menent
*
@@ -47,9 +47,6 @@ $allow_disable_encryption = true;
if ($action == 'setgeneraterule') {
if (!dolibarr_set_const($db, 'USER_PASSWORD_GENERATED', $_GET["value"], 'chaine', 0, '', $conf->entity)) {
dol_print_error($db);
- } else {
- header("Location: ".$_SERVER["PHP_SELF"]);
- exit;
}
}
@@ -94,8 +91,6 @@ if ($action == 'activate_encrypt') {
//exit;
if (!$error) {
$db->commit();
- header("Location: security.php");
- exit;
} else {
$db->rollback();
dol_print_error($db, '');
@@ -106,8 +101,6 @@ if ($action == 'activate_encrypt') {
if ($allow_disable_encryption) {
dolibarr_del_const($db, "DATABASE_PWD_ENCRYPTED", $conf->entity);
}
- header("Location: security.php");
- exit;
}
if ($action == 'activate_encryptdbpassconf') {
@@ -138,12 +131,8 @@ if ($action == 'activate_encryptdbpassconf') {
if ($action == 'activate_MAIN_SECURITY_DISABLEFORGETPASSLINK') {
dolibarr_set_const($db, "MAIN_SECURITY_DISABLEFORGETPASSLINK", '1', 'chaine', 0, '', $conf->entity);
- header("Location: security.php");
- exit;
} elseif ($action == 'disable_MAIN_SECURITY_DISABLEFORGETPASSLINK') {
dolibarr_del_const($db, "MAIN_SECURITY_DISABLEFORGETPASSLINK", $conf->entity);
- header("Location: security.php");
- exit;
}
if ($action == 'updatepattern') {
@@ -387,9 +376,9 @@ if ($conf->global->USER_PASSWORD_GENERATED == "Perso") {
// Cryptage mot de passe
print ' ';
-print "";
+print ' ';
print ' ';
-print " ";
+print ' ';
print '';
print '';
@@ -408,7 +397,7 @@ if (getDolGlobalString('DATABASE_PWD_ENCRYPTED')) {
print '';
if (!getDolGlobalString('DATABASE_PWD_ENCRYPTED')) {
print '';
- print ''.$langs->trans("Activate").' ';
+ print ''.$langs->trans("Activate").' ';
print " ";
}
@@ -418,7 +407,7 @@ if (getDolGlobalString('DATABASE_PWD_ENCRYPTED')) {
if ($allow_disable_encryption) {
//On n'autorise pas l'annulation de l'encryption car les mots de passe ne peuvent pas etre decodes
//Do not allow "disable encryption" as passwords cannot be decrypted
- print ''.$langs->trans("Disable").' ';
+ print ''.$langs->trans("Disable").' ';
} else {
print '-';
}
@@ -444,10 +433,10 @@ if (empty($dolibarr_main_db_pass) && empty($dolibarr_main_db_encrypted_pass)) {
print img_warning($langs->trans("WarningPassIsEmpty"));
} else {
if (empty($dolibarr_main_db_encrypted_pass)) {
- print ''.$langs->trans("Activate").' ';
+ print ''.$langs->trans("Activate").' ';
}
if (!empty($dolibarr_main_db_encrypted_pass)) {
- print ''.$langs->trans("Disable").' ';
+ print ''.$langs->trans("Disable").' ';
}
}
print "";
@@ -467,12 +456,12 @@ if (getDolGlobalString('MAIN_SECURITY_DISABLEFORGETPASSLINK')) {
print '';
if (!getDolGlobalString('MAIN_SECURITY_DISABLEFORGETPASSLINK')) {
print '';
- print ''.$langs->trans("Activate").' ';
+ print ''.$langs->trans("Activate").' ';
print " ";
}
if (getDolGlobalString('MAIN_SECURITY_DISABLEFORGETPASSLINK')) {
print '';
- print ''.$langs->trans("Disable").' ';
+ print ''.$langs->trans("Disable").' ';
print " ";
}
print "";
diff --git a/htdocs/admin/security_other.php b/htdocs/admin/security_other.php
index beffa8d4ea8..70b928f833b 100644
--- a/htdocs/admin/security_other.php
+++ b/htdocs/admin/security_other.php
@@ -211,10 +211,10 @@ print ' ';
print '
';
-print dol_get_fiche_end();
-
print $form->buttonsSaveCancel("Modify", '');
+print dol_get_fiche_end();
+
print ' ';
// End of page
diff --git a/htdocs/admin/stock.php b/htdocs/admin/stock.php
index 2b25d7deb5a..ade62c29081 100644
--- a/htdocs/admin/stock.php
+++ b/htdocs/admin/stock.php
@@ -245,7 +245,7 @@ $found++;
print '';
print ''.$langs->trans("DeStockOnShipment").' ';
print '';
-if (!empty($conf->expedition->enabled)) {
+if (isModEnabled("expedition")) {
if ($conf->use_javascript_ajax) {
print ajax_constantonoff('STOCK_CALCULATE_ON_SHIPMENT', array(), null, 0, 0, 0, 2, 1);
} else {
@@ -262,7 +262,7 @@ $found++;
print ' ';
print ''.$langs->trans("DeStockOnShipmentOnClosing").' ';
print '';
-if (!empty($conf->expedition->enabled)) {
+if (isModEnabled("expedition")) {
if ($conf->use_javascript_ajax) {
print ajax_constantonoff('STOCK_CALCULATE_ON_SHIPMENT_CLOSE', array(), null, 0, 0, 0, 2, 1);
} else {
@@ -293,7 +293,7 @@ $found = 0;
print ' ';
print ''.$langs->trans("ReStockOnBill").' ';
print '';
-if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) {
+if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) {
if ($conf->use_javascript_ajax) {
print ajax_constantonoff('STOCK_CALCULATE_ON_SUPPLIER_BILL', array(), null, 0, 0, 0, 2, 1);
} else {
@@ -311,7 +311,7 @@ $found++;
print ' ';
print ''.$langs->trans("ReStockOnValidateOrder").' ';
print '';
-if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) {
+if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) {
if ($conf->use_javascript_ajax) {
print ajax_constantonoff('STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER', array(), null, 0, 0, 0, 2, 1);
} else {
@@ -324,7 +324,7 @@ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SU
print " \n \n";
$found++;
-if (!empty($conf->reception->enabled)) {
+if (isModEnabled("reception")) {
print '';
print ''.$langs->trans("StockOnReception").' ';
print '';
@@ -356,7 +356,7 @@ if (!empty($conf->reception->enabled)) {
print ' ';
print ''.$langs->trans("ReStockOnDispatchOrder").' ';
print '';
- if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled)) {
+ if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order")) {
if ($conf->use_javascript_ajax) {
print ajax_constantonoff('STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER', array(), null, 0, 0, 0, 2, 1);
} else {
@@ -422,7 +422,7 @@ if (!empty($conf->order->enabled)) {
print " \n";
}
-if (!empty($conf->expedition->enabled)) {
+if (isModEnabled("expedition")) {
print '';
print ''.$langs->trans("StockMustBeEnoughForShipment").' ';
print '';
diff --git a/htdocs/admin/stocktransfer.php b/htdocs/admin/stocktransfer.php
index 0e504ec26f1..099312ef491 100644
--- a/htdocs/admin/stocktransfer.php
+++ b/htdocs/admin/stocktransfer.php
@@ -78,9 +78,10 @@ if ($action == 'updateMask') {
$maskconststocktransfer = GETPOST('maskconststocktransfer', 'alpha');
$maskstocktransfer = GETPOST('maskStockTransfer', 'alpha');
- if ($maskconststocktransfer) $res = dolibarr_set_const($db, $maskconststocktransfer, $maskstocktransfer, 'chaine', 0, '', $conf->entity);
-
- if (!$res > 0) $error++;
+ if ($maskconststocktransfer) {
+ $res = dolibarr_set_const($db, $maskconststocktransfer, $maskstocktransfer, 'chaine', 0, '', $conf->entity);
+ if ($res <= 0) $error++;
+ }
if (!$error) {
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
diff --git a/htdocs/admin/supplier_proposal.php b/htdocs/admin/supplier_proposal.php
index 76a881f9415..593ad13ff82 100644
--- a/htdocs/admin/supplier_proposal.php
+++ b/htdocs/admin/supplier_proposal.php
@@ -498,7 +498,7 @@ print ' \n";
print '';
-if (!empty($conf->banque->enabled)) {
+if (isModEnabled('banque')) {
print '';
print $langs->trans("BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_PROPOSAL").' ';
if (!empty($conf->use_javascript_ajax)) {
diff --git a/htdocs/admin/syslog.php b/htdocs/admin/syslog.php
index 8e80a13673e..875d024fd65 100644
--- a/htdocs/admin/syslog.php
+++ b/htdocs/admin/syslog.php
@@ -293,7 +293,7 @@ print 'global->SYSLOG_LEVEL >= LOG_DEBUG
print '';
print ' ';
-if (!empty($conf->loghandlers['mod_syslog_file']) && !empty($conf->cron->enabled)) {
+if (!empty($conf->loghandlers['mod_syslog_file']) && isModEnabled('cron')) {
print ''.$langs->trans("SyslogFileNumberOfSaves").' ';
print ' ';
print ' ('.$langs->trans('ConfigureCleaningCronjobToSetFrequencyOfSaves').' ) ';
diff --git a/htdocs/admin/system/constall.php b/htdocs/admin/system/constall.php
index 9a27feb3d7a..fee82d89958 100644
--- a/htdocs/admin/system/constall.php
+++ b/htdocs/admin/system/constall.php
@@ -205,7 +205,7 @@ print '';
print '';
print ''.$langs->trans("Parameter").' ';
print ''.$langs->trans("Value").' ';
-if (empty($conf->multicompany->enabled) || !$user->entity) {
+if (!isModEnabled('multicompany') || !$user->entity) {
print ''.$langs->trans("Entity").' '; // If superadmin or multicompany disabled
}
print " \n";
@@ -218,7 +218,7 @@ $sql .= ", type";
$sql .= ", note";
$sql .= ", entity";
$sql .= " FROM ".MAIN_DB_PREFIX."const";
-if (empty($conf->multicompany->enabled)) {
+if (!isModEnabled('multicompany')) {
// If no multicompany mode, admins can see global and their constantes
$sql .= " WHERE entity IN (0,".$conf->entity.")";
} else {
@@ -239,7 +239,7 @@ if ($resql) {
print '';
print ''.$obj->name.' '."\n";
print ''.$obj->value.' '."\n";
- if (empty($conf->multicompany->enabled) || !$user->entity) {
+ if (!isModEnabled('multicompany') || !$user->entity) {
print ''.$obj->entity.' '."\n"; // If superadmin or multicompany disabled
}
print " \n";
diff --git a/htdocs/admin/system/dolibarr.php b/htdocs/admin/system/dolibarr.php
index 8a982f6e0bd..31fa647f403 100644
--- a/htdocs/admin/system/dolibarr.php
+++ b/htdocs/admin/system/dolibarr.php
@@ -382,7 +382,7 @@ foreach ($configfileparameters as $key => $value) {
$newkey = preg_replace('/^\?/', '', $key);
if (preg_match('/^\?/', $key) && empty(${$newkey})) {
- if ($newkey != 'multicompany_transverse_mode' || empty($conf->multicompany->enabled)) {
+ if ($newkey != 'multicompany_transverse_mode' || !isModEnabled('multicompany')) {
continue; // We discard parameters starting with ?
}
}
@@ -483,7 +483,7 @@ print '';
print '';
print ''.$langs->trans("Parameters").' '.$langs->trans("Database").' ';
print ''.$langs->trans("Value").' ';
-if (empty($conf->multicompany->enabled) || !$user->entity) {
+if (!isModEnabled('multicompany') || !$user->entity) {
print ''.$langs->trans("Entity").' '; // If superadmin or multicompany disabled
}
print " \n";
@@ -496,7 +496,7 @@ $sql .= ", type";
$sql .= ", note";
$sql .= ", entity";
$sql .= " FROM ".MAIN_DB_PREFIX."const";
-if (empty($conf->multicompany->enabled)) {
+if (!isModEnabled('multicompany')) {
// If no multicompany mode, admins can see global and their constantes
$sql .= " WHERE entity IN (0,".$conf->entity.")";
} else {
@@ -526,7 +526,7 @@ if ($resql) {
print dol_escape_htmltag($obj->value);
}
print ''."\n";
- if (empty($conf->multicompany->enabled) || !$user->entity) {
+ if (!isModEnabled('multicompany') || !$user->entity) {
print ''.$obj->entity.' '."\n"; // If superadmin or multicompany disabled
}
print "\n";
diff --git a/htdocs/admin/system/security.php b/htdocs/admin/system/security.php
index 8a480ea49ca..ad4befadad6 100644
--- a/htdocs/admin/system/security.php
+++ b/htdocs/admin/system/security.php
@@ -418,6 +418,11 @@ print ' ';
print load_fiche_titre($langs->trans("OtherSetup"), '', 'folder');
+print 'MAIN_ALLOW_SVG_FILES_AS_IMAGES = '.(empty($conf->global->MAIN_ALLOW_SVG_FILES_AS_IMAGES) ? '0' : $conf->global->MAIN_ALLOW_SVG_FILES_AS_IMAGES).' ('.$langs->trans("Recommended").': 0) ';
+print ' ';
+
+print 'MAIN_ALWAYS_CREATE_LOCK_AFTER_LAST_UPGRADE = '.(empty($conf->global->MAIN_ALWAYS_CREATE_LOCK_AFTER_LAST_UPGRADE) ? ''.$langs->trans("Undefined").' ' : $conf->global->MAIN_ALWAYS_CREATE_LOCK_AFTER_LAST_UPGRADE).' ('.$langs->trans("Recommended").': 1) ';
+print ' ';
//print ''.$langs->trans("PasswordEncryption").' : ';
print 'MAIN_SECURITY_HASH_ALGO = '.(empty($conf->global->MAIN_SECURITY_HASH_ALGO) ? ''.$langs->trans("Undefined").' ' : $conf->global->MAIN_SECURITY_HASH_ALGO)." ";
@@ -443,13 +448,7 @@ print ' ';
print 'MAIN_SECURITY_ANTI_SSRF_SERVER_IP = '.(empty($conf->global->MAIN_SECURITY_ANTI_SSRF_SERVER_IP) ? ''.$langs->trans("Undefined").' ('.$langs->trans("Recommended").': List of static IPs of server separated with coma - '.$langs->trans("Note").': common loopback ip like 127.*.*.*, [::1] are already added) ' : $conf->global->MAIN_SECURITY_ANTI_SSRF_SERVER_IP)." ";
print ' ';
-print 'MAIN_ALLOW_SVG_FILES_AS_IMAGES = '.(empty($conf->global->MAIN_ALLOW_SVG_FILES_AS_IMAGES) ? '0' : $conf->global->MAIN_ALLOW_SVG_FILES_AS_IMAGES).' ('.$langs->trans("Recommended").': 0) ';
-print ' ';
-
-print 'MAIN_ALWAYS_CREATE_LOCK_AFTER_LAST_UPGRADE = '.(empty($conf->global->MAIN_ALWAYS_CREATE_LOCK_AFTER_LAST_UPGRADE) ? ''.$langs->trans("Undefined").' ' : $conf->global->MAIN_ALWAYS_CREATE_LOCK_AFTER_LAST_UPGRADE).' ('.$langs->trans("Recommended").': 1) ';
-print ' ';
-
-print 'MAIN_SECURITY_CSRF_WITH_TOKEN = '.(empty($conf->global->MAIN_SECURITY_CSRF_WITH_TOKEN) ? ''.$langs->trans("Undefined").' ' : $conf->global->MAIN_SECURITY_CSRF_WITH_TOKEN).' ('.$langs->trans("Recommended").': 2) '." ";
+print 'MAIN_SECURITY_CSRF_WITH_TOKEN = '.(empty($conf->global->MAIN_SECURITY_CSRF_WITH_TOKEN) ? ''.$langs->trans("Undefined").' ' : $conf->global->MAIN_SECURITY_CSRF_WITH_TOKEN).' ('.$langs->trans("Recommended").': '.$langs->trans("Undefined").' '.$langs->trans("or").' 2) '." ";
print ' ';
print ' ';
@@ -458,15 +457,6 @@ print ' ';
print load_fiche_titre($langs->trans("OtherSetup").' ('.$langs->trans("Experimental").')', '', 'folder');
-print 'MAIN_RESTRICTHTML_ONLY_VALID_HTML = '.(empty($conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML) ? ''.$langs->trans("Undefined").' ('.$langs->trans("Recommended").': 1) ' : $conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML)." ";
-print ' ';
-
-print 'MAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES = '.(empty($conf->global->MAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES) ? ''.$langs->trans("Undefined").' ('.$langs->trans("Recommended").': 1) ' : $conf->global->MAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES)." ";
-print ' ';
-
-print 'MAIN_SECURITY_CSRF_TOKEN_RENEWAL_ON_EACH_CALL = '.(empty($conf->global->MAIN_SECURITY_CSRF_TOKEN_RENEWAL_ON_EACH_CALL) ? ''.$langs->trans("Undefined").' ('.$langs->trans("Recommended").': '.$langs->trans("Undefined").' '.$langs->trans("or").' 0) ' : $conf->global->MAIN_SECURITY_CSRF_TOKEN_RENEWAL_ON_EACH_CALL)." ";
-print ' ';
-
print 'MAIN_EXEC_USE_POPEN = ';
if (empty($conf->global->MAIN_EXEC_USE_POPEN)) {
print ''.$langs->trans("Undefined").' ';
@@ -483,7 +473,36 @@ if ($execmethod == 2) {
print ' ('.$langs->trans("Recommended").': '.$langs->trans("Undefined").' '.$langs->trans("or").' 1)';
print '';
}
-print " ";
+print ' ';
+print ' ';
+
+print 'MAIN_RESTRICTHTML_ONLY_VALID_HTML = '.(empty($conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML) ? ''.$langs->trans("Undefined").' ('.$langs->trans("Recommended").': 1) ' : $conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML)." ";
+print ' ';
+
+print 'MAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES = '.(empty($conf->global->MAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES) ? ''.$langs->trans("Undefined").' ('.$langs->trans("Recommended").': 1) ' : $conf->global->MAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES)." ";
+print ' ';
+
+print 'MAIN_SECURITY_CSRF_TOKEN_RENEWAL_ON_EACH_CALL = '.(empty($conf->global->MAIN_SECURITY_CSRF_TOKEN_RENEWAL_ON_EACH_CALL) ? ''.$langs->trans("Undefined").' ('.$langs->trans("Recommended").': '.$langs->trans("Undefined").' '.$langs->trans("or").' 0) ' : $conf->global->MAIN_SECURITY_CSRF_TOKEN_RENEWAL_ON_EACH_CALL)." ";
+print ' ';
+
+print 'MAIN_SECURITY_FORCECSP = '.(empty($conf->global->MAIN_SECURITY_FORCECSP) ? ''.$langs->trans("Undefined").' ' : $conf->global->MAIN_SECURITY_FORCECSP).' ('.$langs->trans("Example").": \"default-src 'self'; img-src *;\") ";
+print ' ';
+
+print 'WEBSITE_MAIN_SECURITY_FORCECSP = '.(empty($conf->global->WEBSITE_MAIN_SECURITY_FORCECSP) ? ''.$langs->trans("Undefined").' ' : $conf->global->WEBSITE_MAIN_SECURITY_FORCECSP).' ('.$langs->trans("Example").": \"default-src 'self'; style-src: https://cdnjs.cloudflare.com https://fonts.googleapis.com; script-src: https://cdn.transifex.com https://www.googletagmanager.com; object-src https://youtube.com; frame-src https://youtube.com; img-src: *;\") ";
+print ' ';
+
+print 'MAIN_SECURITY_FORCERP = '.(empty($conf->global->MAIN_SECURITY_FORCERP) ? ''.$langs->trans("Undefined").' ' : $conf->global->MAIN_SECURITY_FORCERP).' ('.$langs->trans("Recommended").': '.$langs->trans("Undefined").' '.$langs->trans("or")." \"same-origin\") ";
+print ' ';
+
+print 'WEBSITE_MAIN_SECURITY_FORCERP = '.(empty($conf->global->WEBSITE_MAIN_SECURITY_FORCERP) ? ''.$langs->trans("Undefined").' ' : $conf->global->WEBSITE_MAIN_SECURITY_FORCERP).' ('.$langs->trans("Recommended").': '.$langs->trans("Undefined").' '.$langs->trans("or")." \"strict-origin-when-cross-origin\") ";
+print ' ';
+
+print 'WEBSITE_MAIN_SECURITY_FORCESTS = '.(empty($conf->global->WEBSITE_MAIN_SECURITY_FORCESTS) ? ''.$langs->trans("Undefined").' ' : $conf->global->WEBSITE_MAIN_SECURITY_FORCESTS).' ('.$langs->trans("Example").": \"max-age=31536000; includeSubDomains\") ";
+print ' ';
+
+print 'WEBSITE_MAIN_SECURITY_FORCEPP = '.(empty($conf->global->WEBSITE_MAIN_SECURITY_FORCEPP) ? ''.$langs->trans("Undefined").' ' : $conf->global->WEBSITE_MAIN_SECURITY_FORCEPP).' ('.$langs->trans("Example").": \"camera: 'none'; microphone: 'none';\") ";
+print ' ';
+
print ' ';
diff --git a/htdocs/admin/taxes.php b/htdocs/admin/taxes.php
index 646f4a7be74..fb4b2ec6d72 100644
--- a/htdocs/admin/taxes.php
+++ b/htdocs/admin/taxes.php
@@ -27,7 +27,7 @@
require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
-if (!empty($conf->accounting->enabled)) {
+if (isModEnabled('accounting')) {
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
}
@@ -137,7 +137,7 @@ if ($action == 'update') {
llxHeader('', $langs->trans("TaxSetup"));
$form = new Form($db);
-if (!empty($conf->accounting->enabled)) {
+if (isModEnabled('accounting')) {
$formaccounting = new FormAccounting($db);
}
@@ -282,7 +282,7 @@ echo '
';
echo '';
-if (!empty($conf->accounting->enabled)) {
+if (isModEnabled('accounting')) {
$langs->load("accountancy");
print ''.$langs->trans("AccountingAccountForSalesTaxAreDefinedInto", $langs->transnoentitiesnoconv("MenuAccountancy"), $langs->transnoentitiesnoconv("Setup")).' ';
}
diff --git a/htdocs/admin/ticket.php b/htdocs/admin/ticket.php
index 99d1b34749f..f1fbba03840 100644
--- a/htdocs/admin/ticket.php
+++ b/htdocs/admin/ticket.php
@@ -539,7 +539,7 @@ print $formcategory->textwithpicto('', $langs->trans("TicketsAutoNotifyCloseHelp
print '';
print '';
-if (! empty($conf->product->enabled)) {
+if (isModEnabled('product')) {
print ''.$langs->trans("TicketChooseProductCategory").' ';
print '';
$formcategory->selectProductCategory($conf->global->TICKET_PRODUCT_CATEGORY, 'product_category_id');
diff --git a/htdocs/admin/tools/listevents.php b/htdocs/admin/tools/listevents.php
index 1a45466141b..da7ae901766 100644
--- a/htdocs/admin/tools/listevents.php
+++ b/htdocs/admin/tools/listevents.php
@@ -302,7 +302,7 @@ if ($result) {
$center = '';
if ($num) {
- $center = ''.$langs->trans("Purge").' ';
+ $center = ''.$langs->trans("Purge").' ';
}
print '';
@@ -418,7 +418,7 @@ if ($result) {
$userstatic->status = $obj->status;
print $userstatic->getLoginUrl(1);
- if (!empty($conf->multicompany->enabled) && $userstatic->admin && !$userstatic->entity) {
+ if (isModEnabled('multicompany') && $userstatic->admin && !$userstatic->entity) {
print img_picto($langs->trans("SuperAdministrator"), 'redstar', 'class="valignmiddle paddingleft"');
} elseif ($userstatic->admin) {
print img_picto($langs->trans("Administrator"), 'star', 'class="valignmiddle paddingleft"');
@@ -459,7 +459,7 @@ if ($result) {
// More informations
print '';
$htmltext = ''.$langs->trans("UserAgent").' : '.($obj->user_agent ? dol_string_nohtmltag($obj->user_agent) : $langs->trans("Unknown"));
- $htmltext .= ''.$langs->trans("PrefixSession").' : '.($obj->prefix_session ? dol_string_nohtmltag($obj->prefix_session) : $langs->trans("Unknown"));
+ $htmltext .= ''.$langs->trans("SuffixSessionName").' (DOLSESSID_...) : '.($obj->prefix_session ? dol_string_nohtmltag($obj->prefix_session) : $langs->trans("Unknown"));
print $form->textwithpicto('', $htmltext);
print ' ';
diff --git a/htdocs/admin/translation.php b/htdocs/admin/translation.php
index 1e667e7abb4..154ac3f5665 100644
--- a/htdocs/admin/translation.php
+++ b/htdocs/admin/translation.php
@@ -346,7 +346,7 @@ if ($mode == 'overwrite') {
print_liste_field_titre("Language_en_US_es_MX_etc", $_SERVER["PHP_SELF"], 'lang,transkey', '', $param, '', $sortfield, $sortorder);
print_liste_field_titre("Key", $_SERVER["PHP_SELF"], 'transkey', '', $param, '', $sortfield, $sortorder);
print_liste_field_titre("NewTranslationStringToShow", $_SERVER["PHP_SELF"], 'transvalue', '', $param, '', $sortfield, $sortorder);
- //if (! empty($conf->multicompany->enabled) && !$user->entity) print_liste_field_titre("Entity", $_SERVER["PHP_SELF"], 'entity,transkey', '', $param, '', $sortfield, $sortorder);
+ //if (isModEnabled('multicompany') && !$user->entity) print_liste_field_titre("Entity", $_SERVER["PHP_SELF"], 'entity,transkey', '', $param, '', $sortfield, $sortorder);
print ' ';
print " \n";
@@ -504,7 +504,7 @@ if ($mode == 'searchkey') {
print '';
print ' ';
// Limit to superadmin
- /*if (! empty($conf->multicompany->enabled) && !$user->entity)
+ /*if (isModEnabled('multicompany') && !$user->entity)
{
print ' ';
print ' ';
@@ -525,7 +525,7 @@ if ($mode == 'searchkey') {
print_liste_field_titre("Language_en_US_es_MX_etc", $_SERVER["PHP_SELF"], 'lang,transkey', '', $param, '', $sortfield, $sortorder);
print_liste_field_titre("Key", $_SERVER["PHP_SELF"], 'transkey', '', $param, '', $sortfield, $sortorder);
print_liste_field_titre("CurrentTranslationString", $_SERVER["PHP_SELF"], 'transvalue', '', $param, '', $sortfield, $sortorder);
- //if (! empty($conf->multicompany->enabled) && !$user->entity) print_liste_field_titre("Entity", $_SERVER["PHP_SELF"], 'entity,transkey', '', $param, '', $sortfield, $sortorder);
+ //if (isModEnabled('multicompany') && !$user->entity) print_liste_field_titre("Entity", $_SERVER["PHP_SELF"], 'entity,transkey', '', $param, '', $sortfield, $sortorder);
print ' ';
print "\n";
@@ -609,7 +609,7 @@ if ($mode == 'searchkey') {
$htmltext = $langs->trans("TransKeyWithoutOriginalValue", $key);
print $form->textwithpicto('', $htmltext, 1, 'warning');
}
- /*if (! empty($conf->multicompany->enabled) && !$user->entity)
+ /*if (isModEnabled('multicompany') && !$user->entity)
{
print ''.$val.' ';
}*/
diff --git a/htdocs/admin/webhook.php b/htdocs/admin/webhook.php
index 9dec7a8eeec..b589eac4079 100644
--- a/htdocs/admin/webhook.php
+++ b/htdocs/admin/webhook.php
@@ -343,7 +343,7 @@ if ($action == 'edit') {
include_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
print dolJSToSetRandomPassword($constname, 'generate_token'.$constname);
} elseif ($val['type'] == 'product') {
- if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) {
+ if (isModEnabled("product") || isModEnabled("service")) {
$selected = (empty($conf->global->$constname) ? '' : $conf->global->$constname);
$form->select_produits($selected, $constname, '', 0);
}
diff --git a/htdocs/admin/website.php b/htdocs/admin/website.php
index 5f51bccb240..80e806b6595 100644
--- a/htdocs/admin/website.php
+++ b/htdocs/admin/website.php
@@ -109,7 +109,7 @@ $tabrowid[1] = "";
// Condition to show dictionary in setup page
$tabcond = array();
-$tabcond[1] = (!empty($conf->website->enabled));
+$tabcond[1] = (isModEnabled('website'));
// List of help for fields
$tabhelp = array();
diff --git a/htdocs/admin/workflow.php b/htdocs/admin/workflow.php
index 47e6e87a244..e1899b35a56 100644
--- a/htdocs/admin/workflow.php
+++ b/htdocs/admin/workflow.php
@@ -62,7 +62,7 @@ $workflowcodes = array(
'WORKFLOW_PROPAL_AUTOCREATE_ORDER'=>array(
'family'=>'create',
'position'=>10,
- 'enabled'=>(!empty($conf->propal->enabled) && !empty($conf->commande->enabled)),
+ 'enabled'=>(isModEnabled("propal") && !empty($conf->commande->enabled)),
'picto'=>'order'
),
'WORKFLOW_ORDER_AUTOCREATE_INVOICE'=>array(
@@ -84,14 +84,14 @@ $workflowcodes = array(
'WORKFLOW_ORDER_CLASSIFY_BILLED_PROPAL'=>array(
'family'=>'classify_proposal',
'position'=>30,
- 'enabled'=>(!empty($conf->propal->enabled) && !empty($conf->commande->enabled)),
+ 'enabled'=>(isModEnabled("propal") && !empty($conf->commande->enabled)),
'picto'=>'propal',
'warning'=>''
),
'WORKFLOW_INVOICE_CLASSIFY_BILLED_PROPAL'=>array(
'family'=>'classify_proposal',
'position'=>31,
- 'enabled'=>(!empty($conf->propal->enabled) && isModEnabled('facture')),
+ 'enabled'=>(isModEnabled("propal") && isModEnabled('facture')),
'picto'=>'propal',
'warning'=>''
),
@@ -100,13 +100,13 @@ $workflowcodes = array(
'WORKFLOW_ORDER_CLASSIFY_SHIPPED_SHIPPING'=>array( // when shipping validated
'family'=>'classify_order',
'position'=>40,
- 'enabled'=>(!empty($conf->expedition->enabled) && !empty($conf->commande->enabled)),
+ 'enabled'=>(isModEnabled("expedition") && !empty($conf->commande->enabled)),
'picto'=>'order'
),
'WORKFLOW_ORDER_CLASSIFY_SHIPPED_SHIPPING_CLOSED'=>array( // when shipping closed
'family'=>'classify_order',
'position'=>41,
- 'enabled'=>(!empty($conf->expedition->enabled) && !empty($conf->commande->enabled)),
+ 'enabled'=>(isModEnabled("expedition") && !empty($conf->commande->enabled)),
'picto'=>'order'
),
'WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_ORDER'=>array(
@@ -123,7 +123,7 @@ $workflowcodes = array(
'WORKFLOW_ORDER_CLASSIFY_BILLED_SUPPLIER_PROPOSAL'=>array(
'family'=>'classify_supplier_proposal',
'position'=>60,
- 'enabled'=>(!empty($conf->supplier_proposal->enabled) && ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled))),
+ 'enabled'=>(!empty($conf->supplier_proposal->enabled) && ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice"))),
'picto'=>'supplier_proposal',
'warning'=>''
),
@@ -132,7 +132,7 @@ $workflowcodes = array(
'WORKFLOW_ORDER_CLASSIFY_RECEIVED_RECEPTION'=>array(
'family'=>'classify_supplier_order',
'position'=>63,
- 'enabled'=>(!empty($conf->global->MAIN_FEATURES_LEVEL) && (!empty($conf->reception->enabled)) && ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || empty($conf->supplier_order->enabled))),
+ 'enabled'=>(!empty($conf->global->MAIN_FEATURES_LEVEL) && (isModEnabled("reception")) && ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || empty($conf->supplier_order->enabled))),
'picto'=>'supplier_order',
'warning'=>''
),
@@ -140,7 +140,7 @@ $workflowcodes = array(
'WORKFLOW_ORDER_CLASSIFY_RECEIVED_RECEPTION_CLOSED'=>array(
'family'=>'classify_supplier_order',
'position'=>64,
- 'enabled'=>(!empty($conf->global->MAIN_FEATURES_LEVEL) && (!empty($conf->reception->enabled)) && ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || empty($conf->supplier_order->enabled))),
+ 'enabled'=>(!empty($conf->global->MAIN_FEATURES_LEVEL) && (isModEnabled("reception")) && ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || empty($conf->supplier_order->enabled))),
'picto'=>'supplier_order',
'warning'=>''
),
@@ -148,7 +148,7 @@ $workflowcodes = array(
'WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_SUPPLIER_ORDER'=>array(
'family'=>'classify_supplier_order',
'position'=>65,
- 'enabled'=>((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)),
+ 'enabled'=>((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")),
'picto'=>'supplier_order',
'warning'=>''
),
@@ -157,7 +157,7 @@ $workflowcodes = array(
'WORKFLOW_BILL_ON_RECEPTION'=>array(
'family'=>'classify_reception',
'position'=>80,
- 'enabled'=>(!empty($conf->reception->enabled) && ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled))),
+ 'enabled'=>(isModEnabled("reception") && ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice"))),
'picto'=>'reception'
),
@@ -165,7 +165,7 @@ $workflowcodes = array(
'WORKFLOW_SHIPPING_CLASSIFY_CLOSED_INVOICE' => array(
'family' => 'classify_shipping',
'position' => 90,
- 'enabled' => !empty($conf->expedition->enabled) && !empty($conf->facture->enabled),
+ 'enabled' => isModEnabled("expedition") && isModEnabled("facture"),
'picto' => 'shipment'
),
diff --git a/htdocs/api/class/api.class.php b/htdocs/api/class/api.class.php
index 32d691400d6..0ef143d36ad 100644
--- a/htdocs/api/class/api.class.php
+++ b/htdocs/api/class/api.class.php
@@ -115,6 +115,8 @@ class DolibarrApi
// Remove linkedObjects. We should already have linkedObjectsIds that avoid huge responses
unset($object->linkedObjects);
+ unset($object->linkedObjectsFullLoaded);
+ //unset($object->lines[$i]->linked_objects); // This is the array to create linked object during create
unset($object->fields);
unset($object->oldline);
@@ -139,6 +141,7 @@ class DolibarrApi
unset($object->projet); // Should be fk_project
unset($object->project); // Should be fk_project
+ unset($object->fk_projet); // Should be fk_project
unset($object->author); // Should be fk_user_author
unset($object->timespent_old_duration);
unset($object->timespent_id);
@@ -160,8 +163,8 @@ class DolibarrApi
unset($object->statuts_short);
unset($object->statuts_logo);
unset($object->statuts_long);
- unset($object->labelStatus);
- unset($object->labelStatusShort);
+ //unset($object->labelStatus);
+ //unset($object->labelStatusShort);
unset($object->stats_propale);
unset($object->stats_commande);
diff --git a/htdocs/asset/admin/setup.php b/htdocs/asset/admin/setup.php
index 448473003b3..4f8f06ca160 100644
--- a/htdocs/asset/admin/setup.php
+++ b/htdocs/asset/admin/setup.php
@@ -524,7 +524,7 @@ if ($action == 'edit') {
include_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
print dolJSToSetRandomPassword($constname, 'generate_token'.$constname);
} elseif ($val['type'] == 'product') {
- if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) {
+ if (isModEnabled("product") || isModEnabled("service")) {
$selected = (empty($conf->global->$constname) ? '' : $conf->global->$constname);
$form->select_produits($selected, $constname, '', 0);
}
diff --git a/htdocs/asset/class/asset.class.php b/htdocs/asset/class/asset.class.php
index d144d95819b..55d2bc07593 100644
--- a/htdocs/asset/class/asset.class.php
+++ b/htdocs/asset/class/asset.class.php
@@ -195,7 +195,7 @@ class Asset extends CommonObject
if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid'])) {
$this->fields['rowid']['visible'] = 0;
}
- if (empty($conf->multicompany->enabled) && isset($this->fields['entity'])) {
+ if (!isModEnabled('multicompany') && isset($this->fields['entity'])) {
$this->fields['entity']['enabled'] = 0;
}
@@ -1171,10 +1171,10 @@ class Asset extends CommonObject
global $hidedetails, $hidedesc, $hideref;
$outputlangs = $langs;
$newlang = '';
- if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
+ if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
$newlang = GETPOST('lang_id', 'aZ09');
}
- if ($conf->global->MAIN_MULTILANGS && empty($newlang)) {
+ if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) {
$newlang = $this->thirdparty->default_lang;
}
if (!empty($newlang)) {
@@ -1234,10 +1234,10 @@ class Asset extends CommonObject
global $hidedetails, $hidedesc, $hideref;
$outputlangs = $langs;
$newlang = '';
- if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
+ if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
$newlang = GETPOST('lang_id', 'aZ09');
}
- if ($conf->global->MAIN_MULTILANGS && empty($newlang)) {
+ if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) {
$newlang = $this->thirdparty->default_lang;
}
if (!empty($newlang)) {
diff --git a/htdocs/asset/class/assetmodel.class.php b/htdocs/asset/class/assetmodel.class.php
index 6b75702278d..fb574e6ea18 100644
--- a/htdocs/asset/class/assetmodel.class.php
+++ b/htdocs/asset/class/assetmodel.class.php
@@ -160,7 +160,7 @@ class AssetModel extends CommonObject
if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid'])) {
$this->fields['rowid']['visible'] = 0;
}
- if (empty($conf->multicompany->enabled) && isset($this->fields['entity'])) {
+ if (!isModEnabled('multicompany') && isset($this->fields['entity'])) {
$this->fields['entity']['enabled'] = 0;
}
diff --git a/htdocs/barcode/codeinit.php b/htdocs/barcode/codeinit.php
index ff0ecbf0d01..fe8ff50cf96 100644
--- a/htdocs/barcode/codeinit.php
+++ b/htdocs/barcode/codeinit.php
@@ -355,7 +355,7 @@ if (isModEnabled('societe')) {
// For products
-if ($conf->product->enabled || $conf->product->service) {
+if (isModEnabled('product') || isModEnabled('service')) {
print '';
print ' ';
print ' ';
diff --git a/htdocs/barcode/printsheet.php b/htdocs/barcode/printsheet.php
index 763463d6fb8..c55db4ef2a1 100644
--- a/htdocs/barcode/printsheet.php
+++ b/htdocs/barcode/printsheet.php
@@ -203,25 +203,30 @@ if ($action == 'builddoc') {
$forceimgscalewidth = (empty($conf->global->BARCODE_FORCEIMGSCALEWIDTH) ? 1 : $conf->global->BARCODE_FORCEIMGSCALEWIDTH);
$forceimgscaleheight = (empty($conf->global->BARCODE_FORCEIMGSCALEHEIGHT) ? 1 : $conf->global->BARCODE_FORCEIMGSCALEHEIGHT);
- for ($i = 0; $i < $numberofsticker; $i++) {
- $arrayofrecords[] = array(
- 'textleft'=>$textleft,
- 'textheader'=>$textheader,
- 'textfooter'=>$textfooter,
- 'textright'=>$textright,
- 'code'=>$code,
- 'encoding'=>$encoding,
- 'is2d'=>$is2d,
- 'photo'=>$barcodeimage // Photo must be a file that exists with format supported by TCPDF
- );
+ $MAXSTICKERS = 1000;
+ if ($numberofsticker <= $MAXSTICKERS) {
+ for ($i = 0; $i < $numberofsticker; $i++) {
+ $arrayofrecords[] = array(
+ 'textleft'=>$textleft,
+ 'textheader'=>$textheader,
+ 'textfooter'=>$textfooter,
+ 'textright'=>$textright,
+ 'code'=>$code,
+ 'encoding'=>$encoding,
+ 'is2d'=>$is2d,
+ 'photo'=>$barcodeimage // Photo must be a file that exists with format supported by TCPDF
+ );
+ }
+ } else {
+ $mesg = $langs->trans("ErrorQuantityIsLimitedTo", $MAXSTICKERS);
+ $error++;
}
}
$i++;
- $mesg = '';
// Build and output PDF
- if ($mode == 'label') {
+ if (!$error && $mode == 'label') {
if (!count($arrayofrecords)) {
$mesg = $langs->trans("ErrorRecordNotFound");
}
@@ -240,7 +245,7 @@ if ($action == 'builddoc') {
}
}
- if ($result <= 0 || $mesg) {
+ if ($result <= 0 || $mesg || $error) {
if (empty($mesg)) {
$mesg = 'Error '.$result;
}
@@ -272,8 +277,6 @@ print ' ';
print ''.$langs->trans("PageToGenerateBarCodeSheets", $langs->transnoentitiesnoconv("BuildPageToPrint")).' ';
print ' ';
-dol_htmloutput_errors($mesg);
-
//print img_picto('','puce').' '.$langs->trans("PrintsheetForOneBarCode").' ';
//print ' ';
diff --git a/htdocs/blockedlog/class/blockedlog.class.php b/htdocs/blockedlog/class/blockedlog.class.php
index ea5069cb840..3ab2b63ad3f 100644
--- a/htdocs/blockedlog/class/blockedlog.class.php
+++ b/htdocs/blockedlog/class/blockedlog.class.php
@@ -151,7 +151,7 @@ class BlockedLog
}
/* Supplier
- if (!empty($conf->fournisseur->enabled)) {
+ if (isModEnabled("fournisseur")) {
$this->trackedevents['BILL_SUPPLIER_VALIDATE']='BlockedLogSupplierBillValidate';
$this->trackedevents['BILL_SUPPLIER_DELETE']='BlockedLogSupplierBillDelete';
$this->trackedevents['BILL_SUPPLIER_SENTBYMAIL']='BlockedLogSupplierBillSentByEmail'; // Trigger key does not exists, we want just into array to list it as done
@@ -184,7 +184,7 @@ class BlockedLog
$this->trackedevents['MEMBER_SUBSCRIPTION_MODIFY'] = 'logMEMBER_SUBSCRIPTION_MODIFY';
$this->trackedevents['MEMBER_SUBSCRIPTION_DELETE'] = 'logMEMBER_SUBSCRIPTION_DELETE';
}
- if (!empty($conf->banque->enabled)) {
+ if (isModEnabled("banque")) {
$this->trackedevents['PAYMENT_VARIOUS_CREATE'] = 'logPAYMENT_VARIOUS_CREATE';
$this->trackedevents['PAYMENT_VARIOUS_MODIFY'] = 'logPAYMENT_VARIOUS_MODIFY';
$this->trackedevents['PAYMENT_VARIOUS_DELETE'] = 'logPAYMENT_VARIOUS_DELETE';
@@ -361,11 +361,11 @@ class BlockedLog
$this->amounts = $amounts;
// date
if ($object->element == 'payment' || $object->element == 'payment_supplier') {
- $this->date_object = $object->datepaye;
+ $this->date_object = empty($object->datepaye) ? $object->date : $object->datepaye;
} elseif ($object->element == 'payment_salary') {
$this->date_object = $object->datev;
} elseif ($object->element == 'payment_donation' || $object->element == 'payment_various') {
- $this->date_object = $object->datepaid ? $object->datepaid : $object->datep;
+ $this->date_object = empty($object->datepaid) ? $object->datep : $object->datepaid;
} elseif ($object->element == 'subscription') {
$this->date_object = $object->dateh;
} elseif ($object->element == 'cashcontrol') {
@@ -527,7 +527,7 @@ class BlockedLog
$totalamount = 0;
- // Loop on each invoice payment amount
+ // Loop on each invoice payment amount (payment_part)
if (is_array($object->amounts) && !empty($object->amounts)) {
$paymentpartnumber = 0;
foreach ($object->amounts as $objid => $amount) {
diff --git a/htdocs/bom/bom_card.php b/htdocs/bom/bom_card.php
index ee619a589e3..f088ae34050 100644
--- a/htdocs/bom/bom_card.php
+++ b/htdocs/bom/bom_card.php
@@ -181,24 +181,10 @@ if (empty($reshook)) {
}
if (!$error) {
- $bomline = new BOMLine($db);
- $bomline->fk_bom = $id;
- $bomline->fk_product = $idprod;
- $bomline->fk_bom_child = $bom_child_id;
- $bomline->qty = $qty;
- $bomline->qty_frozen = (int) $qty_frozen;
- $bomline->disable_stock_change = (int) $disable_stock_change;
- $bomline->efficiency = $efficiency;
+ $result = $object->addLine($idprod, $qty, $qty_frozen, $disable_stock_change, $efficiency, -1, $bom_child_id, null);
- // Rang to use
- $rangmax = $object->line_max(0);
- $ranktouse = $rangmax + 1;
-
- $bomline->position = ($ranktouse + 1);
-
- $result = $bomline->create($user);
if ($result <= 0) {
- setEventMessages($bomline->error, $bomline->errors, 'errors');
+ setEventMessages($object->error, $object->errors, 'errors');
$action = '';
} else {
unset($_POST['idprod']);
@@ -207,13 +193,11 @@ if (empty($reshook)) {
unset($_POST['disable_stock_change']);
$object->fetchLines();
-
- $object->calculateCosts();
}
}
}
- // Add line
+ // Update line
if ($action == 'updateline' && $user->rights->bom->write) {
$langs->load('errors');
$error = 0;
@@ -229,26 +213,23 @@ if (empty($reshook)) {
$error++;
}
- $bomline = new BOMLine($db);
- $bomline->fetch($lineid);
- $bomline->qty = $qty;
- $bomline->qty_frozen = (int) $qty_frozen;
- $bomline->disable_stock_change = (int) $disable_stock_change;
- $bomline->efficiency = $efficiency;
+ if (!$error) {
+ $bomline = new BOMLine($db);
+ $bomline->fetch($lineid);
- $result = $bomline->update($user);
- if ($result <= 0) {
- setEventMessages($bomline->error, $bomline->errors, 'errors');
- $action = '';
- } else {
- unset($_POST['idprod']);
- unset($_POST['qty']);
- unset($_POST['qty_frozen']);
- unset($_POST['disable_stock_change']);
+ $result = $object->updateLine($lineid, $qty, (int) $qty_frozen, (int) $disable_stock_change, $efficiency, $bomline->position, $bomline->import_key);
- $object->fetchLines();
+ if ($result <= 0) {
+ setEventMessages($object->error, $object->errors, 'errors');
+ $action = '';
+ } else {
+ unset($_POST['idprod']);
+ unset($_POST['qty']);
+ unset($_POST['qty_frozen']);
+ unset($_POST['disable_stock_change']);
- $object->calculateCosts();
+ $object->fetchLines();
+ }
}
}
}
diff --git a/htdocs/bom/class/api_boms.class.php b/htdocs/bom/class/api_boms.class.php
index 91af888ffd8..fb7d175a229 100644
--- a/htdocs/bom/class/api_boms.class.php
+++ b/htdocs/bom/class/api_boms.class.php
@@ -2,6 +2,7 @@
/* Copyright (C) 2015 Jean-François Ferry
* Copyright (C) 2019 Maxime Kohlhaas
* Copyright (C) 2020 Frédéric France
+ * Copyright (C) 2022 Christian Humpel
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -279,6 +280,177 @@ class Boms extends DolibarrApi
);
}
+ /**
+ * Get lines of an BOM
+ *
+ * @param int $id Id of BOM
+ *
+ * @url GET {id}/lines
+ *
+ * @return array
+ */
+ public function getLines($id)
+ {
+ if (!DolibarrApiAccess::$user->rights->bom->read) {
+ throw new RestException(401);
+ }
+
+ $result = $this->bom->fetch($id);
+ if (!$result) {
+ throw new RestException(404, 'BOM not found');
+ }
+
+ if (!DolibarrApi::_checkAccessToResource('bom_bom', $this->bom->id)) {
+ throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
+ }
+ $this->bom->getLinesArray();
+ $result = array();
+ foreach ($this->bom->lines as $line) {
+ array_push($result, $this->_cleanObjectDatas($line));
+ }
+ return $result;
+ }
+
+ /**
+ * Add a line to given BOM
+ *
+ * @param int $id Id of BOM to update
+ * @param array $request_data BOMLine data
+ *
+ * @url POST {id}/lines
+ *
+ * @return int
+ */
+ public function postLine($id, $request_data = null)
+ {
+ if (!DolibarrApiAccess::$user->rights->bom->write) {
+ throw new RestException(401);
+ }
+
+ $result = $this->bom->fetch($id);
+ if (!$result) {
+ throw new RestException(404, 'BOM not found');
+ }
+
+ if (!DolibarrApi::_checkAccessToResource('bom_bom', $this->bom->id)) {
+ throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
+ }
+
+ $request_data = (object) $request_data;
+
+ $updateRes = $this->bom->addLine(
+ $request_data->fk_product,
+ $request_data->qty,
+ $request_data->qty_frozen,
+ $request_data->disable_stock_change,
+ $request_data->efficiency,
+ $request_data->position,
+ $request_data->fk_bom_child,
+ $request_data->import_key
+ );
+
+ if ($updateRes > 0) {
+ return $updateRes;
+ } else {
+ throw new RestException(400, $this->bom->error);
+ }
+ }
+
+ /**
+ * Update a line to given BOM
+ *
+ * @param int $id Id of BOM to update
+ * @param int $lineid Id of line to update
+ * @param array $request_data BOMLine data
+ *
+ * @url PUT {id}/lines/{lineid}
+ *
+ * @return array|bool
+ */
+ public function putLine($id, $lineid, $request_data = null)
+ {
+ if (!DolibarrApiAccess::$user->rights->bom->write) {
+ throw new RestException(401);
+ }
+
+ $result = $this->bom->fetch($id);
+ if (!$result) {
+ throw new RestException(404, 'BOM not found');
+ }
+
+ if (!DolibarrApi::_checkAccessToResource('bom_bom', $this->bom->id)) {
+ throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
+ }
+
+ $request_data = (object) $request_data;
+
+ $updateRes = $this->bom->updateLine(
+ $lineid,
+ $request_data->qty,
+ $request_data->qty_frozen,
+ $request_data->disable_stock_change,
+ $request_data->efficiency,
+ $request_data->position,
+ $request_data->import_key
+ );
+
+ if ($updateRes > 0) {
+ $result = $this->get($id);
+ unset($result->line);
+ return $this->_cleanObjectDatas($result);
+ }
+ return false;
+ }
+
+ /**
+ * Delete a line to given BOM
+ *
+ *
+ * @param int $id Id of BOM to update
+ * @param int $lineid Id of line to delete
+ *
+ * @url DELETE {id}/lines/{lineid}
+ *
+ * @return int
+ *
+ * @throws RestException 401
+ * @throws RestException 404
+ * @throws RestException 500
+ */
+ public function deleteLine($id, $lineid)
+ {
+ if (!DolibarrApiAccess::$user->rights->bom->write) {
+ throw new RestException(401);
+ }
+
+ $result = $this->bom->fetch($id);
+ if (!$result) {
+ throw new RestException(404, 'BOM not found');
+ }
+
+ if (!DolibarrApi::_checkAccessToResource('bom_bom', $this->bom->id)) {
+ throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
+ }
+
+ //Check the rowid is a line of current bom object
+ $lineIdIsFromObject = false;
+ foreach ($this->bom->lines as $bl) {
+ if ($bl->id == $lineid) {
+ $lineIdIsFromObject = true;
+ break;
+ }
+ }
+ if (!$lineIdIsFromObject) {
+ throw new RestException(500, 'Line to delete (rowid: '.$lineid.') is not a line of BOM (id: '.$this->bom->id.')');
+ }
+
+ $updateRes = $this->bom->deleteline(DolibarrApiAccess::$user, $lineid);
+ if ($updateRes > 0) {
+ return $this->get($id);
+ } else {
+ throw new RestException(405, $this->bom->error);
+ }
+ }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
/**
diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php
index 8adcac855c2..576d8f5fb09 100644
--- a/htdocs/bom/class/bom.class.php
+++ b/htdocs/bom/class/bom.class.php
@@ -239,7 +239,7 @@ class BOM extends CommonObject
if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid'])) {
$this->fields['rowid']['visible'] = 0;
}
- if (empty($conf->multicompany->enabled) && isset($this->fields['entity'])) {
+ if (!isModEnabled('multicompany') && isset($this->fields['entity'])) {
$this->fields['entity']['enabled'] = 0;
}
@@ -502,6 +502,207 @@ class BOM extends CommonObject
//return $this->deleteCommon($user, $notrigger, 1);
}
+ /**
+ * Add an BOM line into database (linked to BOM)
+ *
+ * @param int $fk_product Id of product
+ * @param float $qty Quantity
+ * @param int $qty_frozen Frozen quantity
+ * @param int $disable_stock_change Disable stock change on using in MO
+ * @param float $efficiency Efficiency in MO
+ * @param int $position Position of BOM-Line in BOM-Lines
+ * @param int $fk_bom_child Id of BOM Child
+ * @param string $import_key Import Key
+ * @return int <0 if KO, Id of created object if OK
+ */
+ public function addLine($fk_product, $qty, $qty_frozen = 0, $disable_stock_change = 0, $efficiency = 1.0, $position = -1, $fk_bom_child = null, $import_key = null)
+ {
+ global $mysoc, $conf, $langs, $user;
+
+ $logtext = "::addLine bomid=$this->id, qty=$qty, fk_product=$fk_product, qty_frozen=$qty_frozen, disable_stock_change=$disable_stock_change, efficiency=$efficiency";
+ $logtext .= ", fk_bom_child=$fk_bom_child, import_key=$import_key";
+ dol_syslog(get_class($this).$logtext, LOG_DEBUG);
+
+ if ($this->statut == self::STATUS_DRAFT) {
+ include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
+
+ // Clean parameters
+ if (empty($qty)) {
+ $qty = 0;
+ }
+ if (empty($qty_frozen)) {
+ $qty_frozen = 0;
+ }
+ if (empty($disable_stock_change)) {
+ $disable_stock_change = 0;
+ }
+ if (empty($efficiency)) {
+ $efficiency = 1.0;
+ }
+ if (empty($fk_bom_child)) {
+ $fk_bom_child = null;
+ }
+ if (empty($import_key)) {
+ $import_key = null;
+ }
+ if (empty($position)) {
+ $position = -1;
+ }
+
+ $qty = price2num($qty);
+ $efficiency = price2num($efficiency);
+ $position = price2num($position);
+
+ $this->db->begin();
+
+ // Rank to use
+ $rangMax = $this->line_max();
+ $rankToUse = $position;
+ if ($rankToUse <= 0 or $rankToUse > $rangMax) { // New line after existing lines
+ $rankToUse = $rangMax + 1;
+ } else { // New line between the existing lines
+ foreach ($this->lines as $bl) {
+ if ($bl->position >= $rankToUse) {
+ $bl->position++;
+ $bl->update($user);
+ }
+ }
+ }
+
+ // Insert line
+ $this->line = new BOMLine($this->db);
+
+ $this->line->context = $this->context;
+
+ $this->line->fk_bom = $this->id;
+ $this->line->fk_product = $fk_product;
+ $this->line->qty = $qty;
+ $this->line->qty_frozen = $qty_frozen;
+ $this->line->disable_stock_change = $disable_stock_change;
+ $this->line->efficiency = $efficiency;
+ $this->line->fk_bom_child = $fk_bom_child;
+ $this->line->import_key = $import_key;
+ $this->line->position = $rankToUse;
+
+ $result = $this->line->create($user);
+
+ if ($result > 0) {
+ $this->calculateCosts();
+ $this->db->commit();
+ return $result;
+ } else {
+ $this->error = $this->line->error;
+ dol_syslog(get_class($this)."::addLine error=".$this->error, LOG_ERR);
+ $this->db->rollback();
+ return -2;
+ }
+ } else {
+ dol_syslog(get_class($this)."::addLine status of BOM must be Draft to allow use of ->addLine()", LOG_ERR);
+ return -3;
+ }
+ }
+
+ /**
+ * Update an BOM line into database
+ *
+ * @param int $rowid Id of line to update
+ * @param float $qty Quantity
+ * @param int $qty_frozen Frozen quantity
+ * @param int $disable_stock_change Disable stock change on using in MO
+ * @param float $efficiency Efficiency in MO
+ * @param int $position Position of BOM-Line in BOM-Lines
+ * @param string $import_key Import Key
+ * @return int <0 if KO, Id of updated BOM-Line if OK
+ */
+ public function updateLine($rowid, $qty, $qty_frozen = 0, $disable_stock_change = 0, $efficiency = 1.0, $position = -1, $import_key = null)
+ {
+ global $mysoc, $conf, $langs, $user;
+
+ $logtext = "::updateLine bomid=$this->id, qty=$qty, qty_frozen=$qty_frozen, disable_stock_change=$disable_stock_change, efficiency=$efficiency";
+ $logtext .= ", import_key=$import_key";
+ dol_syslog(get_class($this).$logtext, LOG_DEBUG);
+
+ if ($this->statut == self::STATUS_DRAFT) {
+ include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
+
+ // Clean parameters
+ if (empty($qty)) {
+ $qty = 0;
+ }
+ if (empty($qty_frozen)) {
+ $qty_frozen = 0;
+ }
+ if (empty($disable_stock_change)) {
+ $disable_stock_change = 0;
+ }
+ if (empty($efficiency)) {
+ $efficiency = 1.0;
+ }
+ if (empty($import_key)) {
+ $import_key = null;
+ }
+ if (empty($position)) {
+ $position = -1;
+ }
+
+ $qty = price2num($qty);
+ $efficiency = price2num($efficiency);
+ $position = price2num($position);
+
+ $this->db->begin();
+
+ //Fetch current line from the database and then clone the object and set it in $oldline property
+ $line = new BOMLine($this->db);
+ $line->fetch($rowid);
+ $line->fetch_optionals();
+
+ $staticLine = clone $line;
+ $line->oldcopy = $staticLine;
+ $this->line = $line;
+ $this->line->context = $this->context;
+
+ // Rank to use
+ $rankToUse = (int) $position;
+ if ($rankToUse != $line->oldcopy->position) { // check if position have a new value
+ foreach ($this->lines as $bl) {
+ if ($bl->position >= $rankToUse AND $bl->position < ($line->oldcopy->position + 1)) { // move rank up
+ $bl->position++;
+ $bl->update($user);
+ }
+ if ($bl->position <= $rankToUse AND $bl->position > ($line->oldcopy->position)) { // move rank down
+ $bl->position--;
+ $bl->update($user);
+ }
+ }
+ }
+
+
+ $this->line->fk_bom = $this->id;
+ $this->line->qty = $qty;
+ $this->line->qty_frozen = $qty_frozen;
+ $this->line->disable_stock_change = $disable_stock_change;
+ $this->line->efficiency = $efficiency;
+ $this->line->import_key = $import_key;
+ $this->line->position = $rankToUse;
+
+ $result = $this->line->update($user);
+
+ if ($result > 0) {
+ $this->calculateCosts();
+ $this->db->commit();
+ return $result;
+ } else {
+ $this->error = $this->line->error;
+ dol_syslog(get_class($this)."::addLine error=".$this->error, LOG_ERR);
+ $this->db->rollback();
+ return -2;
+ }
+ } else {
+ dol_syslog(get_class($this)."::addLine status of BOM must be Draft to allow use of ->addLine()", LOG_ERR);
+ return -3;
+ }
+ }
+
/**
* Delete a line of object in database
*
@@ -517,7 +718,38 @@ class BOM extends CommonObject
return -2;
}
- return $this->deleteLineCommon($user, $idline, $notrigger);
+ $this->db->begin();
+
+ //Fetch current line from the database and then clone the object and set it in $oldline property
+ $line = new BOMLine($this->db);
+ $line->fetch($idline);
+ $line->fetch_optionals();
+
+ $staticLine = clone $line;
+ $line->oldcopy = $staticLine;
+ $this->line = $line;
+ $this->line->context = $this->context;
+
+ $result = $this->line->delete($user, $notrigger);
+
+ //Positions (rank) reordering
+ foreach ($this->lines as $bl) {
+ if ($bl->position > ($line->oldcopy->position)) { // move rank down
+ $bl->position--;
+ $bl->update($user);
+ }
+ }
+
+ if ($result > 0) {
+ $this->calculateCosts();
+ $this->db->commit();
+ return $result;
+ } else {
+ $this->error = $this->line->error;
+ dol_syslog(get_class($this)."::addLine error=".$this->error, LOG_ERR);
+ $this->db->rollback();
+ return -2;
+ }
}
/**
@@ -1293,7 +1525,7 @@ class BOMLine extends CommonObjectLine
if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid'])) {
$this->fields['rowid']['visible'] = 0;
}
- if (empty($conf->multicompany->enabled) && isset($this->fields['entity'])) {
+ if (!isModEnabled('multicompany') && isset($this->fields['entity'])) {
$this->fields['entity']['enabled'] = 0;
}
diff --git a/htdocs/bom/tpl/objectline_create.tpl.php b/htdocs/bom/tpl/objectline_create.tpl.php
index 0a3a3b34e7a..e895d534fac 100644
--- a/htdocs/bom/tpl/objectline_create.tpl.php
+++ b/htdocs/bom/tpl/objectline_create.tpl.php
@@ -87,7 +87,7 @@ $coldisplay++;
print '';
// Predefined product/service
-if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) {
+if (isModEnabled("product") || isModEnabled("service")) {
if (!empty($conf->global->BOM_SUB_BOM)) {
print $langs->trans("Product");
}
diff --git a/htdocs/categories/admin/categorie.php b/htdocs/categories/admin/categorie.php
index 02e6892b571..f7022477d97 100644
--- a/htdocs/categories/admin/categorie.php
+++ b/htdocs/categories/admin/categorie.php
@@ -67,7 +67,7 @@ if (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) {
* View
*/
-$help_url = 'EN:Module Categories|FR:Module Catégories|ES:Módulo Categorías';
+$help_url = 'EN:Module Categories|FR:Module Catégories|ES:Módulo Categorías|DE:Modul_Kategorien';
$linkback = ''.$langs->trans("BackToModuleList").' ';
llxHeader('', $langs->trans("Categories"), $help_url);
diff --git a/htdocs/categories/admin/categorie_extrafields.php b/htdocs/categories/admin/categorie_extrafields.php
index 7dbf31835ca..2a1879135d6 100644
--- a/htdocs/categories/admin/categorie_extrafields.php
+++ b/htdocs/categories/admin/categorie_extrafields.php
@@ -63,7 +63,7 @@ require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php';
$textobject = $langs->transnoentitiesnoconv("Categories");
-$help_url = 'EN:Module Categories|FR:Module Catégories|ES:Módulo Categorías';
+$help_url = 'EN:Module Categories|FR:Module Catégories|ES:Módulo Categorías|DE:Modul_Kategorien';
llxHeader('', $langs->trans("Categories"), $help_url);
diff --git a/htdocs/categories/class/api_categories.class.php b/htdocs/categories/class/api_categories.class.php
index fcac14f1337..0a618974024 100644
--- a/htdocs/categories/class/api_categories.class.php
+++ b/htdocs/categories/class/api_categories.class.php
@@ -305,7 +305,8 @@ class Categories extends DolibarrApi
Categorie::TYPE_CUSTOMER,
Categorie::TYPE_SUPPLIER,
Categorie::TYPE_MEMBER,
- Categorie::TYPE_PROJECT
+ Categorie::TYPE_PROJECT,
+ Categorie::TYPE_KNOWLEDGEMANAGEMENT
])) {
throw new RestException(401);
}
@@ -322,6 +323,8 @@ class Categories extends DolibarrApi
throw new RestException(401);
} elseif ($type == Categorie::TYPE_PROJECT && !DolibarrApiAccess::$user->rights->projet->lire) {
throw new RestException(401);
+ } elseif ($type == Categorie::TYPE_KNOWLEDGEMANAGEMENT && !DolibarrApiAccess::$user->rights->knowledgemanagement->knowledgerecord->read) {
+ throw new RestException(401);
}
$categories = $this->category->getListForItem($id, $type, $sortfield, $sortorder, $limit, $page);
diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php
index 8d26b5583d4..b222f70110a 100644
--- a/htdocs/categories/class/categorie.class.php
+++ b/htdocs/categories/class/categorie.class.php
@@ -703,13 +703,14 @@ class Categorie extends CommonObject
$type = $obj->element;
}
+ dol_syslog(get_class($this).'::add_type', LOG_DEBUG);
+
$this->db->begin();
$sql = "INSERT INTO ".MAIN_DB_PREFIX."categorie_".(empty($this->MAP_CAT_TABLE[$type]) ? $type : $this->MAP_CAT_TABLE[$type]);
$sql .= " (fk_categorie, fk_".(empty($this->MAP_CAT_FK[$type]) ? $type : $this->MAP_CAT_FK[$type]).")";
$sql .= " VALUES (".((int) $this->id).", ".((int) $obj->id).")";
- dol_syslog(get_class($this).'::add_type', LOG_DEBUG);
if ($this->db->query($sql)) {
if (!empty($conf->global->CATEGORIE_RECURSIV_ADD)) {
$sql = 'SELECT fk_parent FROM '.MAIN_DB_PREFIX.'categorie';
diff --git a/htdocs/categories/traduction.php b/htdocs/categories/traduction.php
index 512f25a67e2..69a27c5cff5 100644
--- a/htdocs/categories/traduction.php
+++ b/htdocs/categories/traduction.php
@@ -20,9 +20,9 @@
*/
/**
- * \file htdocs/product/traduction.php
- * \ingroup product
- * \brief Page of translation of products
+ * \file htdocs/categories/traduction.php
+ * \ingroup categories
+ * \brief Page of translation of categories
*/
require '../main.inc.php';
@@ -35,8 +35,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
// Load translation files required by the page
$langs->loadLangs(array('categories', 'languages'));
-$id = GETPOST('id', 'int');
-$label = GETPOST('label', 'alpha');
+$id = GETPOST('id', 'int');
+$label = GETPOST('label', 'alpha');
$action = GETPOST('action', 'aZ09');
$cancel = GETPOST('cancel', 'alpha');
@@ -56,21 +56,23 @@ if ($result <= 0) {
$type = $object->type;
if (is_numeric($type)) {
- $type = Categorie::$MAP_ID_TO_CODE[$type]; // For backward compatibility
+ $type = Categorie::$MAP_ID_TO_CODE[$type]; // For backward compatibility
}
+
/*
* Actions
*/
+
$error = 0;
-// retour a l'affichage des traduction si annulation
+// return to translation view if cancelled
if ($cancel == $langs->trans("Cancel")) {
$action = '';
}
-// Validation de l'ajout
+// validation of addition
if ($action == 'vadd' &&
$cancel != $langs->trans("Cancel") &&
($user->rights->categorie->creer)) {
@@ -94,7 +96,7 @@ $cancel != $langs->trans("Cancel") &&
}
if (!$error) {
- // update de l'objet
+ // update the object
if ($forcelangprod == $current_lang) {
$object->label = $libelle;
$object->description = dol_htmlcleanlastbr($desc);
@@ -103,7 +105,7 @@ $cancel != $langs->trans("Cancel") &&
$object->multilangs[$forcelangprod]["description"] = dol_htmlcleanlastbr($desc);
}
- // sauvegarde en base
+ // save in base / sauvegarde en base
$res = $object->setMultiLangs($user);
if ($res < 0) {
$error++;
@@ -119,14 +121,14 @@ $cancel != $langs->trans("Cancel") &&
}
}
-// Validation de l'edition
+// validation of the edition
if ($action == 'vedit' &&
$cancel != $langs->trans("Cancel") &&
($user->rights->categorie->creer)) {
$object->fetch($id);
$current_lang = $langs->getDefaultLang();
- foreach ($object->multilangs as $key => $value) { // enregistrement des nouvelles valeurs dans l'objet
+ foreach ($object->multilangs as $key => $value) { // recording of new values in the object
$libelle = GETPOST('libelle-'.$key, 'alpha');
$desc = GETPOST('desc-'.$key);
@@ -164,7 +166,7 @@ $cancel != $langs->trans("Cancel") &&
* View
*/
-$form = new Form($db);
+$form = new Form($db);
$formadmin = new FormAdmin($db);
$formother = new FormOther($db);
@@ -223,10 +225,10 @@ print dol_get_fiche_end();
-
/*
* Action bar
*/
+
print "\n\n";
if ($action == '') {
@@ -243,7 +245,7 @@ print "\n
\n";
if ($action == 'edit') {
- //WYSIWYG Editor
+ // WYSIWYG Editor
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
print '';
@@ -260,6 +262,7 @@ if ($action == 'edit') {
// Label
$libelle = (GETPOST('libelle-'.$key, 'alpha') ? GETPOST('libelle-'.$key, 'alpha') : $object->multilangs[$key]['label']);
print ''.$langs->trans('Label').' ';
+
// Desc
$desc = (GETPOST('desc-'.$key) ? GETPOST('desc-'.$key) : $object->multilangs[$key]['description']);
print ''.$langs->trans('Description').' ';
diff --git a/htdocs/categories/viewcat.php b/htdocs/categories/viewcat.php
index 5450127bff3..5405b33d994 100644
--- a/htdocs/categories/viewcat.php
+++ b/htdocs/categories/viewcat.php
@@ -1030,7 +1030,7 @@ if ($type == Categorie::TYPE_PROJECT) {
}
// List of users
-if ($type == Categorie::TYPE_USER) {
+if ($type == Categorie::TYPE_USER && $user->hasRight("user", "user", "read")) {
require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
$users = $object->getObjectsInCateg($type);
@@ -1099,6 +1099,9 @@ if ($type == Categorie::TYPE_USER) {
print ''."\n";
}
+} else {
+ print_barre_liste($langs->trans("Users"), null, $_SERVER["PHP_SELF"], '', '', '', '', '', '', 'user');
+ accessforbidden($langs->trans("NotEnoughPermissions"), 0, 0);
}
diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php
index ed25d89db67..ed963ddd7f2 100644
--- a/htdocs/comm/action/card.php
+++ b/htdocs/comm/action/card.php
@@ -538,7 +538,7 @@ if (empty($reshook) && $action == 'add') {
$error++;
}
// End date
- $repeateventlimitdate = dol_mktime('23', '59', '59', GETPOSTISSET("limitmonth", 'int') ? GETPOST("limitmonth", 'int') : 01, GETPOSTISSET("limitday", 'int') ? GETPOST("limitday", 'int') : 01, GETPOSTISSET("limityear", 'int') && GETPOST("limityear", 'int') < 2100 ? GETPOST("limityear", 'int') : 2100, $tzforfullday ? $tzforfullday : 'tzuser');
+ $repeateventlimitdate = dol_mktime(23, 59, 59, GETPOSTISSET("limitmonth") ? GETPOST("limitmonth", 'int') : 1, GETPOSTISSET("limitday") ? GETPOST("limitday", 'int') : 1, GETPOSTISSET("limityear") && GETPOST("limityear", 'int') < 2100 ? GETPOST("limityear", 'int') : 2100, $tzforfullday ? $tzforfullday : 'tzuser');
// Set date of end of event
$deltatime = num_between_day($object->datep, $datep);
$datef = dol_time_plus_duree($datef, $deltatime, 'd');
@@ -677,7 +677,7 @@ if (empty($reshook) && $action == 'update') {
$object->fetch($id);
$object->fetch_optionals();
$object->fetch_userassigned();
- $object->oldcopy = clone $object;
+ $object->oldcopy = dol_clone($object);
// Clean parameters
if ($fulldayevent) {
@@ -927,7 +927,7 @@ if (empty($reshook) && $action == 'confirm_delete' && GETPOST("confirm") == 'yes
$object->fetch($id);
$object->fetch_optionals();
$object->fetch_userassigned();
- $object->oldcopy = clone $object;
+ $object->oldcopy = dol_clone($object);
if ($user->rights->agenda->myactions->delete
|| $user->rights->agenda->allactions->delete) {
@@ -1378,7 +1378,7 @@ if ($action == 'create') {
print '';
- if (!empty($conf->societe->enabled)) {
+ if (isModEnabled("societe")) {
// Related company
print ''.$langs->trans("ActionOnCompany").' ';
if (GETPOST('socid', 'int') > 0) {
@@ -1891,7 +1891,7 @@ if ($id > 0) {
print '';
- if (!empty($conf->societe->enabled)) {
+ if (isModEnabled("societe")) {
// Related company
print ''.$langs->trans("ActionOnCompany").' ';
print '';
@@ -2300,7 +2300,7 @@ if ($id > 0) {
print '
';
print '';
- if (!empty($conf->societe->enabled)) {
+ if (isModEnabled("societe")) {
// Related company
print ''.$langs->trans("ActionOnCompany").' '.($object->thirdparty->id ? $object->thirdparty->getNomUrl(1) : (''.$langs->trans("None").' '));
if (is_object($object->thirdparty) && $object->thirdparty->id > 0 && $object->type_code == 'AC_TEL') {
diff --git a/htdocs/comm/action/class/actioncommreminder.class.php b/htdocs/comm/action/class/actioncommreminder.class.php
index ff242430b0a..eb0d464777a 100644
--- a/htdocs/comm/action/class/actioncommreminder.class.php
+++ b/htdocs/comm/action/class/actioncommreminder.class.php
@@ -149,7 +149,7 @@ class ActionCommReminder extends CommonObject
if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) {
$this->fields['rowid']['visible'] = 0;
}
- if (empty($conf->multicompany->enabled)) {
+ if (!isModEnabled('multicompany')) {
$this->fields['entity']['enabled'] = 0;
}
}
diff --git a/htdocs/comm/action/class/api_agendaevents.class.php b/htdocs/comm/action/class/api_agendaevents.class.php
index 2d868e9bfaa..e7745f1d5fd 100644
--- a/htdocs/comm/action/class/api_agendaevents.class.php
+++ b/htdocs/comm/action/class/api_agendaevents.class.php
@@ -129,19 +129,19 @@ class AgendaEvents extends DolibarrApi
}
$sql = "SELECT t.id as rowid";
- if (!empty($conf->societe->enabled)) {
+ if (isModEnabled("societe")) {
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) {
$sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects)
}
}
$sql .= " FROM ".MAIN_DB_PREFIX."actioncomm as t";
- if (!empty($conf->societe->enabled)) {
+ if (isModEnabled("societe")) {
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale
}
}
$sql .= ' WHERE t.entity IN ('.getEntity('agenda').')';
- if (!empty($conf->societe->enabled)) {
+ if (isModEnabled("societe")) {
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) {
$sql .= " AND t.fk_soc = sc.fk_soc";
}
diff --git a/htdocs/comm/action/class/cactioncomm.class.php b/htdocs/comm/action/class/cactioncomm.class.php
index db62dfe6a9f..db9f28c7763 100644
--- a/htdocs/comm/action/class/cactioncomm.class.php
+++ b/htdocs/comm/action/class/cactioncomm.class.php
@@ -204,19 +204,21 @@ class CActionComm
if ($obj->module == 'order' && !empty($conf->commande->enabled) && empty($user->rights->commande->lire)) {
$qualified = 1;
}
- if ($obj->module == 'propal' && !empty($conf->propal->enabled) && !empty($user->rights->propale->lire)) {
+ if ($obj->module == 'propal' && isModEnabled("propal") && !empty($user->rights->propale->lire)) {
$qualified = 1;
}
- if ($obj->module == 'invoice_supplier' && ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && !empty($user->rights->fournisseur->facture->lire)) || (!empty($conf->rights->supplier_invoice->enabled) && !empty($user->rights->supplier_invoice->lire)))) {
+ if ($obj->module == 'invoice_supplier' && ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && !empty($user->rights->fournisseur->facture->lire)) || (!empty($conf->rights->supplier_invoice->enabled) && !empty($user->rights->supplier_invoice->lire)))) {
$qualified = 1;
}
- if ($obj->module == 'order_supplier' && ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && !empty($user->rights->fournisseur->commande->lire)) || (empty($conf->rights->supplier_order->enabled) && !empty($user->rights->supplier_order->lire)))) {
+ if ($obj->module == 'order_supplier' && ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && !empty($user->rights->fournisseur->commande->lire)) || (empty($conf->rights->supplier_order->enabled) && !empty($user->rights->supplier_order->lire)))) {
$qualified = 1;
}
- if ($obj->module == 'shipping' && !empty($conf->expedition->enabled) && !empty($user->rights->expedition->lire)) {
+ if ($obj->module == 'shipping' && isModEnabled("expedition") && !empty($user->rights->expedition->lire)) {
$qualified = 1;
}
- if (preg_split("/@/", $obj->module, -1)[1] == 'eventorganization' && !empty($conf->eventorganization->enabled)) {
+ // For case module = 'myobject@eventorganization'
+ $tmparray = preg_split("/@/", $obj->module, -1);
+ if (count($tmparray) > 1 && $tmparray[1] == 'eventorganization' && !empty($conf->eventorganization->enabled)) {
$qualified = 1;
}
// For the generic case with type = 'module...' and module = 'myobject@mymodule'
diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php
index 2afad30c454..7fb2f0f129e 100644
--- a/htdocs/comm/action/index.php
+++ b/htdocs/comm/action/index.php
@@ -212,7 +212,7 @@ if (GETPOST("viewperuser", 'alpha') || $mode == 'show_peruser') {
$event->fetch($actionid);
$event->fetch_optionals();
$event->fetch_userassigned();
- $event->oldcopy = clone $event;
+ $event->oldcopy = dol_clone($event);
$result = $event->delete();
}
@@ -757,9 +757,10 @@ if ($type) {
$sql .= " AND ca.id = ".((int) $type);
}
if ($status == '0') {
+ // To do (not started)
$sql .= " AND a.percent = 0";
}
-if ($status == '-1' || $status == 'na') {
+if ($status == 'na') {
// Not applicable
$sql .= " AND a.percent = -1";
}
diff --git a/htdocs/comm/action/pertype.php b/htdocs/comm/action/pertype.php
index 85eb355f2b6..d21b20bbfaf 100644
--- a/htdocs/comm/action/pertype.php
+++ b/htdocs/comm/action/pertype.php
@@ -189,7 +189,7 @@ if ($action == 'delete_action' && $user->rights->agenda->delete) {
$event->fetch($actionid);
$event->fetch_optionals();
$event->fetch_userassigned();
- $event->oldcopy = clone $event;
+ $event->oldcopy = dol_clone($event);
$result = $event->delete();
}
diff --git a/htdocs/comm/action/peruser.php b/htdocs/comm/action/peruser.php
index 87def7240f5..f28a3b2f719 100644
--- a/htdocs/comm/action/peruser.php
+++ b/htdocs/comm/action/peruser.php
@@ -196,7 +196,7 @@ if ($action == 'delete_action' && $user->rights->agenda->delete) {
$event->fetch($actionid);
$event->fetch_optionals();
$event->fetch_userassigned();
- $event->oldcopy = clone $event;
+ $event->oldcopy = dol_clone($event);
$result = $event->delete();
}
@@ -901,7 +901,7 @@ while ($currentdaytoshow < $lastdaytoshow) {
/* Use this list to have for all users */
$sql = "SELECT DISTINCT u.rowid, u.lastname as lastname, u.firstname, u.statut, u.login, u.admin, u.entity";
$sql .= " FROM ".MAIN_DB_PREFIX."user as u";
- if (!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) {
+ if (isModEnabled('multicompany') && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) {
$sql .= ", ".MAIN_DB_PREFIX."usergroup_user as ug";
$sql .= " WHERE ug.entity IN (".getEntity('usergroup').")";
$sql .= " AND ug.fk_user = u.rowid ";
diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php
index 173ee8a6510..ec8ebdd67e6 100644
--- a/htdocs/comm/card.php
+++ b/htdocs/comm/card.php
@@ -44,13 +44,13 @@ if (isModEnabled('facture')) {
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php';
}
-if (!empty($conf->propal->enabled)) {
+if (isModEnabled("propal")) {
require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
}
if (!empty($conf->commande->enabled)) {
require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
}
-if (!empty($conf->expedition->enabled)) {
+if (isModEnabled("expedition")) {
require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php';
}
if (!empty($conf->contrat->enabled)) {
@@ -72,7 +72,7 @@ if (!empty($conf->contrat->enabled)) {
if (!empty($conf->commande->enabled)) {
$langs->load("orders");
}
-if (!empty($conf->expedition->enabled)) {
+if (isModEnabled("expedition")) {
$langs->load("sendings");
}
if (isModEnabled('facture')) {
@@ -438,7 +438,7 @@ if ($object->id > 0) {
print " ";
print ' ';
- if (!empty($conf->banque->enabled)) {
+ if (isModEnabled("banque")) {
// Compte bancaire par défaut
print '';
print '';
@@ -697,7 +697,7 @@ if ($object->id > 0) {
$boxstat .= '';
$boxstat .= '';
- if (!empty($conf->propal->enabled) && $user->rights->propal->lire) {
+ if (isModEnabled("propal") && $user->rights->propal->lire) {
// Box proposals
$tmp = $object->getOutstandingProposals();
$outstandingOpened = $tmp['opened'];
@@ -818,7 +818,7 @@ if ($object->id > 0) {
/*
* Latest proposals
*/
- if (!empty($conf->propal->enabled) && $user->rights->propal->lire) {
+ if (isModEnabled("propal") && $user->rights->propal->lire) {
$langs->load("propal");
$sql = "SELECT s.nom, s.rowid, p.rowid as propalid, p.fk_statut, p.total_ht";
@@ -1024,7 +1024,7 @@ if ($object->id > 0) {
/*
* Latest shipments
*/
- if (!empty($conf->expedition->enabled) && $user->rights->expedition->lire) {
+ if (isModEnabled("expedition") && $user->rights->expedition->lire) {
$sql = 'SELECT e.rowid as id';
$sql .= ', e.ref, e.entity';
$sql .= ', e.date_creation';
@@ -1548,7 +1548,7 @@ if ($object->id > 0) {
print '';
}
- if (!empty($conf->propal->enabled) && $user->rights->propal->creer && $object->status == 1) {
+ if (isModEnabled("propal") && $user->rights->propal->creer && $object->status == 1) {
$langs->load("propal");
print '';
}
diff --git a/htdocs/comm/index.php b/htdocs/comm/index.php
index 7127fd2dd5b..6f9cfac40a5 100644
--- a/htdocs/comm/index.php
+++ b/htdocs/comm/index.php
@@ -90,7 +90,7 @@ $maxofloop = (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global-
$form = new Form($db);
$formfile = new FormFile($db);
$companystatic = new Societe($db);
-if (!empty($conf->propal->enabled)) {
+if (isModEnabled("propal")) {
$propalstatic = new Propal($db);
}
if (!empty($conf->supplier_proposal->enabled)) {
@@ -99,7 +99,7 @@ if (!empty($conf->supplier_proposal->enabled)) {
if (!empty($conf->commande->enabled)) {
$orderstatic = new Commande($db);
}
-if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled)) {
+if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order")) {
$supplierorderstatic = new CommandeFournisseur($db);
}
@@ -128,7 +128,7 @@ if ($tmp) {
* Draft customer proposals
*/
-if (!empty($conf->propal->enabled) && $user->rights->propal->lire) {
+if (isModEnabled("propal") && $user->rights->propal->lire) {
$sql = "SELECT p.rowid, p.ref, p.ref_client, p.total_ht, p.total_tva, p.total_ttc, p.fk_statut as status";
$sql .= ", s.rowid as socid, s.nom as name, s.name_alias";
$sql .= ", s.code_client, s.code_compta, s.client";
@@ -421,7 +421,7 @@ if (!empty($conf->commande->enabled) && $user->rights->commande->lire) {
* Draft purchase orders
*/
-if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->rights->fournisseur->commande->lire) || (!empty($conf->supplier_order->enabled) && $user->rights->supplier_order->lire)) {
+if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->rights->fournisseur->commande->lire) || (isModEnabled("supplier_order") && $user->rights->supplier_order->lire)) {
$sql = "SELECT cf.rowid, cf.ref, cf.ref_supplier, cf.total_ht, cf.total_tva, cf.total_ttc, cf.fk_statut as status";
$sql .= ", s.rowid as socid, s.nom as name, s.name_alias";
$sql .= ", s.code_client, s.code_compta, s.client";
@@ -592,7 +592,7 @@ print '';
/*
* Last modified customers or prospects
*/
-if (!empty($conf->societe->enabled) && $user->rights->societe->lire) {
+if (isModEnabled("societe") && $user->rights->societe->lire) {
$sql = "SELECT s.rowid as socid, s.nom as name, s.name_alias";
$sql .= ", s.code_client, s.code_compta, s.client";
$sql .= ", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur";
@@ -667,7 +667,7 @@ if (!empty($conf->societe->enabled) && $user->rights->societe->lire) {
$s .= '
'.dol_substr($langs->trans("Customer"), 0, 1).' ';
}
/*
- if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) && $obj->fournisseur)
+ if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) && $obj->fournisseur)
{
$s .= '
'.dol_substr($langs->trans("Supplier"), 0, 1).' ';
}*/
@@ -698,7 +698,7 @@ if (!empty($conf->societe->enabled) && $user->rights->societe->lire) {
/*
* Last suppliers
*/
-if (((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) && $user->rights->societe->lire) {
+if (((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) && $user->rights->societe->lire) {
$sql = "SELECT s.rowid as socid, s.nom as name, s.name_alias";
$sql .= ", s.code_client, s.code_compta, s.client";
$sql .= ", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur";
@@ -763,7 +763,7 @@ if (((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_S
{
$s .= '
'.dol_substr($langs->trans("Customer"), 0, 1).' ';
}*/
- if (((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) && $obj->fournisseur) {
+ if (((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) && $obj->fournisseur) {
$s .= '
'.dol_substr($langs->trans("Supplier"), 0, 1).' ';
}
print $s;
@@ -887,7 +887,7 @@ if (!empty($conf->contrat->enabled) && $user->rights->contrat->lire && 0) { // T
/*
* Opened (validated) proposals
*/
-if (!empty($conf->propal->enabled) && $user->rights->propal->lire) {
+if (isModEnabled("propal") && $user->rights->propal->lire) {
$sql = "SELECT p.rowid as propalid, p.entity, p.total_ttc, p.total_ht, p.total_tva, p.ref, p.ref_client, p.fk_statut, p.datep as dp, p.fin_validite as dfv";
$sql .= ", s.rowid as socid, s.nom as name, s.name_alias";
$sql .= ", s.code_client, s.code_compta, s.client";
diff --git a/htdocs/comm/mailing/card.php b/htdocs/comm/mailing/card.php
index 748c5fabf10..eb1b50cee1b 100644
--- a/htdocs/comm/mailing/card.php
+++ b/htdocs/comm/mailing/card.php
@@ -258,7 +258,7 @@ if (empty($reshook)) {
}
}
if (!empty($conf->global->MEMBER_ENABLE_PUBLIC)) {
- $substitutionarray['__PUBLICLINK_NEWMEMBERFORM__'] = '
'.$langs->trans('BlankSubscriptionForm'). ' ';
+ $substitutionarray['__PUBLICLINK_NEWMEMBERFORM__'] = '
'.$langs->trans('BlankSubscriptionForm'). ' ';
}
/* For backward compatibility, deprecated */
if (!empty($conf->paypal->enabled) && !empty($conf->global->PAYPAL_SECURITY_TOKEN)) {
diff --git a/htdocs/comm/multiprix.php b/htdocs/comm/multiprix.php
index 8da9a17ebb2..0e582946df9 100644
--- a/htdocs/comm/multiprix.php
+++ b/htdocs/comm/multiprix.php
@@ -75,7 +75,7 @@ if ($_socid > 0) {
// We load data of thirdparty
$objsoc = new Societe($db);
$objsoc->id = $_socid;
- $objsoc->fetch($_socid, $to);
+ $objsoc->fetch($_socid);
$head = societe_prepare_head($objsoc);
@@ -141,7 +141,6 @@ if ($_socid > 0) {
$resql = $db->query($sql);
if ($resql) {
print '
';
- $tag = !$tag;
print '';
print ''.$langs->trans("Date").' ';
print ''.$langs->trans("PriceLevel").' ';
diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php
index f1a92d032cf..e02ff5d8875 100644
--- a/htdocs/comm/propal/card.php
+++ b/htdocs/comm/propal/card.php
@@ -1,6 +1,6 @@
- * Copyright (C) 2004-2014 Laurent Destailleur
+/* Copyright (C) 2001-2007 Rodolphe Quiedeville
+ * Copyright (C) 2004-2022 Laurent Destailleur
* Copyright (C) 2004 Eric Seigne
* Copyright (C) 2005 Marc Barilley / Ocebo
* Copyright (C) 2005-2012 Regis Houssin
@@ -9,12 +9,12 @@
* Copyright (C) 2010-2021 Philippe Grand
* Copyright (C) 2012-2013 Christophe Battarel
* Copyright (C) 2012 Cedric Salvador
- * Copyright (C) 2013-2014 Florian Henry
- * Copyright (C) 2014 Ferran Marcet
- * Copyright (C) 2016 Marcos García
- * Copyright (C) 2018-2021 Frédéric France
- * Copyright (C) 2020 Nicolas ZABOURI
- * Copyright (C) 2022 Gauthier VERDOL
+ * Copyright (C) 2013-2014 Florian Henry
+ * Copyright (C) 2014 Ferran Marcet
+ * Copyright (C) 2016 Marcos García
+ * Copyright (C) 2018-2021 Frédéric France
+ * Copyright (C) 2020 Nicolas ZABOURI
+ * Copyright (C) 2022 Gauthier VERDOL
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -47,7 +47,6 @@ require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/modules/propale/modules_propale.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/propal.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
-require_once DOL_DOCUMENT_ROOT.'/core/lib/signature.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
if (!empty($conf->project->enabled)) {
@@ -88,9 +87,6 @@ $hidedetails = (GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', 'int') :
$hidedesc = (GETPOST('hidedesc', 'int') ? GETPOST('hidedesc', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0));
$hideref = (GETPOST('hideref', 'int') ? GETPOST('hideref', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0));
-// Nombre de ligne pour choix de produit/service predefinis
-$NBLINES = 4;
-
$object = new Propal($db);
$extrafields = new ExtraFields($db);
@@ -112,14 +108,15 @@ if ($id > 0 || !empty($ref)) {
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$hookmanager->initHooks(array('propalcard', 'globalcard'));
-$usercanread = $user->rights->propal->lire;
-$usercancreate = $user->rights->propal->creer;
-$usercandelete = $user->rights->propal->supprimer;
+$usercanread = $user->hasRight("propal", "lire");
+$usercancreate = $user->hasRight("propal", "creer");
+$usercandelete = $user->hasRight("propal", "supprimer");
$usercanclose = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $usercancreate) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->propal->propal_advance->close)));
$usercanvalidate = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $usercancreate) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->propal->propal_advance->validate)));
$usercansend = (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->propal->propal_advance->send)));
+$usermustrespectpricemin = ((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS));
$usercancreateorder = $user->hasRight('commande', 'creer');
$usercancreateinvoice = $user->hasRight('facture', 'creer');
$usercancreatecontract = $user->hasRight('contrat', 'creer');
@@ -326,8 +323,8 @@ if (empty($reshook)) {
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
$outputlangs = $langs;
$newlang = '';
- if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09');
- if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang;
+ if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09');
+ if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) $newlang = $object->thirdparty->default_lang;
if (!empty($newlang)) {
$outputlangs = new Translate("", $conf);
$outputlangs->setDefaultLang($newlang);
@@ -626,10 +623,10 @@ if (empty($reshook)) {
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
$outputlangs = $langs;
$newlang = '';
- if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
+ if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
$newlang = GETPOST('lang_id', 'aZ09');
}
- if ($conf->global->MAIN_MULTILANGS && empty($newlang)) {
+ if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) {
$newlang = $object->thirdparty->default_lang;
}
if (!empty($newlang)) {
@@ -877,7 +874,7 @@ if (empty($reshook)) {
}
}
} elseif ($action == 'addline' && GETPOST('submitforalllines', 'alpha') && GETPOST('vatforalllines', 'alpha') !== '' && $usercancreate) {
- // Define vat_rate
+ // Define a vat_rate for all lines
$vat_rate = (GETPOST('vatforalllines') ? GETPOST('vatforalllines') : 0);
$vat_rate = str_replace('*', '', $vat_rate);
$localtax1_rate = get_localtax($vat_rate, 1, $object->thirdparty, $mysoc);
@@ -886,7 +883,7 @@ if (empty($reshook)) {
$result = $object->updateline($line->id, $line->subprice, $line->qty, $line->remise_percent, $vat_rate, $localtax1_rate, $localtax2_rate, $line->desc, 'HT', $line->info_bits, $line->special_code, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->product_type, $line->date_start, $line->date_end, $line->array_options, $line->fk_unit, $line->multicurrency_subprice);
}
} elseif ($action == 'addline' && GETPOST('submitforalllines', 'alpha') && GETPOST('remiseforalllines', 'alpha') !== '' && $usercancreate) {
- // Define vat_rate
+ // Define a discount for all lines
$remise_percent = (GETPOST('remiseforalllines') ? GETPOST('remiseforalllines') : 0);
$remise_percent = str_replace('*', '', $remise_percent);
foreach ($object->lines as $line) {
@@ -896,19 +893,36 @@ if (empty($reshook)) {
// Set if we used free entry or predefined product
$predef = '';
$product_desc = (GETPOSTISSET('dp_desc') ? GETPOST('dp_desc', 'restricthtml') : '');
- $price_ht = price2num(GETPOST('price_ht'), 'MU', 2);
- $price_ht_devise = price2num(GETPOST('multicurrency_price_ht'), 'CU', 2);
- $prod_entry_mode = GETPOST('prod_entry_mode');
+
+ $price_ht = '';
+ $price_ht_devise = '';
+ $price_ttc = '';
+ $price_ttc_devise = '';
+
+ if (GETPOST('price_ht') !== '') {
+ $price_ht = price2num(GETPOST('price_ht'), 'MU', 2);
+ }
+ if (GETPOST('multicurrency_price_ht') !== '') {
+ $price_ht_devise = price2num(GETPOST('multicurrency_price_ht'), 'CU', 2);
+ }
+ if (GETPOST('price_ttc') !== '') {
+ $price_ttc = price2num(GETPOST('price_ttc'), 'MU', 2);
+ }
+ if (GETPOST('multicurrency_price_ttc') !== '') {
+ $price_ttc_devise = price2num(GETPOST('multicurrency_price_ttc'), 'CU', 2);
+ }
+
+ $prod_entry_mode = GETPOST('prod_entry_mode', 'aZ09');
if ($prod_entry_mode == 'free') {
$idprod = 0;
- $tva_tx = (GETPOST('tva_tx') ? price2num(preg_replace('/\s*\(.*\)/', '', GETPOST('tva_tx'))) : 0);
+ $tva_tx = (GETPOST('tva_tx', 'alpha') ? price2num(preg_replace('/\s*\(.*\)/', '', GETPOST('tva_tx', 'alpha'))) : 0);
} else {
$idprod = GETPOST('idprod', 'int');
$tva_tx = '';
}
$qty = price2num(GETPOST('qty'.$predef, 'alpha'), 'MS', 2);
- $remise_percent = price2num(GETPOST('remise_percent'.$predef), '', 2);
+ $remise_percent = (GETPOSTISSET('remise_percent'.$predef) ? price2num(GETPOST('remise_percent'.$predef, 'alpha'), '', 2) : 0);
if (empty($remise_percent)) {
$remise_percent = 0;
}
@@ -929,7 +943,7 @@ if (empty($reshook)) {
$error++;
}
- if ($prod_entry_mode == 'free' && (empty($idprod) || $idprod < 0) && $price_ht === '' && $price_ht_devise === '') { // Unit price can be 0 but not ''. Also price can be negative for proposal.
+ if ($prod_entry_mode == 'free' && (empty($idprod) || $idprod < 0) && $price_ht === '' && $price_ht_devise === '' && $price_ttc === '' && $price_ttc_devise === '') { // Unit price can be 0 but not ''. Also price can be negative for proposal.
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("UnitPriceHT")), null, 'errors');
$error++;
}
@@ -956,6 +970,7 @@ if (empty($reshook)) {
$pu_ht = 0;
$pu_ttc = 0;
$price_min = 0;
+ $price_min_ttc = 0;
$price_base_type = (GETPOST('price_base_type', 'alpha') ? GETPOST('price_base_type', 'alpha') : 'HT');
$db->begin();
@@ -983,6 +998,7 @@ if (empty($reshook)) {
$pu_ht = $prod->price;
$pu_ttc = $prod->price_ttc;
$price_min = $prod->price_min;
+ $price_min_ttc = $prod->price_min_ttc;
$price_base_type = $prod->price_base_type;
// If price per segment
@@ -990,6 +1006,7 @@ if (empty($reshook)) {
$pu_ht = $prod->multiprices[$object->thirdparty->price_level];
$pu_ttc = $prod->multiprices_ttc[$object->thirdparty->price_level];
$price_min = $prod->multiprices_min[$object->thirdparty->price_level];
+ $price_min_ttc = $prod->multiprices_min_ttc[$object->thirdparty->price_level];
$price_base_type = $prod->multiprices_base_type[$object->thirdparty->price_level];
if (!empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) { // using this option is a bug. kept for backward compatibility
if (isset($prod->multiprices_tva_tx[$object->thirdparty->price_level])) {
@@ -1014,6 +1031,7 @@ if (empty($reshook)) {
$pu_ht = price($prodcustprice->lines[0]->price);
$pu_ttc = price($prodcustprice->lines[0]->price_ttc);
$price_min = price($prodcustprice->lines[0]->price_min);
+ $price_min_ttc = price($prodcustprice->lines[0]->price_min_ttc);
$price_base_type = $prodcustprice->lines[0]->price_base_type;
$tva_tx = ($prodcustprice->lines[0]->default_vat_code ? $prodcustprice->lines[0]->tva_tx.' ('.$prodcustprice->lines[0]->default_vat_code.' )' : $prodcustprice->lines[0]->tva_tx);
if ($prodcustprice->lines[0]->default_vat_code && !preg_match('/\(.*\)/', $tva_tx)) {
@@ -1072,13 +1090,15 @@ if (empty($reshook)) {
$tmpvat = price2num(preg_replace('/\s*\(.*\)/', '', $tva_tx));
$tmpprodvat = price2num(preg_replace('/\s*\(.*\)/', '', $prod->tva_tx));
- // if price ht is forced (ie: calculated by margin rate and cost price). TODO Why this ?
+ // Set unit price to use
if (!empty($price_ht) || $price_ht === '0') {
$pu_ht = price2num($price_ht, 'MU');
$pu_ttc = price2num($pu_ht * (1 + ($tmpvat / 100)), 'MU');
+ } elseif (!empty($price_ttc) || $price_ttc === '0') {
+ $pu_ttc = price2num($price_ttc, 'MU');
+ $pu_ht = price2num($pu_ttc / (1 + ($tmpvat / 100)), 'MU');
} elseif ($tmpvat != $tmpprodvat) {
- // On reevalue prix selon taux tva car taux tva transaction peut etre different
- // de ceux du produit par defaut (par exemple si pays different entre vendeur et acheteur).
+ // Is this still used ?
if ($price_base_type != 'HT') {
$pu_ht = price2num($pu_ttc / (1 + ($tmpvat / 100)), 'MU');
} else {
@@ -1119,18 +1139,6 @@ if (empty($reshook)) {
$desc = dol_concatdesc($desc, $product_desc, '', !empty($conf->global->MAIN_CHANGE_ORDER_CONCAT_DESCRIPTION));
}
- // Add dimensions into product description
- /*if (empty($conf->global->MAIN_PRODUCT_DISABLE_AUTOADD_DIM))
- {
- $text='';
- if ($prod->weight) $text.=($text?"\n":"").$outputlangs->trans("Weight").': '.$prod->weight.' '.$prod->weight_units;
- if ($prod->length) $text.=($text?"\n":"").$outputlangs->trans("Length").': '.$prod->length.' '.$prod->length_units;
- if ($prod->surface) $text.=($text?"\n":"").$outputlangs->trans("Surface").': '.$prod->surface.' '.$prod->surface_units;
- if ($prod->volume) $text.=($text?"\n":"").$outputlangs->trans("Volume").': '.$prod->volume.' '.$prod->volume_units;
-
- $desc = dol_concatdesc($desc, $text);
- }*/
-
// Add custom code and origin country into description
if (empty($conf->global->MAIN_PRODUCT_DISABLE_CUSTOMCOUNTRYCODE) && (!empty($prod->customcode) || !empty($prod->country_code))) {
$tmptxt = '(';
@@ -1177,15 +1185,22 @@ if (empty($reshook)) {
$fk_unit = $prod->fk_unit;
} else {
$pu_ht = price2num($price_ht, 'MU');
- $pu_ttc = price2num(GETPOST('price_ttc'), 'MU');
+ $pu_ttc = price2num($price_ttc, 'MU');
$tva_npr = (preg_match('/\*/', $tva_tx) ? 1 : 0);
+ if (empty($tva_tx)) {
+ $tva_npr = 0;
+ }
$tva_tx = str_replace('*', '', $tva_tx);
$label = (GETPOST('product_label') ? GETPOST('product_label') : '');
$desc = $product_desc;
$type = GETPOST('type');
-
$fk_unit = GETPOST('units', 'alpha');
$pu_ht_devise = price2num($price_ht_devise, 'MU');
+ $pu_ttc_devise = price2num($price_ttc_devise, 'MU');
+
+ if ($pu_ttc && !$pu_ht) {
+ $price_base_type = 'TTC';
+ }
}
// Margin
@@ -1204,10 +1219,22 @@ if (empty($reshook)) {
$info_bits |= 0x01;
}
- if (((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS)) && (!empty($price_min) && (price2num($pu_ht) * (1 - price2num($remise_percent) / 100) < price2num($price_min)))) {
- $mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency));
- setEventMessages($mesg, null, 'errors');
- } else {
+ //var_dump(price2num($price_min)); var_dump(price2num($pu_ht)); var_dump($remise_percent);
+ //var_dump(price2num($price_min_ttc)); var_dump(price2num($pu_ttc)); var_dump($remise_percent);exit;
+
+ if ($usermustrespectpricemin) {
+ if ($pu_ht && $price_min && ((price2num($pu_ht) * (1 - $remise_percent / 100)) < price2num($price_min))) {
+ $mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, -1, $conf->currency));
+ setEventMessages($mesg, null, 'errors');
+ $error++;
+ } elseif ($pu_ttc && $price_min_ttc && ((price2num($pu_ttc) * (1 - $remise_percent / 100)) < price2num($price_min_ttc))) {
+ $mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min_ttc, 'MU'), 0, $langs, 0, 0, -1, $conf->currency));
+ setEventMessages($mesg, null, 'errors');
+ $error++;
+ }
+ }
+
+ if (!$error) {
// Insert line
$result = $object->addline($desc, $pu_ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $price_base_type, $pu_ttc, $info_bits, $type, min($rank, count($object->lines) + 1), 0, GETPOST('fk_parent_line'), $fournprice, $buyingprice, $label, $date_start, $date_end, $array_options, $fk_unit, '', 0, $pu_ht_devise);
@@ -1285,12 +1312,14 @@ if (empty($reshook)) {
$localtax1_rate = get_localtax($vat_rate, 1, $object->thirdparty, $mysoc);
$localtax2_rate = get_localtax($vat_rate, 2, $object->thirdparty, $mysoc);
$pu_ht = price2num(GETPOST('price_ht'), '', 2);
+ $pu_ttc = price2num(GETPOST('price_ttc'), '', 2);
// Add buying price
$fournprice = price2num(GETPOST('fournprice') ? GETPOST('fournprice') : '');
$buyingprice = price2num(GETPOST('buying_price') != '' ? GETPOST('buying_price') : ''); // If buying_price is '0', we muste keep this value
$pu_ht_devise = price2num(GETPOST('multicurrency_subprice'), '', 2);
+ $pu_ttc_devise = price2num(GETPOST('multicurrency_subprice_ttc'), '', 2);
$date_start = dol_mktime(GETPOST('date_starthour'), GETPOST('date_startmin'), GETPOST('date_startsec'), GETPOST('date_startmonth'), GETPOST('date_startday'), GETPOST('date_startyear'));
$date_end = dol_mktime(GETPOST('date_endhour'), GETPOST('date_endmin'), GETPOST('date_endsec'), GETPOST('date_endmonth'), GETPOST('date_endday'), GETPOST('date_endyear'));
@@ -1321,16 +1350,32 @@ if (empty($reshook)) {
$res = $product->fetch($productid);
$type = $product->type;
+ $label = ((GETPOST('update_label') && GETPOST('product_label')) ? GETPOST('product_label') : '');
$price_min = $product->price_min;
if (!empty($conf->global->PRODUIT_MULTIPRICES) && !empty($object->thirdparty->price_level)) {
- $price_min = $product->multiprices_min [$object->thirdparty->price_level];
+ $price_min = $product->multiprices_min[$object->thirdparty->price_level];
+ }
+ $price_min_ttc = $product->price_min_ttc;
+ if (!empty($conf->global->PRODUIT_MULTIPRICES) && !empty($object->thirdparty->price_level)) {
+ $price_min_ttc = $product->multiprices_min_ttc[$object->thirdparty->price_level];
}
- $label = ((GETPOST('update_label') && GETPOST('product_label')) ? GETPOST('product_label') : '');
- if (((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS)) && ($price_min && (price2num($pu_ht) * (1 - $remise_percent / 100) < price2num($price_min)))) {
- setEventMessages($langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency)), null, 'errors');
- $error++;
+ //var_dump(price2num($price_min)); var_dump(price2num($pu_ht)); var_dump($remise_percent);
+ //var_dump(price2num($price_min_ttc)); var_dump(price2num($pu_ttc)); var_dump($remise_percent);exit;
+
+ if ($usermustrespectpricemin) {
+ if ($pu_ht && $price_min && ((price2num($pu_ht) * (1 - $remise_percent / 100)) < price2num($price_min))) {
+ $mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, -1, $conf->currency));
+ setEventMessages($mesg, null, 'errors');
+ $error++;
+ $action = 'editline';
+ } elseif ($pu_ttc && $price_min_ttc && ((price2num($pu_ttc) * (1 - $remise_percent / 100)) < price2num($price_min_ttc))) {
+ $mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min_ttc, 'MU'), 0, $langs, 0, 0, -1, $conf->currency));
+ setEventMessages($mesg, null, 'errors');
+ $error++;
+ $action = 'editline';
+ }
}
} else {
$type = GETPOST('type');
@@ -1358,7 +1403,14 @@ if (empty($reshook)) {
$qty = price2num(GETPOST('qty', 'alpha'), 'MS');
- $result = $object->updateline(GETPOST('lineid', 'int'), $pu_ht, $qty, $remise_percent, $vat_rate, $localtax1_rate, $localtax2_rate, $description, 'HT', $info_bits, $special_code, GETPOST('fk_parent_line'), 0, $fournprice, $buyingprice, $label, $type, $date_start, $date_end, $array_options, GETPOST("units"), $pu_ht_devise);
+ $pu = $pu_ht;
+ $price_base_type = 'HT';
+ if (empty($pu) && ! empty($pu_ttc)) {
+ $pu = $pu_ttc;
+ $price_base_type = 'TTC';
+ }
+
+ $result = $object->updateline(GETPOST('lineid', 'int'), $pu, $qty, $remise_percent, $vat_rate, $localtax1_rate, $localtax2_rate, $description, $price_base_type, $info_bits, $special_code, GETPOST('fk_parent_line'), 0, $fournprice, $buyingprice, $label, $type, $date_start, $date_end, $array_options, GETPOST("units"), $pu_ht_devise);
if ($result >= 0) {
$db->commit();
@@ -1726,7 +1778,7 @@ if ($action == 'create') {
print ' ';
// Bank Account
- if (!empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL) && !empty($conf->banque->enabled)) {
+ if (!empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL) && isModEnabled("banque")) {
print ''.$langs->trans('BankAccount').' ';
print img_picto('', 'bank_account', 'class="pictofixedwidth"').$form->select_comptes($soc->fk_account, 'fk_account', 0, '', 1, '', 0, 'maxwidth200 widthcentpercentminusx', 1);
print ' ';
@@ -1749,7 +1801,7 @@ if ($action == 'create') {
print '';
// Shipping Method
- if (!empty($conf->expedition->enabled)) {
+ if (isModEnabled("expedition")) {
if (!empty($conf->global->SOCIETE_ASK_FOR_SHIPPING_METHOD) && !empty($soc->shipping_method_id)) {
$shipping_method_id = $soc->shipping_method_id;
}
@@ -1851,7 +1903,7 @@ if ($action == 'create') {
// Calcul contrat->price (HT), contrat->total (TTC), contrat->tva
$objectsrc->remise_absolue = $remise_absolue; // deprecated
$objectsrc->remise_percent = $remise_percent;
- $objectsrc->update_price(1, - 1, 1);
+ $objectsrc->update_price(1, 'auto', 1);
}
print "\n";
@@ -2410,7 +2462,7 @@ if ($action == 'create') {
print '';
// Shipping Method
- if (!empty($conf->expedition->enabled)) {
+ if (isModEnabled("expedition")) {
print '';
print '';
print $langs->trans('SendingMethod');
@@ -2528,7 +2580,7 @@ if ($action == 'create') {
print ' ';
}
- if (!empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL) && !empty($conf->banque->enabled)) {
+ if (!empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL) && isModEnabled("banque")) {
// Bank Account
print '';
print '';
@@ -2672,10 +2724,15 @@ if ($action == 'create') {
* Lines
*/
- // Show object lines
+ // Get object lines
$result = $object->getLinesArray();
- print ' id.(($action != 'editline') ? '' : '#line_'.GETPOST('lineid', 'int')).'" method="POST">
+ // Add products/services form
+ //$forceall = 1;
+ global $inputalsopricewithtax;
+ $inputalsopricewithtax = 1;
+
+ print ' id.'" method="POST">
@@ -2699,8 +2756,6 @@ if ($action == 'create') {
// Form to add new line
if ($object->statut == Propal::STATUS_DRAFT && $usercancreate && $action != 'selectlines') {
if ($action != 'editline') {
- // Add products/services form
-
$parameters = array();
$reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
@@ -2779,7 +2834,7 @@ if ($action == 'create') {
// Create a purchase order
if (!empty($conf->global->WORKFLOW_CAN_CREATE_PURCHASE_ORDER_FROM_PROPOSAL)) {
- if ($object->statut == Propal::STATUS_SIGNED && ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled))) {
+ if ($object->statut == Propal::STATUS_SIGNED && ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order"))) {
if ($usercancreatepurchaseorder) {
print ''.$langs->trans("AddPurchaseOrder").' ';
}
@@ -2787,7 +2842,7 @@ if ($action == 'create') {
}
// Create an intervention
- if (!empty($conf->service->enabled) && !empty($conf->ficheinter->enabled) && $object->statut == Propal::STATUS_SIGNED) {
+ if (isModEnabled("service") && !empty($conf->ficheinter->enabled) && $object->statut == Propal::STATUS_SIGNED) {
if ($usercancreateintervention) {
$langs->load("interventions");
print ''.$langs->trans("AddIntervention").' ';
@@ -2879,7 +2934,7 @@ if ($action == 'create') {
if ($object->statut != Propal::STATUS_DRAFT && $useonlinesignature) {
print ' ';
- require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php';
+ require_once DOL_DOCUMENT_ROOT.'/core/lib/signature.lib.php';
print showOnlineSignatureUrl('proposal', $object->ref).' ';
}
diff --git a/htdocs/comm/propal/class/api_proposals.class.php b/htdocs/comm/propal/class/api_proposals.class.php
index d28b5718c2f..cf675e01b62 100644
--- a/htdocs/comm/propal/class/api_proposals.class.php
+++ b/htdocs/comm/propal/class/api_proposals.class.php
@@ -496,8 +496,12 @@ class Proposals extends DolibarrApi
$request_data = (object) $request_data;
- $request_data->desc = sanitizeVal($request_data->desc, 'restricthtml');
- $request_data->label = sanitizeVal($request_data->label);
+ if (isset($request_data->desc)) {
+ $request_data->desc = sanitizeVal($request_data->desc, 'restricthtml');
+ }
+ if (isset($request_data->label)) {
+ $request_data->label = sanitizeVal($request_data->label);
+ }
$propalline = new PropaleLigne($this->db);
$result = $propalline->fetch($lineid);
diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php
index 7f1dc549054..aa7753946a7 100644
--- a/htdocs/comm/propal/class/propal.class.php
+++ b/htdocs/comm/propal/class/propal.class.php
@@ -932,9 +932,6 @@ class Propal extends CommonObject
$this->line->date_start = $date_start;
$this->line->date_end = $date_end;
- // TODO deprecated
- $this->line->price = $price;
-
if (is_array($array_options) && count($array_options) > 0) {
// We replace values in this->line->array_options only for entries defined into $array_options
foreach ($array_options as $key => $value) {
@@ -1507,12 +1504,13 @@ class Propal extends CommonObject
/**
* Load a proposal from database. Get also lines.
*
- * @param int $rowid id of object to load
- * @param string $ref Ref of proposal
- * @param string $ref_ext Ref ext of proposal
- * @return int >0 if OK, <0 if KO
+ * @param int $rowid Id of object to load
+ * @param string $ref Ref of proposal
+ * @param string $ref_ext Ref ext of proposal
+ * @param int $forceentity Entity id to force when searching on ref or ref_ext
+ * @return int >0 if OK, <0 if KO
*/
- public function fetch($rowid, $ref = '', $ref_ext = '')
+ public function fetch($rowid, $ref = '', $ref_ext = '', $forceentity = 0)
{
$sql = "SELECT p.rowid, p.ref, p.entity, p.remise, p.remise_percent, p.remise_absolue, p.fk_soc";
$sql .= ", p.total_ttc, p.total_tva, p.localtax1, p.localtax2, p.total_ht";
@@ -1551,10 +1549,15 @@ class Propal extends CommonObject
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_input_reason as dr ON p.fk_input_reason = dr.rowid';
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON p.fk_incoterms = i.rowid';
- if ($ref) {
- $sql .= " WHERE p.entity IN (".getEntity('propal').")"; // Dont't use entity if you use rowid
+ if (!empty($ref)) {
+ if (!empty($forceentity)) {
+ $sql .= " WHERE p.entity = ".(int) $forceentity; // Check only the current entity because we may have the same reference in several entities
+ } else {
+ $sql .= " WHERE p.entity IN (".getEntity('propal').")";
+ }
$sql .= " AND p.ref='".$this->db->escape($ref)."'";
} else {
+ // Dont't use entity if you use rowid
$sql .= " WHERE p.rowid = ".((int) $rowid);
}
@@ -3812,7 +3815,7 @@ class Propal extends CommonObject
* @param int $hidedetails Hide details of lines
* @param int $hidedesc Hide description
* @param int $hideref Hide ref
- * @param null|array $moreparams Array to provide more information
+ * @param null|array $moreparams Array to provide more information
* @return int 0 if KO, 1 if OK
*/
public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null)
diff --git a/htdocs/comm/propal/index.php b/htdocs/comm/propal/index.php
index 9f020bc1613..c03cdf4fdcc 100644
--- a/htdocs/comm/propal/index.php
+++ b/htdocs/comm/propal/index.php
@@ -76,7 +76,7 @@ if ($tmp) {
/*
* Draft proposals
*/
-if (!empty($conf->propal->enabled)) {
+if (isModEnabled("propal")) {
$sql = "SELECT p.rowid, p.ref, p.ref_client, p.total_ht, p.total_tva, p.total_ttc";
$sql .= ", s.rowid as socid, s.nom as name, s.client, s.canvas, s.code_client, s.email, s.entity, s.code_compta";
$sql .= " FROM ".MAIN_DB_PREFIX."propal as p";
@@ -226,7 +226,7 @@ if ($resql) {
/*
* Open (validated) proposals
*/
-if (!empty($conf->propal->enabled) && $user->rights->propale->lire) {
+if (isModEnabled("propal") && $user->rights->propale->lire) {
$sql = "SELECT s.nom as socname, s.rowid as socid, s.canvas, s.client, s.email, s.code_compta";
$sql .= ", p.rowid as propalid, p.entity, p.total_ttc, p.total_ht, p.ref, p.fk_statut, p.datep as dp, p.fin_validite as dfv";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php
index 9012b105b55..6b717d3ea6f 100644
--- a/htdocs/comm/propal/list.php
+++ b/htdocs/comm/propal/list.php
@@ -52,7 +52,7 @@ require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
// Load translation files required by the page
$langs->loadLangs(array('companies', 'propal', 'compta', 'bills', 'orders', 'products', 'deliveries', 'categories'));
-if (!empty($conf->expedition->enabled)) {
+if (isModEnabled("expedition")) {
$langs->loadLangs(array('sendings'));
}
@@ -218,7 +218,7 @@ $arrayfields = array(
'p.date_livraison'=>array('label'=>"DeliveryDate", 'checked'=>0),
'p.date_signature'=>array('label'=>"DateSigning", 'checked'=>0),
'ava.rowid'=>array('label'=>"AvailabilityPeriod", 'checked'=>0),
- 'p.fk_shipping_method'=>array('label'=>"SendingMethod", 'checked'=>0, 'enabled'=>!empty($conf->expedition->enabled)),
+ 'p.fk_shipping_method'=>array('label'=>"SendingMethod", 'checked'=>0, 'enabled'=>isModEnabled("expedition")),
'p.fk_input_reason'=>array('label'=>"Origin", 'checked'=>0, 'enabled'=>1),
'p.fk_cond_reglement'=>array('label'=>"PaymentConditionsShort", 'checked'=>0),
'p.fk_mode_reglement'=>array('label'=>"PaymentMode", 'checked'=>0),
diff --git a/htdocs/comm/prospect/index.php b/htdocs/comm/prospect/index.php
index e63aee6f240..bda09507ed0 100644
--- a/htdocs/comm/prospect/index.php
+++ b/htdocs/comm/prospect/index.php
@@ -59,7 +59,7 @@ print load_fiche_titre($langs->trans("ProspectionArea"));
print '';
-if (!empty($conf->propal->enabled)) {
+if (isModEnabled("propal")) {
$var = false;
print '
';
print ' ';
@@ -118,7 +118,7 @@ if ($resql) {
/*
* Liste des propal brouillons
*/
-if (!empty($conf->propal->enabled) && $user->rights->propale->lire) {
+if (isModEnabled("propal") && $user->rights->propale->lire) {
$sql = "SELECT p.rowid, p.ref, p.price, s.nom as sname";
$sql .= " FROM ".MAIN_DB_PREFIX."propal as p";
$sql .= ", ".MAIN_DB_PREFIX."societe as s";
@@ -176,7 +176,7 @@ if (isModEnabled('agenda')) {
/*
* Dernieres propales ouvertes
*/
-if (!empty($conf->propal->enabled) && $user->rights->propale->lire) {
+if (isModEnabled("propal") && $user->rights->propale->lire) {
$sql = "SELECT s.nom as name, s.rowid as socid, s.client, s.canvas,";
$sql .= " p.rowid as propalid, p.total_ttc, p.ref, p.datep as dp, c.label as statut, c.id as statutid";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
diff --git a/htdocs/comm/remx.php b/htdocs/comm/remx.php
index db1cc06c504..a47a865fc45 100644
--- a/htdocs/comm/remx.php
+++ b/htdocs/comm/remx.php
@@ -424,12 +424,12 @@ if ($socid > 0) {
print ''.$langs->trans("ReasonDiscount").' ';
print ''.$langs->trans("ConsumedBy").' ';
print ''.$langs->trans("AmountHT").' ';
- if (!empty($conf->multicurrency->enabled)) {
+ if (isModEnabled('multicompany')) {
print ''.$langs->trans("MulticurrencyAmountHT").' ';
}
print ''.$langs->trans("VATRate").' ';
print ''.$langs->trans("AmountTTC").' ';
- if (!empty($conf->multicurrency->enabled)) {
+ if (isModEnabled('multicompany')) {
print ''.$langs->trans("MulticurrencyAmountTTC").' ';
}
print ''.$langs->trans("DiscountOfferedBy").' ';
@@ -474,12 +474,12 @@ if ($socid > 0) {
}
print ''.$langs->trans("NotConsumed").' ';
print ''.price($obj->amount_ht).' ';
- if (!empty($conf->multicurrency->enabled)) {
+ if (isModEnabled('multicompany')) {
print ''.price($obj->multicurrency_amount_ht).' ';
}
print ''.vatrate($obj->tva_tx.($obj->vat_src_code ? ' ('.$obj->vat_src_code.')' : ''), true).' ';
print ''.price($obj->amount_ttc).' ';
- if (!empty($conf->multicurrency->enabled)) {
+ if (isModEnabled('multicompany')) {
print ''.price($obj->multicurrency_amount_ttc).' ';
}
print '';
@@ -503,7 +503,7 @@ if ($socid > 0) {
}
} else {
$colspan = 8;
- if (!empty($conf->multicurrency->enabled)) {
+ if (isModEnabled('multicompany')) {
$colspan += 2;
}
print ' '.$langs->trans("None").' ';
@@ -562,12 +562,12 @@ if ($socid > 0) {
print ''.$langs->trans("ReasonDiscount").' ';
print ''.$langs->trans("ConsumedBy").' ';
print ''.$langs->trans("AmountHT").' ';
- if (!empty($conf->multicurrency->enabled)) {
+ if (isModEnabled('multicompany')) {
print ''.$langs->trans("MulticurrencyAmountHT").' ';
}
print ''.$langs->trans("VATRate").' ';
print ''.$langs->trans("AmountTTC").' ';
- if (!empty($conf->multicurrency->enabled)) {
+ if (isModEnabled('multicompany')) {
print ''.$langs->trans("MulticurrencyAmountTTC").' ';
}
print ''.$langs->trans("DiscountOfferedBy").' ';
@@ -612,12 +612,12 @@ if ($socid > 0) {
}
print ''.$langs->trans("NotConsumed").' ';
print ''.price($obj->amount_ht).' ';
- if (!empty($conf->multicurrency->enabled)) {
+ if (isModEnabled('multicompany')) {
print ''.price($obj->multicurrency_amount_ht).' ';
}
print ''.vatrate($obj->tva_tx.($obj->vat_src_code ? ' ('.$obj->vat_src_code.')' : ''), true).' ';
print ''.price($obj->amount_ttc).' ';
- if (!empty($conf->multicurrency->enabled)) {
+ if (isModEnabled('multicompany')) {
print ''.price($obj->multicurrency_amount_ttc).' ';
}
print '';
@@ -641,7 +641,7 @@ if ($socid > 0) {
}
} else {
$colspan = 8;
- if (!empty($conf->multicurrency->enabled)) {
+ if (isModEnabled('multicompany')) {
$colspan += 2;
}
print ' '.$langs->trans("None").' ';
@@ -735,12 +735,12 @@ if ($socid > 0) {
print ''.$langs->trans("ReasonDiscount").' ';
print ''.$langs->trans("ConsumedBy").' ';
print ''.$langs->trans("AmountHT").' ';
- if (!empty($conf->multicurrency->enabled)) {
+ if (isModEnabled('multicompany')) {
print ''.$langs->trans("MulticurrencyAmountHT").' ';
}
print ''.$langs->trans("VATRate").' ';
print ''.$langs->trans("AmountTTC").' ';
- if (!empty($conf->multicurrency->enabled)) {
+ if (isModEnabled('multicompany')) {
print ''.$langs->trans("MulticurrencyAmountTTC").' ';
}
print ''.$langs->trans("Author").' ';
@@ -808,12 +808,12 @@ if ($socid > 0) {
}
print ' ';
print ''.price($obj->amount_ht).' ';
- if (!empty($conf->multicurrency->enabled)) {
+ if (isModEnabled('multicompany')) {
print ''.price($obj->multicurrency_amount_ht).' ';
}
print ''.vatrate($obj->tva_tx.($obj->vat_src_code ? ' ('.$obj->vat_src_code.')' : ''), true).' ';
print ''.price($obj->amount_ttc).' ';
- if (!empty($conf->multicurrency->enabled)) {
+ if (isModEnabled('multicompany')) {
print ''.price($obj->multicurrency_amount_ttc).' ';
}
print '';
@@ -825,7 +825,7 @@ if ($socid > 0) {
}
} else {
$colspan = 8;
- if (!empty($conf->multicurrency->enabled)) {
+ if (isModEnabled('multicompany')) {
$colspan += 2;
}
print ' '.$langs->trans("None").' ';
@@ -896,12 +896,12 @@ if ($socid > 0) {
print ''.$langs->trans("ReasonDiscount").' ';
print ''.$langs->trans("ConsumedBy").' ';
print ''.$langs->trans("AmountHT").' ';
- if (!empty($conf->multicurrency->enabled)) {
+ if (isModEnabled('multicompany')) {
print ''.$langs->trans("MulticurrencyAmountHT").' ';
}
print ''.$langs->trans("VATRate").' ';
print ''.$langs->trans("AmountTTC").' ';
- if (!empty($conf->multicurrency->enabled)) {
+ if (isModEnabled('multicompany')) {
print ''.$langs->trans("MulticurrencyAmountTTC").' ';
}
print ''.$langs->trans("Author").' ';
@@ -969,12 +969,12 @@ if ($socid > 0) {
}
print '';
print ''.price($obj->amount_ht).' ';
- if (!empty($conf->multicurrency->enabled)) {
+ if (isModEnabled('multicompany')) {
print ''.price($obj->multicurrency_amount_ht).' ';
}
print ''.vatrate($obj->tva_tx.($obj->vat_src_code ? ' ('.$obj->vat_src_code.')' : ''), true).' ';
print ''.price($obj->amount_ttc).' ';
- if (!empty($conf->multicurrency->enabled)) {
+ if (isModEnabled('multicompany')) {
print ''.price($obj->multicurrency_amount_ttc).' ';
}
print '';
@@ -986,7 +986,7 @@ if ($socid > 0) {
}
} else {
$colspan = 8;
- if (!empty($conf->multicurrency->enabled)) {
+ if (isModEnabled('multicompany')) {
$colspan += 2;
}
print ' '.$langs->trans("None").' ';
diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php
index aa26e7be794..b97bf147dbb 100644
--- a/htdocs/commande/card.php
+++ b/htdocs/commande/card.php
@@ -30,37 +30,41 @@
*/
/**
- * \file htdocs/commande/card.php
- * \ingroup commande
- * \brief Page to show customer order
+ * \file htdocs/commande/card.php
+ * \ingroup commande
+ * \brief Page to show customer order
*/
require '../main.inc.php';
+require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
+require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formorder.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formmargin.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/modules/commande/modules_commande.php';
-require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
-require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
-require_once DOL_DOCUMENT_ROOT.'/core/lib/order.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
-require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
-if (!empty($conf->propal->enabled)) {
+require_once DOL_DOCUMENT_ROOT.'/core/lib/order.lib.php';
+
+require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
+require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
+
+if (isModEnabled("propal")) {
require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
}
-if (!empty($conf->project->enabled)) {
- require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
- require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
-}
-require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
+if (!empty($conf->project->enabled)) {
+ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
+ require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
+}
if (!empty($conf->variants->enabled)) {
require_once DOL_DOCUMENT_ROOT.'/variants/class/ProductCombination.class.php';
}
+
// Load translation files required by the page
$langs->loadLangs(array('orders', 'sendings', 'companies', 'bills', 'propal', 'deliveries', 'products', 'other'));
+
if (!empty($conf->incoterm->enabled)) {
$langs->load('incoterm');
}
@@ -68,21 +72,22 @@ if (!empty($conf->margin->enabled)) {
$langs->load('margins');
}
if (!empty($conf->productbatch->enabled)) {
- $langs->load("productbatch");
+ $langs->load('productbatch');
}
-$id = (GETPOST('id', 'int') ? GETPOST('id', 'int') : GETPOST('orderid', 'int'));
-$ref = GETPOST('ref', 'alpha');
-$socid = GETPOST('socid', 'int');
-$action = GETPOST('action', 'aZ09');
-$cancel = GETPOST('cancel', 'alpha');
-$confirm = GETPOST('confirm', 'alpha');
-$lineid = GETPOST('lineid', 'int');
-$contactid = GETPOST('contactid', 'int');
-$projectid = GETPOST('projectid', 'int');
-$origin = GETPOST('origin', 'alpha');
-$originid = (GETPOST('originid', 'int') ? GETPOST('originid', 'int') : GETPOST('origin_id', 'int')); // For backward compatibility
-$rank = (GETPOST('rank', 'int') > 0) ? GETPOST('rank', 'int') : -1;
+
+$id = (GETPOST('id', 'int') ? GETPOST('id', 'int') : GETPOST('orderid', 'int'));
+$ref = GETPOST('ref', 'alpha');
+$socid = GETPOST('socid', 'int');
+$action = GETPOST('action', 'aZ09');
+$cancel = GETPOST('cancel', 'alpha');
+$confirm = GETPOST('confirm', 'alpha');
+$lineid = GETPOST('lineid', 'int');
+$contactid = GETPOST('contactid', 'int');
+$projectid = GETPOST('projectid', 'int');
+$origin = GETPOST('origin', 'alpha');
+$originid = (GETPOST('originid', 'int') ? GETPOST('originid', 'int') : GETPOST('origin_id', 'int')); // For backward compatibility
+$rank = (GETPOST('rank', 'int') > 0) ? GETPOST('rank', 'int') : -1;
// PDF
$hidedetails = (GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0));
@@ -106,24 +111,27 @@ $extrafields = new ExtraFields($db);
$extrafields->fetch_name_optionals_label($object->table_element);
// Load object
-include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once
+include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once
+
+// Permissions / Rights
+$usercanread = $user->hasRight("commande", "lire");
+$usercancreate = $user->hasRight("commande", "creer");
+$usercandelete = $user->hasRight("commande", "supprimer");
-$usercanread = $user->hasRight('commande', 'lire');
-$usercancreate = $user->hasRight('commande', 'creer');
-$usercandelete = $user->hasRight('commande', 'supprimer');
// Advanced permissions
+$usercanclose = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($usercancreate)) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->hasRight('commande', 'order_advance', 'close')));
+$usercanvalidate = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $usercancreate) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->hasRight('commande', 'order_advance', 'validate')));
+$usercancancel = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $usercancreate) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->hasRight('commande', 'order_advance', 'annuler')));
+$usercansend = (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->hasRight('commande', 'order_advance', 'send'));
+$usercangeneretedoc = (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->hasRight('commande', 'order_advance', 'generetedoc'));
-$usercanclose = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($usercancreate)) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->hasRight('commande', 'order_advance', 'close'))));
-$usercanvalidate = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $usercancreate) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->hasRight('commande', 'order_advance', 'validate'))));
-$usercancancel = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $usercancreate) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->hasRight('commande', 'order_advance', 'annuler'))));
-$usercansend = (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->hasRight('commande', 'order_advance', 'send'));
-$usercangeneretedoc = (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->hasRight('commande', 'order_advance', 'generetedoc'));
-
+$usermustrespectpricemin = ((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS));
$usercancreatepurchaseorder = ($user->hasRight('fournisseur', 'commande', 'creer') || $user->hasRight('supplier_order', 'creer'));
-$permissionnote = $usercancreate; // Used by the include of actions_setnotes.inc.php
-$permissiondellink = $usercancreate; // Used by the include of actions_dellink.inc.php
-$permissiontoadd = $usercancreate; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
+$permissionnote = $usercancreate; // Used by the include of actions_setnotes.inc.php
+$permissiondellink = $usercancreate; // Used by the include of actions_dellink.inc.php
+$permissiontoadd = $usercancreate; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
+
$error = 0;
@@ -165,11 +173,11 @@ if (empty($reshook)) {
$action = '';
}
- include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once
+ include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once
- include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, not include_once
+ include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, not include_once
- 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
if ($action == 'confirm_clone' && $confirm == 'yes' && $usercancreate) {
@@ -219,10 +227,10 @@ if (empty($reshook)) {
// Define output language
$outputlangs = $langs;
$newlang = '';
- if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
+ if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
$newlang = GETPOST('lang_id', 'aZ09');
}
- if ($conf->global->MAIN_MULTILANGS && empty($newlang)) {
+ if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) {
$newlang = $object->thirdparty->default_lang;
}
if (!empty($newlang)) {
@@ -582,7 +590,7 @@ if (empty($reshook)) {
// Define output language
$outputlangs = $langs;
$newlang = GETPOST('lang_id', 'alpha');
- if ($conf->global->MAIN_MULTILANGS && empty($newlang)) {
+ if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) {
$newlang = $object->thirdparty->default_lang;
}
if (!empty($newlang)) {
@@ -645,19 +653,35 @@ if (empty($reshook)) {
// Set if we used free entry or predefined product
$predef = '';
$product_desc = (GETPOSTISSET('dp_desc') ? GETPOST('dp_desc', 'restricthtml') : '');
- $price_ht = price2num(GETPOST('price_ht'), 'MU', 2);
- $price_ht_devise = price2num(GETPOST('multicurrency_price_ht'), 'CU', 2);
- $prod_entry_mode = GETPOST('prod_entry_mode');
+
+ $price_ht = '';
+ $price_ht_devise = '';
+ $price_ttc = '';
+ $price_ttc_devise = '';
+
+ if (GETPOST('price_ht') !== '') {
+ $price_ht = price2num(GETPOST('price_ht'), 'MU', 2);
+ }
+ if (GETPOST('multicurrency_price_ht') !== '') {
+ $price_ht_devise = price2num(GETPOST('multicurrency_price_ht'), 'CU', 2);
+ }
+ if (GETPOST('price_ttc') !== '') {
+ $price_ttc = price2num(GETPOST('price_ttc'), 'MU', 2);
+ }
+ if (GETPOST('multicurrency_price_ttc') !== '') {
+ $price_ttc_devise = price2num(GETPOST('multicurrency_price_ttc'), 'CU', 2);
+ }
+
+ $prod_entry_mode = GETPOST('prod_entry_mode', 'aZ09');
if ($prod_entry_mode == 'free') {
$idprod = 0;
- $tva_tx = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0);
+ $tva_tx = (GETPOST('tva_tx', 'alpha') ? price2num(preg_replace('/\s*\(.*\)/', '', GETPOST('tva_tx', 'alpha'))) : 0);
} else {
$idprod = GETPOST('idprod', 'int');
$tva_tx = '';
}
- $qty = price2num(GETPOST('qty'.$predef, 'alpha'), 'MS');
-
+ $qty = price2num(GETPOST('qty'.$predef, 'alpha'), 'MS', 2);
$remise_percent = (GETPOSTISSET('remise_percent'.$predef) ? price2num(GETPOST('remise_percent'.$predef, 'alpha'), '', 2) : 0);
if (empty($remise_percent)) {
$remise_percent = 0;
@@ -682,7 +706,7 @@ if (empty($reshook)) {
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Type')), null, 'errors');
$error++;
}
- if ($prod_entry_mode == 'free' && (empty($idprod) || $idprod < 0) && $price_ht == '' && $price_ht_devise == '') { // Unit price can be 0 but not ''. Also price can be negative for order.
+ if ($prod_entry_mode == 'free' && (empty($idprod) || $idprod < 0) && $price_ht === '' && $price_ht_devise === '' && $price_ttc === '' && $price_ttc_devise === '') { // Unit price can be 0 but not ''. Also price can be negative for order.
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("UnitPriceHT")), null, 'errors');
$error++;
}
@@ -739,6 +763,7 @@ if (empty($reshook)) {
$pu_ht = $prod->price;
$pu_ttc = $prod->price_ttc;
$price_min = $prod->price_min;
+ $price_min_ttc = $prod->price_min_ttc;
$price_base_type = $prod->price_base_type;
// If price per segment
@@ -746,6 +771,7 @@ if (empty($reshook)) {
$pu_ht = $prod->multiprices[$object->thirdparty->price_level];
$pu_ttc = $prod->multiprices_ttc[$object->thirdparty->price_level];
$price_min = $prod->multiprices_min[$object->thirdparty->price_level];
+ $price_min_ttc = $prod->multiprices_min_ttc[$object->thirdparty->price_level];
$price_base_type = $prod->multiprices_base_type[$object->thirdparty->price_level];
if (!empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) { // using this option is a bug. kept for backward compatibility
if (isset($prod->multiprices_tva_tx[$object->thirdparty->price_level])) {
@@ -769,6 +795,7 @@ if (empty($reshook)) {
$pu_ht = price($prodcustprice->lines[0]->price);
$pu_ttc = price($prodcustprice->lines[0]->price_ttc);
$price_min = price($prodcustprice->lines[0]->price_min);
+ $price_min_ttc = price($prodcustprice->lines[0]->price_min_ttc);
$price_base_type = $prodcustprice->lines[0]->price_base_type;
$tva_tx = $prodcustprice->lines[0]->tva_tx;
if ($prodcustprice->lines[0]->default_vat_code && !preg_match('/\(.*\)/', $tva_tx)) {
@@ -828,13 +855,15 @@ if (empty($reshook)) {
$tmpvat = price2num(preg_replace('/\s*\(.*\)/', '', $tva_tx));
$tmpprodvat = price2num(preg_replace('/\s*\(.*\)/', '', $prod->tva_tx));
- // if price ht is forced (ie: calculated by margin rate and cost price). TODO Why this ?
+ // Set unit price to use
if (!empty($price_ht) || $price_ht === '0') {
$pu_ht = price2num($price_ht, 'MU');
$pu_ttc = price2num($pu_ht * (1 + ($tmpvat / 100)), 'MU');
+ } elseif (!empty($price_ttc) || $price_ttc === '0') {
+ $pu_ttc = price2num($price_ttc, 'MU');
+ $pu_ht = price2num($pu_ttc / (1 + ($tmpvat / 100)), 'MU');
} elseif ($tmpvat != $tmpprodvat) {
- // On reevalue prix selon taux tva car taux tva transaction peut etre different
- // de ceux du produit par defaut (par exemple si pays different entre vendeur et acheteur).
+ // Is this still used ?
if ($price_base_type != 'HT') {
$pu_ht = price2num($pu_ttc / (1 + ($tmpvat / 100)), 'MU');
} else {
@@ -921,14 +950,22 @@ if (empty($reshook)) {
$fk_unit = $prod->fk_unit;
} else {
$pu_ht = price2num($price_ht, 'MU');
- $pu_ttc = price2num(GETPOST('price_ttc'), 'MU');
+ $pu_ttc = price2num($price_ttc, 'MU');
$tva_npr = (preg_match('/\*/', $tva_tx) ? 1 : 0);
$tva_tx = str_replace('*', '', $tva_tx);
+ if (empty($tva_tx)) {
+ $tva_npr = 0;
+ }
$label = (GETPOST('product_label') ? GETPOST('product_label') : '');
$desc = $product_desc;
$type = GETPOST('type');
$fk_unit = GETPOST('units', 'alpha');
$pu_ht_devise = price2num($price_ht_devise, 'MU');
+ $pu_ttc_devise = price2num($price_ttc_devise, 'MU');
+
+ if ($pu_ttc && !$pu_ht) {
+ $price_base_type = 'TTC';
+ }
}
// Margin
@@ -939,17 +976,26 @@ if (empty($reshook)) {
$localtax1_tx = get_localtax($tva_tx, 1, $object->thirdparty);
$localtax2_tx = get_localtax($tva_tx, 2, $object->thirdparty);
- $desc = dol_htmlcleanlastbr($desc);
-
$info_bits = 0;
if ($tva_npr) {
$info_bits |= 0x01;
}
- if (((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS)) && (!empty($price_min) && (price2num($pu_ht) * (1 - price2num($remise_percent) / 100) < price2num($price_min)))) {
- $mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency));
- setEventMessages($mesg, null, 'errors');
- } else {
+ $desc = dol_htmlcleanlastbr($desc);
+
+ if ($usermustrespectpricemin) {
+ if ($pu_ht && $price_min && ((price2num($pu_ht) * (1 - $remise_percent / 100)) < price2num($price_min))) {
+ $mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, -1, $conf->currency));
+ setEventMessages($mesg, null, 'errors');
+ $error++;
+ } elseif ($pu_ttc && $price_min_ttc && ((price2num($pu_ttc) * (1 - $remise_percent / 100)) < price2num($price_min_ttc))) {
+ $mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min_ttc, 'MU'), 0, $langs, 0, 0, -1, $conf->currency));
+ setEventMessages($mesg, null, 'errors');
+ $error++;
+ }
+ }
+
+ if (!$error) {
// Insert line
$result = $object->addline($desc, $pu_ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $info_bits, 0, $price_base_type, $pu_ttc, $date_start, $date_end, $type, min($rank, count($object->lines) + 1), 0, GETPOST('fk_parent_line'), $fournprice, $buyingprice, $label, $array_options, $fk_unit, '', 0, $pu_ht_devise);
@@ -1017,11 +1063,16 @@ if (empty($reshook)) {
$date_start = dol_mktime(GETPOST('date_starthour'), GETPOST('date_startmin'), GETPOST('date_startsec'), GETPOST('date_startmonth'), GETPOST('date_startday'), GETPOST('date_startyear'));
$date_end = dol_mktime(GETPOST('date_endhour'), GETPOST('date_endmin'), GETPOST('date_endsec'), GETPOST('date_endmonth'), GETPOST('date_endday'), GETPOST('date_endyear'));
$description = dol_htmlcleanlastbr(GETPOST('product_desc', 'restricthtml'));
- $pu_ht = price2num(GETPOST('price_ht'), '', 2);
$vat_rate = (GETPOST('tva_tx') ? GETPOST('tva_tx', 'alpha') : 0);
- $pu_ht_devise = price2num(GETPOST('multicurrency_subprice'), '', 2);
+ $vat_rate = str_replace('*', '', $vat_rate);
- $qty = price2num(GETPOST('qty'), 'MS');
+ $pu_ht = price2num(GETPOST('price_ht'), '', 2);
+ $pu_ttc = price2num(GETPOST('price_ttc'), '', 2);
+
+ $pu_ht_devise = price2num(GETPOST('multicurrency_subprice'), '', 2);
+ $pu_ttc_devise = price2num(GETPOST('multicurrency_subprice_ttc'), '', 2);
+
+ $qty = price2num(GETPOST('qty', 'alpha'), 'MS');
// Define info_bits
$info_bits = 0;
@@ -1068,13 +1119,25 @@ if (empty($reshook)) {
if ((!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) && !empty($object->thirdparty->price_level)) {
$price_min = $product->multiprices_min[$object->thirdparty->price_level];
}
+ $price_min_ttc = $product->price_min_ttc;
+ if ((!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) && !empty($object->thirdparty->price_level)) {
+ $price_min_ttc = $product->multiprices_min_ttc[$object->thirdparty->price_level];
+ }
$label = ((GETPOST('update_label') && GETPOST('product_label')) ? GETPOST('product_label') : '');
- if (((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS)) && ($price_min && (price2num($pu_ht) * (1 - $remise_percent / 100) < price2num($price_min)))) {
- setEventMessages($langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency)), null, 'errors');
- $error++;
- $action = 'editline';
+ if ($usermustrespectpricemin) {
+ if ($pu_ht && $price_min && ((price2num($pu_ht) * (1 - $remise_percent / 100)) < price2num($price_min))) {
+ $mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, -1, $conf->currency));
+ setEventMessages($mesg, null, 'errors');
+ $error++;
+ $action = 'editline';
+ } elseif ($pu_ttc && $price_min_ttc && ((price2num($pu_ttc) * (1 - $remise_percent / 100)) < price2num($price_min_ttc))) {
+ $mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min_ttc, 'MU'), 0, $langs, 0, 0, -1, $conf->currency));
+ setEventMessages($mesg, null, 'errors');
+ $error++;
+ $action = 'editline';
+ }
}
} else {
$type = GETPOST('type');
@@ -1104,17 +1167,25 @@ if (empty($reshook)) {
}
}
}
- $result = $object->updateline(GETPOST('lineid', 'int'), $description, $pu_ht, $qty, $remise_percent, $vat_rate, $localtax1_rate, $localtax2_rate, 'HT', $info_bits, $date_start, $date_end, $type, GETPOST('fk_parent_line'), 0, $fournprice, $buyingprice, $label, $special_code, $array_options, GETPOST('units'), $pu_ht_devise);
+
+ $price_base_type = 'HT';
+ $pu = $pu_ht;
+ if (empty($pu) && ! empty($pu_ttc)) {
+ $pu = $pu_ttc;
+ $price_base_type = 'TTC';
+ }
+
+ $result = $object->updateline(GETPOST('lineid', 'int'), $description, $pu, $qty, $remise_percent, $vat_rate, $localtax1_rate, $localtax2_rate, $price_base_type, $info_bits, $date_start, $date_end, $type, GETPOST('fk_parent_line'), 0, $fournprice, $buyingprice, $label, $special_code, $array_options, GETPOST('units'), $pu_ht_devise);
if ($result >= 0) {
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
// Define output language
$outputlangs = $langs;
$newlang = '';
- if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
+ if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
$newlang = GETPOST('lang_id', 'aZ09');
}
- if ($conf->global->MAIN_MULTILANGS && empty($newlang)) {
+ if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) {
$newlang = $object->thirdparty->default_lang;
}
if (!empty($newlang)) {
@@ -1279,10 +1350,10 @@ if (empty($reshook)) {
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
$outputlangs = $langs;
$newlang = '';
- if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
+ if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
$newlang = GETPOST('lang_id', 'aZ09');
}
- if ($conf->global->MAIN_MULTILANGS && empty($newlang)) {
+ if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) {
$newlang = $object->thirdparty->default_lang;
}
if (!empty($newlang)) {
@@ -1752,7 +1823,7 @@ if ($action == 'create' && $usercancreate) {
print '';
// 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) && isModEnabled("banque")) {
print ''.$langs->trans('BankAccount').' ';
print img_picto('', 'bank_account', 'class="pictofixedwidth"').$form->select_comptes($fk_account, 'fk_account', 0, '', 1, '', 0, 'maxwidth200 widthcentpercentminusx', 1);
print ' ';
@@ -2550,7 +2621,7 @@ if ($action == 'create' && $usercancreate) {
}
// 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) && isModEnabled("banque")) {
print '';
$editenable = $usercancreate;
print $form->editfieldkey("BankAccount", 'bankaccount', '', $object, $editenable);
@@ -2647,9 +2718,16 @@ if ($action == 'create' && $usercancreate) {
/*
* Lines
*/
+
+ // Get object lines
$result = $object->getLinesArray();
- print 'id.(($action != 'editline') ? '' : '#line_'.GETPOST('lineid', 'int')).'" method="POST">
+ // Add products/services form
+ //$forceall = 1;
+ global $inputalsopricewithtax;
+ $inputalsopricewithtax = 1;
+
+ print ' id.'" method="POST">
@@ -2737,7 +2815,7 @@ if ($action == 'create' && $usercancreate) {
// Create a purchase order
if (!empty($conf->global->WORKFLOW_CAN_CREATE_PURCHASE_ORDER_FROM_SALE_ORDER)) {
- if (((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled)) && $object->statut > Commande::STATUS_DRAFT && $object->statut < Commande::STATUS_CLOSED && $object->getNbOfServicesLines() > 0) {
+ if (((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order")) && $object->statut > Commande::STATUS_DRAFT && $object->statut < Commande::STATUS_CLOSED && $object->getNbOfServicesLines() > 0) {
if ($usercancreatepurchaseorder) {
print dolGetButtonAction('', $langs->trans('AddPurchaseOrder'), 'default', DOL_URL_ROOT.'/fourn/commande/card.php?action=create&origin='.$object->element.'&originid='.$object->id.'&socid='.$object->socid, '');
}
diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php
index 9a93e8a5047..bf97deb3fd8 100644
--- a/htdocs/commande/class/commande.class.php
+++ b/htdocs/commande/class/commande.class.php
@@ -31,7 +31,7 @@
/**
* \file htdocs/commande/class/commande.class.php
* \ingroup commande
- * \brief Fichier des classes de commandes
+ * \brief class for orders
*/
include_once DOL_DOCUMENT_ROOT.'/core/class/commonorder.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/commonobjectline.class.php';
@@ -93,12 +93,12 @@ class Commande extends CommonOrder
protected $table_ref_field = 'ref';
/**
- * @var int Thirparty ID
+ * @var int Thirdparty ID
*/
public $socid;
/**
- * @var string Thirparty ref of order
+ * @var string Thirdparty ref of order
*/
public $ref_client;
@@ -3710,7 +3710,7 @@ class Commande extends CommonOrder
$result = '';
- if (!empty($conf->expedition->enabled) && ($option == '1' || $option == '2')) {
+ if (isModEnabled("expedition") && ($option == '1' || $option == '2')) {
$url = DOL_URL_ROOT.'/expedition/shipment.php?id='.$this->id;
} else {
$url = DOL_URL_ROOT.'/commande/card.php?id='.$this->id;
diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php
index dbb99d0f993..b92140efa03 100644
--- a/htdocs/commande/list.php
+++ b/htdocs/commande/list.php
@@ -49,7 +49,7 @@ require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
// Load translation files required by the page
-$langs->loadLangs(array("orders", 'sendings', 'deliveries', 'companies', 'compta', 'bills', 'stocks', 'products'));
+$langs->loadLangs(array('orders', 'sendings', 'deliveries', 'companies', 'compta', 'bills', 'stocks', 'products'));
$action = GETPOST('action', 'aZ09');
$massaction = GETPOST('massaction', 'alpha');
@@ -70,6 +70,7 @@ $search_dateorder_start = dol_mktime(0, 0, 0, GETPOST('search_dateorder_start_mo
$search_dateorder_end = dol_mktime(23, 59, 59, GETPOST('search_dateorder_end_month', 'int'), GETPOST('search_dateorder_end_day', 'int'), GETPOST('search_dateorder_end_year', 'int'));
$search_datedelivery_start = dol_mktime(0, 0, 0, GETPOST('search_datedelivery_start_month', 'int'), GETPOST('search_datedelivery_start_day', 'int'), GETPOST('search_datedelivery_start_year', 'int'));
$search_datedelivery_end = dol_mktime(23, 59, 59, GETPOST('search_datedelivery_end_month', 'int'), GETPOST('search_datedelivery_end_day', 'int'), GETPOST('search_datedelivery_end_year', 'int'));
+
$search_product_category = GETPOST('search_product_category', 'int');
$search_ref = GETPOST('search_ref', 'alpha') != '' ?GETPOST('search_ref', 'alpha') : GETPOST('sref', 'alpha');
$search_ref_customer = GETPOST('search_ref_customer', 'alpha');
@@ -77,22 +78,25 @@ $search_company = GETPOST('search_company', 'alpha');
$search_company_alias = GETPOST('search_company_alias', 'alpha');
$search_town = GETPOST('search_town', 'alpha');
$search_zip = GETPOST('search_zip', 'alpha');
-$search_state = GETPOST("search_state", 'alpha');
-$search_country = GETPOST("search_country", 'int');
-$search_type_thirdparty = GETPOST("search_type_thirdparty", 'int');
+$search_state = GETPOST('search_state', 'alpha');
+$search_country = GETPOST('search_country', 'int');
+$search_type_thirdparty = GETPOST('search_type_thirdparty', 'int');
$sall = trim((GETPOST('search_all', 'alphanohtml') != '') ? GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml'));
$socid = GETPOST('socid', 'int');
$search_user = GETPOST('search_user', 'int');
$search_sale = GETPOST('search_sale', 'int');
+
$search_total_ht = GETPOST('search_total_ht', 'alpha');
$search_total_vat = GETPOST('search_total_vat', 'alpha');
$search_total_ttc = GETPOST('search_total_ttc', 'alpha');
$search_warehouse = GETPOST('search_warehouse', 'int');
+
$search_multicurrency_code = GETPOST('search_multicurrency_code', 'alpha');
$search_multicurrency_tx = GETPOST('search_multicurrency_tx', 'alpha');
-$search_multicurrency_montant_ht = GETPOST('search_multicurrency_montant_ht', 'alpha');
+$search_multicurrency_montant_ht = GETPOST('search_multicurrency_montant_ht', 'alpha');
$search_multicurrency_montant_vat = GETPOST('search_multicurrency_montant_vat', 'alpha');
$search_multicurrency_montant_ttc = GETPOST('search_multicurrency_montant_ttc', 'alpha');
+
$search_login = GETPOST('search_login', 'alpha');
$search_categ_cus = GETPOST("search_categ_cus", 'int');
$optioncss = GETPOST('optioncss', 'alpha');
@@ -103,10 +107,11 @@ $search_remove_btn = GETPOST('button_removefilter', 'alpha');
$search_project_ref = GETPOST('search_project_ref', 'alpha');
$search_project = GETPOST('search_project', 'alpha');
$search_shippable = GETPOST('search_shippable', 'aZ09');
-$search_fk_cond_reglement = GETPOST("search_fk_cond_reglement", 'int');
-$search_fk_shipping_method = GETPOST("search_fk_shipping_method", 'int');
-$search_fk_mode_reglement = GETPOST("search_fk_mode_reglement", 'int');
-$search_fk_input_reason = GETPOST("search_fk_input_reason", 'int');
+
+$search_fk_cond_reglement = GETPOST('search_fk_cond_reglement', 'int');
+$search_fk_shipping_method = GETPOST('search_fk_shipping_method', 'int');
+$search_fk_mode_reglement = GETPOST('search_fk_mode_reglement', 'int');
+$search_fk_input_reason = GETPOST('search_fk_input_reason', 'int');
// Security check
$id = (GETPOST('orderid') ?GETPOST('orderid', 'int') : GETPOST('id', 'int'));
@@ -176,7 +181,7 @@ $arrayfields = array(
'typent.code'=>array('label'=>"ThirdPartyType", 'checked'=>$checkedtypetiers, 'position'=>55),
'c.date_commande'=>array('label'=>"OrderDateShort", 'checked'=>1, 'position'=>60),
'c.date_delivery'=>array('label'=>"DateDeliveryPlanned", 'checked'=>1, 'enabled'=>empty($conf->global->ORDER_DISABLE_DELIVERY_DATE), 'position'=>65),
- 'c.fk_shipping_method'=>array('label'=>"SendingMethod", 'checked'=>-1, 'position'=>66 , 'enabled'=>!empty($conf->expedition->enabled)),
+ 'c.fk_shipping_method'=>array('label'=>"SendingMethod", 'checked'=>-1, 'position'=>66 , 'enabled'=>isModEnabled("expedition")),
'c.fk_cond_reglement'=>array('label'=>"PaymentConditionsShort", 'checked'=>-1, 'position'=>67),
'c.fk_mode_reglement'=>array('label'=>"PaymentMode", 'checked'=>-1, 'position'=>68),
'c.fk_input_reason'=>array('label'=>"Channel", 'checked'=>-1, 'position'=>69),
@@ -199,7 +204,7 @@ $arrayfields = array(
'c.date_cloture'=>array('label'=>"DateClosing", 'checked'=>0, 'position'=>130),
'c.note_public'=>array('label'=>'NotePublic', 'checked'=>0, 'enabled'=>(empty($conf->global->MAIN_LIST_ALLOW_PUBLIC_NOTES)), 'position'=>135),
'c.note_private'=>array('label'=>'NotePrivate', 'checked'=>0, 'enabled'=>(empty($conf->global->MAIN_LIST_ALLOW_PRIVATE_NOTES)), 'position'=>140),
- 'shippable'=>array('label'=>"Shippable", 'checked'=>1,'enabled'=>(!empty($conf->expedition->enabled)), 'position'=>990),
+ 'shippable'=>array('label'=>"Shippable", 'checked'=>1,'enabled'=>(isModEnabled("expedition")), 'position'=>990),
'c.facture'=>array('label'=>"Billed", 'checked'=>1, 'enabled'=>(empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT)), 'position'=>995),
'c.import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'position'=>999),
'c.fk_statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000)
@@ -2394,7 +2399,7 @@ if ($resql) {
}
$stock_order = $generic_product->stats_commande['qty'];
}
- if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled)) {
+ if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order")) {
if (empty($productstat_cache[$generic_commande->lines[$lig]->fk_product]['stats_order_supplier'])) {
$generic_product->load_stats_commande_fournisseur(0, '3');
$productstat_cache[$generic_commande->lines[$lig]->fk_product]['stats_order_supplier'] = $generic_product->stats_commande_fournisseur['qty'];
@@ -2415,7 +2420,7 @@ if ($resql) {
} else {
$text_info .= ''.$langs->trans('Available').' : '.$text_stock_reel.' ';
}
- if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled)) {
+ if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order")) {
$text_info .= ' '.$langs->trans('SupplierOrder').' : '.$stock_order_supplier;
}
$text_info .= ($reliquat != $generic_commande->lines[$lig]->qty ? ' ('.$langs->trans("QtyInOtherShipments").' '.($generic_commande->lines[$lig]->qty - $reliquat).') ' : '');
diff --git a/htdocs/compta/accounting-files.php b/htdocs/compta/accounting-files.php
index ab8175c4d38..30d2bedcf14 100644
--- a/htdocs/compta/accounting-files.php
+++ b/htdocs/compta/accounting-files.php
@@ -1,9 +1,10 @@
- * Copyright (C) 2004-2019 Laurent Destailleur
- * Copyright (C) 2017 Pierre-Henry Favre
- * Copyright (C) 2020 Maxime DEMAREST
- * Copyright (C) 2021 Gauthier VERDOL
+/* Copyright (C) 2001-2006 Rodolphe Quiedeville
+ * Copyright (C) 2004-2019 Laurent Destailleur
+ * Copyright (C) 2017 Pierre-Henry Favre
+ * Copyright (C) 2020 Maxime DEMAREST
+ * Copyright (C) 2021 Gauthier VERDOL
+ * Copyright (C) 2022 Alexandre Spangaro
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -116,12 +117,12 @@ if ($user->socid > 0) {
// Define $arrayofentities if multientity is set.
$arrayofentities = array();
-if (!empty($conf->multicompany->enabled) && is_object($mc)) {
+if (isModEnabled('multicompany') && is_object($mc)) {
$arrayofentities = $mc->getEntitiesList();
}
$entity = (GETPOSTISSET('entity') ? GETPOST('entity', 'int') : (GETPOSTISSET('search_entity') ? GETPOST('search_entity', 'int') : $conf->entity));
-if (!empty($conf->multicompany->enabled) && is_object($mc)) {
+if (isModEnabled('multicompany') && is_object($mc)) {
if (empty($entity) && !empty($conf->global->MULTICOMPANY_ALLOW_EXPORT_ACCOUNTING_DOC_FOR_ALL_ENTITIES)) {
$entity = '0,'.join(',', array_keys($arrayofentities));
}
@@ -134,12 +135,12 @@ $error = 0;
$listofchoices = array(
'selectinvoices'=>array('label'=>'Invoices', 'lang'=>'bills', 'enabled' => isModEnabled('facture'), 'perms' => !empty($user->rights->facture->lire)),
- 'selectsupplierinvoices'=>array('label'=>'BillsSuppliers', 'lang'=>'bills', 'enabled' => !empty($conf->supplier_invoice->enabled), 'perms' => !empty($user->rights->fournisseur->facture->lire)),
+ 'selectsupplierinvoices'=>array('label'=>'BillsSuppliers', 'lang'=>'bills', 'enabled' => isModEnabled("supplier_invoice"), 'perms' => !empty($user->rights->fournisseur->facture->lire)),
'selectexpensereports'=>array('label'=>'ExpenseReports', 'lang'=>'trips', 'enabled' => !empty($conf->expensereport->enabled), 'perms' => !empty($user->rights->expensereport->lire)),
'selectdonations'=>array('label'=>'Donations', 'lang'=>'donation', 'enabled' => !empty($conf->don->enabled), 'perms' => !empty($user->rights->don->lire)),
'selectsocialcontributions'=>array('label'=>'SocialContributions', 'enabled' => !empty($conf->tax->enabled), 'perms' => !empty($user->rights->tax->charges->lire)),
'selectpaymentsofsalaries'=>array('label'=>'SalariesPayments', 'lang'=>'salaries', 'enabled' => !empty($conf->salaries->enabled), 'perms' => !empty($user->rights->salaries->read)),
- 'selectvariouspayment'=>array('label'=>'VariousPayment', 'enabled' => !empty($conf->banque->enabled), 'perms' => !empty($user->rights->banque->lire)),
+ 'selectvariouspayment'=>array('label'=>'VariousPayment', 'enabled' => isModEnabled("banque"), 'perms' => !empty($user->rights->banque->lire)),
'selectloanspayment'=>array('label'=>'PaymentLoan', 'enabled' => !empty($conf->loan->enabled), 'perms' => !empty($user->rights->loan->read)),
);
@@ -455,7 +456,7 @@ if ($result && $action == "dl" && !$error) {
dol_mkdir($dirfortmpfile);
$log = $langs->transnoentitiesnoconv("Type");
- if (!empty($conf->multicompany->enabled) && is_object($mc)) {
+ if (isModEnabled('multicompany') && is_object($mc)) {
$log .= ','.$langs->transnoentitiesnoconv("Entity");
}
$log .= ','.$langs->transnoentitiesnoconv("Date");
@@ -497,7 +498,7 @@ if ($result && $action == "dl" && !$error) {
}
$log .= '"'.$langs->trans($file['item']).'"';
- if (!empty($conf->multicompany->enabled) && is_object($mc)) {
+ if (isModEnabled('multicompany') && is_object($mc)) {
$log .= ',"'.(empty($arrayofentities[$file['entity']]) ? $file['entity'] : $arrayofentities[$file['entity']]).'"';
}
$log .= ','.dol_print_date($file['date'], 'dayrfc');
@@ -582,7 +583,7 @@ print "\n";
// Export is for current company only
$socid = 0;
-if (!empty($conf->multicompany->enabled) && is_object($mc)) {
+if (isModEnabled('multicompany') && is_object($mc)) {
$mc->getInfo($conf->entity);
print '('.$langs->trans("Entity").' : ';
print " ";
@@ -626,6 +627,7 @@ print ''."\n";
print dol_get_fiche_end();
+$param = '';
if (!empty($date_start) && !empty($date_stop)) {
$param .= '&date_startday='.GETPOST('date_startday', 'int');
$param .= '&date_startmonth='.GETPOST('date_startmonth', 'int');
@@ -694,14 +696,14 @@ if (!empty($date_start) && !empty($date_stop)) {
print ' '.$langs->trans("Code").' ';
print ''.$langs->trans("Country").' ';
print ''.$langs->trans("VATIntra").' ';
- if (!empty($conf->multicurrency->enabled)) {
+ if (isModEnabled('multicompany')) {
print ''.$langs->trans("Currency").' ';
}
print ' ';
if (empty($TData)) {
print ''.$langs->trans("NoRecordFound").' ';
- if (!empty($conf->multicurrency->enabled)) {
+ if (isModEnabled('multicompany')) {
print ' ';
}
print ' ';
@@ -831,7 +833,7 @@ if (!empty($date_start) && !empty($date_stop)) {
$totalVAT_debit -= $data['amount_vat'];
}
- if (!empty($conf->multicurrency->enabled)) {
+ if (isModEnabled('multicompany')) {
print ''.$data['currency']." \n";
}
@@ -845,7 +847,7 @@ if (!empty($date_start) && !empty($date_stop)) {
print ''.price(price2num($totalIT_credit, 'MT')).' ';
print ''.price(price2num($totalVAT_credit, 'MT')).' ';
print ' ';
- if (!empty($conf->multicurrency->enabled)) {
+ if (isModEnabled('multicompany')) {
print ' ';
}
print "\n";
@@ -856,7 +858,7 @@ if (!empty($date_start) && !empty($date_stop)) {
print ''.price(price2num($totalIT_debit, 'MT')).' ';
print ''.price(price2num($totalVAT_debit, 'MT')).' ';
print ' ';
- if (!empty($conf->multicurrency->enabled)) {
+ if (isModEnabled('multicompany')) {
print ' ';
}
print "\n";
@@ -867,7 +869,7 @@ if (!empty($date_start) && !empty($date_stop)) {
print ''.price(price2num($totalIT_credit + $totalIT_debit, 'MT')).' ';
print ''.price(price2num($totalVAT_credit + $totalVAT_debit, 'MT')).' ';
print ' ';
- if (!empty($conf->multicurrency->enabled)) {
+ if (isModEnabled('multicompany')) {
print ' ';
}
print "\n";
diff --git a/htdocs/compta/bank/bankentries_list.php b/htdocs/compta/bank/bankentries_list.php
index 511d75a12c8..af833e7e257 100644
--- a/htdocs/compta/bank/bankentries_list.php
+++ b/htdocs/compta/bank/bankentries_list.php
@@ -235,8 +235,12 @@ if (empty($reshook)) {
include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
}
+$rowids = GETPOST('rowid', 'array');
+
// Conciliation
-if ((GETPOST('confirm_savestatement', 'alpha') || GETPOST('confirm_reconcile', 'alpha')) && !empty($user->rights->banque->consolidate)
+if ((GETPOST('confirm_savestatement', 'alpha') || GETPOST('confirm_reconcile', 'alpha'))
+ && (GETPOST("num_releve", "alpha") || !empty($rowids))
+ && !empty($user->rights->banque->consolidate)
&& (!GETPOSTISSET('pageplusone') || (GETPOST('pageplusone') == GETPOST('pageplusoneold')))) {
$error = 0;
@@ -357,7 +361,7 @@ if (GETPOST('save') && !$cancel && !empty($user->rights->banque->modifier)) {
$error++;
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Amount")), null, 'errors');
}
- if (!$bankaccountid > 0) {
+ if (!($bankaccountid > 0)) {
$error++;
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BankAccount")), null, 'errors');
}
diff --git a/htdocs/compta/bank/card.php b/htdocs/compta/bank/card.php
index 2751947c023..420ff97ff0d 100644
--- a/htdocs/compta/bank/card.php
+++ b/htdocs/compta/bank/card.php
@@ -6,7 +6,7 @@
* Copyright (C) 2014-2017 Alexandre Spangaro
* Copyright (C) 2015 Jean-François Ferry
* Copyright (C) 2016 Marcos García
- * Copyright (C) 2018 Frédéric France
+ * Copyright (C) 2018-2022 Frédéric France
* Copyright (C) 2022 Charlene Benke
*
* This program is free software; you can redistribute it and/or modify
@@ -68,6 +68,15 @@ $hookmanager->initHooks(array('bankcard', 'globalcard'));
$id = GETPOST("id", 'int') ? GETPOST("id", 'int') : GETPOST('ref', 'alpha');
$fieldid = GETPOST("id", 'int') ? 'rowid' : 'ref';
+if (GETPOST("id", 'int') || GETPOST("ref")) {
+ if (GETPOST("id", 'int')) {
+ $object->fetch(GETPOST("id", 'int'));
+ }
+ if (GETPOST("ref")) {
+ $object->fetch(0, GETPOST("ref"));
+ }
+}
+
$result = restrictedArea($user, 'banque', $id, 'bank_account&bank_account', '', '', $fieldid);
@@ -319,6 +328,7 @@ if (empty($reshook)) {
}
}
+
/*
* View
*/
@@ -333,15 +343,15 @@ if (!empty($conf->accounting->enabled)) {
$countrynotdefined = $langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')';
$help_url = 'EN:Module_Banks_and_Cash|FR:Module_Banques_et_Caisses|ES:Módulo_Bancos_y_Cajas|DE:Modul_Banken_und_Barbestände';
+if ($action == 'create') {
+ $title = $langs->trans("NewFinancialAccount");
+} elseif (!empty($object->ref)) {
+ $title = $object->ref." - ".$langs->trans("Card");
+}
+llxHeader("", $title, $help_url);
// Creation
-
if ($action == 'create') {
- $object = new Account($db);
-
- $title = $langs->trans("NewFinancialAccount");
- llxHeader("", $title, $help_url);
-
print load_fiche_titre($langs->trans("NewFinancialAccount"), '', 'bank_account');
if ($conf->use_javascript_ajax) {
@@ -597,25 +607,8 @@ if ($action == 'create') {
print '';
} else {
- /* ************************************************************************** */
- /* */
- /* Visu et edition */
- /* */
- /* ************************************************************************** */
-
+ // View and edit mode
if ((GETPOST("id", 'int') || GETPOST("ref")) && $action != 'edit') {
- $object = new Account($db);
- if (GETPOST("id", 'int')) {
- $object->fetch(GETPOST("id", 'int'));
- }
- if (GETPOST("ref")) {
- $object->fetch(0, GETPOST("ref"));
- $_GET["id"] = $object->id;
- }
-
- $title = $object->ref." - ".$langs->trans("Card");
- llxHeader("", $title, $help_url);
-
// Show tabs
$head = bank_prepare_head($object);
print dol_get_fiche_head($head, 'bankname', $langs->trans("FinancialAccount"), -1, 'account');
@@ -758,7 +751,7 @@ if ($action == 'create') {
}
print ''.$langs->trans($ibankey).' ';
- print ''.$object->iban.' ';
+ print ' '.getIbanHumanReadable($object).' ';
if (!empty($object->iban)) {
if (!checkIbanForAccount($object)) {
print img_picto($langs->trans("IbanNotValid"), 'warning');
@@ -843,9 +836,6 @@ if ($action == 'create') {
/* ************************************************************************** */
if (GETPOST('id', 'int') && $action == 'edit' && $user->rights->banque->configurer) {
- $object = new Account($db);
- $object->fetch(GETPOST('id', 'int'));
-
print load_fiche_titre($langs->trans("EditFinancialAccount"), '', 'bank_account');
if ($conf->use_javascript_ajax) {
@@ -1014,7 +1004,7 @@ if ($action == 'create') {
$tdextra = ' class="fieldrequired titlefieldcreate"';
}
- print ' '.$langs->trans("AccountancyCode").' ';
+ print ''.$langs->trans("AccountancyCode").' ';
print '';
if (!empty($conf->accounting->enabled)) {
print $formaccounting->select_account($object->account_number, 'account_number', 1, '', 1, 1);
@@ -1089,7 +1079,7 @@ if ($action == 'create') {
print ' ';
}
- if (!empty(isModEnabled('paymentbybanktransfer'))) {
+ if (isModEnabled('paymentbybanktransfer')) {
print ''.$form->textwithpicto($langs->trans("IDS"), $langs->trans("IDS").' ('.$langs->trans("UsedFor", $langs->transnoentitiesnoconv("BankTransfer")).')').' ';
print ' ';
diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php
index 21a082e9491..b42ef184c8f 100644
--- a/htdocs/compta/bank/class/account.class.php
+++ b/htdocs/compta/bank/class/account.class.php
@@ -618,7 +618,7 @@ class Account extends CommonObject
$this->error = $this->db->lasterror();
$this->db->rollback();
- return -3;
+ return -4;
}
}
@@ -630,7 +630,7 @@ class Account extends CommonObject
$this->errors = $accline->errors;
$this->db->rollback();
- return -2;
+ return -5;
}
}
@@ -1381,6 +1381,7 @@ class Account extends CommonObject
public function getNomUrl($withpicto = 0, $mode = '', $option = '', $save_lastsearch_value = -1, $notooltip = 0)
{
global $conf, $langs, $user;
+ include_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php';
$result = '';
$label = img_picto('', $this->picto).' '.$langs->trans("BankAccount").' ';
@@ -1389,7 +1390,7 @@ class Account extends CommonObject
}
$label .= ''.$langs->trans('Label').': '.$this->label;
$label .= ''.$langs->trans('AccountNumber').': '.$this->number;
- $label .= ''.$langs->trans('IBAN').': '.$this->iban;
+ $label .= ''.$langs->trans('IBAN').': '.getIbanHumanReadable($this);
$label .= ''.$langs->trans('BIC').': '.$this->bic;
$label .= ''.$langs->trans("AccountCurrency").': '.$this->currency_code;
diff --git a/htdocs/compta/bank/class/paymentvarious.class.php b/htdocs/compta/bank/class/paymentvarious.class.php
index 48ea553abf0..3d07c280559 100644
--- a/htdocs/compta/bank/class/paymentvarious.class.php
+++ b/htdocs/compta/bank/class/paymentvarious.class.php
@@ -423,11 +423,11 @@ class PaymentVarious extends CommonObject
$this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Amount"));
return -5;
}
- if (!empty($conf->banque->enabled) && (empty($this->fk_account) || $this->fk_account <= 0)) {
+ if (isModEnabled("banque") && (empty($this->fk_account) || $this->fk_account <= 0)) {
$this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("BankAccount"));
return -6;
}
- if (!empty($conf->banque->enabled) && (empty($this->type_payment) || $this->type_payment <= 0)) {
+ if (isModEnabled("banque") && (empty($this->type_payment) || $this->type_payment <= 0)) {
$this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("PaymentMode"));
return -7;
}
@@ -481,7 +481,7 @@ class PaymentVarious extends CommonObject
$this->ref = $this->id;
if ($this->id > 0) {
- if (!empty($conf->banque->enabled) && !empty($this->amount)) {
+ if (isModEnabled("banque") && !empty($this->amount)) {
// Insert into llx_bank
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
diff --git a/htdocs/compta/bank/various_payment/card.php b/htdocs/compta/bank/various_payment/card.php
index cbcb2fd5417..23621157e5a 100644
--- a/htdocs/compta/bank/various_payment/card.php
+++ b/htdocs/compta/bank/various_payment/card.php
@@ -139,7 +139,7 @@ if (empty($reshook)) {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Amount")), null, 'errors');
$error++;
}
- if (!empty($conf->banque->enabled) && !$object->accountid > 0) {
+ if (isModEnabled("banque") && !$object->accountid > 0) {
$langs->load('errors');
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BankAccount")), null, 'errors');
$error++;
@@ -413,7 +413,7 @@ if ($action == 'create') {
print '';
// Bank
- if (!empty($conf->banque->enabled)) {
+ if (isModEnabled("banque")) {
print '';
print $form->editfieldkey('BankAccount', 'selectaccountid', '', $object, 0, 'string', '', 1).' ';
print img_picto('', 'bank_account', 'class="pictofixedwidth"');
@@ -428,7 +428,7 @@ if ($action == 'create') {
print ' ';
// Number
- if (!empty($conf->banque->enabled)) {
+ if (isModEnabled("banque")) {
print ''.$langs->trans('Numero');
print ' ('.$langs->trans("ChequeOrTransferNumber").') ';
print ' ';
@@ -642,7 +642,7 @@ if ($id) {
print $form->editfieldval('SubledgerAccount', 'subledger_account', $object->subledger_account, $object, (!$alreadyaccounted && $user->rights->banque->modifier), 'string', '', 0);
print ' ';
- if (!empty($conf->banque->enabled)) {
+ if (isModEnabled("banque")) {
if ($object->fk_account > 0) {
$bankline = new AccountLine($db);
$bankline->fetch($object->fk_bank);
diff --git a/htdocs/compta/bank/various_payment/list.php b/htdocs/compta/bank/various_payment/list.php
index fdebf7f795c..aa65ac8d2a3 100644
--- a/htdocs/compta/bank/various_payment/list.php
+++ b/htdocs/compta/bank/various_payment/list.php
@@ -152,8 +152,8 @@ $arrayfields = array(
'datev' =>array('label'=>"DateValue", 'checked'=>-1, 'position'=>130),
'type' =>array('label'=>"PaymentMode", 'checked'=>1, 'position'=>140),
'project' =>array('label'=>"Project", 'checked'=>1, 'position'=>200, "enabled"=>!empty($conf->project->enabled)),
- 'bank' =>array('label'=>"BankAccount", 'checked'=>1, 'position'=>300, "enabled"=>!empty($conf->banque->enabled)),
- 'entry' =>array('label'=>"BankTransactionLine", 'checked'=>1, 'position'=>310, "enabled"=>!empty($conf->banque->enabled)),
+ 'bank' =>array('label'=>"BankAccount", 'checked'=>1, 'position'=>300, "enabled"=>isModEnabled("banque")),
+ 'entry' =>array('label'=>"BankTransactionLine", 'checked'=>1, 'position'=>310, "enabled"=>isModEnabled("banque")),
'account' =>array('label'=>"AccountAccountingShort", 'checked'=>1, 'position'=>400, "enabled"=>!empty($conf->accounting->enabled)),
'subledger' =>array('label'=>"SubledgerAccount", 'checked'=>1, 'position'=>410, "enabled"=>!empty($conf->accounting->enabled)),
'debit' =>array('label'=>"Debit", 'checked'=>1, 'position'=>500),
diff --git a/htdocs/compta/cashcontrol/cashcontrol_card.php b/htdocs/compta/cashcontrol/cashcontrol_card.php
index 2b6b027d7ce..0130cfe10f0 100644
--- a/htdocs/compta/cashcontrol/cashcontrol_card.php
+++ b/htdocs/compta/cashcontrol/cashcontrol_card.php
@@ -128,7 +128,7 @@ if (GETPOST('cancel', 'alpha')) {
if ($action == "reopen") {
$result = $object->setStatut($object::STATUS_DRAFT, null, '', 'CASHFENCE_REOPEN');
if ($result < 0) {
- setEventMessages($object->error, $object->error, 'errors');
+ setEventMessages($object->error, $object->errors, 'errors');
}
$action = 'view';
diff --git a/htdocs/compta/charges/index.php b/htdocs/compta/charges/index.php
index 169666477f4..a80916cdc0d 100644
--- a/htdocs/compta/charges/index.php
+++ b/htdocs/compta/charges/index.php
@@ -146,7 +146,7 @@ if (!empty($conf->tax->enabled) && $user->rights->tax->charges->lire) {
print_liste_field_titre("RefPayment", $_SERVER["PHP_SELF"], "pc.rowid", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre("DatePayment", $_SERVER["PHP_SELF"], "pc.datep", "", $param, 'align="center"', $sortfield, $sortorder);
print_liste_field_titre("Type", $_SERVER["PHP_SELF"], "pct.code", "", $param, '', $sortfield, $sortorder);
- if (!empty($conf->banque->enabled)) {
+ if (isModEnabled("banque")) {
print_liste_field_titre("Account", $_SERVER["PHP_SELF"], "ba.label", "", $param, "", $sortfield, $sortorder);
}
print_liste_field_titre("PayedByThisPayment", $_SERVER["PHP_SELF"], "pc.amount", "", $param, 'class="right"', $sortfield, $sortorder);
@@ -220,7 +220,7 @@ if (!empty($conf->tax->enabled) && $user->rights->tax->charges->lire) {
}
print $obj->num_payment.'';
// Account
- if (!empty($conf->banque->enabled)) {
+ if (isModEnabled("banque")) {
print '';
if ($obj->fk_bank > 0) {
//$accountstatic->fetch($obj->fk_bank);
@@ -254,7 +254,7 @@ if (!empty($conf->tax->enabled) && $user->rights->tax->charges->lire) {
print ' ';
print ' ';
print ' ';
- if (!empty($conf->banque->enabled)) {
+ if (isModEnabled("banque")) {
print ' ';
}
print ''.price($totalpaid)." ";
@@ -304,7 +304,7 @@ if (!empty($conf->tax->enabled) && $user->rights->tax->charges->lire) {
print_liste_field_titre("RefPayment", $_SERVER["PHP_SELF"], "ptva.rowid", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre("DatePayment", $_SERVER["PHP_SELF"], "ptva.datep", "", $param, 'align="center"', $sortfield, $sortorder);
print_liste_field_titre("Type", $_SERVER["PHP_SELF"], "pct.code", "", $param, '', $sortfield, $sortorder);
- if (!empty($conf->banque->enabled)) {
+ if (isModEnabled("banque")) {
print_liste_field_titre("Account", $_SERVER["PHP_SELF"], "ba.label", "", $param, "", $sortfield, $sortorder);
}
print_liste_field_titre("PayedByThisPayment", $_SERVER["PHP_SELF"], "ptva.amount", "", $param, 'class="right"', $sortfield, $sortorder);
@@ -341,7 +341,7 @@ if (!empty($conf->tax->enabled) && $user->rights->tax->charges->lire) {
print $obj->num_payment.'';
// Account
- if (!empty($conf->banque->enabled)) {
+ if (isModEnabled("banque")) {
print '';
if ($obj->fk_bank > 0) {
//$accountstatic->fetch($obj->fk_bank);
diff --git a/htdocs/compta/facture/card-rec.php b/htdocs/compta/facture/card-rec.php
index 18a935cedb4..630cafcd3bf 100644
--- a/htdocs/compta/facture/card-rec.php
+++ b/htdocs/compta/facture/card-rec.php
@@ -650,8 +650,8 @@ if (empty($reshook)) {
// Define output language
$outputlangs = $langs;
$newlang = '';
- if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','aZ09')) $newlang = GETPOST('lang_id','aZ09');
- if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang;
+ if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang) && GETPOST('lang_id','aZ09')) $newlang = GETPOST('lang_id','aZ09');
+ if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) $newlang = $object->thirdparty->default_lang;
if (! empty($newlang)) {
$outputlangs = new Translate("", $conf);
$outputlangs->setDefaultLang($newlang);
@@ -857,9 +857,9 @@ if (empty($reshook)) {
// Define output language
$outputlangs = $langs;
$newlang = '';
- if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','aZ09'))
+ if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang) && GETPOST('lang_id','aZ09'))
$newlang = GETPOST('lang_id','aZ09');
- if ($conf->global->MAIN_MULTILANGS && empty($newlang))
+ if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang))
$newlang = $object->thirdparty->default_lang;
if (! empty($newlang)) {
$outputlangs = new Translate("", $conf);
@@ -990,8 +990,8 @@ if ($action == 'create') {
$substitutionarray['__INVOICE_YEAR__'] = $langs->trans("YearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($object->date, '%Y').')';
$substitutionarray['__INVOICE_NEXT_YEAR__'] = $langs->trans("NextYearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($object->date, 1, 'y'), '%Y').')';
// Only on template invoices
- $substitutionarray['__INVOICE_DATE_NEXT_INVOICE_BEFORE_GEN__'] = $langs->trans("DateNextInvoiceBeforeGen").' ('.$langs->trans("Example").': '.dol_print_date($object->date_when, 'dayhour').')';
- $substitutionarray['__INVOICE_DATE_NEXT_INVOICE_AFTER_GEN__'] = $langs->trans("DateNextInvoiceAfterGen").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($object->date_when, $object->frequency, $object->unit_frequency), 'dayhour').')';
+ $substitutionarray['__INVOICE_DATE_NEXT_INVOICE_BEFORE_GEN__'] = $langs->trans("DateNextInvoiceBeforeGen").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($object->date, 1, 'm'), 'dayhour').')';
+ $substitutionarray['__INVOICE_DATE_NEXT_INVOICE_AFTER_GEN__'] = $langs->trans("DateNextInvoiceAfterGen").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($object->date, 2, 'm'), 'dayhour').')';
$substitutionarray['__INVOICE_COUNTER_CURRENT__'] = $langs->trans("Count");
$substitutionarray['__INVOICE_COUNTER_MAX__'] = $langs->trans("MaxPeriodNumber");
diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php
index 59345604d1d..f9075a76211 100644
--- a/htdocs/compta/facture/card.php
+++ b/htdocs/compta/facture/card.php
@@ -37,11 +37,13 @@
* \brief Page to create/see an invoice
*/
+// Libraries
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
+
require_once DOL_DOCUMENT_ROOT.'/core/modules/facture/modules_facture.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
@@ -51,6 +53,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
+
if (!empty($conf->commande->enabled)) {
require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
}
@@ -69,16 +72,19 @@ if (!empty($conf->accounting->enabled)) {
// Load translation files required by the page
$langs->loadLangs(array('bills', 'companies', 'compta', 'products', 'banks', 'main', 'withdrawals'));
+
if (!empty($conf->incoterm->enabled)) {
$langs->load('incoterm');
}
+
if (!empty($conf->margin->enabled)) {
$langs->load('margins');
}
+// General $Variables
$projectid = (GETPOST('projectid', 'int') ? GETPOST('projectid', 'int') : 0);
-$id = (GETPOST('id', 'int') ? GETPOST('id', 'int') : GETPOST('facid', 'int')); // For backward compatibility
+$id = (GETPOST('id', 'int') ? GETPOST('id', 'int') : GETPOST('facid', 'int')); // For backward compatibility
$ref = GETPOST('ref', 'alpha');
$socid = GETPOST('socid', 'int');
$action = GETPOST('action', 'aZ09');
@@ -102,7 +108,7 @@ $hidedetails = (GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', 'int') :
$hidedesc = (GETPOST('hidedesc', 'int') ? GETPOST('hidedesc', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0));
$hideref = (GETPOST('hideref', 'int') ? GETPOST('hideref', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0));
-// Nombre de ligne pour choix de produit/service predefinis
+// Number of lines for predefined product/service choices
$NBLINES = 4;
$usehm = (!empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE) ? $conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE : 0);
@@ -128,11 +134,14 @@ if ($id > 0 || !empty($ref)) {
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$hookmanager->initHooks(array('invoicecard', 'globalcard'));
-$usercanread = $user->rights->facture->lire;
-$usercancreate = $user->rights->facture->creer;
-$usercanissuepayment = $user->rights->facture->paiement;
-$usercandelete = $user->rights->facture->supprimer;
-$usercancreatecontract = $user->rights->contrat->creer;
+// Permissions
+$usercanread = $user->hasRight("facture", "lire");
+$usercancreate = $user->hasRight("facture", "creer");
+$usercanissuepayment = $user->hasRight("facture", "paiement");
+$usercandelete = $user->hasRight("facture", "supprimer");
+$usercancreatecontract = $user->hasRight("contrat", "creer");
+
+// Advanced Permissions
$usercanvalidate = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $usercancreate) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->facture->invoice_advance->validate)));
$usercansend = (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->facture->invoice_advance->send)));
$usercanreopen = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $usercancreate) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->facture->invoice_advance->reopen)));
@@ -141,7 +150,7 @@ if (!empty($conf->global->INVOICE_DISALLOW_REOPEN)) {
}
$usercanunvalidate = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($usercancreate)) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->facture->invoice_advance->unvalidate)));
-$usercanproductignorepricemin = ((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS));
+$usermustrespectpricemin = ((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS));
$usercancreatemargin = (!empty($user->rights->margins->creer) ? $user->rights->margins->creer : 0);
$usercanreadallmargin = (!empty($user->rights->margins->liretous) ? $user->rights->margins->liretous : 0);
$usercancreatewithdrarequest = (!empty($user->rights->prelevement->bons->creer) ? $user->rights->prelevement->bons->creer : 0);
@@ -272,10 +281,10 @@ if (empty($reshook)) {
// Define output language
$outputlangs = $langs;
$newlang = '';
- if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) {
+ if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang) && GETPOST('lang_id')) {
$newlang = GETPOST('lang_id');
}
- if ($conf->global->MAIN_MULTILANGS && empty($newlang)) {
+ if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) {
$newlang = $object->thirdparty->default_lang;
}
if (!empty($newlang)) {
@@ -520,10 +529,10 @@ if (empty($reshook)) {
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
$outputlangs = $langs;
$newlang = '';
- if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
+ if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
$newlang = GETPOST('lang_id', 'aZ09');
}
- if ($conf->global->MAIN_MULTILANGS && empty($newlang)) {
+ if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) {
$newlang = $object->thirdparty->default_lang;
}
if (!empty($newlang)) {
@@ -604,10 +613,10 @@ if (empty($reshook)) {
if (empty($error) && empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
$outputlangs = $langs;
$newlang = '';
- if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
+ if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
$newlang = GETPOST('lang_id', 'aZ09');
}
- if ($conf->global->MAIN_MULTILANGS && empty($newlang)) {
+ if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) {
$newlang = $object->thirdparty->default_lang;
}
if (!empty($newlang)) {
@@ -659,10 +668,10 @@ if (empty($reshook)) {
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
$outputlangs = $langs;
$newlang = '';
- if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
+ if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
$newlang = GETPOST('lang_id', 'aZ09');
}
- if ($conf->global->MAIN_MULTILANGS && empty($newlang)) {
+ if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) {
$newlang = $object->thirdparty->default_lang;
}
if (!empty($newlang)) {
@@ -749,10 +758,10 @@ if (empty($reshook)) {
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
$outputlangs = $langs;
$newlang = '';
- if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
+ if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
$newlang = GETPOST('lang_id', 'aZ09');
}
- if ($conf->global->MAIN_MULTILANGS && empty($newlang)) {
+ if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) {
$newlang = $object->thirdparty->default_lang;
}
if (!empty($newlang)) {
@@ -1956,10 +1965,10 @@ if (empty($reshook)) {
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE) && count($object->lines)) {
$outputlangs = $langs;
$newlang = '';
- if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
+ if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
$newlang = GETPOST('lang_id', 'aZ09');
}
- if ($conf->global->MAIN_MULTILANGS && empty($newlang)) {
+ if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) {
$newlang = $object->thirdparty->default_lang;
}
if (!empty($newlang)) {
@@ -2008,19 +2017,39 @@ if (empty($reshook)) {
// Set if we used free entry or predefined product
$predef = '';
$product_desc =(GETPOSTISSET('dp_desc') ? GETPOST('dp_desc', 'restricthtml') : '');
- $price_ht = price2num(GETPOST('price_ht'), 'MU', 2);
- $price_ht_devise = price2num(GETPOST('multicurrency_price_ht'), 'CU', 2);
- $prod_entry_mode = GETPOST('prod_entry_mode', 'alpha');
+
+ $price_ht = '';
+ $price_ht_devise = '';
+ $price_ttc = '';
+ $price_ttc_devise = '';
+
+ if (GETPOST('price_ht') !== '') {
+ $price_ht = price2num(GETPOST('price_ht'), 'MU', 2);
+ }
+ if (GETPOST('multicurrency_price_ht') !== '') {
+ $price_ht_devise = price2num(GETPOST('multicurrency_price_ht'), 'CU', 2);
+ }
+ if (GETPOST('price_ttc') !== '') {
+ $price_ttc = price2num(GETPOST('price_ttc'), 'MU', 2);
+ }
+ if (GETPOST('multicurrency_price_ttc') !== '') {
+ $price_ttc_devise = price2num(GETPOST('multicurrency_price_ttc'), 'CU', 2);
+ }
+
+ $prod_entry_mode = GETPOST('prod_entry_mode', 'aZ09');
if ($prod_entry_mode == 'free') {
$idprod = 0;
- $tva_tx = (GETPOST('tva_tx', 'alpha') ? GETPOST('tva_tx', 'alpha') : 0);
+ $tva_tx = (GETPOST('tva_tx', 'alpha') ? price2num(preg_replace('/\s*\(.*\)/', '', GETPOST('tva_tx', 'alpha'))) : 0);
} else {
$idprod = GETPOST('idprod', 'int');
$tva_tx = '';
}
- $qty = price2num(GETPOST('qty'.$predef), 'MS', 2);
- $remise_percent = price2num(GETPOST('remise_percent'.$predef), '', 2);
+ $qty = price2num(GETPOST('qty'.$predef, 'alpha'), 'MS', 2);
+ $remise_percent = (GETPOSTISSET('remise_percent'.$predef) ? price2num(GETPOST('remise_percent'.$predef, 'alpha'), '', 2) : 0);
+ if (empty($remise_percent)) {
+ $remise_percent = 0;
+ }
// Extrafields
$extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line);
@@ -2047,8 +2076,8 @@ if (empty($reshook)) {
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Type')), null, 'errors');
$error++;
}
- if (($prod_entry_mode == 'free' && (empty($idprod) || $idprod < 0) && (($price_ht < 0 && empty($conf->global->FACTURE_ENABLE_NEGATIVE_LINES)) || $price_ht == '') && $price_ht_devise == '') && $object->type != Facture::TYPE_CREDIT_NOTE) { // Unit price can be 0 but not ''
- if ($price_ht < 0 && empty($conf->global->FACTURE_ENABLE_NEGATIVE_LINES)) {
+ if ($prod_entry_mode == 'free' && (empty($idprod) || $idprod < 0) && (($price_ht < 0 && empty($conf->global->FACTURE_ENABLE_NEGATIVE_LINES)) || $price_ht == '') && (($price_ht_devise < 0 && empty($conf->global->FACTURE_ENABLE_NEGATIVE_LINES)) || $price_ht_devise == '') && $price_ttc === '' && $price_ttc_devise === '' && $object->type != Facture::TYPE_CREDIT_NOTE) { // Unit price can be 0 but not ''
+ if (($price_ht < 0 || $price_ttc < 0) && empty($conf->global->FACTURE_ENABLE_NEGATIVE_LINES)) {
$langs->load("errors");
if ($object->type == $object::TYPE_DEPOSIT) {
// Using negative lines on deposit lead to headach and blocking problems when you want to consume them.
@@ -2126,20 +2155,24 @@ if (empty($reshook)) {
$pu_ht = $datapriceofproduct['pu_ht'];
$pu_ttc = $datapriceofproduct['pu_ttc'];
$price_min = $datapriceofproduct['price_min'];
+ $price_min_ttc = $datapriceofproduct['price_min_ttc'];
$price_base_type = $datapriceofproduct['price_base_type'];
+
$tva_tx = $datapriceofproduct['tva_tx'];
$tva_npr = $datapriceofproduct['tva_npr'];
$tmpvat = price2num(preg_replace('/\s*\(.*\)/', '', $tva_tx));
$tmpprodvat = price2num(preg_replace('/\s*\(.*\)/', '', $prod->tva_tx));
- // if price ht was forced (ie: from gui when calculated by margin rate and cost price). TODO Why this ?
+ // Set unit price to use
if (!empty($price_ht) || $price_ht === '0') {
$pu_ht = price2num($price_ht, 'MU');
$pu_ttc = price2num($pu_ht * (1 + ($tmpvat / 100)), 'MU');
+ } elseif (!empty($price_ttc) || $price_ttc === '0') {
+ $pu_ttc = price2num($price_ttc, 'MU');
+ $pu_ht = price2num($pu_ttc / (1 + ($tmpvat / 100)), 'MU');
} elseif ($tmpvat != $tmpprodvat) {
- // On reevalue prix selon taux tva car taux tva transaction peut etre different
- // de ceux du produit par defaut (par exemple si pays different entre vendeur et acheteur).
+ // Is this still used ?
if ($price_base_type != 'HT') {
$pu_ht = price2num($pu_ttc / (1 + ($tmpvat / 100)), 'MU');
} else {
@@ -2227,7 +2260,7 @@ if (empty($reshook)) {
$fk_unit = $prod->fk_unit;
} else {
$pu_ht = price2num($price_ht, 'MU');
- $pu_ttc = price2num(GETPOST('price_ttc'), 'MU');
+ $pu_ttc = price2num($price_ttc, 'MU');
$tva_npr = (preg_match('/\*/', $tva_tx) ? 1 : 0);
$tva_tx = str_replace('*', '', $tva_tx);
if (empty($tva_tx)) {
@@ -2238,6 +2271,11 @@ if (empty($reshook)) {
$type = GETPOST('type');
$fk_unit = GETPOST('units', 'alpha');
$pu_ht_devise = price2num($price_ht_devise, 'MU');
+ $pu_ttc_devise = price2num($price_ttc_devise, 'MU');
+
+ if ($pu_ttc && !$pu_ht) {
+ $price_base_type = 'TTC';
+ }
}
// Margin
@@ -2256,6 +2294,7 @@ if (empty($reshook)) {
$price2num_pu_ht = price2num($pu_ht);
$price2num_remise_percent = price2num($remise_percent);
$price2num_price_min = price2num($price_min);
+ $price2num_price_min_ttc = price2num($price_min_ttc);
if (empty($price2num_pu_ht)) {
$price2num_pu_ht = 0;
}
@@ -2265,11 +2304,24 @@ if (empty($reshook)) {
if (empty($price2num_price_min)) {
$price2num_price_min = 0;
}
+ if (empty($price2num_price_min_ttc)) {
+ $price2num_price_min_ttc = 0;
+ }
- if ($usercanproductignorepricemin && (!empty($price_min) && ($price2num_pu_ht * (1 - $price2num_remise_percent / 100) < $price2num_price_min))) {
- $mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency));
- setEventMessages($mesg, null, 'errors');
- } else {
+ // Check price is not lower than minimum (check is done only for standard or replacement invoices)
+ if ($usermustrespectpricemin && ($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_REPLACEMENT)) {
+ if ($pu_ht && $price_min && ((price2num($pu_ht) * (1 - $remise_percent / 100)) < price2num($price_min))) {
+ $mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, -1, $conf->currency));
+ setEventMessages($mesg, null, 'errors');
+ $error++;
+ } elseif ($pu_ttc && $price_min_ttc && ((price2num($pu_ttc) * (1 - $remise_percent / 100)) < price2num($price_min_ttc))) {
+ $mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min_ttc, 'MU'), 0, $langs, 0, 0, -1, $conf->currency));
+ setEventMessages($mesg, null, 'errors');
+ $error++;
+ }
+ }
+
+ if (!$error) {
// Add batchinfo if the detail_batch array is defined
if (!empty($conf->productbatch->enabled) && !empty($lines[$i]->detail_batch) && is_array($lines[$i]->detail_batch) && !empty($conf->global->INVOICE_INCUDE_DETAILS_OF_LOTS_SERIALS)) {
$langs->load('productbatch');
@@ -2286,10 +2338,10 @@ if (empty($reshook)) {
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
$outputlangs = $langs;
$newlang = '';
- if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
+ if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
$newlang = GETPOST('lang_id', 'aZ09');
}
- if ($conf->global->MAIN_MULTILANGS && empty($newlang)) {
+ if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) {
$newlang = $object->thirdparty->default_lang;
}
if (!empty($newlang)) {
@@ -2360,10 +2412,16 @@ if (empty($reshook)) {
$date_start = dol_mktime(GETPOST('date_starthour'), GETPOST('date_startmin'), GETPOST('date_startsec'), GETPOST('date_startmonth'), GETPOST('date_startday'), GETPOST('date_startyear'));
$date_end = dol_mktime(GETPOST('date_endhour'), GETPOST('date_endmin'), GETPOST('date_endsec'), GETPOST('date_endmonth'), GETPOST('date_endday'), GETPOST('date_endyear'));
$description = dol_htmlcleanlastbr(GETPOST('product_desc', 'restricthtml') ? GETPOST('product_desc', 'restricthtml') : GETPOST('desc', 'restricthtml'));
- $pu_ht = price2num(GETPOST('price_ht'), '', 2);
$vat_rate = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0);
- $qty = GETPOST('qty');
+ $vat_rate = str_replace('*', '', $vat_rate);
+
+ $pu_ht = price2num(GETPOST('price_ht'), '', 2);
+ $pu_ttc = price2num(GETPOST('price_ttc'), '', 2);
+
$pu_ht_devise = price2num(GETPOST('multicurrency_subprice'), '', 2);
+ $pu_ttc_devise = price2num(GETPOST('multicurrency_subprice_ttc'), '', 2);
+
+ $qty = price2num(GETPOST('qty', 'alpha'), 'MS');
// Define info_bits
$info_bits = 0;
@@ -2434,15 +2492,28 @@ if (empty($reshook)) {
$price_min = $product->price_min;
if ((!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) && !empty($object->thirdparty->price_level)) {
- $price_min = $product->multiprices_min [$object->thirdparty->price_level];
+ $price_min = $product->multiprices_min[$object->thirdparty->price_level];
+ }
+ $price_min_ttc = $product->price_min_ttc;
+ if ((!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) && !empty($object->thirdparty->price_level)) {
+ $price_min_ttc = $product->multiprices_min_ttc[$object->thirdparty->price_level];
}
$label = ((GETPOST('update_label') && GETPOST('product_label')) ? GETPOST('product_label') : '');
// Check price is not lower than minimum (check is done only for standard or replacement invoices)
- if ($usercanproductignorepricemin && (($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_REPLACEMENT) && $price_min && (price2num($pu_ht) * (1 - $remise_percent / 100) < price2num($price_min)))) {
- setEventMessages($langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency)), null, 'errors');
- $error++;
+ if ($usermustrespectpricemin && ($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_REPLACEMENT)) {
+ if ($pu_ht && $price_min && ((price2num($pu_ht) * (1 - $remise_percent / 100)) < price2num($price_min))) {
+ $mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, -1, $conf->currency));
+ setEventMessages($mesg, null, 'errors');
+ $error++;
+ $action = 'editline';
+ } elseif ($pu_ttc && $price_min_ttc && ((price2num($pu_ttc) * (1 - $remise_percent / 100)) < price2num($price_min_ttc))) {
+ $mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min_ttc, 'MU'), 0, $langs, 0, 0, -1, $conf->currency));
+ setEventMessages($mesg, null, 'errors');
+ $error++;
+ $action = 'editline';
+ }
}
} else {
$type = GETPOST('type');
@@ -2459,8 +2530,8 @@ if (empty($reshook)) {
setEventMessages($langs->trans('ErrorQtyForCustomerInvoiceCantBeNegative'), null, 'errors');
$error++;
}
- if ((empty($productid) && (($pu_ht < 0 && empty($conf->global->FACTURE_ENABLE_NEGATIVE_LINES)) || $pu_ht == '') && $pu_ht_devise == '') && $object->type != Facture::TYPE_CREDIT_NOTE) { // Unit price can be 0 but not ''
- if ($pu_ht < 0 && empty($conf->global->FACTURE_ENABLE_NEGATIVE_LINES)) {
+ if (empty($productid) && (($pu_ht < 0 && empty($conf->global->FACTURE_ENABLE_NEGATIVE_LINES)) || $pu_ht == '') && (($pu_ht_devise < 0 && empty($conf->global->FACTURE_ENABLE_NEGATIVE_LINES)) || $pu_ht_devise == '') && $pu_ttc === '' && $pu_ttc_devise === '' && $object->type != Facture::TYPE_CREDIT_NOTE) { // Unit price can be 0 but not ''
+ if (($pu_ht < 0 || $pu_ttc < 0) && empty($conf->global->FACTURE_ENABLE_NEGATIVE_LINES)) {
$langs->load("errors");
if ($object->type == $object::TYPE_DEPOSIT) {
// Using negative lines on deposit lead to headach and blocking problems when you want to consume them.
@@ -2488,10 +2559,17 @@ if (empty($reshook)) {
}
}
+ $price_base_type = 'HT';
+ $pu = $pu_ht;
+ if (empty($pu) && ! empty($pu_ttc)) {
+ $pu = $pu_ttc;
+ $price_base_type = 'TTC';
+ }
+
$result = $object->updateline(
GETPOST('lineid', 'int'),
$description,
- $pu_ht,
+ $pu,
$qty,
$remise_percent,
$date_start,
@@ -2499,7 +2577,7 @@ if (empty($reshook)) {
$vat_rate,
$localtax1_rate,
$localtax2_rate,
- 'HT',
+ $price_base_type,
$info_bits,
$type,
GETPOST('fk_parent_line', 'int'),
@@ -2519,10 +2597,10 @@ if (empty($reshook)) {
// Define output language
$outputlangs = $langs;
$newlang = '';
- if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
+ if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
$newlang = GETPOST('lang_id', 'aZ09');
}
- if ($conf->global->MAIN_MULTILANGS && empty($newlang)) {
+ if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) {
$newlang = $object->thirdparty->default_lang;
}
if (!empty($newlang)) {
@@ -3652,7 +3730,7 @@ if ($action == 'create') {
print ' ';
// Bank Account
- if (!empty($conf->banque->enabled)) {
+ if (isModEnabled("banque")) {
print ''.$langs->trans('BankAccount').' ';
print img_picto('', 'bank_account', 'class="pictofixedwidth"');
print $form->select_comptes(($fk_account < 0 ? '' : $fk_account), 'fk_account', 0, '', 1, '', 0, 'maxwidth200 widthcentpercentminusx', 1);
@@ -3785,7 +3863,7 @@ if ($action == 'create') {
// Calcul contrat->price (HT), contrat->total (TTC), contrat->tva
$objectsrc->remise_absolue = $remise_absolue;
$objectsrc->remise_percent = $remise_percent;
- $objectsrc->update_price(1, - 1, 1);
+ $objectsrc->update_price(1, 'auto', 1);
}
print "\n\n";
@@ -4215,7 +4293,7 @@ if ($action == 'create') {
// Cree un tableau formulaire
$formquestion = array('text' => $langs->trans("ConfirmCancelBillQuestion"), array('type' => 'radio', 'name' => 'close_code', 'label' => $langs->trans("Reason"), 'values' => $arrayreasons), array('type' => 'text', 'name' => 'close_note', 'label' => $langs->trans("Comment"), 'value' => '', 'morecss' => 'minwidth300'));
- $formconfirm = $form->formconfirm($_SERVER['PHP_SELF'].'?facid='.$object->id, $langs->trans('CancelBill'), $langs->trans('ConfirmCancelBill', $object->ref), 'confirm_canceled', $formquestion, "yes", 1, 250);
+ $formconfirm = $form->formconfirm($_SERVER['PHP_SELF'].'?facid='.$object->id, $langs->trans('CancelBill'), $langs->trans('ConfirmCancelBill', $object->ref), 'confirm_canceled', $formquestion, "yes", 1, 270);
}
}
@@ -4552,7 +4630,7 @@ if ($action == 'create') {
}
// Bank Account
- if (!empty($conf->banque->enabled)) {
+ if (isModEnabled("banque")) {
print ' ';
print '';
print $langs->trans('BankAccount');
@@ -4808,7 +4886,7 @@ if ($action == 'create') {
if (!empty($conf->project->enabled)) {
$nbrows++;
}
- if (!empty($conf->banque->enabled)) {
+ if (isModEnabled("banque")) {
$nbrows++;
$nbcols++;
}
@@ -4837,7 +4915,7 @@ if ($action == 'create') {
print ' '.$langs->trans('ListOfSituationInvoices').' ';
print ' ';
print ''.$langs->trans('Situation').' ';
- if (!empty($conf->banque->enabled)) {
+ if (isModEnabled("banque")) {
print ' ';
}
print ''.$langs->trans('AmountHT').' ';
@@ -4861,7 +4939,7 @@ if ($action == 'create') {
print ''.$prev_invoice->getNomUrl(1).' ';
print ' ';
print ''.(($prev_invoice->type == Facture::TYPE_CREDIT_NOTE) ? $langs->trans('situationInvoiceShortcode_AS') : $langs->trans('situationInvoiceShortcode_S')).$prev_invoice->situation_counter.' ';
- if (!empty($conf->banque->enabled)) {
+ if (isModEnabled("banque")) {
print ' ';
}
print ''.price($prev_invoice->total_ht).' ';
@@ -4881,7 +4959,7 @@ if ($action == 'create') {
print ''.$object->getNomUrl(1).' ';
print ' ';
print ''.(($object->type == Facture::TYPE_CREDIT_NOTE) ? $langs->trans('situationInvoiceShortcode_AS') : $langs->trans('situationInvoiceShortcode_S')).$object->situation_counter.' ';
- if (!empty($conf->banque->enabled)) {
+ if (isModEnabled("banque")) {
print ' ';
}
print ''.price($object->total_ht).' ';
@@ -4904,7 +4982,7 @@ if ($action == 'create') {
$i++;
}
print '';
- if (!empty($conf->banque->enabled)) {
+ if (isModEnabled("banque")) {
print ' ';
}
print ''.price($total_global_ht).' ';
@@ -4936,7 +5014,7 @@ if ($action == 'create') {
print ''.$next_invoice->getNomUrl(1).' ';
print ' ';
print ''.(($next_invoice->type == Facture::TYPE_CREDIT_NOTE) ? $langs->trans('situationInvoiceShortcode_AS') : $langs->trans('situationInvoiceShortcode_S')).$next_invoice->situation_counter.' ';
- if (!empty($conf->banque->enabled)) {
+ if (isModEnabled("banque")) {
print ' ';
}
print ''.price($next_invoice->total_ht).' ';
@@ -4950,7 +5028,7 @@ if ($action == 'create') {
print '';
print ' ';
- if (!empty($conf->banque->enabled)) {
+ if (isModEnabled("banque")) {
print ' ';
}
print ''.price($total_global_ht).' ';
@@ -4977,7 +5055,7 @@ if ($action == 'create') {
print ''.($object->type == Facture::TYPE_CREDIT_NOTE ? $langs->trans("PaymentsBack") : $langs->trans('Payments')).' ';
print ''.$langs->trans('Date').' ';
print ''.$langs->trans('Type').' ';
- if (!empty($conf->banque->enabled)) {
+ if (isModEnabled("banque")) {
print ''.$langs->trans('BankAccount').' ';
}
print ''.$langs->trans('Amount').' ';
@@ -5026,7 +5104,7 @@ if ($action == 'create') {
print '';
$label = ($langs->trans("PaymentType".$objp->payment_code) != ("PaymentType".$objp->payment_code)) ? $langs->trans("PaymentType".$objp->payment_code) : $objp->payment_label;
print ''.$label.' '.$objp->num_payment.' ';
- if (!empty($conf->banque->enabled)) {
+ if (isModEnabled("banque")) {
$bankaccountstatic->id = $objp->baid;
$bankaccountstatic->ref = $objp->baref;
$bankaccountstatic->label = $objp->baref;
@@ -5107,7 +5185,7 @@ if ($action == 'create') {
print '';
print ''.price($obj->amount_ttc).' ';
print '';
- print 'id.'&action=unlinkdiscount&discountid='.$obj->rowid.'">'.img_delete().' ';
+ print 'id.'&action=unlinkdiscount&token='.newToken().'&discountid='.$obj->rowid.'">'.img_delete().' ';
print ' ';
$i++;
if ($invoice->type == Facture::TYPE_CREDIT_NOTE) {
@@ -5192,7 +5270,9 @@ if ($action == 'create') {
}
print '';
print '';
- print ''.(!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency).' '.price(price2num($object->multicurrency_tx*$resteapayeraffiche, 'MT')).' ';
+ print '';
+ //print (empty($object->multicurrency_code) ? $conf->currency : $object->multicurrency_code).' ';
+ print price(price2num($object->multicurrency_tx*$resteapayeraffiche, 'MT'), 1, $langs, 1, -1, -1, (empty($object->multicurrency_code) ? $conf->currency : $object->multicurrency_code)).' ';
}
// Retained warranty : usualy use on construction industry
@@ -5280,10 +5360,15 @@ if ($action == 'create') {
include DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php';
}
- // Lines
+ // Get object lines
$result = $object->getLinesArray();
- // Show global modifiers
+ // Add products/services form
+ //$forceall = 1;
+ global $inputalsopricewithtax;
+ $inputalsopricewithtax = 1;
+
+ // Show global modifiers for situation invoices
if (!empty($conf->global->INVOICE_USE_SITUATION)) {
if ($object->situation_cycle_ref && $object->statut == 0) {
print ''."\n";
@@ -5325,7 +5410,7 @@ if ($action == 'create') {
}
}
- print ' id.(($action != 'editline') ? '' : '#line_'.GETPOST('lineid', 'int')).'" method="POST">
+ print ' id.'" method="POST">
diff --git a/htdocs/compta/facture/class/api_invoices.class.php b/htdocs/compta/facture/class/api_invoices.class.php
index 285d9d366f7..51c094d898e 100644
--- a/htdocs/compta/facture/class/api_invoices.class.php
+++ b/htdocs/compta/facture/class/api_invoices.class.php
@@ -1410,7 +1410,7 @@ class Invoices extends DolibarrApi
throw new RestException(403, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
- if (!empty($conf->banque->enabled)) {
+ if (isModEnabled("banque")) {
if (empty($accountid)) {
throw new RestException(400, 'Account ID is mandatory');
}
@@ -1469,7 +1469,7 @@ class Invoices extends DolibarrApi
throw new RestException(400, 'Payment error : '.$paymentobj->error);
}
- if (!empty($conf->banque->enabled)) {
+ if (isModEnabled("banque")) {
$label = '(CustomerInvoicePayment)';
if ($paymentobj->paiementcode == 'CHQ' && empty($chqemetteur)) {
@@ -1533,7 +1533,7 @@ class Invoices extends DolibarrApi
}
}
- if (!empty($conf->banque->enabled)) {
+ if (isModEnabled("banque")) {
if (empty($accountid)) {
throw new RestException(400, 'Account ID is mandatory');
}
@@ -1617,7 +1617,7 @@ class Invoices extends DolibarrApi
$this->db->rollback();
throw new RestException(400, 'Payment error : '.$paymentobj->error);
}
- if (!empty($conf->banque->enabled)) {
+ if (isModEnabled("banque")) {
$label = '(CustomerInvoicePayment)';
if ($paymentobj->paiementcode == 'CHQ' && empty($chqemetteur)) {
throw new RestException(400, 'Emetteur is mandatory when payment code is '.$paymentobj->paiementcode);
diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php
index 91b5df73a00..0d2840adb97 100644
--- a/htdocs/compta/facture/class/facture.class.php
+++ b/htdocs/compta/facture/class/facture.class.php
@@ -598,10 +598,10 @@ class Facture extends CommonInvoice
$outputlangs = $langs;
$newlang = '';
- if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($this->thirdparty->default_lang)) {
+ if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang) && isset($this->thirdparty->default_lang)) {
$newlang = $this->thirdparty->default_lang; // for proposal, order, invoice, ...
}
- if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($this->default_lang)) {
+ if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang) && isset($this->default_lang)) {
$newlang = $this->default_lang; // for thirdparty
}
if (!empty($newlang)) {
diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php
index 23f53c3d405..5442fd1704a 100644
--- a/htdocs/compta/facture/list.php
+++ b/htdocs/compta/facture/list.php
@@ -1533,7 +1533,7 @@ if ($resql) {
// Status
if (!empty($arrayfields['f.fk_statut']['checked'])) {
print '';
- $liststatus = array('0'=>$langs->trans("BillShortStatusDraft"), '1'=>$langs->trans("BillShortStatusNotPaid"), '0,1'=>$langs->trans("BillShortStatusDraft").'+'.$langs->trans("BillShortStatusNotPaid"), '2'=>$langs->trans("BillShortStatusPaid"), '1,2'=>$langs->trans("BillShortStatusNotPaid").'+'.$langs->trans("BillShortStatusPaid"), '3'=>$langs->trans("BillShortStatusCanceled"));
+ $liststatus = array('0'=>$langs->trans("BillShortStatusDraft"), '0,1'=>$langs->trans("BillShortStatusDraft").'+'.$langs->trans("BillShortStatusNotPaid"), '1'=>$langs->trans("BillShortStatusNotPaid"), '1,2'=>$langs->trans("BillShortStatusNotPaid").'+'.$langs->trans("BillShortStatusPaid"), '2'=>$langs->trans("BillShortStatusPaid"), '3'=>$langs->trans("BillShortStatusCanceled"));
print $form->selectarray('search_status', $liststatus, $search_status, 1, 0, 0, '', 0, 0, 0, '', '', 1);
print ' ';
}
@@ -1771,6 +1771,7 @@ if ($resql) {
$facturestatic->situation_cycle_ref = $obj->situation_cycle_ref;
$facturestatic->situation_counter = $obj->situation_counter;
}
+
$companystatic->id = $obj->socid;
$companystatic->name = $obj->name;
$companystatic->name_alias = $obj->alias;
@@ -2418,7 +2419,7 @@ if ($resql) {
// Status
if (!empty($arrayfields['f.fk_statut']['checked'])) {
print '';
- print $facturestatic->LibStatut($obj->paye, $obj->fk_statut, 5, $paiement, $obj->type);
+ print $facturestatic->getLibStatut(5, $paiement);
print " ";
if (!$i) {
$totalarray['nbfield']++;
diff --git a/htdocs/compta/localtax/card.php b/htdocs/compta/localtax/card.php
index 9bd37eafa36..84f40f5cd19 100644
--- a/htdocs/compta/localtax/card.php
+++ b/htdocs/compta/localtax/card.php
@@ -174,7 +174,7 @@ if ($action == 'create') {
// Amount
print ''.$langs->trans("Amount").' ';
- if (!empty($conf->banque->enabled)) {
+ if (isModEnabled("banque")) {
// Type payment
print ''.$langs->trans("PaymentMode").' ';
$form->select_types_paiements(GETPOST("paiementtype"), "paiementtype", '', 0, 1, 0, 0, 1, 'maxwidth500 widthcentpercentminusx');
@@ -243,7 +243,7 @@ if ($id) {
print ' '.$langs->trans("Amount").' '.price($object->amount).' ';
- if (!empty($conf->banque->enabled)) {
+ if (isModEnabled("banque")) {
if ($object->fk_account > 0) {
$bankline = new AccountLine($db);
$bankline->fetch($object->fk_bank);
diff --git a/htdocs/compta/localtax/class/localtax.class.php b/htdocs/compta/localtax/class/localtax.class.php
index 63b4f982316..ed467ec91f4 100644
--- a/htdocs/compta/localtax/class/localtax.class.php
+++ b/htdocs/compta/localtax/class/localtax.class.php
@@ -467,11 +467,11 @@ class Localtax extends CommonObject
$this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Amount"));
return -4;
}
- if (!empty($conf->banque->enabled) && (empty($this->accountid) || $this->accountid <= 0)) {
+ if (isModEnabled("banque") && (empty($this->accountid) || $this->accountid <= 0)) {
$this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Account"));
return -5;
}
- if (!empty($conf->banque->enabled) && (empty($this->paymenttype) || $this->paymenttype <= 0)) {
+ if (isModEnabled("banque") && (empty($this->paymenttype) || $this->paymenttype <= 0)) {
$this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("PaymentMode"));
return -5;
}
@@ -503,7 +503,7 @@ class Localtax extends CommonObject
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."localtax"); // TODO devrait s'appeler paiementlocaltax
if ($this->id > 0) {
$ok = 1;
- if (!empty($conf->banque->enabled)) {
+ if (isModEnabled("banque")) {
// Insertion dans llx_bank
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
diff --git a/htdocs/compta/paiement.php b/htdocs/compta/paiement.php
index aea9f917dab..5aa41f10405 100644
--- a/htdocs/compta/paiement.php
+++ b/htdocs/compta/paiement.php
@@ -170,7 +170,7 @@ if (empty($reshook)) {
$error++;
}
- if (!empty($conf->banque->enabled)) {
+ if (isModEnabled("banque")) {
// If bank module is on, account is required to enter a payment
if (GETPOST('accountid') <= 0) {
setEventMessages($langs->transnoentities('ErrorFieldRequired', $langs->transnoentities('AccountToCredit')), null, 'errors');
@@ -244,7 +244,7 @@ if (empty($reshook)) {
$multicurrency_code[$key] = $tmpinvoice->multicurrency_code;
}
- if (!empty($conf->banque->enabled)) {
+ if (isModEnabled("banque")) {
// If the bank module is active, an account is required to input a payment
if (GETPOST('accountid', 'int') <= 0) {
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentities('AccountToCredit')), null, 'errors');
@@ -492,7 +492,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
// Bank account
print '';
- if (!empty($conf->banque->enabled)) {
+ if (isModEnabled("banque")) {
if ($facture->type != 2) {
print ''.$langs->trans('AccountToCredit').' ';
}
diff --git a/htdocs/compta/paiement/card.php b/htdocs/compta/paiement/card.php
index bd5c114e983..f163041a43a 100644
--- a/htdocs/compta/paiement/card.php
+++ b/htdocs/compta/paiement/card.php
@@ -32,7 +32,7 @@ require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/modules/facture/modules_facture.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php';
-if (!empty($conf->banque->enabled)) {
+if (isModEnabled("banque")) {
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
}
@@ -285,7 +285,7 @@ print ' '.$langs->trans('Amount').' '.price($object->amount, '',
$disable_delete = 0;
// Bank account
-if (!empty($conf->banque->enabled)) {
+if (isModEnabled("banque")) {
$bankline = new AccountLine($db);
if ($object->fk_account > 0) {
@@ -327,7 +327,7 @@ print ' ';
*/
// Bank account
-if (!empty($conf->banque->enabled)) {
+if (isModEnabled("banque")) {
if ($object->fk_account > 0) {
if ($object->type_code == 'CHQ' && $bankline->fk_bordereau > 0) {
include_once DOL_DOCUMENT_ROOT.'/compta/paiement/cheque/class/remisecheque.class.php';
@@ -425,7 +425,7 @@ if ($resql) {
print '';
print ''.$langs->trans('Bill').' ';
print ''.$langs->trans('Company').' ';
- if (!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_INVOICE_SHARING_ENABLED)) {
+ if (isModEnabled('multicompany') && !empty($conf->global->MULTICOMPANY_INVOICE_SHARING_ENABLED)) {
print ''.$langs->trans('Entity').' ';
}
print ''.$langs->trans('ExpectedToPay').' ';
@@ -462,7 +462,7 @@ if ($resql) {
print '';
// Expected to pay
- if (!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_INVOICE_SHARING_ENABLED)) {
+ if (isModEnabled('multicompany') && !empty($conf->global->MULTICOMPANY_INVOICE_SHARING_ENABLED)) {
print '';
$mc->getInfo($objp->entity);
print $mc->label;
diff --git a/htdocs/compta/paiement/cheque/card.php b/htdocs/compta/paiement/cheque/card.php
index 8c859e6e689..5409d3c381e 100644
--- a/htdocs/compta/paiement/cheque/card.php
+++ b/htdocs/compta/paiement/cheque/card.php
@@ -59,8 +59,15 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$offset = $limit * $page;
$upload_dir = $conf->bank->multidir_output[$object->entity ? $object->entity : $conf->entity]."/checkdeposits";
-
-$filterdate = dol_mktime(0, 0, 0, GETPOST('fdmonth'), GETPOST('fdday'), GETPOST('fdyear'));
+// filter by dates from / to
+$search_date_start_day = GETPOST('search_date_start_day', 'int');
+$search_date_start_month = GETPOST('search_date_start_month', 'int');
+$search_date_start_year = GETPOST('search_date_start_year', 'int');
+$search_date_end_day = GETPOST('search_date_end_day', 'int');
+$search_date_end_month = GETPOST('search_date_end_month', 'int');
+$search_date_end_year = GETPOST('search_date_end_year', 'int');
+$search_date_start = dol_mktime(0, 0, 0, $search_date_start_month, $search_date_start_day, $search_date_start_year);
+$search_date_end = dol_mktime(23, 59, 59, $search_date_end_month, $search_date_end_day, $search_date_end_year);
$filteraccountid = GETPOST('accountid', 'int');
// Security check
@@ -131,10 +138,10 @@ if ($action == 'create' && GETPOST("accountid", "int") > 0 && $user->rights->ban
// Define output language
$outputlangs = $langs;
$newlang = '';
- if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
+ if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
$newlang = GETPOST('lang_id', 'aZ09');
}
- //if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang;
+ //if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) $newlang=$object->client->default_lang;
if (!empty($newlang)) {
$outputlangs = new Translate("", $conf);
$outputlangs->setDefaultLang($newlang);
@@ -182,10 +189,10 @@ if ($action == 'confirm_validate' && $confirm == 'yes' && $user->rights->banque-
// Define output language
$outputlangs = $langs;
$newlang = '';
- if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
+ if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
$newlang = GETPOST('lang_id', 'aZ09');
}
- //if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang;
+ //if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) $newlang=$object->client->default_lang;
if (!empty($newlang)) {
$outputlangs = new Translate("", $conf);
$outputlangs->setDefaultLang($newlang);
@@ -224,10 +231,10 @@ if ($action == 'builddoc' && $user->rights->banque->cheque) {
$outputlangs = $langs;
$newlang = '';
- if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
+ if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
$newlang = GETPOST('lang_id', 'aZ09');
}
- //if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang;
+ //if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) $newlang=$object->client->default_lang;
if (!empty($newlang)) {
$outputlangs = new Translate("", $conf);
$outputlangs->setDefaultLang($newlang);
@@ -265,7 +272,15 @@ if ($action == 'builddoc' && $user->rights->banque->cheque) {
*/
if (GETPOST('removefilter')) {
- $filterdate = '';
+ // filter by dates from / to
+ $search_date_start_day = '';
+ $search_date_start_month = '';
+ $search_date_start_year = '';
+ $search_date_end_day = '';
+ $search_date_end_month = '';
+ $search_date_end_year = '';
+ $search_date_start = '';
+ $search_date_end = '';
$filteraccountid = 0;
}
@@ -352,7 +367,13 @@ if ($action == 'new') {
//print ' '.$langs->trans('Date').' '.dol_print_date($now,'day').' ';
// Filter
print ''.$langs->trans("DateChequeReceived").' ';
- print $form->selectDate($filterdate, 'fd', 0, 0, 1, '', 1, 1);
+ // filter by dates from / to
+ print '';
+ print $form->selectDate($search_date_start, 'search_date_start_', 0, 0, 1, '', 1, 1, 0, '', '', '', '', 1, '', $langs->trans('From'));
+ print '
';
+ print '';
+ print $form->selectDate($search_date_end, 'search_date_end_', 0, 0, 1, '', 1, 1, 0, '', '', '', '', 1, '', $langs->trans('to'));
+ print '
';
print ' ';
print ''.$langs->trans("BankAccount").' ';
$form->select_comptes($filteraccountid, 'accountid', 0, 'courant <> 2', 1);
@@ -363,7 +384,7 @@ if ($action == 'new') {
print '';
print '
';
- if ($filterdate || $filteraccountid > 0) {
+ if ($search_date_start || $search_date_end || $filteraccountid > 0) {
print ' ';
print '
';
}
@@ -382,8 +403,11 @@ if ($action == 'new') {
$sql .= " AND ba.entity IN (".getEntity('bank_account').")";
$sql .= " AND b.fk_bordereau = 0";
$sql .= " AND b.amount > 0";
- if ($filterdate) {
- $sql .= " AND b.dateo = '".$db->idate($filterdate)."'";
+ if ($search_date_start) {
+ $sql .= " AND b.dateo >= '".$db->idate($search_date_start)."'";
+ }
+ if ($search_date_end) {
+ $sql .= " AND b.dateo <= '".$db->idate($search_date_end)."'";
}
if ($filteraccountid > 0) {
$sql .= " AND ba.rowid = ".((int) $filteraccountid);
diff --git a/htdocs/compta/paiement/class/paiement.class.php b/htdocs/compta/paiement/class/paiement.class.php
index 25543ed9d82..6186083c211 100644
--- a/htdocs/compta/paiement/class/paiement.class.php
+++ b/htdocs/compta/paiement/class/paiement.class.php
@@ -8,7 +8,7 @@
* Copyright (C) 2015 Juanjo Menent
* Copyright (C) 2018 Ferran Marcet
* Copyright (C) 2018 Thibault FOUCART
- * Copyright (C) 2018 Frédéric France
+ * Copyright (C) 2018-2022 Frédéric France
* Copyright (C) 2020 Andreu Bisquerra Gaya
* Copyright (C) 2021 OpenDsi
*
@@ -455,7 +455,7 @@ class Paiement extends CommonObject
$newlang = '';
$outputlangs = $langs;
- if ($conf->global->MAIN_MULTILANGS && empty($newlang)) {
+ if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) {
$invoice->fetch_thirdparty();
$newlang = $invoice->thirdparty->default_lang;
}
@@ -464,8 +464,8 @@ class Paiement extends CommonObject
$outputlangs->setDefaultLang($newlang);
}
- $hidedetails = ! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0;
- $hidedesc = ! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0;
+ $hidedetails = !empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0;
+ $hidedesc = !empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0;
$hideref = !empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0;
$ret = $invoice->fetch($facid); // Reload to get new records
@@ -628,7 +628,7 @@ class Paiement extends CommonObject
$error = 0;
$bank_line_id = 0;
- if (!empty($conf->banque->enabled)) {
+ if (isModEnabled("banque")) {
if ($accountid <= 0) {
$this->error = 'Bad value for parameter accountid='.$accountid;
dol_syslog(get_class($this).'::addPaymentToBank '.$this->error, LOG_ERR);
diff --git a/htdocs/compta/paiement/list.php b/htdocs/compta/paiement/list.php
index 988d6e041be..e6b57137df8 100644
--- a/htdocs/compta/paiement/list.php
+++ b/htdocs/compta/paiement/list.php
@@ -104,8 +104,8 @@ $arrayfields = array(
'p.datep' => array('label'=>"Date", 'checked'=>1, 'position'=>20),
's.nom' => array('label'=>"ThirdParty", 'checked'=>1, 'position'=>30),
'c.libelle' => array('label'=>"Type", 'checked'=>1, 'position'=>40),
- 'transaction' => array('label'=>"BankTransactionLine", 'checked'=>1, 'position'=>50, 'enabled'=>(!empty($conf->banque->enabled))),
- 'ba.label' => array('label'=>"Account", 'checked'=>1, 'position'=>60, 'enabled'=>(!empty($conf->banque->enabled))),
+ 'transaction' => array('label'=>"BankTransactionLine", 'checked'=>1, 'position'=>50, 'enabled'=>(isModEnabled("banque"))),
+ 'ba.label' => array('label'=>"Account", 'checked'=>1, 'position'=>60, 'enabled'=>(isModEnabled("banque"))),
'p.num_paiement' => array('label'=>"Numero", 'checked'=>1, 'position'=>70, 'tooltip'=>"ChequeOrTransferNumber"),
'p.amount' => array('label'=>"Amount", 'checked'=>1, 'position'=>80),
'p.statut' => array('label'=>"Status", 'checked'=>1, 'position'=>90, 'enabled'=>(!empty($conf->global->BILL_ADD_PAYMENT_VALIDATION))),
diff --git a/htdocs/compta/paiement_charge.php b/htdocs/compta/paiement_charge.php
index ba62c36b0fa..50236a29e64 100644
--- a/htdocs/compta/paiement_charge.php
+++ b/htdocs/compta/paiement_charge.php
@@ -71,7 +71,7 @@ if ($action == 'add_payment' || ($action == 'confirm_paiement' && $confirm == 'y
$error++;
$action = 'create';
}
- if (!empty($conf->banque->enabled) && !(GETPOST("accountid") > 0)) {
+ if (isModEnabled("banque") && !(GETPOST("accountid") > 0)) {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("AccountToCredit")), null, 'errors');
$error++;
$action = 'create';
@@ -169,13 +169,8 @@ if ($action == 'create') {
}
print load_fiche_titre($langs->trans("DoPayment"));
- print " \n";
- if ($mesg) {
- print "$mesg
";
- }
-
- print '';
+ print ' ';
print ' ';
print ' ';
print ' ';
diff --git a/htdocs/compta/paiement_vat.php b/htdocs/compta/paiement_vat.php
index 645fd36bc2a..f1f243bc06d 100644
--- a/htdocs/compta/paiement_vat.php
+++ b/htdocs/compta/paiement_vat.php
@@ -69,7 +69,7 @@ if ($action == 'add_payment' || ($action == 'confirm_paiement' && $confirm == 'y
$error++;
$action = 'create';
}
- if (!empty($conf->banque->enabled) && !(GETPOST("accountid", 'int') > 0)) {
+ if (isModEnabled("banque") && !(GETPOST("accountid", 'int') > 0)) {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("AccountToDebit")), null, 'errors');
$error++;
$action = 'create';
diff --git a/htdocs/compta/payment_sc/card.php b/htdocs/compta/payment_sc/card.php
index f5ff5a101f2..f76cc6b27c1 100644
--- a/htdocs/compta/payment_sc/card.php
+++ b/htdocs/compta/payment_sc/card.php
@@ -31,7 +31,7 @@ require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php'
require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/paymentsocialcontribution.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/modules/facture/modules_facture.php';
-if (!empty($conf->banque->enabled)) {
+if (isModEnabled("banque")) {
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
}
@@ -141,7 +141,7 @@ print ''.$langs->trans('Amount').' '.price($object->
print ' '.$langs->trans('Note').' '.nl2br($object->note).' ';
// Bank account
-if (!empty($conf->banque->enabled)) {
+if (isModEnabled("banque")) {
if ($object->bank_account) {
$bankline = new AccountLine($db);
$bankline->fetch($object->bank_line);
diff --git a/htdocs/compta/payment_vat/card.php b/htdocs/compta/payment_vat/card.php
index 94dd817900e..401752af11b 100644
--- a/htdocs/compta/payment_vat/card.php
+++ b/htdocs/compta/payment_vat/card.php
@@ -31,7 +31,7 @@ require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/paymentvat.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/modules/facture/modules_facture.php';
-if (!empty($conf->banque->enabled)) {
+if (isModEnabled("banque")) {
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
}
@@ -194,7 +194,7 @@ print ''.$langs->trans('Amount').' '.price($object->
print ' '.$langs->trans('Note').' '.nl2br($object->note).' ';
// Bank account
-if (!empty($conf->banque->enabled)) {
+if (isModEnabled("banque")) {
if ($object->bank_account) {
$bankline = new AccountLine($db);
$bankline->fetch($object->bank_line);
diff --git a/htdocs/compta/resultat/clientfourn.php b/htdocs/compta/resultat/clientfourn.php
index 30d4f4ce825..dc4a2acfda7 100644
--- a/htdocs/compta/resultat/clientfourn.php
+++ b/htdocs/compta/resultat/clientfourn.php
@@ -69,12 +69,12 @@ if (!$sortorder) {
// Date range
$year = GETPOST('year', 'int');
if (empty($year)) {
- $year_current = strftime("%Y", dol_now());
- $month_current = strftime("%m", dol_now());
+ $year_current = dol_print_date(dol_now(), "%Y");
+ $month_current = dol_print_date(dol_now(), "%m");
$year_start = $year_current;
} else {
$year_current = $year;
- $month_current = strftime("%m", dol_now());
+ $month_current = dol_print_date(dol_now(), "%m");
$year_start = $year;
}
$date_start = dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear);
@@ -250,6 +250,7 @@ if ($date_endyear) {
print '';
print '';
+
if ($modecompta == 'BOOKKEEPING') {
print_liste_field_titre("PredefinedGroups", $_SERVER["PHP_SELF"], 'f.thirdparty_code,f.rowid', '', $param, '', $sortfield, $sortorder, 'width200 ');
} else {
@@ -261,6 +262,8 @@ if ($modecompta == 'BOOKKEEPING') {
} else {
if ($modecompta == 'CREANCES-DETTES') {
print_liste_field_titre("AmountHT", $_SERVER["PHP_SELF"], 'amount_ht', '', $param, 'class="right"', $sortfield, $sortorder);
+ } else {
+ print_liste_field_titre(''); // Make 4 columns in total whatever $modecompta is
}
print_liste_field_titre("AmountTTC", $_SERVER["PHP_SELF"], 'amount_ttc', '', $param, 'class="right"', $sortfield, $sortorder);
}
@@ -1036,7 +1039,7 @@ if ($modecompta == 'BOOKKEEPING') {
if ($modecompta == 'CREANCES-DETTES' || $modecompta == 'RECETTES-DEPENSES') {
$langs->load('trips');
if ($modecompta == 'CREANCES-DETTES') {
- $sql = "SELECT p.rowid, p.ref, u.rowid as userid, u.firstname, u.lastname, date_format(date_valid,'%Y-%m') as dm, sum(p.total_ht) as amount_ht,sum(p.total_ttc) as amount_ttc";
+ $sql = "SELECT p.rowid, p.ref, u.rowid as userid, u.firstname, u.lastname, date_format(date_valid,'%Y-%m') as dm, p.total_ht as amount_ht, p.total_ttc as amount_ttc";
$sql .= " FROM ".MAIN_DB_PREFIX."expensereport as p";
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid=p.fk_user_author";
$sql .= " WHERE p.entity IN (".getEntity('expensereport').")";
@@ -1044,7 +1047,7 @@ if ($modecompta == 'BOOKKEEPING') {
$column = 'p.date_valid';
} else {
- $sql = "SELECT p.rowid, p.ref, u.rowid as userid, u.firstname, u.lastname, date_format(pe.datep,'%Y-%m') as dm, sum(p.total_ht) as amount_ht, sum(p.total_ttc) as amount_ttc";
+ $sql = "SELECT p.rowid, p.ref, u.rowid as userid, u.firstname, u.lastname, date_format(pe.datep,'%Y-%m') as dm, sum(pe.amount) as amount_ht, sum(pe.amount) as amount_ttc";
$sql .= " FROM ".MAIN_DB_PREFIX."expensereport as p";
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid=p.fk_user_author";
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."payment_expensereport as pe ON pe.fk_expensereport = p.rowid";
@@ -1124,7 +1127,7 @@ if ($modecompta == 'BOOKKEEPING') {
*/
//$conf->global->ACCOUNTING_REPORTS_INCLUDE_VARPAY = 1;
- if (!empty($conf->global->ACCOUNTING_REPORTS_INCLUDE_VARPAY) && !empty($conf->banque->enabled) && ($modecompta == 'CREANCES-DETTES' || $modecompta == "RECETTES-DEPENSES")) {
+ if (!empty($conf->global->ACCOUNTING_REPORTS_INCLUDE_VARPAY) && isModEnabled("banque") && ($modecompta == 'CREANCES-DETTES' || $modecompta == "RECETTES-DEPENSES")) {
$subtotal_ht = 0;
$subtotal_ttc = 0;
@@ -1525,18 +1528,24 @@ print ' ';
print ''.$langs->trans("Income").' ';
if ($modecompta == 'CREANCES-DETTES') {
print ''.price(price2num($total_ht_income, 'MT')).' ';
+} else {
+ print ' ';
}
print ''.price(price2num($total_ttc_income, 'MT')).' ';
print ' ';
print ''.$langs->trans("Outcome").' ';
if ($modecompta == 'CREANCES-DETTES') {
print ''.price(price2num(-$total_ht_outcome, 'MT')).' ';
+} else {
+ print ' ';
}
print ''.price(price2num(-$total_ttc_outcome, 'MT')).' ';
print ' ';
print ''.$langs->trans("Profit").' ';
if ($modecompta == 'CREANCES-DETTES') {
print ''.price(price2num($total_ht, 'MT')).' ';
+} else {
+ print ' ';
}
print ''.price(price2num($total_ttc, 'MT')).' ';
print ' ';
diff --git a/htdocs/compta/resultat/index.php b/htdocs/compta/resultat/index.php
index 719b1deb29a..90c24e8e905 100644
--- a/htdocs/compta/resultat/index.php
+++ b/htdocs/compta/resultat/index.php
@@ -47,12 +47,12 @@ $nbofyear = 4;
// Date range
$year = GETPOST('year', 'int');
if (empty($year)) {
- $year_current = strftime("%Y", dol_now());
- $month_current = strftime("%m", dol_now());
+ $year_current = dol_print_date(dol_now(), "%Y");
+ $month_current = dol_print_date(dol_now(), "%m");
$year_start = $year_current - ($nbofyear - 1);
} else {
$year_current = $year;
- $month_current = strftime("%m", dol_now());
+ $month_current = dol_print_date(dol_now(), "%m");
$year_start = $year - ($nbofyear - 1);
}
$date_start = dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear);
@@ -796,7 +796,7 @@ if (!empty($conf->don->enabled) && ($modecompta == 'CREANCES-DETTES' || $modecom
* Various Payments
*/
-if (!empty($conf->global->ACCOUNTING_REPORTS_INCLUDE_VARPAY) && !empty($conf->banque->enabled) && ($modecompta == 'CREANCES-DETTES' || $modecompta == "RECETTES-DEPENSES")) {
+if (!empty($conf->global->ACCOUNTING_REPORTS_INCLUDE_VARPAY) && isModEnabled("banque") && ($modecompta == 'CREANCES-DETTES' || $modecompta == "RECETTES-DEPENSES")) {
// decaiss
$sql = "SELECT date_format(p.datep, '%Y-%m') AS dm, SUM(p.amount) AS amount FROM ".MAIN_DB_PREFIX."payment_various as p";
diff --git a/htdocs/compta/resultat/result.php b/htdocs/compta/resultat/result.php
index c296d4037e5..81e6672a1e4 100644
--- a/htdocs/compta/resultat/result.php
+++ b/htdocs/compta/resultat/result.php
@@ -1,6 +1,6 @@
- * Copyright (C) 2016 Alexandre Spangaro
+ * Copyright (C) 2016-2022 Alexandre Spangaro
* Copyright (C) 2018-2020 Laurent Destailleur
* Copyright (C) 2018 Frédéric France
*
@@ -228,7 +228,7 @@ if ($modecompta == "CREANCES-DETTES") {
$period .= ' '.$langs->trans("DetailByAccount").' '.$form->selectarray('showaccountdetail', $arraylist, $showaccountdetail, 0);
$periodlink = $textprevyear.$textnextyear;
$exportlink = '';
- $description = $langs->trans("RulesResultBookkeepingPersonalized").
+ $description = $langs->trans("RulesResultBookkeepingPersonalized");
$description .= ' ('.$langs->trans("SeePageForSetup", DOL_URL_ROOT.'/accountancy/admin/categories_list.php?search_country_id='.$mysoc->country_id.'&mainmenu=accountancy&leftmenu=accountancy_admin', $langs->transnoentitiesnoconv("Accountancy").' / '.$langs->transnoentitiesnoconv("Setup").' / '.$langs->transnoentitiesnoconv("AccountingCategory")).')';
//if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $description.= $langs->trans("DepositsAreNotIncluded");
//else $description.= $langs->trans("DepositsAreIncluded");
diff --git a/htdocs/compta/sociales/card.php b/htdocs/compta/sociales/card.php
index 6cc3496ced0..f6bc9b5fa02 100644
--- a/htdocs/compta/sociales/card.php
+++ b/htdocs/compta/sociales/card.php
@@ -192,7 +192,7 @@ if ($action == 'add' && $user->rights->tax->charges->creer) {
} elseif (!$dateperiod) {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Period")), null, 'errors');
$action = 'create';
- } elseif (!$actioncode > 0) {
+ } elseif (!($actioncode > 0)) {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Type")), null, 'errors');
$action = 'create';
} elseif (empty($amount)) {
@@ -426,7 +426,7 @@ if ($action == 'create') {
print '';
// Bank Account
- if (!empty($conf->banque->enabled)) {
+ if (isModEnabled("banque")) {
print ''.$langs->trans('DefaultBankAccount').' ';
print img_picto('', 'bank_account', 'class="pictofixedwidth"').$form->select_comptes(GETPOST('fk_account', 'int'), 'fk_account', 0, '', 2, '', 0, '', 1);
print ' ';
@@ -638,7 +638,7 @@ if ($id > 0) {
print '';
// Bank account
- if (!empty($conf->banque->enabled)) {
+ if (isModEnabled("banque")) {
print '';
print '';
print $langs->trans('DefaultBankAccount');
@@ -668,7 +668,7 @@ if ($id > 0) {
print '';
$nbcols = 3;
- if (!empty($conf->banque->enabled)) {
+ if (isModEnabled("banque")) {
$nbcols++;
}
@@ -703,7 +703,7 @@ if ($id > 0) {
print '
'.$langs->trans("RefPayment").' ';
print '
'.$langs->trans("Date").' ';
print '
'.$langs->trans("Type").' ';
- if (!empty($conf->banque->enabled)) {
+ if (isModEnabled("banque")) {
print '
'.$langs->trans('BankAccount').' ';
}
print '
'.$langs->trans("Amount").' ';
@@ -726,7 +726,7 @@ if ($id > 0) {
print '
'.dol_print_date($db->jdate($objp->dp), 'day')." \n";
$labeltype = $langs->trans("PaymentType".$objp->type_code) != ("PaymentType".$objp->type_code) ? $langs->trans("PaymentType".$objp->type_code) : $objp->paiement_type;
print "
".$labeltype.' '.$objp->num_payment." \n";
- if (!empty($conf->banque->enabled)) {
+ if (isModEnabled("banque")) {
$bankaccountstatic->id = $objp->baid;
$bankaccountstatic->ref = $objp->baref;
$bankaccountstatic->label = $objp->baref;
diff --git a/htdocs/compta/sociales/class/paymentsocialcontribution.class.php b/htdocs/compta/sociales/class/paymentsocialcontribution.class.php
index 318e7fcd96b..0bf402c6c21 100644
--- a/htdocs/compta/sociales/class/paymentsocialcontribution.class.php
+++ b/htdocs/compta/sociales/class/paymentsocialcontribution.class.php
@@ -552,7 +552,7 @@ class PaymentSocialContribution extends CommonObject
$error = 0;
- if (!empty($conf->banque->enabled)) {
+ if (isModEnabled("banque")) {
include_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
$acc = new Account($this->db);
diff --git a/htdocs/compta/sociales/list.php b/htdocs/compta/sociales/list.php
index 14b8bfa043f..80b231ac381 100644
--- a/htdocs/compta/sociales/list.php
+++ b/htdocs/compta/sociales/list.php
@@ -107,7 +107,7 @@ $arrayfields = array(
'cs.paye' =>array('label'=>"Status", 'checked'=>1, 'position'=>110),
);
-if (!empty($conf->banque->enabled)) {
+if (isModEnabled("banque")) {
$arrayfields['cs.fk_account'] = array('checked'=>-1, 'position'=>90, 'label'=>"DefaultBankAccount");
}
diff --git a/htdocs/compta/sociales/payments.php b/htdocs/compta/sociales/payments.php
index 843dbd58a50..7d59f16cd24 100644
--- a/htdocs/compta/sociales/payments.php
+++ b/htdocs/compta/sociales/payments.php
@@ -225,7 +225,7 @@ print '
';
print '
';
print '
';
print '
';
-if (!empty($conf->banque->enabled)) {
+if (isModEnabled("banque")) {
print '
';
print '
';
}
@@ -245,7 +245,7 @@ print_liste_field_titre("DatePayment", $_SERVER["PHP_SELF"], "pc.datep", "", $pa
print_liste_field_titre("Employee", $_SERVER["PHP_SELF"], "u.rowid", "", $param, "", $sortfield, $sortorder);
print_liste_field_titre("PaymentMode", $_SERVER["PHP_SELF"], "pct.code", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre("Numero", $_SERVER["PHP_SELF"], "pc.num_paiement", "", $param, '', $sortfield, $sortorder, '', 'ChequeOrTransferNumber');
-if (!empty($conf->banque->enabled)) {
+if (isModEnabled("banque")) {
print_liste_field_titre("BankTransactionLine", $_SERVER["PHP_SELF"], "pc.fk_bank", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre("Account", $_SERVER["PHP_SELF"], "ba.label", "", $param, "", $sortfield, $sortorder);
}
@@ -323,7 +323,7 @@ while ($i < min($num, $limit)) {
print '
'.$obj->num_payment.' ';
// Account
- if (!empty($conf->banque->enabled)) {
+ if (isModEnabled("banque")) {
// Bank transaction
print '
';
$accountlinestatic->id = $obj->fk_bank;
@@ -379,7 +379,7 @@ print ' ';
print '
';
print '
';
print '
';
-if (!empty($conf->banque->enabled)) {
+if (isModEnabled("banque")) {
print '
';
print '
';
}
diff --git a/htdocs/compta/stats/byratecountry.php b/htdocs/compta/stats/byratecountry.php
index afc56532fdf..e188cdae859 100644
--- a/htdocs/compta/stats/byratecountry.php
+++ b/htdocs/compta/stats/byratecountry.php
@@ -1,6 +1,7 @@
* Copyright (C) 2018-2021 Frédéric France
+ * Copyright (C) 2022 Alexandre Spangaro
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -54,7 +55,9 @@ if (empty($year)) {
}
$date_start = dol_mktime(0, 0, 0, GETPOST("date_startmonth"), GETPOST("date_startday"), GETPOST("date_startyear"), 'tzserver'); // We use timezone of server so report is same from everywhere
$date_end = dol_mktime(23, 59, 59, GETPOST("date_endmonth"), GETPOST("date_endday"), GETPOST("date_endyear"), 'tzserver'); // We use timezone of server so report is same from everywhere
+
// Quarter
+$q = '';
if (empty($date_start) || empty($date_end)) { // We define date_start and date_end
$q = GETPOST("q", "int");
if (empty($q)) {
@@ -155,10 +158,12 @@ foreach ($listofparams as $param) {
llxHeader('', $langs->trans("TurnoverReport"), '', '', 0, 0, '', '', $morequerystring);
-
+$exportlink="";
+$namelink="";
//print load_fiche_titre($langs->trans("VAT"),"");
//$fsearch.=' ';
+$fsearch = '';
$fsearch .= ' ';
$fsearch .= ' ';
//$fsearch.=' '.$langs->trans("SalesTurnoverMinimum").': ';
@@ -198,14 +203,17 @@ if ($nextquarter < 4) {
$nextquarter = 1;
$nextyear++;
}
-$description .= $fsearch;
+$description = $fsearch;
$builddate = dol_now();
+if (!empty($conf->global->MAIN_MODULE_ACCOUNTING)) {
+ $description .= ' '.$langs->trans("ThisIsAnEstimatedValue");
+}
if ($conf->global->TAX_MODE_SELL_PRODUCT == 'invoice') {
- $description .= $langs->trans("RulesVATDueProducts");
+ $description .= ' '.$langs->trans("RulesVATDueProducts");
}
if ($conf->global->TAX_MODE_SELL_PRODUCT == 'payment') {
- $description .= $langs->trans("RulesVATInProducts");
+ $description .= ' '.$langs->trans("RulesVATInProducts");
}
if ($conf->global->TAX_MODE_SELL_SERVICE == 'invoice') {
$description .= ' '.$langs->trans("RulesVATDueServices");
@@ -216,9 +224,6 @@ if ($conf->global->TAX_MODE_SELL_SERVICE == 'payment') {
if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
$description .= ' '.$langs->trans("DepositsAreNotIncluded");
}
-if (!empty($conf->global->MAIN_MODULE_ACCOUNTING)) {
- $description .= ' '.$langs->trans("ThisIsAnEstimatedValue");
-}
// Customers invoices
$elementcust = $langs->trans("CustomersInvoices");
@@ -229,9 +234,6 @@ $amountcust = $langs->trans("AmountHT");
$elementsup = $langs->trans("SuppliersInvoices");
$productsup = $productcust;
$amountsup = $amountcust;
-$namesup = $namecust;
-
-
// TODO Report from bookkeeping not yet available, so we switch on report on business events
if ($modecompta == "BOOKKEEPING") {
@@ -247,7 +249,7 @@ if ($modecompta == "CREANCES-DETTES") {
$calcmode = $langs->trans("CalcModeDebt");
//$calcmode.=' ('.$langs->trans("SeeReportInInputOutputMode",'',' ').')';
- $description = $langs->trans("RulesCADue");
+ $description .= ' '.$langs->trans("RulesCADue");
if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
$description .= $langs->trans("DepositsAreNotIncluded");
} else {
@@ -260,7 +262,7 @@ if ($modecompta == "CREANCES-DETTES") {
$calcmode = $langs->trans("CalcModeEngagement");
//$calcmode.=' ('.$langs->trans("SeeReportInDueDebtMode",'',' ').')';
- $description = $langs->trans("RulesCAIn");
+ $description .= $langs->trans("RulesCAIn");
$description .= $langs->trans("DepositsAreIncluded");
$builddate = dol_now();
diff --git a/htdocs/compta/stats/cabyprodserv.php b/htdocs/compta/stats/cabyprodserv.php
index e201d403bf4..6b4f8f3e9f2 100644
--- a/htdocs/compta/stats/cabyprodserv.php
+++ b/htdocs/compta/stats/cabyprodserv.php
@@ -3,6 +3,7 @@
* Copyright (C) 2013-2016 Laurent Destailleur
* Copyright (C) 2015 Raphaël Doursenaud
* Copyright (C) 2018 Frédéric France
+ * Copyright (C) 2022 Alexandre Spangaro
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -186,7 +187,9 @@ if (!empty($year)) {
if (!empty($month)) {
$headerparams['month'] = $month;
}
-$headerparams['q'] = $q;
+if (!empty($q)) {
+ $headerparams['q'] = $q;
+}
$tableparams = array();
if (!empty($selected_cat)) {
@@ -205,6 +208,7 @@ $allparams = array_merge($commonparams, $headerparams, $tableparams);
$headerparams = array_merge($commonparams, $headerparams);
$tableparams = array_merge($commonparams, $tableparams);
+$paramslink="";
foreach ($allparams as $key => $value) {
$paramslink .= '&'.$key.'='.$value;
}
@@ -227,6 +231,9 @@ if ($modecompta == "BOOKKEEPINGCOLLECTED") {
$modecompta = "RECETTES-DEPENSES";
}
+$exportlink="";
+$namelink="";
+
// Show report header
if ($modecompta == "CREANCES-DETTES") {
$name = $langs->trans("Turnover").', '.$langs->trans("ByProductsAndServices");
diff --git a/htdocs/compta/stats/cabyuser.php b/htdocs/compta/stats/cabyuser.php
index 2b8f40b3aba..b1d5851ca4a 100644
--- a/htdocs/compta/stats/cabyuser.php
+++ b/htdocs/compta/stats/cabyuser.php
@@ -4,6 +4,7 @@
* Copyright (C) 2005-2009 Regis Houssin
* Copyright (C) 2013 Antoine Iauch
* Copyright (C) 2018 Frédéric France
+ * Copyright (C) 2022 Alexandre Spangaro
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -135,23 +136,36 @@ $commonparams['sortorder'] = $sortorder;
$commonparams['sortfield'] = $sortfield;
$headerparams = array();
-$headerparams['date_startyear'] = $date_startyear;
-$headerparams['date_startmonth'] = $date_startmonth;
-$headerparams['date_startday'] = $date_startday;
-$headerparams['date_endyear'] = $date_endyear;
-$headerparams['date_endmonth'] = $date_endmonth;
-$headerparams['date_endday'] = $date_endday;
-$headerparams['q'] = $q;
+if (!empty($date_startyear)) {
+ $headerparams['date_startyear'] = $date_startyear;
+}
+if (!empty($date_startmonth)) {
+ $headerparams['date_startmonth'] = $date_startmonth;
+}
+if (!empty($date_startday)) {
+ $headerparams['date_startday'] = $date_startday;
+}
+if (!empty($date_endyear)) {
+ $headerparams['date_endyear'] = $date_endyear;
+}
+if (!empty($date_endmonth)) {
+ $headerparams['date_endmonth'] = $date_endmonth;
+}
+if (!empty($date_endday)) {
+ $headerparams['date_endday'] = $date_endday;
+}
+if (!empty($q)) {
+ $headerparams['q'] = $q;
+}
$tableparams = array();
-$tableparams['search_categ'] = $selected_cat;
-$tableparams['subcat'] = ($subcat === true) ? 'yes' : '';
// Adding common parameters
$allparams = array_merge($commonparams, $headerparams, $tableparams);
$headerparams = array_merge($commonparams, $headerparams);
$tableparams = array_merge($commonparams, $tableparams);
+$paramslink="";
foreach ($allparams as $key => $value) {
$paramslink .= '&'.$key.'='.$value;
}
@@ -172,6 +186,9 @@ if ($modecompta == "BOOKKEEPINGCOLLECTED") {
$modecompta = "RECETTES-DEPENSES";
}
+$exportlink="";
+$namelink="";
+
// Show report header
if ($modecompta == "CREANCES-DETTES") {
$name = $langs->trans("Turnover").', '.$langs->trans("ByUserAuthorOfInvoice");
@@ -230,6 +247,8 @@ foreach ($headerparams as $key => $value) {
}
$catotal = 0;
+$catotal_ht = 0;
+
if ($modecompta == 'CREANCES-DETTES') {
$sql = "SELECT u.rowid as rowid, u.lastname as name, u.firstname as firstname, sum(f.total_ht) as amount, sum(f.total_ttc) as amount_ttc";
$sql .= " FROM ".MAIN_DB_PREFIX."user as u";
@@ -245,8 +264,8 @@ if ($modecompta == 'CREANCES-DETTES') {
}
} elseif ($modecompta == "RECETTES-DEPENSES") {
/*
- * Liste des paiements (les anciens paiements ne sont pas vus par cette requete car, sur les
- * vieilles versions, ils n'etaient pas lies via paiement_facture. On les ajoute plus loin)
+ * List of payments (old payments are not seen by this query because on older versions,
+ * they were not linked via the table llx_paiement_facture. They are added later)
*/
$sql = "SELECT u.rowid as rowid, u.lastname as name, u.firstname as firstname, sum(pf.amount) as amount_ttc";
$sql .= " FROM ".MAIN_DB_PREFIX."user as u";
@@ -287,7 +306,7 @@ if ($result) {
dol_print_error($db);
}
-// Adding old-version payments, non-bound by "paiement_facture" then without User
+// Adding old-version payments, non-bound by table llx_paiement_facture then without User
if ($modecompta == 'RECETTES-DEPENSES') {
$sql = "SELECT -1 as rowidx, '' as name, '' as firstname, sum(DISTINCT p.amount) as amount_ttc";
$sql .= " FROM ".MAIN_DB_PREFIX."bank as b";
@@ -478,7 +497,7 @@ if (count($amount)) {
// Other stats
print '';
- if (!empty($conf->propal->enabled) && $key > 0) {
+ if (isModEnabled("propal") && $key > 0) {
print ' '.img_picto($langs->trans("ProposalStats"), "stats").' ';
}
if (!empty($conf->commande->enabled) && $key > 0) {
diff --git a/htdocs/compta/stats/casoc.php b/htdocs/compta/stats/casoc.php
index 320efa36ed6..466b0307df6 100644
--- a/htdocs/compta/stats/casoc.php
+++ b/htdocs/compta/stats/casoc.php
@@ -6,6 +6,7 @@
* Copyright (C) 2013 Antoine Iauch
* Copyright (C) 2015 Raphaël Doursenaud
* Copyright (C) 2018 Frédéric France
+ * Copyright (C) 2022 Alexandre Spangaro
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -158,13 +159,27 @@ $commonparams['sortorder'] = $sortorder;
$commonparams['sortfield'] = $sortfield;
$headerparams = array();
-$headerparams['date_startyear'] = $date_startyear;
-$headerparams['date_startmonth'] = $date_startmonth;
-$headerparams['date_startday'] = $date_startday;
-$headerparams['date_endyear'] = $date_endyear;
-$headerparams['date_endmonth'] = $date_endmonth;
-$headerparams['date_endday'] = $date_endday;
-$headerparams['q'] = $q;
+if (!empty($date_startyear)) {
+ $headerparams['date_startyear'] = $date_startyear;
+}
+if (!empty($date_startmonth)) {
+ $headerparams['date_startmonth'] = $date_startmonth;
+}
+if (!empty($date_startday)) {
+ $headerparams['date_startday'] = $date_startday;
+}
+if (!empty($date_endyear)) {
+ $headerparams['date_endyear'] = $date_endyear;
+}
+if (!empty($date_endmonth)) {
+ $headerparams['date_endmonth'] = $date_endmonth;
+}
+if (!empty($date_endday)) {
+ $headerparams['date_endday'] = $date_endday;
+}
+if (!empty($q)) {
+ $headerparams['q'] = $q;
+}
$tableparams = array();
$tableparams['search_categ'] = $selected_cat;
@@ -250,8 +265,10 @@ $name = array();
// Show Array
$catotal = 0;
+$catotal_ht = 0;
+
if ($modecompta == 'CREANCES-DETTES') {
- $sql = "SELECT DISTINCT s.rowid as socid, s.nom as name, s.zip, s.town, s.fk_pays,";
+ $sql = "SELECT DISTINCT s.rowid as socid, s.nom as name, s.name_alias, s.zip, s.town, s.fk_pays,";
$sql .= " sum(f.total_ht) as amount, sum(f.total_ttc) as amount_ttc";
$sql .= " FROM ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."societe as s";
if ($selected_cat === -2) { // Without any category
@@ -281,10 +298,10 @@ if ($modecompta == 'CREANCES-DETTES') {
}
} elseif ($modecompta == "RECETTES-DEPENSES") {
/*
- * Liste des paiements (les anciens paiements ne sont pas vus par cette requete car, sur les
- * vieilles versions, ils n'etaient pas lies via paiement_facture. On les ajoute plus loin)
+ * List of payments (old payments are not seen by this query because on older versions,
+ * they were not linked via the table llx_paiement_facture. They are added later)
*/
- $sql = "SELECT s.rowid as socid, s.nom as name, s.zip, s.town, s.fk_pays, sum(pf.amount) as amount_ttc";
+ $sql = "SELECT s.rowid as socid, s.nom as name, s.name_alias, s.zip, s.town, s.fk_pays, sum(pf.amount) as amount_ttc";
$sql .= " FROM ".MAIN_DB_PREFIX."facture as f";
$sql .= ", ".MAIN_DB_PREFIX."paiement_facture as pf";
$sql .= ", ".MAIN_DB_PREFIX."paiement as p";
@@ -329,7 +346,7 @@ $sql .= " AND f.entity IN (".getEntity('invoice').")";
if ($socid) {
$sql .= " AND f.fk_soc = ".((int) $socid);
}
-$sql .= " GROUP BY s.rowid, s.nom, s.zip, s.town, s.fk_pays";
+$sql .= " GROUP BY s.rowid, s.nom, s.name_alias, s.zip, s.town, s.fk_pays";
$sql .= " ORDER BY s.rowid";
//echo $sql;
@@ -344,7 +361,11 @@ if ($result) {
$obj = $db->fetch_object($result);
$amount_ht[$obj->socid] = $obj->amount;
$amount[$obj->socid] = $obj->amount_ttc;
- $name[$obj->socid] = $obj->name.' '.$obj->firstname;
+ $fullname = $obj->name;
+ if (!empty($obj->name_alias)) {
+ $fullname .= ' ('.$obj->name_alias.')';
+ }
+ $name[$obj->socid] = $fullname;
$address_zip[$obj->socid] = $obj->zip;
$address_town[$obj->socid] = $obj->town;
$address_pays[$obj->socid] = getCountry($obj->fk_pays);
@@ -356,7 +377,7 @@ if ($result) {
dol_print_error($db);
}
-// On ajoute les paiements anciennes version, non lies par paiement_facture
+// We add the old versions of payments, not linked by table llx_paiement_facture
if ($modecompta == "RECETTES-DEPENSES") {
$sql = "SELECT '0' as socid, 'Autres' as name, sum(p.amount) as amount_ttc";
$sql .= " FROM ".MAIN_DB_PREFIX."bank as b";
@@ -409,7 +430,7 @@ print '';
-print '';
+print ' ';
print img_picto('', 'category', 'class="paddingrightonly"');
print $formother->select_categories(Categorie::TYPE_CUSTOMER, $selected_cat, 'search_categ', 0, $langs->trans("Category"));
print ' ';
@@ -435,7 +456,7 @@ print ' ';
print ' ';
print ' ';
print '';
-print $form->select_country($search_country, 'search_country');
+print $form->select_country($search_country, 'search_country', '', 0, 'minwidth100imp maxwidth100');
//print ' ';
print ' ';
print ' ';
@@ -652,7 +673,7 @@ if (count($amount)) {
// Other stats
print '';
- if (!empty($conf->propal->enabled) && $key > 0) {
+ if (isModEnabled("propal") && $key > 0) {
print ' '.img_picto($langs->trans("ProposalStats"), "stats").' ';
}
if (!empty($conf->commande->enabled) && $key > 0) {
diff --git a/htdocs/compta/stats/index.php b/htdocs/compta/stats/index.php
index b99002fe609..4051055af60 100644
--- a/htdocs/compta/stats/index.php
+++ b/htdocs/compta/stats/index.php
@@ -69,6 +69,8 @@ if (empty($date_start) || empty($date_end)) { // We define date_start and date_e
$month_end = $month_start - 1;
if ($month_end < 1) {
$month_end = 12;
+ } else {
+ $year_end++;
}
} else {
$month_end = $month_start;
diff --git a/htdocs/compta/stats/supplier_turnover.php b/htdocs/compta/stats/supplier_turnover.php
index 7273e8ed529..cd70671af61 100644
--- a/htdocs/compta/stats/supplier_turnover.php
+++ b/htdocs/compta/stats/supplier_turnover.php
@@ -39,12 +39,12 @@ $nbofyear = 4;
// Date range
$year = GETPOST('year', 'int');
if (empty($year)) {
- $year_current = strftime("%Y", dol_now());
- $month_current = strftime("%m", dol_now());
+ $year_current = dol_print_date(dol_now(), "%Y");
+ $month_current = dol_print_date(dol_now(), "%m");
$year_start = $year_current - ($nbofyear - 1);
} else {
$year_current = $year;
- $month_current = strftime("%m", dol_now());
+ $month_current = dol_print_date(dol_now(), "%m");
$year_start = $year - ($nbofyear - 1);
}
$date_start = dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear, 'tzserver'); // We use timezone of server so report is same from everywhere
@@ -56,7 +56,7 @@ if (empty($date_start) || empty($date_end)) { // We define date_start and date_e
if ($q == 0) {
// We define date_start and date_end
$year_end = $year_start + ($nbofyear - 1);
- $month_start = GETPOST("month") ? GETPOST("month", 'int') : ($conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1);
+ $month_start = GETPOSTISSET("month") ? GETPOST("month", 'int') : ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1);
if (!GETPOST('month')) {
if (!GETPOST("year") && $month_start > $month_current) {
$year_start--;
@@ -65,6 +65,8 @@ if (empty($date_start) || empty($date_end)) { // We define date_start and date_e
$month_end = $month_start - 1;
if ($month_end < 1) {
$month_end = 12;
+ } else {
+ $year_end++;
}
} else {
$month_end = $month_start;
diff --git a/htdocs/compta/stats/supplier_turnover_by_thirdparty.php b/htdocs/compta/stats/supplier_turnover_by_thirdparty.php
index 0be2df11190..d13bcfbf349 100644
--- a/htdocs/compta/stats/supplier_turnover_by_thirdparty.php
+++ b/htdocs/compta/stats/supplier_turnover_by_thirdparty.php
@@ -590,10 +590,10 @@ if (count($amount)) {
if (!empty($conf->supplier_proposal->enabled) && $key > 0) {
print ' '.img_picto($langs->trans("ProposalStats"), "stats").' ';
}
- if (((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled)) && $key > 0) {
+ if (((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order")) && $key > 0) {
print ' '.img_picto($langs->trans("OrderStats"), "stats").' ';
}
- if (((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_invoice->enabled)) && $key > 0) {
+ if (((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_invoice")) && $key > 0) {
print ' '.img_picto($langs->trans("InvoiceStats"), "stats").' ';
}
print ' ';
diff --git a/htdocs/compta/tva/card.php b/htdocs/compta/tva/card.php
index e40b9b9b409..b4f16f0e564 100644
--- a/htdocs/compta/tva/card.php
+++ b/htdocs/compta/tva/card.php
@@ -494,7 +494,7 @@ if ($action == 'create') {
print "\n";
print "";
- if (!empty($conf->banque->enabled)) {
+ if (isModEnabled("banque")) {
// Bank account
print ''.$langs->trans("BankAccount").' ';
print img_picto('', 'bank_account', 'pictofixedwidth');
@@ -629,7 +629,7 @@ if ($id > 0) {
print ' ';
// Bank account
- if (!empty($conf->banque->enabled)) {
+ if (isModEnabled("banque")) {
print '';
print '';
print $langs->trans('BankAccount');
@@ -660,7 +660,7 @@ if ($id > 0) {
print '';
$nbcols = 3;
- if (!empty($conf->banque->enabled)) {
+ if (isModEnabled("banque")) {
$nbcols++;
}
@@ -695,7 +695,7 @@ if ($id > 0) {
print '
'.$langs->trans("RefPayment").' ';
print ''.$langs->trans("Date").' ';
print ''.$langs->trans("Type").' ';
- if (!empty($conf->banque->enabled)) {
+ if (isModEnabled("banque")) {
print ''.$langs->trans('BankAccount').' ';
}
print ''.$langs->trans("Amount").' ';
@@ -712,7 +712,7 @@ if ($id > 0) {
print ''.dol_print_date($db->jdate($objp->dp), 'day')." \n";
$labeltype = $langs->trans("PaymentType".$objp->type_code) != ("PaymentType".$objp->type_code) ? $langs->trans("PaymentType".$objp->type_code) : $objp->paiement_type;
print "".$labeltype.' '.$objp->num_payment." \n";
- if (!empty($conf->banque->enabled)) {
+ if (isModEnabled("banque")) {
$bankaccountstatic->id = $objp->baid;
$bankaccountstatic->ref = $objp->baref;
$bankaccountstatic->label = $objp->baref;
diff --git a/htdocs/compta/tva/class/paymentvat.class.php b/htdocs/compta/tva/class/paymentvat.class.php
index b7500fffaa0..ec951d8d72d 100644
--- a/htdocs/compta/tva/class/paymentvat.class.php
+++ b/htdocs/compta/tva/class/paymentvat.class.php
@@ -560,7 +560,7 @@ class PaymentVAT extends CommonObject
$error = 0;
- if (!empty($conf->banque->enabled)) {
+ if (isModEnabled("banque")) {
include_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
$acc = new Account($this->db);
diff --git a/htdocs/compta/tva/class/tva.class.php b/htdocs/compta/tva/class/tva.class.php
index f54ed42fb06..1ce6bed212b 100644
--- a/htdocs/compta/tva/class/tva.class.php
+++ b/htdocs/compta/tva/class/tva.class.php
@@ -572,11 +572,11 @@ class Tva extends CommonObject
$this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Amount"));
return -4;
}
- if (!empty($conf->banque->enabled) && (empty($this->accountid) || $this->accountid <= 0)) {
+ if (isModEnabled("banque") && (empty($this->accountid) || $this->accountid <= 0)) {
$this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Account"));
return -5;
}
- if (!empty($conf->banque->enabled) && (empty($this->type_payment) || $this->type_payment <= 0)) {
+ if (isModEnabled("banque") && (empty($this->type_payment) || $this->type_payment <= 0)) {
$this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("PaymentMode"));
return -5;
}
@@ -633,7 +633,7 @@ class Tva extends CommonObject
if ($this->id > 0) {
$ok = 1;
- if (!empty($conf->banque->enabled) && !empty($this->amount)) {
+ if (isModEnabled("banque") && !empty($this->amount)) {
// Insert into llx_bank
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
diff --git a/htdocs/compta/tva/list.php b/htdocs/compta/tva/list.php
index 5f76b2e9190..524f8b0105b 100644
--- a/htdocs/compta/tva/list.php
+++ b/htdocs/compta/tva/list.php
@@ -83,7 +83,7 @@ $arrayfields = array(
't.status' =>array('checked'=>1, 'position'=>90, 'label'=>"Status"),
);
-if (!empty($conf->banque->enabled)) {
+if (isModEnabled("banque")) {
$arrayfields['t.fk_account'] = array('checked'=>1, 'position'=>60, 'label'=>"DefaultBankAccount");
}
diff --git a/htdocs/compta/tva/payments.php b/htdocs/compta/tva/payments.php
index 0279acdeaa4..9e7c19c8754 100644
--- a/htdocs/compta/tva/payments.php
+++ b/htdocs/compta/tva/payments.php
@@ -129,7 +129,7 @@ if (!empty($conf->tax->enabled) && $user->rights->tax->charges->lire) {
print_liste_field_titre("DatePayment", $_SERVER["PHP_SELF"], "ptva.datep", "", $param, 'align="center"', $sortfield, $sortorder);
print_liste_field_titre("PaymentMode", $_SERVER["PHP_SELF"], "pct.code", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre("Numero", $_SERVER["PHP_SELF"], "ptva.num_paiement", "", $param, '', $sortfield, $sortorder, '', 'ChequeOrTransferNumber');
- if (!empty($conf->banque->enabled)) {
+ if (isModEnabled("banque")) {
print_liste_field_titre("BankTransactionLine", $_SERVER["PHP_SELF"], "ptva.fk_bank", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre("BankAccount", $_SERVER["PHP_SELF"], "bank.ref", "", $param, '', $sortfield, $sortorder);
}
@@ -221,7 +221,7 @@ if (!empty($conf->tax->enabled) && $user->rights->tax->charges->lire) {
// Chq number
print ''.dol_escape_htmltag($obj->num_payment).' ';
- if (!empty($conf->banque->enabled)) {
+ if (isModEnabled("banque")) {
// Bank transaction
print '';
$accountlinestatic->id = $obj->fk_bank;
@@ -258,7 +258,7 @@ if (!empty($conf->tax->enabled) && $user->rights->tax->charges->lire) {
print ' '; // A total here has no sense
print ' ';
print ' ';
- if (!empty($conf->banque->enabled)) {
+ if (isModEnabled("banque")) {
print ' ';
print ' ';
}
diff --git a/htdocs/conf/conf.php.example b/htdocs/conf/conf.php.example
index 487576ed058..b58ac33707e 100644
--- a/htdocs/conf/conf.php.example
+++ b/htdocs/conf/conf.php.example
@@ -185,7 +185,7 @@ $dolibarr_main_instance_unique_id='84b5bc91f83b56e458db71e0adac2b62';
// values using a ",". In this case, Dolibarr will check login/pass for each value in
// order defined into value. However, note that this can't work with all values.
// Examples:
-// $dolibarr_main_authentication='dolibarr'; // Use the password defined into application on user record.
+// $dolibarr_main_authentication='dolibarr'; // Use the password defined into application on user file (default).
// $dolibarr_main_authentication='http'; // Use the HTTP Basic authentication
// $dolibarr_main_authentication='ldap'; // Check the password into a LDAP server
// $dolibarr_main_authentication='ldap,dolibarr'; // You can set several mode using a comma as a separator.
diff --git a/htdocs/contact/canvas/actions_contactcard_common.class.php b/htdocs/contact/canvas/actions_contactcard_common.class.php
index a72ea3d7d21..2c7ac145b78 100644
--- a/htdocs/contact/canvas/actions_contactcard_common.class.php
+++ b/htdocs/contact/canvas/actions_contactcard_common.class.php
@@ -196,7 +196,7 @@ abstract class ActionsContactCardCommon
$this->tpl['contact_element'][$i]['linked_element_value'] = $this->object->ref_commande ? $this->object->ref_commande : $langs->trans("NoContactForAnyOrder");
$i++;
}
- if (!empty($conf->propal->enabled)) {
+ if (isModEnabled("propal")) {
$this->tpl['contact_element'][$i]['linked_element_label'] = $langs->trans("ContactForProposals");
$this->tpl['contact_element'][$i]['linked_element_value'] = $this->object->ref_propal ? $this->object->ref_propal : $langs->trans("NoContactForAnyProposal");
$i++;
diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php
index 0ef31fe36a4..d486432f142 100644
--- a/htdocs/contact/card.php
+++ b/htdocs/contact/card.php
@@ -375,7 +375,7 @@ if (empty($reshook)) {
$newfile = $dir.'/'.dol_sanitizeFileName($_FILES['photo']['name']);
$result = dol_move_uploaded_file($_FILES['photo']['tmp_name'], $newfile, 1);
- if (!$result > 0) {
+ if (!($result > 0)) {
$errors[] = "ErrorFailedToSaveFile";
} else {
$object->photo = dol_sanitizeFileName($_FILES['photo']['name']);
@@ -883,8 +883,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
//Default language
if (!empty($conf->global->MAIN_MULTILANGS)) {
print ''.$form->editfieldkey('DefaultLang', 'default_lang', '', $object, 0).' '."\n";
- print $formadmin->select_language(GETPOST('default_lang', 'alpha') ?GETPOST('default_lang', 'alpha') : ($object->default_lang ? $object->default_lang : ''), 'default_lang', 0, 0, 1, 0, 0, 'maxwidth200onsmartphone', 0, 0, 0, null, 1);
-
+ print img_picto('', 'language', 'class="pictofixedwidth"').$formadmin->select_language(GETPOST('default_lang', 'alpha') ? GETPOST('default_lang', 'alpha') : ($object->default_lang ? $object->default_lang : ''), 'default_lang', 0, 0, 1, 0, 0, 'maxwidth200onsmartphone');
print ' ';
print ' ';
}
@@ -1171,8 +1170,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
//Default language
if (!empty($conf->global->MAIN_MULTILANGS)) {
print ''.$form->editfieldkey('DefaultLang', 'default_lang', '', $object, 0).' '."\n";
- print $formadmin->select_language($object->default_lang, 'default_lang', 0, 0, 1, 0, 0, '', 0, 0, 0, null, 1);
-
+ print img_picto('', 'language', 'class="pictofixedwidth"').$formadmin->select_language(GETPOST('default_lang', 'alpha') ? GETPOST('default_lang', 'alpha') : ($object->default_lang ? $object->default_lang : ''), 'default_lang', 0, 0, 1, 0, 0, 'maxwidth200onsmartphone');
print ' ';
print ' ';
}
@@ -1230,7 +1228,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
print '';
}
- if (!empty($conf->propal->enabled)) {
+ if (isModEnabled("propal")) {
print ''.$langs->trans("ContactForProposals").' ';
print $object->ref_propal ? $object->ref_propal : (''.$langs->trans("NoContactForAnyProposal").' ');
print ' ';
@@ -1328,7 +1326,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
//array('label' => $form->textwithpicto($langs->trans("Type"),$langs->trans("InternalExternalDesc")), 'type' => 'select', 'name' => 'intern', 'default' => 1, 'values' => array(0=>$langs->trans('Internal'),1=>$langs->trans('External')))
);
$text = $langs->trans("ConfirmCreateContact").' ';
- if (!empty($conf->societe->enabled)) {
+ if (isModEnabled("societe")) {
if ($object->socid > 0) {
$text .= $langs->trans("UserWillBeExternalUser");
} else {
@@ -1403,7 +1401,8 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
//$s=picto_from_langcode($object->default_lang);
//print ($s?$s.' ':'');
$langs->load("languages");
- $labellang = ($object->default_lang ? $langs->trans('Language_'.$object->default_lang.'_'.strtoupper($object->default_lang)) : '');
+ $labellang = ($object->default_lang ? $langs->trans('Language_'.$object->default_lang) : '');
+ print picto_from_langcode($object->default_lang, 'class="paddingrightonly saturatemedium opacitylow"');
print $labellang;
print '';
}
@@ -1490,22 +1489,22 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
$object->load_ref_elements();
- if (!empty($conf->propal->enabled)) {
+ if (isModEnabled("propal")) {
print ''.$langs->trans("ContactForProposals").' ';
print $object->ref_propal ? $object->ref_propal : $langs->trans("NoContactForAnyProposal");
print ' ';
}
- if (!empty($conf->commande->enabled) || !empty($conf->expedition->enabled)) {
+ if (!empty($conf->commande->enabled) || isModEnabled("expedition")) {
print '';
- if (!empty($conf->expedition->enabled)) {
+ if (isModEnabled("expedition")) {
print $langs->trans("ContactForOrdersOrShipments");
} else {
print $langs->trans("ContactForOrders");
}
print ' ';
$none = $langs->trans("NoContactForAnyOrder");
- if (!empty($conf->expedition->enabled)) {
+ if (isModEnabled("expedition")) {
$none = $langs->trans("NoContactForAnyOrderOrShipments");
}
print $object->ref_commande ? $object->ref_commande : $none;
diff --git a/htdocs/contact/consumption.php b/htdocs/contact/consumption.php
index 0ba88228666..c3cd54d890e 100644
--- a/htdocs/contact/consumption.php
+++ b/htdocs/contact/consumption.php
@@ -33,6 +33,7 @@ require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php';
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
+$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : str_replace('_', '', basename(dirname(__FILE__)).basename(__FILE__, '.php')); // To manage different context of search
$id = GETPOST('id', 'int');
@@ -46,7 +47,7 @@ if (empty($object->thirdparty)) {
$socid = $object->thirdparty->id;
// Sort & Order fields
-$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
+$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST('sortfield', 'aZ09comma');
$sortorder = GETPOST('sortorder', 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
@@ -153,7 +154,7 @@ print ' ';
if ($object->thirdparty->client) {
$thirdTypeArray['customer'] = $langs->trans("customer");
- if (!empty($conf->propal->enabled) && $user->rights->propal->lire) {
+ if (isModEnabled("propal") && $user->rights->propal->lire) {
$elementTypeArray['propal'] = $langs->transnoentitiesnoconv('Proposals');
}
if (!empty($conf->commande->enabled) && $user->rights->commande->lire) {
@@ -173,15 +174,15 @@ if (!empty($conf->ficheinter->enabled) && $user->rights->ficheinter->lire) {
if ($object->thirdparty->fournisseur) {
$thirdTypeArray['supplier'] = $langs->trans("supplier");
- if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->rights->fournisseur->facture->lire) || (!empty($conf->supplier_invoice->enabled) && $user->rights->supplier_invoice->lire)) {
+ if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->rights->fournisseur->facture->lire) || (isModEnabled("supplier_invoice") && $user->rights->supplier_invoice->lire)) {
$elementTypeArray['supplier_invoice'] = $langs->transnoentitiesnoconv('SuppliersInvoices');
}
- if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->rights->fournisseur->commande->lire) || (!empty($conf->supplier_order->enabled) && $user->rights->supplier_order->lire)) {
+ if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->rights->fournisseur->commande->lire) || (isModEnabled("supplier_order") && $user->rights->supplier_order->lire)) {
$elementTypeArray['supplier_order'] = $langs->transnoentitiesnoconv('SuppliersOrders');
}
// There no contact type for supplier proposals
- // if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) && $user->rights->supplier_proposal->lire) $elementTypeArray['supplier_proposal']=$langs->transnoentitiesnoconv('SupplierProposals');
+ // if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) && $user->rights->supplier_proposal->lire) $elementTypeArray['supplier_proposal']=$langs->transnoentitiesnoconv('SupplierProposals');
}
print '
';
@@ -230,7 +231,7 @@ if ($type_element == 'fichinter') { // Customer : show products from invoices
$tables_from .= ' INNER JOIN '.MAIN_DB_PREFIX.'element_contact ec ON ec.element_id=c.rowid AND ec.fk_socpeople = '.((int) $object->id);
$tables_from .= ' INNER JOIN '.MAIN_DB_PREFIX."c_type_contact tc ON (ec.fk_c_type_contact=tc.rowid and tc.element='propal' and tc.source='external' and tc.active=1)";
$where = ' WHERE c.entity IN ('.getEntity('propal').')';
- $datePrint = 'c.datep';
+ $dateprint = 'c.datep';
$doc_number = 'c.ref';
$thirdTypeSelect = 'customer';
} elseif ($type_element == 'order') {
@@ -443,6 +444,8 @@ if ($sql_select) {
$i = 0;
+ $total_qty = 0;
+ $total_ht = 0;
while (($objp = $db->fetch_object($resql)) && $i < min($num, $limit)) {
$documentstatic->id = $objp->doc_id;
$documentstatic->ref = $objp->doc_number;
diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php
index a0091061adb..f5810db2b13 100644
--- a/htdocs/contact/list.php
+++ b/htdocs/contact/list.php
@@ -753,7 +753,7 @@ if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire) {
$moreforfilter .= '';
}
- if (!empty($conf->fournisseur->enabled) && (empty($type) || $type == 'f')) {
+ if (isModEnabled("fournisseur") && (empty($type) || $type == 'f')) {
$moreforfilter .= '';
$tmptitle = $langs->trans('SuppliersCategoriesShort');
$moreforfilter .= img_picto($tmptitle, 'category', 'class="pictofixedwidth"');
diff --git a/htdocs/contact/perso.php b/htdocs/contact/perso.php
index 6030fc1e6bd..aa7ba34d9f0 100644
--- a/htdocs/contact/perso.php
+++ b/htdocs/contact/perso.php
@@ -60,7 +60,7 @@ if ($action == 'update' && !GETPOST("cancel") && $user->rights->societe->contact
$result = $object->update_perso($id, $user);
if ($result > 0) {
- $object->oldcopy = clone $object;
+ $object->oldcopy = dol_clone($object);
// Logo/Photo save
$dir = $conf->societe->dir_output.'/contact/'.get_exdir($object->id, 0, 0, 1, $object, 'contact').'/photos';
diff --git a/htdocs/contact/project.php b/htdocs/contact/project.php
index b05709f019a..e88c056af37 100644
--- a/htdocs/contact/project.php
+++ b/htdocs/contact/project.php
@@ -76,7 +76,11 @@ if ($id) {
$linkback = '
'.$langs->trans("BackToList").' ';
- $morehtmlref = '
';
+ $morehtmlref = '
';
+ $morehtmlref .= img_picto($langs->trans("Download").' '.$langs->trans("VCard"), 'vcard.png', 'class="valignmiddle marginleftonly paddingrightonly"');
+ $morehtmlref .= ' ';
+
+ $morehtmlref .= '
';
if (empty($conf->global->SOCIETE_DISABLE_CONTACTS) && !empty($socid)) {
$object->thirdparty->fetch($socid);
// Thirdparty
diff --git a/htdocs/contact/vcard.php b/htdocs/contact/vcard.php
index 1fba506e910..256039fa96f 100644
--- a/htdocs/contact/vcard.php
+++ b/htdocs/contact/vcard.php
@@ -44,7 +44,6 @@ if ($result <= 0) {
exit;
}
-$physicalperson = 1;
$company = new Societe($db);
if ($contact->socid) {
@@ -107,7 +106,7 @@ if ($company->id) {
}
// Si contact lie a un tiers non de type "particulier"
- if ($contact->typent_code != 'TE_PRIVATE') {
+ if ($company->typent_code != 'TE_PRIVATE') {
$v->setOrg($company->name);
}
}
diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php
index eb3a29bb3e9..439f312bef6 100644
--- a/htdocs/contrat/card.php
+++ b/htdocs/contrat/card.php
@@ -41,7 +41,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
-if (!empty($conf->propal->enabled)) {
+if (isModEnabled("propal")) {
require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
}
if (!empty($conf->project->enabled)) {
@@ -396,11 +396,28 @@ if (empty($reshook)) {
// Set if we used free entry or predefined product
$predef = '';
$product_desc = (GETPOSTISSET('dp_desc') ? GETPOST('dp_desc', 'restricthtml') : '');
- $price_ht = price2num(GETPOST('price_ht'), 'MU', 2);
- $price_ht_devise = price2num(GETPOST('multicurrency_price_ht'), 'CU', 2);
+
+ $price_ht = '';
+ $price_ht_devise = '';
+ $price_ttc = '';
+ $price_ttc_devise = '';
+
+ if (GETPOST('price_ht') !== '') {
+ $price_ht = price2num(GETPOST('price_ht'), 'MU', 2);
+ }
+ if (GETPOST('multicurrency_price_ht') !== '') {
+ $price_ht_devise = price2num(GETPOST('multicurrency_price_ht'), 'CU', 2);
+ }
+ if (GETPOST('price_ttc') !== '') {
+ $price_ttc = price2num(GETPOST('price_ttc'), 'MU', 2);
+ }
+ if (GETPOST('multicurrency_price_ttc') !== '') {
+ $price_ttc_devise = price2num(GETPOST('multicurrency_price_ttc'), 'CU', 2);
+ }
+
if (GETPOST('prod_entry_mode', 'alpha') == 'free') {
$idprod = 0;
- $tva_tx = (GETPOST('tva_tx', 'alpha') ? GETPOST('tva_tx', 'alpha') : 0);
+ $tva_tx = (GETPOST('tva_tx', 'alpha') ? price2num(preg_replace('/\s*\(.*\)/', '', GETPOST('tva_tx', 'alpha'))) : 0);
} else {
$idprod = GETPOST('idprod', 'int');
$tva_tx = '';
@@ -408,6 +425,9 @@ if (empty($reshook)) {
$qty = price2num(GETPOST('qty'.$predef, 'alpha'), 'MS');
$remise_percent = (GETPOSTISSET('remise_percent'.$predef) ? price2num(GETPOST('remise_percent'.$predef), 2) : 0);
+ if (empty($remise_percent)) {
+ $remise_percent = 0;
+ }
if ($qty == '') {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Qty")), null, 'errors');
@@ -460,6 +480,7 @@ if (empty($reshook)) {
$pu_ht = $prod->price;
$pu_ttc = $prod->price_ttc;
$price_min = $prod->price_min;
+ $price_min_ttc = $prod->price_min_ttc;
$price_base_type = $prod->price_base_type;
// On defini prix unitaire
@@ -467,8 +488,10 @@ if (empty($reshook)) {
$pu_ht = $prod->multiprices[$object->thirdparty->price_level];
$pu_ttc = $prod->multiprices_ttc[$object->thirdparty->price_level];
$price_min = $prod->multiprices_min[$object->thirdparty->price_level];
+ $price_min_ttc = $prod->multiprices_min_ttc[$object->thirdparty->price_level];
$price_base_type = $prod->multiprices_base_type[$object->thirdparty->price_level];
} elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
+ // If price per customer
require_once DOL_DOCUMENT_ROOT.'/product/class/productcustomerprice.class.php';
$prodcustprice = new Productcustomerprice($db);
@@ -478,10 +501,12 @@ if (empty($reshook)) {
$result = $prodcustprice->fetch_all('', '', 0, 0, $filter);
if ($result) {
if (count($prodcustprice->lines) > 0) {
- $pu_ht = price($prodcustprice->lines [0]->price);
- $pu_ttc = price($prodcustprice->lines [0]->price_ttc);
- $price_base_type = $prodcustprice->lines [0]->price_base_type;
- $tva_tx = $prodcustprice->lines [0]->tva_tx;
+ $pu_ht = price($prodcustprice->lines[0]->price);
+ $pu_ttc = price($prodcustprice->lines[0]->price_ttc);
+ $price_min = price($prodcustprice->lines[0]->price_min);
+ $price_min_ttc = price($prodcustprice->lines[0]->price_min_ttc);
+ $price_base_type = $prodcustprice->lines[0]->price_base_type;
+ $tva_tx = $prodcustprice->lines[0]->tva_tx;
if ($prodcustprice->lines[0]->default_vat_code && !preg_match('/\(.*\)/', $tva_tx)) {
$tva_tx .= ' ('.$prodcustprice->lines[0]->default_vat_code.')';
}
@@ -496,9 +521,15 @@ if (empty($reshook)) {
$tmpvat = price2num(preg_replace('/\s*\(.*\)/', '', $tva_tx));
$tmpprodvat = price2num(preg_replace('/\s*\(.*\)/', '', $prod->tva_tx));
- // On reevalue prix selon taux tva car taux tva transaction peut etre different
- // de ceux du produit par defaut (par exemple si pays different entre vendeur et acheteur).
- if ($tmpvat != $tmpprodvat) {
+ // Set unit price to use
+ if (!empty($price_ht) || $price_ht === '0') {
+ $pu_ht = price2num($price_ht, 'MU');
+ $pu_ttc = price2num($pu_ht * (1 + ($tmpvat / 100)), 'MU');
+ } elseif (!empty($price_ttc) || $price_ttc === '0') {
+ $pu_ttc = price2num($price_ttc, 'MU');
+ $pu_ht = price2num($pu_ttc / (1 + ($tmpvat / 100)), 'MU');
+ } elseif ($tmpvat != $tmpprodvat) {
+ // Is this still used ?
if ($price_base_type != 'HT') {
$pu_ht = price2num($pu_ttc / (1 + ($tmpvat / 100)), 'MU');
} else {
@@ -521,12 +552,22 @@ if (empty($reshook)) {
$fk_unit = $prod->fk_unit;
} else {
- $pu_ht = GETPOST('price_ht');
- $price_base_type = 'HT';
- $tva_tx = GETPOST('tva_tx') ?str_replace('*', '', GETPOST('tva_tx')) : 0; // tva_tx field may be disabled, so we use vat rate 0
- $tva_npr = preg_match('/\*/', GETPOST('tva_tx')) ? 1 : 0;
+ $pu_ht = price2num($price_ht, 'MU');
+ $pu_ttc = price2num($price_ttc, 'MU');
+ $tva_npr = (preg_match('/\*/', $tva_tx) ? 1 : 0);
+ if (empty($tva_tx)) {
+ $tva_npr = 0;
+ }
+ $tva_tx = str_replace('*', '', $tva_tx);
$desc = $product_desc;
$fk_unit = GETPOST('units', 'alpha');
+ $pu_ht_devise = price2num($price_ht_devise, 'MU');
+ $pu_ttc_devise = price2num($price_ttc_devise, 'MU');
+
+ $price_base_type = 'HT';
+ if ($pu_ttc && !$pu_ht) {
+ $price_base_type = 'TTC';
+ }
}
$localtax1_tx = get_localtax($tva_tx, 1, $object->thirdparty, $mysoc, $tva_npr);
@@ -577,10 +618,10 @@ if (empty($reshook)) {
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE) && !empty($conf->global->CONTRACT_ADDON_PDF)) { // No generation if default type not defined
$outputlangs = $langs;
$newlang = '';
- if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
+ if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
$newlang = GETPOST('lang_id', 'aZ09');
}
- if ($conf->global->MAIN_MULTILANGS && empty($newlang)) {
+ if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) {
$newlang = $object->thirdparty->default_lang;
}
if (!empty($newlang)) {
@@ -754,10 +795,10 @@ if (empty($reshook)) {
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
$outputlangs = $langs;
$newlang = '';
- if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
+ if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
$newlang = GETPOST('lang_id', 'aZ09');
}
- if ($conf->global->MAIN_MULTILANGS && empty($newlang)) {
+ if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) {
$newlang = $object->thirdparty->default_lang;
}
if (!empty($newlang)) {
@@ -1427,6 +1468,11 @@ if ($action == 'create') {
* Lines of contracts
*/
+ // Add products/services form
+ //$forceall = 1;
+ global $inputalsopricewithtax;
+ $inputalsopricewithtax = 1;
+
$productstatic = new Product($db);
$usemargins = 0;
@@ -2020,12 +2066,15 @@ if ($action == 'create') {
print dol_get_fiche_end();
+ // Select mail models is same action as presend
+ if (GETPOST('modelselected')) {
+ $action = 'presend';
+ }
/*
* Buttons
*/
-
- if ($user->socid == 0) {
+ if ($user->socid == 0 && $action != 'presend' && $action != 'editline') {
print '
';
$parameters = array();
@@ -2137,11 +2186,6 @@ if ($action == 'create') {
print "
";
}
- // Select mail models is same action as presend
- if (GETPOST('modelselected')) {
- $action = 'presend';
- }
-
if ($action != 'presend') {
print '
';
diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php
index 1e8da8a9a81..088d8f9b6d5 100644
--- a/htdocs/contrat/class/contrat.class.php
+++ b/htdocs/contrat/class/contrat.class.php
@@ -2600,6 +2600,177 @@ class Contrat extends CommonObject
return -1;
}
}
+
+
+ /**
+ * Action executed by scheduler
+ * CAN BE A CRON TASK
+ * Loop on each contract lines and update the end of date. Do not execute the update if there is one pending invoice linked to contract.
+ *
+ * @param int $thirdparty_id Thirdparty id
+ * @param int $delayindaysshort To renew the resources x day before (positive value) or after (negative value) the end of date (default is 0)
+ * @return int 0 if OK, <>0 if KO (this function is used also by cron so only 0 is OK)
+ */
+ public function doAutoRenewContracts($thirdparty_id = 0, $delayindaysshort = 0)
+ {
+ global $langs, $user;
+
+ $langs->load("agenda");
+
+ $now = dol_now();
+
+ $enddatetoscan = dol_time_plus_duree($now, -1 * abs($delayindaysshort), 'd');
+
+ $error = 0;
+ $this->output = '';
+ $this->error='';
+
+ $contractlineprocessed = array();
+ $contractignored = array();
+ $contracterror = array();
+
+ dol_syslog(__METHOD__, LOG_DEBUG);
+
+ $sql = 'SELECT c.rowid, c.ref_customer, cd.rowid as lid, cd.date_fin_validite, p.duration';
+ $sql.= ' FROM '.MAIN_DB_PREFIX.'contrat as c, '.MAIN_DB_PREFIX.'contratdet as cd';
+ $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON p.rowid = cd.fk_product';
+ $sql.= ' WHERE cd.fk_contrat = c.rowid';
+ $sql.= " AND date_format(cd.date_fin_validite, '%Y-%m-%d') <= date_format('".$this->db->idate($enddatetoscan)."', '%Y-%m-%d')";
+ $sql.= " AND cd.statut = 4";
+ if ($thirdparty_id > 0) $sql.=" AND c.fk_soc = ".((int) $thirdparty_id);
+ //print $sql;
+
+ $resql = $this->db->query($sql);
+ if ($resql) {
+ $num = $this->db->num_rows($resql);
+
+ include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
+
+ $i=0;
+ while ($i < $num) {
+ $obj = $this->db->fetch_object($resql);
+ if ($obj) {
+ if (! empty($contractlineprocessed[$obj->lid]) || ! empty($contractignored[$obj->rowid]) || ! empty($contracterror[$obj->rowid])) {
+ continue;
+ }
+
+ // Load contract
+ $object = new Contrat($this->db);
+ $object->fetch($obj->rowid); // fetch also lines
+ $object->fetch_thirdparty();
+
+ if ($object->id <= 0) {
+ $error++;
+ $this->errors[] = 'Failed to load contract with id='.$obj->rowid;
+ continue;
+ }
+
+ dol_syslog("* Process contract line in doRenewalContracts for contract id=".$object->id." ref=".$object->ref." ref_customer=".$object->ref_customer." contract line id=".$obj->lid);
+
+ // Update expiration date of line
+ $expirationdate = $this->db->jdate($obj->date_fin_validite);
+ $duration_value = preg_replace('/[^0-9]/', '', $obj->duration);
+ $duration_unit = preg_replace('/\d/', '', $obj->duration);
+ //var_dump($expirationdate.' '.$enddatetoscan);
+
+ // Test if there is pending invoice
+ $object->fetchObjectLinked(null, '', null, '', 'OR', 1, 'sourcetype', 1);
+
+ if (is_array($object->linkedObjects['facture']) && count($object->linkedObjects['facture']) > 0) {
+ usort($object->linkedObjects['facture'], "cmp");
+
+ //dol_sort_array($contract->linkedObjects['facture'], 'date');
+ $someinvoicenotpaid=0;
+ foreach ($object->linkedObjects['facture'] as $idinvoice => $invoice) {
+ if ($invoice->statut == Facture::STATUS_DRAFT) continue; // Draft invoice are not invoice not paid
+
+ if (empty($invoice->paye)) {
+ $someinvoicenotpaid++;
+ }
+ }
+ if ($someinvoicenotpaid) {
+ $this->output .= 'Contract '.$object->ref.' is qualified for renewal but there is '.$someinvoicenotpaid.' invoice(s) unpayed so we cancel renewal'."\n";
+ $contractignored[$object->id]=$object->ref;
+ continue;
+ }
+ }
+
+ if ($expirationdate && $expirationdate < $enddatetoscan) {
+ dol_syslog("Define the newdate of end of services from expirationdate=".$expirationdate);
+ $newdate = $expirationdate;
+ $protecti=0; //$protecti is to avoid infinite loop
+ while ($newdate < $enddatetoscan && $protecti < 1000) {
+ $newdate = dol_time_plus_duree($newdate, $duration_value, $duration_unit);
+ $protecti++;
+ }
+
+ if ($protecti < 1000) { // If not, there is a pb
+ // We will update the end of date of contrat, so first we refresh contract data
+ dol_syslog("We will update the end of date of contract with newdate = ".dol_print_date($newdate, 'dayhourrfc'));
+
+ $this->db->begin();
+
+ $errorforlocaltransaction = 0;
+
+ $label = 'Renewal of contrat '.$object->ref.' line '.$obj->lid;
+ $comment = 'Renew date of contract '.$object->ref.' line '.$obj->lid.' by doAutoRenewContracts';
+
+ $sqlupdate = 'UPDATE '.MAIN_DB_PREFIX."contratdet SET date_fin_validite = '".$this->db->idate($newdate)."'";
+ $sqlupdate.= ' WHERE rowid = '.((int) $obj->lid);
+ $resqlupdate = $this->db->query($sqlupdate);
+ if ($resqlupdate) {
+ $contractlineprocessed[$obj->lid]=$object->ref;
+
+ $actioncode = 'RENEW_CONTRACT';
+ $now = dol_now();
+
+ // Create an event
+ $actioncomm = new ActionComm($this->db);
+ $actioncomm->type_code = 'AC_OTH_AUTO'; // Type of event ('AC_OTH', 'AC_OTH_AUTO', 'AC_XXX'...)
+ $actioncomm->code = 'AC_'.$actioncode;
+ $actioncomm->label = $label;
+ $actioncomm->datep = $now;
+ $actioncomm->datef = $now;
+ $actioncomm->percentage = -1; // Not applicable
+ $actioncomm->socid = $object->thirdparty->id;
+ $actioncomm->authorid = $user->id; // User saving action
+ $actioncomm->userownerid = $user->id; // Owner of action
+ $actioncomm->fk_element = $object->id;
+ $actioncomm->elementtype = 'contract';
+ $actioncomm->note_private = $comment;
+
+ $ret = $actioncomm->create($user); // User creating action
+ } else {
+ $contracterror[$object->id]=$object->ref;
+
+ $error++;
+ $errorforlocaltransaction++;
+ $this->error = $this->db->lasterror();
+ }
+
+ if (! $errorforlocaltransaction) {
+ $this->db->commit();
+ } else {
+ $this->db->rollback();
+ }
+ } else {
+ $error++;
+ $this->error = "Bad value for newdate in doAutoRenewContracts - expirationdate=".$expirationdate." enddatetoscan=".$enddatetoscan." duration_value=".$duration_value." duration_unit=".$duration_value;
+ dol_syslog($this->error, LOG_ERR);
+ }
+ }
+ }
+ $i++;
+ }
+ } else {
+ $error++;
+ $this->error = $this->db->lasterror();
+ }
+
+ $this->output .= count($contractlineprocessed).' contract line(s) with end date before '.dol_print_date($enddatetoscan, 'day').' were renewed'.(count($contractlineprocessed)>0 ? ' : '.join(',', $contractlineprocessed) : '');
+
+ return ($error ? 1: 0);
+ }
}
@@ -3132,12 +3303,13 @@ class ContratLigne extends CommonObjectLine
}
}
+ // $this->oldcopy should have been set by the caller of update (here properties were already modified)
+ if (empty($this->oldcopy)) {
+ $this->oldcopy = dol_clone($this);
+ }
$this->db->begin();
- $this->oldcopy = new ContratLigne($this->db);
- $this->oldcopy->fetch($this->id);
-
// Update request
$sql = "UPDATE ".MAIN_DB_PREFIX."contratdet SET";
$sql .= " fk_contrat=".((int) $this->fk_contrat).",";
diff --git a/htdocs/contrat/list.php b/htdocs/contrat/list.php
index 4f5d8d00b49..5ceec0a4cb9 100644
--- a/htdocs/contrat/list.php
+++ b/htdocs/contrat/list.php
@@ -872,8 +872,8 @@ while ($i < min($num, $limit)) {
}
// Country
if (!empty($arrayfields['country.code_iso']['checked'])) {
- print '
';
- print $socstatic->country;
+ print ' ';
+ print dol_escape_htmltag($socstatic->country);
print ' ';
if (!$i) {
$totalarray['nbfield']++;
diff --git a/htdocs/core/actions_addupdatedelete.inc.php b/htdocs/core/actions_addupdatedelete.inc.php
index 39dba81976f..c7dffe08691 100644
--- a/htdocs/core/actions_addupdatedelete.inc.php
+++ b/htdocs/core/actions_addupdatedelete.inc.php
@@ -366,10 +366,10 @@ if ($action == 'confirm_deleteline' && $confirm == 'yes' && !empty($permissionto
// Define output language
$outputlangs = $langs;
$newlang = '';
- if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
+ if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
$newlang = GETPOST('lang_id', 'aZ09');
}
- if ($conf->global->MAIN_MULTILANGS && empty($newlang) && is_object($object->thirdparty)) {
+ if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang) && is_object($object->thirdparty)) {
$newlang = $object->thirdparty->default_lang;
}
if (!empty($newlang)) {
@@ -442,10 +442,10 @@ if ($action == 'confirm_close' && $confirm == 'yes' && $permissiontoadd) {
if (method_exists($object, 'generateDocument')) {
$outputlangs = $langs;
$newlang = '';
- if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
+ if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
$newlang = GETPOST('lang_id', 'aZ09');
}
- if ($conf->global->MAIN_MULTILANGS && empty($newlang)) {
+ if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) {
$newlang = $object->thirdparty->default_lang;
}
if (!empty($newlang)) {
@@ -486,10 +486,10 @@ if ($action == 'confirm_reopen' && $confirm == 'yes' && $permissiontoadd) {
if (method_exists($object, 'generateDocument')) {
$outputlangs = $langs;
$newlang = '';
- if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
+ if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
$newlang = GETPOST('lang_id', 'aZ09');
}
- if ($conf->global->MAIN_MULTILANGS && empty($newlang)) {
+ if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) {
$newlang = $object->thirdparty->default_lang;
}
if (!empty($newlang)) {
diff --git a/htdocs/core/actions_lineupdown.inc.php b/htdocs/core/actions_lineupdown.inc.php
index 5aee952292b..d41f1f1932c 100644
--- a/htdocs/core/actions_lineupdown.inc.php
+++ b/htdocs/core/actions_lineupdown.inc.php
@@ -34,10 +34,10 @@ if ($action == 'up' && $permissiontoedit) {
// Define output language
$outputlangs = $langs;
$newlang = '';
- if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
+ if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
$newlang = GETPOST('lang_id', 'aZ09');
}
- if ($conf->global->MAIN_MULTILANGS && empty($newlang)) {
+ if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) {
$newlang = $object->thirdparty->default_lang;
}
if (!empty($newlang)) {
@@ -59,10 +59,10 @@ if ($action == 'down' && $permissiontoedit) {
// Define output language
$outputlangs = $langs;
$newlang = '';
- if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
+ if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
$newlang = GETPOST('lang_id', 'aZ09');
}
- if ($conf->global->MAIN_MULTILANGS && empty($newlang)) {
+ if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) {
$newlang = $object->thirdparty->default_lang;
}
if (!empty($newlang)) {
diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php
index a66c9b895b7..3f74ba7fdb2 100644
--- a/htdocs/core/actions_massactions.inc.php
+++ b/htdocs/core/actions_massactions.inc.php
@@ -763,10 +763,10 @@ if (!$error && $massaction == "builddoc" && $permissiontoread && !GETPOST('butto
// Define output language (Here it is not used because we do only merging existing PDF)
$outputlangs = $langs;
$newlang = '';
- if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
+ if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
$newlang = GETPOST('lang_id', 'aZ09');
}
- //elseif ($conf->global->MAIN_MULTILANGS && empty($newlang) && is_object($objecttmp->thirdparty)) { // On massaction, we can have several values for $objecttmp->thirdparty
+ //elseif (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang) && is_object($objecttmp->thirdparty)) { // On massaction, we can have several values for $objecttmp->thirdparty
// $newlang = $objecttmp->thirdparty->default_lang;
//}
if (!empty($newlang)) {
@@ -965,10 +965,10 @@ if (!$error && $massaction == 'validate' && $permissiontoadd) {
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
$outputlangs = $langs;
$newlang = '';
- if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
+ if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
$newlang = GETPOST('lang_id', 'aZ09');
}
- if ($conf->global->MAIN_MULTILANGS && empty($newlang)) {
+ if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) {
$newlang = $objecttmp->thirdparty->default_lang;
}
if (!empty($newlang)) {
@@ -1116,13 +1116,13 @@ if (!$error && $massaction == 'generate_doc' && $permissiontoread) {
$outputlangs = $langs;
$newlang = '';
- if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
+ if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
$newlang = GETPOST('lang_id', 'aZ09');
}
- if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($objecttmp->thirdparty->default_lang)) {
+ if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang) && isset($objecttmp->thirdparty->default_lang)) {
$newlang = $objecttmp->thirdparty->default_lang; // for proposal, order, invoice, ...
}
- if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($objecttmp->default_lang)) {
+ if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang) && isset($objecttmp->default_lang)) {
$newlang = $objecttmp->default_lang; // for thirdparty
}
if (!empty($newlang)) {
diff --git a/htdocs/core/actions_sendmails.inc.php b/htdocs/core/actions_sendmails.inc.php
index f0ef66eb78b..3749b403469 100644
--- a/htdocs/core/actions_sendmails.inc.php
+++ b/htdocs/core/actions_sendmails.inc.php
@@ -361,7 +361,7 @@ if (($action == 'send' || $action == 'relance') && !GETPOST('addfile') && !GETPO
}
$mailfile = new CMailFile($subject, $sendto, $from, $message, $filepath, $mimetype, $filename, $sendtocc, $sendtobcc, $deliveryreceipt, -1, '', '', $trackid, '', $sendcontext);
- if ($mailfile->error) {
+ if (!empty($mailfile->error) || !empty($mailfile->errors)) {
setEventMessages($mailfile->error, $mailfile->errors, 'errors');
$action = 'presend';
} else {
@@ -427,9 +427,14 @@ if (($action == 'send' || $action == 'relance') && !GETPOST('addfile') && !GETPO
} else {
$langs->load("other");
$mesg = '
';
- if ($mailfile->error) {
+ if (!empty($mailfile->error) || !empty($mailfile->errors)) {
$mesg .= $langs->transnoentities('ErrorFailedToSendMail', dol_escape_htmltag($from), dol_escape_htmltag($sendto));
- $mesg .= '
'.$mailfile->error;
+ if (!empty($mailfile->error)) {
+ $mesg .= '
'.$mailfile->error;
+ }
+ if (!empty($mailfile->errors) && is_array($mailfile->errors)) {
+ $mesg .= '
'.implode('
', $mailfile->errors);
+ }
} else {
$mesg .= $langs->transnoentities('ErrorFailedToSendMail', dol_escape_htmltag($from), dol_escape_htmltag($sendto));
if (!empty($conf->global->MAIN_DISABLE_ALL_MAILS)) {
diff --git a/htdocs/core/actions_setnotes.inc.php b/htdocs/core/actions_setnotes.inc.php
index 91e7f4a8aca..7595daf1093 100644
--- a/htdocs/core/actions_setnotes.inc.php
+++ b/htdocs/core/actions_setnotes.inc.php
@@ -45,10 +45,10 @@ if ($action == 'setnote_public' && !empty($permissionnote) && !GETPOST('cancel',
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
$outputlangs = $langs;
$newlang = '';
- if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
+ if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
$newlang = GETPOST('lang_id', 'aZ09');
}
- if ($conf->global->MAIN_MULTILANGS && empty($newlang)) {
+ if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) {
$newlang = $object->thirdparty->default_lang;
}
if (!empty($newlang)) {
diff --git a/htdocs/core/ajax/ajaxdirpreview.php b/htdocs/core/ajax/ajaxdirpreview.php
index ce47cc3568f..7b29159b227 100644
--- a/htdocs/core/ajax/ajaxdirpreview.php
+++ b/htdocs/core/ajax/ajaxdirpreview.php
@@ -77,7 +77,7 @@ if (!isset($mode) || $mode != 'noajax') { // For ajax call
$ecmdir = new EcmDirectory($db);
if ($section > 0) {
$result = $ecmdir->fetch($section);
- if (!$result > 0) {
+ if (!($result > 0)) {
//dol_print_error($db,$ecmdir->error);
//exit;
}
@@ -90,7 +90,7 @@ if (!isset($mode) || $mode != 'noajax') { // For ajax call
$relativepath = '';
if ($section > 0) {
$result = $ecmdir->fetch($section);
- if (!$result > 0) {
+ if (!($result > 0)) {
dol_print_error($db, $ecmdir->error);
exit;
}
diff --git a/htdocs/core/ajax/check_notifications.php b/htdocs/core/ajax/check_notifications.php
index a5efb52e787..96a33f1f099 100644
--- a/htdocs/core/ajax/check_notifications.php
+++ b/htdocs/core/ajax/check_notifications.php
@@ -39,25 +39,6 @@ if (!defined('NOREQUIRETRAN')) {
define('NOREQUIRETRAN', '1');
}
-//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); // Do not load object $user
-//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); // Do not load object $mysoc
-//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); // Do not load object $langs
-//if (! defined('NOSCANGETFORINJECTION')) define('NOSCANGETFORINJECTION', '1'); // Do not check injection attack on GET parameters
-//if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION', '1'); // Do not check injection attack on POST parameters
-//if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); // Do not check CSRF attack (test on referer + on token if option MAIN_SECURITY_CSRF_WITH_TOKEN is on).
-//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on)
-//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK', '1'); // Do not check style html tag into posted data
-//if (! defined('NOIPCHECK')) define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip
-//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // If there is no need to load and show top and left menu
-//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php
-//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); // Do not load ajax.lib.php library
-//if (! defined("NOLOGIN")) define("NOLOGIN", '1'); // If this page is public (can be called outside logged session)
-//if (! defined("MAIN_LANG_DEFAULT")) define('MAIN_LANG_DEFAULT', 'auto'); // Force lang to a particular value
-//if (! defined("MAIN_AUTHENTICATION_MODE")) define('MAIN_AUTHENTICATION_MODE', 'aloginmodule'); // Force authentication handler
-//if (! defined("NOREDIRECTBYMAINTOLOGIN")) define('NOREDIRECTBYMAINTOLOGIN', '1'); // The main.inc.php does not make a redirect if not logged, instead show simple error message
-//if (! defined("XFRAMEOPTIONS_ALLOWALL")) define('XFRAMEOPTIONS_ALLOWALL', '1'); // Do not add the HTTP header 'X-Frame-Options: SAMEORIGIN' but 'X-Frame-Options: ALLOWALL'
-
-
require '../../main.inc.php';
//$time = (int) GETPOST('time', 'int'); // Use the time parameter that is always increased by time_update, even if call is late
diff --git a/htdocs/core/ajax/onlineSign.php b/htdocs/core/ajax/onlineSign.php
index 5f3cc281f90..5f59abea0b5 100644
--- a/htdocs/core/ajax/onlineSign.php
+++ b/htdocs/core/ajax/onlineSign.php
@@ -53,12 +53,13 @@ if (is_numeric($entity)) {
define("DOLENTITY", $entity);
}
include '../../main.inc.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
$action = GETPOST('action', 'aZ09');
$signature = GETPOST('signaturebase64');
$ref = GETPOST('ref', 'aZ09');
-$mode = GETPOST('mode', 'aZ09');
+$mode = GETPOST('mode', 'aZ09'); // 'proposal', ...
$SECUREKEY = GETPOST("securekey"); // Secure key
$error = 0;
@@ -69,10 +70,10 @@ $type = $mode;
// Check securitykey
$securekeyseed = '';
if ($type == 'proposal') {
- $securekeyseed = isset($conf->global->PROPOSAL_ONLINE_SIGNATURE_SECURITY_TOKEN) ? $conf->global->PROPOSAL_ONLINE_SIGNATURE_SECURITY_TOKEN : '';
+ $securekeyseed = getDolGlobalString('PROPOSAL_ONLINE_SIGNATURE_SECURITY_TOKEN');
}
-if (empty($SECUREKEY) || !dol_verifyHash($securekeyseed.$type.$ref, $SECUREKEY, '0')) {
+if (empty($SECUREKEY) || !dol_verifyHash($securekeyseed.$type.$ref.(!isModEnabled('multicompany') ? '' : $entity), $SECUREKEY, '0')) {
http_response_code(403);
print 'Bad value for securitykey. Value provided '.dol_escape_htmltag($SECUREKEY).' does not match expected value for ref='.dol_escape_htmltag($ref);
exit(-1);
@@ -123,33 +124,64 @@ if ($action == "importSignature") {
if (!$error) {
// Defined modele of doc
- $directdownloadlink = $object->getLastMainDocLink('proposal');
+ $last_main_doc_file = $object->last_main_doc;
+ $directdownloadlink = $object->getLastMainDocLink('proposal'); // url to download the $object->last_main_doc
- if (preg_match('/\.pdf/i', $directdownloadlink)) {
+ if (preg_match('/\.pdf/i', $last_main_doc_file)) {
+ // TODO Use the $last_main_doc_file to defined the $newpdffilename and $sourcefile
$newpdffilename = $upload_dir.$ref."_signed-".$date.".pdf";
$sourcefile = $upload_dir.$ref.".pdf";
if (dol_is_file($sourcefile)) {
+ // We build the new PDF
$pdf = pdf_getInstance();
- $pdf->Open();
- $pdf->AddPage();
- $pagecount = $pdf->setSourceFile($sourcefile); // original PDF
+ if (class_exists('TCPDF')) {
+ $pdf->setPrintHeader(false);
+ $pdf->setPrintFooter(false);
+ }
+ $pdf->SetFont(pdf_getPDFFont($langs));
- for ($i=1; $i<($pagecount+1); $i++) {
- if ($i>1) $pdf->AddPage();
- $tppl=$pdf->importPage($i);
- $pdf->useTemplate($tppl);
+ if (getDolGlobalString('MAIN_DISABLE_PDF_COMPRESSION')) {
+ $pdf->SetCompression(false);
}
- $pdf->Image($upload_dir.$filename, 129, 239.6, 60, 15); // FIXME Position will be wrong with non A4 format. Use a value from width and height of page minus relative offset.
- $pdf->Close();
+
+ //$pdf->Open();
+ $pagecount = $pdf->setSourceFile($sourcefile); // original PDF
+
+ $s = array(); // Array with size of each page. Exemple array(w'=>210, 'h'=>297);
+ for ($i=1; $i<($pagecount+1); $i++) {
+ try {
+ $tppl = $pdf->importPage($i);
+ $s = $pdf->getTemplatesize($tppl);
+ $pdf->AddPage($s['h'] > $s['w'] ? 'P' : 'L');
+ $pdf->useTemplate($tppl);
+ } catch (Exception $e) {
+ dol_syslog("Error when manipulating some PDF by onlineSign: ".$e->getMessage(), LOG_ERR);
+ $response = $e->getMessage();
+ $error++;
+ }
+ }
+
+ // A signature image file is 720 x 180 (ratio 1/4) but we use only the size into PDF
+ // TODO Get position of box from PDF template
+ $xforimgstart = (empty($s['w']) ? 120 : round($s['w'] / 2) + 15);
+ $yforimgstart = (empty($s['h']) ? 240 : $s['h'] - 60);
+ $wforimg = $s['w'] - 20 - $xforimgstart;
+
+ $pdf->Image($upload_dir.$filename, $xforimgstart, $yforimgstart, $wforimg, round($wforimg / 4));
+ //$pdf->Close();
$pdf->Output($newpdffilename, "F");
// Index the new file and update the last_main_doc property of object.
$object->indexFile($newpdffilename, 1);
}
+ } elseif (preg_match('/\.odt/i', $last_main_doc_file)) {
+ // Adding signature on .ODT not yet supported
+ // TODO
} else {
- // Adding signature on doc not yet supported
+ // Document format not supported to insert online signature.
+ // We should just create an image file with the signature.
}
}
diff --git a/htdocs/core/boxes/box_activity.php b/htdocs/core/boxes/box_activity.php
index 49690dc893e..12656518efc 100644
--- a/htdocs/core/boxes/box_activity.php
+++ b/htdocs/core/boxes/box_activity.php
@@ -102,7 +102,7 @@ class box_activity extends ModeleBoxes
// list the summary of the propals
- if (!empty($conf->propal->enabled) && $user->rights->propale->lire) {
+ if (isModEnabled("propal") && $user->rights->propale->lire) {
include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
$propalstatic = new Propal($this->db);
diff --git a/htdocs/core/boxes/box_dolibarr_state_board.php b/htdocs/core/boxes/box_dolibarr_state_board.php
index 83615c17fd3..a979e3e5a36 100644
--- a/htdocs/core/boxes/box_dolibarr_state_board.php
+++ b/htdocs/core/boxes/box_dolibarr_state_board.php
@@ -116,9 +116,9 @@ class box_dolibarr_state_board extends ModeleBoxes
'members' => isModEnabled('adherent') && $user->rights->adherent->lire,
'customers' => isModEnabled('societe') && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS_STATS),
'prospects' => isModEnabled('societe') && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS_STATS),
- 'suppliers' => ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->rights->fournisseur->lire)
- || (!empty($conf->supplier_order->enabled) && $user->rights->supplier_order->lire)
- || (!empty($conf->supplier_invoice->enabled) && $user->rights->supplier_invoice->lire)
+ 'suppliers' => ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->rights->fournisseur->lire)
+ || (isModEnabled("supplier_order") && $user->rights->supplier_order->lire)
+ || (isModEnabled("supplier_invoice") && $user->rights->supplier_invoice->lire)
)
&& empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_STATS),
'contacts' => isModEnabled('societe') && $user->hasRight('societe', 'contact', 'lire'),
diff --git a/htdocs/core/boxes/box_graph_product_distribution.php b/htdocs/core/boxes/box_graph_product_distribution.php
index 44f94fd48d1..42a77f14b9c 100644
--- a/htdocs/core/boxes/box_graph_product_distribution.php
+++ b/htdocs/core/boxes/box_graph_product_distribution.php
@@ -152,7 +152,7 @@ class box_graph_product_distribution extends ModeleBoxes
$WIDTH = ($nbofgraph >= 2 || !empty($conf->dol_optimize_smallscreen)) ? '300' : '320';
$HEIGHT = '150'; // Height require to have 5+1 entries into legend visible.
- if (!empty($conf->propal->enabled) && !empty($user->rights->propale->lire)) {
+ if (isModEnabled("propal") && !empty($user->rights->propale->lire)) {
// Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...)
if ($showpropalnb) {
$langs->load("propal");
@@ -365,7 +365,7 @@ class box_graph_product_distribution extends ModeleBoxes
$stringtoshow .= '
';
$stringtoshow .= '
';
$stringtoshow .= '
';
- if (!empty($conf->propal->enabled) || !empty($user->rights->propale->lire)) {
+ if (isModEnabled("propal") || !empty($user->rights->propale->lire)) {
$stringtoshow .= '
'.$langs->trans("ForProposals");
$stringtoshow .= ' ';
}
diff --git a/htdocs/core/boxes/box_produits.php b/htdocs/core/boxes/box_produits.php
index afd0db27990..7a9518d345e 100644
--- a/htdocs/core/boxes/box_produits.php
+++ b/htdocs/core/boxes/box_produits.php
@@ -62,7 +62,7 @@ class box_produits extends ModeleBoxes
$this->db = $db;
$listofmodulesforexternal = explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL);
- $tmpentry = array('enabled'=>(!empty($conf->product->enabled) || !empty($conf->service->enabled)), 'perms'=>(!empty($user->rights->produit->lire) || !empty($user->rights->service->lire)), 'module'=>'product|service');
+ $tmpentry = array('enabled'=>(isModEnabled("product") || isModEnabled("service")), 'perms'=>(!empty($user->rights->produit->lire) || !empty($user->rights->service->lire)), 'module'=>'product|service');
$showmode = isVisibleToUserType(($user->socid > 0 ? 1 : 0), $tmpentry, $listofmodulesforexternal);
$this->hidden = ($showmode != 1);
}
diff --git a/htdocs/core/boxes/box_produits_alerte_stock.php b/htdocs/core/boxes/box_produits_alerte_stock.php
index 72b1957b287..203d42c7eed 100644
--- a/htdocs/core/boxes/box_produits_alerte_stock.php
+++ b/htdocs/core/boxes/box_produits_alerte_stock.php
@@ -64,7 +64,7 @@ class box_produits_alerte_stock extends ModeleBoxes
$this->db = $db;
$listofmodulesforexternal = explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL);
- $tmpentry = array('enabled'=>((!empty($conf->product->enabled) || !empty($conf->service->enabled)) && !empty($conf->stock->enabled)), 'perms'=>!empty($user->rights->stock->lire), 'module'=>'product|service|stock');
+ $tmpentry = array('enabled'=>((isModEnabled("product") || isModEnabled("service")) && !empty($conf->stock->enabled)), 'perms'=>!empty($user->rights->stock->lire), 'module'=>'product|service|stock');
$showmode = isVisibleToUserType(($user->socid > 0 ? 1 : 0), $tmpentry, $listofmodulesforexternal);
$this->hidden = ($showmode != 1);
}
diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php
index 7acd7ac3db0..42dcd1d493b 100644
--- a/htdocs/core/class/CMailFile.class.php
+++ b/htdocs/core/class/CMailFile.class.php
@@ -30,6 +30,8 @@
* \brief File of class to send emails (with attachments or not)
*/
+use OAuth\Common\Storage\DoliStorage;
+use OAuth\Common\Consumer\Credentials;
/**
* Class to send emails (with attachments or not)
* Usage: $mailfile = new CMailFile($subject,$sendto,$replyto,$message,$filepath,$mimetype,$filename,$cc,$ccc,$deliveryreceipt,$msgishtml,$errors_to,$css,$trackid,$moreinheader,$sendcontext,$replyto);
@@ -71,9 +73,29 @@ class CMailFile
*/
public $error = '';
+ /**
+ * @var string[] Array of Error code (or message)
+ */
+ public $errors = array();
+
public $smtps; // Contains SMTPs object (if this method is used)
public $phpmailer; // Contains PHPMailer object (if this method is used)
+ /**
+ * @var Swift_SmtpTransport
+ */
+ public $transport;
+
+ /**
+ * @var Swift_Mailer
+ */
+ public $mailer;
+
+ /**
+ * @var Swift_Plugins_Loggers_ArrayLogger
+ */
+ public $logger;
+
/**
* @var string CSS
*/
@@ -470,12 +492,12 @@ class CMailFile
$emailMatchs = preg_match_all($regexp, $from, $adressEmailFrom);
$adressEmailFrom = reset($adressEmailFrom);
if ($emailMatchs !== false && filter_var($conf->global->MAIN_MAIL_SMTPS_ID, FILTER_VALIDATE_EMAIL) && $conf->global->MAIN_MAIL_SMTPS_ID !== $adressEmailFrom) {
- $result = $this->message->setFrom($conf->global->MAIN_MAIL_SMTPS_ID);
+ $this->message->setFrom($conf->global->MAIN_MAIL_SMTPS_ID);
} else {
- $result = $this->message->setFrom($this->getArrayAddress($this->addr_from));
+ $this->message->setFrom($this->getArrayAddress($this->addr_from));
}
} else {
- $result = $this->message->setFrom($this->getArrayAddress($this->addr_from));
+ $this->message->setFrom($this->getArrayAddress($this->addr_from));
}
} catch (Exception $e) {
$this->errors[] = $e->getMessage();
@@ -485,7 +507,7 @@ class CMailFile
// Set the To addresses with an associative array
if (!empty($this->addr_to)) {
try {
- $result = $this->message->setTo($this->getArrayAddress($this->addr_to));
+ $this->message->setTo($this->getArrayAddress($this->addr_to));
} catch (Exception $e) {
$this->errors[] = $e->getMessage();
}
@@ -493,14 +515,14 @@ class CMailFile
if (!empty($this->reply_to)) {
try {
- $result = $this->message->SetReplyTo($this->getArrayAddress($this->reply_to));
+ $this->message->SetReplyTo($this->getArrayAddress($this->reply_to));
} catch (Exception $e) {
$this->errors[] = $e->getMessage();
}
}
try {
- $result = $this->message->setCharSet($conf->file->character_set_client);
+ $this->message->setCharSet($conf->file->character_set_client);
} catch (Exception $e) {
$this->errors[] = $e->getMessage();
}
@@ -562,7 +584,11 @@ class CMailFile
}
//if (! empty($this->errors_to)) $this->message->setErrorsTo($this->getArrayAddress($this->errors_to));
if (isset($this->deliveryreceipt) && $this->deliveryreceipt == 1) {
- $this->message->setReadReceiptTo($this->getArrayAddress($this->addr_from));
+ try {
+ $this->message->setReadReceiptTo($this->getArrayAddress($this->addr_from));
+ } catch (Exception $e) {
+ $this->errors[] = $e->getMessage();
+ }
}
} else {
// Send mail method not correctly defined
@@ -668,6 +694,8 @@ class CMailFile
$keyforsmtpport = 'MAIN_MAIL_SMTP_PORT';
$keyforsmtpid = 'MAIN_MAIL_SMTPS_ID';
$keyforsmtppw = 'MAIN_MAIL_SMTPS_PW';
+ $keyforsmtpauthtype = 'MAIN_MAIL_SMTPS_AUTH_TYPE';
+ $keyforsmtpoauthservice = 'MAIN_MAIL_SMTPS_OAUTH_SERVICE';
$keyfortls = 'MAIN_MAIL_EMAIL_TLS';
$keyforstarttls = 'MAIN_MAIL_EMAIL_STARTTLS';
$keyforsslseflsigned = 'MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED';
@@ -680,6 +708,8 @@ class CMailFile
$keyforsmtpport = 'MAIN_MAIL_SMTP_PORT_'.$smtpContextKey;
$keyforsmtpid = 'MAIN_MAIL_SMTPS_ID_'.$smtpContextKey;
$keyforsmtppw = 'MAIN_MAIL_SMTPS_PW_'.$smtpContextKey;
+ $keyforsmtpauthtype = 'MAIN_MAIL_SMTPS_AUTH_TYPE_'.$smtpContextKey;
+ $keyforsmtpoauthservice = 'MAIN_MAIL_SMTPS_OAUTH_SERVICE_'.$smtpContextKey;
$keyfortls = 'MAIN_MAIL_EMAIL_TLS_'.$smtpContextKey;
$keyforstarttls = 'MAIN_MAIL_EMAIL_STARTTLS_'.$smtpContextKey;
$keyforsslseflsigned = 'MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_'.$smtpContextKey;
@@ -840,6 +870,60 @@ class CMailFile
$this->smtps->setPW($loginpass);
}
+ if (getDolGlobalString($keyforsmtpauthtype) === "XOAUTH2") {
+ require_once DOL_DOCUMENT_ROOT.'/core/lib/oauth.lib.php'; // define $supportedoauth2array
+ $keyforsupportedoauth2array = $conf->global->$keyforsmtpoauthservice;
+ if (preg_match('/^.*-/', $keyforsupportedoauth2array)) {
+ $keyforprovider = preg_replace('/^.*-/', '', $keyforsupportedoauth2array);
+ } else {
+ $keyforprovider = '';
+ }
+ $keyforsupportedoauth2array = preg_replace('/-.*$/', '', $keyforsupportedoauth2array);
+ $keyforsupportedoauth2array = 'OAUTH_'.$keyforsupportedoauth2array.'_NAME';
+
+ $OAUTH_SERVICENAME = (empty($supportedoauth2array[$keyforsupportedoauth2array]['name']) ? 'Unknown' : $supportedoauth2array[$keyforsupportedoauth2array]['name'].($keyforprovider ? '-'.$keyforprovider : ''));
+
+ require_once DOL_DOCUMENT_ROOT.'/includes/OAuth/bootstrap.php';
+
+ $storage = new DoliStorage($db, $conf);
+ try {
+ $tokenobj = $storage->retrieveAccessToken($OAUTH_SERVICENAME);
+ $expire = false;
+ // Is token expired or will token expire in the next 30 seconds
+ if (is_object($tokenobj)) {
+ $expire = ($tokenobj->getEndOfLife() !== -9002 && $tokenobj->getEndOfLife() !== -9001 && time() > ($tokenobj->getEndOfLife() - 30));
+ }
+ // Token expired so we refresh it
+ if (is_object($tokenobj) && $expire) {
+ $credentials = new Credentials(
+ getDolGlobalString('OAUTH_'.getDolGlobalString('MAIN_MAIL_SMTPS_OAUTH_SERVICE').'_ID'),
+ getDolGlobalString('OAUTH_'.getDolGlobalString('MAIN_MAIL_SMTPS_OAUTH_SERVICE').'_SECRET'),
+ getDolGlobalString('OAUTH_'.getDolGlobalString('MAIN_MAIL_SMTPS_OAUTH_SERVICE').'_URLAUTHORIZE')
+ );
+ $serviceFactory = new \OAuth\ServiceFactory();
+ $oauthname = explode('-', $OAUTH_SERVICENAME);
+ // ex service is Google-Emails we need only the first part Google
+ $apiService = $serviceFactory->createService($oauthname[0], $credentials, $storage, array());
+ // We have to save the token because Google give it only once
+ $refreshtoken = $tokenobj->getRefreshToken();
+ $tokenobj = $apiService->refreshAccessToken($tokenobj);
+ $tokenobj->setRefreshToken($refreshtoken);
+ $storage->storeAccessToken($OAUTH_SERVICENAME, $tokenobj);
+ }
+
+ $tokenobj = $storage->retrieveAccessToken($OAUTH_SERVICENAME);
+ if (is_object($tokenobj)) {
+ $this->smtps->setToken($tokenobj->getAccessToken());
+ } else {
+ $this->error = "Token not found";
+ }
+ } catch (Exception $e) {
+ // Return an error if token not found
+ $this->error = $e->getMessage();
+ dol_syslog("CMailFile::sendfile: mail end error=".$this->error, LOG_ERR);
+ }
+ }
+
$res = true;
$from = $this->smtps->getFrom('org');
if ($res && !$from) {
@@ -860,7 +944,6 @@ class CMailFile
}
$result = $this->smtps->sendMsg();
- //print $result;
if (!empty($conf->global->MAIN_MAIL_DEBUG)) {
$this->dump_mail();
@@ -906,9 +989,62 @@ class CMailFile
if (!empty($conf->global->$keyforsmtpid)) {
$this->transport->setUsername($conf->global->$keyforsmtpid);
}
- if (!empty($conf->global->$keyforsmtppw)) {
+ if (!empty($conf->global->$keyforsmtppw) && getDolGlobalString($keyforsmtpauthtype) != "XOAUTH2") {
$this->transport->setPassword($conf->global->$keyforsmtppw);
}
+ if (getDolGlobalString($keyforsmtpauthtype) === "XOAUTH2") {
+ require_once DOL_DOCUMENT_ROOT.'/core/lib/oauth.lib.php'; // define $supportedoauth2array
+ $keyforsupportedoauth2array = getDolGlobalString($keyforsmtpoauthservice);
+ if (preg_match('/^.*-/', $keyforsupportedoauth2array)) {
+ $keyforprovider = preg_replace('/^.*-/', '', $keyforsupportedoauth2array);
+ } else {
+ $keyforprovider = '';
+ }
+ $keyforsupportedoauth2array = preg_replace('/-.*$/', '', $keyforsupportedoauth2array);
+ $keyforsupportedoauth2array = 'OAUTH_'.$keyforsupportedoauth2array.'_NAME';
+
+ $OAUTH_SERVICENAME = (empty($supportedoauth2array[$keyforsupportedoauth2array]['name']) ? 'Unknown' : $supportedoauth2array[$keyforsupportedoauth2array]['name'].($keyforprovider ? '-'.$keyforprovider : ''));
+
+ require_once DOL_DOCUMENT_ROOT.'/includes/OAuth/bootstrap.php';
+
+ $storage = new DoliStorage($db, $conf);
+
+ try {
+ $tokenobj = $storage->retrieveAccessToken($OAUTH_SERVICENAME);
+ $expire = false;
+ // Is token expired or will token expire in the next 30 seconds
+ if (is_object($tokenobj)) {
+ $expire = ($tokenobj->getEndOfLife() !== -9002 && $tokenobj->getEndOfLife() !== -9001 && time() > ($tokenobj->getEndOfLife() - 30));
+ }
+ // Token expired so we refresh it
+ if (is_object($tokenobj) && $expire) {
+ $credentials = new Credentials(
+ getDolGlobalString('OAUTH_'.getDolGlobalString('MAIN_MAIL_SMTPS_OAUTH_SERVICE').'_ID'),
+ getDolGlobalString('OAUTH_'.getDolGlobalString('MAIN_MAIL_SMTPS_OAUTH_SERVICE').'_SECRET'),
+ getDolGlobalString('OAUTH_'.getDolGlobalString('MAIN_MAIL_SMTPS_OAUTH_SERVICE').'_URLAUTHORIZE')
+ );
+ $serviceFactory = new \OAuth\ServiceFactory();
+ $oauthname = explode('-', $OAUTH_SERVICENAME);
+ // ex service is Google-Emails we need only the first part Google
+ $apiService = $serviceFactory->createService($oauthname[0], $credentials, $storage, array());
+ // We have to save the token because Google give it only once
+ $refreshtoken = $tokenobj->getRefreshToken();
+ $tokenobj = $apiService->refreshAccessToken($tokenobj);
+ $tokenobj->setRefreshToken($refreshtoken);
+ $storage->storeAccessToken($OAUTH_SERVICENAME, $tokenobj);
+ }
+ if (is_object($tokenobj)) {
+ $this->transport->setAuthMode('XOAUTH2');
+ $this->transport->setPassword($tokenobj->getAccessToken());
+ } else {
+ $this->errors[] = "Token not found";
+ }
+ } catch (Exception $e) {
+ // Return an error if token not found
+ $this->errors[] = $e->getMessage();
+ dol_syslog("CMailFile::sendfile: mail end error=".$e->getMessage(), LOG_ERR);
+ }
+ }
if (!empty($conf->global->$keyforsslseflsigned)) {
$this->transport->setStreamOptions(array('ssl' => array('allow_self_signed' => true, 'verify_peer' => false)));
}
@@ -941,16 +1077,16 @@ class CMailFile
try {
$result = $this->mailer->send($this->message, $failedRecipients);
} catch (Exception $e) {
- $this->error = $e->getMessage();
+ $this->errors[] = $e->getMessage();
}
if (!empty($conf->global->MAIN_MAIL_DEBUG)) {
$this->dump_mail();
}
$res = true;
- if (!empty($this->error) || !$result) {
+ if (!empty($this->error) || !empty($this->errors) || !$result) {
if (!empty($failedRecipients)) {
- $this->error = 'Transport failed for the following addresses: "' . join('", "', $failedRecipients) . '".';
+ $this->errors[] = 'Transport failed for the following addresses: "' . join('", "', $failedRecipients) . '".';
}
dol_syslog("CMailFile::sendfile: mail end error=".$this->error, LOG_ERR);
$res = false;
@@ -1421,6 +1557,7 @@ class CMailFile
dol_syslog("Try socket connection to host=".$host." port=".$port);
//See if we can connect to the SMTP server
+ $errno = 0; $errstr = '';
if ($socket = @fsockopen(
$host, // Host to test, IP or domain. Add ssl:// for SSL/TLS.
$port, // which Port number to use
diff --git a/htdocs/core/class/comment.class.php b/htdocs/core/class/comment.class.php
index 937ca6f7875..960d2ac4744 100644
--- a/htdocs/core/class/comment.class.php
+++ b/htdocs/core/class/comment.class.php
@@ -71,19 +71,19 @@ class Comment extends CommonObject
public $fk_user_modif;
/**
- * @var int Entity
+ * @var int Entity
*/
public $entity;
/**
- * @var string import key
+ * @var string Import key
*/
public $import_key;
public $comments = array();
/**
- * @var Comment Object oldcopy
+ * @var Comment Object oldcopy
*/
public $oldcopy;
diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php
index e96eee5c553..bed28c63035 100644
--- a/htdocs/core/class/commoninvoice.class.php
+++ b/htdocs/core/class/commoninvoice.class.php
@@ -574,8 +574,13 @@ abstract class CommonInvoice extends CommonObject
$labelStatus = $langs->transnoentitiesnoconv('BillStatusDraft');
$labelStatusShort = $langs->transnoentitiesnoconv('Bill'.$prefix.'StatusDraft');
} elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) {
- $labelStatus = $langs->transnoentitiesnoconv('BillStatusClosedUnpaid');
- $labelStatusShort = $langs->transnoentitiesnoconv('Bill'.$prefix.'StatusClosedUnpaid');
+ if ($status == 3) {
+ $labelStatus = $langs->transnoentitiesnoconv('BillStatusCanceled');
+ $labelStatusShort = $langs->transnoentitiesnoconv('Bill'.$prefix.'StatusCanceled');
+ } else {
+ $labelStatus = $langs->transnoentitiesnoconv('BillStatusClosedUnpaid');
+ $labelStatusShort = $langs->transnoentitiesnoconv('Bill'.$prefix.'StatusClosedUnpaid');
+ }
$statusType = 'status5';
} elseif (($status == 3 || $status == 2) && $alreadypaid > 0) {
$labelStatus = $langs->transnoentitiesnoconv('BillStatusClosedPaidPartially');
diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php
index 3c24b3c484f..5b5de36406a 100644
--- a/htdocs/core/class/commonobject.class.php
+++ b/htdocs/core/class/commonobject.class.php
@@ -141,7 +141,7 @@ abstract class CommonObject
public $linkedObjectsFullLoaded = array();
/**
- * @var Object To store a cloned copy of object before to edit it and keep track of old properties
+ * @var CommonObject To store a cloned copy of object before to edit it and keep track of old properties
*/
public $oldcopy;
@@ -588,8 +588,8 @@ abstract class CommonObject
public $alreadypaid;
- private $labelStatus;
- private $labelStatusShort;
+ protected $labelStatus;
+ protected $labelStatusShort;
/**
@@ -1043,7 +1043,8 @@ abstract class CommonObject
// Add entry into index
if ($initsharekey) {
require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
- // TODO We can't, we dont' have full path of file, only last_main_doc adn ->element, so we must rebuild full path first
+
+ // TODO We can't, we dont' have full path of file, only last_main_doc and ->element, so we must first rebuild full path $destfull
/*
$ecmfile->filepath = $rel_dir;
$ecmfile->filename = $filename;
@@ -3512,7 +3513,7 @@ abstract class CommonObject
*
* @param int $exclspec >0 = Exclude special product (product_type=9)
* @param string $roundingadjust 'none'=Do nothing, 'auto'=Use default method (MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND if defined, or '0'), '0'=Force mode Total of rounding, '1'=Force mode Rounding of total
- * @param int $nodatabaseupdate 1=Do not update database. Update only properties of object.
+ * @param int $nodatabaseupdate 1=Do not update database total fields of the main object. Update only properties in memory. Can be used to save SQL when this method is called several times, so we can do it only once at end.
* @param Societe $seller If roundingadjust is '0' or '1' or maybe 'auto', it means we recalculate total for lines before calculating total for object and for this, we need seller object (used to analyze lines to check corrupted data).
* @return int <0 if KO, >0 if OK
*/
@@ -3558,10 +3559,6 @@ abstract class CommonObject
include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
- if ($roundingadjust == '-1') {
- $roundingadjust = 'auto'; // For backward compatibility
- }
-
$forcedroundingmode = $roundingadjust;
if ($forcedroundingmode == 'auto' && isset($conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND)) {
$forcedroundingmode = $conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND;
@@ -3573,7 +3570,7 @@ abstract class CommonObject
$multicurrency_tx = !empty($this->multicurrency_tx) ? $this->multicurrency_tx : 1;
- // Define constants to find lines to sum
+ // Define constants to find lines to sum (field name int the table_element_line not into table_element)
$fieldtva = 'total_tva';
$fieldlocaltax1 = 'total_localtax1';
$fieldlocaltax2 = 'total_localtax2';
@@ -3609,6 +3606,7 @@ abstract class CommonObject
$sql .= ' ORDER by rowid'; // We want to be sure to always use same order of line to not change lines differently when option MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND is used
dol_syslog(get_class($this)."::update_price", LOG_DEBUG);
+
$resql = $this->db->query($sql);
if ($resql) {
$this->total_ht = 0;
@@ -3637,14 +3635,26 @@ abstract class CommonObject
$localtax_array = array($obj->localtax1_type, $obj->localtax1_tx, $obj->localtax2_type, $obj->localtax2_tx);
$tmpcal = calcul_price_total($obj->qty, $obj->up, $obj->remise_percent, $obj->vatrate, $obj->localtax1_tx, $obj->localtax2_tx, 0, 'HT', $obj->info_bits, $obj->product_type, $seller, $localtax_array, (isset($obj->situation_percent) ? $obj->situation_percent : 100), $multicurrency_tx);
- $diff_when_using_price_ht = price2num($tmpcal[1] - $obj->total_tva, 'MT', 1); // If price was set with tax price adn unit price HT has a low number of digits, then we may have a diff on recalculation from unit price HT.
+ $diff_when_using_price_ht = price2num($tmpcal[1] - $obj->total_tva, 'MT', 1); // If price was set with tax price and unit price HT has a low number of digits, then we may have a diff on recalculation from unit price HT.
$diff_on_current_total = price2num($obj->total_ttc - $obj->total_ht - $obj->total_tva - $obj->total_localtax1 - $obj->total_localtax2, 'MT', 1);
- //var_dump($obj->total_ht.' '.$obj->total_tva.' '.$obj->total_localtax1.' '.$obj->total_localtax2.' =? '.$obj->total_ttc);
+ //var_dump($obj->total_ht.' '.$obj->total_tva.' '.$obj->total_localtax1.' '.$obj->total_localtax2.' => '.$obj->total_ttc);
//var_dump($diff_when_using_price_ht.' '.$diff_on_current_total);
- if ($diff_when_using_price_ht && $diff_on_current_total) {
+ if ($diff_on_current_total) {
+ // This should not happen, we should always have in table: total_ttc = total_ht + total_vat + total_localtax1 + total_localtax2
$sqlfix = "UPDATE ".$this->db->prefix().$this->table_element_line." SET ".$fieldtva." = ".price2num((float) $tmpcal[1]).", total_ttc = ".price2num((float) $tmpcal[2])." WHERE rowid = ".((int) $obj->rowid);
- dol_syslog('We found unconsistent data into detailed line (diff_when_using_price_ht = '.$diff_when_using_price_ht.' and diff_on_current_total = '.$diff_on_current_total.') for line rowid = '.$obj->rowid." (total vat of line calculated=".$tmpcal[1].", database=".$obj->total_tva."). We fix the total_vat and total_ttc of line by running sqlfix = ".$sqlfix, LOG_WARNING);
+ dol_syslog('We found unconsistent data into detailed line (diff_on_current_total = '.$diff_on_current_total.') for line rowid = '.$obj->rowid." (ht=".$obj->total_ht." vat=".$obj->total_tva." tax1=".$obj->total_localtax1." tax2=".$obj->total_localtax2." ttc=".$obj->total_ttc."). We fix the total_vat and total_ttc of line by running sqlfix = ".$sqlfix, LOG_WARNING);
+ $resqlfix = $this->db->query($sqlfix);
+ if (!$resqlfix) {
+ dol_print_error($this->db, 'Failed to update line');
+ }
+ $obj->total_tva = $tmpcal[1];
+ $obj->total_ttc = $tmpcal[2];
+ } elseif ($diff_when_using_price_ht && $roundingadjust == '0') {
+ // After calculation from HT, total is consistent but we have found a difference between VAT part in calculation and into database and
+ // we ask to force the use of rounding on line (like done on calculation) so we force update of line
+ $sqlfix = "UPDATE ".$this->db->prefix().$this->table_element_line." SET ".$fieldtva." = ".price2num((float) $tmpcal[1]).", total_ttc = ".price2num((float) $tmpcal[2])." WHERE rowid = ".((int) $obj->rowid);
+ dol_syslog('We found a line with different rounding data into detailed line (diff_when_using_price_ht = '.$diff_when_using_price_ht.' and diff_on_current_total = '.$diff_on_current_total.') for line rowid = '.$obj->rowid." (total vat of line calculated=".$tmpcal[1].", database=".$obj->total_tva."). We fix the total_vat and total_ttc of line by running sqlfix = ".$sqlfix);
$resqlfix = $this->db->query($sqlfix);
if (!$resqlfix) {
dol_print_error($this->db, 'Failed to update line');
@@ -3725,7 +3735,7 @@ abstract class CommonObject
$this->db->free($resql);
- // Now update global field total_ht, total_ttc, total_tva, total_localtax1, total_localtax2, multicurrency_total_*
+ // Now update global fields total_ht, total_ttc, total_tva, total_localtax1, total_localtax2, multicurrency_total_* of main object
$fieldht = 'total_ht';
$fieldtva = 'tva';
$fieldlocaltax1 = 'localtax1';
@@ -4932,7 +4942,7 @@ abstract class CommonObject
*
* @param string $action GET/POST action
* @param CommonObjectLine $line Selected object line to output
- * @param string $var Is it a an odd line (true)
+ * @param string $var Not used
* @param int $num Number of line (0)
* @param int $i I
* @param int $dateSelector 1=Show also date range input fields
@@ -6024,7 +6034,7 @@ abstract class CommonObject
// Test fetch_array ! is_int($key) because fetch_array result is a mix table with Key as alpha and Key as int (depend db engine)
if ($key != 'rowid' && $key != 'tms' && $key != 'fk_member' && !is_int($key)) {
// we can add this attribute to object
- if (!empty($extrafields) && in_array($extrafields->attributes[$this->table_element]['type'][$key], array('date', 'datetime'))) {
+ if (!empty($extrafields->attributes[$this->table_element]) && in_array($extrafields->attributes[$this->table_element]['type'][$key], array('date', 'datetime'))) {
//var_dump($extrafields->attributes[$this->table_element]['type'][$key]);
$this->array_options["options_".$key] = $this->db->jdate($value);
} else {
@@ -6037,7 +6047,7 @@ abstract class CommonObject
// If field is a computed field, value must become result of compute
foreach ($tab as $key => $value) {
- if (!empty($extrafields) && !empty($extrafields->attributes[$this->table_element]['computed'][$key])) {
+ if (!empty($extrafields->attributes[$this->table_element]) && !empty($extrafields->attributes[$this->table_element]['computed'][$key])) {
//var_dump($conf->disable_compute);
if (empty($conf->disable_compute)) {
$this->array_options["options_".$key] = dol_eval($extrafields->attributes[$this->table_element]['computed'][$key], 1, 0, '');
@@ -8908,11 +8918,12 @@ abstract class CommonObject
/**
- * Function to prepare a part of the query for insert.
- * Note $this->${field} are set by the page that make the createCommon or the updateCommon.
- * $this->${field} should be a clean value. The page can run
+ * Function to prepare a part of the query for insert by returning an array with all properties of object.
*
- * @return array
+ * Note $this->${field} are set by the page that make the createCommon() or the updateCommon().
+ * $this->${field} should be a clean and string value (so date are formated for SQL insert).
+ *
+ * @return array Array with all values of each properties to update
*/
protected function setSaveQuery()
{
@@ -8940,7 +8951,7 @@ abstract class CommonObject
}
} elseif ($this->isInt($info) || $this->isFloat($info)) {
if ($field == 'entity' && is_null($this->{$field})) {
- $queryarray[$field] = $conf->entity;
+ $queryarray[$field] = ((int) $conf->entity);
} else {
// $this->{$field} may be null, '', 0, '0', 123, '123'
if ((isset($this->{$field}) && $this->{$field} != '') || !empty($info['notnull'])) {
@@ -9368,6 +9379,11 @@ abstract class CommonObject
$now = dol_now();
+ // $this->oldcopy should have been set by the caller of update
+ //if (empty($this->oldcopy)) {
+ // $this->oldcopy = dol_clone($this);
+ //}
+
$fieldvalues = $this->setSaveQuery();
if (array_key_exists('date_modification', $fieldvalues) && empty($fieldvalues['date_modification'])) {
@@ -9413,6 +9429,7 @@ abstract class CommonObject
$sql = 'UPDATE '.$this->db->prefix().$this->table_element.' SET '.implode(', ', $tmp).' WHERE rowid='.((int) $this->id);
$this->db->begin();
+
if (!$error) {
$res = $this->db->query($sql);
if (!$res) {
@@ -9954,7 +9971,7 @@ abstract class CommonObject
}
}
- return $error ? -1 * $error : $ok;
+ return $error ? (-1 * $error) : $ok;
}
/**
diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php
index 2e544a9953a..234f8d80e0c 100644
--- a/htdocs/core/class/conf.class.php
+++ b/htdocs/core/class/conf.class.php
@@ -255,6 +255,8 @@ class Conf
);
if (!is_null($db) && is_object($db)) {
+ include_once DOL_DOCUMENT_ROOT.'/core/lib/security.lib.php';
+
// Define all global constants into $this->global->key=value
$sql = "SELECT ".$db->decrypt('name')." as name,";
$sql .= " ".$db->decrypt('value')." as value, entity";
@@ -278,8 +280,7 @@ class Conf
$value = $_ENV['DOLIBARR_'.$key];
}
- //if (! defined("$key")) define("$key", $value); // In some cases, the constant might be already forced (Example: SYSLOG_HANDLERS during install)
- $this->global->$key = $value;
+ $this->global->$key = dolDecrypt($value);
if ($value && strpos($key, 'MAIN_MODULE_') === 0) {
$reg = array();
@@ -370,7 +371,7 @@ class Conf
}
// Object $mc
- if (!defined('NOREQUIREMC') && !empty($this->multicompany->enabled)) {
+ if (!defined('NOREQUIREMC') && isModEnabled('multicompany')) {
global $mc;
$ret = @dol_include_once('/multicompany/class/actions_multicompany.class.php');
if ($ret) {
@@ -424,7 +425,7 @@ class Conf
$rootfordata = DOL_DATA_ROOT;
$rootforuser = DOL_DATA_ROOT;
// If multicompany module is enabled, we redefine the root of data
- if (!empty($this->multicompany->enabled) && !empty($this->entity) && $this->entity > 1) {
+ if (isModEnabled('multicompany') && !empty($this->entity) && $this->entity > 1) {
$rootfordata .= '/'.$this->entity;
}
// Set standard temporary folder name or global override
@@ -986,7 +987,7 @@ class Conf
}
// Object $mc
- if (!defined('NOREQUIREMC') && !empty($this->multicompany->enabled)) {
+ if (!defined('NOREQUIREMC') && isModEnabled('multicompany')) {
if (is_object($mc)) {
$mc->setValues($this);
}
@@ -1018,7 +1019,9 @@ class Conf
}
if (empty($handler_file_found)) {
- throw new Exception('Missing log handler file '.$handler.'.php');
+ // If log handler has been removed of is badly setup, we must be able to continue code.
+ //throw new Exception('Missing log handler file '.$handler.'.php');
+ continue;
}
require_once $handler_file_found;
diff --git a/htdocs/core/class/defaultvalues.class.php b/htdocs/core/class/defaultvalues.class.php
index 278b5d5e0e6..57939f307a7 100644
--- a/htdocs/core/class/defaultvalues.class.php
+++ b/htdocs/core/class/defaultvalues.class.php
@@ -148,7 +148,7 @@ class DefaultValues extends CommonObject
if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid'])) {
$this->fields['rowid']['visible'] = 0;
}
- if (empty($conf->multicompany->enabled) && isset($this->fields['entity'])) {
+ if (!isModEnabled('multicompany') && isset($this->fields['entity'])) {
$this->fields['entity']['enabled'] = 0;
}
diff --git a/htdocs/core/class/emailsenderprofile.class.php b/htdocs/core/class/emailsenderprofile.class.php
index b5b1619443b..583dd7faca0 100644
--- a/htdocs/core/class/emailsenderprofile.class.php
+++ b/htdocs/core/class/emailsenderprofile.class.php
@@ -149,7 +149,7 @@ class EmailSenderProfile extends CommonObject
if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) {
$this->fields['rowid']['visible'] = 0;
}
- if (empty($conf->multicompany->enabled)) {
+ if (!isModEnabled('multicompany')) {
$this->fields['entity']['enabled'] = 0;
}
}
diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php
index c12cfc480fc..bbc5e8604ce 100644
--- a/htdocs/core/class/extrafields.class.php
+++ b/htdocs/core/class/extrafields.class.php
@@ -1634,7 +1634,7 @@ class ExtraFields
if (!empty($value)) {
//$value=price($value);
$sizeparts = explode(",", $size);
- $number_decimals = $sizeparts[1];
+ $number_decimals = array_key_exists(1, $sizeparts) ? $sizeparts[1] : 0;
$value = price($value, 0, $langs, 0, 0, $number_decimals, '');
}
} elseif ($type == 'boolean') {
diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php
index 82e73186233..a8ae8a0af33 100644
--- a/htdocs/core/class/html.form.class.php
+++ b/htdocs/core/class/html.form.class.php
@@ -233,21 +233,21 @@ class Form
}
if (preg_match('/^(string|safehtmlstring|email)/', $typeofdata)) {
$tmp = explode(':', $typeofdata);
- $ret .= '
';
+ $ret .= '
';
} elseif (preg_match('/^(integer)/', $typeofdata)) {
$tmp = explode(':', $typeofdata);
$valuetoshow = price2num($editvalue ? $editvalue : $value, 0);
- $ret .= '
';
+ $ret .= '
';
} elseif (preg_match('/^(numeric|amount)/', $typeofdata)) {
$tmp = explode(':', $typeofdata);
$valuetoshow = price2num($editvalue ? $editvalue : $value);
- $ret .= '
';
+ $ret .= '
';
} elseif (preg_match('/^(checkbox)/', $typeofdata)) {
$tmp = explode(':', $typeofdata);
- $ret .= '
';
+ $ret .= '
';
} elseif (preg_match('/^text/', $typeofdata) || preg_match('/^note/', $typeofdata)) { // if wysiwyg is enabled $typeofdata = 'ckeditor'
$tmp = explode(':', $typeofdata);
- $cols = $tmp[2];
+ $cols = (empty($tmp[2]) ? '' : $tmp[2]);
$morealt = '';
if (preg_match('/%/', $cols)) {
$morealt = ' style="width: '.$cols.'"';
@@ -255,7 +255,7 @@ class Form
}
$valuetoshow = ($editvalue ? $editvalue : $value);
- $ret .= '
';
+ $ret .= '';
// textarea convert automatically entities chars into simple chars.
// So we convert & into & so a string like 'a < b é <script>alert('X');<script>' stay a correct html and is not converted by textarea component when wysiwig is off.
$valuetoshow = str_replace('&', '&', $valuetoshow);
@@ -277,7 +277,7 @@ class Form
} elseif (preg_match('/^ckeditor/', $typeofdata)) {
$tmp = explode(':', $typeofdata); // Example: ckeditor:dolibarr_zzz:width:height:savemethod:toolbarstartexpanded:rows:cols:uselocalbrowser
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
- $doleditor = new DolEditor($htmlname, ($editvalue ? $editvalue : $value), ($tmp[2] ? $tmp[2] : ''), ($tmp[3] ? $tmp[3] : '100'), ($tmp[1] ? $tmp[1] : 'dolibarr_notes'), 'In', ($tmp[5] ? $tmp[5] : 0), (isset($tmp[8]) ? ($tmp[8] ?true:false) : true), true, ($tmp[6] ? $tmp[6] : '20'), ($tmp[7] ? $tmp[7] : '100'));
+ $doleditor = new DolEditor($htmlname, ($editvalue ? $editvalue : $value), (empty($tmp[2]) ? '' : $tmp[2]), (empty($tmp[3]) ? '100' : $tmp[3]), (empty($tmp[1]) ? 'dolibarr_notes' : $tmp[1]), 'In', (empty($tmp[5]) ? 0 : $tmp[5]), (isset($tmp[8]) ? ($tmp[8] ? true : false) : true), true, (empty($tmp[6]) ? '20' : $tmp[6]), (empty($tmp[7]) ? '100' : $tmp[7]));
$ret .= $doleditor->Create(1);
}
if (empty($notabletag)) {
@@ -1104,7 +1104,7 @@ class Form
global $langs, $conf;
// If product & services are enabled or both disabled.
- if ($forceall == 1 || (empty($forceall) && !empty($conf->product->enabled) && !empty($conf->service->enabled))
+ if ($forceall == 1 || (empty($forceall) && isModEnabled("product") && isModEnabled("service"))
|| (empty($forceall) && empty($conf->product->enabled) && empty($conf->service->enabled))) {
if (empty($hidetext)) {
print $langs->trans("Type").': ';
@@ -1134,11 +1134,11 @@ class Form
print ajax_combobox('select_'.$htmlname);
//if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1);
}
- if ((empty($forceall) && empty($conf->product->enabled) && !empty($conf->service->enabled)) || $forceall == 3) {
+ if ((empty($forceall) && empty($conf->product->enabled) && isModEnabled("service")) || $forceall == 3) {
print $langs->trans("Service");
print ' ';
}
- if ((empty($forceall) && !empty($conf->product->enabled) && empty($conf->service->enabled)) || $forceall == 2) {
+ if ((empty($forceall) && isModEnabled("product") && empty($conf->service->enabled)) || $forceall == 2) {
print $langs->trans("Product");
print ' ';
}
@@ -1408,7 +1408,7 @@ class Form
if (count($scrit) > 1) {
$sql .= ")";
}
- if (!empty($conf->barcode->enabled)) {
+ if (isModEnabled('barcode')) {
$sql .= " OR s.barcode LIKE '".$this->db->escape($prefix.$filterkey)."%'";
}
$sql .= " OR s.code_client LIKE '".$this->db->escape($prefix.$filterkey)."%' OR s.code_fournisseur LIKE '".$this->db->escape($prefix.$filterkey)."%'";
@@ -1961,11 +1961,11 @@ class Form
// Forge request to select users
$sql = "SELECT DISTINCT u.rowid, u.lastname as lastname, u.firstname, u.statut as status, u.login, u.admin, u.entity, u.photo";
- if (!empty($conf->multicompany->enabled) && $conf->entity == 1 && $user->admin && !$user->entity) {
+ if (isModEnabled('multicompany') && $conf->entity == 1 && $user->admin && !$user->entity) {
$sql .= ", e.label";
}
$sql .= " FROM ".$this->db->prefix()."user as u";
- if (!empty($conf->multicompany->enabled) && $conf->entity == 1 && $user->admin && !$user->entity) {
+ if (isModEnabled('multicompany') && $conf->entity == 1 && $user->admin && !$user->entity) {
$sql .= " LEFT JOIN ".$this->db->prefix()."entity as e ON e.rowid = u.entity";
if ($force_entity) {
$sql .= " WHERE u.entity IN (0, ".$this->db->sanitize($force_entity).")";
@@ -1973,7 +1973,7 @@ class Form
$sql .= " WHERE u.entity IS NOT NULL";
}
} else {
- if (!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) {
+ if (isModEnabled('multicompany') && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) {
$sql .= " LEFT JOIN ".$this->db->prefix()."usergroup_user as ug";
$sql .= " ON ug.fk_user = u.rowid";
$sql .= " WHERE ug.entity = ".$conf->entity;
@@ -2075,7 +2075,7 @@ class Form
$moreinfo .= ($moreinfo ? ' - ' : ' (').$langs->trans('Disabled');
}
}
- if (!empty($conf->multicompany->enabled) && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && !$user->entity) {
+ if (isModEnabled('multicompany') && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && !$user->entity) {
if (!$obj->entity) {
$moreinfo .= ($moreinfo ? ' - ' : ' (').$langs->trans("AllEntities");
} else {
@@ -2278,10 +2278,10 @@ class Form
$ajaxoptions = array();
}
- if (strval($filtertype) === '' && (!empty($conf->product->enabled) || !empty($conf->service->enabled))) {
- if (!empty($conf->product->enabled) && empty($conf->service->enabled)) {
+ if (strval($filtertype) === '' && (isModEnabled("product") || isModEnabled("service"))) {
+ if (isModEnabled("product") && empty($conf->service->enabled)) {
$filtertype = '0';
- } elseif (empty($conf->product->enabled) && !empty($conf->service->enabled)) {
+ } elseif (empty($conf->product->enabled) && isModEnabled("service")) {
$filtertype = '1';
}
}
@@ -2691,7 +2691,7 @@ class Form
if (count($scrit) > 1) {
$sql .= ")";
}
- if (!empty($conf->barcode->enabled)) {
+ if (isModEnabled('barcode')) {
$sql .= " OR p.barcode LIKE '".$this->db->escape($prefix.$filterkey)."%'";
}
$sql .= ')';
@@ -3254,7 +3254,7 @@ class Form
if (!empty($conf->global->PRODUCT_USE_UNITS)) {
$sql .= ", u.label as unit_long, u.short_label as unit_short, p.weight, p.weight_units, p.length, p.length_units, p.width, p.width_units, p.height, p.height_units, p.surface, p.surface_units, p.volume, p.volume_units";
}
- if (!empty($conf->barcode->enabled)) {
+ if (isModEnabled('barcode')) {
$sql .= ", pfp.barcode";
}
$sql .= " FROM ".$this->db->prefix()."product as p";
@@ -3305,7 +3305,7 @@ class Form
if (count($scrit) > 1) {
$sql .= ")";
}
- if (!empty($conf->barcode->enabled)) {
+ if (isModEnabled('barcode')) {
$sql .= " OR p.barcode LIKE '".$this->db->escape($prefix.$filterkey)."%'";
$sql .= " OR pfp.barcode LIKE '".$this->db->escape($prefix.$filterkey)."%'";
}
@@ -3402,7 +3402,7 @@ class Form
if (!empty($objp->idprodfournprice) && ($objp->ref != $objp->ref_fourn)) {
$optlabel .= ' ('.$objp->ref_fourn.') ';
}
- if (!empty($conf->barcode->enabled) && !empty($objp->barcode)) {
+ if (isModEnabled('barcode') && !empty($objp->barcode)) {
$optlabel .= ' ('.$outbarcode.')';
}
$optlabel .= ' - '.dol_trunc($label, $maxlengtharticle);
@@ -3411,7 +3411,7 @@ class Form
if (!empty($objp->idprodfournprice) && ($objp->ref != $objp->ref_fourn)) {
$outvallabel .= ' ('.$objRefFourn.')';
}
- if (!empty($conf->barcode->enabled) && !empty($objp->barcode)) {
+ if (isModEnabled('barcode') && !empty($objp->barcode)) {
$outvallabel .= ' ('.$outbarcode.')';
}
$outvallabel .= ' - '.dol_trunc($label, $maxlengtharticle);
@@ -5034,7 +5034,7 @@ class Form
$more .= '
';
}
$more .= 'transnoentities($labelbuttonyes)).'": function() {
- var options = "&token='.urlencode(newToken()).'";
+ var options = "token='.urlencode(newToken()).'";
var inputok = '.json_encode($inputok).'; /* List of fields into form */
+ var page = "'.dol_escape_js(!empty($page) ? $page : '').'";
var pageyes = "'.dol_escape_js(!empty($pageyes) ? $pageyes : '').'";
if (inputok.length>0) {
$.each(inputok, function(i, inputname) {
@@ -5174,13 +5175,19 @@ class Form
options += "&" + inputname + "=" + encodeURIComponent(inputvalue);
});
}
- var urljump = pageyes + (pageyes.indexOf("?") < 0 ? "?" : "") + options;
- if (pageyes.length > 0) { location.href = urljump; }
+ if (pageyes.length > 0) {
+ var post = $.post(
+ pageyes,
+ options,
+ (data) => {$("body").html(data)}
+ );
+ }
$(this).dialog("close");
},
"'.dol_escape_js($langs->transnoentities($labelbuttonno)).'": function() {
- var options = "&token='.urlencode(newToken()).'";
+ var options = "token='.urlencode(newToken()).'";
var inputko = '.json_encode($inputko).'; /* List of fields into form */
+ var page = "'.dol_escape_js(!empty($page) ? $page : '').'";
var pageno="'.dol_escape_js(!empty($pageno) ? $pageno : '').'";
if (inputko.length>0) {
$.each(inputko, function(i, inputname) {
@@ -5191,9 +5198,13 @@ class Form
options += "&" + inputname + "=" + encodeURIComponent(inputvalue);
});
}
- var urljump=pageno + (pageno.indexOf("?") < 0 ? "?" : "") + options;
- //alert(urljump);
- if (pageno.length > 0) { location.href = urljump; }
+ if (pageno.length > 0) {
+ var post = $.post(
+ pageno,
+ options,
+ (data) => {$("body").html(data)}
+ );
+ }
$(this).dialog("close");
}
}
@@ -6459,11 +6470,15 @@ class Form
} elseif ($usecalendar == 'jquery') {
if (!$disabled) {
// Output javascript for datepicker
+ $minYear = getDolGlobalInt('MIN_YEAR_SELECT_DATE', (date('Y') - 100));
+ $maxYear = getDolGlobalInt('MAX_YEAR_SELECT_DATE', (date('Y') + 100));
+
$retstring .= "';
+ exit;
+}
+
+
+// @CHANGE
+
+// This is the function that sends the results of the uploading process to CKE.
+/**
+ * SendCKEditorResults
+ *
+ * @param string $callback callback
+ * @param string $sFileUrl sFileUrl
+ * @param string $customMsg customMsg
+ * @return void
+ */
+function SendCKEditorResults($callback, $sFileUrl, $customMsg = '')
+{
+ echo '';
+}
+
+
+
+/**
+ * RemoveFromStart
+ *
+ * @param string $sourceString Source
+ * @param string $charToRemove Char to remove
+ * @return string Result
+ */
+function RemoveFromStart($sourceString, $charToRemove)
+{
+ $sPattern = '|^'.$charToRemove.'+|';
+ return preg_replace($sPattern, '', $sourceString);
+}
+
+/**
+ * RemoveFromEnd
+ *
+ * @param string $sourceString Source
+ * @param string $charToRemove Rhar to remove
+ * @return string Result
+ */
+function RemoveFromEnd($sourceString, $charToRemove)
+{
+ $sPattern = '|'.$charToRemove.'+$|';
+ return preg_replace($sPattern, '', $sourceString);
+}
+
+/**
+ * FindBadUtf8
+ *
+ * @param string $string String
+ * @return boolean
+ */
+function FindBadUtf8($string)
+{
+ $regex = '([\x00-\x7F]|[\xC2-\xDF][\x80-\xBF]|\xE0[\xA0-\xBF][\x80-\xBF]|[\xE1-\xEC\xEE\xEF][\x80-\xBF]{2}|\xED[\x80-\x9F][\x80-\xBF]';
+ $regex .= '|\xF0[\x90-\xBF][\x80-\xBF]{2}|[\xF1-\xF3][\x80-\xBF]{3}|\xF4[\x80-\x8F][\x80-\xBF]{2}|(.{1}))';
+
+ $matches = array();
+ while (preg_match('/'.$regex.'/S', $string, $matches)) {
+ if (isset($matches[2])) {
+ return true;
+ }
+ $string = substr($string, strlen($matches[0]));
+ }
+
+ return false;
+}
+
+/**
+ * ConvertToXmlAttribute
+ *
+ * @param string $value Value
+ * @return string
+ */
+function ConvertToXmlAttribute($value)
+{
+ if (defined('PHP_OS')) {
+ $os = PHP_OS;
+ } else {
+ $os = php_uname();
+ }
+
+ if (strtoupper(substr($os, 0, 3)) === 'WIN' || FindBadUtf8($value)) {
+ return (utf8_encode(htmlspecialchars($value)));
+ } else {
+ return (htmlspecialchars($value));
+ }
+}
+
+/**
+ * Check whether given extension is in html etensions list
+ *
+ * @param string $ext Extension
+ * @param array $formExtensions Array of extensions
+ * @return boolean
+ */
+function IsHtmlExtension($ext, $formExtensions)
+{
+ if (!$formExtensions || !is_array($formExtensions)) {
+ return false;
+ }
+ $lcaseHtmlExtensions = array();
+ foreach ($formExtensions as $key => $val) {
+ $lcaseHtmlExtensions[$key] = strtolower($val);
+ }
+ return in_array($ext, $lcaseHtmlExtensions);
+}
+
+/**
+ * Detect HTML in the first KB to prevent against potential security issue with
+ * IE/Safari/Opera file type auto detection bug.
+ * Returns true if file contain insecure HTML code at the beginning.
+ *
+ * @param string $filePath absolute path to file
+ * @return boolean
+ */
+function DetectHtml($filePath)
+{
+ $fp = @fopen($filePath, 'rb');
+
+ //open_basedir restriction, see #1906
+ if ($fp === false || !flock($fp, LOCK_SH)) {
+ return -1;
+ }
+
+ $chunk = fread($fp, 1024);
+ flock($fp, LOCK_UN);
+ fclose($fp);
+
+ $chunk = strtolower($chunk);
+
+ if (!$chunk) {
+ return false;
+ }
+
+ $chunk = trim($chunk);
+
+ if (preg_match("/ 0) {
- return $Config['QuickUploadAbsolutePath'][$resourceType];
- }
-
- // Map the "UserFiles" path to a local directory.
- return Server_MapPath($Config['QuickUploadPath'][$resourceType]);
- } else {
- if (strlen($Config['FileTypesAbsolutePath'][$resourceType]) > 0) {
- return $Config['FileTypesAbsolutePath'][$resourceType];
- }
-
- // Map the "UserFiles" path to a local directory.
- return Server_MapPath($Config['FileTypesPath'][$resourceType]);
- }
-}
-
-/**
- * GetUrlFromPath
- *
- * @param string $resourceType Resource type
- * @param string $folderPath Path
- * @param string $sCommand Command
- * @return string Full url
- */
-function GetUrlFromPath($resourceType, $folderPath, $sCommand)
-{
- return CombinePaths(GetResourceTypePath($resourceType, $sCommand), $folderPath);
-}
-
-/**
- * RemoveExtension
- *
- * @param string $fileName Filename
- * @return string String without extension
- */
-function RemoveExtension($fileName)
-{
- return substr($fileName, 0, strrpos($fileName, '.'));
-}
-/**
- * ServerMapFolder
- *
- * @param string $resourceType Resource type
- * @param string $folderPath Folder
- * @param string $sCommand Command
- * @return string
- */
-function ServerMapFolder($resourceType, $folderPath, $sCommand)
-{
- // Get the resource type directory.
- $sResourceTypePath = GetResourceTypeDirectory($resourceType, $sCommand);
-
- // Ensure that the directory exists.
- $sErrorMsg = CreateServerFolder($sResourceTypePath);
- if ($sErrorMsg != '') {
- SendError(1, "Error creating folder \"{$sResourceTypePath}\" ({$sErrorMsg})");
- }
-
- // Return the resource type directory combined with the required path.
- return CombinePaths($sResourceTypePath, $folderPath);
-}
-
-/**
- * GetParentFolder
- *
- * @param string $folderPath Folder path
- * @return string Parent folder
- */
-function GetParentFolder($folderPath)
-{
- $sPattern = "-[/\\\\][^/\\\\]+[/\\\\]?$-";
- return preg_replace($sPattern, '', $folderPath);
-}
-
-/**
- * CreateServerFolder
- *
- * @param string $folderPath Folder
- * @param string $lastFolder Folder
- * @return string ''=success, error message otherwise
- */
-function CreateServerFolder($folderPath, $lastFolder = null)
-{
- global $Config;
- $sParent = GetParentFolder($folderPath);
-
- // Ensure the folder path has no double-slashes, or mkdir may fail on certain platforms
- while (strpos($folderPath, '//') !== false) {
- $folderPath = str_replace('//', '/', $folderPath);
- }
-
- // Check if the parent exists, or create it.
- if (!empty($sParent) && !file_exists($sParent)) {
- //prevents agains infinite loop when we can't create root folder
- if (!is_null($lastFolder) && $lastFolder === $sParent) {
- return "Can't create $folderPath directory";
- }
-
- $sErrorMsg = CreateServerFolder($sParent, $folderPath);
- if ($sErrorMsg != '') {
- return $sErrorMsg;
- }
- }
-
- if (!file_exists($folderPath)) {
- // Turn off all error reporting.
- error_reporting(0);
-
- $php_errormsg = '';
- // Enable error tracking to catch the error.
- ini_set('track_errors', '1');
-
- if (isset($Config['ChmodOnFolderCreate']) && !$Config['ChmodOnFolderCreate']) {
- mkdir($folderPath);
- } else {
- $permissions = '0777';
- if (isset($Config['ChmodOnFolderCreate']) && $Config['ChmodOnFolderCreate']) {
- $permissions = (string) $Config['ChmodOnFolderCreate'];
- }
- $permissionsdec = octdec($permissions);
- $permissionsdec |= octdec('0111'); // Set x bit required for directories
- dol_syslog("io.php permission = ".$permissions." ".$permissionsdec." ".decoct($permissionsdec));
- // To create the folder with 0777 permissions, we need to set umask to zero.
- $oldumask = umask(0);
- mkdir($folderPath, $permissionsdec);
- umask($oldumask);
- }
-
- $sErrorMsg = $php_errormsg;
-
- // Restore the configurations.
- ini_restore('track_errors');
- ini_restore('error_reporting');
-
- return $sErrorMsg;
- } else {
- return '';
- }
-}
-
-/**
- * Get Root Path
- *
- * @return string real path
- */
-function GetRootPath()
-{
- if (!isset($_SERVER)) {
- global $_SERVER;
- }
- $sRealPath = realpath('./');
- // #2124 ensure that no slash is at the end
- $sRealPath = rtrim($sRealPath, "\\/");
-
- $sSelfPath = $_SERVER['PHP_SELF'];
- $sSelfPath = substr($sSelfPath, 0, strrpos($sSelfPath, '/'));
-
- $sSelfPath = str_replace('/', DIRECTORY_SEPARATOR, $sSelfPath);
-
- $position = strpos($sRealPath, $sSelfPath);
-
- // This can check only that this script isn't run from a virtual dir
- // But it avoids the problems that arise if it isn't checked
- if ($position === false || $position <> strlen($sRealPath) - strlen($sSelfPath)) {
- SendError(1, 'Sorry, can\'t map "UserFilesPath" to a physical path. You must set the "UserFilesAbsolutePath" value in "editor/filemanager/connectors/php/config.php".');
- }
-
- return substr($sRealPath, 0, $position);
-}
-
-/**
- * Emulate the asp Server.mapPath function.
- * @param string $path given an url path return the physical directory that it corresponds to
- * @return string Path
- */
-function Server_MapPath($path)
-{
- // This function is available only for Apache
- if (function_exists('apache_lookup_uri')) {
- $info = apache_lookup_uri($path);
- return $info->filename.$info->path_info;
- }
-
- // This isn't correct but for the moment there's no other solution
- // If this script is under a virtual directory or symlink it will detect the problem and stop
- return GetRootPath().$path;
-}
-
-/**
- * Is Allowed Extension
- *
- * @param string $sExtension File extension
- * @param string $resourceType ressource type
- * @return boolean true or false
- */
-function IsAllowedExt($sExtension, $resourceType)
-{
- global $Config;
- // Get the allowed and denied extensions arrays.
- $arAllowed = $Config['AllowedExtensions'][$resourceType];
- $arDenied = $Config['DeniedExtensions'][$resourceType];
-
- if (count($arAllowed) > 0 && !in_array($sExtension, $arAllowed)) {
- return false;
- }
-
- if (count($arDenied) > 0 && in_array($sExtension, $arDenied)) {
- return false;
- }
-
- return true;
-}
-
-/**
- * Is Allowed Type
- *
- * @param string $resourceType ressource type
- * @return boolean true or false
- */
-function IsAllowedType($resourceType)
-{
- global $Config;
- if (!in_array($resourceType, $Config['ConfigAllowedTypes'])) {
- return false;
- }
-
- return true;
-}
-
-/**
- * IsAllowedCommand
- *
- * @param string $sCommand Command
- * @return boolean True or false
- */
-function IsAllowedCommand($sCommand)
-{
- global $Config;
-
- if (!in_array($sCommand, $Config['ConfigAllowedCommands'])) {
- return false;
- }
-
- return true;
-}
-
-/**
- * GetCurrentFolder
- *
- * @return string current folder
- */
-function GetCurrentFolder()
-{
- if (!isset($_GET)) {
- global $_GET;
- }
- $sCurrentFolder = isset($_GET['CurrentFolder']) ? GETPOST('CurrentFolder', '', 1) : '/';
-
- // Check the current folder syntax (must begin and start with a slash).
- if (!preg_match('|/$|', $sCurrentFolder)) {
- $sCurrentFolder .= '/';
- }
- if (strpos($sCurrentFolder, '/') !== 0) {
- $sCurrentFolder = '/'.$sCurrentFolder;
- }
-
- // Ensure the folder path has no double-slashes
- while (strpos($sCurrentFolder, '//') !== false) {
- $sCurrentFolder = str_replace('//', '/', $sCurrentFolder);
- }
-
- // Check for invalid folder paths (..)
- if (strpos($sCurrentFolder, '..') || strpos($sCurrentFolder, "\\")) {
- SendError(102, '');
- }
-
- if (preg_match(",(/\.)|[[:cntrl:]]|(//)|(\\\\)|([\:\*\?\"\<\>\|]),", $sCurrentFolder)) {
- SendError(102, '');
- }
-
- return $sCurrentFolder;
-}
-
-/**
- * Do a cleanup of the folder name to avoid possible problems
- *
- * @param string $sNewFolderName Folder
- * @return string Folder sanitized
- */
-function SanitizeFolderName($sNewFolderName)
-{
- $sNewFolderName = stripslashes($sNewFolderName);
-
- // Remove . \ / | : ? * " < >
- $sNewFolderName = preg_replace('/\\.|\\\\|\\/|\\||\\:|\\?|\\*|"|<|>|[[:cntrl:]]/', '_', $sNewFolderName);
-
- return $sNewFolderName;
-}
-
-/**
- * Do a cleanup of the file name to avoid possible problems
- *
- * @param string $sNewFileName Folder
- * @return string Folder sanitized
- */
-function SanitizeFileName($sNewFileName)
-{
- global $Config;
-
- $sNewFileName = stripslashes($sNewFileName);
-
- // Replace dots in the name with underscores (only one dot can be there... security issue).
- if ($Config['ForceSingleExtension']) {
- $sNewFileName = preg_replace('/\\.(?![^.]*$)/', '_', $sNewFileName);
- }
-
- // Remove \ / | : ? * " < >
- $sNewFileName = preg_replace('/\\\\|\\/|\\||\\:|\\?|\\*|"|<|>|[[:cntrl:]]/', '_', $sNewFileName);
-
- return $sNewFileName;
-}
-
-/**
- * This is the function that sends the results of the uploading process.
- *
- * @param string $errorNumber errorNumber
- * @param string $fileUrl fileUrl
- * @param string $fileName fileName
- * @param string $customMsg customMsg
- * @return void
- */
-function SendUploadResults($errorNumber, $fileUrl = '', $fileName = '', $customMsg = '')
-{
- // Minified version of the document.domain automatic fix script (#1919).
- // The original script can be found at _dev/domain_fix_template.js
- echo <<
-(function(){var d=document.domain;while (true){try{var A=window.parent.document.domain;break;}catch(e) {};d=d.replace(/.*?(?:\.|$)/,'');if (d.length==0) break;try{document.domain=d;}catch (e){break;}}})();
-EOF;
-
- if ($errorNumber && $errorNumber != 201) {
- $fileUrl = "";
- $fileName = "";
- }
-
- $rpl = array('\\' => '\\\\', '"' => '\\"');
- echo 'console.log('.$errorNumber.');';
- echo 'window.parent.OnUploadCompleted('.$errorNumber.', "'.strtr($fileUrl, $rpl).'", "'.strtr($fileName, $rpl).'", "'.strtr($customMsg, $rpl).'");';
- echo '';
- exit;
-}
-
-
-// @CHANGE
-
-// This is the function that sends the results of the uploading process to CKE.
-/**
- * SendCKEditorResults
- *
- * @param string $callback callback
- * @param string $sFileUrl sFileUrl
- * @param string $customMsg customMsg
- * @return void
- */
-function SendCKEditorResults($callback, $sFileUrl, $customMsg = '')
-{
- echo '';
-}
diff --git a/htdocs/core/filemanagerdol/connectors/php/upload.php b/htdocs/core/filemanagerdol/connectors/php/upload.php
deleted file mode 100644
index b28627631f2..00000000000
--- a/htdocs/core/filemanagerdol/connectors/php/upload.php
+++ /dev/null
@@ -1,75 +0,0 @@
- $val) {
- $lcaseHtmlExtensions[$key] = strtolower($val);
- }
- return in_array($ext, $lcaseHtmlExtensions);
-}
-
-/**
- * Detect HTML in the first KB to prevent against potential security issue with
- * IE/Safari/Opera file type auto detection bug.
- * Returns true if file contain insecure HTML code at the beginning.
- *
- * @param string $filePath absolute path to file
- * @return boolean
- */
-function DetectHtml($filePath)
-{
- $fp = @fopen($filePath, 'rb');
-
- //open_basedir restriction, see #1906
- if ($fp === false || !flock($fp, LOCK_SH)) {
- return -1;
- }
-
- $chunk = fread($fp, 1024);
- flock($fp, LOCK_UN);
- fclose($fp);
-
- $chunk = strtolower($chunk);
-
- if (!$chunk) {
- return false;
- }
-
- $chunk = trim($chunk);
-
- if (preg_match("/fetch_object($resql);
if ($obj) {
- $value = $obj->value;
+ include_once DOL_DOCUMENT_ROOT.'/core/lib/security.lib.php';
+ $value = dolDecrypt($obj->value);
}
}
return $value;
@@ -651,11 +652,22 @@ function dolibarr_set_const($db, $name, $value, $type = 'chaine', $visible = 0,
$resql = $db->query($sql);
if (strcmp($value, '')) { // true if different. Must work for $value='0' or $value=0
- $sql = "INSERT INTO ".MAIN_DB_PREFIX."const(name,value,type,visible,note,entity)";
+ if (!preg_match('/^MAIN_LOGEVENTS/', $name) && (preg_match('/(_KEY|_EXPORTKEY|_SECUREKEY|_SERVERKEY|_PASS|_PASSWORD|_PW|_PW_TICKET|_PW_EMAILING|_SECRET|_SECURITY_TOKEN|_WEB_TOKEN)$/', $name))) {
+ // This seems a sensitive constant, we encrypt its value
+ // To list all sensitive constant, you can make a
+ // WHERE name like '%\_KEY' or name like '%\_EXPORTKEY' or name like '%\_SECUREKEY' or name like '%\_SERVERKEY' or name like '%\_PASS' or name like '%\_PASSWORD' or name like '%\_SECRET'
+ // or name like '%\_SECURITY_TOKEN' or name like '%\WEB_TOKEN'
+ include_once DOL_DOCUMENT_ROOT.'/core/lib/security.lib.php';
+ $newvalue = dolEncrypt($value);
+ } else {
+ $newvalue = $value;
+ }
+
+ $sql = "INSERT INTO ".MAIN_DB_PREFIX."const(name, value, type, visible, note, entity)";
$sql .= " VALUES (";
$sql .= $db->encrypt($name);
- $sql .= ", ".$db->encrypt($value);
- $sql .= ",'".$db->escape($type)."',".((int) $visible).",'".$db->escape($note)."',".((int) $entity).")";
+ $sql .= ", ".$db->encrypt($newvalue);
+ $sql .= ", '".$db->escape($type)."', ".((int) $visible).", '".$db->escape($note)."', ".((int) $entity).")";
//print "sql".$value."-".pg_escape_string($value)."-".$sql;exit;
//print "xx".$db->escape($value);
@@ -693,7 +705,7 @@ function modules_prepare_head($nbofactivatedmodules, $nboftotalmodules)
$h = 0;
$head = array();
- $mode = empty($conf->global->MAIN_MODULE_SETUP_ON_LIST_BY_DEFAULT) ? 'commonkanban' : 'common';
+ $mode = empty($conf->global->MAIN_MODULE_SETUP_ON_LIST_BY_DEFAULT) ? 'commonkanban' : $conf->global->MAIN_MODULE_SETUP_ON_LIST_BY_DEFAULT;
$head[$h][0] = DOL_URL_ROOT."/admin/modules.php?mode=".$mode;
if ($nbofactivatedmodules <= (empty($conf->global->MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING) ? 1 : $conf->global->MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING)) { // If only minimal initial modules enabled)
//$head[$h][1] = $form->textwithpicto($langs->trans("AvailableModules"), $desc);
@@ -1552,10 +1564,10 @@ function complete_elementList_with_modules(&$elementList)
// We discard modules according to features level (PS: if module is activated we always show it)
$const_name = 'MAIN_MODULE_'.strtoupper(preg_replace('/^mod/i', '', get_class($objMod)));
- if ($objMod->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2 && !$conf->global->$const_name) {
+ if ($objMod->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2 && getDolGlobalString($const_name)) {
$modulequalified = 0;
}
- if ($objMod->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1 && !$conf->global->$const_name) {
+ if ($objMod->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1 && getDolGlobalString($const_name)) {
$modulequalified = 0;
}
//If module is not activated disqualified
diff --git a/htdocs/core/lib/bank.lib.php b/htdocs/core/lib/bank.lib.php
index a19c6e44a92..5dde1bc4360 100644
--- a/htdocs/core/lib/bank.lib.php
+++ b/htdocs/core/lib/bank.lib.php
@@ -290,6 +290,24 @@ function checkIbanForAccount(Account $account)
}
}
+/**
+ * Returns the iban human readable
+ *
+ * @param Account $account Account object
+ * @return string
+ */
+function getIbanHumanReadable(Account $account)
+{
+ if ($account->getCountryCode() == 'FR') {
+ require_once DOL_DOCUMENT_ROOT.'/includes/php-iban/oophp-iban.php';
+ $ibantoprint = preg_replace('/[^a-zA-Z0-9]/', '', $account->iban);
+ $iban = new PHP_IBAN\IBAN($ibantoprint);
+ return $iban->HumanFormat();
+ }
+
+ return $account->iban;
+}
+
/**
* Check account number informations for a bank account
*
diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php
index 908dacb870c..6ba3ca18094 100644
--- a/htdocs/core/lib/company.lib.php
+++ b/htdocs/core/lib/company.lib.php
@@ -128,7 +128,7 @@ function societe_prepare_head(Societe $object)
}
}
$supplier_module_enabled = 0;
- if ((isModEnabled('fournisseur') && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_proposal->enabled) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) {
+ if ((isModEnabled('fournisseur') && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_proposal->enabled) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) {
$supplier_module_enabled = 1;
}
if ($supplier_module_enabled == 1 && $object->fournisseur && !empty($user->rights->fournisseur->lire)) {
@@ -179,7 +179,7 @@ function societe_prepare_head(Societe $object)
}
// Related items
- if ((isModEnabled('commande') || isModEnabled('propal') || isModEnabled('facture') || isModEnabled('ficheinter') || (isModEnabled('fournisseur') && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled))
+ if ((isModEnabled('commande') || isModEnabled('propal') || isModEnabled('facture') || isModEnabled('ficheinter') || (isModEnabled('fournisseur') && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice"))
&& empty($conf->global->THIRDPARTIES_DISABLE_RELATED_OBJECT_TAB)) {
$head[$h][0] = DOL_URL_ROOT.'/societe/consumption.php?socid='.$object->id;
$head[$h][1] = $langs->trans("Referers");
diff --git a/htdocs/core/lib/contact.lib.php b/htdocs/core/lib/contact.lib.php
index b63e7b025c7..ad9c47f4c48 100644
--- a/htdocs/core/lib/contact.lib.php
+++ b/htdocs/core/lib/contact.lib.php
@@ -92,7 +92,7 @@ function contact_prepare_head(Contact $object)
}
// Related items
- if (!empty($conf->commande->enabled) || !empty($conf->propal->enabled) || isModEnabled('facture') || !empty($conf->ficheinter->enabled) || (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) {
+ if (!empty($conf->commande->enabled) || isModEnabled("propal") || isModEnabled('facture') || !empty($conf->ficheinter->enabled) || (isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) {
$head[$tab][0] = DOL_URL_ROOT.'/contact/consumption.php?id='.$object->id;
$head[$tab][1] = $langs->trans("Referers");
$head[$tab][2] = 'consumption';
diff --git a/htdocs/core/lib/date.lib.php b/htdocs/core/lib/date.lib.php
index 558ba2aa322..f8d11b4bc82 100644
--- a/htdocs/core/lib/date.lib.php
+++ b/htdocs/core/lib/date.lib.php
@@ -207,7 +207,7 @@ function dol_time_plus_duree($time, $duration_value, $duration_unit, $ruleforend
*/
function convertTime2Seconds($iHours = 0, $iMinutes = 0, $iSeconds = 0)
{
- $iResult = ($iHours * 3600) + ($iMinutes * 60) + $iSeconds;
+ $iResult = ((int) $iHours * 3600) + ((int) $iMinutes * 60) + (int) $iSeconds;
return $iResult;
}
@@ -243,6 +243,7 @@ function convertSecondToTime($iSecond, $format = 'all', $lengthOfDay = 86400, $l
if (empty($lengthOfWeek)) {
$lengthOfWeek = 7; // 1 week = 7 days
}
+ $nbHbyDay = $lengthOfDay / 3600;
if ($format == 'all' || $format == 'allwithouthour' || $format == 'allhour' || $format == 'allhourmin' || $format == 'allhourminsec') {
if ((int) $iSecond === 0) {
@@ -290,11 +291,11 @@ function convertSecondToTime($iSecond, $format = 'all', $lengthOfDay = 86400, $l
$sTime .= dol_print_date($iSecond, 'hourduration', true);
}
} elseif ($format == 'allhourminsec') {
- return sprintf("%02d", ($sWeek * $lengthOfWeek * 24 + $sDay * 24 + (int) floor($iSecond / 3600))).':'.sprintf("%02d", ((int) floor(($iSecond % 3600) / 60))).':'.sprintf("%02d", ((int) ($iSecond % 60)));
+ return sprintf("%02d", ($sWeek * $lengthOfWeek * $nbHbyDay + $sDay * $nbHbyDay + (int) floor($iSecond/3600))).':'.sprintf("%02d", ((int) floor(($iSecond % 3600) / 60))).':'.sprintf("%02d", ((int) ($iSecond % 60)));
} elseif ($format == 'allhourmin') {
- return sprintf("%02d", ($sWeek * $lengthOfWeek * 24 + $sDay * 24 + (int) floor($iSecond / 3600))).':'.sprintf("%02d", ((int) floor(($iSecond % 3600) / 60)));
+ return sprintf("%02d", ($sWeek * $lengthOfWeek * $nbHbyDay + $sDay * $nbHbyDay + (int) floor($iSecond/3600))).':'.sprintf("%02d", ((int) floor(($iSecond % 3600)/60)));
} elseif ($format == 'allhour') {
- return sprintf("%02d", ($sWeek * $lengthOfWeek * 24 + $sDay * 24 + (int) floor($iSecond / 3600)));
+ return sprintf("%02d", ($sWeek * $lengthOfWeek * $nbHbyDay + $sDay * $nbHbyDay + (int) floor($iSecond/3600)));
}
} elseif ($format == 'hour') { // only hour part
$sTime = dol_print_date($iSecond, '%H', true);
@@ -899,6 +900,15 @@ function num_public_holiday($timestampStart, $timestampEnd, $country_code = '',
}
// Fronleichnam
}
+
+ if (in_array('genevafast', $specialdayrule)) {
+ // Geneva fast in Switzerland (Thursday after the first sunday in September)
+ $date_1sunsept = strtotime('next thursday', strtotime('next sunday', mktime(0, 0, 0, 9, 1, $annee)));
+ $jour_1sunsept = date("d", $date_1sunsept);
+ $mois_1sunsept = date("m", $date_1sunsept);
+ if ($jour_1sunsept == $jour && $mois_1sunsept == $mois) $ferie=true;
+ // Geneva fast in Switzerland
+ }
}
//print "ferie=".$ferie."\n";
diff --git a/htdocs/core/lib/expedition.lib.php b/htdocs/core/lib/expedition.lib.php
index 99118197174..b9eb90d7f9f 100644
--- a/htdocs/core/lib/expedition.lib.php
+++ b/htdocs/core/lib/expedition.lib.php
@@ -35,7 +35,7 @@
function expedition_prepare_head(Expedition $object)
{
global $langs, $conf, $user;
- if (!empty($conf->expedition->enabled)) {
+ if (isModEnabled("expedition")) {
$langs->load("sendings");
}
$langs->load("orders");
diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php
index cd4ff50044e..147938fb53a 100644
--- a/htdocs/core/lib/files.lib.php
+++ b/htdocs/core/lib/files.lib.php
@@ -318,7 +318,7 @@ function completeFileArrayWithDatabaseInfo(&$filearray, $relativedir)
if ($modulepart == 'produit' && !empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) {
global $object;
if (!empty($object->id)) {
- if (!empty($conf->product->enabled)) {
+ if (isModEnabled("product")) {
$upload_dirold = $conf->product->multidir_output[$object->entity].'/'.substr(substr("000".$object->id, -2), 1, 1).'/'.substr(substr("000".$object->id, -2), 0, 1).'/'.$object->id."/photos";
} else {
$upload_dirold = $conf->service->multidir_output[$object->entity].'/'.substr(substr("000".$object->id, -2), 1, 1).'/'.substr(substr("000".$object->id, -2), 0, 1).'/'.$object->id."/photos";
@@ -2421,7 +2421,7 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity,
return 'ErrorBadParameter';
}
if (empty($entity)) {
- if (empty($conf->multicompany->enabled)) {
+ if (!isModEnabled('multicompany')) {
$entity = 1;
} else {
$entity = 0;
@@ -2921,9 +2921,9 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity,
if (($fuser->rights->produit->{$lire} || $fuser->rights->service->{$lire}) || preg_match('/^specimen/i', $original_file)) {
$accessallowed = 1;
}
- if (!empty($conf->product->enabled)) {
+ if (isModEnabled("product")) {
$original_file = $conf->product->multidir_output[$entity].'/'.$original_file;
- } elseif (!empty($conf->service->enabled)) {
+ } elseif (isModEnabled("service")) {
$original_file = $conf->service->multidir_output[$entity].'/'.$original_file;
}
} elseif ($modulepart == 'product_batch' || $modulepart == 'produitlot') {
diff --git a/htdocs/core/lib/ftp.lib.php b/htdocs/core/lib/ftp.lib.php
index 3d680de08a0..118c85e9b74 100644
--- a/htdocs/core/lib/ftp.lib.php
+++ b/htdocs/core/lib/ftp.lib.php
@@ -276,3 +276,32 @@ function dol_ftp_rmdir($connect_id, $file, $newsection)
return @ftp_rmdir($connect_id, $newremotefileiso);
}
}
+
+
+/**
+ * Remove FTP directory
+ *
+ * @param resource $connect_id Connection handler
+ * @param string $newdir Dir create
+ * @param string $newsection $newsection
+ * @return result
+ */
+function dol_ftp_mkdir($connect_id, $newdir, $newsection)
+{
+
+ global $conf;
+
+ if (!empty($conf->global->FTP_CONNECT_WITH_SFTP)) {
+ $newsection = ssh2_sftp_realpath($connect_id, ".").'/./'; // workaround for bug https://bugs.php.net/bug.php?id=64169
+ }
+
+ // Remote file
+ $newremotefileiso = $newsection.(preg_match('@[\\\/]$@', $newsection) ? '' : '/').$newdir;
+ $newremotefileiso = utf8_decode($newremotefileiso);
+
+ if (!empty($conf->global->FTP_CONNECT_WITH_SFTP)) {
+ return ssh2_sftp_mkdir($connect_id, $newremotefileiso, 0777);
+ } else {
+ return @ftp_mkdir($connect_id, $newremotefileiso);
+ }
+}
diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php
index 90698c95f80..3174fb132cd 100644
--- a/htdocs/core/lib/functions.lib.php
+++ b/htdocs/core/lib/functions.lib.php
@@ -432,8 +432,8 @@ function GETPOSTISSET($paramname)
* Can be used before GETPOST to know if the $check param of GETPOST need to check an array or a string
*
* @param string $paramname Name or parameter to test
- * @param int $method Type of method (0 = get then post, 1 = only get, 2 = only post, 3 = post then get)
- * @return bool True if we have just submit a POST or GET request with the parameter provided (even if param is empty)
+ * @param int $method Type of method (0 = get then post, 1 = only get, 2 = only post, 3 = post then get)
+ * @return bool True if we have just submit a POST or GET request with the parameter provided (even if param is empty)
*/
function GETPOSTISARRAY($paramname, $method = 0)
{
@@ -954,12 +954,15 @@ function sanitizeVal($out = '', $check = 'alphanohtml', $filter = null, $options
// Restore entity ' into ' (restricthtml is for html content so we can use html entity)
$out = preg_replace('/'/i', "'", $out);
-
- preg_match_all('/( getDolGlobalInt("MAIN_SECURITY_MAX_IMG_IN_HTML_CONTENT", 1000)) {
- $out = '';
- }
} while ($oldstringtoclean != $out);
+
+ // Check the limit of external links in a Rich text content. We count ' getDolGlobalInt("MAIN_SECURITY_MAX_IMG_IN_HTML_CONTENT", 1000)) {
+ return 'TooManyLinksIntoHTMLString';
+ }
+
break;
case 'custom':
if (empty($filter)) {
@@ -1690,7 +1693,7 @@ function dol_syslog($message, $level = LOG_INFO, $ident = 0, $suffixinfilename =
* @param string $name A name for the html component
* @param string $label Label shown in Popup title top bar
* @param string $buttonstring button string
- * @param string $url Url to open
+ * @param string $url Relative Url to open
* @param string $disabled Disabled text
* @param string $morecss More CSS
* @param string $backtopagejsfields The back to page must be managed using javascript instead of a redirect.
@@ -1699,6 +1702,8 @@ function dol_syslog($message, $level = LOG_INFO, $ident = 0, $suffixinfilename =
*/
function dolButtonToOpenUrlInDialogPopup($name, $label, $buttonstring, $url, $disabled = '', $morecss = 'button bordertransp', $backtopagejsfields = '')
{
+ global $conf;
+
if (strpos($url, '?') > 0) {
$url .= '&dol_hide_topmenu=1&dol_hide_leftmenu=1&dol_openinpopup='.urlencode($name);
} else {
@@ -1722,44 +1727,50 @@ function dolButtonToOpenUrlInDialogPopup($name, $label, $buttonstring, $url, $di
}
//print ' ';
- $out .= ''."\n";
- $out .= ''.$buttonstring.' ';
- $out .= 'div for dialog
';
- $out .= 'div for returned id
';
- $out .= 'div for returned label
';
- $out .= '';
- $out .= '';
+ ';
+ }
return $out;
}
@@ -3196,6 +3207,8 @@ function dol_print_phone($phone, $countrycode = '', $cid = 0, $socid = 0, $addli
$newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 2).$separ.substr($newphone, 5, 2).$separ.substr($newphone, 7, 2).$separ.substr($newphone, 9, 2);
} elseif (dol_strlen($phone) == 12) {
$newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 1).$separ.substr($newphone, 4, 2).$separ.substr($newphone, 6, 2).$separ.substr($newphone, 8, 2).$separ.substr($newphone, 10, 2);
+ } elseif (dol_strlen($phone) == 13) {
+ $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 2).$separ.substr($newphone, 6, 2).$separ.substr($newphone, 8, 3).$separ.substr($newphone, 11, 2);
}
} elseif (strtoupper($countrycode) == "CA") {
if (dol_strlen($phone) == 10) {
@@ -3307,8 +3320,8 @@ function dol_print_phone($phone, $countrycode = '', $cid = 0, $socid = 0, $addli
$newphone = substr($newphone, 0, 5).$separ.substr($newphone, 5, 3).$separ.substr($newphone, 8, 4);
}
} elseif (strtoupper($countrycode) == "MG") {//Madagascar
- if (dol_strlen($phone) == 13) {//ex: +261_AB_CD_EF_GHI
- $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 2).$separ.substr($newphone, 6, 2).$separ.substr($newphone, 8, 2).$separ.substr($newphone, 10, 3);
+ if (dol_strlen($phone) == 13) {//ex: +261_AB_CD_EFG_HI
+ $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 2).$separ.substr($newphone, 6, 2).$separ.substr($newphone, 8, 3).$separ.substr($newphone, 11, 2);
}
} elseif (strtoupper($countrycode) == "GB") {//Royaume uni
if (dol_strlen($phone) == 13) {//ex: +44_ABCD_EFG_HIJ
@@ -6821,10 +6834,11 @@ function dol_string_onlythesehtmlattributes($stringtoclean, $allowed_attributes
for ($attrs = $els->item($i)->attributes, $ii = $attrs->length - 1; $ii >= 0; $ii--) {
//var_dump($attrs->item($ii));
if (! empty($attrs->item($ii)->name)) {
- // Delete attribute if not into allowed_attributes
if (! in_array($attrs->item($ii)->name, $allowed_attributes)) {
+ // Delete attribute if not into allowed_attributes
$els->item($i)->removeAttribute($attrs->item($ii)->name);
} elseif (in_array($attrs->item($ii)->name, array('style'))) {
+ // If attribute is 'style'
$valuetoclean = $attrs->item($ii)->value;
if (isset($valuetoclean)) {
@@ -6833,10 +6847,14 @@ function dol_string_onlythesehtmlattributes($stringtoclean, $allowed_attributes
$valuetoclean = preg_replace('/\/\*.*\*\//m', '', $valuetoclean); // clean css comments
$valuetoclean = preg_replace('/position\s*:\s*[a-z]+/mi', '', $valuetoclean);
if ($els->item($i)->tagName == 'a') { // more paranoiac cleaning for clickable tags.
- $valuetoclean = preg_replace('/display\s*://m', '', $valuetoclean);
- $valuetoclean = preg_replace('/z-index\s*://m', '', $valuetoclean);
- $valuetoclean = preg_replace('/\s+(top|left|right|bottom)\s*://m', '', $valuetoclean);
+ $valuetoclean = preg_replace('/display\s*:/mi', '', $valuetoclean);
+ $valuetoclean = preg_replace('/z-index\s*:/mi', '', $valuetoclean);
+ $valuetoclean = preg_replace('/\s+(top|left|right|bottom)\s*:/mi', '', $valuetoclean);
}
+
+ // We do not allow logout|passwordforgotten.php and action= into the content of a "style" tag
+ $valuetoclean = preg_replace('/(logout|passwordforgotten)\.php/mi', '', $valuetoclean);
+ $valuetoclean = preg_replace('/action=/mi', '', $valuetoclean);
} while ($oldvaluetoclean != $valuetoclean);
}
@@ -7331,7 +7349,7 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null,
$substitutionarray['__NOTE_PRIVATE__'] = '__NOTE_PRIVATE__';
$substitutionarray['__EXTRAFIELD_XXX__'] = '__EXTRAFIELD_XXX__';
- if (!empty($conf->societe->enabled)) { // Most objects are concerned
+ if (isModEnabled("societe")) { // Most objects are concerned
$substitutionarray['__THIRDPARTY_ID__'] = '__THIRDPARTY_ID__';
$substitutionarray['__THIRDPARTY_NAME__'] = '__THIRDPARTY_NAME__';
$substitutionarray['__THIRDPARTY_NAME_ALIAS__'] = '__THIRDPARTY_NAME_ALIAS__';
@@ -7393,7 +7411,7 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null,
$substitutionarray['__CONTRACT_LOWEST_EXPIRATION_DATE__'] = 'Lowest data for planned expiration of service';
$substitutionarray['__CONTRACT_LOWEST_EXPIRATION_DATETIME__'] = 'Lowest date and hour for planned expiration of service';
}
- if (!empty($conf->propal->enabled) && (!is_object($object) || $object->element == 'propal')) {
+ if (isModEnabled("propal") && (!is_object($object) || $object->element == 'propal')) {
$substitutionarray['__ONLINE_SIGN_URL__'] = 'ToOfferALinkForOnlineSignature';
}
$substitutionarray['__ONLINE_PAYMENT_URL__'] = 'UrlToPayOnlineIfApplicable';
@@ -7410,11 +7428,11 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null,
$substitutionarray['__DIRECTDOWNLOAD_URL_CONTRACT__'] = 'Direct download url of a contract';
$substitutionarray['__DIRECTDOWNLOAD_URL_SUPPLIER_PROPOSAL__'] = 'Direct download url of a supplier proposal';
- if (!empty($conf->expedition->enabled) && (!is_object($object) || $object->element == 'shipping')) {
+ if (isModEnabled("expedition") && (!is_object($object) || $object->element == 'shipping')) {
$substitutionarray['__SHIPPINGTRACKNUM__'] = 'Shipping tracking number';
$substitutionarray['__SHIPPINGTRACKNUMURL__'] = 'Shipping tracking url';
}
- if (!empty($conf->reception->enabled) && (!is_object($object) || $object->element == 'reception')) {
+ if (isModEnabled("reception") && (!is_object($object) || $object->element == 'reception')) {
$substitutionarray['__RECEPTIONTRACKNUM__'] = 'Shippin tracking number of shipment';
$substitutionarray['__RECEPTIONTRACKNUMURL__'] = 'Shipping tracking url';
}
@@ -7794,7 +7812,7 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null,
));
}
- if (!empty($conf->multicompany->enabled)) {
+ if (isModEnabled('multicompany')) {
$substitutionarray = array_merge($substitutionarray, array('__ENTITY_ID__' => $conf->entity));
}
if (empty($exclude) || !in_array('system', $exclude)) {
@@ -9364,16 +9382,16 @@ function dol_set_focus($selector)
/**
* Return getmypid() or random PID when function is disabled
* Some web hosts disable this php function for security reasons
- * and sometimes we can't redeclare function
+ * and sometimes we can't redeclare function.
*
* @return int
*/
function dol_getmypid()
{
if (!function_exists('getmypid')) {
- return mt_rand(1, 32768);
+ return mt_rand(99900000, 99965535);
} else {
- return getmypid();
+ return getmypid(); // May be a number on 64 bits (depending on OS)
}
}
diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php
index ac051fd92e0..cad97108733 100644
--- a/htdocs/core/lib/functions2.lib.php
+++ b/htdocs/core/lib/functions2.lib.php
@@ -416,7 +416,7 @@ function dol_print_object_info($object, $usetable = 0)
} else {
print ': ';
}
- if (is_object($object->user_approve)) {
+ if (!empty($object->user_approve) && is_object($object->user_approve)) {
if ($object->user_approve->id) {
print $object->user_approve->getNomUrl(-1, '', 0, 0, 0);
} else {
diff --git a/htdocs/core/lib/images.lib.php b/htdocs/core/lib/images.lib.php
index b8202b8e361..37cc70760eb 100644
--- a/htdocs/core/lib/images.lib.php
+++ b/htdocs/core/lib/images.lib.php
@@ -233,19 +233,20 @@ function dol_imageResizeOrCrop($file, $mode, $newWidth, $newHeight, $src_x = 0,
if ($filetowrite) {
$imgfonction = '';
switch ($newExt) {
- case 'gif': // IMG_GIF
+ case 'gif': // IMG_GIF
$imgfonction = 'imagecreatefromgif';
break;
- case 'jpg': // IMG_JPG
+ case 'jpg': // IMG_JPG
+ case 'jpeg': // IMG_JPEG
$imgfonction = 'imagecreatefromjpeg';
break;
- case 'png': // IMG_PNG
+ case 'png': // IMG_PNG
$imgfonction = 'imagecreatefrompng';
break;
- case 'bmp': // IMG_WBMP
+ case 'bmp': // IMG_WBMP
$imgfonction = 'imagecreatefromwbmp';
break;
- case 'webp': // IMG_WEBP
+ case 'webp': // IMG_WEBP
$imgfonction = 'imagecreatefromwebp';
break;
}
@@ -300,12 +301,14 @@ function dol_imageResizeOrCrop($file, $mode, $newWidth, $newHeight, $src_x = 0,
}
// Set transparent color according to image extension
+ $trans_colour = -1; // By default, undefined
switch ($newExt) {
case 'gif': // Gif
$trans_colour = imagecolorallocate($imgTarget, 255, 255, 255); // On procede autrement pour le format GIF
imagecolortransparent($imgTarget, $trans_colour);
break;
case 'jpg': // Jpg
+ case 'jpeg': // Jpeg
$trans_colour = imagecolorallocatealpha($imgTarget, 255, 255, 255, 0);
break;
case 'png': // Png
@@ -319,11 +322,11 @@ function dol_imageResizeOrCrop($file, $mode, $newWidth, $newHeight, $src_x = 0,
$trans_colour = imagecolorallocatealpha($imgTarget, 255, 255, 255, 127);
break;
}
- if (function_exists("imagefill")) {
+ if (function_exists("imagefill") && $trans_colour > 0) {
imagefill($imgTarget, 0, 0, $trans_colour);
}
- dol_syslog("dol_imageResizeOrCrop: convert image from ($imgWidth x $imgHeight) at position ($src_x x $src_y) to ($newWidth x $newHeight) as $extImg");
+ dol_syslog("dol_imageResizeOrCrop: convert image from ($imgWidth x $imgHeight) at position ($src_x x $src_y) to ($newWidth x $newHeight) as a $extImg");
//imagecopyresized($imgTarget, $img, 0, 0, 0, 0, $thumbWidth, $thumbHeight, $imgWidth, $imgHeight); // Insere l'image de base redimensionnee
imagecopyresampled($imgTarget, $img, 0, 0, $src_x, $src_y, $newWidth, $newHeight, ($mode == 0 ? $imgWidth : $newWidth), ($mode == 0 ? $imgHeight : $newHeight)); // Insere l'image de base redimensionnee
@@ -338,6 +341,7 @@ function dol_imageResizeOrCrop($file, $mode, $newWidth, $newHeight, $src_x = 0,
imagegif($imgTarget, $imgTargetName);
break;
case 'jpg': // Jpg
+ case 'jpeg': // Jpeg
$newquality = ($newquality ? $newquality : '100'); // % quality maximum
imagejpeg($imgTarget, $imgTargetName, $newquality);
break;
@@ -353,6 +357,8 @@ function dol_imageResizeOrCrop($file, $mode, $newWidth, $newHeight, $src_x = 0,
$newquality = ($newquality ? $newquality : '100'); // % quality maximum
imagewebp($imgTarget, $imgTargetName, $newquality);
break;
+ default:
+ dol_syslog("images.lib.php::imageResizeOrCrop() Format ".$newExt." is not supported", LOG_WARNING);
}
// Set permissions on file
diff --git a/htdocs/core/lib/invoice.lib.php b/htdocs/core/lib/invoice.lib.php
index 52daea0f150..9e60f20fd25 100644
--- a/htdocs/core/lib/invoice.lib.php
+++ b/htdocs/core/lib/invoice.lib.php
@@ -1072,7 +1072,7 @@ function getPurchaseInvoiceUnpaidOpenTable($maxCount = 500, $socid = 0)
$result = '';
- if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->rights->fournisseur->facture->lire) || (!empty($conf->supplier_invoice->enabled) && $user->rights->supplier_invoice->lire)) {
+ if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->rights->fournisseur->facture->lire) || (isModEnabled("supplier_invoice") && $user->rights->supplier_invoice->lire)) {
$facstatic = new FactureFournisseur($db);
$sql = "SELECT ff.rowid, ff.ref, ff.fk_statut as status, ff.type, ff.libelle as label, ff.total_ht, ff.total_tva, ff.total_ttc, ff.paye";
diff --git a/htdocs/core/lib/ldap.lib.php b/htdocs/core/lib/ldap.lib.php
index 56a8bcc4285..7e173bd269e 100644
--- a/htdocs/core/lib/ldap.lib.php
+++ b/htdocs/core/lib/ldap.lib.php
@@ -57,7 +57,7 @@ function ldap_prepare_head()
$h++;
}
- if (!empty($conf->societe->enabled) && !empty($conf->global->LDAP_CONTACT_ACTIVE)) {
+ if (isModEnabled("societe") && !empty($conf->global->LDAP_CONTACT_ACTIVE)) {
$head[$h][0] = DOL_URL_ROOT."/admin/ldap_contacts.php";
$head[$h][1] = $langs->trans("LDAPContactsSynchro");
$head[$h][2] = 'contacts';
diff --git a/htdocs/core/lib/oauth.lib.php b/htdocs/core/lib/oauth.lib.php
index f99266db178..bacd8135739 100644
--- a/htdocs/core/lib/oauth.lib.php
+++ b/htdocs/core/lib/oauth.lib.php
@@ -23,16 +23,30 @@
*/
+$shortscopegoogle = 'userinfo_email,userinfo_profile';
+$shortscopegoogle .= ',openid,email,profile'; // For openid connect
+if (!empty($conf->printing->enabled)) {
+ $shortscopegoogle .= ',cloud_print';
+}
+if (!empty($conf->global->OAUTH_GOOGLE_GSUITE)) {
+ $shortscopegoogle .= ',admin_directory_user';
+}
+if (!empty($conf->global->OAUTH_GOOGLE_GMAIL)) {
+ $shortscopegoogle.=',gmail_full';
+}
+
// Supported OAUTH (a provider is supported when a file xxx_oauthcallback.php is available into htdocs/core/modules/oauth)
$supportedoauth2array = array(
- 'OAUTH_GOOGLE_NAME'=>array('callbackfile' => 'google', 'picto' => 'google', 'urlforapp' => 'OAUTH_GOOGLE_DESC', 'name'=>'Google', 'urlforcredentials'=>'https://console.developers.google.com/'),
+ 'OAUTH_GOOGLE_NAME'=>array('callbackfile' => 'google', 'picto' => 'google', 'urlforapp' => 'OAUTH_GOOGLE_DESC', 'name'=>'Google', 'urlforcredentials'=>'https://console.developers.google.com/', 'defaultscope'=>$shortscopegoogle),
);
if (!empty($conf->stripe->enabled)) {
- $supportedoauth2array['OAUTH_STRIPE_TEST_NAME'] = array('callbackfile' => 'stripetest', 'picto' => 'stripe', 'urlforapp' => '', 'name'=>'StripeTest', 'urlforcredentials'=>'');
- $supportedoauth2array['OAUTH_STRIPE_LIVE_NAME'] = array('callbackfile' => 'stripelive', 'picto' => 'stripe', 'urlforapp' => '', 'name'=>'StripeLive', 'urlforcredentials'=>'');
+ $supportedoauth2array['OAUTH_STRIPE_TEST_NAME'] = array('callbackfile' => 'stripetest', 'picto' => 'stripe', 'urlforapp' => '', 'name'=>'StripeTest', 'urlforcredentials'=>'', 'defaultscope'=>'read_write');
+ $supportedoauth2array['OAUTH_STRIPE_LIVE_NAME'] = array('callbackfile' => 'stripelive', 'picto' => 'stripe', 'urlforapp' => '', 'name'=>'StripeLive', 'urlforcredentials'=>'', 'defaultscope'=>'read_write');
+}
+$supportedoauth2array['OAUTH_GITHUB_NAME'] = array('callbackfile' => 'github', 'picto' => 'github', 'urlforapp' => 'OAUTH_GITHUB_DESC', 'name'=>'GitHub', 'urlforcredentials'=>'https://github.com/settings/developers', 'defaultscope'=>'user,public_repo');
+if (getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 2) {
+ $supportedoauth2array['OAUTH_OTHER_NAME'] = array('callbackfile' => 'generic', 'picto' => 'generic', 'urlforapp' => 'OAUTH_OTHER_DESC', 'name'=>'Other', 'urlforcredentials'=>'', 'defaultscope'=>'ToComplete');
}
-$supportedoauth2array['OAUTH_GITHUB_NAME'] = array('callbackfile' => 'github', 'picto' => 'github', 'urlforapp' => 'OAUTH_GITHUB_DESC', 'name'=>'GitHub', 'urlforcredentials'=>'https://github.com/settings/developers');
-
// API access parameters OAUTH
@@ -259,6 +273,11 @@ $list = array(
'OAUTH_YAMMER_ID',
'OAUTH_YAMMER_SECRET',
),
+ array(
+ 'OAUTH_OTHER_NAME',
+ 'OAUTH_OTHER_ID',
+ 'OAUTH_OTHER_SECRET',
+ ),
);
diff --git a/htdocs/core/lib/order.lib.php b/htdocs/core/lib/order.lib.php
index bde894940de..9a5e9ae56a5 100644
--- a/htdocs/core/lib/order.lib.php
+++ b/htdocs/core/lib/order.lib.php
@@ -34,7 +34,7 @@
function commande_prepare_head(Commande $object)
{
global $db, $langs, $conf, $user;
- if (!empty($conf->expedition->enabled)) {
+ if (isModEnabled("expedition")) {
$langs->load("sendings");
}
$langs->load("orders");
diff --git a/htdocs/core/lib/payments.lib.php b/htdocs/core/lib/payments.lib.php
index 809b5f8dc73..5c9d9342b01 100644
--- a/htdocs/core/lib/payments.lib.php
+++ b/htdocs/core/lib/payments.lib.php
@@ -393,7 +393,7 @@ function getOnlinePaymentUrl($mode, $type, $ref = '', $amount = '9.99', $freetag
}
// For multicompany
- if (!empty($out) && !empty($conf->multicompany->enabled)) {
+ if (!empty($out) && isModEnabled('multicompany')) {
$out .= "&entity=".$conf->entity; // Check the entity because we may have the same reference in several entities
}
diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php
index be89f4700b8..ca9bfcfe0e4 100644
--- a/htdocs/core/lib/pdf.lib.php
+++ b/htdocs/core/lib/pdf.lib.php
@@ -61,7 +61,7 @@ function pdf_admin_prepare_head()
// $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
complete_head_from_modules($conf, $langs, null, $head, $h, 'pdf_admin');
- if (!empty($conf->propal->enabled)) {
+ if (isModEnabled("propal")) {
$head[$h][0] = DOL_URL_ROOT.'/admin/pdf_other.php';
$head[$h][1] = $langs->trans("Other");
$head[$h][2] = 'other';
@@ -1181,6 +1181,7 @@ function pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_
$pdf->SetAutoPageBreak(1, 0); // Restore pagebreak
}
+ if (getDolGlobalInt('PDF_FREETEXT_DISABLE_PAGEBREAK') === 1) { $pdf->SetAutoPageBreak(0, 0); } // Option for disable auto pagebreak
if ($line) { // Free text
$pdf->SetXY($dims['lm'], -$posy);
if (!getDolGlobalString('PDF_ALLOW_HTML_FOR_FREE_TEXT')) { // by default
@@ -1190,6 +1191,7 @@ function pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_
}
$posy -= $freetextheight;
}
+ if (getDolGlobalInt('PDF_FREETEXT_DISABLE_PAGEBREAK') === 1) { $pdf->SetAutoPageBreak(1, 0); } // Restore pagebreak
$pdf->SetY(-$posy);
@@ -1199,16 +1201,15 @@ function pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_
}
// Option for set top margin height of footer after freetext
- if (getDolGlobalString('PDF_FOOTER_TOP_MARGIN') || getDolGlobalString('PDF_FOOTER_TOP_MARGIN') === '0') {
- // TODO Remove this case. Height should be good automatically, only $posy-- should be required.
- $posy -= getDolGlobalInt('PDF_FOOTER_TOP_MARGIN');
+ if (getDolGlobalString('PDF_FOOTER_TOP_MARGIN') || getDolGlobalInt('PDF_FOOTER_TOP_MARGIN') === 0) {
+ $posy -= floatval(getDolGlobalString('PDF_FOOTER_TOP_MARGIN'));
} else {
$posy--;
}
- if (getDolGlobalString('PDF_FOOTER_DISABLE_PAGEBREAK') === '1') { $pdf->SetAutoPageBreak(0, 0); } // Option for disable auto pagebreak
+ if (getDolGlobalInt('PDF_FOOTER_DISABLE_PAGEBREAK') === 1) { $pdf->SetAutoPageBreak(0, 0); } // Option for disable auto pagebreak
$pdf->writeHTMLCell($pdf->page_largeur - $pdf->margin_left - $pdf->margin_right, $mycustomfooterheight, $dims['lm'], $dims['hk'] - $posy, dol_htmlentitiesbr($mycustomfooter, 1, 'UTF-8', 0));
- if (getDolGlobalString('PDF_FOOTER_DISABLE_PAGEBREAK') === '1') { $pdf->SetAutoPageBreak(1, 0); } // Restore pagebreak
+ if (getDolGlobalInt('PDF_FOOTER_DISABLE_PAGEBREAK') === 1) { $pdf->SetAutoPageBreak(1, 0); } // Restore pagebreak
$posy -= $mycustomfooterheight - 3;
} else {
@@ -1224,6 +1225,7 @@ function pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_
$pdf->SetAutoPageBreak(1, 0); // Restore pagebreak
}
+ if (getDolGlobalInt('PDF_FREETEXT_DISABLE_PAGEBREAK') === 1) { $pdf->SetAutoPageBreak(0, 0); } // Option for disable auto pagebreak
if ($line) { // Free text
$pdf->SetXY($dims['lm'], -$posy);
if (!getDolGlobalString('PDF_ALLOW_HTML_FOR_FREE_TEXT')) { // by default
@@ -1233,6 +1235,7 @@ function pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_
}
$posy -= $freetextheight;
}
+ if (getDolGlobalInt('PDF_FREETEXT_DISABLE_PAGEBREAK') === 1) { $pdf->SetAutoPageBreak(1, 0); } // Restore pagebreak
$pdf->SetY(-$posy);
@@ -1242,9 +1245,8 @@ function pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_
}
// Option for set top margin height of footer after freetext
- if (getDolGlobalString('PDF_FOOTER_TOP_MARGIN') || getDolGlobalString('PDF_FOOTER_TOP_MARGIN') === '0') {
- // TODO Remove this case. Height should be good automatically, only $posy-- should be required.
- $posy -= getDolGlobalString('PDF_FOOTER_TOP_MARGIN');
+ if (getDolGlobalString('PDF_FOOTER_TOP_MARGIN') || getDolGlobalInt('PDF_FOOTER_TOP_MARGIN') === 0) {
+ $posy -= floatval(getDolGlobalString('PDF_FOOTER_TOP_MARGIN'));
} else {
$posy--;
}
diff --git a/htdocs/core/lib/product.lib.php b/htdocs/core/lib/product.lib.php
index 7b3d1e4637f..17235576394 100644
--- a/htdocs/core/lib/product.lib.php
+++ b/htdocs/core/lib/product.lib.php
@@ -38,8 +38,11 @@ function product_prepare_head($object)
$langs->load("products");
$label = $langs->trans('Product');
+ $usercancreadprice = getDolGlobalString('MAIN_USE_ADVANCED_PERMS')?$user->hasRight('product', 'product_advance', 'read_prices'):$user->hasRight('product', 'lire');
+
if ($object->isService()) {
$label = $langs->trans('Service');
+ $usercancreadprice = getDolGlobalString('MAIN_USE_ADVANCED_PERMS')?$user->hasRight('service', 'service_advance', 'read_prices'):$user->hasRight('service', 'lire');
}
$h = 0;
@@ -50,7 +53,7 @@ function product_prepare_head($object)
$head[$h][2] = 'card';
$h++;
- if (!empty($object->status)) {
+ if (!empty($object->status) && $usercancreadprice) {
$head[$h][0] = DOL_URL_ROOT."/product/price.php?id=".$object->id;
$head[$h][1] = $langs->trans("SellingPrices");
$head[$h][2] = 'price';
@@ -58,13 +61,15 @@ function product_prepare_head($object)
}
if (!empty($object->status_buy) || (!empty($conf->margin->enabled) && !empty($object->status))) { // If margin is on and product on sell, we may need the cost price even if product os not on purchase
- if ((((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) && $user->rights->fournisseur->lire)
+ if ((((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) && $user->rights->fournisseur->lire)
|| (!empty($conf->margin->enabled) && $user->rights->margin->liretous)
) {
- $head[$h][0] = DOL_URL_ROOT."/product/fournisseurs.php?id=".$object->id;
- $head[$h][1] = $langs->trans("BuyingPrices");
- $head[$h][2] = 'suppliers';
- $h++;
+ if ($usercancreadprice) {
+ $head[$h][0] = DOL_URL_ROOT."/product/fournisseurs.php?id=".$object->id;
+ $head[$h][1] = $langs->trans("BuyingPrices");
+ $head[$h][2] = 'suppliers';
+ $h++;
+ }
}
}
@@ -171,18 +176,18 @@ function product_prepare_head($object)
// Attachments
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
- if (!empty($conf->product->enabled) && ($object->type == Product::TYPE_PRODUCT)) {
+ if (isModEnabled("product") && ($object->type == Product::TYPE_PRODUCT)) {
$upload_dir = $conf->product->multidir_output[$object->entity].'/'.dol_sanitizeFileName($object->ref);
}
- if (!empty($conf->service->enabled) && ($object->type == Product::TYPE_SERVICE)) {
+ if (isModEnabled("service") && ($object->type == Product::TYPE_SERVICE)) {
$upload_dir = $conf->service->multidir_output[$object->entity].'/'.dol_sanitizeFileName($object->ref);
}
$nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) {
- if (!empty($conf->product->enabled) && ($object->type == Product::TYPE_PRODUCT)) {
+ if (isModEnabled("product") && ($object->type == Product::TYPE_PRODUCT)) {
$upload_dir = $conf->product->multidir_output[$object->entity].'/'.get_exdir($object->id, 2, 0, 0, $object, 'product').$object->id.'/photos';
}
- if (!empty($conf->service->enabled) && ($object->type == Product::TYPE_SERVICE)) {
+ if (isModEnabled("service") && ($object->type == Product::TYPE_SERVICE)) {
$upload_dir = $conf->service->multidir_output[$object->entity].'/'.get_exdir($object->id, 2, 0, 0, $object, 'product').$object->id.'/photos';
}
$nbFiles += count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
@@ -374,7 +379,7 @@ function show_stats_for_company($product, $socid)
print ' ';
// Customer proposals
- if (!empty($conf->propal->enabled) && $user->rights->propale->lire) {
+ if (isModEnabled("propal") && $user->rights->propale->lire) {
$nblines++;
$ret = $product->load_stats_propale($socid);
if ($ret < 0) {
@@ -431,7 +436,7 @@ function show_stats_for_company($product, $socid)
print '';
}
// Supplier orders
- if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->rights->fournisseur->commande->lire) || (!empty($conf->supplier_order->enabled) && $user->rights->supplier_order->lire)) {
+ if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->rights->fournisseur->commande->lire) || (isModEnabled("supplier_order") && $user->rights->supplier_order->lire)) {
$nblines++;
$ret = $product->load_stats_commande_fournisseur($socid);
if ($ret < 0) {
@@ -469,7 +474,7 @@ function show_stats_for_company($product, $socid)
print '';
}
// Customer template invoices
- if (!empty($conf->facture->enabled) && $user->rights->facture->lire) {
+ if (isModEnabled("facture") && $user->rights->facture->lire) {
$nblines++;
$ret = $product->load_stats_facturerec($socid);
if ($ret < 0) {
@@ -488,7 +493,7 @@ function show_stats_for_company($product, $socid)
print '';
}
// Supplier invoices
- if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->rights->fournisseur->facture->lire) || (!empty($conf->supplier_invoice->enabled) && $user->rights->supplier_invoice->lire)) {
+ if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->rights->fournisseur->facture->lire) || (isModEnabled("supplier_invoice") && $user->rights->supplier_invoice->lire)) {
$nblines++;
$ret = $product->load_stats_facture_fournisseur($socid);
if ($ret < 0) {
diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php
index 776d0f0776f..8e514a505bf 100644
--- a/htdocs/core/lib/project.lib.php
+++ b/htdocs/core/lib/project.lib.php
@@ -124,8 +124,8 @@ function project_prepare_head(Project $project, $moreparam = '')
$h++;
}
- if (((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled))
- || !empty($conf->propal->enabled) || !empty($conf->commande->enabled)
+ if (((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice"))
+ || isModEnabled("propal") || !empty($conf->commande->enabled)
|| isModEnabled('facture') || !empty($conf->contrat->enabled)
|| !empty($conf->ficheinter->enabled) || !empty($conf->agenda->enabled) || !empty($conf->deplacement->enabled) || !empty($conf->stock->enabled)) {
$nbElements = 0;
@@ -138,7 +138,7 @@ function project_prepare_head(Project $project, $moreparam = '')
if (!empty($conf->stock->enabled)) {
$nbElements += $project->getElementCount('stock', 'entrepot', 'fk_project');
}
- if (!empty($conf->propal->enabled)) {
+ if (isModEnabled("propal")) {
$nbElements += $project->getElementCount('propal', 'propal');
}
if (!empty($conf->commande->enabled)) {
@@ -153,10 +153,10 @@ function project_prepare_head(Project $project, $moreparam = '')
if (!empty($conf->supplier_proposal->enabled)) {
$nbElements += $project->getElementCount('proposal_supplier', 'supplier_proposal');
}
- if (!empty($conf->supplier_order->enabled)) {
+ if (isModEnabled("supplier_order")) {
$nbElements += $project->getElementCount('order_supplier', 'commande_fournisseur');
}
- if (!empty($conf->supplier_invoice->enabled)) {
+ if (isModEnabled("supplier_invoice")) {
$nbElements += $project->getElementCount('invoice_supplier', 'facture_fourn');
}
if (!empty($conf->contrat->enabled)) {
@@ -165,7 +165,7 @@ function project_prepare_head(Project $project, $moreparam = '')
if (!empty($conf->ficheinter->enabled)) {
$nbElements += $project->getElementCount('intervention', 'fichinter');
}
- if (!empty($conf->expedition->enabled)) {
+ if (isModEnabled("expedition")) {
$nbElements += $project->getElementCount('shipping', 'expedition');
}
if (!empty($conf->mrp->enabled)) {
@@ -195,7 +195,7 @@ function project_prepare_head(Project $project, $moreparam = '')
if (!empty($conf->salaries->enabled)) {
$nbElements += $project->getElementCount('salaries', 'payment_salary');
}
- if (!empty($conf->banque->enabled)) {
+ if (isModEnabled("banque")) {
$nbElements += $project->getElementCount('variouspayment', 'payment_various');
}
dol_setcache($cachekey, $nbElements, 120); // If setting cache fails, this is not a problem, so we do not test result.
diff --git a/htdocs/core/lib/propal.lib.php b/htdocs/core/lib/propal.lib.php
index c5d2a647a57..71391f2e499 100644
--- a/htdocs/core/lib/propal.lib.php
+++ b/htdocs/core/lib/propal.lib.php
@@ -42,8 +42,8 @@ function propal_prepare_head($object)
$head[$h][2] = 'comm';
$h++;
- if ((empty($conf->commande->enabled) && ((!empty($conf->expedition->enabled) && !empty($conf->expedition_bon->enabled) && $user->rights->expedition->lire)
- || (!empty($conf->expedition->enabled) && !empty($conf->delivery_note->enabled) && $user->rights->expedition->delivery->lire)))) {
+ if ((empty($conf->commande->enabled) && ((isModEnabled("expedition") && !empty($conf->expedition_bon->enabled) && $user->rights->expedition->lire)
+ || (isModEnabled("expedition") && !empty($conf->delivery_note->enabled) && $user->rights->expedition->delivery->lire)))) {
$langs->load("sendings");
$text = '';
$head[$h][0] = DOL_URL_ROOT.'/expedition/propal.php?id='.$object->id;
diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php
index 1d3f013e9f3..79b020b4883 100644
--- a/htdocs/core/lib/security.lib.php
+++ b/htdocs/core/lib/security.lib.php
@@ -92,7 +92,109 @@ function dol_decode($chain, $key = '1')
}
/**
- * Returns a hash of a string.
+ * Return a string of random bytes (hexa string) with length = $length fro cryptographic purposes.
+ *
+ * @param int $length Length of random string
+ * @return string Random string
+ */
+function dolGetRandomBytes($length)
+{
+ if (function_exists('random_bytes')) { // Available with PHP 7 only.
+ return bin2hex(random_bytes((int) floor($length / 2))); // the bin2hex will double the number of bytes so we take length / 2
+ }
+
+ return bin2hex(openssl_random_pseudo_bytes((int) floor($length / 2))); // the bin2hex will double the number of bytes so we take length / 2. May be very slow on Windows.
+}
+
+/**
+ * Encode a string with a symetric encryption. Used to encrypt sensitive data into database.
+ * Note: If a backup is restored onto another instance with a different $dolibarr_main_instance_unique_id, then decoded value will differ.
+ *
+ * @param string $chain string to encode
+ * @param string $key If '', we use $dolibarr_main_instance_unique_id
+ * @param string $ciphering Default ciphering algorithm
+ * @return string encoded string
+ * @see dolDecrypt(), dol_hash()
+ */
+function dolEncrypt($chain, $key = '', $ciphering = "AES-256-CTR")
+{
+ global $dolibarr_main_instance_unique_id;
+
+ if ($chain === '') {
+ return '';
+ }
+
+ $reg = array();
+ if (preg_match('/^dolcrypt:([^:]+):(.+)$/', $chain, $reg)) {
+ // The $chain is already a crypted string
+ return $chain;
+ }
+
+ if (empty($key)) {
+ $key = $dolibarr_main_instance_unique_id;
+ }
+
+ $newchain = $chain;
+
+ if (function_exists('openssl_encrypt')) {
+ $ivlen = 16;
+ if (function_exists('openssl_cipher_iv_length')) {
+ $ivlen = openssl_cipher_iv_length($ciphering);
+ }
+ if ($ivlen === false || $ivlen < 1 || $ivlen > 32) {
+ $ivlen = 16;
+ }
+ $ivseed = dolGetRandomBytes($ivlen);
+
+ $newchain = openssl_encrypt($chain, $ciphering, $key, null, $ivseed);
+ return 'dolcrypt:'.$ciphering.':'.$ivseed.':'.$newchain;
+ } else {
+ return $chain;
+ }
+}
+
+/**
+ * Decode a string with a symetric encryption. Used to decrypt sensitive data saved into database.
+ * Note: If a backup is restored onto another instance with a different $dolibarr_main_instance_unique_id, then decoded value will differ.
+ *
+ * @param string $chain string to encode
+ * @param string $key If '', we use $dolibarr_main_instance_unique_id
+ * @return string encoded string
+ * @see dolEncrypt(), dol_hash()
+ */
+function dolDecrypt($chain, $key = '')
+{
+ global $dolibarr_main_instance_unique_id;
+
+ if ($chain === '') {
+ return '';
+ }
+
+ if (empty($key)) {
+ $key = $dolibarr_main_instance_unique_id;
+ }
+
+ $reg = array();
+ if (preg_match('/^dolcrypt:([^:]+):(.+)$/', $chain, $reg)) {
+ $ciphering = $reg[1];
+ if (function_exists('openssl_decrypt')) {
+ $tmpexplode = explode(':', $reg[2]);
+ if (!empty($tmpexplode[1]) && is_string($tmpexplode[0])) {
+ $newchain = openssl_decrypt($tmpexplode[1], $ciphering, $key, null, $tmpexplode[0]);
+ } else {
+ $newchain = openssl_decrypt($tmpexplode[0], $ciphering, $key, null, null);
+ }
+ } else {
+ $newchain = 'Error function openssl_decrypt() not available';
+ }
+ return $newchain;
+ } else {
+ return $chain;
+ }
+}
+
+/**
+ * Returns a hash (non reversible encryption) of a string.
* If constant MAIN_SECURITY_HASH_ALGO is defined, we use this function as hashing function (recommanded value is 'password_hash')
* If constant MAIN_SECURITY_SALT is defined, we use it as a salt (used only if hashing algorightm is something else than 'password_hash').
*
@@ -690,11 +792,11 @@ function checkUserAccessToObject($user, array $featuresarray, $object = 0, $tabl
$sharedelement = (!empty($params[1]) ? $params[1] : $dbtablename); // We change dbtablename, so we set sharedelement too.
}
- // Check permission for object on entity only
- if (in_array($feature, $check)) {
+ // Check permission for objectid on entity only
+ if (in_array($feature, $check) && $objectid > 0) { // For $objectid = 0, no check
$sql = "SELECT COUNT(dbt.".$dbt_select.") as nb";
$sql .= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt";
- if (($feature == 'user' || $feature == 'usergroup') && !empty($conf->multicompany->enabled)) { // Special for multicompany
+ if (($feature == 'user' || $feature == 'usergroup') && isModEnabled('multicompany')) { // Special for multicompany
if (!empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) {
if ($conf->entity == 1 && $user->admin && !$user->entity) {
$sql .= " WHERE dbt.".$dbt_select." IN (".$db->sanitize($objectid, 1).")";
@@ -723,13 +825,13 @@ function checkUserAccessToObject($user, array $featuresarray, $object = 0, $tabl
}
$checkonentitydone = 1;
}
- if (in_array($feature, $checksoc)) { // We check feature = checksoc
+ if (in_array($feature, $checksoc) && $objectid > 0) { // We check feature = checksoc. For $objectid = 0, no check
// If external user: Check permission for external users
if ($user->socid > 0) {
if ($user->socid != $objectid) {
return false;
}
- } elseif (!empty($conf->societe->enabled) && ($user->rights->societe->lire && empty($user->rights->societe->client->voir))) {
+ } elseif (isModEnabled("societe") && ($user->rights->societe->lire && empty($user->rights->societe->client->voir))) {
// If internal user: Check permission for internal users that are restricted on their objects
$sql = "SELECT COUNT(sc.fk_soc) as nb";
$sql .= " FROM (".MAIN_DB_PREFIX."societe_commerciaux as sc";
@@ -738,7 +840,7 @@ function checkUserAccessToObject($user, array $featuresarray, $object = 0, $tabl
$sql .= " AND sc.fk_user = ".((int) $user->id);
$sql .= " AND sc.fk_soc = s.rowid";
$sql .= " AND s.entity IN (".getEntity($sharedelement, 1).")";
- } elseif (!empty($conf->multicompany->enabled)) {
+ } elseif (isModEnabled('multicompany')) {
// If multicompany and internal users with all permissions, check user is in correct entity
$sql = "SELECT COUNT(s.rowid) as nb";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
@@ -748,14 +850,14 @@ function checkUserAccessToObject($user, array $featuresarray, $object = 0, $tabl
$checkonentitydone = 1;
}
- if (in_array($feature, $checkother)) { // Test on entity + link to thirdparty. Allowed if link is empty (Ex: contacts...).
+ if (in_array($feature, $checkother) && $objectid > 0) { // Test on entity + link to thirdparty. Allowed if link is empty (Ex: contacts...).
// If external user: Check permission for external users
if ($user->socid > 0) {
$sql = "SELECT COUNT(dbt.".$dbt_select.") as nb";
$sql .= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt";
$sql .= " WHERE dbt.".$dbt_select." IN (".$db->sanitize($objectid, 1).")";
$sql .= " AND dbt.fk_soc = ".((int) $user->socid);
- } elseif (!empty($conf->societe->enabled) && ($user->rights->societe->lire && empty($user->rights->societe->client->voir))) {
+ } elseif (isModEnabled("societe") && ($user->rights->societe->lire && empty($user->rights->societe->client->voir))) {
// If internal user: Check permission for internal users that are restricted on their objects
$sql = "SELECT COUNT(dbt.".$dbt_select.") as nb";
$sql .= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt";
@@ -763,7 +865,7 @@ function checkUserAccessToObject($user, array $featuresarray, $object = 0, $tabl
$sql .= " WHERE dbt.".$dbt_select." IN (".$db->sanitize($objectid, 1).")";
$sql .= " AND (dbt.fk_soc IS NULL OR sc.fk_soc IS NOT NULL)"; // Contact not linked to a company or to a company of user
$sql .= " AND dbt.entity IN (".getEntity($sharedelement, 1).")";
- } elseif (!empty($conf->multicompany->enabled)) {
+ } elseif (isModEnabled('multicompany')) {
// If multicompany and internal users with all permissions, check user is in correct entity
$sql = "SELECT COUNT(dbt.".$dbt_select.") as nb";
$sql .= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt";
@@ -773,7 +875,7 @@ function checkUserAccessToObject($user, array $featuresarray, $object = 0, $tabl
$checkonentitydone = 1;
}
- if (in_array($feature, $checkproject)) {
+ if (in_array($feature, $checkproject) && $objectid > 0) {
if (!empty($conf->project->enabled) && empty($user->rights->projet->all->lire)) {
$projectid = $objectid;
@@ -794,7 +896,7 @@ function checkUserAccessToObject($user, array $featuresarray, $object = 0, $tabl
$checkonentitydone = 1;
}
- if (in_array($feature, $checktask)) {
+ if (in_array($feature, $checktask) && $objectid > 0) {
if (!empty($conf->project->enabled) && empty($user->rights->projet->all->lire)) {
$task = new Task($db);
$task->fetch($objectid);
@@ -817,7 +919,7 @@ function checkUserAccessToObject($user, array $featuresarray, $object = 0, $tabl
$checkonentitydone = 1;
}
- if (!$checkonentitydone && !in_array($feature, $nocheck)) { // By default (case of $checkdefault), we check on object entity + link to third party on field $dbt_keyfield
+ if (!$checkonentitydone && !in_array($feature, $nocheck) && $objectid > 0) { // By default (case of $checkdefault), we check on object entity + link to third party on field $dbt_keyfield
// If external user: Check permission for external users
if ($user->socid > 0) {
if (empty($dbt_keyfield)) {
@@ -827,7 +929,7 @@ function checkUserAccessToObject($user, array $featuresarray, $object = 0, $tabl
$sql .= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt";
$sql .= " WHERE dbt.rowid IN (".$db->sanitize($objectid, 1).")";
$sql .= " AND dbt.".$dbt_keyfield." = ".((int) $user->socid);
- } elseif (!empty($conf->societe->enabled) && empty($user->rights->societe->client->voir)) {
+ } elseif (isModEnabled("societe") && empty($user->rights->societe->client->voir)) {
// If internal user: Check permission for internal users that are restricted on their objects
if ($feature != 'ticket') {
if (empty($dbt_keyfield)) {
@@ -849,7 +951,7 @@ function checkUserAccessToObject($user, array $featuresarray, $object = 0, $tabl
$sql .= " AND dbt.entity IN (".getEntity($sharedelement, 1).")";
$sql .= " AND (sc.fk_user = ".((int) $user->id)." OR sc.fk_user IS NULL)";
}
- } elseif (!empty($conf->multicompany->enabled)) {
+ } elseif (isModEnabled('multicompany')) {
// If multicompany and internal users with all permissions, check user is in correct entity
$sql = "SELECT COUNT(dbt.".$dbt_select.") as nb";
$sql .= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt";
@@ -860,7 +962,7 @@ function checkUserAccessToObject($user, array $featuresarray, $object = 0, $tabl
//print $sql;
// For events, check on users assigned to event
- if ($feature === 'agenda') {
+ if ($feature === 'agenda' && $objectid > 0) {
// Also check owner or attendee for users without allactions->read
if ($objectid > 0 && empty($user->rights->agenda->allactions->read)) {
require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
@@ -874,7 +976,7 @@ function checkUserAccessToObject($user, array $featuresarray, $object = 0, $tabl
// For some object, we also have to check it is in the user hierarchy
// Param $object must be the full object and not a simple id to have this test possible.
- if (in_array($feature, $checkhierarchy) && is_object($object)) {
+ if (in_array($feature, $checkhierarchy) && is_object($object) && $objectid > 0) {
$childids = $user->getAllChildIds(1);
$useridtocheck = 0;
if ($feature == 'holiday') {
diff --git a/htdocs/core/lib/security2.lib.php b/htdocs/core/lib/security2.lib.php
index 8f4abca6167..380282fc48b 100644
--- a/htdocs/core/lib/security2.lib.php
+++ b/htdocs/core/lib/security2.lib.php
@@ -374,13 +374,16 @@ function encodedecode_dbpassconf($level = 0)
$lineofpass = 0;
+ $reg = array();
if (preg_match('/^[^#]*dolibarr_main_db_encrypted_pass[\s]*=[\s]*(.*)/i', $buffer, $reg)) { // Old way to save crypted value
$val = trim($reg[1]); // This also remove CR/LF
$val = preg_replace('/^["\']/', '', $val);
$val = preg_replace('/["\'][\s;]*$/', '', $val);
if (!empty($val)) {
$passwd_crypted = $val;
+ // method dol_encode/dol_decode
$val = dol_decode($val);
+ //$val = dolEncrypt($val);
$passwd = $val;
$lineofpass = 1;
}
@@ -389,10 +392,17 @@ function encodedecode_dbpassconf($level = 0)
$val = preg_replace('/^["\']/', '', $val);
$val = preg_replace('/["\'][\s;]*$/', '', $val);
if (preg_match('/crypted:/i', $buffer)) {
+ // method dol_encode/dol_decode
$val = preg_replace('/crypted:/i', '', $val);
$passwd_crypted = $val;
$val = dol_decode($val);
$passwd = $val;
+ } elseif (preg_match('/^dolcrypt:([^:]+):(.*)$/i', $buffer, $reg)) {
+ // method dolEncrypt/dolDecrypt
+ $val = preg_replace('/crypted:([^:]+):/i', '', $val);
+ $passwd_crypted = $val;
+ $val = dolDecrypt($buffer);
+ $passwd = $val;
} else {
$passwd = $val;
$val = dol_encode($val);
diff --git a/htdocs/core/lib/signature.lib.php b/htdocs/core/lib/signature.lib.php
index d76120ab3de..d2f0c64f463 100644
--- a/htdocs/core/lib/signature.lib.php
+++ b/htdocs/core/lib/signature.lib.php
@@ -90,7 +90,7 @@ function getOnlineSignatureUrl($mode, $type, $ref = '', $localorexternal = 1)
if ($mode == 1) {
$out .= "hash('".$securekeyseed."' + '".$type."' + proposal_ref)";
} else {
- $out .= '&securekey='.dol_hash($securekeyseed.$type.$ref, '0');
+ $out .= '&securekey='.dol_hash($securekeyseed.$type.$ref.(!isModEnabled('multicompany') ? '' : $object->entity), '0');
}
/*
if ($mode == 1) {
@@ -119,7 +119,7 @@ function getOnlineSignatureUrl($mode, $type, $ref = '', $localorexternal = 1)
}
// For multicompany
- if (!empty($out) && !empty($conf->multicompany->enabled)) {
+ if (!empty($out) && isModEnabled('multicompany')) {
$out .= "&entity=".$conf->entity; // Check the entity because we may have the same reference in several entities
}
diff --git a/htdocs/core/lib/ticket.lib.php b/htdocs/core/lib/ticket.lib.php
index ef2f6bcf286..8ef509057c4 100644
--- a/htdocs/core/lib/ticket.lib.php
+++ b/htdocs/core/lib/ticket.lib.php
@@ -1,7 +1,7 @@
* Copyright (C) 2016 Christophe Battarel
- * Copyright (C) 2019-2020 Frédéric France
+ * Copyright (C) 2019-2022 Frédéric France
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -250,7 +250,7 @@ function llxHeaderTicket($title, $head = "", $disablejs = 0, $disablehead = 0, $
if (!empty($conf->global->TICKET_IMAGE_PUBLIC_INTERFACE)) {
print '';
- print '
';
+ print '
';
print '
';
}
@@ -560,7 +560,7 @@ function show_ticket_messaging($conf, $langs, $db, $filterobj, $objcon = '', $no
// Set $out to sow events
$out = '';
- if (empty($conf->agenda->enabled)) {
+ if (!isModEnabled('agenda')) {
$langs->loadLangs(array("admin", "errors"));
$out = info_admin($langs->trans("WarningModuleXDisabledSoYouMayMissEventHere", $langs->transnoentitiesnoconv("Module2400Name")), 0, 0, 'warning');
}
@@ -697,8 +697,8 @@ function show_ticket_messaging($conf, $langs, $db, $filterobj, $objcon = '', $no
// $out.=' '.$langs->trans('Show').' ';
//}
- if ($user->rights->agenda->allactions->create ||
- (($actionstatic->authorid == $user->id || $actionstatic->userownerid == $user->id) && $user->rights->agenda->myactions->create)) {
+ if (!empty($user->rights->agenda->allactions->create) ||
+ (($actionstatic->authorid == $user->id || $actionstatic->userownerid == $user->id) && !empty($user->rights->agenda->myactions->create))) {
$out .= ' ';
}
diff --git a/htdocs/core/login/functions_dolibarr.php b/htdocs/core/login/functions_dolibarr.php
index 610072aa35a..c4825998b3a 100644
--- a/htdocs/core/login/functions_dolibarr.php
+++ b/htdocs/core/login/functions_dolibarr.php
@@ -40,7 +40,7 @@ function check_user_password_dolibarr($usertotest, $passwordtotest, $entitytotes
// Force master entity in transversal mode
$entity = $entitytotest;
- if (!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) {
+ if (isModEnabled('multicompany') && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) {
$entity = 1;
}
@@ -134,11 +134,11 @@ function check_user_password_dolibarr($usertotest, $passwordtotest, $entitytotes
}
// We must check entity
- if ($passok && !empty($conf->multicompany->enabled)) { // We must check entity
+ if ($passok && isModEnabled('multicompany')) { // We must check entity
global $mc;
if (!isset($mc)) {
- $conf->multicompany->enabled = false; // Global not available, disable $conf->multicompany->enabled for safety
+ !isModEnabled('multicompany'); // Global not available, disable $conf->multicompany->enabled for safety
} else {
$ret = $mc->checkRight($obj->rowid, $entitytotest);
if ($ret < 0) {
diff --git a/htdocs/core/login/functions_ldap.php b/htdocs/core/login/functions_ldap.php
index 022186b8de1..18800c3a19e 100644
--- a/htdocs/core/login/functions_ldap.php
+++ b/htdocs/core/login/functions_ldap.php
@@ -46,7 +46,7 @@ function check_user_password_ldap($usertotest, $passwordtotest, $entitytotest)
// Force master entity in transversal mode
$entity = $entitytotest;
- if (!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) {
+ if (isModEnabled('multicompany') && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) {
$entity = 1;
}
@@ -228,7 +228,7 @@ function check_user_password_ldap($usertotest, $passwordtotest, $entitytotest)
unset($usertmp);
}
- if (!empty($conf->multicompany->enabled)) { // We must check entity (even if sync is not active)
+ if (isModEnabled('multicompany')) { // We must check entity (even if sync is not active)
global $mc;
$usertmp = new User($db);
diff --git a/htdocs/core/menus/init_menu_auguria.sql b/htdocs/core/menus/init_menu_auguria.sql
index 96625dd1f95..0580c6c8cc0 100644
--- a/htdocs/core/menus/init_menu_auguria.sql
+++ b/htdocs/core/menus/init_menu_auguria.sql
@@ -12,7 +12,7 @@ delete from llx_menu where menu_handler=__HANDLER__ and entity=__ENTITY__;
-- Top-Menu
-- old: (module, enabled, rowid, ...)
insert into llx_menu (rowid, module, enabled, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ( 1__+MAX_llx_menu__, '', '1', __HANDLER__, 'top', 'home', '', 0, '/index.php?mainmenu=home&leftmenu=', 'Home', -1, '', '', '', 2, 10, __ENTITY__);
-insert into llx_menu (rowid, module, enabled, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ( 2__+MAX_llx_menu__, 'societe|fournisseur|supplier_order|supplier_invoice', '($conf->societe->enabled && (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) || empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) || !empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || $conf->supplier_order->enabled || $conf->supplier_invoice->enabled))', __HANDLER__, 'top', 'companies', '', 0, '/societe/index.php?mainmenu=companies&leftmenu=', 'ThirdParties', -1, 'companies', '$user->rights->societe->lire || $user->rights->societe->contact->lire', '', 2, 20, __ENTITY__);
+insert into llx_menu (rowid, module, enabled, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ( 2__+MAX_llx_menu__, 'societe|fournisseur|supplier_order|supplier_invoice', '($conf->societe->enabled && (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) || empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) || isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || $conf->supplier_order->enabled || $conf->supplier_invoice->enabled))', __HANDLER__, 'top', 'companies', '', 0, '/societe/index.php?mainmenu=companies&leftmenu=', 'ThirdParties', -1, 'companies', '$user->rights->societe->lire || $user->rights->societe->contact->lire', '', 2, 20, __ENTITY__);
insert into llx_menu (rowid, module, enabled, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ( 3__+MAX_llx_menu__, 'product|service', '$conf->product->enabled || $conf->service->enabled', __HANDLER__, 'top', 'products', '', 0, '/product/index.php?mainmenu=products&leftmenu=', 'ProductsPipeServices', -1, 'products', '$user->rights->produit->lire||$user->rights->service->lire', '', 0, 30, __ENTITY__);
insert into llx_menu (rowid, module, enabled, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ( 16__+MAX_llx_menu__, 'bom|mrp', '$conf->bom->enabled || $conf->mrp->enabled', __HANDLER__, 'top', 'mrp', '', 0, '/mrp/index.php?mainmenu=mrp&leftmenu=', 'MRP', -1, 'mrp', '$user->rights->bom->read||$user->rights->mrp->read', '', 0, 31, __ENTITY__);
insert into llx_menu (rowid, module, enabled, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ( 7__+MAX_llx_menu__, 'projet', '$conf->project->enabled', __HANDLER__, 'top', 'project', '', 0, '/projet/index.php?mainmenu=project&leftmenu=', 'Projects', -1, 'projects', '$user->rights->projet->lire', '', 2, 32, __ENTITY__);
@@ -86,8 +86,8 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->societe->enabled', __HANDLER__, 'left', 500__+MAX_llx_menu__, 'companies', 'thirdparties', 2__+MAX_llx_menu__, '/societe/index.php?mainmenu=companies&leftmenu=thirdparties', 'ThirdParty', 0, 'companies', '$user->rights->societe->lire', '', 2, 0, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->societe->enabled', __HANDLER__, 'left', 501__+MAX_llx_menu__, 'companies', '', 500__+MAX_llx_menu__, '/societe/card.php?mainmenu=companies&action=create', 'MenuNewThirdParty', 1, 'companies', '$user->rights->societe->creer', '', 2, 0, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->societe->enabled', __HANDLER__, 'left', 502__+MAX_llx_menu__, 'companies', '', 500__+MAX_llx_menu__, '/societe/list.php?mainmenu=companies&leftmenu=thirdparties', 'List', 1, 'companies', '$user->rights->societe->lire', '', 2, 0, __ENTITY__);
-insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->societe->enabled && (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled))', __HANDLER__, 'left', 503__+MAX_llx_menu__, 'companies', '', 500__+MAX_llx_menu__, '/societe/list.php?mainmenu=companies&type=f&leftmenu=suppliers', 'ListSuppliersShort', 1, 'suppliers', '$user->rights->societe->lire && $user->rights->fournisseur->lire', '', 2, 5, __ENTITY__);
-insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->societe->enabled && (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled))', __HANDLER__, 'left', 504__+MAX_llx_menu__, 'companies', '', 503__+MAX_llx_menu__, '/societe/card.php?mainmenu=companies&leftmenu=supplier&action=create&type=f', 'NewSupplier', 2, 'suppliers', '$user->rights->societe->creer', '', 2, 0, __ENTITY__);
+insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->societe->enabled && (isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice"))', __HANDLER__, 'left', 503__+MAX_llx_menu__, 'companies', '', 500__+MAX_llx_menu__, '/societe/list.php?mainmenu=companies&type=f&leftmenu=suppliers', 'ListSuppliersShort', 1, 'suppliers', '$user->rights->societe->lire && $user->rights->fournisseur->lire', '', 2, 5, __ENTITY__);
+insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->societe->enabled && (isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice"))', __HANDLER__, 'left', 504__+MAX_llx_menu__, 'companies', '', 503__+MAX_llx_menu__, '/societe/card.php?mainmenu=companies&leftmenu=supplier&action=create&type=f', 'NewSupplier', 2, 'suppliers', '$user->rights->societe->creer', '', 2, 0, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->societe->enabled', __HANDLER__, 'left', 506__+MAX_llx_menu__, 'companies', '', 500__+MAX_llx_menu__, '/societe/list.php?mainmenu=companies&type=p&leftmenu=prospects', 'ListProspectsShort', 1, 'companies', '$user->rights->societe->lire', '', 2, 3, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->societe->enabled', __HANDLER__, 'left', 507__+MAX_llx_menu__, 'companies', '', 506__+MAX_llx_menu__, '/societe/card.php?mainmenu=companies&leftmenu=prospects&action=create&type=p', 'MenuNewProspect', 2, 'companies', '$user->rights->societe->creer', '', 2, 0, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->societe->enabled', __HANDLER__, 'left', 509__+MAX_llx_menu__, 'companies', '', 500__+MAX_llx_menu__, '/societe/list.php?mainmenu=companies&type=c&leftmenu=customers', 'ListCustomersShort', 1, 'companies', '$user->rights->societe->lire', '', 2, 4, __ENTITY__);
@@ -99,7 +99,7 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->societe->enabled', __HANDLER__, 'left', 602__+MAX_llx_menu__, 'companies', '', 600__+MAX_llx_menu__, '/contact/list.php?mainmenu=companies&leftmenu=contacts', 'List', 1, 'companies', '$user->rights->societe->lire', '', 2, 1, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->societe->enabled', __HANDLER__, 'left', 604__+MAX_llx_menu__, 'companies', '', 602__+MAX_llx_menu__, '/contact/list.php?mainmenu=companies&leftmenu=contacts&type=p', 'ThirdPartyProspects', 2, 'companies', '$user->rights->societe->contact->lire', '', 2, 1, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->societe->enabled', __HANDLER__, 'left', 605__+MAX_llx_menu__, 'companies', '', 602__+MAX_llx_menu__, '/contact/list.php?mainmenu=companies&leftmenu=contacts&type=c', 'ThirdPartyCustomers', 2, 'companies', '$user->rights->societe->contact->lire', '', 2, 2, __ENTITY__);
-insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->societe->enabled && (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled))', __HANDLER__, 'left', 606__+MAX_llx_menu__, 'companies', '', 602__+MAX_llx_menu__, '/contact/list.php?mainmenu=companies&leftmenu=contacts&type=f', 'ThirdPartySuppliers', 2, 'companies', '$user->rights->societe->contact->lire', '', 2, 3, __ENTITY__);
+insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->societe->enabled && (isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice"))', __HANDLER__, 'left', 606__+MAX_llx_menu__, 'companies', '', 602__+MAX_llx_menu__, '/contact/list.php?mainmenu=companies&leftmenu=contacts&type=f', 'ThirdPartySuppliers', 2, 'companies', '$user->rights->societe->contact->lire', '', 2, 3, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->societe->enabled', __HANDLER__, 'left', 607__+MAX_llx_menu__, 'companies', '', 602__+MAX_llx_menu__, '/contact/list.php?mainmenu=companies&leftmenu=contacts&type=o', 'Others', 2, 'companies', '$user->rights->societe->contact->lire', '', 2, 4, __ENTITY__);
-- Third parties - Category customer
@@ -107,8 +107,8 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->societe->enabled && $conf->categorie->enabled', __HANDLER__, 'left', 651__+MAX_llx_menu__, 'companies', '', 650__+MAX_llx_menu__, '/categories/card.php?mainmenu=companies&action=create&type=1', 'NewCategory', 1, 'categories', '$user->rights->categorie->creer', '', 2, 0, __ENTITY__);
-- Third parties - Category supplier
-insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '(!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) && $conf->categorie->enabled', __HANDLER__, 'left', 660__+MAX_llx_menu__, 'companies', 'cat', 2__+MAX_llx_menu__, '/categories/index.php?mainmenu=companies&leftmenu=cat&type=2', 'CustomersProspectsCategoriesShort', 0, 'categories', '$user->rights->categorie->lire', '', 2, 4, __ENTITY__);
-insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '(!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) && $conf->categorie->enabled', __HANDLER__, 'left', 661__+MAX_llx_menu__, 'companies', '', 660__+MAX_llx_menu__, '/categories/card.php?mainmenu=companies&action=create&type=2', 'NewCategory', 1, 'categories', '$user->rights->categorie->creer', '', 2, 0, __ENTITY__);
+insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '(isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) && $conf->categorie->enabled', __HANDLER__, 'left', 660__+MAX_llx_menu__, 'companies', 'cat', 2__+MAX_llx_menu__, '/categories/index.php?mainmenu=companies&leftmenu=cat&type=2', 'CustomersProspectsCategoriesShort', 0, 'categories', '$user->rights->categorie->lire', '', 2, 4, __ENTITY__);
+insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '(isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) && $conf->categorie->enabled', __HANDLER__, 'left', 661__+MAX_llx_menu__, 'companies', '', 660__+MAX_llx_menu__, '/categories/card.php?mainmenu=companies&action=create&type=2', 'NewCategory', 1, 'categories', '$user->rights->categorie->creer', '', 2, 0, __ENTITY__);
-- Third parties - Category contact
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->societe->enabled && $conf->categorie->enabled', __HANDLER__, 'left', 670__+MAX_llx_menu__, 'companies', 'cat', 2__+MAX_llx_menu__, '/categories/index.php?mainmenu=companies&leftmenu=cat&type=4', 'ContactCategoriesShort', 0, 'categories', '$user->rights->categorie->lire', '', 2, 3, __ENTITY__);
@@ -257,7 +257,7 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->tax->enabled && $leftmenu=="tax_social"', __HANDLER__, 'left', 2251__+MAX_llx_menu__, 'billing', '', 2250__+MAX_llx_menu__, '/compta/sociales/card.php?mainmenu=billing&leftmenu=tax_social&action=create', 'MenuNewSocialContribution', 2, '', '$user->rights->tax->charges->creer', '', 0, 2, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->tax->enabled && $leftmenu=="tax_social"', __HANDLER__, 'left', 2252__+MAX_llx_menu__, 'billing', '', 2250__+MAX_llx_menu__, '/compta/sociales/payments.php?mainmenu=billing&leftmenu=tax_social', 'Payments', 2, '', '$user->rights->tax->charges->lire', '', 0, 3, __ENTITY__);
--- VAT/TVA/IVA
+-- VAT/TVA/IVA
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->tax->enabled && empty($conf->global->TAX_DISABLE_VAT_MENUS)', __HANDLER__, 'left', 2300__+MAX_llx_menu__, 'billing', 'tax_vat', 2200__+MAX_llx_menu__, '/compta/tva/list.php?mainmenu=billing&leftmenu=tax_vat', 'VAT', 1, 'companies', '$user->rights->tax->charges->lire', '', 0, 7, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->tax->enabled && empty($conf->global->TAX_DISABLE_VAT_MENUS) && $leftmenu=="tax_vat"', __HANDLER__, 'left', 2301__+MAX_llx_menu__, 'billing', '', 2300__+MAX_llx_menu__, '/compta/tva/card.php?mainmenu=billing&leftmenu=tax_vat&action=create', 'New', 2, 'companies', '$user->rights->tax->charges->creer', '', 0, 0, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->tax->enabled && empty($conf->global->TAX_DISABLE_VAT_MENUS) && $leftmenu=="tax_vat"', __HANDLER__, 'left', 2302__+MAX_llx_menu__, 'billing', '', 2300__+MAX_llx_menu__, '/compta/tva/list.php?mainmenu=billing&leftmenu=tax_vat', 'List', 2, 'companies', '$user->rights->tax->charges->lire', '', 0, 1, __ENTITY__);
@@ -313,9 +313,9 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $conf->facture->enabled && empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_SALES)', __HANDLER__, 'left', 2401__+MAX_llx_menu__, 'accountancy', 'accountancy_dispatch_customer', 2400__+MAX_llx_menu__, '/accountancy/customer/index.php?mainmenu=accountancy&leftmenu=accountancy_dispatch_customer', 'CustomersVentilation', 1, 'accountancy', '$user->rights->accounting->bind->write', '', 0, 2, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $conf->facture->enabled && empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_SALES) && $leftmenu=="accountancy_dispatch_customer"', __HANDLER__, 'left', 2402__+MAX_llx_menu__, 'accountancy', '', 2401__+MAX_llx_menu__, '/accountancy/customer/list.php?mainmenu=accountancy', 'ToDispatch', 2, 'accountancy', '$user->rights->accounting->bind->write', '', 0, 3, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $conf->facture->enabled && empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_SALES) && $leftmenu=="accountancy_dispatch_customer"', __HANDLER__, 'left', 2403__+MAX_llx_menu__, 'accountancy', '', 2401__+MAX_llx_menu__, '/accountancy/customer/lines.php?mainmenu=accountancy', 'Dispatched', 2, 'accountancy', '$user->rights->accounting->bind->write', '', 0, 4, __ENTITY__);
-insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_invoice->enabled)) && empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_PURCHASES)', __HANDLER__, 'left', 2410__+MAX_llx_menu__, 'accountancy', 'accountancy_dispatch_supplier', 2400__+MAX_llx_menu__, '/accountancy/supplier/index.php?mainmenu=accountancy&leftmenu=accountancy_dispatch_supplier', 'SuppliersVentilation', 1, 'accountancy', '$user->rights->accounting->bind->write', '', 0, 5, __ENTITY__);
-insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_invoice->enabled)) && empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_PURCHASES) && $leftmenu=="accountancy_dispatch_supplier"', __HANDLER__, 'left', 2411__+MAX_llx_menu__, 'accountancy', '', 2410__+MAX_llx_menu__, '/accountancy/supplier/list.php?mainmenu=accountancy', 'ToDispatch', 2, 'accountancy', '$user->rights->accounting->bind->write', '', 0, 6, __ENTITY__);
-insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_invoice->enabled)) && empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_PURCHASES) && $leftmenu=="accountancy_dispatch_supplier"', __HANDLER__, 'left', 2412__+MAX_llx_menu__, 'accountancy', '', 2410__+MAX_llx_menu__, '/accountancy/supplier/lines.php?mainmenu=accountancy', 'Dispatched', 2, 'accountancy', '$user->rights->accounting->bind->write', '', 0, 7, __ENTITY__);
+insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && (isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || isModEnabled("supplier_invoice")) && empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_PURCHASES)', __HANDLER__, 'left', 2410__+MAX_llx_menu__, 'accountancy', 'accountancy_dispatch_supplier', 2400__+MAX_llx_menu__, '/accountancy/supplier/index.php?mainmenu=accountancy&leftmenu=accountancy_dispatch_supplier', 'SuppliersVentilation', 1, 'accountancy', '$user->rights->accounting->bind->write', '', 0, 5, __ENTITY__);
+insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && (isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || isModEnabled("supplier_invoice")) && empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_PURCHASES) && $leftmenu=="accountancy_dispatch_supplier"', __HANDLER__, 'left', 2411__+MAX_llx_menu__, 'accountancy', '', 2410__+MAX_llx_menu__, '/accountancy/supplier/list.php?mainmenu=accountancy', 'ToDispatch', 2, 'accountancy', '$user->rights->accounting->bind->write', '', 0, 6, __ENTITY__);
+insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && (isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || isModEnabled("supplier_invoice")) && empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_PURCHASES) && $leftmenu=="accountancy_dispatch_supplier"', __HANDLER__, 'left', 2412__+MAX_llx_menu__, 'accountancy', '', 2410__+MAX_llx_menu__, '/accountancy/supplier/lines.php?mainmenu=accountancy', 'Dispatched', 2, 'accountancy', '$user->rights->accounting->bind->write', '', 0, 7, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $conf->expensereport->enabled && empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_EXPENSEREPORTS)', __HANDLER__, 'left', 2420__+MAX_llx_menu__, 'accountancy', 'accountancy_dispatch_expensereport', 2400__+MAX_llx_menu__, '/accountancy/expensereport/index.php?mainmenu=accountancy&leftmenu=accountancy_dispatch_expensereport', 'ExpenseReportsVentilation', 1, 'accountancy', '$user->rights->accounting->bind->write', '', 0, 5, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $conf->expensereport->enabled && empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_EXPENSEREPORTS) && $leftmenu=="accountancy_dispatch_expensereport"', __HANDLER__, 'left', 2421__+MAX_llx_menu__, 'accountancy', '', 2420__+MAX_llx_menu__, '/accountancy/expensereport/list.php?mainmenu=accountancy', 'ToDispatch', 2, 'accountancy', '$user->rights->accounting->bind->write', '', 0, 6, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $conf->expensereport->enabled && empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_EXPENSEREPORTS) && $leftmenu=="accountancy_dispatch_expensereport"', __HANDLER__, 'left', 2422__+MAX_llx_menu__, 'accountancy', '', 2420__+MAX_llx_menu__, '/accountancy/expensereport/lines.php?mainmenu=accountancy', 'Dispatched', 2, 'accountancy', '$user->rights->accounting->bind->write', '', 0, 7, __ENTITY__);
diff --git a/htdocs/core/modules/DolibarrModules.class.php b/htdocs/core/modules/DolibarrModules.class.php
index 627a13a7844..2076c6a348e 100644
--- a/htdocs/core/modules/DolibarrModules.class.php
+++ b/htdocs/core/modules/DolibarrModules.class.php
@@ -1368,7 +1368,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it
// For the moment, we manage this with hard coded exception
//print "Remove box ".$file.' ';
if ($file == 'box_graph_product_distribution.php') {
- if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) {
+ if (isModEnabled("product") || isModEnabled("service")) {
dol_syslog("We discard deleting module ".$file." because another module still active requires it.");
continue;
}
diff --git a/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php b/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php
index 3a8defb8db4..2a2f813011b 100644
--- a/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php
+++ b/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php
@@ -986,20 +986,20 @@ class pdf_espadon extends ModelePdfExpedition
}
// Show barcode
- if (!empty($conf->barcode->enabled)) {
+ if (isModEnabled('barcode')) {
$posx = 105;
} else {
$posx = $this->marge_gauche + 3;
}
//$pdf->Rect($this->marge_gauche, $this->marge_haute, $this->page_largeur-$this->marge_gauche-$this->marge_droite, 30);
- if (!empty($conf->barcode->enabled)) {
+ if (isModEnabled('barcode')) {
// TODO Build code bar with function writeBarCode of barcode module for sending ref $object->ref
//$pdf->SetXY($this->marge_gauche+3, $this->marge_haute+3);
//$pdf->Image($logo,10, 5, 0, 24);
}
$pdf->SetDrawColor(128, 128, 128);
- if (!empty($conf->barcode->enabled)) {
+ if (isModEnabled('barcode')) {
// TODO Build code bar with function writeBarCode of barcode module for sending ref $object->ref
//$pdf->SetXY($this->marge_gauche+3, $this->marge_haute+3);
//$pdf->Image($logo,10, 5, 0, 24);
diff --git a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php
index ab9461d104f..de2c454de18 100644
--- a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php
+++ b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php
@@ -931,20 +931,20 @@ class pdf_rouget extends ModelePdfExpedition
}
// Show barcode
- if (!empty($conf->barcode->enabled)) {
+ if (isModEnabled('barcode')) {
$posx = 105;
} else {
$posx = $this->marge_gauche + 3;
}
//$pdf->Rect($this->marge_gauche, $this->marge_haute, $this->page_largeur-$this->marge_gauche-$this->marge_droite, 30);
- if (!empty($conf->barcode->enabled)) {
+ if (isModEnabled('barcode')) {
// TODO Build code bar with function writeBarCode of barcode module for sending ref $object->ref
//$pdf->SetXY($this->marge_gauche+3, $this->marge_haute+3);
//$pdf->Image($logo,10, 5, 0, 24);
}
$pdf->SetDrawColor(128, 128, 128);
- if (!empty($conf->barcode->enabled)) {
+ if (isModEnabled('barcode')) {
// TODO Build code bar with function writeBarCode of barcode module for sending ref $object->ref
//$pdf->SetXY($this->marge_gauche+3, $this->marge_haute+3);
//$pdf->Image($logo,10, 5, 0, 24);
diff --git a/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php b/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php
index 43c1ae9e4de..365a2326281 100644
--- a/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php
+++ b/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php
@@ -1043,7 +1043,7 @@ class pdf_standard extends ModeleExpenseReport
$pdf->MultiCell(15, 3, $outputlangs->transnoentities("Amount"), 0, 'C', 0);
$pdf->SetXY($tab3_posx + 35, $tab3_top + 1);
$pdf->MultiCell(30, 3, $outputlangs->transnoentities("Type"), 0, 'L', 0);
- if (!empty($conf->banque->enabled)) {
+ if (isModEnabled("banque")) {
$pdf->SetXY($tab3_posx + 65, $tab3_top + 1);
$pdf->MultiCell(25, 3, $outputlangs->transnoentities("BankAccount"), 0, 'L', 0);
}
@@ -1083,7 +1083,7 @@ class pdf_standard extends ModeleExpenseReport
$oper = $outputlangs->transnoentitiesnoconv("PaymentTypeShort".$row->p_code);
$pdf->MultiCell(40, 3, $oper, 0, 'L', 0);
- if (!empty($conf->banque->enabled)) {
+ if (isModEnabled("banque")) {
$pdf->SetXY($tab3_posx + 65, $tab3_top + $y + 1);
$pdf->MultiCell(30, 3, $row->baref, 0, 'L', 0);
}
diff --git a/htdocs/core/modules/expensereport/mod_expensereport_sand.php b/htdocs/core/modules/expensereport/mod_expensereport_sand.php
index c403aa8c228..d14f17de067 100644
--- a/htdocs/core/modules/expensereport/mod_expensereport_sand.php
+++ b/htdocs/core/modules/expensereport/mod_expensereport_sand.php
@@ -82,7 +82,8 @@ class mod_expensereport_sand extends ModeleNumRefExpenseReport
// Parametrage du prefix
$texte .= ''.$langs->trans("Mask").': ';
- $texte .= ''.$form->textwithpicto(' ', $tooltip, 1, 1).' ';
+ $mask = empty($conf->global->EXPENSEREPORT_SAND_MASK) ? '' : $conf->global->EXPENSEREPORT_SAND_MASK;
+ $texte .= ''.$form->textwithpicto(' ', $tooltip, 1, 1).' ';
$texte .= ' ';
@@ -128,7 +129,7 @@ class mod_expensereport_sand extends ModeleNumRefExpenseReport
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
// We get cursor rule
- $mask = $conf->global->EXPENSEREPORT_SAND_MASK;
+ $mask = empty($conf->global->EXPENSEREPORT_SAND_MASK) ? '' : $conf->global->EXPENSEREPORT_SAND_MASK;
if (!$mask) {
$this->error = 'NotConfigured';
diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php
index 63e9d61c409..47d5480268c 100644
--- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php
+++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php
@@ -1163,6 +1163,14 @@ class pdf_crabe extends ModelePDFFactures
$pdf->SetFont('', '', $default_font_size - 2);
$pdf->SetXY($posxval, $posy);
$lib_mode_reg = $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) != ('PaymentType'.$object->mode_reglement_code) ? $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) : $outputlangs->convToOutputCharset($object->mode_reglement);
+ //#21654: add account number used for the debit
+ if ($object->mode_reglement_code == "PRE") {
+ require_once DOL_DOCUMENT_ROOT.'/societe/class/companybankaccount.class.php';
+ $bac = new CompanyBankAccount($this->db);
+ $bac->fetch(0, $object->thirdparty->id);
+ $iban= $bac->iban.(($bac->iban && $bac->bic) ? ' / ' : '').$bac->bic;
+ $lib_mode_reg .= $langs->trans("PaymentTypePREdetails", dol_trunc($iban, 6, 'right', 'UTF-8', 1));
+ }
$pdf->MultiCell(80, 5, $lib_mode_reg, 0, 'L');
$posy = $pdf->GetY();
diff --git a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php
index 9c79896ee6e..547aaaadae1 100644
--- a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php
+++ b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php
@@ -116,30 +116,30 @@ class pdf_sponge extends ModelePDFFactures
public $marge_basse;
- /**
- * @var int heightforinfotot
- */
- public $heightforinfotot;
+ /**
+ * @var int heightforinfotot
+ */
+ public $heightforinfotot;
- /**
- * @var int heightforfreetext
- */
- public $heightforfreetext;
+ /**
+ * @var int heightforfreetext
+ */
+ public $heightforfreetext;
- /**
- * @var int heightforfooter
- */
- public $heightforfooter;
+ /**
+ * @var int heightforfooter
+ */
+ public $heightforfooter;
- /**
- * @var int tab_top
- */
- public $tab_top;
+ /**
+ * @var int tab_top
+ */
+ public $tab_top;
- /**
- * @var int tab_top_newpage
- */
- public $tab_top_newpage;
+ /**
+ * @var int tab_top_newpage
+ */
+ public $tab_top_newpage;
/**
* Issuer
@@ -1243,37 +1243,47 @@ class pdf_sponge extends ModelePDFFactures
if (empty($object->mode_reglement_code)
&& empty($conf->global->FACTURE_CHQ_NUMBER)
&& empty($conf->global->FACTURE_RIB_NUMBER)) {
- $this->error = $outputlangs->transnoentities("ErrorNoPaiementModeConfigured");
+ $this->error = $outputlangs->transnoentities("ErrorNoPaiementModeConfigured");
} elseif (($object->mode_reglement_code == 'CHQ' && empty($conf->global->FACTURE_CHQ_NUMBER) && empty($object->fk_account) && empty($object->fk_bank))
- || ($object->mode_reglement_code == 'VIR' && empty($conf->global->FACTURE_RIB_NUMBER) && empty($object->fk_account) && empty($object->fk_bank))) {
- // Avoid having any valid PDF with setup that is not complete
- $outputlangs->load("errors");
+ || ($object->mode_reglement_code == 'VIR' && empty($conf->global->FACTURE_RIB_NUMBER) && empty($object->fk_account) && empty($object->fk_bank))) {
+ // Avoid having any valid PDF with setup that is not complete
+ $outputlangs->load("errors");
- $pdf->SetXY($this->marge_gauche, $posy);
- $pdf->SetTextColor(200, 0, 0);
- $pdf->SetFont('', 'B', $default_font_size - 2);
- $this->error = $outputlangs->transnoentities("ErrorPaymentModeDefinedToWithoutSetup", $object->mode_reglement_code);
- $pdf->MultiCell($posxend - $this->marge_gauche, 3, $this->error, 0, 'L', 0);
- $pdf->SetTextColor(0, 0, 0);
+ $pdf->SetXY($this->marge_gauche, $posy);
+ $pdf->SetTextColor(200, 0, 0);
+ $pdf->SetFont('', 'B', $default_font_size - 2);
+ $this->error = $outputlangs->transnoentities("ErrorPaymentModeDefinedToWithoutSetup", $object->mode_reglement_code);
+ $pdf->MultiCell($posxend - $this->marge_gauche, 3, $this->error, 0, 'L', 0);
+ $pdf->SetTextColor(0, 0, 0);
- $posy = $pdf->GetY() + 1;
+ $posy = $pdf->GetY() + 1;
}
// Show payment mode
if (!empty($object->mode_reglement_code)
- && $object->mode_reglement_code != 'CHQ'
- && $object->mode_reglement_code != 'VIR') {
- $pdf->SetFont('', 'B', $default_font_size - 2);
- $pdf->SetXY($this->marge_gauche, $posy);
- $titre = $outputlangs->transnoentities("PaymentMode").':';
- $pdf->MultiCell($posxend - $this->marge_gauche, 5, $titre, 0, 'L');
+ && $object->mode_reglement_code != 'CHQ'
+ && $object->mode_reglement_code != 'VIR') {
+ $pdf->SetFont('', 'B', $default_font_size - 2);
+ $pdf->SetXY($this->marge_gauche, $posy);
+ $titre = $outputlangs->transnoentities("PaymentMode").':';
+ $pdf->MultiCell($posxend - $this->marge_gauche, 5, $titre, 0, 'L');
- $pdf->SetFont('', '', $default_font_size - 2);
- $pdf->SetXY($posxval, $posy);
- $lib_mode_reg = $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) != ('PaymentType'.$object->mode_reglement_code) ? $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) : $outputlangs->convToOutputCharset($object->mode_reglement);
- $pdf->MultiCell($posxend - $posxval, 5, $lib_mode_reg, 0, 'L');
+ $pdf->SetFont('', '', $default_font_size - 2);
+ $pdf->SetXY($posxval, $posy);
+ $lib_mode_reg = $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) != ('PaymentType'.$object->mode_reglement_code) ? $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) : $outputlangs->convToOutputCharset($object->mode_reglement);
- $posy = $pdf->GetY();
+ //#21654: add account number used for the debit
+ if ($object->mode_reglement_code == "PRE") {
+ require_once DOL_DOCUMENT_ROOT.'/societe/class/companybankaccount.class.php';
+ $bac = new CompanyBankAccount($this->db);
+ $bac->fetch(0, $object->thirdparty->id);
+ $iban= $bac->iban.(($bac->iban && $bac->bic) ? ' / ' : '').$bac->bic;
+ $lib_mode_reg .= $langs->trans("PaymentTypePREdetails", dol_trunc($iban, 6, 'right', 'UTF-8', 1));
+ }
+
+ $pdf->MultiCell($posxend - $posxval, 5, $lib_mode_reg, 0, 'L');
+
+ $posy = $pdf->GetY();
}
// Show online payment link
@@ -1291,6 +1301,7 @@ class pdf_sponge extends ModelePDFFactures
}
}
+
if ($object->statut != Facture::STATUS_DRAFT && $useonlinepayment) {
require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php';
global $langs;
@@ -1461,13 +1472,12 @@ class pdf_sponge extends ModelePDFFactures
if ($posy > $this->page_hauteur - 4 - $this->heightforfooter) {
$this->_pagefoot($pdf, $object, $outputlangs, 1);
$pdf->addPage();
- if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
- $this->_pagehead($pdf, $object, 0, $outputlangs, $outputlangsbis);
- $pdf->setY($this->tab_top_newpage);
- }
- else{
- $pdf->setY($this->marge_haute);
- }
+ if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
+ $this->_pagehead($pdf, $object, 0, $outputlangs, $outputlangsbis);
+ $pdf->setY($this->tab_top_newpage);
+ } else {
+ $pdf->setY($this->marge_haute);
+ }
$posy = $pdf->GetY();
}
@@ -1529,13 +1539,12 @@ class pdf_sponge extends ModelePDFFactures
if ($posy > $this->page_hauteur - 4 - $this->heightforfooter) {
$pdf->addPage();
- if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
- $this->_pagehead($pdf, $object, 0, $outputlangs, $outputlangsbis);
- $pdf->setY($this->tab_top_newpage);
- }
- else {
- $pdf->setY($this->marge_haute);
- }
+ if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
+ $this->_pagehead($pdf, $object, 0, $outputlangs, $outputlangsbis);
+ $pdf->setY($this->tab_top_newpage);
+ } else {
+ $pdf->setY($this->marge_haute);
+ }
$posy = $pdf->GetY();
}
diff --git a/htdocs/core/modules/import/import_csv.modules.php b/htdocs/core/modules/import/import_csv.modules.php
index 32284a2cbd1..426a582c3f4 100644
--- a/htdocs/core/modules/import/import_csv.modules.php
+++ b/htdocs/core/modules/import/import_csv.modules.php
@@ -115,7 +115,7 @@ class ImportCsv extends ModeleImports
$this->datatoimport = $datatoimport;
if (preg_match('/^societe_/', $datatoimport)) {
- $this->thirpartyobject = new Societe($this->db);
+ $this->thirdpartyobject = new Societe($this->db);
}
}
@@ -560,8 +560,8 @@ class ImportCsv extends ModeleImports
}
} elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'getcustomercodeifauto') {
if (strtolower($newval) == 'auto') {
- $this->thirpartyobject->get_codeclient(0, 0);
- $newval = $this->thirpartyobject->code_client;
+ $this->thirdpartyobject->get_codeclient(0, 0);
+ $newval = $this->thirdpartyobject->code_client;
//print 'code_client='.$newval;
}
if (empty($newval)) {
@@ -569,8 +569,8 @@ class ImportCsv extends ModeleImports
}
} elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'getsuppliercodeifauto') {
if (strtolower($newval) == 'auto') {
- $newval = $this->thirpartyobject->get_codefournisseur(0, 1);
- $newval = $this->thirpartyobject->code_fournisseur;
+ $newval = $this->thirdpartyobject->get_codefournisseur(0, 1);
+ $newval = $this->thirdpartyobject->code_fournisseur;
//print 'code_fournisseur='.$newval;
}
if (empty($newval)) {
@@ -578,8 +578,8 @@ class ImportCsv extends ModeleImports
}
} elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'getcustomeraccountancycodeifauto') {
if (strtolower($newval) == 'auto') {
- $this->thirpartyobject->get_codecompta('customer');
- $newval = $this->thirpartyobject->code_compta;
+ $this->thirdpartyobject->get_codecompta('customer');
+ $newval = $this->thirdpartyobject->code_compta;
//print 'code_compta='.$newval;
}
if (empty($newval)) {
@@ -587,8 +587,8 @@ class ImportCsv extends ModeleImports
}
} elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'getsupplieraccountancycodeifauto') {
if (strtolower($newval) == 'auto') {
- $this->thirpartyobject->get_codecompta('supplier');
- $newval = $this->thirpartyobject->code_compta_fournisseur;
+ $this->thirdpartyobject->get_codecompta('supplier');
+ $newval = $this->thirdpartyobject->code_compta_fournisseur;
if (empty($newval)) {
$arrayrecord[($key - 1)]['type'] = -1; // If we get empty value, we will use "null"
}
diff --git a/htdocs/core/modules/import/import_xlsx.modules.php b/htdocs/core/modules/import/import_xlsx.modules.php
index d8a9d77a98e..6d7c5bf82fd 100644
--- a/htdocs/core/modules/import/import_xlsx.modules.php
+++ b/htdocs/core/modules/import/import_xlsx.modules.php
@@ -133,7 +133,7 @@ class ImportXlsx extends ModeleImports
$this->datatoimport = $datatoimport;
if (preg_match('/^societe_/', $datatoimport)) {
- $this->thirpartyobject = new Societe($this->db);
+ $this->thirdpartyobject = new Societe($this->db);
}
}
@@ -604,8 +604,8 @@ class ImportXlsx extends ModeleImports
}
} elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'getcustomercodeifauto') {
if (strtolower($newval) == 'auto') {
- $this->thirpartyobject->get_codeclient(0, 0);
- $newval = $this->thirpartyobject->code_client;
+ $this->thirdpartyobject->get_codeclient(0, 0);
+ $newval = $this->thirdpartyobject->code_client;
//print 'code_client='.$newval;
}
if (empty($newval)) {
@@ -613,8 +613,8 @@ class ImportXlsx extends ModeleImports
}
} elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'getsuppliercodeifauto') {
if (strtolower($newval) == 'auto') {
- $newval = $this->thirpartyobject->get_codefournisseur(0, 1);
- $newval = $this->thirpartyobject->code_fournisseur;
+ $newval = $this->thirdpartyobject->get_codefournisseur(0, 1);
+ $newval = $this->thirdpartyobject->code_fournisseur;
//print 'code_fournisseur='.$newval;
}
if (empty($newval)) {
@@ -622,8 +622,8 @@ class ImportXlsx extends ModeleImports
}
} elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'getcustomeraccountancycodeifauto') {
if (strtolower($newval) == 'auto') {
- $this->thirpartyobject->get_codecompta('customer');
- $newval = $this->thirpartyobject->code_compta;
+ $this->thirdpartyobject->get_codecompta('customer');
+ $newval = $this->thirdpartyobject->code_compta;
//print 'code_compta='.$newval;
}
if (empty($newval)) {
@@ -631,8 +631,8 @@ class ImportXlsx extends ModeleImports
}
} elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'getsupplieraccountancycodeifauto') {
if (strtolower($newval) == 'auto') {
- $this->thirpartyobject->get_codecompta('supplier');
- $newval = $this->thirpartyobject->code_compta_fournisseur;
+ $this->thirdpartyobject->get_codecompta('supplier');
+ $newval = $this->thirdpartyobject->code_compta_fournisseur;
if (empty($newval)) {
$arrayrecord[($key)]['type'] = -1; // If we get empty value, we will use "null"
}
diff --git a/htdocs/core/modules/mailings/partnership.modules.php b/htdocs/core/modules/mailings/partnership.modules.php
index 7813d93f54d..aa1f861bfe2 100644
--- a/htdocs/core/modules/mailings/partnership.modules.php
+++ b/htdocs/core/modules/mailings/partnership.modules.php
@@ -1,4 +1,5 @@
* Copyright (C) 2005-2010 Laurent Destailleur
* Copyright (C) 2005-2009 Regis Houssin
@@ -16,6 +17,8 @@
* \brief Example file to provide a list of recipients for mailing module
*/
+
+// Load Dolibarr Environment
include_once DOL_DOCUMENT_ROOT.'/core/modules/mailings/modules_mailings.php';
@@ -24,9 +27,10 @@ include_once DOL_DOCUMENT_ROOT.'/core/modules/mailings/modules_mailings.php';
*/
class mailing_partnership extends MailingTargets
{
- public $name = 'PartnershipThirdartiesOrMembers';
// This label is used if no translation is found for key XXX neither MailingModuleDescXXX where XXX=name is found
+ public $name = 'PartnershipThirdpartiesOrMembers';
public $desc = "Thirdparties or members included into a partnership program";
+
public $require_admin = 0;
public $require_module = array(); // This module allows to select by categories must be also enabled if category module is not activated
@@ -52,7 +56,7 @@ class mailing_partnership extends MailingTargets
public function __construct($db)
{
global $conf, $langs;
- $langs->load("companies");
+ $langs->load('companies');
$this->db = $db;
}
@@ -218,7 +222,7 @@ class mailing_partnership extends MailingTargets
$num = $this->db->num_rows($resql);
if (empty($conf->partnership->enabled)) {
- $num = 0; // Force empty list if category module is not enabled
+ $num = 0; // Force empty list if category module is not enabled
}
if ($num) {
@@ -253,7 +257,7 @@ class mailing_partnership extends MailingTargets
*/
public function url($id, $sourcetype = 'thirdparty')
{
- if ($sourcetype == 'thirparty') {
+ if ($sourcetype == 'thirdparty') {
return ''.img_object('', "societe").' ';
}
if ($sourcetype == 'member') {
diff --git a/htdocs/core/modules/modAdherent.class.php b/htdocs/core/modules/modAdherent.class.php
index ec0546e9af1..2db6311b172 100644
--- a/htdocs/core/modules/modAdherent.class.php
+++ b/htdocs/core/modules/modAdherent.class.php
@@ -145,7 +145,7 @@ class modAdherent extends DolibarrModules
$this->const[$r][4] = 0;
$r++;
- $this->const[$r][0] = "ADHERENT_MAILMAN_ADMINPW";
+ $this->const[$r][0] = "ADHERENT_MAILMAN_ADMIN_PASSWORD";
$this->const[$r][1] = "chaine";
$this->const[$r][2] = "";
$this->const[$r][3] = "Mot de passe Admin des liste mailman";
@@ -345,7 +345,7 @@ class modAdherent extends DolibarrModules
'a.email'=>"Email", 'a.birth'=>"Birthday", 'a.statut'=>"Status*", 'a.photo'=>"Photo", 'a.note_public'=>"NotePublic", 'a.note_private'=>"NotePrivate",
'a.datec'=>'DateCreation', 'a.datefin'=>'DateEndSubscription'
);
- if (!empty($conf->societe->enabled)) {
+ if (isModEnabled("societe")) {
$this->import_fields_array[$r]['a.fk_soc'] = "ThirdParty";
}
// Add extra fields
@@ -380,7 +380,7 @@ class modAdherent extends DolibarrModules
'dict' => 'DictionaryCountry'
)
);
- if (!empty($conf->societe->enabled)) {
+ if (isModEnabled("societe")) {
$this->import_convertvalue_array[$r]['a.fk_soc'] = array('rule'=>'fetchidfromref', 'classfile'=>'/societe/class/societe.class.php', 'class'=>'Societe', 'method'=>'fetch', 'element'=>'ThirdParty');
}
$this->import_fieldshidden_array[$r] = array('extra.fk_object'=>'lastrowid-'.MAIN_DB_PREFIX.'adherent'); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent)
@@ -394,7 +394,7 @@ class modAdherent extends DolibarrModules
'a.email'=>'jsmith@example.com', 'a.birth'=>'1972-10-10', 'a.statut'=>"0 or 1", 'a.note_public'=>"This is a public comment on member",
'a.note_private'=>"This is private comment on member", 'a.datec'=>dol_print_date($now, '%Y-%m__%d'), 'a.datefin'=>dol_print_date(dol_time_plus_duree($now, 1, 'y'), '%Y-%m-%d')
);
- if (!empty($conf->societe->enabled)) {
+ if (isModEnabled("societe")) {
$this->import_examplevalues_array[$r]['a.fk_soc'] = "rowid or name";
}
$this->import_updatekeys_array[$r] = array('a.ref'=>'MemberRef', 'a.login'=>'Login');
diff --git a/htdocs/core/modules/modCategorie.class.php b/htdocs/core/modules/modCategorie.class.php
index 57ac7a637dc..e70cdad999e 100644
--- a/htdocs/core/modules/modCategorie.class.php
+++ b/htdocs/core/modules/modCategorie.class.php
@@ -127,19 +127,19 @@ class modCategorie extends DolibarrModules
$this->export_permission[$r] = array(array("categorie", "lire"));
$typeexample = "";
- if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) {
+ if (isModEnabled("product") || isModEnabled("service")) {
$typeexample .= ($typeexample ? " / " : "")."0=Product-Service";
}
- if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) {
+ if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) {
$typeexample .= ($typeexample ? "/" : "")."1=Supplier";
}
- if (!empty($conf->societe->enabled)) {
+ if (isModEnabled("societe")) {
$typeexample .= ($typeexample ? " / " : "")."2=Customer-Prospect";
}
if (!empty($conf->adherent->enabled)) {
$typeexample .= ($typeexample ? " / " : "")."3=Member";
}
- if (!empty($conf->societe->enabled)) {
+ if (isModEnabled("societe")) {
$typeexample .= ($typeexample ? " / " : "")."4=Contact";
}
if (!empty($conf->bank->enabled)) {
@@ -179,7 +179,7 @@ class modCategorie extends DolibarrModules
$this->export_code[$r] = $this->rights_class.'_0_'.Categorie::$MAP_ID_TO_CODE[0];
$this->export_label[$r] = 'CatProdList';
$this->export_icon[$r] = $this->picto;
- $this->export_enabled[$r] = '!empty($conf->product->enabled) || !empty($conf->service->abled)';
+ $this->export_enabled[$r] = 'isModEnabled("product") || !empty($conf->service->abled)';
$this->export_permission[$r] = array(array("categorie", "lire"), array("produit", "export"));
$this->export_fields_array[$r] = array('cat.rowid'=>"CategId", 'cat.label'=>"Label", 'cat.description'=>"Description", 'cat.fk_parent'=>"ParentCategory", 'p.rowid'=>'ProductId', 'p.ref'=>'Ref', 'p.label'=>'Label');
$this->export_TypeFields_array[$r] = array('cat.label'=>"Text", 'cat.description'=>"Text", 'cat.fk_parent'=>'List:categorie:label:rowid', 'p.ref'=>'Text', 'p.label'=>'Text');
@@ -203,7 +203,7 @@ class modCategorie extends DolibarrModules
$this->export_code[$r] = $this->rights_class.'_1_'.Categorie::$MAP_ID_TO_CODE[1];
$this->export_label[$r] = 'CatSupList';
$this->export_icon[$r] = $this->picto;
- $this->export_enabled[$r] = '!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)';
+ $this->export_enabled[$r] = 'isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")';
$this->export_permission[$r] = array(array("categorie", "lire"), array("fournisseur", "lire"));
$this->export_fields_array[$r] = array(
'cat.rowid'=>"CategId", 'cat.label'=>"Label", 'cat.description'=>"Description", 'cat.fk_parent'=>"ParentCategory",
@@ -249,7 +249,7 @@ class modCategorie extends DolibarrModules
$this->export_code[$r] = $this->rights_class.'_2_'.Categorie::$MAP_ID_TO_CODE[2];
$this->export_label[$r] = 'CatCusList';
$this->export_icon[$r] = $this->picto;
- $this->export_enabled[$r] = '!empty($conf->societe->enabled)';
+ $this->export_enabled[$r] = 'isModEnabled("societe")';
$this->export_permission[$r] = array(array("categorie", "lire"), array("societe", "export"));
$this->export_fields_array[$r] = array(
'cat.rowid'=>"CategId", 'cat.label'=>"Label", 'cat.description'=>"Description", 'cat.fk_parent'=>"ParentCategory",
@@ -321,7 +321,7 @@ class modCategorie extends DolibarrModules
$this->export_code[$r] = $this->rights_class.'_4_'.Categorie::$MAP_ID_TO_CODE[4];
$this->export_label[$r] = 'CatContactList';
$this->export_icon[$r] = $this->picto;
- $this->export_enabled[$r] = '!empty($conf->societe->enabled)';
+ $this->export_enabled[$r] = 'isModEnabled("societe")';
$this->export_permission[$r] = array(array("categorie", "lire"), array("societe", "contact", "export"));
$this->export_fields_array[$r] = array(
'cat.rowid'=>"CategId", 'cat.label'=>"Label", 'cat.description'=>"Description", 'cat.fk_parent'=>"ParentCategory",
@@ -466,7 +466,7 @@ class modCategorie extends DolibarrModules
$this->import_updatekeys_array[$r] = array('ca.label'=>'Label');
// 0 Products
- if (!empty($conf->product->enabled)) {
+ if (isModEnabled("product")) {
$r++;
$this->import_code[$r] = $this->rights_class.'_0_'.Categorie::$MAP_ID_TO_CODE[0];
$this->import_label[$r] = "CatProdLinks"; // Translation key
@@ -485,7 +485,7 @@ class modCategorie extends DolibarrModules
}
// 1 Suppliers
- if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) {
+ if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) {
$r++;
$this->import_code[$r] = $this->rights_class.'_1_'.Categorie::$MAP_ID_TO_CODE[1];
$this->import_label[$r] = "CatSupLinks"; // Translation key
@@ -506,7 +506,7 @@ class modCategorie extends DolibarrModules
}
// 2 Customers
- if (!empty($conf->societe->enabled)) {
+ if (isModEnabled("societe")) {
$r++;
$this->import_code[$r] = $this->rights_class.'_2_'.Categorie::$MAP_ID_TO_CODE[2];
$this->import_label[$r] = "CatCusLinks"; // Translation key
@@ -545,7 +545,7 @@ class modCategorie extends DolibarrModules
}
// 4 Contacts/Addresses
- if (!empty($conf->societe->enabled)) {
+ if (isModEnabled("societe")) {
$r++;
$this->import_code[$r] = $this->rights_class.'_4_'.Categorie::$MAP_ID_TO_CODE[4];
$this->import_label[$r] = "CatContactsLinks"; // Translation key
diff --git a/htdocs/core/modules/modCommande.class.php b/htdocs/core/modules/modCommande.class.php
index 70f06169394..4f2b58ff00d 100644
--- a/htdocs/core/modules/modCommande.class.php
+++ b/htdocs/core/modules/modCommande.class.php
@@ -221,7 +221,7 @@ class modCommande extends DolibarrModules
// Add multicompany field
if (!empty($conf->global->MULTICOMPANY_ENTITY_IN_EXPORT_IF_SHARED)) {
$nbofallowedentities = count(explode(',', getEntity('commande')));
- if (!empty($conf->multicompany->enabled) && $nbofallowedentities > 1) {
+ if (isModEnabled('multicompany') && $nbofallowedentities > 1) {
$this->export_fields_array[$r]['c.entity'] = 'Entity';
}
}
diff --git a/htdocs/core/modules/modCron.class.php b/htdocs/core/modules/modCron.class.php
index 290eea449f5..00d73dd7d14 100644
--- a/htdocs/core/modules/modCron.class.php
+++ b/htdocs/core/modules/modCron.class.php
@@ -101,6 +101,7 @@ class modCron extends DolibarrModules
0=>array('entity'=>0, 'label'=>'PurgeDeleteTemporaryFilesShort', 'jobtype'=>'method', 'class'=>'core/class/utils.class.php', 'objectname'=>'Utils', 'method'=>'purgeFiles', 'parameters'=>'tempfilesold+logfiles', 'comment'=>'PurgeDeleteTemporaryFiles', 'frequency'=>2, 'unitfrequency'=>3600 * 24 * 7, 'priority'=>50, 'status'=>1, 'test'=>true),
1=>array('entity'=>0, 'label'=>'MakeLocalDatabaseDumpShort', 'jobtype'=>'method', 'class'=>'core/class/utils.class.php', 'objectname'=>'Utils', 'method'=>'dumpDatabase', 'parameters'=>'none,auto,1,auto,10', 'comment'=>'MakeLocalDatabaseDump', 'frequency'=>1, 'unitfrequency'=>3600 * 24 * 7, 'priority'=>90, 'status'=>0, 'test'=>'in_array($conf->db->type, array(\'mysql\', \'mysqli\'))'),
2=>array('entity'=>0, 'label'=>'MakeSendLocalDatabaseDumpShort', 'jobtype'=>'method', 'class'=>'core/class/utils.class.php', 'objectname'=>'Utils', 'method'=>'sendDumpDatabase', 'parameters'=>',,,,,sql', 'comment'=>'MakeSendLocalDatabaseDump', 'frequency'=>1, 'unitfrequency'=>604800, 'priority'=>91, 'status'=>0, 'test'=>'!empty($conf->global->MAIN_ALLOW_BACKUP_BY_EMAIL) && in_array($conf->db->type, array(\'mysql\', \'mysqli\'))'),
+ 3=>array('entity'=>0, 'label'=>'CleanUnfinishedCronjobShort', 'jobtype'=>'method', 'class'=>'core/class/utils.class.php', 'objectname'=>'Utils', 'method'=>'cleanUnfinishedCronjob', 'parameters'=>'', 'comment'=>'CleanUnfinishedCronjob', 'frequency'=>5, 'unitfrequency'=>60, 'priority'=>10, 'status'=>0, 'test'=>'getDolGlobalInt("MAIN_FEATURES_LEVEL") >= 2'),
// 1=>array('entity'=>0, 'label'=>'My label', 'jobtype'=>'command', 'command'=>'', 'parameters'=>'', 'comment'=>'Comment', 'frequency'=>1, 'unitfrequency'=>3600*24)
);
diff --git a/htdocs/core/modules/modEventOrganization.class.php b/htdocs/core/modules/modEventOrganization.class.php
index a7a6c048a4d..c2c9309cd44 100644
--- a/htdocs/core/modules/modEventOrganization.class.php
+++ b/htdocs/core/modules/modEventOrganization.class.php
@@ -56,7 +56,7 @@ class modEventOrganization extends DolibarrModules
$this->description = "EventOrganizationDescription";
$this->descriptionlong = "EventOrganizationDescriptionLong";
- $this->version = 'experimental';
+ $this->version = 'dolibarr';
// Key used in llx_const table to save module status enabled/disabled (where EVENTORGANIZATION is value of property name of module in uppercase)
diff --git a/htdocs/core/modules/modFTP.class.php b/htdocs/core/modules/modFTP.class.php
index 7cde492b2c3..ae2de933bb6 100644
--- a/htdocs/core/modules/modFTP.class.php
+++ b/htdocs/core/modules/modFTP.class.php
@@ -54,7 +54,7 @@ class modFTP extends DolibarrModules
// Module description used if translation string 'ModuleXXXDesc' not found (XXX is id value)
$this->description = "FTP Client";
// Possible values for version are: 'development', 'experimental', 'dolibarr' or version
- $this->version = 'dolibarr';
+ $this->version = 'dolibarr_deprecated';
// Key used in llx_const table to save module status enabled/disabled (XXX is id value)
$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
// Name of png file (without png) used for this module
diff --git a/htdocs/core/modules/modFacture.class.php b/htdocs/core/modules/modFacture.class.php
index 3cea4f0ff92..a819dae666c 100644
--- a/htdocs/core/modules/modFacture.class.php
+++ b/htdocs/core/modules/modFacture.class.php
@@ -538,7 +538,7 @@ class modFacture extends DolibarrModules
// Add multicompany field
if (!empty($conf->global->MULTICOMPANY_ENTITY_IN_EXPORT_IF_SHARED)) {
$nbofallowedentities = count(explode(',', getEntity('invoice')));
- if (!empty($conf->multicompany->enabled) && $nbofallowedentities > 1) {
+ if (isModEnabled('multicompany') && $nbofallowedentities > 1) {
$this->export_fields_array[$r]['f.entity'] = 'Entity';
}
}
diff --git a/htdocs/core/modules/modHoliday.class.php b/htdocs/core/modules/modHoliday.class.php
index 53f69dfefaf..429e511de48 100644
--- a/htdocs/core/modules/modHoliday.class.php
+++ b/htdocs/core/modules/modHoliday.class.php
@@ -140,7 +140,7 @@ class modHoliday extends DolibarrModules
$datestart = dol_mktime(4, 0, 0, $arraydate['mon'], $arraydate['mday'], $arraydate['year']);
$this->cronjobs = array(
0 => array(
- 'label' => 'HolidayBalanceMonthlyUpdate',
+ 'label' => 'HolidayBalanceMonthlyUpdate:holiday',
'jobtype' => 'method',
'class' => 'holiday/class/holiday.class.php',
'objectname' => 'Holiday',
diff --git a/htdocs/core/modules/modProduct.class.php b/htdocs/core/modules/modProduct.class.php
index b18d10a29b1..f3c79de5ab8 100644
--- a/htdocs/core/modules/modProduct.class.php
+++ b/htdocs/core/modules/modProduct.class.php
@@ -127,6 +127,14 @@ class modProduct extends DolibarrModules
$this->rights[$r][4] = 'creer';
$r++;
+ $this->rights[$r][0] = 33; // id de la permission
+ $this->rights[$r][1] = 'Read prices products'; // libelle de la permission
+ $this->rights[$r][2] = 'w'; // type de la permission (deprecie a ce jour)
+ $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut
+ $this->rights[$r][4] = 'product_advance';
+ $this->rights[$r][5] = 'read_prices';
+ $r++;
+
$this->rights[$r][0] = 34; // id de la permission
$this->rights[$r][1] = 'Delete products'; // libelle de la permission
$this->rights[$r][2] = 'd'; // type de la permission (deprecie a ce jour)
@@ -203,20 +211,20 @@ class modProduct extends DolibarrModules
if (is_object($mysoc) && $usenpr) {
$this->export_fields_array[$r]['p.recuperableonly'] = 'NPR';
}
- if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled) || !empty($conf->margin->enabled)) {
+ if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice") || !empty($conf->margin->enabled)) {
$this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p.cost_price'=>'CostPrice'));
}
if (!empty($conf->stock->enabled)) {
$this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('e.ref'=>'DefaultWarehouse', 'p.tobatch'=>'ManageLotSerial', 'p.stock'=>'Stock', 'p.seuil_stock_alerte'=>'StockLimit', 'p.desiredstock'=>'DesiredStock', 'p.pmp'=>'PMPValue'));
}
- if (!empty($conf->barcode->enabled)) {
+ if (isModEnabled('barcode')) {
$this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p.barcode'=>'BarCode'));
}
$keyforselect = 'product';
$keyforelement = 'product';
$keyforaliasextra = 'extra';
include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
- if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) {
+ if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) {
$this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('s.nom'=>'Supplier', 'pf.ref_fourn'=>'SupplierRef', 'pf.quantity'=>'QtyMin', 'pf.remise_percent'=>'DiscountQtyMin', 'pf.unitprice'=>'BuyingPrice', 'pf.delivery_time_days'=>'NbDaysToDelivery'));
}
if (!empty($conf->global->EXPORTTOOL_CATEGORIES)) {
@@ -247,10 +255,10 @@ class modProduct extends DolibarrModules
if (!empty($conf->stock->enabled)) {
$this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('e.ref'=>'Text', 'p.tobatch'=>'Numeric', 'p.stock'=>'Numeric', 'p.seuil_stock_alerte'=>'Numeric', 'p.desiredstock'=>'Numeric', 'p.pmp'=>'Numeric', 'p.cost_price'=>'Numeric'));
}
- if (!empty($conf->barcode->enabled)) {
+ if (isModEnabled('barcode')) {
$this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('p.barcode'=>'Text'));
}
- if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) {
+ if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) {
$this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('s.nom'=>'Text', 'pf.ref_fourn'=>'Text', 'pf.unitprice'=>'Numeric', 'pf.quantity'=>'Numeric', 'pf.remise_percent'=>'Numeric', 'pf.delivery_time_days'=>'Numeric'));
}
if (!empty($conf->global->MAIN_MULTILANGS)) {
@@ -266,10 +274,10 @@ class modProduct extends DolibarrModules
if (!empty($conf->stock->enabled)) {
$this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.stock'=>'product', 'p.pmp'=>'product'));
}
- if (!empty($conf->barcode->enabled)) {
+ if (isModEnabled('barcode')) {
$this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.barcode'=>'product'));
}
- if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) {
+ if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) {
$this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('s.nom'=>'product_supplier_ref', 'pf.ref_fourn'=>'product_supplier_ref', 'pf.unitprice'=>'product_supplier_ref', 'pf.quantity'=>'product_supplier_ref', 'pf.remise_percent'=>'product_supplier_ref', 'pf.delivery_time_days'=>'product_supplier_ref'));
}
if (!empty($conf->global->MAIN_MULTILANGS)) {
@@ -281,10 +289,10 @@ class modProduct extends DolibarrModules
if (!empty($conf->stock->enabled)) {
$this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.stock'=>'product', 'p.pmp'=>'product'));
}
- if (!empty($conf->barcode->enabled)) {
+ if (isModEnabled('barcode')) {
$this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.barcode'=>'product'));
}
- if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) {
+ if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) {
$this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('s.nom'=>'product_supplier_ref', 'pf.ref_fourn'=>'product_supplier_ref', 'pf.unitprice'=>'product_supplier_ref', 'pf.quantity'=>'product_supplier_ref', 'pf.remise_percent'=>'product_supplier_ref', 'pf.delivery_time_days'=>'product_supplier_ref'));
}
if (!empty($conf->global->MAIN_MULTILANGS)) {
@@ -305,7 +313,7 @@ class modProduct extends DolibarrModules
$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_lang as l ON l.fk_product = p.rowid';
}
$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra ON p.rowid = extra.fk_object';
- if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) {
+ if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) {
$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_fournisseur_price as pf ON pf.fk_product = p.rowid LEFT JOIN '.MAIN_DB_PREFIX.'societe s ON s.rowid = pf.fk_soc';
}
if (!empty($conf->stock->enabled)) {
@@ -404,7 +412,7 @@ class modProduct extends DolibarrModules
if (!empty($conf->stock->enabled)) {
$this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p.stock'=>'Stock', 'p.seuil_stock_alerte'=>'StockLimit', 'p.desiredstock'=>'DesiredStock', 'p.pmp'=>'PMPValue'));
}
- if (!empty($conf->barcode->enabled)) {
+ if (isModEnabled('barcode')) {
$this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p.barcode'=>'BarCode'));
}
$this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('pa.qty'=>'Qty', 'pa.incdec'=>'ComposedProductIncDecStock'));
@@ -420,7 +428,7 @@ class modProduct extends DolibarrModules
if (!empty($conf->stock->enabled)) {
$this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('p.stock'=>'Numeric', 'p.seuil_stock_alerte'=>'Numeric', 'p.desiredstock'=>'Numeric', 'p.pmp'=>'Numeric', 'p.cost_price'=>'Numeric'));
}
- if (!empty($conf->barcode->enabled)) {
+ if (isModEnabled('barcode')) {
$this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('p.barcode'=>'Text'));
}
$this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('pa.qty'=>'Numeric'));
@@ -436,7 +444,7 @@ class modProduct extends DolibarrModules
if (!empty($conf->stock->enabled)) {
$this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.stock'=>'virtualproduct', 'p.seuil_stock_alerte'=>'virtualproduct', 'p.desiredstock'=>'virtualproduct', 'p.pmp'=>'virtualproduct'));
}
- if (!empty($conf->barcode->enabled)) {
+ if (isModEnabled('barcode')) {
$this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.barcode'=>'virtualproduct'));
}
$this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('pa.qty'=>"subproduct", 'pa.incdec'=>'subproduct'));
@@ -617,7 +625,7 @@ class modProduct extends DolibarrModules
));
}
- if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled) || !empty($conf->margin->enabled)) {
+ if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice") || !empty($conf->margin->enabled)) {
$this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('p.cost_price'=>'CostPrice'));
}
if (is_object($mysoc) && $usenpr) {
@@ -629,7 +637,7 @@ class modProduct extends DolibarrModules
if (is_object($mysoc) && $mysoc->useLocalTax(2)) {
$this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('p.localtax2_tx'=>'LT2', 'p.localtax2_type'=>'LT2Type'));
}
- if (!empty($conf->barcode->enabled)) {
+ if (isModEnabled('barcode')) {
$this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('p.barcode'=>'BarCode'));
}
if (!empty($conf->global->PRODUCT_USE_UNITS)) {
@@ -710,7 +718,7 @@ class modProduct extends DolibarrModules
'p.desiredstock' => ''
));
}
- if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled) || !empty($conf->margin->enabled)) {
+ if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice") || !empty($conf->margin->enabled)) {
$import_sample = array_merge($import_sample, array('p.cost_price'=>'90'));
}
if (is_object($mysoc) && $usenpr) {
@@ -722,7 +730,7 @@ class modProduct extends DolibarrModules
if (is_object($mysoc) && $mysoc->useLocalTax(2)) {
$import_sample = array_merge($import_sample, array('p.localtax2_tx'=>'', 'p.localtax2_type'=>''));
}
- if (!empty($conf->barcode->enabled)) {
+ if (isModEnabled('barcode')) {
$import_sample = array_merge($import_sample, array('p.barcode'=>''));
}
if (!empty($conf->global->PRODUCT_USE_UNITS)) {
@@ -745,11 +753,11 @@ class modProduct extends DolibarrModules
}
$this->import_examplevalues_array[$r] = array_merge($import_sample, $import_extrafield_sample);
$this->import_updatekeys_array[$r] = array('p.ref'=>'Ref');
- if (!empty($conf->barcode->enabled)) {
+ if (isModEnabled('barcode')) {
$this->import_updatekeys_array[$r] = array_merge($this->import_updatekeys_array[$r], array('p.barcode'=>'BarCode')); //only show/allow barcode as update key if Barcode module enabled
}
- if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) {
+ if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) {
// Import suppliers prices (note: this code is duplicated in module Service)
$r++;
$this->import_code[$r] = $this->rights_class.'_supplierprices';
diff --git a/htdocs/core/modules/modProjet.class.php b/htdocs/core/modules/modProjet.class.php
index ebfba5d95b9..5f1ad7d2099 100644
--- a/htdocs/core/modules/modProjet.class.php
+++ b/htdocs/core/modules/modProjet.class.php
@@ -246,7 +246,7 @@ class modProjet extends DolibarrModules
// Add multicompany field
if (!empty($conf->global->MULTICOMPANY_ENTITY_IN_EXPORT_IF_SHARED)) {
$nbofallowedentities = count(explode(',', getEntity('project'))); // If project are shared, nb will be > 1
- if (!empty($conf->multicompany->enabled) && $nbofallowedentities > 1) {
+ if (isModEnabled('multicompany') && $nbofallowedentities > 1) {
$this->export_fields_array[$r] += array('p.entity'=>'Entity');
}
}
diff --git a/htdocs/core/modules/modPropale.class.php b/htdocs/core/modules/modPropale.class.php
index f6443e6c992..13991cdcafa 100644
--- a/htdocs/core/modules/modPropale.class.php
+++ b/htdocs/core/modules/modPropale.class.php
@@ -207,7 +207,7 @@ class modPropale extends DolibarrModules
// Add multicompany field
if (!empty($conf->global->MULTICOMPANY_ENTITY_IN_EXPORT_IF_SHARED)) {
$nbofallowedentities = count(explode(',', getEntity('propal')));
- if (!empty($conf->multicompany->enabled) && $nbofallowedentities > 1) {
+ if (isModEnabled('multicompany') && $nbofallowedentities > 1) {
$this->export_fields_array[$r]['c.entity'] = 'Entity';
}
}
diff --git a/htdocs/core/modules/modRecruitment.class.php b/htdocs/core/modules/modRecruitment.class.php
index 1d2d614b9ea..ed67430bce5 100644
--- a/htdocs/core/modules/modRecruitment.class.php
+++ b/htdocs/core/modules/modRecruitment.class.php
@@ -261,7 +261,7 @@ class modRecruitment extends DolibarrModules
'prefix' => img_picto('', $this->picto, 'class="paddingright pictofixedwidth"'),
'mainmenu'=>'hrm',
'leftmenu'=>'recruitmentjobposition',
- 'url'=>'/recruitment/recruitmentindex.php',
+ 'url'=>'/recruitment/index.php',
'langs'=>'recruitment', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
'position'=>1000 + $r,
'enabled'=>'$conf->recruitment->enabled', // Define condition to show or hide menu entry. Use '$conf->recruitment->enabled' if entry must be visible if module is enabled.
diff --git a/htdocs/core/modules/modService.class.php b/htdocs/core/modules/modService.class.php
index bdc3388da5c..598c9131efb 100644
--- a/htdocs/core/modules/modService.class.php
+++ b/htdocs/core/modules/modService.class.php
@@ -102,6 +102,14 @@ class modService extends DolibarrModules
$this->rights[$r][4] = 'creer';
$r++;
+ $this->rights[$r][0] = 533; // id de la permission
+ $this->rights[$r][1] = 'Read prices services'; // libelle de la permission
+ $this->rights[$r][2] = 'w'; // type de la permission (deprecie a ce jour)
+ $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut
+ $this->rights[$r][4] = 'service_advance';
+ $this->rights[$r][5] = 'read_prices';
+ $r++;
+
$this->rights[$r][0] = 534; // id de la permission
$this->rights[$r][1] = 'Delete les services'; // libelle de la permission
$this->rights[$r][2] = 'd'; // type de la permission (deprecie a ce jour)
@@ -168,20 +176,20 @@ class modService extends DolibarrModules
if (is_object($mysoc) && $usenpr) {
$this->export_fields_array[$r]['p.recuperableonly'] = 'NPR';
}
- if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled) || !empty($conf->margin->enabled)) {
+ if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice") || !empty($conf->margin->enabled)) {
$this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p.cost_price'=>'CostPrice'));
}
if (!empty($conf->stock->enabled)) {
$this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p.stock'=>'Stock', 'p.seuil_stock_alerte'=>'StockLimit', 'p.desiredstock'=>'DesiredStock', 'p.pmp'=>'PMPValue'));
}
- if (!empty($conf->barcode->enabled)) {
+ if (isModEnabled('barcode')) {
$this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p.barcode'=>'BarCode'));
}
$keyforselect = 'product';
$keyforelement = 'product';
$keyforaliasextra = 'extra';
include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
- if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) {
+ if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) {
$this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('s.nom'=>'Supplier', 'pf.ref_fourn'=>'SupplierRef', 'pf.quantity'=>'QtyMin', 'pf.remise_percent'=>'DiscountQtyMin', 'pf.unitprice'=>'BuyingPrice', 'pf.delivery_time_days'=>'NbDaysToDelivery'));
}
if (!empty($conf->global->EXPORTTOOL_CATEGORIES)) {
@@ -210,10 +218,10 @@ class modService extends DolibarrModules
if (!empty($conf->stock->enabled)) {
$this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('p.stock'=>'Numeric', 'p.seuil_stock_alerte'=>'Numeric', 'p.desiredstock'=>'Numeric', 'p.pmp'=>'Numeric', 'p.cost_price'=>'Numeric'));
}
- if (!empty($conf->barcode->enabled)) {
+ if (isModEnabled('barcode')) {
$this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('p.barcode'=>'Text'));
}
- if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) {
+ if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) {
$this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('s.nom'=>'Text', 'pf.ref_fourn'=>'Text', 'pf.unitprice'=>'Numeric', 'pf.quantity'=>'Numeric', 'pf.remise_percent'=>'Numeric', 'pf.delivery_time_days'=>'Numeric'));
}
if (!empty($conf->global->MAIN_MULTILANGS)) {
@@ -229,10 +237,10 @@ class modService extends DolibarrModules
if (!empty($conf->stock->enabled)) {
$this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.stock'=>'product', 'p.pmp'=>'product'));
}
- if (!empty($conf->barcode->enabled)) {
+ if (isModEnabled('barcode')) {
$this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.barcode'=>'product'));
}
- if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) {
+ if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) {
$this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('s.nom'=>'product_supplier_ref', 'pf.ref_fourn'=>'product_supplier_ref', 'pf.unitprice'=>'product_supplier_ref', 'pf.quantity'=>'product_supplier_ref', 'pf.remise_percent'=>'product_supplier_ref', 'pf.delivery_time_days'=>'product_supplier_ref'));
}
if (!empty($conf->global->MAIN_MULTILANGS)) {
@@ -244,10 +252,10 @@ class modService extends DolibarrModules
if (!empty($conf->stock->enabled)) {
$this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.stock'=>'product', 'p.pmp'=>'product'));
}
- if (!empty($conf->barcode->enabled)) {
+ if (isModEnabled('barcode')) {
$this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.barcode'=>'product'));
}
- if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) {
+ if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) {
$this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('s.nom'=>'product_supplier_ref', 'pf.ref_fourn'=>'product_supplier_ref', 'pf.unitprice'=>'product_supplier_ref', 'pf.quantity'=>'product_supplier_ref', 'pf.remise_percent'=>'product_supplier_ref', 'pf.delivery_time_days'=>'product_supplier_ref'));
}
if (!empty($conf->global->MAIN_MULTILANGS)) {
@@ -268,7 +276,7 @@ class modService extends DolibarrModules
$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_lang as l ON l.fk_product = p.rowid';
}
$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra ON p.rowid = extra.fk_object';
- if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) {
+ if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) {
$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_fournisseur_price as pf ON pf.fk_product = p.rowid LEFT JOIN '.MAIN_DB_PREFIX.'societe s ON s.rowid = pf.fk_soc';
}
$this->export_sql_end[$r] .= ' WHERE p.fk_product_type = 1 AND p.entity IN ('.getEntity('product').')';
@@ -363,7 +371,7 @@ class modService extends DolibarrModules
if (!empty($conf->stock->enabled)) {
$this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p.stock'=>'Stock', 'p.seuil_stock_alerte'=>'StockLimit', 'p.desiredstock'=>'DesiredStock', 'p.pmp'=>'PMPValue'));
}
- if (!empty($conf->barcode->enabled)) {
+ if (isModEnabled('barcode')) {
$this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p.barcode'=>'BarCode'));
}
$this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('pa.qty'=>'Qty', 'pa.incdec'=>'ComposedProductIncDecStock'));
@@ -379,7 +387,7 @@ class modService extends DolibarrModules
if (!empty($conf->stock->enabled)) {
$this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('p.stock'=>'Numeric', 'p.seuil_stock_alerte'=>'Numeric', 'p.desiredstock'=>'Numeric', 'p.pmp'=>'Numeric', 'p.cost_price'=>'Numeric'));
}
- if (!empty($conf->barcode->enabled)) {
+ if (isModEnabled('barcode')) {
$this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('p.barcode'=>'Text'));
}
$this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('pa.qty'=>'Numeric'));
@@ -395,7 +403,7 @@ class modService extends DolibarrModules
if (!empty($conf->stock->enabled)) {
$this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.stock'=>'virtualproduct', 'p.seuil_stock_alerte'=>'virtualproduct', 'p.desiredstock'=>'virtualproduct', 'p.pmp'=>'virtualproduct'));
}
- if (!empty($conf->barcode->enabled)) {
+ if (isModEnabled('barcode')) {
$this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.barcode'=>'virtualproduct'));
}
$this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('pa.qty'=>"subproduct", 'pa.incdec'=>'subproduct'));
@@ -564,7 +572,7 @@ class modService extends DolibarrModules
));
}
- if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled) || !empty($conf->margin->enabled)) {
+ if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice") || !empty($conf->margin->enabled)) {
$this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('p.cost_price'=>'CostPrice'));
}
if (is_object($mysoc) && $usenpr) {
@@ -576,7 +584,7 @@ class modService extends DolibarrModules
if (is_object($mysoc) && $mysoc->useLocalTax(2)) {
$this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('p.localtax2_tx'=>'LT2', 'p.localtax2_type'=>'LT2Type'));
}
- if (!empty($conf->barcode->enabled)) {
+ if (isModEnabled('barcode')) {
$this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('p.barcode'=>'BarCode'));
}
if (!empty($conf->global->PRODUCT_USE_UNITS)) {
@@ -655,7 +663,7 @@ class modService extends DolibarrModules
'p.desiredstock' => ''
));
}
- if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled) || !empty($conf->margin->enabled)) {
+ if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice") || !empty($conf->margin->enabled)) {
$import_sample = array_merge($import_sample, array('p.cost_price'=>'90'));
}
if (is_object($mysoc) && $usenpr) {
@@ -667,7 +675,7 @@ class modService extends DolibarrModules
if (is_object($mysoc) && $mysoc->useLocalTax(2)) {
$import_sample = array_merge($import_sample, array('p.localtax2_tx'=>'', 'p.localtax2_type'=>''));
}
- if (!empty($conf->barcode->enabled)) {
+ if (isModEnabled('barcode')) {
$import_sample = array_merge($import_sample, array('p.barcode'=>''));
}
if (!empty($conf->global->PRODUCT_USE_UNITS)) {
@@ -693,12 +701,12 @@ class modService extends DolibarrModules
}
$this->import_examplevalues_array[$r] = array_merge($import_sample, $import_extrafield_sample);
$this->import_updatekeys_array[$r] = array('p.ref'=>'Ref');
- if (!empty($conf->barcode->enabled)) {
+ if (isModEnabled('barcode')) {
$this->import_updatekeys_array[$r] = array_merge($this->import_updatekeys_array[$r], array('p.barcode'=>'BarCode')); //only show/allow barcode as update key if Barcode module enabled
}
if (empty($conf->product->enabled)) { // We enable next import templates only if module product not already enabled (to avoid duplicate entries)
- if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) {
+ if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) {
// Import suppliers prices (note: this code is duplicated in module Service)
$r++;
$this->import_code[$r] = $this->rights_class.'_supplierprices';
diff --git a/htdocs/core/modules/modSociete.class.php b/htdocs/core/modules/modSociete.class.php
index 327262ce39f..c11c37d11ef 100644
--- a/htdocs/core/modules/modSociete.class.php
+++ b/htdocs/core/modules/modSociete.class.php
@@ -148,7 +148,7 @@ class modSociete extends DolibarrModules
$this->rights[$r][1] = 'Read thirdparties customers';
$this->rights[$r][2] = 'r';
$this->rights[$r][3] = 0;
- $this->rights[$r][4] = 'thirparty_customer_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on
+ $this->rights[$r][4] = 'thirdparty_customer_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on
$this->rights[$r][5] = 'read';
$r++;
@@ -172,7 +172,7 @@ class modSociete extends DolibarrModules
$this->rights[$r][1] = 'Create thirdparties customers';
$this->rights[$r][2] = 'r';
$this->rights[$r][3] = 0;
- $this->rights[$r][4] = 'thirparty_customer_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on
+ $this->rights[$r][4] = 'thirdparty_customer_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on
$this->rights[$r][5] = 'read';
$r++;
@@ -295,7 +295,7 @@ class modSociete extends DolibarrModules
// Add multicompany field
if (!empty($conf->global->MULTICOMPANY_ENTITY_IN_EXPORT_IF_SHARED)) {
$nbofallowedentities = count(explode(',', getEntity('societe'))); // If project are shared, nb will be > 1
- if (!empty($conf->multicompany->enabled) && $nbofallowedentities > 1) {
+ if (isModEnabled('multicompany') && $nbofallowedentities > 1) {
$this->export_fields_array[$r] += array('s.entity'=>'Entity');
}
}
@@ -379,7 +379,7 @@ class modSociete extends DolibarrModules
);
// Add multicompany field
if (! empty($conf->global->MULTICOMPANY_ENTITY_IN_EXPORT_IF_SHARED)) {
- if (!empty($conf->multicompany->enabled)) {
+ if (isModEnabled('multicompany')) {
$nbofallowedentities = count(explode(',', getEntity('contact')));
if ($nbofallowedentities > 1) {
$this->export_fields_array[$r]['c.entity'] = 'Entity';
@@ -413,7 +413,7 @@ class modSociete extends DolibarrModules
't.libelle'=>"company",
's.entity'=>'company',
); // We define here only fields that use another picto
- if (empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) {
+ if (empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) {
unset($this->export_fields_array[$r]['s.code_fournisseur']);
unset($this->export_entities_array[$r]['s.code_fournisseur']);
}
diff --git a/htdocs/core/modules/oauth/generic_oauthcallback.php b/htdocs/core/modules/oauth/generic_oauthcallback.php
new file mode 100644
index 00000000000..9d66bb07302
--- /dev/null
+++ b/htdocs/core/modules/oauth/generic_oauthcallback.php
@@ -0,0 +1,193 @@
+
+ * Copyright (C) 2015 Frederic France
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+/**
+ * \file htdocs/core/modules/oauth/generic_oauthcallback.php
+ * \ingroup oauth
+ * \brief Page to get oauth callback
+ */
+
+require '../../../main.inc.php';
+require_once DOL_DOCUMENT_ROOT.'/includes/OAuth/bootstrap.php';
+use OAuth\Common\Storage\DoliStorage;
+use OAuth\Common\Consumer\Credentials;
+use OAuth\OAuth2\Service\GitHub;
+
+// Define $urlwithroot
+$urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
+$urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
+//$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
+
+
+$action = GETPOST('action', 'aZ09');
+$backtourl = GETPOST('backtourl', 'alpha');
+$keyforprovider = GETPOST('keyforprovider', 'aZ09');
+if (empty($keyforprovider) && !empty($_SESSION["oauthkeyforproviderbeforeoauthjump"]) && (GETPOST('code') || $action == 'delete')) {
+ $keyforprovider = $_SESSION["oauthkeyforproviderbeforeoauthjump"];
+}
+$genericstring = 'OTHER';
+
+
+/**
+ * Create a new instance of the URI class with the current URI, stripping the query string
+ */
+$uriFactory = new \OAuth\Common\Http\Uri\UriFactory();
+//$currentUri = $uriFactory->createFromSuperGlobalArray($_SERVER);
+//$currentUri->setQuery('');
+$currentUri = $uriFactory->createFromAbsolute($urlwithroot.'/core/modules/oauth/generic_oauthcallback.php');
+
+
+/**
+ * Load the credential for the service
+ */
+
+/** @var $serviceFactory \OAuth\ServiceFactory An OAuth service factory. */
+$serviceFactory = new \OAuth\ServiceFactory();
+$httpClient = new \OAuth\Common\Http\Client\CurlClient();
+// TODO Set options for proxy and timeout
+// $params=array('CURLXXX'=>value, ...)
+//$httpClient->setCurlParameters($params);
+$serviceFactory->setHttpClient($httpClient);
+
+// Dolibarr storage
+$storage = new DoliStorage($db, $conf);
+
+// Setup the credentials for the requests
+$keyforparamid = 'OAUTH_'.$genericstring.($keyforprovider ? '-'.$keyforprovider : '').'_ID';
+$keyforparamsecret = 'OAUTH_'.$genericstring.($keyforprovider ? '-'.$keyforprovider : '').'_SECRET';
+$credentials = new Credentials(
+ getDolGlobalString($keyforparamid),
+ getDolGlobalString($keyforparamsecret),
+ $currentUri->getAbsoluteUri()
+);
+
+$requestedpermissionsarray = array();
+if (GETPOST('state')) {
+ $requestedpermissionsarray = explode(',', GETPOST('state')); // Example: 'user'. 'state' parameter is standard to retrieve some parameters back
+}
+if ($action != 'delete' && empty($requestedpermissionsarray)) {
+ print 'Error, parameter state is not defined';
+ exit;
+}
+//var_dump($requestedpermissionsarray);exit;
+
+// Instantiate the Api service using the credentials, http client and storage mechanism for the token
+$apiService = $serviceFactory->createService($genericstring, $credentials, $storage, $requestedpermissionsarray);
+
+/*
+var_dump($genericstring.($keyforprovider ? '-'.$keyforprovider : ''));
+var_dump($credentials);
+var_dump($storage);
+var_dump($requestedpermissionsarray);
+*/
+
+if (empty($apiService)) {
+ print 'Error, failed to create serviceFactory';
+ exit;
+}
+
+// access type needed to have oauth provider refreshing token
+//$apiService->setAccessType('offline');
+
+$langs->load("oauth");
+
+if (!getDolGlobalString($keyforparamid)) {
+ accessforbidden('Setup of service is not complete. Customer ID is missing');
+}
+if (!getDolGlobalString($keyforparamsecret)) {
+ accessforbidden('Setup of service is not complete. Secret key is missing');
+}
+
+
+/*
+ * Actions
+ */
+
+if ($action == 'delete') {
+ $storage->clearToken($genericstring);
+
+ setEventMessages($langs->trans('TokenDeleted'), null, 'mesgs');
+
+ header('Location: '.$backtourl);
+ exit();
+}
+
+if (GETPOST('code')) { // We are coming from oauth provider page
+ // We should have
+ //$_GET=array('code' => string 'aaaaaaaaaaaaaa' (length=20), 'state' => string 'user,public_repo' (length=16))
+
+ dol_syslog("We are coming from the oauth provider page");
+ //llxHeader('',$langs->trans("OAuthSetup"));
+
+ //$linkback=''.$langs->trans("BackToModuleList").' ';
+ //print load_fiche_titre($langs->trans("OAuthSetup"),$linkback,'title_setup');
+
+ //print dol_get_fiche_head();
+ // retrieve the CSRF state parameter
+ $state = GETPOSTISSET('state') ? GETPOST('state') : null;
+ //print '';
+
+ // This was a callback request from service, get the token
+ try {
+ //var_dump($_GET['code']);
+ //var_dump($state);
+ //var_dump($apiService); // OAuth\OAuth2\Service\GitHub
+
+ //$token = $apiService->requestAccessToken(GETPOST('code'), $state);
+ $token = $apiService->requestAccessToken(GETPOST('code'));
+ // Github is a service that does not need state to be stored.
+ // Into constructor of GitHub, the call
+ // parent::__construct($credentials, $httpClient, $storage, $scopes, $baseApiUri)
+ // has not the ending parameter to true like the Google class constructor.
+
+ setEventMessages($langs->trans('NewTokenStored'), null, 'mesgs'); // Stored into object managed by class DoliStorage so into table oauth_token
+
+ $backtourl = $_SESSION["backtourlsavedbeforeoauthjump"];
+ unset($_SESSION["backtourlsavedbeforeoauthjump"]);
+
+ header('Location: '.$backtourl);
+ exit();
+ } catch (Exception $e) {
+ print $e->getMessage();
+ }
+} else { // If entry on page with no parameter, we arrive here
+ $_SESSION["backtourlsavedbeforeoauthjump"] = $backtourl;
+ $_SESSION["oauthkeyforproviderbeforeoauthjump"] = $keyforprovider;
+ $_SESSION['oauthstateanticsrf'] = $state;
+
+ // This may create record into oauth_state before the header redirect.
+ // Creation of record with state in this tables depend on the Provider used (see its constructor).
+ if (GETPOST('state')) {
+ $url = $apiService->getAuthorizationUri(array('state' => GETPOST('state')));
+ } else {
+ $url = $apiService->getAuthorizationUri(); // Parameter state will be randomly generated
+ }
+
+ // we go on oauth provider authorization page
+ header('Location: '.$url);
+ exit();
+}
+
+
+/*
+ * View
+ */
+
+// No view at all, just actions
+
+$db->close();
diff --git a/htdocs/core/modules/oauth/github_oauthcallback.php b/htdocs/core/modules/oauth/github_oauthcallback.php
index 5c24e23aafa..f496c42d0ac 100644
--- a/htdocs/core/modules/oauth/github_oauthcallback.php
+++ b/htdocs/core/modules/oauth/github_oauthcallback.php
@@ -1,5 +1,5 @@
* Copyright (C) 2015 Frederic France
*
* This program is free software; you can redistribute it and/or modify
@@ -86,7 +86,7 @@ if ($action != 'delete' && empty($requestedpermissionsarray)) {
//var_dump($requestedpermissionsarray);exit;
// Instantiate the Api service using the credentials, http client and storage mechanism for the token
-$apiService = $serviceFactory->createService('GitHub'.($keyforprovider ? '-'.$keyforprovider : ''), $credentials, $storage, $requestedpermissionsarray);
+$apiService = $serviceFactory->createService('GitHub', $credentials, $storage, $requestedpermissionsarray);
// access type needed to have oauth provider refreshing token
//$apiService->setAccessType('offline');
diff --git a/htdocs/core/modules/oauth/google_oauthcallback.php b/htdocs/core/modules/oauth/google_oauthcallback.php
index 2812c4f7163..9208a6110a9 100644
--- a/htdocs/core/modules/oauth/google_oauthcallback.php
+++ b/htdocs/core/modules/oauth/google_oauthcallback.php
@@ -1,5 +1,5 @@
* Copyright (C) 2015 Frederic France
*
* This program is free software; you can redistribute it and/or modify
diff --git a/htdocs/core/modules/oauth/stripelive_oauthcallback.php b/htdocs/core/modules/oauth/stripelive_oauthcallback.php
index bf9656df783..f24921faf83 100644
--- a/htdocs/core/modules/oauth/stripelive_oauthcallback.php
+++ b/htdocs/core/modules/oauth/stripelive_oauthcallback.php
@@ -1,5 +1,5 @@
* Copyright (C) 2019 Thibault FOUCART
*
* This program is free software; you can redistribute it and/or modify
diff --git a/htdocs/core/modules/oauth/stripetest_oauthcallback.php b/htdocs/core/modules/oauth/stripetest_oauthcallback.php
index 64d55fba760..b41b579857e 100644
--- a/htdocs/core/modules/oauth/stripetest_oauthcallback.php
+++ b/htdocs/core/modules/oauth/stripetest_oauthcallback.php
@@ -1,5 +1,5 @@
* Copyright (C) 2015 Frederic France
*
* This program is free software; you can redistribute it and/or modify
diff --git a/htdocs/core/modules/printing/printgcp.modules.php b/htdocs/core/modules/printing/printgcp.modules.php
index 964558de8df..391f5b435d7 100644
--- a/htdocs/core/modules/printing/printgcp.modules.php
+++ b/htdocs/core/modules/printing/printgcp.modules.php
@@ -137,7 +137,6 @@ class printing_printgcp extends PrintingDriver
$this->errors[] = $e->getMessage();
$token_ok = false;
}
- //var_dump($this->errors);exit;
$expire = false;
// Is token expired or will token expire in the next 30 seconds
diff --git a/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php b/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php
index d00eee45219..420dfd61909 100644
--- a/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php
+++ b/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php
@@ -37,7 +37,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/doc.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
-if (!empty($conf->propal->enabled)) {
+if (isModEnabled("propal")) {
require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
}
if (isModEnabled('facture')) {
@@ -49,10 +49,10 @@ if (isModEnabled('facture')) {
if (!empty($conf->commande->enabled)) {
require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
}
-if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_invoice->enabled)) {
+if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_invoice")) {
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
}
-if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled)) {
+if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order")) {
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
}
if (!empty($conf->contrat->enabled)) {
@@ -971,13 +971,13 @@ class doc_generic_project_odt extends ModelePDFProjects
'title' => "ListSupplierOrdersAssociatedProject",
'table' => 'commande_fournisseur',
'class' => 'CommandeFournisseur',
- 'test' => (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->rights->fournisseur->commande->lire) || (!empty($conf->supplier_order->enabled) && $user->rights->supplier_order->lire)
+ 'test' => (isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->rights->fournisseur->commande->lire) || (isModEnabled("supplier_order") && $user->rights->supplier_order->lire)
),
'invoice_supplier' => array(
'title' => "ListSupplierInvoicesAssociatedProject",
'table' => 'facture_fourn',
'class' => 'FactureFournisseur',
- 'test' => (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->rights->fournisseur->facture->lire) || (!empty($conf->supplier_invoice->enabled) && $user->rights->supplier_invoice->lire)
+ 'test' => (isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->rights->fournisseur->facture->lire) || (isModEnabled("supplier_invoice") && $user->rights->supplier_invoice->lire)
),
'contract' => array(
'title' => "ListContractAssociatedProject",
diff --git a/htdocs/core/modules/project/doc/pdf_beluga.modules.php b/htdocs/core/modules/project/doc/pdf_beluga.modules.php
index fba5e02b098..1dc5b7bf3f9 100644
--- a/htdocs/core/modules/project/doc/pdf_beluga.modules.php
+++ b/htdocs/core/modules/project/doc/pdf_beluga.modules.php
@@ -407,7 +407,7 @@ class pdf_beluga extends ModelePDFProjects
'class'=>'CommandeFournisseur',
'table'=>'commande_fournisseur',
'datefieldname'=>'date_commande',
- 'test'=>(!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->rights->fournisseur->commande->lire) || (!empty($conf->supplier_order->enabled) && $user->rights->supplier_order->lire),
+ 'test'=>(isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->rights->fournisseur->commande->lire) || (isModEnabled("supplier_order") && $user->rights->supplier_order->lire),
'lang'=>'orders'),
'invoice_supplier'=>array(
'name'=>"BillsSuppliers",
@@ -416,7 +416,7 @@ class pdf_beluga extends ModelePDFProjects
'margin'=>'minus',
'table'=>'facture_fourn',
'datefieldname'=>'datef',
- 'test'=>(!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->rights->fournisseur->facture->lire) || (!empty($conf->supplier_invoice->enabled) && $user->rights->supplier_invoice->lire),
+ 'test'=>(isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->rights->fournisseur->facture->lire) || (isModEnabled("supplier_invoice") && $user->rights->supplier_invoice->lire),
'lang'=>'bills'),
'contract'=>array(
'name'=>"Contracts",
diff --git a/htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php b/htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php
index 410d3ae5b29..8433aaa6331 100644
--- a/htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php
+++ b/htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php
@@ -38,7 +38,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/doc.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
-if (!empty($conf->propal->enabled)) {
+if (isModEnabled("propal")) {
require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
}
if (isModEnabled('facture')) {
@@ -50,10 +50,10 @@ if (isModEnabled('facture')) {
if (!empty($conf->commande->enabled)) {
require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
}
-if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_invoice->enabled)) {
+if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_invoice")) {
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
}
-if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled)) {
+if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order")) {
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
}
if (!empty($conf->contrat->enabled)) {
diff --git a/htdocs/core/modules/propale/doc/pdf_azur.modules.php b/htdocs/core/modules/propale/doc/pdf_azur.modules.php
index 177443153ce..bb6389a2e67 100644
--- a/htdocs/core/modules/propale/doc/pdf_azur.modules.php
+++ b/htdocs/core/modules/propale/doc/pdf_azur.modules.php
@@ -815,15 +815,15 @@ class pdf_azur extends ModelePDFPropales
foreach ($filetomerge->lines as $linefile) {
if (!empty($linefile->id) && !empty($linefile->file_name)) {
if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) {
- if (!empty($conf->product->enabled)) {
+ if (isModEnabled("product")) {
$filetomerge_dir = $conf->product->multidir_output[$entity_product_file].'/'.get_exdir($product->id, 2, 0, 0, $product, 'product').$product->id."/photos";
- } elseif (!empty($conf->service->enabled)) {
+ } elseif (isModEnabled("service")) {
$filetomerge_dir = $conf->service->multidir_output[$entity_product_file].'/'.get_exdir($product->id, 2, 0, 0, $product, 'product').$product->id."/photos";
}
} else {
- if (!empty($conf->product->enabled)) {
+ if (isModEnabled("product")) {
$filetomerge_dir = $conf->product->multidir_output[$entity_product_file].'/'.get_exdir(0, 0, 0, 0, $product, 'product');
- } elseif (!empty($conf->service->enabled)) {
+ } elseif (isModEnabled("service")) {
$filetomerge_dir = $conf->service->multidir_output[$entity_product_file].'/'.get_exdir(0, 0, 0, 0, $product, 'product');
}
}
diff --git a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php
index 1ed76728b92..7be7170edb2 100644
--- a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php
+++ b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php
@@ -940,15 +940,15 @@ class pdf_cyan extends ModelePDFPropales
foreach ($filetomerge->lines as $linefile) {
if (!empty($linefile->id) && !empty($linefile->file_name)) {
if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) {
- if (!empty($conf->product->enabled)) {
+ if (isModEnabled("product")) {
$filetomerge_dir = $conf->product->multidir_output[$entity_product_file].'/'.get_exdir($product->id, 2, 0, 0, $product, 'product').$product->id."/photos";
- } elseif (!empty($conf->service->enabled)) {
+ } elseif (isModEnabled("service")) {
$filetomerge_dir = $conf->service->multidir_output[$entity_product_file].'/'.get_exdir($product->id, 2, 0, 0, $product, 'product').$product->id."/photos";
}
} else {
- if (!empty($conf->product->enabled)) {
+ if (isModEnabled("product")) {
$filetomerge_dir = $conf->product->multidir_output[$entity_product_file].'/'.get_exdir(0, 0, 0, 0, $product, 'product');
- } elseif (!empty($conf->service->enabled)) {
+ } elseif (isModEnabled("service")) {
$filetomerge_dir = $conf->service->multidir_output[$entity_product_file].'/'.get_exdir(0, 0, 0, 0, $product, 'product');
}
}
diff --git a/htdocs/core/modules/propale/mod_propale_saphir.php b/htdocs/core/modules/propale/mod_propale_saphir.php
index af7579fb142..2cb10e3d932 100644
--- a/htdocs/core/modules/propale/mod_propale_saphir.php
+++ b/htdocs/core/modules/propale/mod_propale_saphir.php
@@ -85,7 +85,8 @@ class mod_propale_saphir extends ModeleNumRefPropales
// Parametrage du prefix
$texte .= ''.$langs->trans("Mask").': ';
- $texte .= ''.$form->textwithpicto(' ', $tooltip, 1, 1).' ';
+ $mask = empty($conf->global->PROPALE_SAPHIR_MASK) ? '' : $conf->global->PROPALE_SAPHIR_MASK;
+ $texte .= ''.$form->textwithpicto(' ', $tooltip, 1, 1).' ';
$texte .= ' ';
@@ -134,7 +135,7 @@ class mod_propale_saphir extends ModeleNumRefPropales
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
// On defini critere recherche compteur
- $mask = $conf->global->PROPALE_SAPHIR_MASK;
+ $mask = empty($conf->global->PROPALE_SAPHIR_MASK) ? '' : $conf->global->PROPALE_SAPHIR_MASK;
if (!$mask) {
$this->error = 'NotConfigured';
diff --git a/htdocs/core/modules/rapport/pdf_paiement.class.php b/htdocs/core/modules/rapport/pdf_paiement.class.php
index 215987054ce..e4991a5830d 100644
--- a/htdocs/core/modules/rapport/pdf_paiement.class.php
+++ b/htdocs/core/modules/rapport/pdf_paiement.class.php
@@ -185,14 +185,14 @@ class pdf_paiement
$sql .= ", c.code as paiement_code, p.num_paiement as num_payment";
$sql .= ", p.amount as paiement_amount, f.total_ttc as facture_amount";
$sql .= ", pf.amount as pf_amount";
- if (!empty($conf->banque->enabled)) {
+ if (isModEnabled("banque")) {
$sql .= ", ba.ref as bankaccount";
}
$sql .= ", p.rowid as prowid";
$sql .= " FROM ".MAIN_DB_PREFIX."paiement as p LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON p.fk_paiement = c.id";
$sql .= ", ".MAIN_DB_PREFIX."facture as f,";
$sql .= " ".MAIN_DB_PREFIX."paiement_facture as pf,";
- if (!empty($conf->banque->enabled)) {
+ if (isModEnabled("banque")) {
$sql .= " ".MAIN_DB_PREFIX."bank as b, ".MAIN_DB_PREFIX."bank_account as ba,";
}
$sql .= " ".MAIN_DB_PREFIX."societe as s";
@@ -200,7 +200,7 @@ class pdf_paiement
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= " WHERE f.fk_soc = s.rowid AND pf.fk_facture = f.rowid AND pf.fk_paiement = p.rowid";
- if (!empty($conf->banque->enabled)) {
+ if (isModEnabled("banque")) {
$sql .= " AND p.fk_bank = b.rowid AND b.fk_account = ba.rowid ";
}
$sql .= " AND f.entity IN (".getEntity('invoice').")";
@@ -223,14 +223,14 @@ class pdf_paiement
$sql .= ", c.code as paiement_code, p.num_paiement as num_payment";
$sql .= ", p.amount as paiement_amount, f.total_ttc as facture_amount";
$sql .= ", pf.amount as pf_amount";
- if (!empty($conf->banque->enabled)) {
+ if (isModEnabled("banque")) {
$sql .= ", ba.ref as bankaccount";
}
$sql .= ", p.rowid as prowid";
$sql .= " FROM ".MAIN_DB_PREFIX."paiementfourn as p LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON p.fk_paiement = c.id";
$sql .= ", ".MAIN_DB_PREFIX."facture_fourn as f,";
$sql .= " ".MAIN_DB_PREFIX."paiementfourn_facturefourn as pf,";
- if (!empty($conf->banque->enabled)) {
+ if (isModEnabled("banque")) {
$sql .= " ".MAIN_DB_PREFIX."bank as b, ".MAIN_DB_PREFIX."bank_account as ba,";
}
$sql .= " ".MAIN_DB_PREFIX."societe as s";
@@ -238,7 +238,7 @@ class pdf_paiement
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= " WHERE f.fk_soc = s.rowid AND pf.fk_facturefourn = f.rowid AND pf.fk_paiementfourn = p.rowid";
- if (!empty($conf->banque->enabled)) {
+ if (isModEnabled("banque")) {
$sql .= " AND p.fk_bank = b.rowid AND b.fk_account = ba.rowid ";
}
$sql .= " AND f.entity IN (".getEntity('invoice').")";
diff --git a/htdocs/core/modules/reception/doc/pdf_squille.modules.php b/htdocs/core/modules/reception/doc/pdf_squille.modules.php
index 61fab1ab02d..050459d91d2 100644
--- a/htdocs/core/modules/reception/doc/pdf_squille.modules.php
+++ b/htdocs/core/modules/reception/doc/pdf_squille.modules.php
@@ -856,20 +856,20 @@ class pdf_squille extends ModelePdfReception
}
// Show barcode
- if (!empty($conf->barcode->enabled)) {
+ if (isModEnabled('barcode')) {
$posx = 105;
} else {
$posx = $this->marge_gauche + 3;
}
//$pdf->Rect($this->marge_gauche, $this->marge_haute, $this->page_largeur-$this->marge_gauche-$this->marge_droite, 30);
- if (!empty($conf->barcode->enabled)) {
+ if (isModEnabled('barcode')) {
// TODO Build code bar with function writeBarCode of barcode module for reception ref $object->ref
//$pdf->SetXY($this->marge_gauche+3, $this->marge_haute+3);
//$pdf->Image($logo,10, 5, 0, 24);
}
$pdf->SetDrawColor(128, 128, 128);
- if (!empty($conf->barcode->enabled)) {
+ if (isModEnabled('barcode')) {
// TODO Build code bar with function writeBarCode of barcode module for reception ref $object->ref
//$pdf->SetXY($this->marge_gauche+3, $this->marge_haute+3);
//$pdf->Image($logo,10, 5, 0, 24);
@@ -917,7 +917,7 @@ class pdf_squille extends ModelePdfReception
$origin_id = $object->origin_id;
// TODO move to external function
- if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled)) { // commonly $origin='commande'
+ if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order")) { // commonly $origin='commande'
$outputlangs->load('orders');
$classname = 'CommandeFournisseur';
diff --git a/htdocs/core/modules/security/generate/modGeneratePassPerso.class.php b/htdocs/core/modules/security/generate/modGeneratePassPerso.class.php
index baa818aa63b..02b970ee2aa 100644
--- a/htdocs/core/modules/security/generate/modGeneratePassPerso.class.php
+++ b/htdocs/core/modules/security/generate/modGeneratePassPerso.class.php
@@ -98,8 +98,8 @@ class modGeneratePassPerso extends ModeleGenPassword
$this->user = $user;
if (empty($conf->global->USER_PASSWORD_PATTERN)) {
- // default value at auto generation (12 chars, 1 upercase, 1 digit, 1 special char, 3 repeat, exclude ambiguous characters).
- dolibarr_set_const($db, "USER_PASSWORD_PATTERN", '12;1;1;1;3;1', 'chaine', 0, '', $conf->entity);
+ // default value at auto generation (12 chars, 1 uppercase, 1 digit, 0 special char, 3 repeat max, exclude ambiguous characters).
+ dolibarr_set_const($db, "USER_PASSWORD_PATTERN", '12;1;1;0;3;1', 'chaine', 0, '', $conf->entity);
}
$this->Maj = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
diff --git a/htdocs/core/modules/stocktransfer/doc/pdf_eagle.modules.php b/htdocs/core/modules/stocktransfer/doc/pdf_eagle.modules.php
index c00bf34621e..7722698593c 100644
--- a/htdocs/core/modules/stocktransfer/doc/pdf_eagle.modules.php
+++ b/htdocs/core/modules/stocktransfer/doc/pdf_eagle.modules.php
@@ -944,20 +944,20 @@ class pdf_eagle extends ModelePdfStockTransfer
}
// Show barcode
- if (!empty($conf->barcode->enabled)) {
+ if (isModEnabled('barcode')) {
$posx = 105;
} else {
$posx = $this->marge_gauche + 3;
}
//$pdf->Rect($this->marge_gauche, $this->marge_haute, $this->page_largeur-$this->marge_gauche-$this->marge_droite, 30);
- if (!empty($conf->barcode->enabled)) {
+ if (isModEnabled('barcode')) {
// TODO Build code bar with function writeBarCode of barcode module for sending ref $object->ref
//$pdf->SetXY($this->marge_gauche+3, $this->marge_haute+3);
//$pdf->Image($logo,10, 5, 0, 24);
}
$pdf->SetDrawColor(128, 128, 128);
- if (!empty($conf->barcode->enabled)) {
+ if (isModEnabled('barcode')) {
// TODO Build code bar with function writeBarCode of barcode module for sending ref $object->ref
//$pdf->SetXY($this->marge_gauche+3, $this->marge_haute+3);
//$pdf->Image($logo,10, 5, 0, 24);
diff --git a/htdocs/core/modules/usergroup/doc/doc_generic_usergroup_odt.modules.php b/htdocs/core/modules/usergroup/doc/doc_generic_usergroup_odt.modules.php
index d56d8f8d4d1..df3804670ad 100644
--- a/htdocs/core/modules/usergroup/doc/doc_generic_usergroup_odt.modules.php
+++ b/htdocs/core/modules/usergroup/doc/doc_generic_usergroup_odt.modules.php
@@ -123,7 +123,7 @@ class doc_generic_usergroup_odt extends ModelePDFUserGroup
$texte .= ' ';
$texte .= ' ';
$texte .= ' ';
- if ($conf->global->MAIN_PROPAL_CHOOSE_ODT_DOCUMENT > 0) {
+ if (!empty($conf->global->MAIN_PROPAL_CHOOSE_ODT_DOCUMENT)) {
$texte .= ' ';
$texte .= ' ';
$texte .= ' ';
@@ -169,7 +169,7 @@ class doc_generic_usergroup_odt extends ModelePDFUserGroup
if (count($listofdir)) {
$texte .= $langs->trans("NumberOfModelFilesFound").': '.count($listoffiles).' ';
- if ($conf->global->MAIN_PROPAL_CHOOSE_ODT_DOCUMENT > 0) {
+ if (!empty($conf->global->MAIN_PROPAL_CHOOSE_ODT_DOCUMENT)) {
// Model for creation
$list = ModelePDFUserGroup::liste_modeles($this->db);
$texte .= '';
diff --git a/htdocs/core/multicompany_page.php b/htdocs/core/multicompany_page.php
index 4a3bcba51fb..690c971fd23 100644
--- a/htdocs/core/multicompany_page.php
+++ b/htdocs/core/multicompany_page.php
@@ -92,7 +92,7 @@ print '';
//print '
';
-if (empty($conf->multicompany->enabled)) {
+if (!isModEnabled('multicompany')) {
$langs->load("admin");
$bookmarkList .= '
'.$langs->trans("WarningModuleNotActive", $langs->transnoentitiesnoconv("MultiCompany")).' ';
$bookmarkList .= '
';
diff --git a/htdocs/core/photos_resize.php b/htdocs/core/photos_resize.php
index 6bedf368e97..e35d09d7e3f 100644
--- a/htdocs/core/photos_resize.php
+++ b/htdocs/core/photos_resize.php
@@ -56,13 +56,13 @@ if ($modulepart == 'produit' || $modulepart == 'product' || $modulepart == 'serv
$accessallowed = 1;
} elseif ($modulepart == 'project') {
$result = restrictedArea($user, 'projet', $id);
- if (!$user->rights->projet->lire) {
+ if (empty($user->rights->projet->lire)) {
accessforbidden();
}
$accessallowed = 1;
} elseif ($modulepart == 'bom') {
$result = restrictedArea($user, $modulepart, $id, 'bom_bom');
- if (!$user->rights->bom->read) {
+ if (empty($user->rights->bom->read)) {
accessforbidden();
}
$accessallowed = 1;
@@ -73,14 +73,14 @@ if ($modulepart == 'produit' || $modulepart == 'product' || $modulepart == 'serv
}
$accessallowed = 1;
} elseif ($modulepart == 'user') {
- $result = restrictedArea($user, $modulepart, $id, $modulepart);
- if (!$user->rights->user->user->lire) {
+ $result = restrictedArea($user, $modulepart, $id, $modulepart, $modulepart);
+ if (empty($user->rights->user->user->lire)) {
accessforbidden();
}
$accessallowed = 1;
} elseif ($modulepart == 'tax') {
$result = restrictedArea($user, $modulepart, $id, 'chargesociales', 'charges');
- if (!$user->rights->tax->charges->lire) {
+ if (empty($user->rights->tax->charges->lire)) {
accessforbidden();
}
$accessallowed = 1;
diff --git a/htdocs/core/tpl/admin_extrafields_add.tpl.php b/htdocs/core/tpl/admin_extrafields_add.tpl.php
index 1dbc0861adb..97748290bd7 100644
--- a/htdocs/core/tpl/admin_extrafields_add.tpl.php
+++ b/htdocs/core/tpl/admin_extrafields_add.tpl.php
@@ -205,7 +205,7 @@ $listofexamplesforlink = 'Societe:societe/class/societe.class.php
Contact:con
textwithpicto($langs->trans("HelpOnTooltip"), $langs->trans("HelpOnTooltipDesc")); ?>
-multicompany->enabled)) { ?>
+
trans("AllEntities"); ?> >
diff --git a/htdocs/core/tpl/admin_extrafields_edit.tpl.php b/htdocs/core/tpl/admin_extrafields_edit.tpl.php
index c055dd1d3b5..8dcc1edf017 100644
--- a/htdocs/core/tpl/admin_extrafields_edit.tpl.php
+++ b/htdocs/core/tpl/admin_extrafields_edit.tpl.php
@@ -197,9 +197,10 @@ $typewecanchangeinto = array(
'text'=>array('text', 'html'),
'html'=>array('text', 'html'),
'password'=>array('password', 'varchar'),
- 'mail'=>array('varchar', 'phone', 'mail', 'url', 'select'),
- 'url'=>array('varchar', 'phone', 'mail', 'url', 'select'),
- 'phone'=>array('varchar', 'phone', 'mail', 'url', 'select'),
+ 'mail'=>array('ip', 'varchar', 'phone', 'mail', 'url', 'select'),
+ 'url'=>array('ip', 'varchar', 'phone', 'mail', 'url', 'select'),
+ 'phone'=>array('ip', 'varchar', 'phone', 'mail', 'url', 'select'),
+ 'ip'=>array('ip', 'varchar', 'phone', 'mail', 'url', 'select'),
'select'=>array('varchar', 'phone', 'mail', 'url', 'select'),
'date'=>array('date', 'datetime')
);
@@ -295,7 +296,7 @@ if (in_array($type, array_keys($typewecanchangeinto))) {
textwithpicto($langs->trans("HelpOnTooltip"), $langs->trans("HelpOnTooltipDesc")); ?>
-multicompany->enabled)) { ?>
+
trans("AllEntities"); ?> >
diff --git a/htdocs/core/tpl/admin_extrafields_view.tpl.php b/htdocs/core/tpl/admin_extrafields_view.tpl.php
index da1d2d58558..285b7eb30a4 100644
--- a/htdocs/core/tpl/admin_extrafields_view.tpl.php
+++ b/htdocs/core/tpl/admin_extrafields_view.tpl.php
@@ -65,7 +65,7 @@ print '
'.$langs->trans("AlwaysEditable").' ';
print '
'.$form->textwithpicto($langs->trans("Visible"), $langs->trans("VisibleDesc")).' ';
print '
'.$form->textwithpicto($langs->trans("DisplayOnPdf"), $langs->trans("DisplayOnPdfDesc")).' ';
print '
'.$form->textwithpicto($langs->trans("Totalizable"), $langs->trans("TotalizableDesc")).' ';
-if (!empty($conf->multicompany->enabled)) {
+if (isModEnabled('multicompany')) {
print '
'.$langs->trans("Entity").' ';
}
print '
';
@@ -113,7 +113,7 @@ if (isset($extrafields->attributes[$elementtype]['type']) && is_array($extrafiel
print '
'.dol_escape_htmltag($extrafields->attributes[$elementtype]['printable'][$key])." \n";
// Summable
print '
'.yn($extrafields->attributes[$elementtype]['totalizable'][$key])." \n";
- if (!empty($conf->multicompany->enabled)) {
+ if (isModEnabled('multicompany')) {
print '
';
if (empty($extrafields->attributes[$elementtype]['entityid'][$key])) {
print $langs->trans("All");
@@ -139,7 +139,7 @@ if (isset($extrafields->attributes[$elementtype]['type']) && is_array($extrafiel
}
} else {
$colspan = 14;
- if (!empty($conf->multicompany->enabled)) {
+ if (isModEnabled('multicompany')) {
$colspan++;
}
diff --git a/htdocs/core/tpl/card_presend.tpl.php b/htdocs/core/tpl/card_presend.tpl.php
index 0376a5e85c9..5fbb227bc69 100644
--- a/htdocs/core/tpl/card_presend.tpl.php
+++ b/htdocs/core/tpl/card_presend.tpl.php
@@ -146,6 +146,11 @@ if ($action == 'presend') {
$formmail->fromname = (!empty($conf->global->ORDER_SUPPLIER_EMAIL_SENDER_NAME) ? $conf->global->ORDER_SUPPLIER_EMAIL_SENDER_NAME : '');
$formmail->fromtype = 'special';
}
+ if ($object->element === 'recruitmentcandidature' ) {
+ $formmail->frommail = (!empty($conf->global->RECRUITMENT_EMAIL_SENDER) ? $conf->global->RECRUITMENT_EMAIL_SENDER : $recruitermail);
+ $formmail->fromname = (!empty($conf->global->RECRUITMENT_EMAIL_SENDER_NAME) ? $conf->global->RECRUITMENT_EMAIL_SENDER_NAME : (!empty($recruitername) ? $recruitername : ''));
+ $formmail->fromtype = 'special';
+ }
$formmail->trackid = empty($trackid) ? '' : $trackid;
$formmail->inreplyto = empty($inreplyto) ? '' : $inreplyto;
@@ -198,7 +203,7 @@ if ($action == 'presend') {
}
$formmail->withto = $liste;
- $formmail->withtofree = (GETPOSTISSET('sendto') ? (GETPOST('sendto', 'alphawithlgt') ? GETPOST('sendto', 'alphawithlgt') : '1') : '1');
+ $formmail->withtofree = (GETPOST('sendto', 'alphawithlgt') ? GETPOST('sendto', 'alphawithlgt') : '1');
$formmail->withtocc = $liste;
$formmail->withtoccc = getDolGlobalString('MAIN_EMAIL_USECCC');
$formmail->withtopic = $topicmail;
diff --git a/htdocs/core/tpl/extrafields_list_print_fields.tpl.php b/htdocs/core/tpl/extrafields_list_print_fields.tpl.php
index 2a12a07fd23..67d41199594 100644
--- a/htdocs/core/tpl/extrafields_list_print_fields.tpl.php
+++ b/htdocs/core/tpl/extrafields_list_print_fields.tpl.php
@@ -67,7 +67,7 @@ if (!empty($extrafieldsobjectkey) && !empty($extrafields->attributes[$extrafield
// we keep position for the first line
$totalarray['totalizable'][$key]['pos'] = $totalarray['nbfield'];
}
- if (is_numeric($obj->$tmpkey)) {
+ if (isset($obj->$tmpkey) && is_numeric($obj->$tmpkey)) {
if (!isset($totalarray['totalizable'][$key]['total'])) {
$totalarray['totalizable'][$key]['total'] = 0;
}
diff --git a/htdocs/core/tpl/list_print_total.tpl.php b/htdocs/core/tpl/list_print_total.tpl.php
index 8d84228e2ec..288f3b8f72e 100644
--- a/htdocs/core/tpl/list_print_total.tpl.php
+++ b/htdocs/core/tpl/list_print_total.tpl.php
@@ -3,7 +3,7 @@
if (!empty($totalarray['totalizable']) && is_array($totalarray['totalizable'])) {
foreach ($totalarray['totalizable'] as $keytotalizable => $valtotalizable) {
$totalarray['pos'][$valtotalizable['pos']] = $keytotalizable;
- $totalarray['val'][$keytotalizable] = $valtotalizable['total'];
+ $totalarray['val'][$keytotalizable] = isset($valtotalizable['total']) ? $valtotalizable['total'] : 0;
}
}
// Show total line
diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php
index 2956e71178f..cb38d7a3546 100644
--- a/htdocs/core/tpl/objectline_create.tpl.php
+++ b/htdocs/core/tpl/objectline_create.tpl.php
@@ -48,6 +48,7 @@ if (!isset($dateSelector)) {
global $dateSelector; // Take global var only if not already defined into function calling (for example formAddObjectLine)
}
global $forceall, $forcetoshowtitlelines, $senderissupplier, $inputalsopricewithtax;
+
if (!isset($dateSelector)) {
$dateSelector = 1; // For backward compatibility
} elseif (empty($dateSelector)) {
@@ -192,7 +193,7 @@ if ($nolinesbefore) {
// Free line
echo '';
// Show radio free line
- if ($forceall >= 0 && (!empty($conf->product->enabled) || !empty($conf->service->enabled))) {
+ if ($forceall >= 0 && (isModEnabled("product") || isModEnabled("service"))) {
echo '';
echo ' product->enabled) || empty($conf->service->enabled)))?' checked':'') );
@@ -218,7 +219,7 @@ if ($nolinesbefore) {
echo ' ';
}
// Predefined product/service
- if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) {
+ if (isModEnabled("product") || isModEnabled("service")) {
if ($forceall >= 0 && $freelines) {
echo '';
} else {
@@ -229,17 +230,17 @@ if ($nolinesbefore) {
$labelforradio = '';
if (empty($conf->dol_optimize_smallscreen)) {
if (empty($senderissupplier)) {
- if (!empty($conf->product->enabled) && empty($conf->service->enabled)) {
+ if (isModEnabled("product") && empty($conf->service->enabled)) {
$labelforradio = $langs->trans('PredefinedProductsToSell');
- } elseif ((empty($conf->product->enabled) && !empty($conf->service->enabled)) || ($object->element == 'contrat' && empty($conf->global->CONTRACT_SUPPORT_PRODUCTS))) {
+ } elseif ((empty($conf->product->enabled) && isModEnabled("service")) || ($object->element == 'contrat' && empty($conf->global->CONTRACT_SUPPORT_PRODUCTS))) {
$labelforradio = $langs->trans('PredefinedServicesToSell');
} else {
$labelforradio = $langs->trans('PredefinedProductsAndServicesToSell');
}
} else {
- if (!empty($conf->product->enabled) && empty($conf->service->enabled)) {
+ if (isModEnabled("product") && empty($conf->service->enabled)) {
$labelforradio = $langs->trans('PredefinedProductsToPurchase');
- } elseif (empty($conf->product->enabled) && !empty($conf->service->enabled)) {
+ } elseif (empty($conf->product->enabled) && isModEnabled("service")) {
$labelforradio = $langs->trans('PredefinedServicesToPurchase');
} else {
$labelforradio = $langs->trans('PredefinedProductsAndServicesToPurchase');
@@ -335,7 +336,7 @@ if ($nolinesbefore) {
print $hookmanager->resPrint;
}
}
- if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) {
+ if (isModEnabled("product") || isModEnabled("service")) {
echo ' ';
if (!empty($conf->variants->enabled)) {
echo '
';
@@ -355,7 +356,7 @@ if ($nolinesbefore) {
$doleditor = new DolEditor('dp_desc', GETPOST('dp_desc', 'restricthtml'), '', (empty($conf->global->MAIN_DOLEDITOR_HEIGHT) ? 100 : $conf->global->MAIN_DOLEDITOR_HEIGHT), $toolbarname, '', false, true, $enabled, $nbrows, '98%');
$doleditor->Create();
// Show autofill date for recurring invoices
- if (!empty($conf->service->enabled) && ($object->element == 'facturerec' || $object->element == 'invoice_supplier_rec')) {
+ if (isModEnabled("service") && ($object->element == 'facturerec' || $object->element == 'invoice_supplier_rec')) {
echo '';
echo $langs->trans('AutoFillDateFrom').' ';
if (!empty($conf->global->INVOICE_REC_DATE_TO_YES)) {
@@ -445,7 +446,7 @@ if ($nolinesbefore) {
?>
- product->enabled) || !empty($conf->service->enabled)) { ?>
+
@@ -470,7 +471,7 @@ if ($nolinesbefore) {
service->enabled) || ($object->element == 'contrat')) && $dateSelector && GETPOST('type') != '0') { // We show date field if required
+if ((isModEnabled("service") || ($object->element == 'contrat')) && $dateSelector && GETPOST('type') != '0') { // We show date field if required
print ' '."\n";
if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) {
print ' ';
@@ -734,7 +735,7 @@ if (!empty($usemargins) && $user->rights->margins->creer) {
$.post('/product/ajax/products.php?action=fetch',
{ 'id': $(this).val(), 'socid': socid; ?> },
function(data) {
- console.log("Load unit price end, we got value "+data.price_ht);
+ console.log("Load unit price end, we got value ht="+data.price_ht+" ttc="+data.price_ttc+" pricebasetype="+data.pricebasetype);
$('#date_start').removeAttr('type');
$('#date_end').removeAttr('type');
@@ -755,7 +756,11 @@ if (!empty($usemargins) && $user->rights->margins->creer) {
jQuery('#date_end').removeClass('inputmandatory');
}
- jQuery("#price_ht").val(data.price_ht);
+ if ( == 1 && data.pricebasetype == 'TTC') {
+ jQuery("#price_ttc").val(data.price_ttc);
+ } else {
+ jQuery("#price_ht").val(data.price_ht);
+ }
global->PRODUIT_AUTOFILL_DESC) && $conf->global->PRODUIT_AUTOFILL_DESC == 1) {
if (!empty($conf->global->MAIN_MULTILANGS) && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { ?>
diff --git a/htdocs/core/tpl/objectline_edit.tpl.php b/htdocs/core/tpl/objectline_edit.tpl.php
index c59949d5fb7..761be27b512 100644
--- a/htdocs/core/tpl/objectline_edit.tpl.php
+++ b/htdocs/core/tpl/objectline_edit.tpl.php
@@ -1,6 +1,6 @@
- * Copyright (C) 2010-2020 Laurent Destailleur
+ * Copyright (C) 2010-2022 Laurent Destailleur
* Copyright (C) 2012 Christophe Battarel
* Copyright (C) 2012 Cédric Salvador
* Copyright (C) 2012-2014 Raphaël Doursenaud
@@ -176,7 +176,7 @@ $coldisplay++;
}
// Show autofill date for recuring invoices
- if (!empty($conf->service->enabled) && $line->product_type == 1 && ($line->element == 'facturedetrec' || $line->element == 'invoice_supplier_det_rec')) {
+ if (isModEnabled("service") && $line->product_type == 1 && ($line->element == 'facturedetrec' || $line->element == 'invoice_supplier_det_rec')) {
if ($line->element == 'invoice_supplier_det_rec') {
$line->date_start_fill = $line->date_start;
$line->date_end_fill = $line->date_end;
@@ -290,7 +290,7 @@ $coldisplay++;
?>
- product->enabled) || !empty($conf->service->enabled)) { ?>
+
@@ -325,12 +325,12 @@ $coldisplay++;
- ">
- ">
+ ">
+ ">
-service->enabled) && $line->product_type == 1 && $dateSelector) { ?>
+product_type == 1 && $dateSelector) { ?>
global->MAIN_VIEW_LINE_NUMBER)) { ?>
diff --git a/htdocs/core/tpl/objectline_title.tpl.php b/htdocs/core/tpl/objectline_title.tpl.php
index 0071b37ab9b..762e9b4eefa 100644
--- a/htdocs/core/tpl/objectline_title.tpl.php
+++ b/htdocs/core/tpl/objectline_title.tpl.php
@@ -61,7 +61,7 @@ if ($this->element == 'supplier_proposal' || $this->element == 'order_supplier'
}
// VAT
-print '';
+print ' ';
if (!empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) || !empty($conf->global->FACTURE_LOCAL_TAX2_OPTION)) {
print $langs->trans('Taxes');
} else {
@@ -85,7 +85,7 @@ if (in_array($object->element, array('propal', 'commande', 'facture')) && $objec
print ' ';
// Price HT
-print ''.$langs->trans('PriceUHT').' ';
+print ''.$langs->trans('PriceUHT').' ';
// Multicurrency
if (!empty($conf->multicurrency->enabled) && $this->multicurrency_code != $conf->currency) {
@@ -93,7 +93,7 @@ if (!empty($conf->multicurrency->enabled) && $this->multicurrency_code != $conf-
}
if ($inputalsopricewithtax) {
- print ''.$langs->trans('PriceUTTC').' ';
+ print ''.$langs->trans('PriceUTTC').' ';
}
// Qty
@@ -105,7 +105,7 @@ if (!empty($conf->global->PRODUCT_USE_UNITS)) {
}
// Reduction short
-print '';
+print ' ';
print $langs->trans('ReductionShort');
if (in_array($object->element, array('propal', 'commande', 'facture')) && $object->status == $object::STATUS_DRAFT) {
diff --git a/htdocs/core/tpl/objectline_view.tpl.php b/htdocs/core/tpl/objectline_view.tpl.php
index c2d81b81eb5..c93e0d5c4cd 100644
--- a/htdocs/core/tpl/objectline_view.tpl.php
+++ b/htdocs/core/tpl/objectline_view.tpl.php
@@ -280,17 +280,17 @@ print vatrate($positiverates.($line->vat_src_code ? ' ('.$line->vat_src_code.')'
//print vatrate($line->tva_tx.($line->vat_src_code?(' ('.$line->vat_src_code.')'):''), '%', $line->info_bits);
?>
- subprice); ?>
+ subprice); ?>
multicurrency->enabled) && $this->multicurrency_code != $conf->currency) { ?>
- multicurrency_subprice); ?>
+ multicurrency_subprice); ?>
- pu_ttc) ? price($sign * $line->pu_ttc) : price($sign * $line->subprice)); ?>
+ pu_ttc) ? price($sign * $line->pu_ttc) : price($sign * $line->subprice)); ?>
-
+
info_bits & 2) != 2) && $line->special_code != 3) {
// I comment this because it shows info even when not required
diff --git a/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php b/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php
index cc6a1168c32..9a8414c7a69 100644
--- a/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php
+++ b/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php
@@ -117,7 +117,7 @@ class InterfaceWorkflowManager extends DolibarrTriggers
// Order classify billed proposal
if ($action == 'ORDER_CLASSIFY_BILLED') {
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
- if (!empty($conf->propal->enabled) && !empty($conf->workflow->enabled) && !empty($conf->global->WORKFLOW_ORDER_CLASSIFY_BILLED_PROPAL)) {
+ if (isModEnabled("propal") && !empty($conf->workflow->enabled) && !empty($conf->global->WORKFLOW_ORDER_CLASSIFY_BILLED_PROPAL)) {
$object->fetchObjectLinked('', 'propal', $object->id, $object->element);
if (!empty($object->linkedObjects)) {
$totalonlinkedelements = 0;
@@ -161,7 +161,7 @@ class InterfaceWorkflowManager extends DolibarrTriggers
}
// Second classify billed the proposal.
- if (!empty($conf->propal->enabled) && !empty($conf->workflow->enabled) && !empty($conf->global->WORKFLOW_INVOICE_CLASSIFY_BILLED_PROPAL)) {
+ if (isModEnabled("propal") && !empty($conf->workflow->enabled) && !empty($conf->global->WORKFLOW_INVOICE_CLASSIFY_BILLED_PROPAL)) {
$object->fetchObjectLinked('', 'propal', $object->id, $object->element);
if (!empty($object->linkedObjects)) {
$totalonlinkedelements = 0;
@@ -179,7 +179,7 @@ class InterfaceWorkflowManager extends DolibarrTriggers
}
}
- if (!empty($conf->expedition->enabled) && !empty($conf->workflow->enabled) && !empty($conf->global->WORKFLOW_SHIPPING_CLASSIFY_CLOSED_INVOICE)) {
+ if (isModEnabled("expedition") && !empty($conf->workflow->enabled) && !empty($conf->global->WORKFLOW_SHIPPING_CLASSIFY_CLOSED_INVOICE)) {
/** @var Facture $object */
$object->fetchObjectLinked('', 'shipping', $object->id, $object->element);
@@ -200,7 +200,7 @@ class InterfaceWorkflowManager extends DolibarrTriggers
// Firstly, we set to purchase order to "Billed" if WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_SUPPLIER_ORDER is set.
// After we will set proposals
- if (((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) && !empty($conf->global->WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_SUPPLIER_ORDER)) {
+ if (((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) && !empty($conf->global->WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_SUPPLIER_ORDER)) {
$object->fetchObjectLinked('', 'order_supplier', $object->id, $object->element);
if (!empty($object->linkedObjects)) {
$totalonlinkedelements = 0;
@@ -244,7 +244,7 @@ class InterfaceWorkflowManager extends DolibarrTriggers
}
// Then set reception to "Billed" if WORKFLOW_BILL_ON_RECEPTION is set
- if (!empty($conf->reception->enabled) && !empty($conf->global->WORKFLOW_BILL_ON_RECEPTION)) {
+ if (isModEnabled("reception") && !empty($conf->global->WORKFLOW_BILL_ON_RECEPTION)) {
$object->fetchObjectLinked('', 'reception', $object->id, $object->element);
if (!empty($object->linkedObjects)) {
$totalonlinkedelements = 0;
@@ -296,7 +296,7 @@ class InterfaceWorkflowManager extends DolibarrTriggers
if (($action == 'SHIPPING_VALIDATE') || ($action == 'SHIPPING_CLOSED')) {
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
- if (!empty($conf->commande->enabled) && !empty($conf->expedition->enabled) && !empty($conf->workflow->enabled) &&
+ if (!empty($conf->commande->enabled) && isModEnabled("expedition") && !empty($conf->workflow->enabled) &&
(
(!empty($conf->global->WORKFLOW_ORDER_CLASSIFY_SHIPPED_SHIPPING) && ($action == 'SHIPPING_VALIDATE')) ||
(!empty($conf->global->WORKFLOW_ORDER_CLASSIFY_SHIPPED_SHIPPING_CLOSED) && ($action == 'SHIPPING_CLOSED'))
@@ -365,7 +365,7 @@ class InterfaceWorkflowManager extends DolibarrTriggers
if (($action == 'RECEPTION_VALIDATE') || ($action == 'RECEPTION_CLOSED')) {
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
- if ((!empty($conf->fournisseur->enabled) || !empty($conf->supplier_order->enabled)) && !empty($conf->reception->enabled) && !empty($conf->workflow->enabled) &&
+ if ((isModEnabled("fournisseur") || isModEnabled("supplier_order")) && isModEnabled("reception") && !empty($conf->workflow->enabled) &&
(
(!empty($conf->global->WORKFLOW_ORDER_CLASSIFY_RECEIVED_RECEPTION) && ($action == 'RECEPTION_VALIDATE')) ||
(!empty($conf->global->WORKFLOW_ORDER_CLASSIFY_RECEIVED_RECEPTION_CLOSED) && ($action == 'RECEPTION_CLOSED'))
diff --git a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php
index 4e926050f24..49e2965787b 100644
--- a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php
+++ b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php
@@ -987,7 +987,7 @@ class InterfaceActionsAuto extends DolibarrTriggers
}
*/
- dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
+ dol_syslog("Trigger '".$this->name."' for action '".$action."' launched by ".__FILE__.". id=".$object->id);
// Add entry in event table
$now = dol_now();
diff --git a/htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php b/htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php
index 741cc4d09bc..275fc954ece 100644
--- a/htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php
+++ b/htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php
@@ -69,7 +69,7 @@ class InterfaceActionsBlockedLog extends DolibarrTriggers
return 1;
}
- dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
+ dol_syslog("Trigger '".$this->name."' for action '".$action."' launched by ".__FILE__.". id=".$object->id);
require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php';
$b = new BlockedLog($this->db);
diff --git a/htdocs/core/triggers/interface_50_modNotification_Notification.class.php b/htdocs/core/triggers/interface_50_modNotification_Notification.class.php
index b4d32860c82..dc02117da13 100644
--- a/htdocs/core/triggers/interface_50_modNotification_Notification.class.php
+++ b/htdocs/core/triggers/interface_50_modNotification_Notification.class.php
@@ -74,7 +74,7 @@ class InterfaceNotification extends DolibarrTriggers
return 0;
}
- dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
+ dol_syslog("Trigger '".$this->name."' for action '".$action."' launched by ".__FILE__.". id=".$object->id);
$notify = new Notify($this->db);
$notify->send($action, $object);
diff --git a/htdocs/core/triggers/interface_50_modTicket_TicketEmail.class.php b/htdocs/core/triggers/interface_50_modTicket_TicketEmail.class.php
index 298ad489764..87f707081bb 100644
--- a/htdocs/core/triggers/interface_50_modTicket_TicketEmail.class.php
+++ b/htdocs/core/triggers/interface_50_modTicket_TicketEmail.class.php
@@ -387,10 +387,12 @@ class InterfaceTicketEmail extends DolibarrTriggers
$trackid = 'tic'.$object->id;
+ $old_MAIN_MAIL_AUTOCOPY_TO = getDolGlobalString('MAIN_MAIL_AUTOCOPY_TO');
+
if (!empty($conf->global->TICKET_DISABLE_MAIL_AUTOCOPY_TO)) {
- $old_MAIN_MAIL_AUTOCOPY_TO = $conf->global->MAIN_MAIL_AUTOCOPY_TO;
$conf->global->MAIN_MAIL_AUTOCOPY_TO = '';
}
+
include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
$mailfile = new CMailFile($subject, $sendto, $from, $message_customer, $filepath, $mimetype, $filename, '', '', 0, -1, '', '', $trackid, '', 'ticket');
if ($mailfile->error) {
diff --git a/htdocs/core/triggers/interface_90_modSociete_ContactRoles.class.php b/htdocs/core/triggers/interface_90_modSociete_ContactRoles.class.php
index b1eb321f7f5..2f291f5698b 100644
--- a/htdocs/core/triggers/interface_90_modSociete_ContactRoles.class.php
+++ b/htdocs/core/triggers/interface_90_modSociete_ContactRoles.class.php
@@ -70,7 +70,7 @@ class InterfaceContactRoles extends DolibarrTriggers
if ($action === 'PROPAL_CREATE' || $action === 'ORDER_CREATE' || $action === 'BILL_CREATE'
|| $action === 'ORDER_SUPPLIER_CREATE' || $action === 'BILL_SUPPLIER_CREATE' || $action === 'PROPOSAL_SUPPLIER_CREATE'
|| $action === 'CONTRACT_CREATE' || $action === 'FICHINTER_CREATE' || $action === 'PROJECT_CREATE' || $action === 'TICKET_CREATE') {
- dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
+ dol_syslog("Trigger '".$this->name."' for action '".$action."' launched by ".__FILE__.". id=".$object->id);
$socid = (property_exists($object, 'socid') ? $object->socid : $object->fk_soc);
diff --git a/htdocs/core/triggers/interface_99_modZapier_ZapierTriggers.class.php b/htdocs/core/triggers/interface_99_modZapier_ZapierTriggers.class.php
index 8a2cffe05f3..d706488129e 100644
--- a/htdocs/core/triggers/interface_99_modZapier_ZapierTriggers.class.php
+++ b/htdocs/core/triggers/interface_99_modZapier_ZapierTriggers.class.php
@@ -396,7 +396,7 @@ class InterfaceZapierTriggers extends DolibarrTriggers
// case 'SHIPPING_DELETE':
}
if ($logtriggeraction) {
- dol_syslog("Trigger '".$this->name."' for action '.$action.' launched by ".__FILE__." id=".$object->id);
+ dol_syslog("Trigger '".$this->name."' for action '".$action."' launched by ".__FILE__." id=".$object->id);
}
return 0;
}
@@ -404,14 +404,20 @@ class InterfaceZapierTriggers extends DolibarrTriggers
/**
* Post webhook in zapier with object data
*
- * @param string $url url provided by zapier
- * @param string $json data to send
+ * @param string $url Url provided by zapier
+ * @param string $json Data to send
* @return void
*/
function zapierPostWebhook($url, $json)
{
$headers = array('Accept: application/json', 'Content-Type: application/json');
- // TODO supprimer le webhook en cas de mauvaise réponse
+
+ // TODO disable wekhook if error ?
+
+ dol_syslog("Send message to Zapier with json size=".dol_strlen($json), LOG_DEBUG);
+ getURLContent($url, 'POSTALREADYFORMATED', $json, 1, $headers, array('http', 'https'), 0);
+
+ /*
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
@@ -420,8 +426,10 @@ function zapierPostWebhook($url, $json)
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $json);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
+
$output = curl_exec($ch);
curl_close($ch);
+ */
}
/**
diff --git a/htdocs/core/website.inc.php b/htdocs/core/website.inc.php
index 8205696751b..3bbfe225bee 100644
--- a/htdocs/core/website.inc.php
+++ b/htdocs/core/website.inc.php
@@ -82,10 +82,82 @@ if ($pageid > 0) {
}
if (!defined('USEDOLIBARRSERVER') && !defined('USEDOLIBARREDITOR')) {
+ // Security options
+
+ // X-Content-Type-Options
header("X-Content-Type-Options: nosniff");
+
+ // X-Frame-Options
if (empty($websitepage->allowed_in_frames) && empty($conf->global->WEBSITE_ALLOW_FRAMES_ON_ALL_PAGES)) {
header("X-Frame-Options: SAMEORIGIN");
}
+
+ // X-XSS-Protection
+ //header("X-XSS-Protection: 1"); // XSS filtering protection of some browsers (note: use of Content-Security-Policy is more efficient). Disabled as deprecated.
+
+ // Content-Security-Policy
+ if (!defined('WEBSITE_MAIN_SECURITY_FORCECSP')) {
+ // The constant WEBSITE_MAIN_SECURITY_FORCECSP should never be defined by page, but the variable used just after may be
+
+ // A default security policy that keep usage of js external component like ckeditor, stripe, google, working
+ // $contentsecuritypolicy = "font-src *; img-src *; style-src * 'unsafe-inline' 'unsafe-eval'; default-src 'self' *.stripe.com 'unsafe-inline' 'unsafe-eval'; script-src 'self' *.stripe.com 'unsafe-inline' 'unsafe-eval'; frame-src 'self' *.stripe.com; connect-src 'self';";
+ $contentsecuritypolicy = getDolGlobalString('WEBSITE_MAIN_SECURITY_FORCECSP');
+
+ if (!is_object($hookmanager)) {
+ $hookmanager = new HookManager($db);
+ }
+ $hookmanager->initHooks(array("main"));
+
+ $parameters = array('contentsecuritypolicy'=>$contentsecuritypolicy);
+ $result = $hookmanager->executeHooks('setContentSecurityPolicy', $parameters); // Note that $action and $object may have been modified by some hooks
+ if ($result > 0) {
+ $contentsecuritypolicy = $hookmanager->resPrint; // Replace CSP
+ } else {
+ $contentsecuritypolicy .= $hookmanager->resPrint; // Concat CSP
+ }
+
+ if (!empty($contentsecuritypolicy)) {
+ // For example: to restrict to only local resources, except for css (cloudflare+google), and js (transifex + google tags) and object/iframe (youtube)
+ // default-src 'self'; style-src: https://cdnjs.cloudflare.com https://fonts.googleapis.com; script-src: https://cdn.transifex.com https://www.googletagmanager.com; object-src https://youtube.com; frame-src https://youtube.com; img-src: *;
+ // For example, to restrict everything to itself except img that can be on other servers:
+ // default-src 'self'; img-src *;
+ // Pre-existing site that uses too much js code to fix but wants to ensure resources are loaded only over https and disable plugins:
+ // default-src https: 'unsafe-inline' 'unsafe-eval'; object-src 'none'
+ header("Content-Security-Policy: ".$contentsecuritypolicy);
+ }
+ }
+
+ // Referrer-Policy
+ if (!defined('WEBSITE_MAIN_SECURITY_FORCERP')) {
+ // The constant WEBSITE_MAIN_SECURITY_FORCERP should never be defined by page, but the variable used just after may be
+
+ // For public web sites, we use the same default value than "strict-origin-when-cross-origin"
+ $referrerpolicy = getDolGlobalString('WEBSITE_MAIN_SECURITY_FORCERP', "strict-origin-when-cross-origin");
+
+ header("Referrer-Policy: ".$referrerpolicy);
+ }
+
+ // Strict-Transport-Security
+ if (!defined('WEBSITE_MAIN_SECURITY_FORCESTS')) {
+ // The constant WEBSITE_MAIN_SECURITY_FORCESTS should never be defined by page, but the variable used just after may be
+
+ // Example: "max-age=31536000; includeSubDomains"
+ $sts = getDolGlobalString('WEBSITE_MAIN_SECURITY_FORCESTS');
+ if (!empty($sts)) {
+ header("Strict-Transport-Security: ".$sts);
+ }
+ }
+
+ // Permissions-Policy (old name was Feature-Policy)
+ if (!defined('WEBSITE_MAIN_SECURITY_FORCEPP')) {
+ // The constant WEBSITE_MAIN_SECURITY_FORCEPP should never be defined by page, but the variable used just after may be
+
+ // Example: "camera: 'none'; microphone: 'none';"
+ $pp = getDolGlobalString('WEBSITE_MAIN_SECURITY_FORCEPP');
+ if (!empty($pp)) {
+ header("Permissions-Policy: ".$pp);
+ }
+ }
}
// A lang was forced, so we change weblangs init
diff --git a/htdocs/cron/card.php b/htdocs/cron/card.php
index 6fd71669d9c..319c16c7d0c 100644
--- a/htdocs/cron/card.php
+++ b/htdocs/cron/card.php
@@ -337,7 +337,7 @@ if (($action == "create") || ($action == "edit")) {
print ' ';
print $langs->trans('CronLabel')." ";
- print " label."\" /> ";
+ print ' ';
print " ";
print "";
print " ";
@@ -353,7 +353,7 @@ if (($action == "create") || ($action == "edit")) {
print '';
print $langs->trans('CronModule')." ";
- print " module_name."\" /> ";
+ print ' ';
print " ";
print "";
print $form->textwithpicto('', $langs->trans("CronModuleHelp"), 1, 'help');
@@ -362,7 +362,7 @@ if (($action == "create") || ($action == "edit")) {
print ' ';
print $langs->trans('CronClassFile')." ";
- print ' ';
+ print ' ';
print " ";
print "";
print $form->textwithpicto('', $langs->trans("CronClassFileHelp"), 1, 'help');
@@ -371,7 +371,7 @@ if (($action == "create") || ($action == "edit")) {
print ' ';
print $langs->trans('CronObject')." ";
- print " objectname."\" /> ";
+ print ' ';
print " ";
print "";
print $form->textwithpicto('', $langs->trans("CronObjectHelp"), 1, 'help');
@@ -380,7 +380,7 @@ if (($action == "create") || ($action == "edit")) {
print ' ';
print $langs->trans('CronMethod')." ";
- print ' ';
+ print ' ';
print " ";
print "";
print $form->textwithpicto('', $langs->trans("CronMethodHelp"), 1, 'help');
@@ -545,8 +545,15 @@ if (($action == "create") || ($action == "edit")) {
$linkback = ''.$langs->trans("BackToList").' ';
+ $reg = array();
+ if (preg_match('/:(.*)$/', $object->label, $reg)) {
+ $langs->load($reg[1]);
+ }
+
+ $labeltoshow = preg_replace('/:.*$/', '', $object->label);
+
$morehtmlref = '';
- $morehtmlref .= $langs->trans($object->label);
+ $morehtmlref .= $langs->trans($labeltoshow);
$morehtmlref .= '
';
dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref);
@@ -605,7 +612,7 @@ if (($action == "create") || ($action == "edit")) {
}
print " ";
- if (!empty($conf->multicompany->enabled)) {
+ if (isModEnabled('multicompany')) {
print '
';
print $langs->trans('Entity')." ";
if (empty($object->entity)) {
diff --git a/htdocs/cron/class/cronjob.class.php b/htdocs/cron/class/cronjob.class.php
index a84fa3109df..9bc8400188f 100644
--- a/htdocs/cron/class/cronjob.class.php
+++ b/htdocs/cron/class/cronjob.class.php
@@ -137,6 +137,11 @@ class Cronjob extends CommonObject
*/
public $processing;
+ /**
+ * @var int The job current PID
+ */
+ public $pid;
+
/**
* @var int ID
*/
@@ -422,6 +427,7 @@ class Cronjob extends CommonObject
$sql .= " t.frequency,";
$sql .= " t.status,";
$sql .= " t.processing,";
+ $sql .= " t.pid,";
$sql .= " t.fk_user_author,";
$sql .= " t.fk_user_mod,";
$sql .= " t.note as note_private,";
@@ -470,6 +476,7 @@ class Cronjob extends CommonObject
$this->frequency = $obj->frequency;
$this->status = $obj->status;
$this->processing = $obj->processing;
+ $this->pid = $obj->pid;
$this->fk_user_author = $obj->fk_user_author;
$this->fk_user_mod = $obj->fk_user_mod;
$this->note_private = $obj->note_private;
@@ -530,6 +537,7 @@ class Cronjob extends CommonObject
$sql .= " t.frequency,";
$sql .= " t.status,";
$sql .= " t.processing,";
+ $sql .= " t.pid,";
$sql .= " t.fk_user_author,";
$sql .= " t.fk_user_mod,";
$sql .= " t.note as note_private,";
@@ -606,6 +614,7 @@ class Cronjob extends CommonObject
$line->frequency = $obj->frequency;
$line->status = $obj->status;
$line->processing = $obj->processing;
+ $line->pid = $obj->pid;
$line->fk_user_author = $obj->fk_user_author;
$line->fk_user_mod = $obj->fk_user_mod;
$line->note_private = $obj->note_private;
@@ -708,6 +717,10 @@ class Cronjob extends CommonObject
$this->processing = 0;
}
+ if (empty($this->pid)) {
+ $this->pid = null;
+ }
+
// Check parameters
// Put here code to add a control on parameters values
if (dol_strlen($this->datenextrun) == 0) {
@@ -773,6 +786,7 @@ class Cronjob extends CommonObject
$sql .= " frequency=".(isset($this->frequency) ? $this->frequency : "null").",";
$sql .= " status=".(isset($this->status) ? $this->status : "null").",";
$sql .= " processing=".((isset($this->processing) && $this->processing > 0) ? $this->processing : "0").",";
+ $sql .= " pid=".(isset($this->pid) ? $this->pid : "null").",";
$sql .= " fk_user_mod=".$user->id.",";
$sql .= " note=".(isset($this->note_private) ? "'".$this->db->escape($this->note_private)."'" : "null").",";
$sql .= " nbrun=".((isset($this->nbrun) && $this->nbrun > 0) ? $this->nbrun : "null").",";
@@ -925,6 +939,7 @@ class Cronjob extends CommonObject
$this->frequency = '';
$this->status = 0;
$this->processing = 0;
+ $this->pid = null;
$this->fk_user_author = 0;
$this->fk_user_mod = 0;
$this->note_private = '';
@@ -1125,6 +1140,7 @@ class Cronjob extends CommonObject
$this->lastoutput = '';
$this->lastresult = '';
$this->processing = 1; // To know job was started
+ $this->pid = function_exists('getmypid') ? getmypid() : null; // Avoid dol_getmypid to get null if the function is not available
$this->nbrun = $this->nbrun + 1;
$result = $this->update($user); // This include begin/commit
if ($result < 0) {
@@ -1316,6 +1332,7 @@ class Cronjob extends CommonObject
$this->datelastresult = dol_now();
$this->processing = 0;
+ $this->pid = null;
$result = $this->update($user); // This include begin/commit
if ($result < 0) {
dol_syslog(get_class($this)."::run_jobs ".$this->error, LOG_ERR);
diff --git a/htdocs/cron/list.php b/htdocs/cron/list.php
index 40fe27d3404..2732e41dc14 100644
--- a/htdocs/cron/list.php
+++ b/htdocs/cron/list.php
@@ -489,9 +489,14 @@ if ($num > 0) {
}
}
+ $reg = array();
+ if (preg_match('/:(.*)$/', $obj->label, $reg)) {
+ $langs->load($reg[1]);
+ }
+
$object->id = $obj->rowid;
$object->ref = $obj->rowid;
- $object->label = $obj->label;
+ $object->label = preg_replace('/:.*$/', '', $obj->label);
$object->status = $obj->status;
$object->priority = $obj->priority;
$object->processing = $obj->processing;
@@ -512,9 +517,9 @@ if ($num > 0) {
// Label
print ' ';
- if (!empty($obj->label)) {
- $object->ref = $langs->trans($obj->label);
- print ''.$object->getNomUrl(0, '', 1).' ';
+ if (!empty($object->label)) {
+ $object->ref = $langs->trans($object->label);
+ print ''.$object->getNomUrl(0, '', 1).' ';
$object->ref = $obj->rowid;
} else {
//print $langs->trans('CronNone');
diff --git a/htdocs/datapolicy/admin/setupmail.php b/htdocs/datapolicy/admin/setupmail.php
index 535c4383d0d..e2f562ee79b 100644
--- a/htdocs/datapolicy/admin/setupmail.php
+++ b/htdocs/datapolicy/admin/setupmail.php
@@ -63,7 +63,7 @@ if ($action == 'setvalue' && $user->admin) {
$result = dolibarr_set_const($db, $sub, GETPOST($sub), 'chaine', 0, '', $conf->entity);
$sub = "DATAPOLICIESREFUSE_".$l;
$result = dolibarr_set_const($db, $sub, GETPOST($sub), 'chaine', 0, '', $conf->entity);
- if (!$result > 0) {
+ if (!($result > 0)) {
$error++;
}
if (!$error) {
diff --git a/htdocs/delivery/card.php b/htdocs/delivery/card.php
index dba3d0de437..108f81751b3 100644
--- a/htdocs/delivery/card.php
+++ b/htdocs/delivery/card.php
@@ -34,7 +34,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/sendings.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
-if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) {
+if (isModEnabled("product") || isModEnabled("service")) {
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
}
if (!empty($conf->expedition_bon->enabled)) {
@@ -49,7 +49,7 @@ if (!empty($conf->project->enabled)) {
}
// Load translation files required by the page
-$langs->loadLangs(array("sendings", "bills", 'deliveries', 'orders'));
+$langs->loadLangs(array('bills', 'deliveries', 'orders', 'sendings'));
if (!empty($conf->incoterm->enabled)) {
$langs->load('incoterm');
@@ -89,10 +89,10 @@ $error = 0;
*/
$parameters = array();
-$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
+$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
// Delete Link
$permissiondellink = $user->rights->expedition->delivery->supprimer; // Used by the include of actions_dellink.inc.php
-include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, not include_once
+include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, not include_once
if ($action == 'add') {
$db->begin();
@@ -101,7 +101,7 @@ if ($action == 'add') {
$object->note = GETPOST("note", 'restricthtml');
$object->note_private = GETPOST("note", 'restricthtml');
$object->commande_id = GETPOST("commande_id", 'int');
- $object->fk_incoterms = GETPOST('incoterm_id', 'int');
+ $object->fk_incoterms = GETPOST('incoterm_id', 'int');
if (!$conf->expedition_bon->enabled && !empty($conf->stock->enabled)) {
$expedition->entrepot_id = GETPOST('entrepot_id', 'int');
@@ -142,10 +142,10 @@ if ($action == 'add') {
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
$outputlangs = $langs;
$newlang = '';
- if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
+ if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
$newlang = GETPOST('lang_id', 'aZ09');
}
- if ($conf->global->MAIN_MULTILANGS && empty($newlang)) {
+ if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) {
$newlang = $object->thirdparty->default_lang;
}
if (!empty($newlang)) {
@@ -312,7 +312,7 @@ if ($action == 'create') { // Create. Seems to no be used
$objectsrc = new Commande($db);
$objectsrc->fetch($expedition->origin_id);
}
- if ($typeobject == 'propal' && $expedition->origin_id > 0 && !empty($conf->propal->enabled)) {
+ if ($typeobject == 'propal' && $expedition->origin_id > 0 && isModEnabled("propal")) {
$objectsrc = new Propal($db);
$objectsrc->fetch($expedition->origin_id);
}
@@ -409,7 +409,7 @@ if ($action == 'create') { // Create. Seems to no be used
print " \n";
print '';
}
- if ($typeobject == 'propal' && $expedition->origin_id && !empty($conf->propal->enabled)) {
+ if ($typeobject == 'propal' && $expedition->origin_id && isModEnabled("propal")) {
$propal = new Propal($db);
$propal->fetch($expedition->origin_id);
print '
'.$langs->trans("RefProposal").' ';
diff --git a/htdocs/delivery/class/delivery.class.php b/htdocs/delivery/class/delivery.class.php
index 9edc080701b..9af06f87541 100644
--- a/htdocs/delivery/class/delivery.class.php
+++ b/htdocs/delivery/class/delivery.class.php
@@ -31,7 +31,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/commonincoterm.class.php';
require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php';
-if (!empty($conf->propal->enabled)) {
+if (isModEnabled("propal")) {
require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
}
if (!empty($conf->commande->enabled)) {
diff --git a/htdocs/document.php b/htdocs/document.php
index a33708e3e77..65e5cce7e5f 100644
--- a/htdocs/document.php
+++ b/htdocs/document.php
@@ -120,7 +120,7 @@ if ($user->socid > 0) {
// For some module part, dir may be privates
if (in_array($modulepart, array('facture_paiement', 'unpaid'))) {
- if (empty($user->rights->societe->client->voir) || $socid) {
+ if (!$user->hasRight('societe', 'client', 'voir') || $socid) {
$original_file = 'private/'.$user->id.'/'.$original_file; // If user has no permission to see all, output dir is specific to user
}
}
diff --git a/htdocs/don/admin/donation.php b/htdocs/don/admin/donation.php
index c56effea73a..9a360f69882 100644
--- a/htdocs/don/admin/donation.php
+++ b/htdocs/don/admin/donation.php
@@ -310,7 +310,7 @@ print ''.$langs->trans("Value")." \n";
print ' ';
print "\n";
-if (!empty($conf->societe->enabled)) {
+if (isModEnabled("societe")) {
print '
';
print '';
print $langs->trans("DonationUseThirdparties");
diff --git a/htdocs/don/card.php b/htdocs/don/card.php
index 30a3ec24c6c..c867418cfbb 100644
--- a/htdocs/don/card.php
+++ b/htdocs/don/card.php
@@ -44,7 +44,7 @@ if (!empty($conf->project->enabled)) {
}
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
-$langs->loadLangs(array("bills", "companies", "donations", "users"));
+$langs->loadLangs(array('bills', 'companies', 'donations', 'users'));
$id = GETPOST('rowid') ?GETPOST('rowid', 'int') : GETPOST('id', 'int');
$action = GETPOST('action', 'aZ09');
@@ -119,10 +119,10 @@ if (empty($reshook)) {
if (method_exists($object, 'generateDocument')) {
$outputlangs = $langs;
$newlang = '';
- if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
+ if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
$newlang = GETPOST('lang_id', 'aZ09');
}
- if ($conf->global->MAIN_MULTILANGS && empty($newlang)) {
+ if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) {
$newlang = $object->thirdparty->default_lang;
}
if (!empty($newlang)) {
@@ -211,7 +211,7 @@ if (empty($reshook)) {
$error = 0;
- if (!empty($conf->societe->enabled) && !empty($conf->global->DONATION_USE_THIRDPARTIES) && !(GETPOST("socid", 'int') > 0)) {
+ if (isModEnabled("societe") && !empty($conf->global->DONATION_USE_THIRDPARTIES) && !(GETPOST("socid", 'int') > 0)) {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ThirdParty")), null, 'errors');
$action = "create";
$error++;
@@ -351,8 +351,8 @@ if (empty($reshook)) {
// Define output language
$outputlangs = $langs;
$newlang='';
- if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id'];
- if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->thirdparty->default_lang;
+ if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id'];
+ if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) $newlang=$object->thirdparty->default_lang;
if (! empty($newlang))
{
$outputlangs = new Translate("",$conf);
@@ -402,7 +402,7 @@ if ($action == 'create') {
print ' '.$langs->trans('Ref').' '.$langs->trans('Draft').' ';
// Company
- if (!empty($conf->societe->enabled) && !empty($conf->global->DONATION_USE_THIRDPARTIES)) {
+ if (isModEnabled("societe") && !empty($conf->global->DONATION_USE_THIRDPARTIES)) {
// Thirdparty
if ($soc->id > 0) {
print '
'.$langs->trans('ThirdParty').' ';
@@ -591,7 +591,7 @@ if (!empty($id) && $action == 'edit') {
print "
";
print "\n";
- if (!empty($conf->societe->enabled) && !empty($conf->global->DONATION_USE_THIRDPARTIES)) {
+ if (isModEnabled("societe") && !empty($conf->global->DONATION_USE_THIRDPARTIES)) {
$company = new Societe($db);
print '
'.$langs->trans("ThirdParty").' ';
@@ -756,7 +756,7 @@ if (!empty($id) && $action != 'edit') {
print yn($object->public);
print ' ';
- if (!empty($conf->societe->enabled) && !empty($conf->global->DONATION_USE_THIRDPARTIES)) {
+ if (isModEnabled("societe") && !empty($conf->global->DONATION_USE_THIRDPARTIES)) {
$company = new Societe($db);
print '
'.$langs->trans("ThirdParty").' ';
diff --git a/htdocs/don/class/paymentdonation.class.php b/htdocs/don/class/paymentdonation.class.php
index 6de83f5570e..e4928ac9363 100644
--- a/htdocs/don/class/paymentdonation.class.php
+++ b/htdocs/don/class/paymentdonation.class.php
@@ -574,7 +574,7 @@ class PaymentDonation extends CommonObject
$error = 0;
- if (!empty($conf->banque->enabled)) {
+ if (isModEnabled("banque")) {
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
$acc = new Account($this->db);
diff --git a/htdocs/don/document.php b/htdocs/don/document.php
index 030ca5cb085..1bb371c7812 100644
--- a/htdocs/don/document.php
+++ b/htdocs/don/document.php
@@ -40,7 +40,7 @@ if (!empty($conf->project->enabled)) {
}
// Load translation files required by the page
-$langs->loadLangs(array("companies", "other", "donations"));
+$langs->loadLangs(array('companies', 'other', 'donations'));
$id = GETPOST('id', 'int');
$ref = GETPOST('ref', 'alpha');
diff --git a/htdocs/don/info.php b/htdocs/don/info.php
index f326972f782..29d8f129036 100644
--- a/htdocs/don/info.php
+++ b/htdocs/don/info.php
@@ -30,7 +30,7 @@ if (!empty($conf->project->enabled)) {
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
}
-$langs->load("donations");
+$langs->load('donations');
$id = GETPOST('id', 'int');
$ref = GETPOST('ref', 'alpha');
@@ -45,17 +45,22 @@ $result = restrictedArea($user, 'don', $id, '');
$object = new Don($db);
$object->fetch($id);
+
+
/*
* Actions
*/
+
if ($action == 'classin' && $user->rights->don->creer) {
$object->fetch($id);
$object->setProject($projectid);
}
+
/*
* View
*/
+
$title = $langs->trans('Donation')." - ".$langs->trans('Info');
$help_url = 'EN:Module_Donations|FR:Module_Dons|ES:Módulo_Donaciones|DE:Modul_Spenden';
diff --git a/htdocs/don/list.php b/htdocs/don/list.php
index 891f7e6877b..68f8ab0bbea 100644
--- a/htdocs/don/list.php
+++ b/htdocs/don/list.php
@@ -32,7 +32,7 @@ if (!empty($conf->project->enabled)) {
}
// Load translation files required by the page
-$langs->loadLangs(array("companies", "donations"));
+$langs->loadLangs(array('companies', 'donations'));
$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'sclist';
diff --git a/htdocs/don/note.php b/htdocs/don/note.php
index 8e1b5192ee2..0b1c555e772 100644
--- a/htdocs/don/note.php
+++ b/htdocs/don/note.php
@@ -35,7 +35,7 @@ if (!empty($conf->project->enabled)) {
}
// Load translation files required by the page
-$langs->loadLangs(array("companies", "bills", "donations"));
+$langs->loadLangs(array('companies', 'bills', 'donations'));
$id = (GETPOST('id', 'int') ?GETPOST('id', 'int') : GETPOST('facid', 'int')); // For backward compatibility
$ref = GETPOST('ref', 'alpha');
@@ -60,6 +60,7 @@ $permissionnote = $user->rights->don->creer; // Used by the include of actions_s
/*
* Actions
*/
+
$reshook = $hookmanager->executeHooks('doActions', array(), $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
@@ -73,6 +74,7 @@ if ($action == 'classin' && $user->rights->don->creer) {
$object->setProject($projectid);
}
+
/*
* View
*/
diff --git a/htdocs/don/payment/card.php b/htdocs/don/payment/card.php
index 363ef6d34ef..1b4ebaaf88e 100644
--- a/htdocs/don/payment/card.php
+++ b/htdocs/don/payment/card.php
@@ -27,7 +27,7 @@ require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php';
require_once DOL_DOCUMENT_ROOT.'/don/class/paymentdonation.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/modules/facture/modules_facture.php';
-if (!empty($conf->banque->enabled)) {
+if (isModEnabled("banque")) {
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
}
@@ -124,7 +124,7 @@ print ' '.$langs->trans('Amount').' '.price($object->amount, 0, $
print ' '.$langs->trans('Note').' '.nl2br($object->note_public).' ';
// Bank account
-if (!empty($conf->banque->enabled)) {
+if (isModEnabled("banque")) {
if ($object->bank_account) {
$bankline = new AccountLine($db);
$bankline->fetch($object->bank_line);
diff --git a/htdocs/don/payment/payment.php b/htdocs/don/payment/payment.php
index 6cc37303346..092f5114141 100644
--- a/htdocs/don/payment/payment.php
+++ b/htdocs/don/payment/payment.php
@@ -66,7 +66,7 @@ if ($action == 'add_payment') {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Date")), null, 'errors');
$error++;
}
- if (!empty($conf->banque->enabled) && !(GETPOST("accountid", 'int') > 0)) {
+ if (isModEnabled("banque") && !(GETPOST("accountid", 'int') > 0)) {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("AccountToCredit")), null, 'errors');
$error++;
}
@@ -111,7 +111,7 @@ if ($action == 'add_payment') {
if (!$error) {
$result = $payment->addPaymentToBank($user, 'payment_donation', '(DonationPayment)', GETPOST('accountid', 'int'), '', '');
- if (!$result > 0) {
+ if (!($result > 0)) {
$errmsg = $payment->error;
setEventMessages($errmsg, null, 'errors');
$error++;
diff --git a/htdocs/ecm/class/ecmfiles.class.php b/htdocs/ecm/class/ecmfiles.class.php
index d70f5c863d7..3f4df8b847b 100644
--- a/htdocs/ecm/class/ecmfiles.class.php
+++ b/htdocs/ecm/class/ecmfiles.class.php
@@ -407,7 +407,7 @@ class EcmFiles extends CommonObject
$sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t';
$sql .= ' WHERE 1 = 1';
/* Fetching this table depends on filepath+filename, it must not depends on entity because filesystem on disk does not know what is Dolibarr entities
- if (! empty($conf->multicompany->enabled)) {
+ if (isModEnabled('multicompany')) {
$sql .= " AND entity IN (" . getEntity('ecmfiles') . ")";
}*/
if ($relativepath) {
@@ -546,7 +546,7 @@ class EcmFiles extends CommonObject
}
$sql .= ' WHERE 1 = 1';
/* Fetching this table depends on filepath+filename, it must not depends on entity
- if (! empty($conf->multicompany->enabled)) {
+ if (isModEnabled('multicompany')) {
$sql .= " AND entity IN (" . getEntity('ecmfiles') . ")";
}*/
if (count($sqlwhere) > 0) {
diff --git a/htdocs/ecm/dir_add_card.php b/htdocs/ecm/dir_add_card.php
index e5df264e377..6f80a68dc35 100644
--- a/htdocs/ecm/dir_add_card.php
+++ b/htdocs/ecm/dir_add_card.php
@@ -85,7 +85,7 @@ if (!$sortfield) {
$ecmdir = new EcmDirectory($db);
if (!empty($section)) {
$result = $ecmdir->fetch($section);
- if (!$result > 0) {
+ if (!($result > 0)) {
dol_print_error($db, $ecmdir->error);
exit;
}
diff --git a/htdocs/ecm/file_card.php b/htdocs/ecm/file_card.php
index c44fab4702e..624f8d6ddf0 100644
--- a/htdocs/ecm/file_card.php
+++ b/htdocs/ecm/file_card.php
@@ -76,7 +76,7 @@ if (!$urlfile) {
// Load ecm object
$ecmdir = new EcmDirectory($db);
$result = $ecmdir->fetch(GETPOST("section", 'alpha'));
-if (!$result > 0) {
+if (!($result > 0)) {
dol_print_error($db, $ecmdir->error);
exit;
}
diff --git a/htdocs/ecm/file_note.php b/htdocs/ecm/file_note.php
index 41367cf2894..53b120d3191 100644
--- a/htdocs/ecm/file_note.php
+++ b/htdocs/ecm/file_note.php
@@ -80,7 +80,7 @@ if (!$urlfile) {
// Load ecm object
$ecmdir = new EcmDirectory($db);
$result = $ecmdir->fetch(GETPOST("section", 'alpha'));
-if (!$result > 0) {
+if (!($result > 0)) {
dol_print_error($db, $ecmdir->error);
exit;
}
diff --git a/htdocs/ecm/index.php b/htdocs/ecm/index.php
index 11ac3bf95c1..ceaf74f533d 100644
--- a/htdocs/ecm/index.php
+++ b/htdocs/ecm/index.php
@@ -32,7 +32,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/treeview.lib.php';
require_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmdirectory.class.php';
// Load translation files required by the page
-$langs->loadLangs(array("ecm", "companies", "other", "users", "orders", "propal", "bills", "contracts"));
+$langs->loadLangs(array('ecm', 'companies', 'other', 'users', 'orders', 'propal', 'bills', 'contracts'));
// Get parameters
$socid = GETPOST('socid', 'int');
@@ -64,7 +64,7 @@ if (!$sortfield) {
$ecmdir = new EcmDirectory($db);
if ($section > 0) {
$result = $ecmdir->fetch($section);
- if (!$result > 0) {
+ if (!($result > 0)) {
dol_print_error($db, $ecmdir->error);
exit;
}
diff --git a/htdocs/ecm/index_auto.php b/htdocs/ecm/index_auto.php
index 1fcdac35b0f..4ffe606c79e 100644
--- a/htdocs/ecm/index_auto.php
+++ b/htdocs/ecm/index_auto.php
@@ -74,7 +74,7 @@ if ($module == 'invoice_supplier' && $sortfield == "fullname") {
$ecmdir = new EcmDirectory($db);
if ($section) {
$result = $ecmdir->fetch($section);
- if (!$result > 0) {
+ if (!($result > 0)) {
dol_print_error($db, $ecmdir->error);
exit;
}
@@ -309,14 +309,14 @@ llxHeader($moreheadcss.$moreheadjs, $langs->trans("ECMArea"), '', '', '', '', $m
$rowspan = 0;
$sectionauto = array();
if (!empty($conf->global->ECM_AUTO_TREE_ENABLED)) {
- if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) {
+ if (isModEnabled("product") || isModEnabled("service")) {
$langs->load("products");
- $rowspan++; $sectionauto[] = array('position'=>10, 'level'=>1, 'module'=>'product', 'test'=>(!empty($conf->product->enabled) || !empty($conf->service->enabled)), 'label'=>$langs->trans("ProductsAndServices"), 'desc'=>$langs->trans("ECMDocsByProducts"));
+ $rowspan++; $sectionauto[] = array('position'=>10, 'level'=>1, 'module'=>'product', 'test'=>(isModEnabled("product") || isModEnabled("service")), 'label'=>$langs->trans("ProductsAndServices"), 'desc'=>$langs->trans("ECMDocsByProducts"));
}
- if (!empty($conf->societe->enabled)) {
+ if (isModEnabled("societe")) {
$rowspan++; $sectionauto[] = array('position'=>20, 'level'=>1, 'module'=>'company', 'test'=>$conf->societe->enabled, 'label'=>$langs->trans("ThirdParties"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("ThirdParties")));
}
- if (!empty($conf->propal->enabled)) {
+ if (isModEnabled("propal")) {
$rowspan++; $sectionauto[] = array('position'=>30, 'level'=>1, 'module'=>'propal', 'test'=>$conf->propal->enabled, 'label'=>$langs->trans("Proposals"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Proposals")));
}
if (!empty($conf->contrat->enabled)) {
@@ -332,11 +332,11 @@ if (!empty($conf->global->ECM_AUTO_TREE_ENABLED)) {
$langs->load("supplier_proposal");
$rowspan++; $sectionauto[] = array('position'=>70, 'level'=>1, 'module'=>'supplier_proposal', 'test'=>$conf->supplier_proposal->enabled, 'label'=>$langs->trans("SupplierProposals"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("SupplierProposals")));
}
- if (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled)) {
- $rowspan++; $sectionauto[] = array('position'=>80, 'level'=>1, 'module'=>'order_supplier', 'test'=>(!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled)), 'label'=>$langs->trans("SuppliersOrders"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("PurchaseOrders")));
+ if (isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || isModEnabled("supplier_order")) {
+ $rowspan++; $sectionauto[] = array('position'=>80, 'level'=>1, 'module'=>'order_supplier', 'test'=>(isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || isModEnabled("supplier_order")), 'label'=>$langs->trans("SuppliersOrders"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("PurchaseOrders")));
}
- if (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_invoice->enabled)) {
- $rowspan++; $sectionauto[] = array('position'=>90, 'level'=>1, 'module'=>'invoice_supplier', 'test'=>(!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_invoice->enabled)), 'label'=>$langs->trans("SuppliersInvoices"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("SupplierInvoices")));
+ if (isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || isModEnabled("supplier_invoice")) {
+ $rowspan++; $sectionauto[] = array('position'=>90, 'level'=>1, 'module'=>'invoice_supplier', 'test'=>(isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || isModEnabled("supplier_invoice")), 'label'=>$langs->trans("SuppliersInvoices"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("SupplierInvoices")));
}
if (!empty($conf->tax->enabled)) {
$langs->load("compta");
@@ -363,7 +363,7 @@ if (!empty($conf->global->ECM_AUTO_TREE_ENABLED)) {
$langs->load("holiday");
$rowspan++; $sectionauto[] = array('position'=>170, 'level'=>1, 'module'=>'holiday', 'test'=>$conf->holiday->enabled, 'label'=>$langs->trans("Holidays"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Holidays")));
}
- if (!empty($conf->banque->enabled)) {
+ if (isModEnabled("banque")) {
$langs->load("banks");
$rowspan++; $sectionauto[] = array('position'=>180, 'level'=>1, 'module'=>'banque', 'test'=>$conf->banque->enabled, 'label'=>$langs->trans("BankAccount"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("BankAccount")));
$rowspan++; $sectionauto[] = array('position'=>190, 'level'=>1, 'module'=>'chequereceipt', 'test'=>$conf->banque->enabled, 'label'=>$langs->trans("CheckReceipt"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("CheckReceipt")));
diff --git a/htdocs/ecm/search.php b/htdocs/ecm/search.php
index 27a76d2ae6e..d04983fff11 100644
--- a/htdocs/ecm/search.php
+++ b/htdocs/ecm/search.php
@@ -78,7 +78,7 @@ if (!$sortfield) {
$ecmdir = new EcmDirectory($db);
if (!empty($section)) {
$result = $ecmdir->fetch($section);
- if (!$result > 0) {
+ if (!($result > 0)) {
dol_print_error($db, $ecmdir->error);
exit;
}
@@ -113,13 +113,13 @@ $userstatic = new User($db);
// Ajout rubriques automatiques
$rowspan = 0;
$sectionauto = array();
-if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) {
- $langs->load("products"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'product', 'test'=>(!empty($conf->product->enabled) || !empty($conf->service->enabled)), 'label'=>$langs->trans("ProductsAndServices"), 'desc'=>$langs->trans("ECMDocsByProducts"));
+if (isModEnabled("product") || isModEnabled("service")) {
+ $langs->load("products"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'product', 'test'=>(isModEnabled("product") || isModEnabled("service")), 'label'=>$langs->trans("ProductsAndServices"), 'desc'=>$langs->trans("ECMDocsByProducts"));
}
-if (!empty($conf->societe->enabled)) {
+if (isModEnabled("societe")) {
$rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'company', 'test'=>$conf->societe->enabled, 'label'=>$langs->trans("ThirdParties"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("ThirdParties")));
}
-if (!empty($conf->propal->enabled)) {
+if (isModEnabled("propal")) {
$rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'propal', 'test'=>$conf->propal->enabled, 'label'=>$langs->trans("Proposals"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Proposals")));
}
if (!empty($conf->contrat->enabled)) {
@@ -134,11 +134,11 @@ if (isModEnabled('facture')) {
if (!empty($conf->supplier_proposal->enabled)) {
$langs->load("supplier_proposal"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'supplier_proposal', 'test'=>$conf->supplier_proposal->enabled, 'label'=>$langs->trans("SupplierProposals"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("SupplierProposals")));
}
-if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled)) {
- $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'order_supplier', 'test'=>((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled)), 'label'=>$langs->trans("SuppliersOrders"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("PurchaseOrders")));
+if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order")) {
+ $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'order_supplier', 'test'=>((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order")), 'label'=>$langs->trans("SuppliersOrders"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("PurchaseOrders")));
}
-if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_invoice->enabled)) {
- $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'invoice_supplier', 'test'=>((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_invoice->enabled)), 'label'=>$langs->trans("SuppliersInvoices"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("SupplierInvoices")));
+if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_invoice")) {
+ $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'invoice_supplier', 'test'=>((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_invoice")), 'label'=>$langs->trans("SuppliersInvoices"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("SupplierInvoices")));
}
if (!empty($conf->tax->enabled)) {
$langs->load("compta"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'tax', 'test'=>$conf->tax->enabled, 'label'=>$langs->trans("SocialContributions"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("SocialContributions")));
@@ -155,7 +155,7 @@ if (!empty($conf->expensereport->enabled)) {
if (!empty($conf->holiday->enabled)) {
$langs->load("holiday"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'holiday', 'test'=>$conf->holiday->enabled, 'label'=>$langs->trans("Holidays"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Holidays")));
}
-if (!empty($conf->banque->enabled)) {
+if (isModEnabled("banque")) {
$langs->load("banks"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'banque', 'test'=>$conf->banque->enabled, 'label'=>$langs->trans("BankAccount"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("BankAccount")));
}
if (!empty($conf->mrp->enabled)) {
diff --git a/htdocs/emailcollector/class/emailcollector.class.php b/htdocs/emailcollector/class/emailcollector.class.php
index 4f95a44652e..50b7047b90d 100644
--- a/htdocs/emailcollector/class/emailcollector.class.php
+++ b/htdocs/emailcollector/class/emailcollector.class.php
@@ -40,7 +40,19 @@ require_once DOL_DOCUMENT_ROOT.'/supplier_proposal/class/supplier_proposal.class
require_once DOL_DOCUMENT_ROOT.'/reception/class/reception.class.php'; // reception
include_once DOL_DOCUMENT_ROOT.'/emailcollector/lib/emailcollector.lib.php';
//require_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php'; // Holidays (leave request)
-//require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; // expernse report
+//require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; // expernse repor
+
+
+// use Webklex\PHPIMAP;
+require DOL_DOCUMENT_ROOT.'/includes/webklex/php-imap/vendor/autoload.php';
+use Webklex\PHPIMAP\ClientManager;
+
+use Webklex\PHPIMAP\Exceptions\ConnectionFailedException;
+use Webklex\PHPIMAP\Exceptions\InvalidWhereQueryCriteriaException;
+use Webklex\PHPIMAP\Exceptions\GetMessagesFailedException;
+
+use OAuth\Common\Storage\DoliStorage;
+use OAuth\Common\Consumer\Credentials;
/**
@@ -111,15 +123,17 @@ class EmailCollector extends CommonObject
public $fields = array(
'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'visible'=>2, 'enabled'=>1, 'position'=>1, 'notnull'=>1, 'index'=>1),
'entity' => array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'default'=>1, 'notnull'=>1, 'index'=>1, 'position'=>20),
- 'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1, 'help'=>'Example: MyCollector1', 'csslist'=>'tdoverflowmax200'),
+ 'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1, 'help'=>'Example: MyCollector1', 'csslist'=>'tdoverflowmax150'),
'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'visible'=>1, 'enabled'=>1, 'position'=>30, 'notnull'=>-1, 'searchall'=>1, 'help'=>'Example: My Email collector', 'csslist'=>'tdoverflowmax150'),
'description' => array('type'=>'text', 'label'=>'Description', 'visible'=>-1, 'enabled'=>1, 'position'=>60, 'notnull'=>-1, 'csslist'=>'small'),
'host' => array('type'=>'varchar(255)', 'label'=>'EMailHost', 'visible'=>1, 'enabled'=>1, 'position'=>90, 'notnull'=>1, 'searchall'=>1, 'comment'=>"IMAP server", 'help'=>'Example: imap.gmail.com', 'csslist'=>'tdoverflow125'),
'port' => array('type'=>'varchar(10)', 'label'=>'EMailHostPort', 'visible'=>1, 'enabled'=>1, 'position'=>91, 'notnull'=>1, 'searchall'=>0, 'comment'=>"IMAP server port", 'help'=>'Example: 993', 'csslist'=>'tdoverflow125', 'default'=>'993'),
'hostcharset' => array('type'=>'varchar(16)', 'label'=>'HostCharset', 'visible'=>-1, 'enabled'=>1, 'position'=>92, 'notnull'=>0, 'searchall'=>0, 'comment'=>"IMAP server charset", 'help'=>'Example: "UTF-8" (May be "US-ASCII" with some Office365)', 'default'=>'UTF-8'),
- 'login' => array('type'=>'varchar(128)', 'label'=>'Login', 'visible'=>-1, 'enabled'=>1, 'position'=>101, 'notnull'=>-1, 'index'=>1, 'comment'=>"IMAP login", 'help'=>'Example: myaccount@gmail.com'),
- 'password' => array('type'=>'password', 'label'=>'Password', 'visible'=>-1, 'enabled'=>1, 'position'=>102, 'notnull'=>-1, 'comment'=>"IMAP password", 'help'=>'WithGMailYouCanCreateADedicatedPassword'),
- 'source_directory' => array('type'=>'varchar(255)', 'label'=>'MailboxSourceDirectory', 'visible'=>-1, 'enabled'=>1, 'position'=>103, 'notnull'=>1, 'default' => 'Inbox', 'help'=>'Example: INBOX'),
+ 'acces_type' => array('type'=>'integer', 'label'=>'accessType', 'visible'=>-1, 'enabled'=>"getDolGlobalInt('MAIN_IMAP_USE_PHPIMAP')", 'position'=>101, 'notnull'=>1, 'index'=>1, 'comment'=>"IMAP login type", 'arrayofkeyval'=>array('0'=>'loginPassword', '1'=>'oauthToken'), 'default'=>'0', 'help'=>''),
+ 'login' => array('type'=>'varchar(128)', 'label'=>'Login', 'visible'=>-1, 'enabled'=>1, 'position'=>102, 'notnull'=>-1, 'index'=>1, 'comment'=>"IMAP login", 'help'=>'Example: myaccount@gmail.com'),
+ 'password' => array('type'=>'password', 'label'=>'Password', 'visible'=>-1, 'enabled'=>"1", 'position'=>103, 'notnull'=>-1, 'comment'=>"IMAP password", 'help'=>'WithGMailYouCanCreateADedicatedPassword'),
+ 'oauth_service' => array('type'=>'varchar(128)', 'label'=>'oauthService', 'visible'=>-1, 'enabled'=>"getDolGlobalInt('MAIN_IMAP_USE_PHPIMAP')", 'position'=>104, 'notnull'=>0, 'index'=>1, 'comment'=>"IMAP login oauthService", 'arrayofkeyval'=>array(), 'help'=>'TokenMustHaveBeenCreated'),
+ 'source_directory' => array('type'=>'varchar(255)', 'label'=>'MailboxSourceDirectory', 'visible'=>-1, 'enabled'=>1, 'position'=>104, 'notnull'=>1, 'default' => 'Inbox', 'help'=>'Example: INBOX'),
//'filter' => array('type'=>'text', 'label'=>'Filter', 'visible'=>1, 'enabled'=>1, 'position'=>105),
//'actiontodo' => array('type'=>'varchar(255)', 'label'=>'ActionToDo', 'visible'=>1, 'enabled'=>1, 'position'=>106),
'target_directory' => array('type'=>'varchar(255)', 'label'=>'MailboxTargetDirectory', 'visible'=>1, 'enabled'=>1, 'position'=>110, 'notnull'=>0, 'help'=>"EmailCollectorTargetDir"),
@@ -198,6 +212,8 @@ class EmailCollector extends CommonObject
public $hostcharset;
public $login;
public $password;
+ public $acces_type;
+ public $oauth_service;
public $source_directory;
public $target_directory;
public $maxemailpercollect;
@@ -235,10 +251,31 @@ class EmailCollector extends CommonObject
if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid'])) {
$this->fields['rowid']['visible'] = 0;
}
- if (empty($conf->multicompany->enabled) && isset($this->fields['entity'])) {
+ if (!isModEnabled('multicompany') && isset($this->fields['entity'])) {
$this->fields['entity']['enabled'] = 0;
}
+ // List of oauth services
+ $oauthservices = array();
+
+ foreach ($conf->global as $key => $val) {
+ if (!empty($val) && preg_match('/^OAUTH_.*_ID$/', $key)) {
+ $key = preg_replace('/^OAUTH_/', '', $key);
+ $key = preg_replace('/_ID$/', '', $key);
+ if (preg_match('/^.*-/', $key)) {
+ $name = preg_replace('/^.*-/', '', $key);
+ } else {
+ $name = $langs->trans("NoName");
+ }
+ $provider = preg_replace('/-.*$/', '', $key);
+ $provider = ucfirst(strtolower($provider));
+
+ $oauthservices[$key] = $name." (".$provider.")";
+ }
+ }
+
+ $this->fields['oauth_service']['arrayofkeyval'] = $oauthservices;
+
// Unset fields that are disabled
foreach ($this->fields as $key => $val) {
if (isset($val['enabled']) && empty($val['enabled'])) {
@@ -274,8 +311,13 @@ class EmailCollector extends CommonObject
return -1;
}
+ include_once DOL_DOCUMENT_ROOT.'/core/lib/security.lib.php';
+ $this->password = dolEncrypt($this->password);
+
$id = $this->createCommon($user, $notrigger);
+ $this->password = dolDecrypt($this->password);
+
if (is_array($this->filters) && count($this->filters)) {
$emailcollectorfilter = new EmailCollectorFilter($this->db);
@@ -334,6 +376,7 @@ class EmailCollector extends CommonObject
unset($object->id);
unset($object->fk_user_creat);
unset($object->import_key);
+ unset($object->password);
// Clear fields
$object->ref = "copy_of_".$object->ref;
@@ -385,6 +428,10 @@ class EmailCollector extends CommonObject
public function fetch($id, $ref = null)
{
$result = $this->fetchCommon($id, $ref);
+
+ include_once DOL_DOCUMENT_ROOT.'/core/lib/security.lib.php';
+ $this->password = dolDecrypt($this->password);
+
//if ($result > 0 && ! empty($this->table_element_line)) $this->fetchLines();
return $result;
}
@@ -480,7 +527,14 @@ class EmailCollector extends CommonObject
return -1;
}
- return $this->updateCommon($user, $notrigger);
+ include_once DOL_DOCUMENT_ROOT.'/core/lib/security.lib.php';
+ $this->password = dolEncrypt($this->password);
+
+ $result = $this->updateCommon($user, $notrigger);
+
+ $this->password = dolDecrypt($this->password);
+
+ return $result;
}
/**
@@ -951,7 +1005,7 @@ class EmailCollector extends CommonObject
*/
public function doCollectOneCollector()
{
- global $conf, $langs, $user;
+ global $db, $conf, $langs, $user;
global $hookmanager;
//$conf->global->SYSLOG_FILE = 'DOL_DATA_ROOT/dolibarr_mydedicatedlofile.log';
@@ -968,6 +1022,7 @@ class EmailCollector extends CommonObject
$now = dol_now();
+
if (empty($this->host)) {
$this->error = $langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('EMailHost'));
return -1;
@@ -980,149 +1035,386 @@ class EmailCollector extends CommonObject
$this->error = $langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('MailboxSourceDirectory'));
return -1;
}
- if (!function_exists('imap_open')) {
- $this->error = 'IMAP function not enabled on your PHP';
- return -2;
- }
$this->fetchFilters();
$this->fetchActions();
- $sourcedir = $this->source_directory;
- $targetdir = ($this->target_directory ? $this->target_directory : ''); // Can be '[Gmail]/Trash' or 'mytag'
+ if (!empty($conf->global->MAIN_IMAP_USE_PHPIMAP)) {
+ if ($this->acces_type == 1) {
+ // Mode OAUth2 with PHP-IMAP
+ require_once DOL_DOCUMENT_ROOT.'/core/lib/oauth.lib.php'; // define $supportedoauth2array
+ $keyforsupportedoauth2array = $this->oauth_service;
+ if (preg_match('/^.*-/', $keyforsupportedoauth2array)) {
+ $keyforprovider = preg_replace('/^.*-/', '', $keyforsupportedoauth2array);
+ } else {
+ $keyforprovider = '';
+ }
+ $keyforsupportedoauth2array = preg_replace('/-.*$/', '', $keyforsupportedoauth2array);
+ $keyforsupportedoauth2array = 'OAUTH_'.$keyforsupportedoauth2array.'_NAME';
- $connectstringserver = $this->getConnectStringIMAP();
- $connectstringsource = $connectstringserver.imap_utf7_encode($sourcedir);
- $connectstringtarget = $connectstringserver.imap_utf7_encode($targetdir);
+ $OAUTH_SERVICENAME = (empty($supportedoauth2array[$keyforsupportedoauth2array]['name']) ? 'Unknown' : $supportedoauth2array[$keyforsupportedoauth2array]['name'].($keyforprovider ? '-'.$keyforprovider : ''));
- $connection = imap_open($connectstringsource, $this->login, $this->password);
- if (!$connection) {
- $this->error = 'Failed to open IMAP connection '.$connectstringsource;
- return -3;
- }
- imap_errors(); // Clear stack of errors.
+ require_once DOL_DOCUMENT_ROOT.'/includes/OAuth/bootstrap.php';
+ //$debugtext = "Host: ".$this->host."
Port: ".$this->port."
Login: ".$this->login."
Password: ".$this->password."
access type: ".$this->acces_type."
oauth service: ".$this->oauth_service."
Max email per collect: ".$this->maxemailpercollect;
+ //dol_syslog($debugtext);
- $host = dol_getprefix('email');
- //$host = '123456';
+ $storage = new DoliStorage($db, $conf);
- // Define the IMAP search string
- // See https://tools.ietf.org/html/rfc3501#section-6.4.4 for IMAPv4 (PHP not yet compatible)
- // See https://tools.ietf.org/html/rfc1064 page 13 for IMAPv2
- //$search='ALL';
- $search = 'UNDELETED'; // Seems not supported by some servers
- $searchhead = '';
- $searchfilterdoltrackid = 0;
- $searchfilternodoltrackid = 0;
- $searchfilterisanswer = 0;
- $searchfilterisnotanswer = 0;
- foreach ($this->filters as $rule) {
- if (empty($rule['status'])) {
- continue;
+ try {
+ $tokenobj = $storage->retrieveAccessToken($OAUTH_SERVICENAME);
+ $expire = true;
+ // Is token expired or will token expire in the next 30 seconds
+ // if (is_object($tokenobj)) {
+ // $expire = ($tokenobj->getEndOfLife() !== -9002 && $tokenobj->getEndOfLife() !== -9001 && time() > ($tokenobj->getEndOfLife() - 30));
+ // }
+ // Token expired so we refresh it
+ if (is_object($tokenobj) && $expire) {
+ $credentials = new Credentials(
+ getDolGlobalString('OAUTH_'.$this->oauth_service.'_ID'),
+ getDolGlobalString('OAUTH_'.$this->oauth_service.'_SECRET'),
+ getDolGlobalString('OAUTH_'.$this->oauth_service.'_URLAUTHORIZE')
+ );
+ $serviceFactory = new \OAuth\ServiceFactory();
+ $oauthname = explode('-', $OAUTH_SERVICENAME);
+ // ex service is Google-Emails we need only the first part Google
+ $apiService = $serviceFactory->createService($oauthname[0], $credentials, $storage, array());
+ // We have to save the token because Google give it only once
+ $refreshtoken = $tokenobj->getRefreshToken();
+ $tokenobj = $apiService->refreshAccessToken($tokenobj);
+ $tokenobj->setRefreshToken($refreshtoken);
+ $storage->storeAccessToken($OAUTH_SERVICENAME, $tokenobj);
+ }
+ $tokenobj = $storage->retrieveAccessToken($OAUTH_SERVICENAME);
+ if (is_object($tokenobj)) {
+ $token = $tokenobj->getAccessToken();
+ } else {
+ $this->error = "Token not found";
+ return -1;
+ }
+ } catch (Exception $e) {
+ // Return an error if token not found
+ $this->error = $e->getMessage();
+ dol_syslog("CMailFile::sendfile: mail end error=".$this->error, LOG_ERR);
+ return -1;
+ }
+
+
+ $cm = new ClientManager();
+ $client = $cm->make([
+ 'host' => $this->host,
+ 'port' => $this->port,
+ 'encryption' => 'ssl',
+ 'validate_cert' => true,
+ 'protocol' => 'imap',
+ 'username' => $this->login,
+ 'password' => $token,
+ 'authentication' => "oauth",
+ ]);
+ } else {
+ // Mode login/pass with PHP-IMAP
+ $cm = new ClientManager();
+ $client = $cm->make([
+ 'host' => $this->host,
+ 'port' => $this->port,
+ 'encryption' => 'ssl',
+ 'validate_cert' => true,
+ 'protocol' => 'imap',
+ 'username' => $this->login,
+ 'password' => $this->password,
+ 'authentication' => "login",
+ ]);
}
- if ($rule['type'] == 'to') {
- $tmprulevaluearray = explode('*', $rule['rulevalue']);
- if (count($tmprulevaluearray) >= 2) {
- foreach ($tmprulevaluearray as $tmprulevalue) {
- $search .= ($search ? ' ' : '').'TO "'.str_replace('"', '', $tmprulevalue).'"';
+ try {
+ $client->connect();
+ } catch (ConnectionFailedException $e) {
+ $this->error = $e->getMessage();
+ $this->errors[] = $this->error;
+ dol_syslog("EmailCollector::doCollectOneCollector ".$this->error, LOG_ERR);
+ return -1;
+ }
+
+ $host = dol_getprefix('email');
+ } else {
+ // Use native IMAP functions
+ if (!function_exists('imap_open')) {
+ $this->error = 'IMAP function not enabled on your PHP';
+ return -2;
+ }
+ $sourcedir = $this->source_directory;
+ $targetdir = ($this->target_directory ? $this->target_directory : ''); // Can be '[Gmail]/Trash' or 'mytag'
+
+ $connectstringserver = $this->getConnectStringIMAP();
+ $connectstringsource = $connectstringserver.imap_utf7_encode($sourcedir);
+ $connectstringtarget = $connectstringserver.imap_utf7_encode($targetdir);
+
+ $connection = imap_open($connectstringsource, $this->login, $this->password);
+ if (!$connection) {
+ $this->error = 'Failed to open IMAP connection '.$connectstringsource.' '.imap_last_error();
+ return -3;
+ }
+ imap_errors(); // Clear stack of errors.
+
+ $host = dol_getprefix('email');
+ //$host = '123456';
+
+ // Define the IMAP search string
+ // See https://tools.ietf.org/html/rfc3501#section-6.4.4 for IMAPv4 (PHP not yet compatible)
+ // See https://tools.ietf.org/html/rfc1064 page 13 for IMAPv2
+ //$search='ALL';
+ }
+
+ if (!empty($conf->global->MAIN_IMAP_USE_PHPIMAP)) {
+ $criteria = array(array('UNDELETED')); // Seems not supported by some servers
+ $search = '';
+ $searchhead = '';
+ $searchfilterdoltrackid = 0;
+ $searchfilternodoltrackid = 0;
+ $searchfilterisanswer = 0;
+ $searchfilterisnotanswer = 0;
+ foreach ($this->filters as $rule) {
+ if (empty($rule['status'])) {
+ continue;
+ }
+ if ($rule['type'] == 'to') {
+ $tmprulevaluearray = explode('*', $rule['rulevalue']);
+ if (count($tmprulevaluearray) >= 2) {
+ foreach ($tmprulevaluearray as $tmprulevalue) {
+ array_push($criteria, array("TO" => $tmprulevalue));
+ }
+ } else {
+ array_push($criteria, array("TO" => $rule['rulevalue']));
}
- } else {
- $search .= ($search ? ' ' : '').'TO "'.str_replace('"', '', $rule['rulevalue']).'"';
+ }
+ if ($rule['type'] == 'bcc') {
+ array_push($criteria, array("BCC" => $rule['rulevalue']));
+ }
+ if ($rule['type'] == 'cc') {
+ array_push($criteria, array("CC" => $rule['rulevalue']));
+ }
+ if ($rule['type'] == 'from') {
+ array_push($criteria, array("FROM" => $rule['rulevalue']));
+ }
+ if ($rule['type'] == 'subject') {
+ array_push($criteria, array("SUBJECT" => $rule['rulevalue']));
+ }
+ if ($rule['type'] == 'body') {
+ array_push($criteria, array("BODY" => $rule['rulevalue']));
+ }
+ if ($rule['type'] == 'header') {
+ array_push($criteria, array("HEADER" => $rule['rulevalue']));
+ }
+
+ if ($rule['type'] == 'notinsubject') {
+ array_push($criteria, array("SUBJECT NOT" => $rule['rulevalue']));
+ }
+ if ($rule['type'] == 'notinbody') {
+ array_push($criteria, array("BODY NOT" => $rule['rulevalue']));
+ }
+
+ if ($rule['type'] == 'seen') {
+ array_push($criteria, array("SEEN"));
+ }
+ if ($rule['type'] == 'unseen') {
+ array_push($criteria, array("UNSEEN"));
+ }
+ if ($rule['type'] == 'unanswered') {
+ array_push($criteria, array("UNANSWERED"));
+ }
+ if ($rule['type'] == 'answered') {
+ array_push($criteria, array("ANSWERED"));
+ }
+ if ($rule['type'] == 'smaller') {
+ array_push($criteria, array("SMALLER"));
+ }
+ if ($rule['type'] == 'larger') {
+ array_push($criteria, array("LARGER"));
+ }
+
+ // Rules to filter after the search imap
+ if ($rule['type'] == 'withtrackingidinmsgid') {
+ $searchfilterdoltrackid++; $searchhead .= '/Message-ID.*@'.preg_quote($host, '/').'/';
+ }
+ if ($rule['type'] == 'withouttrackingidinmsgid') {
+ $searchfilterdoltrackid++; $searchhead .= '/Message-ID.*@'.preg_quote($host, '/').'/';
+ }
+ if ($rule['type'] == 'withtrackingid') {
+ $searchfilterdoltrackid++; $searchhead .= '/References.*@'.preg_quote($host, '/').'/';
+ }
+ if ($rule['type'] == 'withouttrackingid') {
+ $searchfilternodoltrackid++; $searchhead .= '! /References.*@'.preg_quote($host, '/').'/';
+ }
+
+ if ($rule['type'] == 'isanswer') {
+ $searchfilterisanswer++; $searchhead .= '/References.*@.*/';
+ }
+ if ($rule['type'] == 'isnotanswer') {
+ $searchfilterisnotanswer++; $searchhead .= '! /References.*@.*/';
}
}
- if ($rule['type'] == 'bcc') {
- $search .= ($search ? ' ' : '').'BCC';
- }
- if ($rule['type'] == 'cc') {
- $search .= ($search ? ' ' : '').'CC';
- }
- if ($rule['type'] == 'from') {
- $search .= ($search ? ' ' : '').'FROM "'.str_replace('"', '', $rule['rulevalue']).'"';
- }
- if ($rule['type'] == 'subject') {
- $search .= ($search ? ' ' : '').'SUBJECT "'.str_replace('"', '', $rule['rulevalue']).'"';
- }
- if ($rule['type'] == 'body') {
- $search .= ($search ? ' ' : '').'BODY "'.str_replace('"', '', $rule['rulevalue']).'"';
- }
- if ($rule['type'] == 'header') {
- $search .= ($search ? ' ' : '').'HEADER '.$rule['rulevalue'];
+
+ if (empty($targetdir)) { // Use last date as filter if there is no targetdir defined.
+ $fromdate = 0;
+ if ($this->datelastok) {
+ $fromdate = $this->datelastok;
+ }
+ if ($fromdate > 0) {
+ // $search .= ($search ? ' ' : '').'SINCE '.date('j-M-Y', $fromdate - 1); // SENTSINCE not supported. Date must be X-Abc-9999 (X on 1 digit if < 10)
+ array_push($criteria, array("SINCE" => date('j-M-Y', $fromdate - 1)));
+ }
+ //$search.=($search?' ':'').'SINCE 8-Apr-2022';
}
- if ($rule['type'] == 'notinsubject') {
- $search .= ($search ? ' ' : '').'SUBJECT NOT "'.str_replace('"', '', $rule['rulevalue']).'"';
- }
- if ($rule['type'] == 'notinbody') {
- $search .= ($search ? ' ' : '').'BODY NOT "'.str_replace('"', '', $rule['rulevalue']).'"';
+ dol_syslog("IMAP search string = ".var_export($criteria, true));
+ $search = var_export($criteria, true);
+ } else {
+ $search = 'UNDELETED'; // Seems not supported by some servers
+ $searchhead = '';
+ $searchfilterdoltrackid = 0;
+ $searchfilternodoltrackid = 0;
+ $searchfilterisanswer = 0;
+ $searchfilterisnotanswer = 0;
+ foreach ($this->filters as $rule) {
+ if (empty($rule['status'])) {
+ continue;
+ }
+
+ if ($rule['type'] == 'to') {
+ $tmprulevaluearray = explode('*', $rule['rulevalue']);
+ if (count($tmprulevaluearray) >= 2) {
+ foreach ($tmprulevaluearray as $tmprulevalue) {
+ $search .= ($search ? ' ' : '').'TO "'.str_replace('"', '', $tmprulevalue).'"';
+ }
+ } else {
+ $search .= ($search ? ' ' : '').'TO "'.str_replace('"', '', $rule['rulevalue']).'"';
+ }
+ }
+ if ($rule['type'] == 'bcc') {
+ $search .= ($search ? ' ' : '').'BCC';
+ }
+ if ($rule['type'] == 'cc') {
+ $search .= ($search ? ' ' : '').'CC';
+ }
+ if ($rule['type'] == 'from') {
+ $search .= ($search ? ' ' : '').'FROM "'.str_replace('"', '', $rule['rulevalue']).'"';
+ }
+ if ($rule['type'] == 'subject') {
+ $search .= ($search ? ' ' : '').'SUBJECT "'.str_replace('"', '', $rule['rulevalue']).'"';
+ }
+ if ($rule['type'] == 'body') {
+ $search .= ($search ? ' ' : '').'BODY "'.str_replace('"', '', $rule['rulevalue']).'"';
+ }
+ if ($rule['type'] == 'header') {
+ $search .= ($search ? ' ' : '').'HEADER '.$rule['rulevalue'];
+ }
+
+ if ($rule['type'] == 'notinsubject') {
+ $search .= ($search ? ' ' : '').'SUBJECT NOT "'.str_replace('"', '', $rule['rulevalue']).'"';
+ }
+ if ($rule['type'] == 'notinbody') {
+ $search .= ($search ? ' ' : '').'BODY NOT "'.str_replace('"', '', $rule['rulevalue']).'"';
+ }
+
+ if ($rule['type'] == 'seen') {
+ $search .= ($search ? ' ' : '').'SEEN';
+ }
+ if ($rule['type'] == 'unseen') {
+ $search .= ($search ? ' ' : '').'UNSEEN';
+ }
+ if ($rule['type'] == 'unanswered') {
+ $search .= ($search ? ' ' : '').'UNANSWERED';
+ }
+ if ($rule['type'] == 'answered') {
+ $search .= ($search ? ' ' : '').'ANSWERED';
+ }
+ if ($rule['type'] == 'smaller') {
+ $search .= ($search ? ' ' : '').'SMALLER "'.str_replace('"', '', $rule['rulevalue']).'"';
+ }
+ if ($rule['type'] == 'larger') {
+ $search .= ($search ? ' ' : '').'LARGER "'.str_replace('"', '', $rule['rulevalue']).'"';
+ }
+
+ // Rules to filter after the search imap
+ if ($rule['type'] == 'withtrackingidinmsgid') {
+ $searchfilterdoltrackid++; $searchhead .= '/Message-ID.*@'.preg_quote($host, '/').'/';
+ }
+ if ($rule['type'] == 'withouttrackingidinmsgid') {
+ $searchfilterdoltrackid++; $searchhead .= '/Message-ID.*@'.preg_quote($host, '/').'/';
+ }
+ if ($rule['type'] == 'withtrackingid') {
+ $searchfilterdoltrackid++; $searchhead .= '/References.*@'.preg_quote($host, '/').'/';
+ }
+ if ($rule['type'] == 'withouttrackingid') {
+ $searchfilternodoltrackid++; $searchhead .= '! /References.*@'.preg_quote($host, '/').'/';
+ }
+
+ if ($rule['type'] == 'isanswer') {
+ $searchfilterisanswer++; $searchhead .= '/References.*@.*/';
+ }
+ if ($rule['type'] == 'isnotanswer') {
+ $searchfilterisnotanswer++; $searchhead .= '! /References.*@.*/';
+ }
}
- if ($rule['type'] == 'seen') {
- $search .= ($search ? ' ' : '').'SEEN';
- }
- if ($rule['type'] == 'unseen') {
- $search .= ($search ? ' ' : '').'UNSEEN';
- }
- if ($rule['type'] == 'unanswered') {
- $search .= ($search ? ' ' : '').'UNANSWERED';
- }
- if ($rule['type'] == 'answered') {
- $search .= ($search ? ' ' : '').'ANSWERED';
- }
- if ($rule['type'] == 'smaller') {
- $search .= ($search ? ' ' : '').'SMALLER "'.str_replace('"', '', $rule['rulevalue']).'"';
- }
- if ($rule['type'] == 'larger') {
- $search .= ($search ? ' ' : '').'LARGER "'.str_replace('"', '', $rule['rulevalue']).'"';
+ if (empty($targetdir)) { // Use last date as filter if there is no targetdir defined.
+ $fromdate = 0;
+ if ($this->datelastok) {
+ $fromdate = $this->datelastok;
+ }
+ if ($fromdate > 0) {
+ $search .= ($search ? ' ' : '').'SINCE '.date('j-M-Y', $fromdate - 1); // SENTSINCE not supported. Date must be X-Abc-9999 (X on 1 digit if < 10)
+ }
+ //$search.=($search?' ':'').'SINCE 8-Apr-2018';
}
- if ($rule['type'] == 'withtrackingidinmsgid') {
- $searchfilterdoltrackid++; $searchhead .= '/Message-ID.*@'.preg_quote($host, '/').'/';
- }
- if ($rule['type'] == 'withouttrackingidinmsgid') {
- $searchfilterdoltrackid++; $searchhead .= '/Message-ID.*@'.preg_quote($host, '/').'/';
- }
- if ($rule['type'] == 'withtrackingid') {
- $searchfilterdoltrackid++; $searchhead .= '/References.*@'.preg_quote($host, '/').'/';
- }
- if ($rule['type'] == 'withouttrackingid') {
- $searchfilternodoltrackid++; $searchhead .= '! /References.*@'.preg_quote($host, '/').'/';
- }
-
- if ($rule['type'] == 'isanswer') {
- $searchfilterisanswer++; $searchhead .= '/References.*@.*/';
- }
- if ($rule['type'] == 'isnotanswer') {
- $searchfilterisnotanswer++; $searchhead .= '! /References.*@.*/';
- }
+ dol_syslog("IMAP search string = ".$search);
+ //var_dump($search);
}
- if (empty($targetdir)) { // Use last date as filter if there is no targetdir defined.
- $fromdate = 0;
- if ($this->datelastok) {
- $fromdate = $this->datelastok;
- }
- if ($fromdate > 0) {
- $search .= ($search ? ' ' : '').'SINCE '.date('j-M-Y', $fromdate - 1); // SENTSINCE not supported. Date must be X-Abc-9999 (X on 1 digit if < 10)
- }
- //$search.=($search?' ':'').'SINCE 8-Apr-2018';
- }
- dol_syslog("IMAP search string = ".$search);
- //var_dump($search);
-
$nbemailprocessed = 0;
$nbemailok = 0;
$nbactiondone = 0;
$charset = ($this->hostcharset ? $this->hostcharset : "UTF-8");
- // Scan IMAP inbox
- $arrayofemail = imap_search($connection, $search, null, $charset);
- if ($arrayofemail === false) {
- // Nothing found or search string not understood
- $mapoferrrors = imap_errors();
- if ($mapoferrrors !== false) {
- $error++;
- $this->error = "Search string not understood - ".join(',', $mapoferrrors);
+ if (!empty($conf->global->MAIN_IMAP_USE_PHPIMAP)) {
+ try {
+ //$criteria = [['ALL']];
+ //$Query = $client->getFolders()[0]->messages()->where($criteria);
+ $f = $client->getFolders(false, $this->source_directory);
+ $Query = $f[0]->messages()->where($criteria);
+ } catch (InvalidWhereQueryCriteriaException $e) {
+ $this->error = $e->getMessage();
$this->errors[] = $this->error;
+ dol_syslog("EmailCollector::doCollectOneCollector ".$this->error, LOG_ERR);
+ return -1;
+ } catch (Exception $e) {
+ $this->error = $e->getMessage();
+ $this->errors[] = $this->error;
+ dol_syslog("EmailCollector::doCollectOneCollector ".$this->error, LOG_ERR);
+ return -1;
+ }
+
+ try {
+ //var_dump($Query->count());
+ $arrayofemail = $Query->limit($this->maxemailpercollect)->setFetchOrder("asc")->get();
+ //var_dump($arrayofemail);
+ } catch (Exception $e) {
+ $this->error = $e->getMessage();
+ $this->errors[] = $this->error;
+ dol_syslog("EmailCollector::doCollectOneCollector ".$this->error, LOG_ERR);
+ return -1;
+ }
+ } else {
+ // Scan IMAP inbox
+ $arrayofemail = imap_search($connection, $search, null, $charset);
+ if ($arrayofemail === false) {
+ // Nothing found or search string not understood
+ $mapoferrrors = imap_errors();
+ if ($mapoferrrors !== false) {
+ $error++;
+ $this->error = "Search string not understood - ".join(',', $mapoferrrors);
+ $this->errors[] = $this->error;
+ }
}
}
@@ -1130,77 +1422,20 @@ class EmailCollector extends CommonObject
if (!$error && !empty($arrayofemail) && count($arrayofemail) > 0) {
// Loop to get part html and plain
/*
- 0 multipart/mixed
- 1 multipart/alternative
- 1.1 text/plain
- 1.2 text/html
- 2 message/rfc822
- 2 multipart/mixed
- 2.1 multipart/alternative
- 2.1.1 text/plain
- 2.1.2 text/html
- 2.2 message/rfc822
- 2.2 multipart/alternative
- 2.2.1 text/plain
- 2.2.2 text/html
+ 0 multipart/mixed
+ 1 multipart/alternative
+ 1.1 text/plain
+ 1.2 text/html
+ 2 message/rfc822
+ 2 multipart/mixed
+ 2.1 multipart/alternative
+ 2.1.1 text/plain
+ 2.1.2 text/html
+ 2.2 message/rfc822
+ 2.2 multipart/alternative
+ 2.2.1 text/plain
+ 2.2.2 text/html
*/
- /**
- * create_part_array
- *
- * @param Object $structure Structure
- * @param string $prefix prefix
- * @return array Array with number and object
- */
- /*function createPartArray($structure, $prefix = "")
- {
- //print_r($structure);
- $part_array=array();
- if (count($structure->parts) > 0) { // There some sub parts
- foreach ($structure->parts as $count => $part) {
- addPartToArray($part, $prefix.($count+1), $part_array);
- }
- }else{ // Email does not have a seperate mime attachment for text
- $part_array[] = array('part_number' => $prefix.'1', 'part_object' => $structure);
- }
- return $part_array;
- }*/
-
- /**
- * Sub function for createPartArray(). Only called by createPartArray() and itself.
- *
- * @param Object $obj Structure
- * @param string $partno Part no
- * @param array $part_array array
- * @return void
- */
- /*function addPartToArray($obj, $partno, &$part_array)
- {
- $part_array[] = array('part_number' => $partno, 'part_object' => $obj);
- if ($obj->type == 2) { // Check to see if the part is an attached email message, as in the RFC-822 type
- //print_r($obj);
- if (array_key_exists('parts', $obj)) { // Check to see if the email has parts
- foreach ($obj->parts as $count => $part) {
- // Iterate here again to compensate for the broken way that imap_fetchbody() handles attachments
- if (count($part->parts) > 0) {
- foreach ($part->parts as $count2 => $part2) {
- addPartToArray($part2, $partno.".".($count2+1), $part_array);
- }
- }else{ // Attached email does not have a seperate mime attachment for text
- $part_array[] = array('part_number' => $partno.'.'.($count+1), 'part_object' => $obj);
- }
- }
- }else{ // Not sure if this is possible
- $part_array[] = array('part_number' => $partno.'.1', 'part_object' => $obj);
- }
- }else{ // If there are more sub-parts, expand them out.
- if (array_key_exists('parts', $obj)) {
- foreach ($obj->parts as $count => $p) {
- addPartToArray($p, $partno.".".($count+1), $part_array);
- }
- }
- }
- }*/
-
dol_syslog("Start of loop on email", LOG_INFO, 1);
$iforemailloop = 0;
@@ -1208,23 +1443,25 @@ class EmailCollector extends CommonObject
if ($nbemailprocessed > 1000) {
break; // Do not process more than 1000 email per launch (this is a different protection than maxnbcollectedpercollect)
}
-
$iforemailloop++;
+
// GET header and overview datas
+ if (!empty($conf->global->MAIN_IMAP_USE_PHPIMAP)) {
+ $header = $imapemail->getHeader()->raw;
+ $overview = $imapemail->getAttributes();
+ } else {
+ //$header = imap_headerinfo($connection, $imapemail);
+ $header = imap_fetchheader($connection, $imapemail, 0);
+ $overview = imap_fetch_overview($connection, $imapemail, 0);
+ }
- $header = imap_fetchheader($connection, $imapemail, 0);
- $overview = imap_fetch_overview($connection, $imapemail, 0);
-
- // print $header;
- // var_dump($overview);
-
- // Process $header of email
$header = preg_replace('/\r\n\s+/m', ' ', $header); // When a header line is on several lines, merge lines
$matches = array();
preg_match_all('/([^: ]+): (.+?(?:\r\n\s(?:.+?))*)\r\n/m', $header, $matches);
$headers = array_combine($matches[1], $matches[2]);
+ //var_dump($headers);exit;
if (!empty($headers['in-reply-to']) && empty($headers['In-Reply-To'])) {
$headers['In-Reply-To'] = $headers['in-reply-to'];
@@ -1235,12 +1472,15 @@ class EmailCollector extends CommonObject
if (!empty($headers['message-id']) && empty($headers['Message-ID'])) {
$headers['Message-ID'] = $headers['message-id'];
}
+ if (!empty($headers['subject']) && empty($headers['Subject'])) {
+ $headers['Subject'] = $headers['subject'];
+ }
$headers['Subject'] = $this->decodeSMTPSubject($headers['Subject']);
dol_syslog("** Process email ".$iforemailloop." References: ".$headers['References']." Subject: ".$headers['Subject']);
- //print "Process mail ".$iforemailloop." Subject: ".dol_escape_htmltag($headers['Subject'])." References: ".dol_escape_htmltag($headers['References'])." In-Reply-To: ".dol_escape_htmltag($headers['In-Reply-To'])."
\n";
+
// If there is a filter on trackid
if ($searchfilterdoltrackid > 0) {
@@ -1315,21 +1555,40 @@ class EmailCollector extends CommonObject
$this->db->begin();
- dol_syslog("msgid=".$overview[0]->message_id." date=".dol_print_date($overview[0]->udate, 'dayrfc', 'gmt')." from=".$overview[0]->from." to=".$overview[0]->to." subject=".$overview[0]->subject);
+ if (!empty($conf->global->MAIN_IMAP_USE_PHPIMAP)) {
+ dol_syslog("msgid=".$overview['message_id']." date=".dol_print_date($overview['date'], 'dayrfc', 'gmt')." from=".$overview['from']." to=".$overview['to']." subject=".$overview['subject']);
- $overview[0]->subject = $this->decodeSMTPSubject($overview[0]->subject);
+ // Removed emojis
+ $overview['subject'] = preg_replace('/[\x{10000}-\x{10FFFF}]/u', "\xEF\xBF\xBD", $overview['subject']);
+ } else {
+ dol_syslog("msgid=".$overview[0]->message_id." date=".dol_print_date($overview[0]->udate, 'dayrfc', 'gmt')." from=".$overview[0]->from." to=".$overview[0]->to." subject=".$overview[0]->subject);
- $overview[0]->from = $this->decodeSMTPSubject($overview[0]->from);
+ $overview[0]->subject = $this->decodeSMTPSubject($overview[0]->subject);
- // Removed emojis
- $overview[0]->subject = preg_replace('/[\x{10000}-\x{10FFFF}]/u', "\xEF\xBF\xBD", $overview[0]->subject);
+ $overview[0]->from = $this->decodeSMTPSubject($overview[0]->from);
+ // Removed emojis
+ $overview[0]->subject = preg_replace('/[\x{10000}-\x{10FFFF}]/u', "\xEF\xBF\xBD", $overview[0]->subject);
+ }
// GET IMAP email structure/content
global $htmlmsg, $plainmsg, $charset, $attachments;
- $this->getmsg($connection, $imapemail);
-
+ if (!empty($conf->global->MAIN_IMAP_USE_PHPIMAP)) {
+ if ($imapemail->hasHTMLBody()) {
+ $htmlmsg = $imapemail->getHTMLBody();
+ }
+ if ($imapemail->hasTextBody()) {
+ $plainmsg = $imapemail->getTextBody();
+ }
+ if ($imapemail->hasAttachments()) {
+ $attachments = $imapemail->getAttachments()->all();
+ } else {
+ $attachments = [];
+ }
+ } else {
+ $this->getmsg($connection, $imapemail);
+ }
//print $plainmsg;
//var_dump($plainmsg); exit;
@@ -1393,16 +1652,29 @@ class EmailCollector extends CommonObject
//print $messagetext;
//exit;
- $fromstring = $overview[0]->from;
+ if (!empty($conf->global->MAIN_IMAP_USE_PHPIMAP)) {
+ $fromstring = $overview['from'];
+
+ $sender = $overview['sender'];
+ $to = $overview['to'];
+ $sendtocc = empty($overview['cc']) ? '' : $overview['cc'];
+ $sendtobcc = empty($overview['bcc']) ? '' : $overview['bcc'];
+ $date = $overview['date'];
+ $msgid = str_replace(array('<', '>'), '', $overview['message_id']);
+ $subject = $overview['subject'];
+ } else {
+ $fromstring = $overview[0]->from;
+
+ $sender = $overview[0]->sender;
+ $to = $overview[0]->to;
+ $sendtocc = $overview[0]->cc;
+ $sendtobcc = $overview[0]->bcc;
+ $date = $overview[0]->udate;
+ $msgid = str_replace(array('<', '>'), '', $overview[0]->message_id);
+ $subject = $overview[0]->subject;
+ //var_dump($msgid);exit;
+ }
- $sender = $overview[0]->sender;
- $to = $overview[0]->to;
- $sendtocc = $overview[0]->cc;
- $sendtobcc = $overview[0]->bcc;
- $date = $overview[0]->udate;
- $msgid = str_replace(array('<', '>'), '', $overview[0]->message_id);
- $subject = $overview[0]->subject;
- //var_dump($msgid);exit;
$reg = array();
if (preg_match('/^(.*)<(.*)>$/', $fromstring, $reg)) {
@@ -1780,8 +2052,9 @@ class EmailCollector extends CommonObject
dol_syslog("Third party with id=".$idtouseforthirdparty." email=".$emailtouseforthirdparty." name=".$nametouseforthirdparty." was not found");
$errorforactions++;
- $this->error = 'ErrorFailedToLoadThirdParty';
- $this->errors[] = 'ErrorFailedToLoadThirdParty';
+ $langs->load("errors");
+ $this->error = $langs->trans('ErrorFailedToLoadThirdParty', $idtouseforthirdparty, $emailtouseforthirdparty, $nametouseforthirdparty);
+ $this->errors[] = $this->error;
} elseif ($operation['type'] == 'loadandcreatethirdparty') {
dol_syslog("Third party with id=".$idtouseforthirdparty." email=".$emailtouseforthirdparty." name=".$nametouseforthirdparty." was not found. We try to create it.");
@@ -1911,49 +2184,49 @@ class EmailCollector extends CommonObject
$data[$val['filename']] = getFileData($imapemail, $val['pos'], $val['type'], $connection);
}
if (count($pj) > 0) {
- $sql = "SELECT rowid as id FROM " . MAIN_DB_PREFIX . "user WHERE email LIKE '%" . $from . "%'";
+ $sql = "SELECT rowid as id FROM ".MAIN_DB_PREFIX."user WHERE email LIKE '%".$this->db->escape($from)."%'";
$resql = $this->db->query($sql);
if ($this->db->num_rows($resql) == 0) {
$this->errors[] = 'User Not allowed to add documents';
}
$arrayobject = array(
'propale' => array('table' => 'propal',
- 'fields' => array('ref'),
- 'class' => 'comm/propal/class/propal.class.php',
- 'object' => 'Propal'),
+ 'fields' => array('ref'),
+ 'class' => 'comm/propal/class/propal.class.php',
+ 'object' => 'Propal'),
'holiday' => array('table' => 'holiday',
- 'fields' => array('ref'),
- 'class' => 'holiday/class/holiday.class.php',
- 'object' => 'Holiday'),
+ 'fields' => array('ref'),
+ 'class' => 'holiday/class/holiday.class.php',
+ 'object' => 'Holiday'),
'expensereport' => array('table' => 'expensereport',
- 'fields' => array('ref'),
- 'class' => 'expensereport/class/expensereport.class.php',
- 'object' => 'ExpenseReport'),
+ 'fields' => array('ref'),
+ 'class' => 'expensereport/class/expensereport.class.php',
+ 'object' => 'ExpenseReport'),
'recruitment/recruitmentjobposition' => array('table' => 'recruitment_recruitmentjobposition',
- 'fields' => array('ref'),
- 'class' => 'recruitment/class/recruitmentjobposition.class.php',
- 'object' => 'RecruitmentJobPosition'),
+ 'fields' => array('ref'),
+ 'class' => 'recruitment/class/recruitmentjobposition.class.php',
+ 'object' => 'RecruitmentJobPosition'),
'recruitment/recruitmentjobposition' => array('table' => 'recruitment_recruitmentcandidature',
- 'fields' => array('ref'),
- 'class' => 'recruitment/class/recruitmentcandidature.class.php',
- 'object' => ' RecruitmentCandidature'),
+ 'fields' => array('ref'),
+ 'class' => 'recruitment/class/recruitmentcandidature.class.php',
+ 'object' => ' RecruitmentCandidature'),
'societe' => array('table' => 'societe',
'fields' => array('code_client', 'code_fournisseur'),
'class' => 'societe/class/societe.class.php',
'object' => 'Societe'),
- 'commande' => array('table' => 'commande',
+ 'commande' => array('table' => 'commande',
'fields' => array('ref'),
'class' => 'commande/class/commande.class.php',
'object' => 'Commande'),
- 'expedition' => array('table' => 'expedition',
+ 'expedition' => array('table' => 'expedition',
'fields' => array('ref'),
'class' => 'expedition/class/expedition.class.php',
'object' => 'Expedition'),
- 'contract' => array('table' => 'contrat',
+ 'contract' => array('table' => 'contrat',
'fields' => array('ref'),
'class' => 'contrat/class/contrat.class.php',
'object' => 'Contrat'),
- 'fichinter' => array('table' => 'fichinter',
+ 'fichinter' => array('table' => 'fichinter',
'fields' => array('ref'),
'class' => 'fichinter/class/fichinter.class.php',
'object' => 'Fichinter'),
@@ -1961,51 +2234,51 @@ class EmailCollector extends CommonObject
'fields' => array('ref'),
'class' => 'ticket/class/ticket.class.php',
'object' => ' Ticket'),
- 'knowledgemanagement' => array('table' => 'knowledgemanagement_knowledgerecord',
+ 'knowledgemanagement' => array('table' => 'knowledgemanagement_knowledgerecord',
'fields' => array('ref'),
'class' => 'knowledgemanagement/class/knowledgemanagement.class.php',
'object' => 'KnowledgeRecord'),
- 'supplier_proposal' => array('table' => 'supplier_proposal',
+ 'supplier_proposal' => array('table' => 'supplier_proposal',
'fields' => array('ref'),
'class' => 'supplier_proposal/class/supplier_proposal.class.php',
'object' => 'SupplierProposal'),
- 'fournisseur/commande' => array('table' => 'commande_fournisseur',
+ 'fournisseur/commande' => array('table' => 'commande_fournisseur',
'fields' => array('ref', 'ref_supplier'),
'class' => 'fourn/class/fournisseur.commande.class.php',
'object' => 'SupplierProposal'),
- 'facture' => array('table' => 'facture',
+ 'facture' => array('table' => 'facture',
'fields' => array('ref'),
'class' => 'compta/facture/class/facture.class.php',
'object' => 'Facture'),
- 'fournisseur/facture' => array('table' => 'facture_fourn',
+ 'fournisseur/facture' => array('table' => 'facture_fourn',
'fields' => array('ref', ref_client),
'class' => 'fourn/class/fournisseur.facture.class.php',
'object' => 'FactureFournisseur'),
- 'produit' => array('table' => 'product',
+ 'produit' => array('table' => 'product',
'fields' => array('ref'),
'class' => 'product/class/product.class.php',
'object' => 'Product'),
- 'productlot' => array('table' => 'product_lot',
+ 'productlot' => array('table' => 'product_lot',
'fields' => array('batch'),
'class' => 'product/stock/class/productlot.class.php',
'object' => 'Productlot'),
- 'projet' => array('table' => 'projet',
+ 'projet' => array('table' => 'projet',
'fields' => array('ref'),
'class' => 'projet/class/projet.class.php',
'object' => 'Project'),
- 'projet_task' => array('table' => 'projet_task',
+ 'projet_task' => array('table' => 'projet_task',
'fields' => array('ref'),
'class' => 'projet/class/task.class.php',
'object' => 'Task'),
- 'ressource' => array('table' => 'resource',
+ 'ressource' => array('table' => 'resource',
'fields' => array('ref'),
'class' => 'ressource/class/dolressource.class.php',
'object' => 'Dolresource'),
- 'bom' => array('table' => 'bom_bom',
+ 'bom' => array('table' => 'bom_bom',
'fields' => array('ref'),
'class' => 'bom/class/bom.class.php',
'object' => 'BOM'),
- 'mrp' => array('table' => 'mrp_mo',
+ 'mrp' => array('table' => 'mrp_mo',
'fields' => array('ref'),
'class' => 'mrp/class/mo.class.php',
'object' => 'Mo'),
@@ -2072,7 +2345,6 @@ class EmailCollector extends CommonObject
} elseif ($operation['type'] == 'project') {
// Create project / lead
$projecttocreate = new Project($this->db);
-
$alreadycreated = $projecttocreate->fetch(0, '', '', $msgid);
if ($alreadycreated == 0) {
if ($thirdpartystatic->id > 0) {
@@ -2156,6 +2428,7 @@ class EmailCollector extends CommonObject
$projecttocreate->ref = $defaultref;
}
+
if ($errorforthisaction) {
$errorforactions++;
} else {
@@ -2169,6 +2442,20 @@ class EmailCollector extends CommonObject
$errorforactions++;
$this->error = 'Failed to create project: '.$langs->trans($projecttocreate->error);
$this->errors = $projecttocreate->errors;
+ } else {
+ if ($attachments) {
+ $destdir = $conf->project->dir_output.'/'.$projecttocreate->ref;
+ if (!dol_is_dir($destdir)) {
+ dol_mkdir($destdir);
+ }
+ if (!empty($conf->global->MAIN_IMAP_USE_PHPIMAP)) {
+ foreach ($attachments as $attachment) {
+ $attachment->save($destdir.'/');
+ }
+ } else {
+ $this->getmsg($connection, $imapemail, $destdir);
+ }
+ }
}
}
}
@@ -2282,6 +2569,12 @@ class EmailCollector extends CommonObject
$destdir = $conf->ticket->dir_output.'/'.$tickettocreate->ref;
if (!dol_is_dir($destdir)) {
dol_mkdir($destdir);
+ }
+ if (!empty($conf->global->MAIN_IMAP_USE_PHPIMAP)) {
+ foreach ($attachments as $attachment) {
+ $attachment->save($destdir.'/');
+ }
+ } else {
$this->getmsg($connection, $imapemail, $destdir);
}
}
@@ -2406,7 +2699,7 @@ class EmailCollector extends CommonObject
'header'=>$header,
'attachments'=>$attachments,
);
- $reshook = $hookmanager->executeHooks('doCollectOneCollector', $parameters, $this, $operation['type']);
+ $reshook = $hookmanager->executeHooks('doColleimapctOneCollector', $parameters, $this, $operation['type']);
if ($reshook < 0) {
$errorforthisaction++;
@@ -2417,6 +2710,7 @@ class EmailCollector extends CommonObject
}
}
+
if (!$errorforactions) {
$nbactiondoneforemail++;
}
@@ -2424,22 +2718,26 @@ class EmailCollector extends CommonObject
// Error for email or not ?
if (!$errorforactions) {
- if ($targetdir) {
- dol_syslog("EmailCollector::doCollectOneCollector move message ".$imapemail." to ".$connectstringtarget, LOG_DEBUG);
- $res = imap_mail_move($connection, $imapemail, $targetdir, 0);
- if ($res == false) {
- $errorforemail++;
- $this->error = imap_last_error();
- $this->errors[] = $this->error;
- dol_syslog(imap_last_error());
+ if (empty($conf->global->MAIN_IMAP_USE_PHPIMAP)) {
+ if ($targetdir) {
+ dol_syslog("EmailCollector::doCollectOneCollector move message ".$imapemail." to ".$connectstringtarget, LOG_DEBUG);
+ $res = imap_mail_move($connection, $imapemail, $targetdir, 0);
+ if ($res == false) {
+ $errorforemail++;
+ $this->error = imap_last_error();
+ $this->errors[] = $this->error;
+ dol_syslog(imap_last_error());
+ }
+ } else {
+ dol_syslog("EmailCollector::doCollectOneCollector message ".$imapemail." to ".$connectstringtarget." was set to read", LOG_DEBUG);
+ // TODO Make the move
}
- } else {
- dol_syslog("EmailCollector::doCollectOneCollector message ".$imapemail." to ".$connectstringtarget." was set to read", LOG_DEBUG);
}
} else {
$errorforemail++;
}
+
unset($objectemail);
unset($projectstatic);
unset($thirdpartystatic);
@@ -2472,9 +2770,13 @@ class EmailCollector extends CommonObject
$output = $langs->trans('NoNewEmailToProcess');
}
- imap_expunge($connection); // To validate any move
+ if (!empty($conf->global->MAIN_IMAP_USE_PHPIMAP)) {
+ $client->disconnect();
+ } else {
+ imap_expunge($connection); // To validate any move
- imap_close($connection);
+ imap_close($connection);
+ }
$this->datelastresult = $now;
$this->lastresult = $output;
@@ -2488,7 +2790,7 @@ class EmailCollector extends CommonObject
}
if (!empty($this->errors)) {
- $this->lastresult .= " - ".join(" - ", $this->errors);
+ $this->lastresult .= "
".join("
", $this->errors);
}
$this->codelastresult = ($error ? 'KO' : 'OK');
$this->update($user);
diff --git a/htdocs/emailcollector/class/emailcollectoraction.class.php b/htdocs/emailcollector/class/emailcollectoraction.class.php
index 37bd93926cb..46b787fc6fd 100644
--- a/htdocs/emailcollector/class/emailcollectoraction.class.php
+++ b/htdocs/emailcollector/class/emailcollectoraction.class.php
@@ -158,7 +158,7 @@ class EmailCollectorAction extends CommonObject
if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid'])) {
$this->fields['rowid']['visible'] = 0;
}
- if (empty($conf->multicompany->enabled) && isset($this->fields['entity'])) {
+ if (!isModEnabled('multicompany') && isset($this->fields['entity'])) {
$this->fields['entity']['enabled'] = 0;
}
diff --git a/htdocs/emailcollector/class/emailcollectorfilter.class.php b/htdocs/emailcollector/class/emailcollectorfilter.class.php
index 6386ee3c27f..c19610f14ad 100644
--- a/htdocs/emailcollector/class/emailcollectorfilter.class.php
+++ b/htdocs/emailcollector/class/emailcollectorfilter.class.php
@@ -127,7 +127,7 @@ class EmailCollectorFilter extends CommonObject
if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid'])) {
$this->fields['rowid']['visible'] = 0;
}
- if (empty($conf->multicompany->enabled) && isset($this->fields['entity'])) {
+ if (!isModEnabled('multicompany') && isset($this->fields['entity'])) {
$this->fields['entity']['enabled'] = 0;
}
diff --git a/htdocs/eventorganization/class/conferenceorbooth.class.php b/htdocs/eventorganization/class/conferenceorbooth.class.php
index a2eb140c789..2c22bfb77ab 100644
--- a/htdocs/eventorganization/class/conferenceorbooth.class.php
+++ b/htdocs/eventorganization/class/conferenceorbooth.class.php
@@ -152,7 +152,7 @@ class ConferenceOrBooth extends ActionComm
if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid'])) {
$this->fields['id']['visible'] = 0;
}
- if (empty($conf->multicompany->enabled) && isset($this->fields['entity'])) {
+ if (!isModEnabled('multicompany') && isset($this->fields['entity'])) {
$this->fields['entity']['enabled'] = 0;
}
diff --git a/htdocs/eventorganization/class/conferenceorboothattendee.class.php b/htdocs/eventorganization/class/conferenceorboothattendee.class.php
index 3dae278d3a1..158b29e4cf6 100644
--- a/htdocs/eventorganization/class/conferenceorboothattendee.class.php
+++ b/htdocs/eventorganization/class/conferenceorboothattendee.class.php
@@ -196,7 +196,7 @@ class ConferenceOrBoothAttendee extends CommonObject
if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid'])) {
$this->fields['rowid']['visible'] = 0;
}
- if (empty($conf->multicompany->enabled) && isset($this->fields['entity'])) {
+ if (!isModEnabled('multicompany') && isset($this->fields['entity'])) {
$this->fields['entity']['enabled'] = 0;
}
diff --git a/htdocs/eventorganization/conferenceorbooth_contact.php b/htdocs/eventorganization/conferenceorbooth_contact.php
index 57f2a76c042..33b8f633b3a 100644
--- a/htdocs/eventorganization/conferenceorbooth_contact.php
+++ b/htdocs/eventorganization/conferenceorbooth_contact.php
@@ -35,8 +35,9 @@ require_once DOL_DOCUMENT_ROOT.'/eventorganization/lib/eventorganization_confere
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
// Load translation files required by the page
-$langs->loadLangs(array("eventorganization", "projects", "companies", "other", "mails"));
+$langs->loadLangs(array('companies', 'eventorganization', 'mails', 'others', 'projects'));
+// Variables GET
$id = GETPOST('id', 'int');
$ref = GETPOST('ref', 'alpha');
$lineid = GETPOST('lineid', 'int');
@@ -51,12 +52,14 @@ $backtopageforcancel = GETPOST('backtopageforcancel', 'alpha');
$withproject = GETPOST('withproject', 'int');
+
// Initialize technical objects
$object = new ConferenceOrBooth($db);
$extrafields = new ExtraFields($db);
$projectstatic = new Project($db);
$diroutputmassaction = $conf->eventorganization->dir_output.'/temp/massgeneration/'.$user->id;
$hookmanager->initHooks(array('conferenceorboothcontact', 'globalcard')); // Note that conf->hooks_modules contains array
+
// Fetch optionals attributes and labels
$extrafields->fetch_name_optionals_label($object->table_element);
@@ -69,6 +72,7 @@ include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be includ
if ($user->socid > 0) {
accessforbidden();
}
+
$isdraft = (($object->status== $object::STATUS_DRAFT) ? 1 : 0);
$result = restrictedArea($user, 'eventorganization', $object->id, '', '', 'fk_soc', 'rowid', $isdraft);
diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php
index c226ba927be..3a0a9869571 100644
--- a/htdocs/expedition/card.php
+++ b/htdocs/expedition/card.php
@@ -47,10 +47,10 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php';
require_once DOL_DOCUMENT_ROOT.'/product/stock/class/productlot.class.php';
require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
-if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) {
+if (isModEnabled("product") || isModEnabled("service")) {
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
}
-if (!empty($conf->propal->enabled)) {
+if (isModEnabled("propal")) {
require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
}
if (!empty($conf->productbatch->enabled)) {
@@ -763,10 +763,10 @@ if (empty($reshook)) {
// Define output language
$outputlangs = $langs;
$newlang = '';
- if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
+ if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
$newlang = GETPOST('lang_id', 'aZ09');
}
- if ($conf->global->MAIN_MULTILANGS && empty($newlang)) {
+ if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) {
$newlang = $object->thirdparty->default_lang;
}
if (!empty($newlang)) {
@@ -878,7 +878,7 @@ if ($action == 'create') {
if ($origin == 'commande' && !empty($conf->commande->enabled)) {
print $langs->trans("RefOrder");
}
- if ($origin == 'propal' && !empty($conf->propal->enabled)) {
+ if ($origin == 'propal' && isModEnabled("propal")) {
print $langs->trans("RefProposal");
}
print '
';
@@ -1315,10 +1315,10 @@ if ($action == 'create') {
$detail = '';
$detail .= $langs->trans("Batch").': '.$dbatch->batch;
- if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) {
+ if (empty($conf->global->PRODUCT_DISABLE_SELLBY) && !empty($dbatch->sellby)) {
$detail .= ' - '.$langs->trans("SellByDate").': '.dol_print_date($dbatch->sellby, "day");
}
- if (empty($conf->global->PRODUCT_DISABLE_EATBY)) {
+ if (empty($conf->global->PRODUCT_DISABLE_EATBY) && !empty($dbatch->eatby)) {
$detail .= ' - '.$langs->trans("EatByDate").': '.dol_print_date($dbatch->eatby, "day");
}
$detail .= ' - '.$langs->trans("Qty").': '.$dbatch->qty;
@@ -1526,6 +1526,12 @@ if ($action == 'create') {
} else {
print 'TableLotIncompleteRunRepairWithParamStandardEqualConfirmed';
}
+ if (empty($conf->global->PRODUCT_DISABLE_SELLBY) && !empty($dbatch->sellby)) {
+ print ' - '.$langs->trans("SellByDate").': '.dol_print_date($dbatch->sellby, "day");
+ }
+ if (empty($conf->global->PRODUCT_DISABLE_EATBY) && !empty($dbatch->eatby)) {
+ print ' - '.$langs->trans("EatByDate").': '.dol_print_date($dbatch->eatby, "day");
+ }
print ' ('.$dbatch->qty.')';
$quantityToBeDelivered -= $deliverableQty;
if ($quantityToBeDelivered < 0) {
@@ -1712,7 +1718,7 @@ if ($action == 'create') {
$objectsrc = new Commande($db);
$objectsrc->fetch($object->$typeobject->id);
}
- if ($typeobject == 'propal' && $object->$typeobject->id && !empty($conf->propal->enabled)) {
+ if ($typeobject == 'propal' && $object->$typeobject->id && isModEnabled("propal")) {
$objectsrc = new Propal($db);
$objectsrc->fetch($object->$typeobject->id);
}
@@ -1781,7 +1787,7 @@ if ($action == 'create') {
print " \n";
print '';
}
- if ($typeobject == 'propal' && $object->$typeobject->id && !empty($conf->propal->enabled)) {
+ if ($typeobject == 'propal' && $object->$typeobject->id && isModEnabled("propal")) {
print '
';
print $langs->trans("RefProposal").' ';
print '';
diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php
index 22d1d0c7b19..5df7108e895 100644
--- a/htdocs/expedition/class/expedition.class.php
+++ b/htdocs/expedition/class/expedition.class.php
@@ -37,7 +37,7 @@
require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
require_once DOL_DOCUMENT_ROOT."/core/class/commonobjectline.class.php";
require_once DOL_DOCUMENT_ROOT.'/core/class/commonincoterm.class.php';
-if (!empty($conf->propal->enabled)) {
+if (isModEnabled("propal")) {
require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
}
if (!empty($conf->commande->enabled)) {
@@ -752,7 +752,7 @@ class Expedition extends CommonObject
//var_dump($this->lines[$i]);
$mouvS = new MouvementStock($this->db);
- //$mouvS->origin = dol_clone($this, 1);
+
$mouvS->setOrigin($this->element, $this->id);
if (empty($obj->edbrowid)) {
diff --git a/htdocs/expedition/contact.php b/htdocs/expedition/contact.php
index 669c6f8e56d..112d35a63aa 100644
--- a/htdocs/expedition/contact.php
+++ b/htdocs/expedition/contact.php
@@ -57,7 +57,7 @@ if ($id > 0 || !empty($ref)) {
$objectsrc = new Commande($db);
$objectsrc->fetch($object->$typeobject->id);
}
- if ($typeobject == 'propal' && $object->$typeobject->id && !empty($conf->propal->enabled)) {
+ if ($typeobject == 'propal' && $object->$typeobject->id && isModEnabled("propal")) {
$objectsrc = new Propal($db);
$objectsrc->fetch($object->$typeobject->id);
}
@@ -206,7 +206,7 @@ if ($id > 0 || !empty($ref)) {
print " \n";
print '';
}
- if ($typeobject == 'propal' && $object->$typeobject->id && !empty($conf->propal->enabled)) {
+ if ($typeobject == 'propal' && $object->$typeobject->id && isModEnabled("propal")) {
print '
';
$objectsrc = new Propal($db);
$objectsrc->fetch($object->$typeobject->id);
diff --git a/htdocs/expedition/note.php b/htdocs/expedition/note.php
index e391d5be180..c8fc0ff35be 100644
--- a/htdocs/expedition/note.php
+++ b/htdocs/expedition/note.php
@@ -55,7 +55,7 @@ if ($id > 0 || !empty($ref)) {
$objectsrc = new Commande($db);
$objectsrc->fetch($object->$typeobject->id);
}
- if ($typeobject == 'propal' && $object->$typeobject->id && !empty($conf->propal->enabled)) {
+ if ($typeobject == 'propal' && $object->$typeobject->id && isModEnabled("propal")) {
$objectsrc = new Propal($db);
$objectsrc->fetch($object->$typeobject->id);
}
diff --git a/htdocs/expedition/shipment.php b/htdocs/expedition/shipment.php
index bf352ebe5da..0be623ab6bf 100644
--- a/htdocs/expedition/shipment.php
+++ b/htdocs/expedition/shipment.php
@@ -40,10 +40,10 @@ if (!empty($conf->project->enabled)) {
if (!empty($conf->stock->enabled)) {
require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php';
}
-if (!empty($conf->propal->enabled)) {
+if (isModEnabled("propal")) {
require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
}
-if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) {
+if (isModEnabled("product") || isModEnabled("service")) {
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
}
diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php
index c714ad452c1..05831c5dd97 100644
--- a/htdocs/expensereport/card.php
+++ b/htdocs/expensereport/card.php
@@ -83,7 +83,7 @@ if (! empty($conf->global->EXPENSEREPORT_PREFILL_DATES_WITH_CURRENT_MONTH)) {
$rootfordata = DOL_DATA_ROOT;
$rootforuser = DOL_DATA_ROOT;
// If multicompany module is enabled, we redefine the root of data
-if (!empty($conf->multicompany->enabled) && !empty($conf->entity) && $conf->entity > 1) {
+if (isModEnabled('multicompany') && !empty($conf->entity) && $conf->entity > 1) {
$rootfordata .= '/'.$conf->entity;
}
$conf->expensereport->dir_output = $rootfordata.'/expensereport';
@@ -383,10 +383,10 @@ if (empty($reshook)) {
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
$outputlangs = $langs;
$newlang = '';
- if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
+ if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
$newlang = GETPOST('lang_id', 'aZ09');
}
- if ($conf->global->MAIN_MULTILANGS && empty($newlang)) {
+ if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) {
$newlang = $object->thirdparty->default_lang;
}
if (!empty($newlang)) {
@@ -493,10 +493,10 @@ if (empty($reshook)) {
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
$outputlangs = $langs;
$newlang = '';
- if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
+ if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
$newlang = GETPOST('lang_id', 'aZ09');
}
- if ($conf->global->MAIN_MULTILANGS && empty($newlang)) {
+ if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) {
$newlang = $object->thirdparty->default_lang;
}
if (!empty($newlang)) {
@@ -603,10 +603,10 @@ if (empty($reshook)) {
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
$outputlangs = $langs;
$newlang = '';
- if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
+ if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
$newlang = GETPOST('lang_id', 'aZ09');
}
- if ($conf->global->MAIN_MULTILANGS && empty($newlang)) {
+ if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) {
$newlang = $object->thirdparty->default_lang;
}
if (!empty($newlang)) {
@@ -717,10 +717,10 @@ if (empty($reshook)) {
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
$outputlangs = $langs;
$newlang = '';
- if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
+ if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
$newlang = GETPOST('lang_id', 'aZ09');
}
- if ($conf->global->MAIN_MULTILANGS && empty($newlang)) {
+ if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) {
$newlang = $object->thirdparty->default_lang;
}
if (!empty($newlang)) {
@@ -831,10 +831,10 @@ if (empty($reshook)) {
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
$outputlangs = $langs;
$newlang = '';
- if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
+ if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
$newlang = GETPOST('lang_id', 'aZ09');
}
- if ($conf->global->MAIN_MULTILANGS && empty($newlang)) {
+ if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) {
$newlang = $object->thirdparty->default_lang;
}
if (!empty($newlang)) {
@@ -943,10 +943,10 @@ if (empty($reshook)) {
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
$outputlangs = $langs;
$newlang = '';
- if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
+ if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
$newlang = GETPOST('lang_id', 'aZ09');
}
- if ($conf->global->MAIN_MULTILANGS && empty($newlang)) {
+ if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) {
$newlang = $object->thirdparty->default_lang;
}
if (!empty($newlang)) {
@@ -982,10 +982,10 @@ if (empty($reshook)) {
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
$outputlangs = $langs;
$newlang = '';
- if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
+ if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
$newlang = GETPOST('lang_id', 'aZ09');
}
- if ($conf->global->MAIN_MULTILANGS && empty($newlang)) {
+ if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) {
$newlang = $object->thirdparty->default_lang;
}
if (!empty($newlang)) {
@@ -1011,10 +1011,10 @@ if (empty($reshook)) {
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
$outputlangs = $langs;
$newlang = '';
- if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
+ if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
$newlang = GETPOST('lang_id', 'aZ09');
}
- if ($conf->global->MAIN_MULTILANGS && empty($newlang)) {
+ if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) {
$newlang = $object->thirdparty->default_lang;
}
if (!empty($newlang)) {
@@ -1229,10 +1229,10 @@ if (empty($reshook)) {
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
$outputlangs = $langs;
$newlang = '';
- if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
+ if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
$newlang = GETPOST('lang_id', 'aZ09');
}
- if ($conf->global->MAIN_MULTILANGS && empty($newlang)) {
+ if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) {
$newlang = $object->thirdparty->default_lang;
}
if (!empty($newlang)) {
@@ -1321,10 +1321,10 @@ if (empty($reshook)) {
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
$outputlangs = $langs;
$newlang = '';
- if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
+ if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
$newlang = GETPOST('lang_id', 'aZ09');
}
- if ($conf->global->MAIN_MULTILANGS && empty($newlang)) {
+ if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) {
$newlang = $object->thirdparty->default_lang;
}
if (!empty($newlang)) {
@@ -1930,7 +1930,7 @@ if ($action == 'create') {
// List of payments already done
$nbcols = 3;
$nbrows = 0;
- if (!empty($conf->banque->enabled)) {
+ if (isModEnabled("banque")) {
$nbrows++;
$nbcols++;
}
@@ -1941,7 +1941,7 @@ if ($action == 'create') {
print ' '.$langs->trans('Payments').' ';
print ''.$langs->trans('Date').' ';
print ''.$langs->trans('Type').' ';
- if (!empty($conf->banque->enabled)) {
+ if (isModEnabled("banque")) {
print ''.$langs->trans('BankAccount').' ';
}
print ''.$langs->trans('Amount').' ';
@@ -1950,7 +1950,7 @@ if ($action == 'create') {
// Payments already done (from payment on this expensereport)
$sql = "SELECT p.rowid, p.num_payment, p.datep as dp, p.amount, p.fk_bank,";
- $sql .= "c.code as p_code, c.libelle as payment_type,";
+ $sql .= "c.code as payment_code, c.libelle as payment_type,";
$sql .= "ba.rowid as baid, ba.ref as baref, ba.label, ba.number as banumber, ba.account_number, ba.fk_accountancy_journal";
$sql .= " FROM ".MAIN_DB_PREFIX."expensereport as e, ".MAIN_DB_PREFIX."payment_expensereport as p";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON p.fk_typepayment = c.id";
@@ -1969,19 +1969,21 @@ if ($action == 'create') {
$objp = $db->fetch_object($resql);
$paymentexpensereportstatic->id = $objp->rowid;
- $paymentexpensereportstatic->datepaye = $db->jdate($objp->dp);
+ $paymentexpensereportstatic->datep = $db->jdate($objp->dp);
$paymentexpensereportstatic->ref = $objp->rowid;
$paymentexpensereportstatic->num_payment = $objp->num_payment;
- $paymentexpensereportstatic->payment_code = $objp->payment_code;
+ $paymentexpensereportstatic->type_code = $objp->payment_code;
+ $paymentexpensereportstatic->type_label = $objp->payment_type;
print '';
print '';
print $paymentexpensereportstatic->getNomUrl(1);
print ' ';
print ''.dol_print_date($db->jdate($objp->dp), 'day')." \n";
- $labeltype = $langs->trans("PaymentType".$objp->p_code) != ("PaymentType".$objp->p_code) ? $langs->trans("PaymentType".$objp->p_code) : $objp->payment_type;
+ $labeltype = $langs->trans("PaymentType".$objp->payment_code) != ("PaymentType".$objp->payment_code) ? $langs->trans("PaymentType".$objp->payment_code) : $objp->payment_type;
print "".$labeltype.' '.$objp->num_payment." \n";
- if (!empty($conf->banque->enabled)) {
+ // Bank account
+ if (isModEnabled("banque")) {
$bankaccountstatic->id = $objp->baid;
$bankaccountstatic->ref = $objp->baref;
$bankaccountstatic->label = $objp->baref;
@@ -2765,7 +2767,7 @@ if ($action != 'create' && $action != 'edit' && $action != 'editline') {
}
// If bank module is used
- if ($user->rights->expensereport->to_paid && !empty($conf->banque->enabled) && $object->status == ExpenseReport::STATUS_APPROVED) {
+ if ($user->rights->expensereport->to_paid && isModEnabled("banque") && $object->status == ExpenseReport::STATUS_APPROVED) {
// Pay
if ($remaintopay == 0) {
print ''.$langs->trans('DoPayment').'
';
diff --git a/htdocs/expensereport/class/paymentexpensereport.class.php b/htdocs/expensereport/class/paymentexpensereport.class.php
index 5f9e9f17e6f..e871cba86b3 100644
--- a/htdocs/expensereport/class/paymentexpensereport.class.php
+++ b/htdocs/expensereport/class/paymentexpensereport.class.php
@@ -137,14 +137,17 @@ class PaymentExpenseReport extends CommonObject
if (isset($this->note_public)) {
$this->note_public = trim($this->note_public);
}
+ if (isset($this->note_private)) {
+ $this->note_private = trim($this->note_private);
+ }
if (isset($this->fk_bank)) {
- $this->fk_bank = trim($this->fk_bank);
+ $this->fk_bank = ((int) $this->fk_bank);
}
if (isset($this->fk_user_creat)) {
- $this->fk_user_creat = trim($this->fk_user_creat);
+ $this->fk_user_creat = ((int) $this->fk_user_creat);
}
if (isset($this->fk_user_modif)) {
- $this->fk_user_modif = trim($this->fk_user_modif);
+ $this->fk_user_modif = ((int) $this->fk_user_modif);
}
$totalamount = 0;
@@ -170,7 +173,7 @@ class PaymentExpenseReport extends CommonObject
$sql .= " '".$this->db->idate($this->datepaid)."',";
$sql .= " ".price2num($totalamount).",";
$sql .= " ".((int) $this->fk_typepayment).", '".$this->db->escape($this->num_payment)."', '".$this->db->escape($this->note_public)."', ".((int) $user->id).",";
- $sql .= " 0)";
+ $sql .= " 0)"; // fk_bank is ID of transaction into ll_bank
dol_syslog(get_class($this)."::create", LOG_DEBUG);
$resql = $this->db->query($sql);
@@ -513,7 +516,7 @@ class PaymentExpenseReport extends CommonObject
$error = 0;
- if (!empty($conf->banque->enabled)) {
+ if (isModEnabled("banque")) {
include_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
$acc = new Account($this->db);
@@ -540,7 +543,7 @@ class PaymentExpenseReport extends CommonObject
);
// Update fk_bank in llx_paiement.
- // On connait ainsi le paiement qui a genere l'ecriture bancaire
+ // So we wil know the payment that have generated the bank transaction
if ($bank_line_id > 0) {
$result = $this->update_fk_bank($bank_line_id);
if ($result <= 0) {
@@ -585,6 +588,7 @@ class PaymentExpenseReport extends CommonObject
}
} else {
$this->error = $acc->error;
+ $this->errors = $acc->errors;
$error++;
}
}
diff --git a/htdocs/expensereport/payment/card.php b/htdocs/expensereport/payment/card.php
index 847c059a9c6..c24689a9d69 100644
--- a/htdocs/expensereport/payment/card.php
+++ b/htdocs/expensereport/payment/card.php
@@ -26,7 +26,7 @@ require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php';
require_once DOL_DOCUMENT_ROOT.'/expensereport/class/paymentexpensereport.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/modules/expensereport/modules_expensereport.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/expensereport.lib.php';
-if (!empty($conf->banque->enabled)) {
+if (isModEnabled("banque")) {
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
}
@@ -120,7 +120,7 @@ print ' '.$langs->trans('Note').' '.nl2
$disable_delete = 0;
// Bank account
-if (!empty($conf->banque->enabled)) {
+if (isModEnabled("banque")) {
if ($object->bank_account) {
$bankline = new AccountLine($db);
$bankline->fetch($object->bank_line);
diff --git a/htdocs/expensereport/payment/list.php b/htdocs/expensereport/payment/list.php
index 3f3e017612d..5a08c30f636 100644
--- a/htdocs/expensereport/payment/list.php
+++ b/htdocs/expensereport/payment/list.php
@@ -103,7 +103,7 @@ $arrayfields = array(
'u.login' =>array('label'=>"User", 'checked'=>1, 'position'=>30),
'c.libelle' =>array('label'=>"Type", 'checked'=>1, 'position'=>40),
'pndf.num_payment' =>array('label'=>"Numero", 'checked'=>1, 'position'=>50, 'tooltip'=>"ChequeOrTransferNumber"),
- 'ba.label' =>array('label'=>"Account", 'checked'=>1, 'position'=>60, 'enable'=>(!empty($conf->banque->enabled))),
+ 'ba.label' =>array('label'=>"Account", 'checked'=>1, 'position'=>60, 'enable'=>(isModEnabled("banque"))),
'pndf.amount' =>array('label'=>"Amount", 'checked'=>1, 'position'=>70),
);
$arrayfields = dol_sort_array($arrayfields, 'position');
diff --git a/htdocs/expensereport/payment/payment.php b/htdocs/expensereport/payment/payment.php
index 185b3cdc139..74e0c63151b 100644
--- a/htdocs/expensereport/payment/payment.php
+++ b/htdocs/expensereport/payment/payment.php
@@ -75,7 +75,8 @@ if ($action == 'add_payment') {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Date")), null, 'errors');
$error++;
}
- if (!empty($conf->banque->enabled) && !($accountid > 0)) {
+
+ if (isModEnabled("banque") && !($accountid > 0)) {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("AccountToDebit")), null, 'errors');
$error++;
}
@@ -87,14 +88,16 @@ if ($action == 'add_payment') {
// Read possible payments
foreach ($_POST as $key => $value) {
if (substr($key, 0, 7) == 'amount_') {
- $amounts[$expensereport->fk_user_author] = price2num(GETPOST($key));
- $total += price2num(GETPOST($key));
+ if (GETPOST($key)) {
+ $amounts[$expensereport->fk_user_author] = price2num(GETPOST($key));
+ $total += price2num(GETPOST($key));
+ }
}
}
if (count($amounts) <= 0) {
$error++;
- $errmsg = 'ErrorNoPaymentDefined';
+ setEventMessages('ErrorNoPaymentDefined', null, 'errors');
}
if (!$error) {
@@ -109,6 +112,7 @@ if ($action == 'add_payment') {
$payment->fk_typepayment = GETPOST("fk_typepayment", 'int');
$payment->num_payment = GETPOST("num_payment", 'alphanothtml');
$payment->note_public = GETPOST("note_public", 'restricthtml');
+ $payment->fk_bank = $accountid;
if (!$error) {
$paymentid = $payment->create($user);
@@ -120,7 +124,7 @@ if ($action == 'add_payment') {
if (!$error) {
$result = $payment->addPaymentToBank($user, 'payment_expensereport', '(ExpenseReportPayment)', $accountid, '', '');
- if (!$result > 0) {
+ if ($result <= 0) {
setEventMessages($payment->error, $payment->errors, 'errors');
$error++;
}
@@ -130,7 +134,7 @@ if ($action == 'add_payment') {
$payment->fetch($paymentid);
if ($expensereport->total_ttc - $payment->amount == 0) {
$result = $expensereport->setPaid($expensereport->id, $user);
- if (!$result > 0) {
+ if (!($result > 0)) {
setEventMessages($payment->error, $payment->errors, 'errors');
$error++;
}
@@ -202,7 +206,7 @@ if ($action == 'create' || empty($action)) {
print ''."\n";
print ''.$langs->trans("Period").' '.get_date_range($expensereport->date_debut, $expensereport->date_fin, "", $langs, 0).' ';
- print ''.$langs->trans("Amount").' '.price($expensereport->total_ttc, 0, $outputlangs, 1, -1, -1, $conf->currency).' ';
+ print ''.$langs->trans("Amount").' '.price($expensereport->total_ttc, 0, $langs, 1, -1, -1, $conf->currency).' ';
$sql = "SELECT sum(p.amount) as total";
$sql .= " FROM ".MAIN_DB_PREFIX."payment_expensereport as p, ".MAIN_DB_PREFIX."expensereport as e";
@@ -214,8 +218,8 @@ if ($action == 'create' || empty($action)) {
$sumpaid = $obj->total;
$db->free($resql);
}
- print ''.$langs->trans("AlreadyPaid").' '.price($sumpaid, 0, $outputlangs, 1, -1, -1, $conf->currency).' ';
- print ''.$langs->trans("RemainderToPay").' '.price($total - $sumpaid, 0, $outputlangs, 1, -1, -1, $conf->currency).' ';
+ print ''.$langs->trans("AlreadyPaid").' '.price($sumpaid, 0, $langs, 1, -1, -1, $conf->currency).' ';
+ print ''.$langs->trans("RemainderToPay").' '.price($total - $sumpaid, 0, $langs, 1, -1, -1, $conf->currency).' ';
print '
';
@@ -223,6 +227,8 @@ if ($action == 'create' || empty($action)) {
print dol_get_fiche_end();
+ print ' ';
+
print dol_get_fiche_head();
print '