diff --git a/htdocs/accountancy/admin/index.php b/htdocs/accountancy/admin/index.php index 7eae1eb6536..ae36f0f7fa6 100644 --- a/htdocs/accountancy/admin/index.php +++ b/htdocs/accountancy/admin/index.php @@ -37,8 +37,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; $langs->loadLangs(array("compta", "bills", "admin", "accountancy", "other")); // Security access -if (empty($user->rights->accounting->chartofaccount)) -{ +if (empty($user->rights->accounting->chartofaccount)) { accessforbidden(); } @@ -48,9 +47,9 @@ $action = GETPOST('action', 'aZ09'); $list = array( 'ACCOUNTING_LENGTH_GACCOUNT', 'ACCOUNTING_LENGTH_AACCOUNT', -// 'ACCOUNTING_LIMIT_LIST_VENTILATION' // there is already a global parameter to define the nb of records in lists, we must use it in priority. Having one parameter for nb of record for each page is deprecated. -// 'ACCOUNTING_LENGTH_DESCRIPTION', // adjust size displayed for lines description for dol_trunc -// 'ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT', // adjust size displayed for select account description for dol_trunc +// 'ACCOUNTING_LIMIT_LIST_VENTILATION' // there is already a global parameter to define the nb of records in lists, we must use it in priority. Having one parameter for nb of record for each page is deprecated. +// 'ACCOUNTING_LENGTH_DESCRIPTION', // adjust size displayed for lines description for dol_trunc +// 'ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT', // adjust size displayed for select account description for dol_trunc ); $list_binding = array( @@ -65,10 +64,8 @@ $list_binding = array( if ($action == 'update') { $error = 0; - if (!$error) - { - foreach ($list as $constname) - { + if (!$error) { + foreach ($list as $constname) { $constvalue = GETPOST($constname, 'alpha'); if (!dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) { @@ -79,8 +76,7 @@ if ($action == 'update') { setEventMessages($langs->trans("Error"), null, 'errors'); } - foreach ($list_binding as $constname) - { + foreach ($list_binding as $constname) { $constvalue = GETPOST($constname, 'alpha'); if ($constname == 'ACCOUNTING_DATE_START_BINDING') { @@ -104,8 +100,9 @@ if ($action == 'update') { if ($action == 'setlistsorttodo') { $setlistsorttodo = GETPOST('value', 'int'); $res = dolibarr_set_const($db, "ACCOUNTING_LIST_SORT_VENTILATION_TODO", $setlistsorttodo, 'yesno', 0, '', $conf->entity); - if (!$res > 0) + if (!$res > 0) { $error++; + } if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); @@ -117,8 +114,9 @@ if ($action == 'setlistsorttodo') { if ($action == 'setlistsortdone') { $setlistsortdone = GETPOST('value', 'int'); $res = dolibarr_set_const($db, "ACCOUNTING_LIST_SORT_VENTILATION_DONE", $setlistsortdone, 'yesno', 0, '', $conf->entity); - if (!$res > 0) + if (!$res > 0) { $error++; + } if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } else { @@ -129,8 +127,9 @@ if ($action == 'setlistsortdone') { if ($action == 'setmanagezero') { $setmanagezero = GETPOST('value', 'int'); $res = dolibarr_set_const($db, "ACCOUNTING_MANAGE_ZERO", $setmanagezero, 'yesno', 0, '', $conf->entity); - if (!$res > 0) + if (!$res > 0) { $error++; + } if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } else { @@ -141,8 +140,9 @@ if ($action == 'setmanagezero') { if ($action == 'setdisabledirectinput') { $setdisabledirectinput = GETPOST('value', 'int'); $res = dolibarr_set_const($db, "BANK_DISABLE_DIRECT_INPUT", $setdisabledirectinput, 'yesno', 0, '', $conf->entity); - if (!$res > 0) + if (!$res > 0) { $error++; + } if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } else { @@ -153,8 +153,9 @@ if ($action == 'setdisabledirectinput') { if ($action == 'setenabledraftexport') { $setenabledraftexport = GETPOST('value', 'int'); $res = dolibarr_set_const($db, "ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL", $setenabledraftexport, 'yesno', 0, '', $conf->entity); - if (!$res > 0) + if (!$res > 0) { $error++; + } if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } else { @@ -165,8 +166,9 @@ if ($action == 'setenabledraftexport') { if ($action == 'setenablesubsidiarylist') { $setenablesubsidiarylist = GETPOST('value', 'int'); $res = dolibarr_set_const($db, "ACCOUNTANCY_COMBO_FOR_AUX", $setenablesubsidiarylist, 'yesno', 0, '', $conf->entity); - if (!$res > 0) + if (!$res > 0) { $error++; + } if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } else { @@ -177,8 +179,9 @@ if ($action == 'setenablesubsidiarylist') { if ($action == 'setdisablebindingonsales') { $setdisablebindingonsales = GETPOST('value', 'int'); $res = dolibarr_set_const($db, "ACCOUNTING_DISABLE_BINDING_ON_SALES", $setdisablebindingonsales, 'yesno', 0, '', $conf->entity); - if (!$res > 0) + if (!$res > 0) { $error++; + } if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } else { @@ -189,8 +192,9 @@ if ($action == 'setdisablebindingonsales') { if ($action == 'setdisablebindingonpurchases') { $setdisablebindingonpurchases = GETPOST('value', 'int'); $res = dolibarr_set_const($db, "ACCOUNTING_DISABLE_BINDING_ON_PURCHASES", $setdisablebindingonpurchases, 'yesno', 0, '', $conf->entity); - if (!$res > 0) + if (!$res > 0) { $error++; + } if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } else { @@ -201,8 +205,9 @@ if ($action == 'setdisablebindingonpurchases') { if ($action == 'setdisablebindingonexpensereports') { $setdisablebindingonexpensereports = GETPOST('value', 'int'); $res = dolibarr_set_const($db, "ACCOUNTING_DISABLE_BINDING_ON_EXPENSEREPORTS", $setdisablebindingonexpensereports, 'yesno', 0, '', $conf->entity); - if (!$res > 0) + if (!$res > 0) { $error++; + } if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } else { @@ -289,11 +294,12 @@ if (!empty($conf->global->ACCOUNTING_MANAGE_ZERO)) { print ''; // Param a user $user->rights->accounting->chartofaccount can access -foreach ($list as $key) -{ +foreach ($list as $key) { print ''; - if (!empty($conf->global->ACCOUNTING_MANAGE_ZERO) && ($key == 'ACCOUNTING_LENGTH_GACCOUNT' || $key == 'ACCOUNTING_LENGTH_AACCOUNT')) continue; + if (!empty($conf->global->ACCOUNTING_MANAGE_ZERO) && ($key == 'ACCOUNTING_LENGTH_GACCOUNT' || $key == 'ACCOUNTING_LENGTH_AACCOUNT')) { + continue; + } // Param $label = $langs->trans($key); @@ -342,8 +348,7 @@ if (!empty($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_DONE)) { print ''; // Param a user $user->rights->accounting->chartofaccount can access -foreach ($list_binding as $key) -{ +foreach ($list_binding as $key) { print ''; // Param diff --git a/htdocs/accountancy/bookkeeping/listbyaccount.php b/htdocs/accountancy/bookkeeping/listbyaccount.php index f1883f0da77..34a6b2d5ffd 100644 --- a/htdocs/accountancy/bookkeeping/listbyaccount.php +++ b/htdocs/accountancy/bookkeeping/listbyaccount.php @@ -1,7 +1,7 @@ * Copyright (C) 2013-2016 Olivier Geffroy - * Copyright (C) 2013-2016 Florian Henry + * Copyright (C) 2013-2020 Florian Henry * Copyright (C) 2013-2020 Alexandre Spangaro * Copyright (C) 2018 Frédéric France * @@ -22,7 +22,7 @@ /** * \file htdocs/accountancy/bookkeeping/listbyaccount.php * \ingroup Accountancy (Double entries) - * \brief List operation of book keeping ordered by account number + * \brief List operation of ledger ordered by account number */ require '../../main.inc.php'; @@ -62,7 +62,7 @@ $search_doc_ref = GETPOST('search_doc_ref', 'alpha'); $search_label_operation = GETPOST('search_label_operation', 'alpha'); $search_mvt_num = GETPOST('search_mvt_num', 'int'); $search_direction = GETPOST('search_direction', 'alpha'); -$search_ledger_code = GETPOST('search_ledger_code', 'alpha'); +$search_ledger_code = GETPOST('search_ledger_code', 'array'); $search_debit = GETPOST('search_debit', 'alpha'); $search_credit = GETPOST('search_credit', 'alpha'); $search_lettering_code = GETPOST('search_lettering_code', 'alpha'); @@ -172,7 +172,7 @@ if (empty($reshook)) $search_label_operation = ''; $search_mvt_num = ''; $search_direction = ''; - $search_ledger_code = ''; + $search_ledger_code = array(); $search_date_start = ''; $search_date_end = ''; $search_date_startyear = ''; @@ -233,7 +233,9 @@ if (empty($reshook)) } if (!empty($search_ledger_code)) { $filter['t.code_journal'] = $search_ledger_code; - $param .= '&search_ledger_code='.urlencode($search_ledger_code); + foreach ($search_ledger_code as $code) { + $param .= '&search_ledger_code[]='.urlencode($code); + } } if (!empty($search_debit)) { $filter['t.debit'] = $search_debit; @@ -448,7 +450,9 @@ print ''; // Code journal if (!empty($arrayfields['t.code_journal']['checked'])) { - print ''; + print ''; + print $formaccounting->multi_select_journal($search_ledger_code, 'search_ledger_code', 0, 1, 1, 1); + print ''; } // Date document if (!empty($arrayfields['t.doc_date']['checked'])) { diff --git a/htdocs/accountancy/bookkeeping/listbysubaccount.php b/htdocs/accountancy/bookkeeping/listbysubaccount.php index 10d4dc3084b..e30a9984949 100644 --- a/htdocs/accountancy/bookkeeping/listbysubaccount.php +++ b/htdocs/accountancy/bookkeeping/listbysubaccount.php @@ -1,7 +1,7 @@ * Copyright (C) 2013-2016 Olivier Geffroy - * Copyright (C) 2013-2016 Florian Henry + * Copyright (C) 2013-2020 Florian Henry * Copyright (C) 2013-2020 Alexandre Spangaro * Copyright (C) 2018 Frédéric France * @@ -62,7 +62,7 @@ $search_doc_ref = GETPOST('search_doc_ref', 'alpha'); $search_label_operation = GETPOST('search_label_operation', 'alpha'); $search_mvt_num = GETPOST('search_mvt_num', 'int'); $search_direction = GETPOST('search_direction', 'alpha'); -$search_ledger_code = GETPOST('search_ledger_code', 'alpha'); +$search_ledger_code = GETPOST('search_ledger_code', 'array'); $search_debit = GETPOST('search_debit', 'alpha'); $search_credit = GETPOST('search_credit', 'alpha'); $search_lettering_code = GETPOST('search_lettering_code', 'alpha'); @@ -171,7 +171,7 @@ if (empty($reshook)) $search_label_operation = ''; $search_mvt_num = ''; $search_direction = ''; - $search_ledger_code = ''; + $search_ledger_code = array(); $search_date_start = ''; $search_date_end = ''; $search_date_startyear = ''; @@ -232,7 +232,9 @@ if (empty($reshook)) } if (!empty($search_ledger_code)) { $filter['t.code_journal'] = $search_ledger_code; - $param .= '&search_ledger_code='.urlencode($search_ledger_code); + foreach ($search_ledger_code as $code) { + $param .= '&search_ledger_code[]='.urlencode($code); + } } if (!empty($search_debit)) { $filter['t.debit'] = $search_debit; @@ -452,7 +454,9 @@ print ''; // Code journal if (!empty($arrayfields['t.code_journal']['checked'])) { - print ''; + print ''; + print $formaccounting->multi_select_journal($search_ledger_code, 'search_ledger_code', 0, 1, 1, 1); + print ''; } // Date document if (!empty($arrayfields['t.doc_date']['checked'])) { diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index 72428762459..3b03e6ae8ca 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -1,7 +1,7 @@ * Copyright (C) 2015-2017 Alexandre Spangaro - * Copyright (C) 2015-2017 Florian Henry + * Copyright (C) 2015-2020 Florian Henry * Copyright (C) 2018-2020 Frédéric France * * This program is free software; you can redistribute it and/or modify diff --git a/htdocs/adherents/class/api_subscriptions.class.php b/htdocs/adherents/class/api_subscriptions.class.php index 370de13c3a2..04b9f750a88 100644 --- a/htdocs/adherents/class/api_subscriptions.class.php +++ b/htdocs/adherents/class/api_subscriptions.class.php @@ -87,7 +87,7 @@ class Subscriptions extends DolibarrApi */ public function index($sortfield = "dateadh", $sortorder = 'ASC', $limit = 100, $page = 0, $sqlfilters = '') { - global $db, $conf; + global $conf; $obj_ret = array(); @@ -183,7 +183,9 @@ class Subscriptions extends DolibarrApi } foreach ($request_data as $field => $value) { - if ($field == 'id') continue; + if ($field == 'id') { + continue; + } $subscription->$field = $value; } @@ -236,8 +238,9 @@ class Subscriptions extends DolibarrApi { $subscription = array(); foreach (Subscriptions::$FIELDS as $field) { - if (!isset($data[$field])) + if (!isset($data[$field])) { throw new RestException(400, "$field field missing"); + } $subscription[$field] = $data[$field]; } return $subscription; diff --git a/htdocs/adherents/class/subscription.class.php b/htdocs/adherents/class/subscription.class.php index b6349bf9dc2..dff127d6d2b 100644 --- a/htdocs/adherents/class/subscription.class.php +++ b/htdocs/adherents/class/subscription.class.php @@ -84,8 +84,15 @@ class Subscription extends CommonObject * @var int ID */ public $fk_type; + + /** + * @var int Member ID + */ public $fk_adherent; + /** + * @var double amount subscription + */ public $amount; /** @@ -140,7 +147,9 @@ class Subscription extends CommonObject $this->error = $langs->trans("ErrorBadValueForDate"); return -1; } - if (empty($this->datec)) $this->datec = $now; + if (empty($this->datec)) { + $this->datec = $now; + } $this->db->begin(); @@ -177,7 +186,9 @@ class Subscription extends CommonObject $this->context = array('member' => $member); // Call triggers $result = $this->call_trigger('MEMBER_SUBSCRIPTION_CREATE', $user); - if ($result < 0) { $error++; } + if ($result < 0) { + $error++; + } // End call triggers } @@ -278,7 +289,9 @@ class Subscription extends CommonObject $this->context = array('member'=>$member); // Call triggers $result = $this->call_trigger('MEMBER_SUBSCRIPTION_MODIFY', $user); - if ($result < 0) { $error++; } //Do also here what you must do to rollback action if trigger fail + if ($result < 0) { + $error++; + } //Do also here what you must do to rollback action if trigger fail // End call triggers } } else { @@ -320,7 +333,9 @@ class Subscription extends CommonObject if (!$notrigger) { // Call triggers $result = $this->call_trigger('MEMBER_SUBSCRIPTION_DELETE', $user); - if ($result < 0) { $error++; } // Do also here what you must do to rollback action if trigger fail + if ($result < 0) { + $error++; + } // Do also here what you must do to rollback action if trigger fail // End call triggers } } @@ -407,16 +422,24 @@ class Subscription extends CommonObject if ($option != 'nolink') { // Add param to save lastsearch_values or not $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; - if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) { + $add_save_lastsearch_values = 1; + } + if ($add_save_lastsearch_values) { + $url .= '&save_lastsearch_values=1'; + } } $linkstart = ''; $linkend = ''; $result .= $linkstart; - if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); - if ($withpicto != 2) $result .= $this->ref; + if ($withpicto) { + $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + } + if ($withpicto != 2) { + $result .= $this->ref; + } $result .= $linkend; return $result; diff --git a/htdocs/admin/expensereport.php b/htdocs/admin/expensereport.php index a93f5c3c608..61688e18515 100644 --- a/htdocs/admin/expensereport.php +++ b/htdocs/admin/expensereport.php @@ -37,7 +37,9 @@ require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; // Load translation files required by the page $langs->loadLangs(array('admin', 'errors', 'trips', 'other')); -if (!$user->admin) accessforbidden(); +if (!$user->admin) { + accessforbidden(); +} $action = GETPOST('action', 'aZ09'); $value = GETPOST('value', 'alpha'); @@ -52,51 +54,47 @@ $type = 'expensereport'; include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; -if ($action == 'updateMask') -{ +if ($action == 'updateMask') { $maskconst = GETPOST('maskconst', 'alpha'); $maskvalue = GETPOST('maskvalue', 'alpha'); - if ($maskconst) $res = dolibarr_set_const($db, $maskconst, $maskvalue, 'chaine', 0, '', $conf->entity); + if ($maskconst) { + $res = dolibarr_set_const($db, $maskconst, $maskvalue, 'chaine', 0, '', $conf->entity); + } - if (!$res > 0) $error++; + if (!$res > 0) { + $error++; + } - if (!$error) - { + if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } else { setEventMessages($langs->trans("Error"), null, 'errors'); } -} elseif ($action == 'specimen') // For fiche inter -{ +} elseif ($action == 'specimen') { // For fiche expensereport $modele = GETPOST('module', 'alpha'); - $inter = new ExpenseReport($db); - $inter->initAsSpecimen(); - $inter->status = 0; // Force statut draft to show watermark - $inter->fk_statut = 0; // Force statut draft to show watermark + $expensespecimen = new ExpenseReport($db); + $expensespecimen->initAsSpecimen(); + $expensespecimen->status = 0; // Force statut draft to show watermark // Search template files $file = ''; $classname = ''; $filefound = 0; $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); - foreach ($dirmodels as $reldir) - { + foreach ($dirmodels as $reldir) { $file = dol_buildpath($reldir."core/modules/expensereport/doc/pdf_".$modele.".modules.php", 0); - if (file_exists($file)) - { + if (file_exists($file)) { $filefound = 1; $classname = "pdf_".$modele; break; } } - if ($filefound) - { + if ($filefound) { require_once $file; $module = new $classname($db); - if ($module->write_file($inter, $langs) > 0) - { + if ($module->write_file($expensespecimen, $langs) > 0) { header("Location: ".DOL_URL_ROOT."/document.php?modulepart=expensereport&file=SPECIMEN.pdf"); return; } else { @@ -107,30 +105,22 @@ if ($action == 'updateMask') setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors'); dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); } -} - -// Activate a model -elseif ($action == 'set') -{ +} elseif ($action == 'set') { + // Activate a model $ret = addDocumentModel($value, $type, $label, $scandir); - if ($ret > 0 && empty($conf->global->EXPENSEREPORT_ADDON_PDF)) - { + if ($ret > 0 && empty($conf->global->EXPENSEREPORT_ADDON_PDF)) { dolibarr_set_const($db, 'EXPENSEREPORT_ADDON_PDF', $value, 'chaine', 0, '', $conf->entity); } -} elseif ($action == 'del') -{ +} elseif ($action == 'del') { $ret = delDocumentModel($value, $type); - if ($ret > 0) - { - if ($conf->global->EXPENSEREPORT_ADDON_PDF == "$value") dolibarr_del_const($db, 'EXPENSEREPORT_ADDON_PDF', $conf->entity); + if ($ret > 0) { + if ($conf->global->EXPENSEREPORT_ADDON_PDF == "$value") { + dolibarr_del_const($db, 'EXPENSEREPORT_ADDON_PDF', $conf->entity); + } } -} - -// Set default model -elseif ($action == 'setdoc') -{ - if (dolibarr_set_const($db, "EXPENSEREPORT_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity)) - { +} elseif ($action == 'setdoc') { + // Set default model + if (dolibarr_set_const($db, "EXPENSEREPORT_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity)) { // La constante qui a ete lue en avant du nouveau set // on passe donc par une variable pour avoir un affichage coherent $conf->global->EXPENSEREPORT_ADDON_PDF = $value; @@ -138,18 +128,15 @@ elseif ($action == 'setdoc') // On active le modele $ret = delDocumentModel($value, $type); - if ($ret > 0) - { + if ($ret > 0) { $ret = addDocumentModel($value, $type, $label, $scandir); } -} elseif ($action == 'setmod') -{ +} elseif ($action == 'setmod') { // TODO Verifier si module numerotation choisi peut etre active // par appel methode canBeActivated dolibarr_set_const($db, "EXPENSEREPORT_ADDON", $value, 'chaine', 0, '', $conf->entity); -} elseif ($action == 'setoptions') -{ +} elseif ($action == 'setoptions') { $db->begin(); $freetext = GETPOST('EXPENSEREPORT_FREE_TEXT', 'restricthtml'); // No alpha here, we want exact string @@ -158,10 +145,11 @@ elseif ($action == 'setdoc') $draft = GETPOST('EXPENSEREPORT_DRAFT_WATERMARK', 'alpha'); $res2 = dolibarr_set_const($db, "EXPENSEREPORT_DRAFT_WATERMARK", trim($draft), 'chaine', 0, '', $conf->entity); - if (!$res1 > 0 || !$res2 > 0) $error++; + if (!$res1 > 0 || !$res2 > 0) { + $error++; + } - if (!$error) - { + if (!$error) { $db->commit(); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } else { @@ -206,19 +194,14 @@ print ''."\n"; clearstatcache(); -foreach ($dirmodels as $reldir) -{ +foreach ($dirmodels as $reldir) { $dir = dol_buildpath($reldir."core/modules/expensereport/"); - if (is_dir($dir)) - { + if (is_dir($dir)) { $handle = opendir($dir); - if (is_resource($handle)) - { - while (($file = readdir($handle)) !== false) - { - if (substr($file, 0, 18) == 'mod_expensereport_' && substr($file, dol_strlen($file) - 3, 3) == 'php') - { + if (is_resource($handle)) { + while (($file = readdir($handle)) !== false) { + if (substr($file, 0, 18) == 'mod_expensereport_' && substr($file, dol_strlen($file) - 3, 3) == 'php') { $file = substr($file, 0, dol_strlen($file) - 4); require_once $dir.$file.'.php'; @@ -226,11 +209,14 @@ foreach ($dirmodels as $reldir) $module = new $file($db); // Show modules according to features level - if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; - if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) { + continue; + } + if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) { + continue; + } - if ($module->isEnabled()) - { + if ($module->isEnabled()) { print ''.$module->nom."\n"; print $module->info(); print ''; @@ -241,13 +227,15 @@ foreach ($dirmodels as $reldir) if (preg_match('/^Error/', $tmp)) { $langs->load("errors"); print '
'.$langs->trans($tmp).'
'; - } elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); - else print $tmp; + } elseif ($tmp == 'NotConfigured') { + print $langs->trans($tmp); + } else { + print $tmp; + } print ''."\n"; print ''; - if ($conf->global->EXPENSEREPORT_ADDON == $file) - { + if ($conf->global->EXPENSEREPORT_ADDON == $file) { print img_picto($langs->trans("Activated"), 'switch_on'); } else { print ''; @@ -266,8 +254,9 @@ foreach ($dirmodels as $reldir) if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval $htmltooltip .= ''.$langs->trans("NextValue").': '; if ($nextval) { - if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') + if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') { $nextval = $langs->trans($nextval); + } $htmltooltip .= $nextval.'
'; } else { $htmltooltip .= $langs->trans($module->error).'
'; @@ -289,7 +278,7 @@ foreach ($dirmodels as $reldir) print "
\n"; /* - * Documents models for Interventions + * Documents models for ExpenseReport */ print load_fiche_titre($langs->trans("TemplatePDFExpenseReports"), '', ''); @@ -302,12 +291,10 @@ $sql .= " FROM ".MAIN_DB_PREFIX."document_model"; $sql .= " WHERE type = '".$db->escape($type)."'"; $sql .= " AND entity = ".$conf->entity; $resql = $db->query($sql); -if ($resql) -{ +if ($resql) { $i = 0; $num_rows = $db->num_rows($resql); - while ($i < $num_rows) - { + while ($i < $num_rows) { $array = $db->fetch_array($resql); array_push($def, $array[0]); $i++; @@ -328,28 +315,21 @@ print "\n"; clearstatcache(); -foreach ($dirmodels as $reldir) -{ +foreach ($dirmodels as $reldir) { $dir = dol_buildpath($reldir."core/modules/expensereport/doc"); - if (is_dir($dir)) - { + if (is_dir($dir)) { $handle = opendir($dir); - if (is_resource($handle)) - { - while (($file = readdir($handle)) !== false) - { + if (is_resource($handle)) { + while (($file = readdir($handle)) !== false) { $filelist[] = $file; } closedir($handle); arsort($filelist); - foreach ($filelist as $file) - { - if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) - { - if (file_exists($dir.'/'.$file)) - { + foreach ($filelist as $file) { + if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) { + if (file_exists($dir.'/'.$file)) { $name = substr($file, 4, dol_strlen($file) - 16); $classname = substr($file, 0, dol_strlen($file) - 12); @@ -357,21 +337,26 @@ foreach ($dirmodels as $reldir) $module = new $classname($db); $modulequalified = 1; - if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0; - if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0; + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) { + $modulequalified = 0; + } + if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) { + $modulequalified = 0; + } - if ($modulequalified) - { + if ($modulequalified) { print ''; print (empty($module->name) ? $name : $module->name); print "\n"; - if (method_exists($module, 'info')) print $module->info($langs); - else print $module->description; + if (method_exists($module, 'info')) { + print $module->info($langs); + } else { + print $module->description; + } print ''; // Active - if (in_array($name, $def)) - { + if (in_array($name, $def)) { print ''."\n"; print '
scandir.'&label='.urlencode($module->name).'">'; print img_picto($langs->trans("Enabled"), 'switch_on'); @@ -385,8 +370,7 @@ foreach ($dirmodels as $reldir) // Default print ''; - if ($conf->global->EXPENSEREPORT_ADDON_PDF == "$name") - { + if ($conf->global->EXPENSEREPORT_ADDON_PDF == "$name") { print img_picto($langs->trans("Default"), 'on'); } else { print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').''; @@ -409,8 +393,7 @@ foreach ($dirmodels as $reldir) // Preview print ''; - if ($module->type == 'pdf') - { + if ($module->type == 'pdf') { print ''.img_object($langs->trans("Preview"), 'pdf').''; } else { print img_object($langs->trans("PreviewNotAvailable"), 'generic'); @@ -451,14 +434,15 @@ print "\n"; $substitutionarray = pdf_getSubstitutionArray($langs, null, null, 2); $substitutionarray['__(AnyTranslationKey)__'] = $langs->trans("Translation"); $htmltext = ''.$langs->trans("AvailableVariables").':
'; -foreach ($substitutionarray as $key => $val) $htmltext .= $key.'
'; +foreach ($substitutionarray as $key => $val) { + $htmltext .= $key.'
'; +} $htmltext .= '
'; print ''; print $form->textwithpicto($langs->trans("FreeLegalTextOnExpenseReports"), $langs->trans("AddCRIfTooLong").'

'.$htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'
'; $variablename = 'EXPENSEREPORT_FREE_TEXT'; -if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) -{ +if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { print ''; } else { include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; diff --git a/htdocs/admin/expensereport_rules.php b/htdocs/admin/expensereport_rules.php index 9b56ac5901b..050c2b9455c 100644 --- a/htdocs/admin/expensereport_rules.php +++ b/htdocs/admin/expensereport_rules.php @@ -20,7 +20,7 @@ /** - * \file htdocs/admin/expensereport_ik.php + * \file htdocs/admin/expensereport_rules.php * \ingroup expensereport * \brief Page to display expense tax ik */ @@ -34,7 +34,9 @@ require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport_rule.class.ph // Load translation files required by the page $langs->loadLangs(array("admin", "other", "trips", "errors", "dict")); -if (!$user->admin) accessforbidden(); +if (!$user->admin) { + accessforbidden(); +} //Init error $error = false; @@ -55,15 +57,15 @@ $amount = GETPOST('amount'); $restrictive = GETPOST('restrictive'); $object = new ExpenseReportRule($db); -if (!empty($id)) -{ +if (!empty($id)) { $result = $object->fetch($id); - if ($result < 0) dol_print_error('', $object->error, $object->errors); + if ($result < 0) { + dol_print_error('', $object->error, $object->errors); + } } // TODO do action -if ($action == 'save') -{ +if ($action == 'save') { $error = 0; // check parameters @@ -92,8 +94,7 @@ if ($action == 'save') setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ExpenseReportLimitAmount")), null, 'errors'); } - if (empty($error)) - { + if (empty($error)) { $object->setValues($_POST); if ($apply_to == 'U') { @@ -116,18 +117,22 @@ if ($action == 'save') $object->entity = $conf->entity; $res = $object->create($user); - if ($res > 0) setEventMessages($langs->trans('ExpenseReportRuleSave'), null); - else dol_print_error($object->db); + if ($res > 0) { + setEventMessages($langs->trans('ExpenseReportRuleSave'), null); + } else { + dol_print_error($object->db); + } header('Location: '.$_SERVER['PHP_SELF']); exit; } -} elseif ($action == 'delete') -{ +} elseif ($action == 'delete') { // TODO add confirm $res = $object->delete($user); - if ($res < 0) dol_print_error($object->db); + if ($res < 0) { + dol_print_error($object->db); + } header('Location: '.$_SERVER['PHP_SELF']); exit; @@ -135,8 +140,17 @@ if ($action == 'save') $rules = ExpenseReportRule::getAllRule(); -$tab_apply = array('A' => $langs->trans('All'), 'G' => $langs->trans('Group'), 'U' => $langs->trans('User')); -$tab_rules_type = array('EX_DAY' => $langs->trans('Day'), 'EX_MON' => $langs->trans('Month'), 'EX_YEA' => $langs->trans('Year'), 'EX_EXP' => $langs->trans('OnExpense')); +$tab_apply = array( + 'A' => $langs->trans('All'), + 'G' => $langs->trans('Group'), + 'U' => $langs->trans('User') +); +$tab_rules_type = array( + 'EX_DAY' => $langs->trans('Day'), + 'EX_MON' => $langs->trans('Month'), + 'EX_YEA' => $langs->trans('Year'), + 'EX_EXP' => $langs->trans('OnExpense') +); /* @@ -156,8 +170,7 @@ print dol_get_fiche_head($head, 'expenserules', $langs->trans("ExpenseReportsRul echo ''.$langs->trans('ExpenseReportRulesDesc').''; print '

'; -if ($action != 'edit') -{ +if ($action != 'edit') { echo '
'; echo ''; echo ''; @@ -199,8 +212,7 @@ if ($action != 'edit') echo ''; echo ''; -if ($action == 'edit') -{ +if ($action == 'edit') { echo ''; echo ''; } @@ -218,43 +230,47 @@ echo ''.$langs->trans('ExpenseReportRestrictive').''; echo ' '; echo ''; -foreach ($rules as $rule) -{ +foreach ($rules as $rule) { echo ''; echo ''; - if ($action == 'edit' && $object->id == $rule->id) - { + if ($action == 'edit' && $object->id == $rule->id) { $selected = ($object->is_for_all > 0) ? 'A' : ($object->fk_usergroup > 0 ? 'G' : 'U'); echo '
'.$form->selectarray('apply_to', $tab_apply, $selected, 0).'
'; echo '
'.$form->select_dolusers($object->fk_user, 'fk_user').'
'; echo '
'.$form->select_dolgroups($object->fk_usergroup, 'fk_usergroup').'
'; } else { - if ($rule->is_for_all > 0) echo $tab_apply['A']; - elseif ($rule->fk_usergroup > 0) echo $tab_apply['G'].' ('.$rule->getGroupLabel().')'; - elseif ($rule->fk_user > 0) echo $tab_apply['U'].' ('.$rule->getUserName().')'; - } - echo ''; - - - echo ''; - if ($action == 'edit' && $object->id == $rule->id) - { - echo $form->selectExpense($object->fk_c_type_fees, 'fk_c_type_fees', 0, 1, 1); - } else { - if ($rule->fk_c_type_fees == -1) echo $langs->trans('AllExpenseReport'); - else { - $key = getDictvalue(MAIN_DB_PREFIX.'c_type_fees', 'code', $rule->fk_c_type_fees, false, 'id'); - if ($key != $langs->trans($key)) echo $langs->trans($key); - else echo $langs->trans(getDictvalue(MAIN_DB_PREFIX.'c_type_fees', 'label', $rule->fk_c_type_fees, false, 'id')); // TODO check to return trans of 'code' + if ($rule->is_for_all > 0) { + echo $tab_apply['A']; + } elseif ($rule->fk_usergroup > 0) { + echo $tab_apply['G'].' ('.$rule->getGroupLabel().')'; + } elseif ($rule->fk_user > 0) { + echo $tab_apply['U'].' ('.$rule->getUserName().')'; } } echo ''; echo ''; - if ($action == 'edit' && $object->id == $rule->id) - { + if ($action == 'edit' && $object->id == $rule->id) { + echo $form->selectExpense($object->fk_c_type_fees, 'fk_c_type_fees', 0, 1, 1); + } else { + if ($rule->fk_c_type_fees == -1) { + echo $langs->trans('AllExpenseReport'); + } else { + $key = getDictvalue(MAIN_DB_PREFIX.'c_type_fees', 'code', $rule->fk_c_type_fees, false, 'id'); + if ($key != $langs->trans($key)) { + echo $langs->trans($key); + } else { + echo $langs->trans(getDictvalue(MAIN_DB_PREFIX.'c_type_fees', 'label', $rule->fk_c_type_fees, false, 'id')); // TODO check to return trans of 'code' + } + } + } + echo ''; + + + echo ''; + if ($action == 'edit' && $object->id == $rule->id) { echo $form->selectarray('code_expense_rules_type', $tab_rules_type, $object->code_expense_rules_type, 0); } else { echo $tab_rules_type[$rule->code_expense_rules_type]; @@ -263,8 +279,7 @@ foreach ($rules as $rule) echo ''; - if ($action == 'edit' && $object->id == $rule->id) - { + if ($action == 'edit' && $object->id == $rule->id) { print $form->selectDate(strtotime(date('Y-m-d', $object->dates)), 'start', '', '', 0, '', 1, 0); } else { echo dol_print_date($rule->dates, 'day'); @@ -273,8 +288,7 @@ foreach ($rules as $rule) echo ''; - if ($action == 'edit' && $object->id == $rule->id) - { + if ($action == 'edit' && $object->id == $rule->id) { print $form->selectDate(strtotime(date('Y-m-d', $object->datee)), 'end', '', '', 0, '', 1, 0); } else { echo dol_print_date($rule->datee, 'day'); @@ -283,8 +297,7 @@ foreach ($rules as $rule) echo ''; - if ($action == 'edit' && $object->id == $rule->id) - { + if ($action == 'edit' && $object->id == $rule->id) { echo ''.$conf->currency; } else { echo price($rule->amount, 0, $langs, 1, -1, -1, $conf->currency); @@ -293,8 +306,7 @@ foreach ($rules as $rule) echo ''; - if ($action == 'edit' && $object->id == $rule->id) - { + if ($action == 'edit' && $object->id == $rule->id) { echo $form->selectyesno('restrictive', $object->restrictive, 1); } else { echo yn($rule->restrictive, 1, 1); @@ -303,8 +315,7 @@ foreach ($rules as $rule) echo ''; - if ($object->id != $rule->id) - { + if ($object->id != $rule->id) { echo ''.img_edit().' '; echo ''.img_delete().''; } else { diff --git a/htdocs/core/js/lib_foot.js.php b/htdocs/core/js/lib_foot.js.php index d04379210a6..de19f674659 100644 --- a/htdocs/core/js/lib_foot.js.php +++ b/htdocs/core/js/lib_foot.js.php @@ -21,13 +21,27 @@ * \brief File that include javascript functions (included if option use_javascript activated) */ -if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); -if (!defined('NOCSRFCHECK')) define('NOCSRFCHECK', 1); -if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', 1); -if (!defined('NOLOGIN')) define('NOLOGIN', 1); -if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', 1); -if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', 1); -if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); +if (!defined('NOREQUIRESOC')) { + define('NOREQUIRESOC', '1'); +} +if (!defined('NOCSRFCHECK')) { + define('NOCSRFCHECK', 1); +} +if (!defined('NOTOKENRENEWAL')) { + define('NOTOKENRENEWAL', 1); +} +if (!defined('NOLOGIN')) { + define('NOLOGIN', 1); +} +if (!defined('NOREQUIREMENU')) { + define('NOREQUIREMENU', 1); +} +if (!defined('NOREQUIREHTML')) { + define('NOREQUIREHTML', 1); +} +if (!defined('NOREQUIREAJAX')) { + define('NOREQUIREAJAX', '1'); +} session_cache_limiter('public'); @@ -36,8 +50,11 @@ require_once '../../main.inc.php'; // Define javascript type top_httphead('text/javascript; charset=UTF-8'); // Important: Following code is to avoid page request by browser and PHP CPU at each Dolibarr page access. -if (empty($dolibarr_nocache)) header('Cache-Control: max-age=10800, public, must-revalidate'); -else header('Cache-Control: no-cache'); +if (empty($dolibarr_nocache)) { + header('Cache-Control: max-age=10800, public, must-revalidate'); +} else { + header('Cache-Control: no-cache'); +} //var_dump($conf); @@ -46,15 +63,14 @@ else header('Cache-Control: no-cache'); print "\n/* JS CODE TO ENABLE Tooltips on all object with class classfortooltip */\n"; print "jQuery(document).ready(function () {\n"; -if (empty($conf->dol_no_mouse_hover)) -{ +if (empty($conf->dol_no_mouse_hover)) { print 'jQuery(".classfortooltip").tooltip({ - show: { collision: "flipfit", effect:\'toggle\', delay:50 }, - hide: { delay: 250 }, + show: { collision: "flipfit", effect:"toggle", delay:75, duration:150 }, + hide: { delay: 250, duration: 20 }, tooltipClass: "mytooltip", content: function () { console.log("Return title for popup"); - return $(this).prop(\'title\'); /* To force to get title as is */ + return $(this).prop("title"); /* To force to get title as is */ } });'."\n"; } @@ -79,8 +95,7 @@ print "});\n"; // Wrapper to manage dropdown -if (!defined('JS_JQUERY_DISABLE_DROPDOWN')) -{ +if (!defined('JS_JQUERY_DISABLE_DROPDOWN')) { print "\n/* JS CODE TO ENABLE dropdown (hamburger, linkto, ...) */\n"; print ' jQuery(document).ready(function () { @@ -149,8 +164,7 @@ if (!defined('JS_JQUERY_DISABLE_DROPDOWN')) } // Wrapper to manage document_preview -if ($conf->browser->layout != 'phone') -{ +if ($conf->browser->layout != 'phone') { print "\n/* JS CODE TO ENABLE document_preview */\n"; // Function document_preview is into header print ' jQuery(document).ready(function () { diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index 08bab0b4c76..eef93849c8b 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -11,7 +11,7 @@ * Copyright (C) 2015-2016 Ferran Marcet * Copyright (C) 2017 Josep Lluís Amador * Copyright (C) 2018 Charlene Benke - * Copyright (C) 2018-2019 Frédéric France + * Copyright (C) 2018-2020 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 @@ -60,8 +60,7 @@ $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'sup $socid = GETPOST('socid', 'int'); // Security check -if ($user->socid > 0) -{ +if ($user->socid > 0) { $action = ''; $_GET["action"] = ''; $socid = $user->socid; @@ -363,13 +362,10 @@ if ($massaction == 'transfer_request') { $langs->load("withdrawals"); - if (!$user->rights->paymentbybanktransfer->create) - { + if (!$user->rights->paymentbybanktransfer->create) { $error++; setEventMessages($langs->trans("NotEnoughPermissions"), null, 'errors'); - } - else - { + } else { //Checking error $error = 0; @@ -421,34 +417,27 @@ if ($massaction == 'transfer_request') elseif (!empty($objecttmp->mode_reglement_code) && $objecttmp->mode_reglement_code != 'VIR') { $error++; setEventMessages($objecttmp->ref.' '.$langs->trans("BadPaymentMethod"), $objecttmp->errors, 'errors'); - } - else { + } else { $listofbills[] = $objecttmp; // $listofbills will only contains invoices with good payment method and no request already done } } } //Massive withdraw request for request with no errors - if (!empty($listofbills)) - { + if (!empty($listofbills)) { $nbwithdrawrequestok = 0; - foreach ($listofbills as $aBill) - { + foreach ($listofbills as $aBill) { $db->begin(); $result = $aBill->demande_prelevement($user, $aBill->resteapayer, 'bank-transfer', 'supplier_invoice'); - if ($result > 0) - { + if ($result > 0) { $db->commit(); $nbwithdrawrequestok++; - } - else - { + } else { $db->rollback(); setEventMessages($aBill->error, $aBill->errors, 'errors'); } } - if ($nbwithdrawrequestok > 0) - { + if ($nbwithdrawrequestok > 0) { setEventMessages($langs->trans("BankTransferRequestsDone", $nbwithdrawrequestok), null, 'mesgs'); } } diff --git a/htdocs/fourn/facture/paiement.php b/htdocs/fourn/facture/paiement.php index 8a7e0cc8054..f88e6dfd834 100644 --- a/htdocs/fourn/facture/paiement.php +++ b/htdocs/fourn/facture/paiement.php @@ -9,7 +9,7 @@ * Copyright (C) 2015 Marcos García * Copyright (C) 2015 Juanjo Menent * Copyright (C) 2017 Alexandre Spangaro - * Copyright (C) 2018 Frédéric France + * Copyright (C) 2018-2020 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 @@ -42,15 +42,15 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; // Load translation files required by the page $langs->loadLangs(array('companies', 'bills', 'banks', 'compta')); -$action = GETPOST('action', 'alpha'); -$confirm = GETPOST('confirm', 'alpha'); +$action = GETPOST('action', 'alpha'); +$confirm = GETPOST('confirm', 'alpha'); $optioncss = GETPOST('optioncss', 'alpha'); -$facid = GETPOST('facid', 'int'); -$socid = GETPOST('socid', 'int'); +$facid = GETPOST('facid', 'int'); +$socid = GETPOST('socid', 'int'); $accountid = GETPOST('accountid', 'int'); $day = GETPOST('day', 'int'); -$month = GETPOST('month', 'int'); +$month = GETPOST('month', 'int'); $year = GETPOST('year', 'int'); $search_ref = GETPOST("search_ref", "alpha"); @@ -562,15 +562,19 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie print ''.$langs->trans('RefSupplier').''; print ''.$langs->trans('Date').''; print ''.$langs->trans('DateMaxPayment').''; - if (!empty($conf->multicurrency->enabled)) print ''.$langs->trans('Currency').''; - if (!empty($conf->multicurrency->enabled)) print ''.$langs->trans('MulticurrencyAmountTTC').''; - if (!empty($conf->multicurrency->enabled)) print ''.$langs->trans('MulticurrencyAlreadyPaid').''; - if (!empty($conf->multicurrency->enabled)) print ''.$langs->trans('MulticurrencyRemainderToPay').''; + if (!empty($conf->multicurrency->enabled)) { + print ''.$langs->trans('Currency').''; + print ''.$langs->trans('MulticurrencyAmountTTC').''; + print ''.$langs->trans('MulticurrencyAlreadyPaid').''; + print ''.$langs->trans('MulticurrencyRemainderToPay').''; + } print ''.$langs->trans('AmountTTC').''; print ''.$langs->trans('AlreadyPaid').''; print ''.$langs->trans('RemainderToPay').''; print ''.$langs->trans('PaymentAmount').''; - if (!empty($conf->multicurrency->enabled)) print ''.$langs->trans('MulticurrencyPaymentAmount').''; + if (!empty($conf->multicurrency->enabled)) { + print ''.$langs->trans('MulticurrencyPaymentAmount').''; + } print ''; $total = 0; @@ -596,8 +600,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie $remaintopay = price2num($invoice->total_ttc - $paiement - $creditnotes - $deposits, 'MT'); // Multicurrency Price - if (!empty($conf->multicurrency->enabled)) - { + if (!empty($conf->multicurrency->enabled)) { $multicurrency_payment = $invoice->getSommePaiement(1); $multicurrency_creditnotes = $invoice->getSumCreditNotesUsed(1); $multicurrency_deposits = $invoice->getSumDepositsUsed(1); @@ -616,8 +619,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie print ''.$objp->ref_supplier.''; // Date - if ($objp->df > 0) - { + if ($objp->df > 0) { print ''; print dol_print_date($db->jdate($objp->df), 'day').''; } else { @@ -728,15 +730,16 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie $totalrecudeposits += $deposits; $i++; } - if ($i > 1) - { + if ($i > 1) { // Print total print ''; print ''.$langs->trans('TotalTTC').':'; - if (!empty($conf->multicurrency->enabled)) print ' '; - if (!empty($conf->multicurrency->enabled)) print ' '; - if (!empty($conf->multicurrency->enabled)) print ' '; - if (!empty($conf->multicurrency->enabled)) print ' '; + if (!empty($conf->multicurrency->enabled)) { + print ' '; + print ' '; + print ' '; + print ' '; + } print ''.price($sign * $total_ttc).''; print ''.price($sign * $totalrecu); if ($totalrecucreditnote) print '+'.price($totalrecucreditnote); @@ -744,7 +747,9 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie print ''; print ''.price($sign * price2num($total_ttc - $totalrecu - $totalrecucreditnote - $totalrecudeposits, 'MT')).''; print ''; // Autofilled - if (!empty($conf->multicurrency->enabled)) print ''; + if (!empty($conf->multicurrency->enabled)) { + print ''; + } print "\n"; } print "\n"; @@ -785,7 +790,9 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie print ''; } - } else dol_print_error($db); + } else { + dol_print_error($db); + } } // End of page diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php index 7d09667bd22..8c225e091ce 100644 --- a/htdocs/modulebuilder/template/myobject_list.php +++ b/htdocs/modulebuilder/template/myobject_list.php @@ -115,6 +115,10 @@ $search = array(); foreach ($object->fields as $key => $val) { if (GETPOST('search_'.$key, 'alpha') !== '') $search[$key] = GETPOST('search_'.$key, 'alpha'); + if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) { + $search[$key.'_dtstart'] = dol_mktime(0, 0, 0, GETPOST('search_'.$key.'_dtstartmonth', 'int'), GETPOST('search_'.$key.'_dtstartday', 'int'), GETPOST('search_'.$key.'_dtstartyear', 'int')); + $search[$key.'_dtend'] = dol_mktime(23, 59, 59, GETPOST('search_'.$key.'_dtendmonth', 'int'), GETPOST('search_'.$key.'_dtendday', 'int'), GETPOST('search_'.$key.'_dtendyear', 'int')); + } } // List of fields to search into when doing a "search in all" @@ -183,6 +187,10 @@ if (empty($reshook)) { foreach ($object->fields as $key => $val) { $search[$key] = ''; + if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) { + $search[$key.'_dtstart'] = ''; + $search[$key.'_dtend'] = ''; + } } $toselect = ''; $search_array_options = array(); @@ -241,13 +249,27 @@ if ($object->ismultientitymanaged == 1) $sql .= " WHERE t.entity IN (".getEntity else $sql .= " WHERE 1 = 1"; foreach ($search as $key => $val) { - if ($key == 'status' && $search[$key] == -1) continue; - $mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0); - if (strpos($object->fields[$key]['type'], 'integer:') === 0) { - if ($search[$key] == '-1') $search[$key] = ''; - $mode_search = 2; + if (in_array($key, $object->fields)) { + if ($key == 'status' && $search[$key] == -1) continue; + $mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0); + if (strpos($object->fields[$key]['type'], 'integer:') === 0) { + if ($search[$key] == '-1') $search[$key] = ''; + $mode_search = 2; + } + if ($search[$key] != '') $sql .= natural_search($key, $search[$key], (($key == 'status') ? 2 : $mode_search)); + } else { + if (preg_match('/(_dtstart|_dtend)$/', $key) && $search[$key] != '') { + $columnName=preg_replace('/(_dtstart|_dtend)$/', '', $key); + if (preg_match('/^(date|timestamp|datetime)/', $object->fields[$columnName]['type'])) { + if (preg_match('/_dtstart$/', $key)) { + $sql .= " AND t." . $columnName . " >= '" . $db->idate($search[$key]) . "'"; + } + if (preg_match('/_dtend$/', $key)) { + $sql .= " AND t." . $columnName . " <= '" . $db->idate($search[$key]) . "'"; + } + } + } } - if ($search[$key] != '') $sql .= natural_search($key, $search[$key], (($key == 'status') ? 2 : $mode_search)); } if ($search_all) $sql .= natural_search(array_keys($fieldstosearchall), $search_all); //$sql.= dolSqlDateFilter("t.field", $search_xxxday, $search_xxxmonth, $search_xxxyear); @@ -428,7 +450,16 @@ foreach ($object->fields as $key => $val) if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1); elseif (strpos($val['type'], 'integer:') === 0) { print $object->showInputField($val, $key, $search[$key], '', '', 'search_', 'maxwidth125', 1); - } elseif (!preg_match('/^(date|timestamp)/', $val['type'])) print ''; + } elseif (!preg_match('/^(date|timestamp|datetime)/', $val['type'])) { + print ''; + } elseif (preg_match('/^(date|timestamp|datetime)/', $val['type'])) { + print '
'; + print $form->selectDate($search[$key.'_dtstart'] ? $search[$key.'_dtstart'] : '', "search_".$key."_dtstart", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')); + print '
'; + print '
'; + print $form->selectDate($search[$key.'_dtend'] ? $search[$key.'_dtend'] : '', "search_".$key."_dtend", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to')); + print '
'; + } print ''; } } diff --git a/scripts/user/migrate_picture_path.php b/scripts/user/migrate_picture_path.php index 795d03b710d..dd395dc0629 100755 --- a/scripts/user/migrate_picture_path.php +++ b/scripts/user/migrate_picture_path.php @@ -19,12 +19,14 @@ */ /** - * \file scripts/product/migrate_picture_path.php + * \file scripts/user/migrate_picture_path.php * \ingroup scripts * \brief Migrate pictures from old system prior to 3.7 to new path for 3.7+ */ -if (!defined('NOSESSION')) define('NOSESSION', '1'); +if (!defined('NOSESSION')) { + define('NOSESSION', '1'); +} $sapi_type = php_sapi_name(); $script_file = basename(__FILE__); diff --git a/scripts/user/sync_users_ldap2dolibarr.php b/scripts/user/sync_users_ldap2dolibarr.php index 375cb2f43ba..a040599bfc2 100755 --- a/scripts/user/sync_users_ldap2dolibarr.php +++ b/scripts/user/sync_users_ldap2dolibarr.php @@ -24,7 +24,9 @@ * \brief Script to update users into Dolibarr from LDAP */ -if (!defined('NOSESSION')) define('NOSESSION', '1'); +if (!defined('NOSESSION')) { + define('NOSESSION', '1'); +} $sapi_type = php_sapi_name(); $script_file = basename(__FILE__); @@ -59,12 +61,27 @@ print "***** ".$script_file." (".$version.") pid=".dol_getmypid()." *****\n"; dol_syslog($script_file." launched with arg ".join(',', $argv)); // List of fields to get from LDAP -$required_fields = array($conf->global->LDAP_KEY_USERS, $conf->global->LDAP_FIELD_FULLNAME, $conf->global->LDAP_FIELD_NAME, $conf->global->LDAP_FIELD_FIRSTNAME, $conf->global->LDAP_FIELD_LOGIN, $conf->global->LDAP_FIELD_LOGIN_SAMBA, $conf->global->LDAP_FIELD_PASSWORD, $conf->global->LDAP_FIELD_PASSWORD_CRYPTED, $conf->global->LDAP_FIELD_PHONE, $conf->global->LDAP_FIELD_FAX, $conf->global->LDAP_FIELD_MOBILE, +$required_fields = array( + $conf->global->LDAP_KEY_USERS, + $conf->global->LDAP_FIELD_FULLNAME, + $conf->global->LDAP_FIELD_NAME, + $conf->global->LDAP_FIELD_FIRSTNAME, + $conf->global->LDAP_FIELD_LOGIN, + $conf->global->LDAP_FIELD_LOGIN_SAMBA, + $conf->global->LDAP_FIELD_PASSWORD, + $conf->global->LDAP_FIELD_PASSWORD_CRYPTED, + $conf->global->LDAP_FIELD_PHONE, + $conf->global->LDAP_FIELD_FAX, + $conf->global->LDAP_FIELD_MOBILE, // $conf->global->LDAP_FIELD_ADDRESS, // $conf->global->LDAP_FIELD_ZIP, // $conf->global->LDAP_FIELD_TOWN, // $conf->global->LDAP_FIELD_COUNTRY, - $conf->global->LDAP_FIELD_MAIL, $conf->global->LDAP_FIELD_TITLE, $conf->global->LDAP_FIELD_DESCRIPTION, $conf->global->LDAP_FIELD_SID); + $conf->global->LDAP_FIELD_MAIL, + $conf->global->LDAP_FIELD_TITLE, + $conf->global->LDAP_FIELD_DESCRIPTION, + $conf->global->LDAP_FIELD_SID +); // Remove from required_fields all entries not configured in LDAP (empty) and duplicated $required_fields = array_unique(array_values(array_filter($required_fields, "dolValidElement"))); @@ -75,14 +92,18 @@ if (!isset($argv[1])) { } foreach ($argv as $key => $val) { - if ($val == 'commitiferror') + if ($val == 'commitiferror') { $forcecommit = 1; - if (preg_match('/--server=([^\s]+)$/', $val, $reg)) + } + if (preg_match('/--server=([^\s]+)$/', $val, $reg)) { $conf->global->LDAP_SERVER_HOST = $reg[1]; - if (preg_match('/--excludeuser=([^\s]+)$/', $val, $reg)) + } + if (preg_match('/--excludeuser=([^\s]+)$/', $val, $reg)) { $excludeuser = explode(',', $reg[1]); - if (preg_match('/-y$/', $val, $reg)) + } + if (preg_match('/-y$/', $val, $reg)) { $confirmed = 1; + } } print "Mails sending disabled (useless in batch mode)\n"; @@ -94,9 +115,11 @@ print "port=".$conf->global->LDAP_SERVER_PORT."\n"; print "login=".$conf->global->LDAP_ADMIN_DN."\n"; print "pass=".preg_replace('/./i', '*', $conf->global->LDAP_ADMIN_PASS)."\n"; print "DN to extract=".$conf->global->LDAP_USER_DN."\n"; -if (!empty($conf->global->LDAP_FILTER_CONNECTION)) +if (!empty($conf->global->LDAP_FILTER_CONNECTION)) { print 'Filter=('.$conf->global->LDAP_FILTER_CONNECTION.')'."\n"; // Note: filter is defined into function getRecords -else print 'Filter=('.$conf->global->LDAP_KEY_USERS.'=*)'."\n"; +} else { + print 'Filter=('.$conf->global->LDAP_KEY_USERS.'=*)'."\n"; +} print "----- To Dolibarr database:\n"; print "type=".$conf->db->type."\n"; print "host=".$conf->db->host."\n"; @@ -200,7 +223,7 @@ if ($result >= 0) { $fuser->job = $ldapuser[$conf->global->LDAP_FIELD_TITLE]; $fuser->note = $ldapuser[$conf->global->LDAP_FIELD_DESCRIPTION]; $fuser->admin = 0; - $fuser->societe_id = 0; + $fuser->socid = 0; $fuser->contact_id = 0; $fuser->fk_member = 0; @@ -254,9 +277,11 @@ if ($result >= 0) { } if (!$error || $forcecommit) { - if (!$error) + if (!$error) { print $langs->transnoentities("NoErrorCommitIsDone")."\n"; - else print $langs->transnoentities("ErrorButCommitIsDone")."\n"; + } else { + print $langs->transnoentities("ErrorButCommitIsDone")."\n"; + } $db->commit(); } else { print $langs->transnoentities("ErrorSomeErrorWereFoundRollbackIsDone", $error)."\n";