diff --git a/.github/workflows/exakat.yml b/.github/workflows/exakat.yml index 26ea74183e4..d1bdffc71a6 100644 --- a/.github/workflows/exakat.yml +++ b/.github/workflows/exakat.yml @@ -22,7 +22,7 @@ jobs: - name: Exakat uses: docker://exakat/exakat-ga with: - ignore_rules: 'Classes/UseInstanceof,Performances/PrePostIncrement,Functions/UndefinedFunctions,Functions/WrongNumberOfArguments,Functions/WrongTypeWithCall,Variables/UndefinedVariable,Classes/DontUnsetProperties,Classes/NonPpp,Classes/StaticMethodsCalledFromObject,Classes/UseClassOperator,Functions/UsesDefaultArguments,Php/NoClassInGlobal,Php/ShouldUseCoalesce,Php/WrongTypeForNativeFunction,Structures/AddZero,Structures/DropElseAfterReturn,Structures/IfWithSameConditions,Structures/MergeIfThen,Structures/ElseIfElseif,Structures/ExitUsage,Structures/RepeatedPrint,Structures/RepeatedRegex,Structures/SameConditions,Structures/SwitchWithoutDefault,Structures/ShouldMakeTernary,Structures/UselessParenthesis,Structures/UseConstant' + ignore_rules: 'Classes/UseInstanceof,Performances/PrePostIncrement,Functions/UndefinedFunctions,Functions/WrongNumberOfArguments,Functions/WrongTypeWithCall,Variables/UndefinedVariable,Classes/DontUnsetProperties,Classes/NonPpp,Classes/StaticMethodsCalledFromObject,Classes/UseClassOperator,Functions/UsesDefaultArguments,Php/NoClassInGlobal,Php/ShouldUseCoalesce,Php/WrongTypeForNativeFunction,Structures/AddZero,Structures/DropElseAfterReturn,Structures/IfWithSameConditions,Structures/MergeIfThen,Structures/NestedTernary,Structures/ElseIfElseif,Structures/ExitUsage,Structures/RepeatedPrint,Structures/RepeatedRegex,Structures/SameConditions,Structures/SwitchWithoutDefault,Structures/ShouldMakeTernary,Structures/UselessParenthesis,Structures/UseConstant' ignore_dirs: '/htdocs/includes/,/htdocs/install/doctemplates/,/build/,/dev/,/doc/,/scripts/,/test/' file_extensions: php project_reports: Perfile \ No newline at end of file diff --git a/.github/workflows/phpcsfixer.yml b/.github/workflows/phpcsfixer.yml.disabled similarity index 100% rename from .github/workflows/phpcsfixer.yml rename to .github/workflows/phpcsfixer.yml.disabled diff --git a/ChangeLog b/ChangeLog index 935b36fb78e..41341fa2d45 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,7 +3,15 @@ English Dolibarr ChangeLog -------------------------------------------------------------- -***** ChangeLog for 1.0.0 compared to 18.0.0 ***** +***** ChangeLog for 19.0.0 compared to 18.0.0 ***** + +For users: +---------- +... + +For developers or integrators: +------------------------------ +... WARNING: @@ -14,10 +22,44 @@ Following changes may create regressions for some external modules, but were nec +***** ChangeLog for 18.0.1 compared to 18.0.0 ***** +FIX: Adding a product in recurring invoice does not use the correct VAT +FIX: API /product/getAttributes +FIX: avoid php8 warnings +FIX: bad balance of TR tag in multicurrency price view +FIX: Bad calculation of localtax when price_base_type not defined. +FIX: Bad link into message +FIX: Bad message on menu to go to setup of accounting custom groups +FIX: Bank receipt was empty +FIX: Billing massaction should be possible on Processed Reception. +FIX: clone when cloning object with ->lines containing not object +FIX: Condition to show column POSModule and POSTerminal in invoice list +FIX: CSS +FIX: date survey : button to add dates would not work. Session would store cells numbers which would stay to 10 for next surveys created. +FIX: dir output path for ODT models on reception card +FIX: Duplicate tooltip on ref of an agenda event +FIX: encrypt sensitive data must not be done for const MAIN_AGENDA_ACTIONAUTO +FIX: Export when old file export_csv.modules.php is still present +FIX: fatal error with bad definition of dictionaries +FIX: fatal error with some parameters +FIX: hook formBuilddocOptions was broken when used by 2 modules +FIX: Line for revenuestamp in accountancy transfer must appear only if it exists +FIX: Navigation between bank receipts +FIX: payment card: misleading message when delete button disabled +FIX: reception odt dir output path +FIX: SQL request parenthesis +FIX: Suppliers addlines never have VAT if buyprice for this supplier not set +FIX: TakePOS receipt preview in admin #25648 +FIX: technical error on conciliation of lines +FIX: the account in chart of account to use for revenue stamp is on dict +FIX: url to check keyword not saved on partnership from public form +FIX: when adding new times on a survey, all hours would be erased. + + ***** ChangeLog for 18.0.0 compared to 17.0.0 ***** -For uses: ---------- +For users: +---------- NEW: PHP 8.2 compatibility (test not yet completed) NEW: Module Workstations Management upgraded to stable status diff --git a/dev/tools/apstats.php b/dev/tools/apstats.php index 6c45c68b617..271bd264270 100755 --- a/dev/tools/apstats.php +++ b/dev/tools/apstats.php @@ -230,6 +230,29 @@ th,td { .trgroup { background-color: #EEE; } +.seedetail { + color: #000088; +} +.box { + padding: 20px; + font-size: 1.2em; + margin-top: 10px; + margin-bottom: 10px; + width: 200px; +} +.box.inline-box { + display: inline-block; + text-align: center; + margin-left: 10px; +} +.back1 { + background-color: #888800; + color: #FFF; +} +.back1 { + background-color: #880088; + color: #FFF; +} '; $html .= ''; @@ -303,12 +326,14 @@ $html .= ''; $html .= '
'; $html .= '

Project value


'; -$html .= 'COCOMO (Basic organic model) value: $'; -$html .= formatNumber($arraycocomo['proj']['currency'] + $arraycocomo['dep']['currency'], 2); -$html .= '
'; -$html .= 'COCOMO (Basic organic model) effort: '; -$html .= formatNumber($arraycocomo['proj']['people'] * $arraycocomo['proj']['effort'] + $arraycocomo['dep']['people'] * $arraycocomo['dep']['effort']); -$html .= ' monthes people
'; +$html .= '
'; +$html .= 'COCOMO (Basic organic model) value:
'; +$html .= '$'.formatNumber($arraycocomo['proj']['currency'] + $arraycocomo['dep']['currency'], 2).''; +$html .= '
'; +$html .= '
'; +$html .= 'COCOMO (Basic organic model) effort
'; +$html .= ''.formatNumber($arraycocomo['proj']['people'] * $arraycocomo['proj']['effort'] + $arraycocomo['dep']['people'] * $arraycocomo['dep']['effort']); +$html .= ' monthes people
'; $html .= '
'; $html .= '
'; diff --git a/htdocs/accountancy/admin/account.php b/htdocs/accountancy/admin/account.php index c5db08e73e7..1dc461b8ae6 100644 --- a/htdocs/accountancy/admin/account.php +++ b/htdocs/accountancy/admin/account.php @@ -1,6 +1,6 @@ - * Copyright (C) 2013-2020 Alexandre Spangaro + * Copyright (C) 2013-2023 Alexandre Spangaro * Copyright (C) 2016-2018 Laurent Destailleur * * This program is free software; you can redistribute it and/or modify @@ -142,10 +142,13 @@ if (empty($reshook)) { $search_labelshort = ""; $search_accountparent = ""; $search_pcgtype = ""; + $search_import_key = ""; $search_array_options = array(); } if ((GETPOST('valid_change_chart', 'alpha') && GETPOST('chartofaccounts', 'int') > 0) // explicit click on button 'Change and load' with js on || (GETPOST('chartofaccounts', 'int') > 0 && GETPOST('chartofaccounts', 'int') != getDolGlobalInt('CHARTOFACCOUNTS'))) { // a submit of form is done and chartofaccounts combo has been modified + $error = 0; + if ($chartofaccounts > 0 && $permissiontoadd) { // Get language code for this $chartofaccounts $sql = 'SELECT code FROM '.MAIN_DB_PREFIX.'c_country as c, '.MAIN_DB_PREFIX.'accounting_system as a'; @@ -218,14 +221,13 @@ if (empty($reshook)) { /* * View */ - $form = new Form($db); $formaccounting = new FormAccounting($db); llxHeader('', $langs->trans("ListAccounts")); if ($action == 'delete') { - $formconfirm = $html->formconfirm($_SERVER["PHP_SELF"].'?id='.$id, $langs->trans('DeleteAccount'), $langs->trans('ConfirmDeleteAccount'), 'confirm_delete', '', 0, 1); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$id, $langs->trans('DeleteAccount'), $langs->trans('ConfirmDeleteAccount'), 'confirm_delete', '', 0, 1); print $formconfirm; } @@ -234,11 +236,24 @@ $pcgver = getDolGlobalInt('CHARTOFACCOUNTS'); $sql = "SELECT aa.rowid, aa.fk_pcg_version, aa.pcg_type, aa.account_number, aa.account_parent, aa.label, aa.labelshort, aa.fk_accounting_category,"; $sql .= " aa.reconcilable, aa.active, aa.import_key,"; $sql .= " a2.rowid as rowid2, a2.label as label2, a2.account_number as account_number2"; + +// Add fields from hooks +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object, $action); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; +$sql = preg_replace('/,\s*$/', '', $sql); + $sql .= " FROM ".MAIN_DB_PREFIX."accounting_account as aa"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version AND aa.entity = ".((int) $conf->entity); $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as a2 ON a2.rowid = aa.account_parent AND a2.entity = ".((int) $conf->entity); + +// Add table from hooks +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; + $sql .= " WHERE asy.rowid = ".((int) $pcgver); -//print $sql; + if (strlen(trim($search_account))) { $lengthpaddingaccount = 0; if (getDolGlobalInt('ACCOUNTING_LENGTH_GACCOUNT') || getDolGlobalInt('ACCOUNTING_LENGTH_AACCOUNT')) { @@ -285,6 +300,15 @@ if (strlen(trim($search_accountparent)) && $search_accountparent != '-1') { if (strlen(trim($search_pcgtype))) { $sql .= natural_search("aa.pcg_type", $search_pcgtype); } +if (strlen(trim($search_import_key))) { + $sql .= natural_search("aa.import_key", $search_import_key); +} + +// Add where from hooks +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object, $action); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; + $sql .= $db->order($sortfield, $sortorder); //print $sql; @@ -299,16 +323,6 @@ if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) { } } -// List of mass actions available -if ($user->hasRight('accounting', 'chartofaccount')) { - $arrayofmassactions['predelete'] = ''.$langs->trans("Delete"); -} -if (in_array($massaction, array('presend', 'predelete', 'closed'))) { - $arrayofmassactions = array(); -} - -$massactionbutton = $form->selectMassAction('', $arrayofmassactions); -$arrayofselected = is_array($toselect) ? $toselect : array(); $sql .= $db->plimit($limit + 1, $offset); dol_syslog('accountancy/admin/account.php:: $sql='.$sql); @@ -317,6 +331,8 @@ $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); + $arrayofselected = is_array($toselect) ? $toselect : array(); + $param = ''; if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.urlencode($contextpage); @@ -339,13 +355,18 @@ if ($resql) { if ($search_pcgtype) { $param .= '&search_pcgtype='.urlencode($search_pcgtype); } - if ($optioncss != '') { + if ($search_import_key) { $param .= '&search_import_key='.urlencode($search_import_key); } if ($optioncss != '') { $param .= '&optioncss='.urlencode($optioncss); } + // Add $param from hooks + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + $param .= $hookmanager->resPrint; + if (!empty($conf->use_javascript_ajax)) { print ' '; } + // List of mass actions available + if ($user->hasRight('accounting', 'chartofaccount')) { + $arrayofmassactions['predelete'] = ''.$langs->trans("Delete"); + } + if (in_array($massaction, array('presend', 'predelete', 'closed'))) { + $arrayofmassactions = array(); + } + + $massactionbutton = $form->selectMassAction('', $arrayofmassactions); + $newcardbutton = ''; + $newcardbutton = dolGetButtonTitle($langs->trans('Addanaccount'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/accountancy/admin/card.php?action=create', '', $permissiontoadd); + print '
'; if ($optioncss != '') { @@ -372,10 +405,10 @@ if ($resql) { print ''; print ''; - $newcardbutton .= dolGetButtonTitle($langs->trans("New"), $langs->trans("Addanaccount"), 'fa fa-plus-circle', './card.php?action=create'); - include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; print_barre_liste($langs->trans('ListAccounts'), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'accounting_account', 0, $newcardbutton, '', $limit, 0, 0, 1); + include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; + // Box to select active chart of account print $langs->trans("Selectchartofaccounts")." : "; print ''; } @@ -452,6 +499,12 @@ if ($resql) { if (!empty($arrayfields['categories']['checked'])) { print ''; } + + // Fields from hook + $parameters = array('arrayfields'=>$arrayfields); + $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + // Import key if (!empty($arrayfields['aa.import_key']['checked'])) { print ''; @@ -464,44 +517,78 @@ if ($resql) { if (!empty($arrayfields['aa.active']['checked'])) { print ' '; } - print ''; - $searchpicto = $form->showFilterButtons(); - print $searchpicto; - print ''; - print ''; + // Action column + if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; + $searchpicto = $form->showFilterButtons(); + print $searchpicto; + print ''; + } + print ''."\n"; + + $totalarray = array(); + $totalarray['nbfield'] = 0; + + // Fields title label + // -------------------------------------------------------------------- print ''; + // Action column + if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch actioncolumn '); + $totalarray['nbfield']++; + } if (!empty($arrayfields['aa.account_number']['checked'])) { print_liste_field_titre($arrayfields['aa.account_number']['label'], $_SERVER["PHP_SELF"], "aa.account_number", "", $param, '', $sortfield, $sortorder); + $totalarray['nbfield']++; } if (!empty($arrayfields['aa.label']['checked'])) { print_liste_field_titre($arrayfields['aa.label']['label'], $_SERVER["PHP_SELF"], "aa.label", "", $param, '', $sortfield, $sortorder); + $totalarray['nbfield']++; } if (!empty($arrayfields['aa.labelshort']['checked'])) { print_liste_field_titre($arrayfields['aa.labelshort']['label'], $_SERVER["PHP_SELF"], "aa.labelshort", "", $param, '', $sortfield, $sortorder); + $totalarray['nbfield']++; } if (!empty($arrayfields['aa.account_parent']['checked'])) { print_liste_field_titre($arrayfields['aa.account_parent']['label'], $_SERVER["PHP_SELF"], "aa.account_parent", "", $param, '', $sortfield, $sortorder, 'left '); + $totalarray['nbfield']++; } if (!empty($arrayfields['aa.pcg_type']['checked'])) { print_liste_field_titre($arrayfields['aa.pcg_type']['label'], $_SERVER["PHP_SELF"], 'aa.pcg_type,aa.account_number', '', $param, '', $sortfield, $sortorder, '', $arrayfields['aa.pcg_type']['help'], 1); + $totalarray['nbfield']++; } if (!empty($arrayfields['categories']['checked'])) { print_liste_field_titre($arrayfields['categories']['label'], $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, '', $arrayfields['categories']['help'], 1); + $totalarray['nbfield']++; } + + // Hook fields + $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); + $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + if (!empty($arrayfields['aa.import_key']['checked'])) { print_liste_field_titre($arrayfields['aa.import_key']['label'], $_SERVER["PHP_SELF"], 'aa.import_key', '', $param, '', $sortfield, $sortorder, '', $arrayfields['aa.import_key']['help'], 1); + $totalarray['nbfield']++; } if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { if (!empty($arrayfields['aa.reconcilable']['checked'])) { print_liste_field_titre($arrayfields['aa.reconcilable']['label'], $_SERVER["PHP_SELF"], 'aa.reconcilable', '', $param, '', $sortfield, $sortorder); + $totalarray['nbfield']++; } } if (!empty($arrayfields['aa.active']['checked'])) { print_liste_field_titre($arrayfields['aa.active']['label'], $_SERVER["PHP_SELF"], 'aa.active', '', $param, '', $sortfield, $sortorder); + $totalarray['nbfield']++; + } + if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch '); + $totalarray['nbfield']++; } - print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); print "\n"; + // Loop on record + // -------------------------------------------------------------------- $i = 0; while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); @@ -512,6 +599,22 @@ if ($resql) { print ''; + // Action column + if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; + if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + $selected = 0; + if (in_array($obj->rowid, $arrayofselected)) { + $selected = 1; + } + print ''; + } + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Account number if (!empty($arrayfields['aa.account_number']['checked'])) { print ""; @@ -589,6 +692,11 @@ if ($resql) { } } + // Fields from hook + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + // Import id if (!empty($arrayfields['aa.import_key']['checked'])) { print ""; @@ -600,7 +708,7 @@ if ($resql) { } if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { - // Activated or not reconciliation on accounting account + // Activated or not reconciliation on an accounting account if (!empty($arrayfields['aa.reconcilable']['checked'])) { print ''; if (empty($obj->reconcilable)) { @@ -637,28 +745,20 @@ if ($resql) { } } - // Action - print ''; - if ($user->hasRight('accounting', 'chartofaccount')) { - print ''; - print img_edit(); - print ''; - print ' '; - print ''; - print img_delete(); - print ''; - print ' '; + // Action column + if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined $selected = 0; if (in_array($obj->rowid, $arrayofselected)) { $selected = 1; } - print ''; + print ''; + } + print ''; + if (!$i) { + $totalarray['nbfield']++; } - } - print ''."\n"; - if (!$i) { - $totalarray['nbfield']++; } print "\n"; @@ -675,9 +775,16 @@ if ($resql) { print ''.$langs->trans("None").''; } - print ""; - print ""; - print '
'; + $db->free($resql); + + $parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql); + $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + + print ''."\n"; + print ''."\n"; + + print ''."\n"; } else { dol_print_error($db); } diff --git a/htdocs/accountancy/admin/categories_list.php b/htdocs/accountancy/admin/categories_list.php index e77b97fe92d..7b7148f89ce 100644 --- a/htdocs/accountancy/admin/categories_list.php +++ b/htdocs/accountancy/admin/categories_list.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2004-2023 Laurent Destailleur * Copyright (C) 2011-2021 Alexandre Spangaro * * This program is free software; you can redistribute it and/or modify @@ -852,6 +852,9 @@ if ($resql) { print "\n"; $i++; } + } else { + $colspan = 11; + print ''.$langs->trans("None").''; } } else { dol_print_error($db); diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index 53650a3cd28..994e7c7d15e 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -29,26 +29,30 @@ // Load Dolibarr environment require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/accountancy/class/lettering.class.php'; -require_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php'; -require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php'; +require_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php'; +require_once DOL_DOCUMENT_ROOT.'/accountancy/class/lettering.class.php'; // Load translation files required by the page $langs->loadLangs(array("accountancy", "compta")); +// Get Parameters $socid = GETPOST('socid', 'int'); +// action+display Parameters $action = GETPOST('action', 'aZ09'); $massaction = GETPOST('massaction', 'alpha'); $confirm = GETPOST('confirm', 'alpha'); $toselect = GETPOST('toselect', 'array'); $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'bookkeepinglist'; + +// Search Parameters $search_mvt_num = GETPOST('search_mvt_num', 'int'); $search_doc_type = GETPOST("search_doc_type", 'alpha'); $search_doc_ref = GETPOST("search_doc_ref", 'alpha'); diff --git a/htdocs/accountancy/journal/purchasesjournal.php b/htdocs/accountancy/journal/purchasesjournal.php index 1170a20b969..cc7655d28f3 100644 --- a/htdocs/accountancy/journal/purchasesjournal.php +++ b/htdocs/accountancy/journal/purchasesjournal.php @@ -72,6 +72,8 @@ if (!$user->hasRight('accounting', 'mouvements', 'lire')) { accessforbidden(); } +$error = 0; + /* * Actions @@ -341,7 +343,7 @@ foreach ($tabfac as $key => $val) { // Loop on each invoice // Bookkeeping Write -if ($action == 'writebookkeeping') { +if ($action == 'writebookkeeping' && !$error) { $now = dol_now(); $error = 0; @@ -712,7 +714,7 @@ if ($action == 'writebookkeeping') { $form = new Form($db); // Export -if ($action == 'exportcsv') { // ISO and not UTF8 ! +if ($action == 'exportcsv' && !$error) { // ISO and not UTF8 ! $sep = getDolGlobalString('ACCOUNTING_EXPORT_SEPARATORCSV'); $filename = 'journal'; diff --git a/htdocs/accountancy/journal/sellsjournal.php b/htdocs/accountancy/journal/sellsjournal.php index 6ee2ae461ed..31986312388 100644 --- a/htdocs/accountancy/journal/sellsjournal.php +++ b/htdocs/accountancy/journal/sellsjournal.php @@ -74,6 +74,8 @@ if (!$user->hasRight('accounting', 'mouvements', 'lire')) { accessforbidden(); } +$error = 0; + /* * Actions @@ -360,7 +362,7 @@ foreach ($tabfac as $key => $val) { // Loop on each invoice // Bookkeeping Write -if ($action == 'writebookkeeping') { +if ($action == 'writebookkeeping' && !$error) { $now = dol_now(); $error = 0; @@ -764,7 +766,7 @@ if ($action == 'writebookkeeping') { $form = new Form($db); // Export -if ($action == 'exportcsv') { // ISO and not UTF8 ! +if ($action == 'exportcsv' && !$error) { // ISO and not UTF8 ! // Note that to have the button to get this feature enabled, you must enable ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL $sep = getDolGlobalString('ACCOUNTING_EXPORT_SEPARATORCSV'); diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index 4c13905c147..fb306b9b257 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -1726,6 +1726,9 @@ if ($id > 0) { } if (in_array($value, array('label', 'libelle', 'libelle_facture')) && empty($tabcomplete[$tabname[$id]]['help'][$value])) { + if (!is_array($tabcomplete[$tabname[$id]]['help'])) { // protection when $tabcomplete[$tabname[$id]]['help'] is a an empty string, we must force it into an array + $tabcomplete[$tabname[$id]]['help'] = array(); + } $tabcomplete[$tabname[$id]]['help'][$value] = $langs->trans('LabelUsedByDefault'); } @@ -2636,7 +2639,6 @@ function fieldList($fieldlist, $obj = '', $tabname = '', $context = '') $maxlength = ''; if (in_array($fieldlist[$field], array('libelle', 'label'))) { switch ($tabname) { - case 'c_accounting_category': case 'c_ecotaxe': case 'c_email_senderprofile': case 'c_forme_juridique': diff --git a/htdocs/admin/ihm.php b/htdocs/admin/ihm.php index b868a847e9e..6237e5912f0 100644 --- a/htdocs/admin/ihm.php +++ b/htdocs/admin/ihm.php @@ -308,7 +308,7 @@ if ($action == 'update') { $_SESSION["mainmenu"] = ""; // The menu manager may have changed if (GETPOST('dol_resetcache')) { - dolibarr_set_const($db, "MAIN_IHM_PARAMS_REV", ((int) $conf->global->MAIN_IHM_PARAMS_REV) + 1, 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_IHM_PARAMS_REV", getDolGlobalInt('MAIN_IHM_PARAMS_REV') + 1, 'chaine', 0, '', $conf->entity); } header("Location: ".$_SERVER["PHP_SELF"]."?mainmenu=home&leftmenu=setup&mode=".$mode.(GETPOSTISSET('page_y') ? '&page_y='.GETPOST('page_y', 'int') : '')); diff --git a/htdocs/admin/mails_templates.php b/htdocs/admin/mails_templates.php index 7166b4f4853..4a7c644df19 100644 --- a/htdocs/admin/mails_templates.php +++ b/htdocs/admin/mails_templates.php @@ -1196,7 +1196,7 @@ if ($num) { print ''.img_edit().''; } if ($iserasable) { - print ''.img_delete().''; + print ''.img_delete().''; //else print ''.img_delete().''; // Some dictionary can be edited by other profile than admin } print ''; @@ -1301,7 +1301,7 @@ if ($num) { print ''.img_edit().''; } if ($iserasable) { - print ''.img_delete().''; + print ''.img_delete().''; //else print ''.img_delete().''; // Some dictionary can be edited by other profile than admin } print ''; diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index 0242e021ab3..af7327dcf68 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -274,7 +274,7 @@ if ($action == 'set' && $user->admin) { if ($csrfCheckOldValue != getDolGlobalInt('MAIN_SECURITY_CSRF_WITH_TOKEN')) { setEventMessage($langs->trans('WarningModuleHasChangedSecurityCsrfParameter', $value), 'warnings'); } - dolibarr_set_const($db, "MAIN_IHM_PARAMS_REV", (int) $conf->global->MAIN_IHM_PARAMS_REV + 1, 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_IHM_PARAMS_REV", getDolGlobalInt('MAIN_IHM_PARAMS_REV') + 1, 'chaine', 0, '', $conf->entity); if (!empty($resarray['errors'])) { setEventMessages('', $resarray['errors'], 'errors'); } else { @@ -298,7 +298,7 @@ if ($action == 'set' && $user->admin) { exit; } elseif ($action == 'reset' && $user->admin && GETPOST('confirm') == 'yes') { $result = unActivateModule($value); - dolibarr_set_const($db, "MAIN_IHM_PARAMS_REV", (int) $conf->global->MAIN_IHM_PARAMS_REV + 1, 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_IHM_PARAMS_REV", getDolGlobalInt('MAIN_IHM_PARAMS_REV') + 1, 'chaine', 0, '', $conf->entity); if ($result) { setEventMessages($result, null, 'errors'); } diff --git a/htdocs/asset/list.php b/htdocs/asset/list.php index adbb6afd400..96a09b6507e 100644 --- a/htdocs/asset/list.php +++ b/htdocs/asset/list.php @@ -33,6 +33,7 @@ require_once DOL_DOCUMENT_ROOT.'/asset/class/asset.class.php'; // Load translation files required by the page $langs->loadLangs(array("assets", "other")); +// Get parameters $action = GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ... $massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists) $show_files = GETPOST('show_files', 'int'); // Show files area generated by bulk actions ? @@ -42,8 +43,8 @@ $toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'assetlist'; // To manage different context of search $backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') - -$id = GETPOST('id', 'int'); +$mode = GETPOST('mode', 'alpha'); // mode view (kanban or common) +$id = GETPOST('id', 'int'); // Load variable for pagination $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index 02207be5265..f6a5620c51c 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -72,6 +72,10 @@ class BOM extends CommonObject */ public $picto = 'bom'; + /** + * @var Product Object product of the BOM + */ + public $product; const STATUS_DRAFT = 0; const STATUS_VALIDATED = 1; @@ -909,7 +913,7 @@ class BOM extends CommonObject */ public function validate($user, $notrigger = 0) { - global $conf, $langs; + global $conf; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -1354,7 +1358,7 @@ class BOM extends CommonObject { $this->initAsSpecimenCommon(); $this->ref = 'BOM-123'; - $this->date = $this->date_creation; + $this->date_creation = dol_now() - 20000; } diff --git a/htdocs/bookcal/admin/booking_extrafields.php b/htdocs/bookcal/admin/booking_extrafields.php deleted file mode 100644 index de09660f63d..00000000000 --- a/htdocs/bookcal/admin/booking_extrafields.php +++ /dev/null @@ -1,113 +0,0 @@ - - * Copyright (C) 2003 Jean-Louis Bergamo - * Copyright (C) 2004-2011 Laurent Destailleur - * Copyright (C) 2012 Regis Houssin - * Copyright (C) 2014 Florian Henry - * Copyright (C) 2015 Jean-François Ferry - * - * 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/bookcal/admin/booking_extrafields.php - * \ingroup bookcal - * \brief Page to setup extra fields of booking - */ - -// Load Dolibarr environment -require '../../main.inc.php'; - -require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; -require_once '../lib/bookcal.lib.php'; - -// Load translation files required by the page -$langs->loadLangs(array('agenda', 'admin')); - -$extrafields = new ExtraFields($db); -$form = new Form($db); - -// List of supported format -$tmptype2label = ExtraFields::$type2label; -$type2label = array(''); -foreach ($tmptype2label as $key => $val) { - $type2label[$key] = $langs->transnoentitiesnoconv($val); -} - -$action = GETPOST('action', 'aZ09'); -$attrname = GETPOST('attrname', 'alpha'); -$elementtype = 'bookcal_booking'; //Must be the $table_element of the class that manage extrafield - -if (!$user->admin) { - accessforbidden(); -} - - -/* - * Actions - */ - -require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php'; - - - -/* - * View - */ - -$textobject = $langs->transnoentitiesnoconv("Booking"); - -$help_url = ''; -$page_name = "BookCalSetup"; - -llxHeader('', $langs->trans("BookCalSetup"), $help_url); - - -$linkback = ''.$langs->trans("BackToModuleList").''; -print load_fiche_titre($langs->trans($page_name), $linkback, 'title_setup'); - - -$head = bookcalAdminPrepareHead(); - -print dol_get_fiche_head($head, 'booking_extrafields', $langs->trans($page_name), -1, 'fa-calendar-check'); - -require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; - -print dol_get_fiche_end(); - - - -/* - * Creation of an optional field - */ -if ($action == 'create') { - print '
'; - print load_fiche_titre($langs->trans('NewAttribute')); - - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; -} - -/* - * Edition of an optional field - */ -if ($action == 'edit' && !empty($attrname)) { - print "
"; - print load_fiche_titre($langs->trans("FieldEdition", $attrname)); - - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; -} - -// End of page -llxFooter(); -$db->close(); diff --git a/htdocs/bookcal/bookcalindex.php b/htdocs/bookcal/bookcalindex.php index bed921e91ea..c236815a040 100644 --- a/htdocs/bookcal/bookcalindex.php +++ b/htdocs/bookcal/bookcalindex.php @@ -27,7 +27,6 @@ // Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; -require_once DOL_DOCUMENT_ROOT.'/bookcal/class/booking.class.php'; // Load translation files required by the page $langs->loadLangs(array("agenda")); @@ -74,7 +73,7 @@ print '
'; // Draft MyObject if ($user->hasRight('bookcal', 'availabilities', 'read') && isModEnabled('bookcal')) { $langs->load("orders"); - $myobjectstatic = new Booking($db); + /*$myobjectstatic = new Booking($db); $sql = "SELECT rowid, `ref`, fk_soc, fk_project, description, note_public, note_private, date_creation, tms, fk_user_creat, fk_user_modif, last_main_doc, import_key, model_pdf, status, firstname, lastname, email, `start`, duration"; $sql .= " FROM ". MAIN_DB_PREFIX . 'bookcal_booking'; @@ -129,7 +128,7 @@ if ($user->hasRight('bookcal', 'availabilities', 'read') && isModEnabled('bookca $db->free($resql); } else { dol_print_error($db); - } + }*/ } //END MODULEBUILDER DRAFT MYOBJECT */ diff --git a/htdocs/bookcal/booking_agenda.php b/htdocs/bookcal/booking_agenda.php deleted file mode 100644 index 62346d66721..00000000000 --- a/htdocs/bookcal/booking_agenda.php +++ /dev/null @@ -1,268 +0,0 @@ - - * Copyright (C) 2022 Alice Adminson - * - * 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/bookcal/booking_agenda.php - * \ingroup bookcal - * \brief Tab of events on Booking - */ - -// Load Dolibarr environment -require '../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/bookcal/class/booking.class.php'; -require_once DOL_DOCUMENT_ROOT.'/bookcal/lib/bookcal_booking.lib.php'; - - -// Load translation files required by the page -$langs->loadLangs(array("agenda", "other")); - -// Get parameters -$id = GETPOST('id', 'int'); -$ref = GETPOST('ref', 'alpha'); -$action = GETPOST('action', 'aZ09'); -$cancel = GETPOST('cancel', 'aZ09'); -$backtopage = GETPOST('backtopage', 'alpha'); - -if (GETPOST('actioncode', 'array')) { - $actioncode = GETPOST('actioncode', 'array', 3); - if (!count($actioncode)) { - $actioncode = '0'; - } -} else { - $actioncode = GETPOST("actioncode", "alpha", 3) ? GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT)); -} - -$search_rowid = GETPOST('search_rowid'); -$search_agenda_label = GETPOST('search_agenda_label'); - -$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'); -if (empty($page) || $page == -1) { - $page = 0; -} // If $page is not defined, or '' or -1 -$offset = $limit * $page; -$pageprev = $page - 1; -$pagenext = $page + 1; -if (!$sortfield) { - $sortfield = 'a.datep,a.id'; -} -if (!$sortorder) { - $sortorder = 'DESC,DESC'; -} - -// Initialize technical objects -$object = new Booking($db); -$extrafields = new ExtraFields($db); -$diroutputmassaction = $conf->bookcal->dir_output.'/temp/massgeneration/'.$user->id; -$hookmanager->initHooks(array('bookingagenda', 'globalcard')); // Note that conf->hooks_modules contains array -// Fetch optionals attributes and labels -$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 // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals -if ($id > 0 || !empty($ref)) { - $upload_dir = $conf->bookcal->multidir_output[!empty($object->entity) ? $object->entity : $conf->entity]."/".$object->id; -} - -// There is several ways to check permission. -// Set $enablepermissioncheck to 1 to enable a minimum low level of checks -$enablepermissioncheck = 0; -if ($enablepermissioncheck) { - $permissiontoread = $user->rights->bookcal->booking->read; - $permissiontoadd = $user->rights->bookcal->booking->write; -} else { - $permissiontoread = 1; - $permissiontoadd = 1; -} - -// Security check (enable the most restrictive one) -//if ($user->socid > 0) accessforbidden(); -//if ($user->socid > 0) $socid = $user->socid; -//$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0); -//restrictedArea($user, $object->element, $object->id, $object->table_element, '', 'fk_soc', 'rowid', $isdraft); -if (!isModEnabled('bookcal')) accessforbidden(); -if (!$permissiontoread) accessforbidden(); - - -/* - * Actions - */ - -$parameters = array('id'=>$id); -$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks -if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); -} - -if (empty($reshook)) { - // Cancel - if (GETPOST('cancel', 'alpha') && !empty($backtopage)) { - header("Location: ".$backtopage); - exit; - } - - // Purge search criteria - if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers - $actioncode = ''; - $search_agenda_label = ''; - } -} - - - -/* - * View - */ - -$form = new Form($db); - -if ($object->id > 0) { - $title = $langs->trans("Agenda"); - //if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/',$conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->name." - ".$title; - $help_url = 'EN:Module_Agenda_En|DE:Modul_Terminplanung'; - llxHeader('', $title, $help_url); - - if (!empty($conf->notification->enabled)) { - $langs->load("mails"); - } - $head = bookingPrepareHead($object); - - - print dol_get_fiche_head($head, 'agenda', $langs->trans("Booking"), -1, $object->picto); - - // Object card - // ------------------------------------------------------------ - $linkback = ''.$langs->trans("BackToList").''; - - $morehtmlref = '
'; - /* - // Ref customer - $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1); - $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1); - // Thirdparty - $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . (is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : ''); - // Project - if (isModEnabled('project')) { - $langs->load("projects"); - $morehtmlref.='
'.$langs->trans('Project') . ' '; - if ($permissiontoadd) { - if ($action != 'classify') { - //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; - } - $morehtmlref.=' : '; - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.='
'; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.='
'; - } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); - } - } else { - if (! empty($object->fk_project)) { - $proj = new Project($db); - $proj->fetch($object->fk_project); - $morehtmlref .= ': '.$proj->getNomUrl(); - } else { - $morehtmlref .= ''; - } - } - }*/ - $morehtmlref .= '
'; - - - dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); - - print '
'; - print '
'; - - $object->info($object->id); - dol_print_object_info($object, 1); - - print '
'; - - print dol_get_fiche_end(); - - - - // Actions buttons - - $objthirdparty = $object; - $objcon = new stdClass(); - - $out = '&origin='.urlencode($object->element.'@'.$object->module).'&originid='.urlencode($object->id); - $urlbacktopage = $_SERVER['PHP_SELF'].'?id='.$object->id; - $out .= '&backtopage='.urlencode($urlbacktopage); - $permok = $user->hasRight('agenda', 'myactions', 'create'); - if ((!empty($objthirdparty->id) || !empty($objcon->id)) && $permok) { - //$out.='trans("AddAnAction"),'filenew'); - //$out.=""; - } - - - print '
'; - - if (isModEnabled('agenda')) { - if ($user->hasRight('agenda', 'myactions', 'create') || $user->hasRight('agenda', 'allactions', 'create')) { - print ''.$langs->trans("AddAction").''; - } else { - print ''.$langs->trans("AddAction").''; - } - } - - print '
'; - - if (isModEnabled('agenda') && ($user->hasRight('agenda', 'myactions', 'read') || $user->hasRight('agenda', 'allactions', 'read'))) { - $param = '&id='.$object->id.(!empty($socid) ? '&socid='.$socid : ''); - if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { - $param .= '&contextpage='.urlencode($contextpage); - } - if ($limit > 0 && $limit != $conf->liste_limit) { - $param .= '&limit='.((int) $limit); - } - - - //print load_fiche_titre($langs->trans("ActionsOnBooking"), '', ''); - - // List of all actions - $filters = array(); - $filters['search_agenda_label'] = $search_agenda_label; - $filters['search_rowid'] = $search_rowid; - - // TODO Replace this with same code than into list.php - show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder, $object->module); - } -} - -// End of page -llxFooter(); -$db->close(); diff --git a/htdocs/bookcal/booking_card.php b/htdocs/bookcal/booking_card.php deleted file mode 100644 index f85331cc801..00000000000 --- a/htdocs/bookcal/booking_card.php +++ /dev/null @@ -1,569 +0,0 @@ - - * Copyright (C) 2022 Alice Adminson - * - * 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/bookcal/booking_card.php - * \ingroup bookcal - * \brief Page to create/edit/view booking - */ - -// Load Dolibarr environment -require '../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; -require_once DOL_DOCUMENT_ROOT.'/bookcal/class/booking.class.php'; -require_once DOL_DOCUMENT_ROOT.'/bookcal/lib/bookcal_booking.lib.php'; - -// Load translation files required by the page -$langs->loadLangs(array("agenda", "other")); - -// Get parameters -$id = GETPOST('id', 'int'); -$ref = GETPOST('ref', 'alpha'); -$lineid = GETPOST('lineid', 'int'); - -$action = GETPOST('action', 'aZ09'); -$confirm = GETPOST('confirm', 'alpha'); -$cancel = GETPOST('cancel', 'aZ09'); -$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'); -$backtopageforcancel = GETPOST('backtopageforcancel', 'alpha'); -$dol_openinpopup = GETPOST('dol_openinpopup', 'aZ09'); - -// Initialize technical objects -$object = new Booking($db); -$extrafields = new ExtraFields($db); -$diroutputmassaction = $conf->bookcal->dir_output.'/temp/massgeneration/'.$user->id; -$hookmanager->initHooks(array('bookingcard', 'globalcard')); // Note that conf->hooks_modules contains array - -// Fetch optionals attributes and labels -$extrafields->fetch_name_optionals_label($object->table_element); - -$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); - -// Initialize array of search criterias -$search_all = GETPOST("search_all", 'alpha'); -$search = array(); -foreach ($object->fields as $key => $val) { - if (GETPOST('search_'.$key, 'alpha')) { - $search[$key] = GETPOST('search_'.$key, 'alpha'); - } -} - -if (empty($action) && empty($id) && empty($ref)) { - $action = 'view'; -} - -// Load object -include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once. - -// There is several ways to check permission. -// Set $enablepermissioncheck to 1 to enable a minimum low level of checks -$enablepermissioncheck = 0; -if ($enablepermissioncheck) { - $permissiontoread = $user->rights->bookcal->booking->read; - $permissiontoadd = $user->rights->bookcal->booking->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php - $permissiontodelete = $user->rights->bookcal->booking->delete || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT); - $permissionnote = $user->rights->bookcal->booking->write; // Used by the include of actions_setnotes.inc.php - $permissiondellink = $user->rights->bookcal->booking->write; // Used by the include of actions_dellink.inc.php -} else { - $permissiontoread = 1; - $permissiontoadd = 1; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php - $permissiontodelete = 1; - $permissionnote = 1; - $permissiondellink = 1; -} - -$upload_dir = $conf->bookcal->multidir_output[isset($object->entity) ? $object->entity : 1].'/booking'; - -// Security check (enable the most restrictive one) -//if ($user->socid > 0) accessforbidden(); -//if ($user->socid > 0) $socid = $user->socid; -//$isdraft = (isset($object->status) && ($object->status == $object::STATUS_DRAFT) ? 1 : 0); -//restrictedArea($user, $object->element, $object->id, $object->table_element, '', 'fk_soc', 'rowid', $isdraft); -if (!isModEnabled('bookcal')) accessforbidden(); -if (!$permissiontoread) accessforbidden(); - - -/* - * Actions - */ - -$parameters = array(); -$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks -if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); -} - -if (empty($reshook)) { - $error = 0; - - $backurlforlist = dol_buildpath('/bookcal/booking_list.php', 1); - - if (empty($backtopage) || ($cancel && empty($id))) { - if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) { - if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) { - $backtopage = $backurlforlist; - } else { - $backtopage = dol_buildpath('/bookcal/booking_card.php', 1).'?id='.((!empty($id) && $id > 0) ? $id : '__ID__'); - } - } - } - - $triggermodname = 'BOOKCAL_BOOKING_MODIFY'; // Name of trigger action code to execute when we modify record - - // Actions cancel, add, update, update_extras, confirm_validate, confirm_delete, confirm_deleteline, confirm_clone, confirm_close, confirm_setdraft, confirm_reopen - include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php'; - - // Actions when linking object each other - include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; - - // Actions when printing a doc from card - include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; - - // Action to move up and down lines of object - //include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php'; - - // Action to build doc - include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; - - if ($action == 'set_thirdparty' && $permissiontoadd) { - $object->setValueFrom('fk_soc', GETPOST('fk_soc', 'int'), '', '', 'date', '', $user, $triggermodname); - } - if ($action == 'classin' && $permissiontoadd) { - $object->setProject(GETPOST('projectid', 'int')); - } - - // Actions to send emails - $triggersendname = 'BOOKCAL_BOOKING_SENTBYMAIL'; - $autocopy = 'MAIN_MAIL_AUTOCOPY_BOOKING_TO'; - $trackid = 'booking'.$object->id; - include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; -} - - - - -/* - * View - * - * Put here all code to build page - */ - -$form = new Form($db); -$formfile = new FormFile($db); -$formproject = new FormProjets($db); - -$title = $langs->trans("Booking"); -$help_url = ''; -llxHeader('', $title, $help_url); - -// Example : Adding jquery code -// print ''; - - -// Part to create -if ($action == 'create') { - if (empty($permissiontoadd)) { - accessforbidden($langs->trans('NotEnoughPermissions'), 0, 1); - exit; - } - - print load_fiche_titre($langs->trans("NewObject", $langs->transnoentitiesnoconv("Booking")), '', 'object_'.$object->picto); - - print '
'; - print ''; - print ''; - if ($backtopage) { - print ''; - } - if ($backtopageforcancel) { - print ''; - } - - print dol_get_fiche_head(array(), ''); - - // Set some default values - //if (! GETPOSTISSET('fieldname')) $_POST['fieldname'] = 'myvalue'; - - print ''."\n"; - - // Common attributes - include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_add.tpl.php'; - - // Other attributes - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php'; - - print '
'."\n"; - - print dol_get_fiche_end(); - - print $form->buttonsSaveCancel("Create"); - - print '
'; - - //dol_set_focus('input[name="ref"]'); -} - -// Part to edit record -if (($id || $ref) && $action == 'edit') { - print load_fiche_titre($langs->trans("Booking"), '', 'object_'.$object->picto); - - print '
'; - print ''; - print ''; - print ''; - if ($backtopage) { - print ''; - } - if ($backtopageforcancel) { - print ''; - } - - print dol_get_fiche_head(); - - print ''."\n"; - - // Common attributes - include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_edit.tpl.php'; - - // Other attributes - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_edit.tpl.php'; - - print '
'; - - print dol_get_fiche_end(); - - print $form->buttonsSaveCancel(); - - print '
'; -} - -// Part to show record -if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) { - $res = $object->fetch_optionals(); - - $head = bookingPrepareHead($object); - print dol_get_fiche_head($head, 'card', $langs->trans("Booking"), -1, $object->picto); - - $formconfirm = ''; - - // Confirmation to delete - if ($action == 'delete') { - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteBooking'), $langs->trans('ConfirmDeleteObject'), 'confirm_delete', '', 0, 1); - } - // Confirmation to delete line - if ($action == 'deleteline') { - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_deleteline', '', 0, 1); - } - - // Clone confirmation - if ($action == 'clone') { - // Create an array for form - $formquestion = array(); - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneAsk', $object->ref), 'confirm_clone', $formquestion, 'yes', 1); - } - - // Confirmation of action xxxx (You can use it for xxx = 'close', xxx = 'reopen', ...) - if ($action == 'xxx') { - $text = $langs->trans('ConfirmActionBooking', $object->ref); - /*if (! empty($conf->notification->enabled)) - { - require_once DOL_DOCUMENT_ROOT . '/core/class/notify.class.php'; - $notify = new Notify($db); - $text .= '
'; - $text .= $notify->confirmMessage('BOOKING_CLOSE', $object->socid, $object); - }*/ - - $formquestion = array(); - /* - $forcecombo=0; - if ($conf->browser->name == 'ie') $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy - $formquestion = array( - // 'text' => $langs->trans("ConfirmClone"), - // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1), - // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1), - // array('type' => 'other', 'name' => 'idwarehouse', 'label' => $langs->trans("SelectWarehouseForStockDecrease"), 'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse')?GETPOST('idwarehouse'):'ifone', 'idwarehouse', '', 1, 0, 0, '', 0, $forcecombo)) - ); - */ - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('XXX'), $text, 'confirm_xxx', $formquestion, 0, 1, 220); - } - - // Call Hook formConfirm - $parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid); - $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if (empty($reshook)) { - $formconfirm .= $hookmanager->resPrint; - } elseif ($reshook > 0) { - $formconfirm = $hookmanager->resPrint; - } - - // Print form confirm - print $formconfirm; - - - // Object card - // ------------------------------------------------------------ - $linkback = ''.$langs->trans("BackToList").''; - - $morehtmlref = '
'; - /* - // Ref customer - $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1); - $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1); - // Thirdparty - $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . (is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : ''); - // Project - if (isModEnabled('project')) { - $langs->load("projects"); - $morehtmlref .= '
'.$langs->trans('Project') . ' '; - if ($permissiontoadd) { - //if ($action != 'classify') $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' '; - $morehtmlref .= ' : '; - if ($action == 'classify') { - //$morehtmlref .= $form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 0, 1, '', 'maxwidth300'); - $morehtmlref .= '
'; - $morehtmlref .= ''; - $morehtmlref .= ''; - $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref .= ''; - $morehtmlref .= '
'; - } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1, '', 'maxwidth300'); - } - } else { - if (! empty($object->fk_project)) { - $proj = new Project($db); - $proj->fetch($object->fk_project); - $morehtmlref .= ': '.$proj->getNomUrl(); - } else { - $morehtmlref .= ''; - } - } - }*/ - $morehtmlref .= '
'; - - - dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); - - - print '
'; - print '
'; - print '
'; - print ''."\n"; - - // Common attributes - //$keyforbreak='fieldkeytoswitchonsecondcolumn'; // We change column just before this field - //unset($object->fields['fk_project']); // Hide field already shown in banner - //unset($object->fields['fk_soc']); // Hide field already shown in banner - include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php'; - - // Other attributes. Fields from hook formObjectOptions and Extrafields. - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; - - print '
'; - print '
'; - print '
'; - - print '
'; - - print dol_get_fiche_end(); - - - /* - * Lines - */ - - if (!empty($object->table_element_line)) { - // Show object lines - $result = $object->getLinesArray(); - - print '
- - - - - - '; - - if (!empty($conf->use_javascript_ajax) && $object->status == 0) { - include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php'; - } - - print '
'; - if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) { - print ''; - } - - if (!empty($object->lines)) { - $object->printObjectLines($action, $mysoc, null, GETPOST('lineid', 'int'), 1); - } - - // Form to add new line - if ($object->status == 0 && $permissiontoadd && $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'); - if (empty($reshook)) - $object->formAddObjectLine(1, $mysoc, $soc); - } - } - - if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) { - print '
'; - } - print '
'; - - print "
\n"; - } - - - // Buttons for actions - - if ($action != 'presend' && $action != 'editline') { - print '
'."\n"; - $parameters = array(); - $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); - } - - if (empty($reshook)) { - // Send - if (empty($user->socid)) { - print dolGetButtonAction($langs->trans('SendMail'), '', 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=presend&mode=init&token='.newToken().'#formmailbeforetitle'); - } - - // Back to draft - if ($object->status == $object::STATUS_VALIDATED) { - print dolGetButtonAction($langs->trans('SetToDraft'), '', 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=confirm_setdraft&confirm=yes&token='.newToken(), '', $permissiontoadd); - } - - print dolGetButtonAction($langs->trans('Modify'), '', 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=edit&token='.newToken(), '', $permissiontoadd); - - // Validate - if ($object->status == $object::STATUS_DRAFT) { - if (empty($object->table_element_line) || (is_array($object->lines) && count($object->lines) > 0)) { - print dolGetButtonAction($langs->trans('Validate'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=confirm_validate&confirm=yes&token='.newToken(), '', $permissiontoadd); - } else { - $langs->load("errors"); - print dolGetButtonAction($langs->trans("ErrorAddAtLeastOneLineFirst"), $langs->trans("Validate"), 'default', '#', '', 0); - } - } - - // Clone - print dolGetButtonAction($langs->trans('ToClone'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.(!empty($object->socid)?'&socid='.$object->socid:'').'&action=clone&token='.newToken(), '', $permissiontoadd); - - /* - if ($permissiontoadd) { - if ($object->status == $object::STATUS_ENABLED) { - print dolGetButtonAction($langs->trans('Disable'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=disable&token='.newToken(), '', $permissiontoadd); - } else { - print dolGetButtonAction($langs->trans('Enable'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=enable&token='.newToken(), '', $permissiontoadd); - } - } - if ($permissiontoadd) { - if ($object->status == $object::STATUS_VALIDATED) { - print dolGetButtonAction($langs->trans('Cancel'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=close&token='.newToken(), '', $permissiontoadd); - } else { - print dolGetButtonAction($langs->trans('Re-Open'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=reopen&token='.newToken(), '', $permissiontoadd); - } - } - */ - - // Delete (need delete permission, or if draft, just need create/modify permission) - print dolGetButtonAction($langs->trans('Delete'), '', 'delete', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=delete&token='.newToken(), '', $permissiontodelete || ($object->status == $object::STATUS_DRAFT && $permissiontoadd)); - } - print '
'."\n"; - } - - - // Select mail models is same action as presend - if (GETPOST('modelselected')) { - $action = 'presend'; - } - - if ($action != 'presend') { - print '
'; - print ''; // ancre - - $includedocgeneration = 0; - - // Documents - if ($includedocgeneration) { - $objref = dol_sanitizeFileName($object->ref); - $relativepath = $objref.'/'.$objref.'.pdf'; - $filedir = $conf->bookcal->dir_output.'/'.$object->element.'/'.$objref; - $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; - $genallowed = $permissiontoread; // If you can read, you can build the PDF to read content - $delallowed = $permissiontoadd; // If you can create/edit, you can remove a file on card - print $formfile->showdocuments('bookcal:Booking', $object->element.'/'.$objref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', '', '', $langs->defaultlang); - } - - // Show links to link elements - $linktoelem = $form->showLinkToObjectBlock($object, null, array('booking')); - $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem); - - - print '
'; - - $MAXEVENT = 10; - - $morehtmlcenter = dolGetButtonTitle($langs->trans('SeeAll'), '', 'fa fa-bars imgforviewmode', dol_buildpath('/bookcal/booking_agenda.php', 1).'?id='.$object->id); - - // List of actions on element - include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; - $formactions = new FormActions($db); - $somethingshown = $formactions->showactions($object, $object->element.'@'.$object->module, (is_object($object->thirdparty) ? $object->thirdparty->id : 0), 1, '', $MAXEVENT, '', $morehtmlcenter); - - print '
'; - } - - //Select mail models is same action as presend - if (GETPOST('modelselected')) { - $action = 'presend'; - } - - // Presend form - $modelmail = 'booking'; - $defaulttopic = 'InformationMessage'; - $diroutput = $conf->bookcal->dir_output; - $trackid = 'booking'.$object->id; - - include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php'; -} - -// End of page -llxFooter(); -$db->close(); diff --git a/htdocs/bookcal/booking_contact.php b/htdocs/bookcal/booking_contact.php deleted file mode 100644 index 938e3287c70..00000000000 --- a/htdocs/bookcal/booking_contact.php +++ /dev/null @@ -1,197 +0,0 @@ - - * Copyright (C) 2022 Alice Adminson - * - * 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/bookcal/booking_contact.php - * \ingroup bookcal - * \brief Tab for contacts linked to Booking - */ - -// Load Dolibarr environment -require '../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; -require_once DOL_DOCUMENT_ROOT.'/bookcal/class/booking.class.php'; -require_once DOL_DOCUMENT_ROOT.'/bookcal/lib/bookcal_booking.lib.php'; - -// Load translation files required by the page -$langs->loadLangs(array("agenda", "companies", "other", "mails")); - -$id = (GETPOST('id') ?GETPOST('id', 'int') : GETPOST('facid', 'int')); // For backward compatibility -$ref = GETPOST('ref', 'alpha'); -$lineid = GETPOST('lineid', 'int'); -$socid = GETPOST('socid', 'int'); -$action = GETPOST('action', 'aZ09'); - -// Initialize technical objects -$object = new Booking($db); -$extrafields = new ExtraFields($db); -$diroutputmassaction = $conf->bookcal->dir_output.'/temp/massgeneration/'.$user->id; -$hookmanager->initHooks(array('bookingcontact', 'globalcard')); // Note that conf->hooks_modules contains array -// Fetch optionals attributes and labels -$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 // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals - -// There is several ways to check permission. -// Set $enablepermissioncheck to 1 to enable a minimum low level of checks -$enablepermissioncheck = 0; -if ($enablepermissioncheck) { - $permissiontoread = $user->rights->bookcal->booking->read; - $permission = $user->rights->bookcal->booking->write; -} else { - $permissiontoread = 1; - $permission = 1; -} - -// Security check (enable the most restrictive one) -//if ($user->socid > 0) accessforbidden(); -//if ($user->socid > 0) $socid = $user->socid; -//$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0); -//restrictedArea($user, $object->element, $object->id, $object->table_element, '', 'fk_soc', 'rowid', $isdraft); -if (!isModEnabled('bookcal')) accessforbidden(); -if (!$permissiontoread) accessforbidden(); - - -/* - * Add a new contact - */ - -if ($action == 'addcontact' && $permission) { - $contactid = (GETPOST('userid') ? GETPOST('userid', 'int') : GETPOST('contactid', 'int')); - $typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type')); - $result = $object->add_contact($contactid, $typeid, GETPOST("source", 'aZ09')); - - if ($result >= 0) { - header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); - exit; - } else { - if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') { - $langs->load("errors"); - setEventMessages($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), null, 'errors'); - } else { - setEventMessages($object->error, $object->errors, 'errors'); - } - } -} elseif ($action == 'swapstatut' && $permission) { - // Toggle the status of a contact - $result = $object->swapContactStatus(GETPOST('ligne', 'int')); -} elseif ($action == 'deletecontact' && $permission) { - // Deletes a contact - $result = $object->delete_contact($lineid); - - if ($result >= 0) { - header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); - exit; - } else { - dol_print_error($db); - } -} - - -/* - * View - */ - -$title = $langs->trans('Booking')." - ".$langs->trans('ContactsAddresses'); -$help_url = ''; -//$help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; -llxHeader('', $title, $help_url); - -$form = new Form($db); -$formcompany = new FormCompany($db); -$contactstatic = new Contact($db); -$userstatic = new User($db); - - -/* *************************************************************************** */ -/* */ -/* View and edit mode */ -/* */ -/* *************************************************************************** */ - -if ($object->id) { - /* - * Show tabs - */ - $head = bookingPrepareHead($object); - - print dol_get_fiche_head($head, 'contact', $langs->trans("Booking"), -1, $object->picto); - - $linkback = ''.$langs->trans("BackToList").''; - - $morehtmlref = '
'; - /* - // Ref customer - $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1); - $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1); - // Thirdparty - $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . (is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : ''); - // Project - if (isModEnabled('project')) - { - $langs->load("projects"); - $morehtmlref.='
'.$langs->trans('Project') . ' '; - if ($permissiontoadd) - { - if ($action != 'classify') - //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; - $morehtmlref.=' : '; - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.='
'; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.='
'; - } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); - } - } else { - if (! empty($object->fk_project)) { - $proj = new Project($db); - $proj->fetch($object->fk_project); - $morehtmlref .= ': '.$proj->getNomUrl(); - } else { - $morehtmlref .= ''; - } - } - }*/ - $morehtmlref .= '
'; - - dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0, '', '', 1); - - print dol_get_fiche_end(); - - print '
'; - - // Contacts lines (modules that overwrite templates must declare this into descriptor) - $dirtpls = array_merge($conf->modules_parts['tpl'], array('/core/tpl')); - foreach ($dirtpls as $reldir) { - $res = @include dol_buildpath($reldir.'/contacts.tpl.php'); - if ($res) { - break; - } - } -} - -// End of page -llxFooter(); -$db->close(); diff --git a/htdocs/bookcal/booking_document.php b/htdocs/bookcal/booking_document.php deleted file mode 100644 index d04258d54d2..00000000000 --- a/htdocs/bookcal/booking_document.php +++ /dev/null @@ -1,211 +0,0 @@ - - * Copyright (C) 2022 Alice Adminson - * - * 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/bookcal/booking_document.php - * \ingroup bookcal - * \brief Tab for documents linked to Booking - */ - -// Load Dolibarr environment -require '../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; -require_once DOL_DOCUMENT_ROOT.'/bookcal/class/booking.class.php'; -require_once DOL_DOCUMENT_ROOT.'/bookcal/lib/bookcal_booking.lib.php'; - -// Load translation files required by the page -$langs->loadLangs(array("agenda", "companies", "other", "mails")); - - -$action = GETPOST('action', 'aZ09'); -$confirm = GETPOST('confirm'); -$id = (GETPOST('socid', 'int') ? GETPOST('socid', 'int') : GETPOST('id', 'int')); -$ref = GETPOST('ref', 'alpha'); - -// Get parameters -$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'); -if (empty($page) || $page == -1) { - $page = 0; -} // If $page is not defined, or '' or -1 -$offset = $limit * $page; -$pageprev = $page - 1; -$pagenext = $page + 1; -if (!$sortorder) { - $sortorder = "ASC"; -} -if (!$sortfield) { - $sortfield = "name"; -} -//if (! $sortfield) $sortfield="position_name"; - -// Initialize technical objects -$object = new Booking($db); -$extrafields = new ExtraFields($db); -$diroutputmassaction = $conf->bookcal->dir_output.'/temp/massgeneration/'.$user->id; -$hookmanager->initHooks(array('bookingdocument', 'globalcard')); // Note that conf->hooks_modules contains array -// Fetch optionals attributes and labels -$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 // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals - -if ($id > 0 || !empty($ref)) { - $upload_dir = $conf->bookcal->multidir_output[$object->entity ? $object->entity : $conf->entity]."/booking/".get_exdir(0, 0, 0, 1, $object); -} - -// There is several ways to check permission. -// Set $enablepermissioncheck to 1 to enable a minimum low level of checks -$enablepermissioncheck = 0; -if ($enablepermissioncheck) { - $permissiontoread = $user->rights->bookcal->booking->read; - $permissiontoadd = $user->rights->bookcal->booking->write; // Used by the include of actions_addupdatedelete.inc.php and actions_linkedfiles.inc.php -} else { - $permissiontoread = 1; - $permissiontoadd = 1; -} - -// Security check (enable the most restrictive one) -//if ($user->socid > 0) accessforbidden(); -//if ($user->socid > 0) $socid = $user->socid; -//$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0); -//restrictedArea($user, $object->element, $object->id, $object->table_element, '', 'fk_soc', 'rowid', $isdraft); -if (!isModEnabled('bookcal')) accessforbidden(); -if (!$permissiontoread) accessforbidden(); - - -/* - * Actions - */ - -include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; - - -/* - * View - */ - -$form = new Form($db); - -$title = $langs->trans("Booking").' - '.$langs->trans("Files"); -$help_url = ''; -//$help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; -llxHeader('', $title, $help_url); - -if ($object->id) { - /* - * Show tabs - */ - $head = bookingPrepareHead($object); - - print dol_get_fiche_head($head, 'document', $langs->trans("Booking"), -1, $object->picto); - - - // Build file list - $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1); - $totalsize = 0; - foreach ($filearray as $key => $file) { - $totalsize += $file['size']; - } - - // Object card - // ------------------------------------------------------------ - $linkback = ''.$langs->trans("BackToList").''; - - $morehtmlref = '
'; - /* - // Ref customer - $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1); - $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1); - // Thirdparty - $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . (is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : ''); - // Project - if (isModEnabled('project')) - { - $langs->load("projects"); - $morehtmlref.='
'.$langs->trans('Project') . ' '; - if ($permissiontoadd) - { - if ($action != 'classify') - //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; - $morehtmlref.=' : '; - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.='
'; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.='
'; - } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); - } - } else { - if (! empty($object->fk_project)) { - $proj = new Project($db); - $proj->fetch($object->fk_project); - $morehtmlref .= ': '.$proj->getNomUrl(); - } else { - $morehtmlref .= ''; - } - } - }*/ - $morehtmlref .= '
'; - - dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); - - print '
'; - - print '
'; - print ''; - - // Number of files - print ''; - - // Total size - print ''; - - print '
'.$langs->trans("NbOfAttachedFiles").''.count($filearray).'
'.$langs->trans("TotalSizeOfAttachedFiles").''.$totalsize.' '.$langs->trans("bytes").'
'; - - print '
'; - - print dol_get_fiche_end(); - - $modulepart = 'bookcal'; - //$permissiontoadd = $user->rights->bookcal->booking->write; - $permissiontoadd = 1; - //$permtoedit = $user->rights->bookcal->booking->write; - $permtoedit = 1; - $param = '&id='.$object->id; - - //$relativepathwithnofile='booking/' . dol_sanitizeFileName($object->id).'/'; - $relativepathwithnofile = 'booking/'.dol_sanitizeFileName($object->ref).'/'; - - include DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; -} else { - accessforbidden('', 0, 1); -} - -// End of page -llxFooter(); -$db->close(); diff --git a/htdocs/bookcal/booking_list.php b/htdocs/bookcal/booking_list.php deleted file mode 100644 index a141f33a909..00000000000 --- a/htdocs/bookcal/booking_list.php +++ /dev/null @@ -1,794 +0,0 @@ - - * Copyright (C) 2022 Alice Adminson - * - * 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/bookcal/booking_list.php - * \ingroup bookcal - * \brief List page for booking - */ - -// Load Dolibarr environment -require '../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; - -// load bookcal libraries -require_once __DIR__.'/class/booking.class.php'; - -// for other modules -//dol_include_once('/othermodule/class/otherobject.class.php'); - -// Load translation files required by the page -$langs->loadLangs(array("agenda", "other")); - -$id = GETPOST('id', 'int'); -$ref = GETPOST('ref', 'alpha'); - -$action = GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ... -$massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists) -$show_files = GETPOST('show_files', 'int'); // Show files area generated by bulk actions ? -$confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation -$cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button -$toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list -$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'); // Go back to a dedicated page -$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') -$mode = GETPOST('mode', 'aZ'); - -// Load variable for pagination -$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'); -if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) { - // If $page is not defined, or '' or -1 or if we click on clear filters - $page = 0; -} -$offset = $limit * $page; -$pageprev = $page - 1; -$pagenext = $page + 1; - -// Initialize technical objects -$object = new Booking($db); -$extrafields = new ExtraFields($db); -$diroutputmassaction = $conf->bookcal->dir_output.'/temp/massgeneration/'.$user->id; -$hookmanager->initHooks(array('bookinglist')); // Note that conf->hooks_modules contains array - -// Fetch optionals attributes and labels -$extrafields->fetch_name_optionals_label($object->table_element); -//$extrafields->fetch_name_optionals_label($object->table_element_line); - -$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); - -// Default sort order (if not yet defined by previous GETPOST) -if (!$sortfield) { - reset($object->fields); // Reset is required to avoid key() to return null. - $sortfield = "t.".key($object->fields); // Set here default search field. By default 1st field in definition. -} -if (!$sortorder) { - $sortorder = "ASC"; -} - -// Initialize array of search criterias -$search_all = GETPOST('search_all', 'alphanohtml'); -$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" -$fieldstosearchall = array(); -foreach ($object->fields as $key => $val) { - if (!empty($val['searchall'])) { - $fieldstosearchall['t.'.$key] = $val['label']; - } -} - -// Definition of array of fields for columns -$arrayfields = array(); -foreach ($object->fields as $key => $val) { - // If $val['visible']==0, then we never show the field - if (!empty($val['visible'])) { - $visible = (int) dol_eval($val['visible'], 1); - $arrayfields['t.'.$key] = array( - 'label'=>$val['label'], - 'checked'=>(($visible < 0) ? 0 : 1), - 'enabled'=>(abs($visible) != 3 && dol_eval($val['enabled'], 1)), - 'position'=>$val['position'], - 'help'=> isset($val['help']) ? $val['help'] : '' - ); - } -} -// Extra fields -include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; - -$object->fields = dol_sort_array($object->fields, 'position'); -//$arrayfields['anotherfield'] = array('type'=>'integer', 'label'=>'AnotherField', 'checked'=>1, 'enabled'=>1, 'position'=>90, 'csslist'=>'right'); -$arrayfields = dol_sort_array($arrayfields, 'position'); - -// There is several ways to check permission. -// Set $enablepermissioncheck to 1 to enable a minimum low level of checks -$enablepermissioncheck = 0; -if ($enablepermissioncheck) { - $permissiontoread = $user->rights->bookcal->booking->read; - $permissiontoadd = $user->rights->bookcal->booking->write; - $permissiontodelete = $user->rights->bookcal->booking->delete; -} else { - $permissiontoread = 1; - $permissiontoadd = 1; - $permissiontodelete = 1; -} - -// Security check (enable the most restrictive one) -if ($user->socid > 0) accessforbidden(); -//if ($user->socid > 0) accessforbidden(); -//$socid = 0; if ($user->socid > 0) $socid = $user->socid; -//$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0); -//restrictedArea($user, $object->element, 0, $object->table_element, '', 'fk_soc', 'rowid', $isdraft); -if (!isModEnabled('bookcal')) accessforbidden('Module not enabled'); -if (!$permissiontoread) accessforbidden(); - - -/* - * Actions - */ - -if (GETPOST('cancel', 'alpha')) { - $action = 'list'; - $massaction = ''; -} -if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { - $massaction = ''; -} - -$parameters = array(); -$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks -if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); -} - -if (empty($reshook)) { - // Selection of new fields - include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; - - // Purge search criteria - if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers - foreach ($object->fields as $key => $val) { - $search[$key] = ''; - if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) { - $search[$key.'_dtstart'] = ''; - $search[$key.'_dtend'] = ''; - } - } - $toselect = array(); - $search_array_options = array(); - } - if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha') - || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) { - $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation - } - - // Mass actions - $objectclass = 'Booking'; - $objectlabel = 'Booking'; - $uploaddir = $conf->bookcal->dir_output; - include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; -} - - - -/* - * View - */ - -$form = new Form($db); - -$now = dol_now(); - -//$help_url = "EN:Module_Booking|FR:Module_Booking_FR|ES:Módulo_Booking"; -$help_url = ''; -$title = $langs->trans("Bookings"); -$morejs = array(); -$morecss = array(); - - -// Build and execute select -// -------------------------------------------------------------------- -$sql = 'SELECT '; -$sql .= $object->getFieldList('t'); -// Add fields from extrafields -if (!empty($extrafields->attributes[$object->table_element]['label'])) { - foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : ''); - } -} -// Add fields from hooks -$parameters = array(); -$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook -$sql .= $hookmanager->resPrint; -$sql = preg_replace('/,\s*$/', '', $sql); -//$sql .= ", COUNT(rc.rowid) as anotherfield"; -$sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; -//$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."anothertable as rc ON rc.parent = t.rowid"; -if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)"; -} -// Add table from hooks -$parameters = array(); -$reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object); // Note that $action and $object may have been modified by hook -$sql .= $hookmanager->resPrint; -if ($object->ismultientitymanaged == 1) { - $sql .= " WHERE t.entity IN (".getEntity($object->element).")"; -} else { - $sql .= " WHERE 1 = 1"; -} -foreach ($search as $key => $val) { - if (array_key_exists($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) || (strpos($object->fields[$key]['type'], 'sellist:') === 0) || !empty($object->fields[$key]['arrayofkeyval'])) { - if ($search[$key] == '-1' || ($search[$key] === '0' && (empty($object->fields[$key]['arrayofkeyval']) || !array_key_exists('0', $object->fields[$key]['arrayofkeyval'])))) { - $search[$key] = ''; - } - $mode_search = 2; - } - if ($search[$key] != '') { - $sql .= natural_search("t.".$db->escape($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.".$db->escape($columnName)." >= '".$db->idate($search[$key])."'"; - } - if (preg_match('/_dtend$/', $key)) { - $sql .= " AND t.".$db->escape($columnName)." <= '".$db->idate($search[$key])."'"; - } - } - } - } -} -if ($search_all) { - $sql .= natural_search(array_keys($fieldstosearchall), $search_all); -} -//$sql.= dolSqlDateFilter("t.field", $search_xxxday, $search_xxxmonth, $search_xxxyear); -// Add where from extra fields -include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; -// Add where from hooks -$parameters = array(); -$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook -$sql .= $hookmanager->resPrint; - -/* If a group by is required -$sql .= " GROUP BY "; -foreach($object->fields as $key => $val) { - $sql .= "t.".$db->escape($key).", "; -} -// Add fields from extrafields -if (!empty($extrafields->attributes[$object->table_element]['label'])) { - foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.', ' : ''); - } -} -// Add where from hooks -$parameters = array(); -$reshook = $hookmanager->executeHooks('printFieldListGroupBy', $parameters, $object); // Note that $action and $object may have been modified by hook -$sql .= $hookmanager->resPrint; -$sql = preg_replace('/,\s*$/', '', $sql); -*/ - -// Add HAVING from hooks -/* -$parameters = array(); -$reshook = $hookmanager->executeHooks('printFieldListHaving', $parameters, $object); // Note that $action and $object may have been modified by hook -$sql .= empty($hookmanager->resPrint) ? "" : " HAVING 1=1 ".$hookmanager->resPrint; -*/ - -// Count total nb of records -$nbtotalofrecords = ''; -if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) { - /* This old and fast method to get and count full list returns all record so use a high amount of memory. - $resql = $db->query($sql); - $nbtotalofrecords = $db->num_rows($resql); - */ - /* The slow method does not consume memory on mysql (not tested on pgsql) */ - /*$resql = $db->query($sql, 0, 'auto', 1); - while ($db->fetch_object($resql)) { - if (empty($nbtotalofrecords)) { - $nbtotalofrecords = 1; // We can't make +1 because init value is '' - } else { - $nbtotalofrecords++; - } - }*/ - /* The fast and low memory method to get and count full list converts the sql into a sql count */ - $sqlforcount = preg_replace('/^SELECT[a-zA-Z0-9\._\s\(\),=<>\:\-\']+\sFROM/', 'SELECT COUNT(*) as nbtotalofrecords FROM', $sql); - $resql = $db->query($sqlforcount); - if ($resql) { - $objforcount = $db->fetch_object($resql); - $nbtotalofrecords = $objforcount->nbtotalofrecords; - } else { - dol_print_error($db); - } - - if (($page * $limit) > $nbtotalofrecords) { // if total of record found is smaller than page * limit, goto and load page 0 - $page = 0; - $offset = 0; - } - $db->free($resql); -} - -// Complete request and execute it with limit -$sql .= $db->order($sortfield, $sortorder); -if ($limit) { - $sql .= $db->plimit($limit + 1, $offset); -} - -$resql = $db->query($sql); -if (!$resql) { - dol_print_error($db); - exit; -} - -$num = $db->num_rows($resql); - - -// Direct jump if only one record found -if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all && !$page) { - $obj = $db->fetch_object($resql); - $id = $obj->rowid; - header("Location: ".dol_buildpath('/bookcal/booking_card.php', 1).'?id='.$id); - exit; -} - - -// Output page -// -------------------------------------------------------------------- - -llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', 'bodyforlist'); - -// Example : Adding jquery code -// print ''; - -$arrayofselected = is_array($toselect) ? $toselect : array(); - -$param = ''; -if (!empty($mode)) { - $param .= '&mode='.urlencode($mode); -} -if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { - $param .= '&contextpage='.urlencode($contextpage); -} -if ($limit > 0 && $limit != $conf->liste_limit) { - $param .= '&limit='.((int) $limit); -} -foreach ($search as $key => $val) { - if (is_array($search[$key]) && count($search[$key])) { - foreach ($search[$key] as $skey) { - if ($skey != '') { - $param .= '&search_'.$key.'[]='.urlencode($skey); - } - } - } elseif ($search[$key] != '') { - $param .= '&search_'.$key.'='.urlencode($search[$key]); - } -} -if ($optioncss != '') { - $param .= '&optioncss='.urlencode($optioncss); -} -// Add $param from extra fields -include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; -// Add $param from hooks -$parameters = array(); -$reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object); // Note that $action and $object may have been modified by hook -$param .= $hookmanager->resPrint; - -// List of mass actions available -$arrayofmassactions = array( - //'validate'=>img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("Validate"), - //'generate_doc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("ReGeneratePDF"), - //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"), - //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"), -); -if (!empty($permissiontodelete)) { - $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete"); -} -if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) { - $arrayofmassactions = array(); -} -$massactionbutton = $form->selectMassAction('', $arrayofmassactions); - -print '
'."\n"; -if ($optioncss != '') { - print ''; -} -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; - - -$newcardbutton = ''; -$newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition')); -$newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition')); -$newcardbutton .= dolGetButtonTitleSeparator(); -$newcardbutton .= dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', dol_buildpath('/bookcal/booking_card.php', 1).'?action=create&backtopage='.urlencode($_SERVER['PHP_SELF']), '', $permissiontoadd); - -print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'object_'.$object->picto, 0, $newcardbutton, '', $limit, 0, 0, 1); - -// Add code for pre mass action (confirmation or email presend form) -$topicmail = "SendBookingRef"; -$modelmail = "booking"; -$objecttmp = new Booking($db); -$trackid = 'xxxx'.$object->id; -include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; - -if ($search_all) { - $setupstring = ''; - foreach ($fieldstosearchall as $key => $val) { - $fieldstosearchall[$key] = $langs->trans($val); - $setupstring .= $key."=".$val.";"; - } - print ''."\n"; - print '
'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'
'."\n"; -} - -$moreforfilter = ''; -/*$moreforfilter.='
'; -$moreforfilter.= $langs->trans('MyFilter') . ': '; -$moreforfilter.= '
';*/ - -$parameters = array(); -$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook -if (empty($reshook)) { - $moreforfilter .= $hookmanager->resPrint; -} else { - $moreforfilter = $hookmanager->resPrint; -} - -if (!empty($moreforfilter)) { - print '
'; - print $moreforfilter; - print '
'; -} - -$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; -$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN', '')); // This also change content of $arrayfields -$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); - -print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table -print ''."\n"; - - -// Fields title search -// -------------------------------------------------------------------- -print ''; -// Action column -if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { - print ''; -} -foreach ($object->fields as $key => $val) { - $searchkey = empty($search[$key]) ? '' : $search[$key]; - $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']); - if ($key == 'status') { - $cssforfield .= ($cssforfield ? ' ' : '').'center'; - } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) { - $cssforfield .= ($cssforfield ? ' ' : '').'center'; - } elseif (in_array($val['type'], array('timestamp'))) { - $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; - } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('id', 'rowid', 'ref', 'status')) && $val['label'] != 'TechnicalID' && empty($val['arrayofkeyval'])) { - $cssforfield .= ($cssforfield ? ' ' : '').'right'; - } - if (!empty($arrayfields['t.'.$key]['checked'])) { - print ''; - } -} -// Extra fields -include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; - -// Fields from hook -$parameters = array('arrayfields'=>$arrayfields); -$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook -print $hookmanager->resPrint; -/*if (!empty($arrayfields['anotherfield']['checked'])) { - print ''; -}*/ -// Action column -if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { - print ''; -} -print ''."\n"; - -$totalarray = array(); -$totalarray['nbfield'] = 0; - -// Fields title label -// -------------------------------------------------------------------- -print ''; -if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { - print getTitleFieldOfList(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; -} -foreach ($object->fields as $key => $val) { - $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']); - if ($key == 'status') { - $cssforfield .= ($cssforfield ? ' ' : '').'center'; - } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) { - $cssforfield .= ($cssforfield ? ' ' : '').'center'; - } elseif (in_array($val['type'], array('timestamp'))) { - $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; - } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('id', 'rowid', 'ref', 'status')) && $val['label'] != 'TechnicalID' && empty($val['arrayofkeyval'])) { - $cssforfield .= ($cssforfield ? ' ' : '').'right'; - } - $cssforfield = preg_replace('/small\s*/', '', $cssforfield); // the 'small' css must not be used for the title label - if (!empty($arrayfields['t.'.$key]['checked'])) { - print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''))."\n"; - $totalarray['nbfield']++; - } -} -// Extra fields -include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; -// Hook fields -$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder, 'totalarray'=>&$totalarray); -$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook -print $hookmanager->resPrint; -/*if (!empty($arrayfields['anotherfield']['checked'])) { - print ''; - $totalarray['nbfield']++; -}*/ -// Action column -if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { - print getTitleFieldOfList(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; -} -$totalarray['nbfield']++; -print ''."\n"; - - -// Detect if we need a fetch on each output line -$needToFetchEachLine = 0; -if (isset($extrafields->attributes[$object->table_element]['computed']) && is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) { - foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) { - if (!is_null($val) && preg_match('/\$object/', $val)) { - $needToFetchEachLine++; // There is at least one compute field that use $object - } - } -} - - -// Loop on record -// -------------------------------------------------------------------- -$i = 0; -$savnbfield = $totalarray['nbfield']; -$totalarray = array(); -$totalarray['nbfield'] = 0; -$imaxinloop = ($limit ? min($num, $limit) : $num); -while ($i < $imaxinloop) { - $obj = $db->fetch_object($resql); - if (empty($obj)) { - break; // Should not happen - } - - // Store properties in $object - $object->setVarsFromFetchObj($obj); - - if ($mode == 'kanban') { - if ($i == 0) { - print ''; - } - } else { - // Show here line of result - $j = 0; - print ''; - // Action column - if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { - print ''; - } - foreach ($object->fields as $key => $val) { - $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']); - if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) { - $cssforfield .= ($cssforfield ? ' ' : '').'center'; - } elseif ($key == 'status') { - $cssforfield .= ($cssforfield ? ' ' : '').'center'; - } - - if (in_array($val['type'], array('timestamp'))) { - $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; - } elseif ($key == 'ref') { - $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; - } - - if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('rowid', 'status')) && empty($val['arrayofkeyval'])) { - $cssforfield .= ($cssforfield ? ' ' : '').'right'; - } - //if (in_array($key, array('fk_soc', 'fk_user', 'fk_warehouse'))) $cssforfield = 'tdoverflowmax100'; - - if (!empty($arrayfields['t.'.$key]['checked'])) { - print '$key)) { - print ' title="'.dol_escape_htmltag($object->$key).'"'; - } - print '>'; - if ($key == 'status') { - print $object->getLibStatut(5); - } elseif ($key == 'rowid') { - print $object->showOutputField($val, $key, $object->id, ''); - } else { - print $object->showOutputField($val, $key, $object->$key, ''); - } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - if (!empty($val['isameasure']) && $val['isameasure'] == 1) { - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key; - } - if (!isset($totalarray['val'])) { - $totalarray['val'] = array(); - } - if (!isset($totalarray['val']['t.'.$key])) { - $totalarray['val']['t.'.$key] = 0; - } - $totalarray['val']['t.'.$key] += $object->$key; - } - } - } - // Extra fields - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; - // Fields from hook - $parameters = array('arrayfields'=>$arrayfields, 'object'=>$object, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); - $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - /*if (!empty($arrayfields['anotherfield']['checked'])) { - print ''; - }*/ - // Action column - if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { - print ''; - } - if (!$i) { - $totalarray['nbfield']++; - } - - print ''."\n"; - } - - $i++; -} - -// Show total line -include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; - -// If no record found -if ($num == 0) { - $colspan = 1; - foreach ($arrayfields as $key => $val) { - if (!empty($val['checked'])) { - $colspan++; - } - } - print ''; -} - - -$db->free($resql); - -$parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql); -$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook -print $hookmanager->resPrint; - -print '
'; - $searchpicto = $form->showFilterButtons('left'); - print $searchpicto; - print ''; - if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) { - print $form->selectarray('search_'.$key, $val['arrayofkeyval'], (isset($search[$key]) ? $search[$key] : ''), $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1); - } elseif ((strpos($val['type'], 'integer:') === 0) || (strpos($val['type'], 'sellist:') === 0)) { - print $object->showInputField($val, $key, (isset($search[$key]) ? $search[$key] : ''), '', '', 'search_', $cssforfield.' maxwidth250', 1); - } 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 '
'; - } elseif ($key == 'lang') { - require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php'; - $formadmin = new FormAdmin($db); - print $formadmin->select_language($search[$key], 'search_lang', 0, null, 1, 0, 0, 'minwidth150 maxwidth200', 2); - } else { - print ''; - } - print '
'; - $searchpicto = $form->showFilterButtons(); - print $searchpicto; - print '
'.$langs->trans("AnotherField").'
'; - print '
'; - } - // Output Kanban - print $object->getKanbanView('', array('selected' => in_array($object->id, $arrayofselected))); - if ($i == ($imaxinloop - 1)) { - print '
'; - print '
'; - if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - $selected = 0; - if (in_array($object->id, $arrayofselected)) { - $selected = 1; - } - print ''; - } - print ''.$obj->anotherfield.''; - if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - $selected = 0; - if (in_array($object->id, $arrayofselected)) { - $selected = 1; - } - print ''; - } - print '
'.$langs->trans("NoRecordFound").'
'."\n"; -print '
'."\n"; - -print '
'."\n"; - -if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { - $hidegeneratedfilelistifempty = 1; - if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { - $hidegeneratedfilelistifempty = 0; - } - - require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; - $formfile = new FormFile($db); - - // Show list of available documents - $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; - $urlsource .= str_replace('&', '&', $param); - - $filedir = $diroutputmassaction; - $genallowed = $permissiontoread; - $delallowed = $permissiontoadd; - - print $formfile->showdocuments('massfilesarea_bookcal', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty); -} - -// End of page -llxFooter(); -$db->close(); diff --git a/htdocs/bookcal/booking_note.php b/htdocs/bookcal/booking_note.php deleted file mode 100644 index b72c0fbe6d1..00000000000 --- a/htdocs/bookcal/booking_note.php +++ /dev/null @@ -1,171 +0,0 @@ - - * Copyright (C) 2022 Alice Adminson - * - * 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/bookcal/booking_note.php - * \ingroup bookcal - * \brief Tab for notes on Booking - */ - -// Load Dolibarr environment -require '../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/bookcal/class/booking.class.php'; -require_once DOL_DOCUMENT_ROOT.'/bookcal/lib/bookcal_booking.lib.php'; - -// Load translation files required by the page -$langs->loadLangs(array("agenda", "companies")); - -// Get parameters -$id = GETPOST('id', 'int'); -$ref = GETPOST('ref', 'alpha'); -$action = GETPOST('action', 'aZ09'); -$cancel = GETPOST('cancel', 'aZ09'); -$backtopage = GETPOST('backtopage', 'alpha'); - -// Initialize technical objects -$object = new Booking($db); -$extrafields = new ExtraFields($db); -$diroutputmassaction = $conf->bookcal->dir_output.'/temp/massgeneration/'.$user->id; -$hookmanager->initHooks(array('bookingnote', 'globalcard')); // Note that conf->hooks_modules contains array -// Fetch optionals attributes and labels -$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 // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals -if ($id > 0 || !empty($ref)) { - $upload_dir = $conf->bookcal->multidir_output[!empty($object->entity) ? $object->entity : $conf->entity]."/".$object->id; -} - - -// There is several ways to check permission. -// Set $enablepermissioncheck to 1 to enable a minimum low level of checks -$enablepermissioncheck = 0; -if ($enablepermissioncheck) { - $permissiontoread = $user->rights->bookcal->booking->read; - $permissiontoadd = $user->rights->bookcal->booking->write; - $permissionnote = $user->rights->bookcal->booking->write; // Used by the include of actions_setnotes.inc.php -} else { - $permissiontoread = 1; - $permissiontoadd = 1; - $permissionnote = 1; -} - -// Security check (enable the most restrictive one) -//if ($user->socid > 0) accessforbidden(); -//if ($user->socid > 0) $socid = $user->socid; -//$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0); -//restrictedArea($user, $object->element, $object->id, $object->table_element, '', 'fk_soc', 'rowid', $isdraft); -if (!isModEnabled('bookcal')) accessforbidden(); -if (!$permissiontoread) accessforbidden(); - - -/* - * Actions - */ - -$parameters = array(); -$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks -if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); -} -if (empty($reshook)) { - include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once -} - - -/* - * View - */ - -$form = new Form($db); - -//$help_url='EN:Customers_Orders|FR:Commandes_Clients|ES:Pedidos de clientes'; -$help_url = ''; -$title = $langs->trans('Booking').' - '.$langs->trans("Notes"); -llxHeader('', $title, $help_url); - -if ($id > 0 || !empty($ref)) { - $object->fetch_thirdparty(); - - $head = bookingPrepareHead($object); - - print dol_get_fiche_head($head, 'note', $langs->trans("Booking"), -1, $object->picto); - - // Object card - // ------------------------------------------------------------ - $linkback = ''.$langs->trans("BackToList").''; - - $morehtmlref = '
'; - /* - // Ref customer - $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1); - $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1); - // Thirdparty - $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . (is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : ''); - // Project - if (isModEnabled('project')) - { - $langs->load("projects"); - $morehtmlref.='
'.$langs->trans('Project') . ' '; - if ($permissiontoadd) - { - if ($action != 'classify') - //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; - $morehtmlref.=' : '; - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.='
'; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.='
'; - } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); - } - } else { - if (! empty($object->fk_project)) { - $proj = new Project($db); - $proj->fetch($object->fk_project); - $morehtmlref .= ': '.$proj->getNomUrl(); - } else { - $morehtmlref .= ''; - } - } - }*/ - $morehtmlref .= '
'; - - - dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); - - - print '
'; - print '
'; - - - $cssclass = "titlefield"; - include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php'; - - print '
'; - - print dol_get_fiche_end(); -} - -// End of page -llxFooter(); -$db->close(); diff --git a/htdocs/bookcal/class/availabilities.class.php b/htdocs/bookcal/class/availabilities.class.php index 8fdbfec04b5..40e07b821c5 100644 --- a/htdocs/bookcal/class/availabilities.class.php +++ b/htdocs/bookcal/class/availabilities.class.php @@ -103,7 +103,6 @@ class Availabilities extends CommonObject */ public $fields=array( 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>'1', 'position'=>1, 'notnull'=>1, 'visible'=>0, 'noteditable'=>'1', 'index'=>1, 'css'=>'left', 'comment'=>"Id"), - 'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>'1', 'position'=>20, 'notnull'=>1, 'visible'=>1, 'index'=>1, 'searchall'=>1, 'showoncombobox'=>'1', 'validate'=>'1', 'comment'=>"Reference of object"), 'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>'1', 'position'=>30, 'notnull'=>0, 'visible'=>1, 'searchall'=>1, 'css'=>'minwidth300', 'cssview'=>'wordbreak', 'help'=>"Help text", 'showoncombobox'=>'2', 'validate'=>'1',), 'description' => array('type'=>'text', 'label'=>'Description', 'enabled'=>'1', 'position'=>60, 'notnull'=>0, 'visible'=>3, 'validate'=>'1',), 'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>'1', 'position'=>61, 'notnull'=>0, 'visible'=>0, 'cssview'=>'wordbreak', 'validate'=>'1',), @@ -118,14 +117,12 @@ class Availabilities extends CommonObject 'status' => array('type'=>'integer', 'label'=>'Status', 'enabled'=>'1', 'position'=>2000, 'notnull'=>1, 'visible'=>1, 'index'=>1, 'arrayofkeyval'=>array('0'=>'Draft', '1'=>'Validated', '9'=>'Canceled'), 'validate'=>'1',), 'start' => array('type'=>'date', 'label'=>'Start Date', 'enabled'=>'1', 'position'=>40, 'notnull'=>1, 'visible'=>1, 'searchall'=>1,), 'end' => array('type'=>'date', 'label'=>'End Date', 'enabled'=>'1', 'position'=>45, 'notnull'=>1, 'visible'=>1, 'searchall'=>1,), - 'type' => array('type'=>'integer', 'label'=>'Type', 'enabled'=>'1', 'position'=>49, 'notnull'=>1, 'visible'=>1, 'index'=>1, 'arrayofkeyval'=>array('0'=>'Customer', '1'=>'Supplier', '2'=>'Else'),), 'duration' => array('type'=>'integer', 'label'=>'Duration', 'enabled'=>'1', 'position'=>47, 'notnull'=>1, 'visible'=>1, 'default'=>'30',), 'startHour' => array('type'=>'integer', 'label'=>'Start Hour', 'enabled'=>'1', 'position'=>46, 'notnull'=>1, 'visible'=>-1,), 'endHour' => array('type'=>'integer', 'label'=>'End Hour', 'enabled'=>'1', 'position'=>46.5, 'notnull'=>1, 'visible'=>-1,), 'fk_bookcal_calendar' => array('type'=>'integer:Calendar:bookcal/class/calendar.class.php:1', 'label'=>'CalendarId', 'enabled'=>'1', 'position'=>48, 'notnull'=>1, 'visible'=>1,), ); public $rowid; - public $ref; public $label; public $description; public $note_public; @@ -140,7 +137,6 @@ class Availabilities extends CommonObject public $status; public $start; public $end; - public $type; public $duration; public $startHour; public $endHour; diff --git a/htdocs/bookcal/class/booking.class.php b/htdocs/bookcal/class/booking.class.php deleted file mode 100644 index b3633826271..00000000000 --- a/htdocs/bookcal/class/booking.class.php +++ /dev/null @@ -1,1091 +0,0 @@ - - * Copyright (C) 2022 Alice Adminson - * - * 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 class/booking.class.php - * \ingroup bookcal - * \brief This file is a CRUD class file for Booking (Create/Read/Update/Delete) - */ - -// Put here all includes required by your class file -require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; -//require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; -//require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; - -/** - * Class for Booking - */ -class Booking extends CommonObject -{ - /** - * @var string ID of module. - */ - public $module = 'bookcal'; - - /** - * @var string ID to identify managed object. - */ - public $element = 'booking'; - - /** - * @var string Name of table without prefix where object is stored. This is also the key used for extrafields management. - */ - public $table_element = 'bookcal_booking'; - - /** - * @var int Does this object support multicompany module ? - * 0=No test on entity, 1=Test with field entity, 'field@table'=Test with link by field@table - */ - public $ismultientitymanaged = 0; - - /** - * @var int Does object support extrafields ? 0=No, 1=Yes - */ - public $isextrafieldmanaged = 1; - - /** - * @var string String with name of icon for booking. Must be a 'fa-xxx' fontawesome code (or 'fa-xxx_fa_color_size') or 'booking@bookcal' if picto is file 'img/object_booking.png'. - */ - public $picto = 'fa-file'; - - - const STATUS_DRAFT = 0; - const STATUS_VALIDATED = 1; - const STATUS_CANCELED = 9; - - - /** - * 'type' field format ('integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter[:Sortfield]]]', 'sellist:TableName:LabelFieldName[:KeyFieldName[:KeyFieldParent[:Filter[:Sortfield]]]]', 'varchar(x)', 'double(24,8)', 'real', 'price', 'text', 'text:none', 'html', 'date', 'datetime', 'timestamp', 'duration', 'mail', 'phone', 'url', 'password') - * Note: Filter can be a string like "(t.ref:like:'SO-%') or (t.date_creation:<:'20160101') or (t.nature:is:NULL)" - * 'label' the translation key. - * 'picto' is code of a picto to show before value in forms - * 'enabled' is a condition when the field must be managed (Example: 1 or '$conf->global->MY_SETUP_PARAM' or 'isModEnabled('multicurrency')' ...) - * 'position' is the sort order of field. - * 'notnull' is set to 1 if not null in database. Set to -1 if we must set data to null if empty ('' or 0). - * 'visible' says if field is visible in list (Examples: 0=Not visible, 1=Visible on list and create/update/view forms, 2=Visible on list only, 3=Visible on create/update/view form only (not list), 4=Visible on list and update/view form only (not create). 5=Visible on list and view only (not create/not update). Using a negative value means field is not shown by default on list but can be selected for viewing) - * 'noteditable' says if field is not editable (1 or 0) - * 'default' is a default value for creation (can still be overwrote by the Setup of Default Values if field is editable in creation form). Note: If default is set to '(PROV)' and field is 'ref', the default value will be set to '(PROVid)' where id is rowid when a new record is created. - * 'index' if we want an index in database. - * 'foreignkey'=>'tablename.field' if the field is a foreign key (it is recommanded to name the field fk_...). - * 'searchall' is 1 if we want to search in this field when making a search from the quick search button. - * 'isameasure' must be set to 1 or 2 if field can be used for measure. Field type must be summable like integer or double(24,8). Use 1 in most cases, or 2 if you don't want to see the column total into list (for example for percentage) - * 'css' and 'cssview' and 'csslist' is the CSS style to use on field. 'css' is used in creation and update. 'cssview' is used in view mode. 'csslist' is used for columns in lists. For example: 'css'=>'minwidth300 maxwidth500 widthcentpercentminusx', 'cssview'=>'wordbreak', 'csslist'=>'tdoverflowmax200' - * 'help' is a 'TranslationString' to use to show a tooltip on field. You can also use 'TranslationString:keyfortooltiponlick' for a tooltip on click. - * 'showoncombobox' if value of the field must be visible into the label of the combobox that list record - * 'disabled' is 1 if we want to have the field locked by a 'disabled' attribute. In most cases, this is never set into the definition of $fields into class, but is set dynamically by some part of code. - * 'arrayofkeyval' to set a list of values if type is a list of predefined values. For example: array("0"=>"Draft","1"=>"Active","-1"=>"Cancel"). Note that type can be 'integer' or 'varchar' - * 'autofocusoncreate' to have field having the focus on a create form. Only 1 field should have this property set to 1. - * 'comment' is not used. You can store here any text of your choice. It is not used by application. - * 'validate' is 1 if need to validate with $this->validateField() - * 'copytoclipboard' is 1 or 2 to allow to add a picto to copy value into clipboard (1=picto after label, 2=picto after value) - * - * Note: To have value dynamic, you can set value to 0 in definition and edit the value on the fly into the constructor. - */ - - // BEGIN MODULEBUILDER PROPERTIES - /** - * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. - */ - public $fields=array( - 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>'1', 'position'=>1, 'notnull'=>1, 'visible'=>0, 'noteditable'=>'1', 'index'=>1, 'css'=>'left', 'comment'=>"Id"), - 'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>'1', 'position'=>1.2, 'notnull'=>1, 'visible'=>1, 'index'=>1, 'searchall'=>1, 'validate'=>'1', 'comment'=>"Reference of object"), - 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php:1:((status:=:1) and (entity:IN:__SHARED_ENTITIES__))', 'label'=>'ThirdParty', 'picto'=>'company', 'enabled'=>'isModEnabled("societe")', 'position'=>50, 'notnull'=>-1, 'visible'=>1, 'index'=>1, 'css'=>'maxwidth500 widthcentpercentminusxx', 'help'=>"LinkToThirparty", 'validate'=>'1',), - 'fk_project' => array('type'=>'integer:Project:projet/class/project.class.php:1', 'label'=>'Project', 'picto'=>'project', 'enabled'=>'$conf->project->enabled', 'position'=>52, 'notnull'=>-1, 'visible'=>-1, 'index'=>1, 'css'=>'maxwidth500 widthcentpercentminusxx', 'validate'=>'1',), - 'description' => array('type'=>'text', 'label'=>'Description', 'enabled'=>'1', 'position'=>60, 'notnull'=>0, 'visible'=>3, 'validate'=>'1',), - 'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>'1', 'position'=>61, 'notnull'=>0, 'visible'=>0, 'cssview'=>'wordbreak', 'validate'=>'1',), - 'note_private' => array('type'=>'html', 'label'=>'NotePrivate', 'enabled'=>'1', 'position'=>62, 'notnull'=>0, 'visible'=>0, 'cssview'=>'wordbreak', 'validate'=>'1',), - 'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>'1', 'position'=>500, 'notnull'=>1, 'visible'=>-2,), - 'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>'1', 'position'=>501, 'notnull'=>0, 'visible'=>-2,), - 'fk_user_creat' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserAuthor', 'enabled'=>'1', 'position'=>510, 'notnull'=>-1, 'visible'=>-2,), - 'fk_user_modif' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserModif', 'picto'=>'user', 'enabled'=>'1', 'position'=>511, 'notnull'=>-1, 'visible'=>-2,), - 'last_main_doc' => array('type'=>'varchar(255)', 'label'=>'LastMainDoc', 'enabled'=>'1', 'position'=>600, 'notnull'=>0, 'visible'=>0,), - 'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>'1', 'position'=>1000, 'notnull'=>-1, 'visible'=>-2,), - 'model_pdf' => array('type'=>'varchar(255)', 'label'=>'Model pdf', 'enabled'=>'1', 'position'=>1010, 'notnull'=>-1, 'visible'=>0,), - 'status' => array('type'=>'integer', 'label'=>'Status', 'enabled'=>'1', 'position'=>2000, 'notnull'=>1, 'visible'=>1, 'index'=>1, 'arrayofkeyval'=>array('0'=>'Draft', '1'=>'Validated', '9'=>'Canceled'), 'validate'=>'1',), - 'firstname' => array('type'=>'varchar(128)', 'label'=>'firstname', 'enabled'=>'1', 'position'=>2, 'notnull'=>1, 'visible'=>-1,), - 'lastname' => array('type'=>'varchar(128)', 'label'=>'lastname', 'enabled'=>'1', 'position'=>3, 'notnull'=>1, 'visible'=>-1,), - 'email' => array('type'=>'varchar(128)', 'label'=>'email', 'enabled'=>'1', 'position'=>4, 'notnull'=>1, 'visible'=>-1,), - 'start' => array('type'=>'datetime', 'label'=>'Start Hour', 'enabled'=>'1', 'position'=>5, 'notnull'=>1, 'visible'=>-1,), - 'duration' => array('type'=>'integer', 'label'=>'Duration', 'enabled'=>'1', 'position'=>6, 'notnull'=>1, 'visible'=>-1,), - 'fk_bookcal_availability' => array('type'=>'integer:Availabilities:bookcal/class/availabilities.class.php', 'label'=>'AvailabilityId', 'enabled'=>'1', 'position'=>49, 'notnull'=>1, 'visible'=>-1,), - ); - public $rowid; - public $ref; - public $fk_soc; - public $fk_project; - public $description; - public $note_public; - public $note_private; - public $date_creation; - public $tms; - public $fk_user_creat; - public $fk_user_modif; - public $last_main_doc; - public $import_key; - public $model_pdf; - public $status; - public $firstname; - public $lastname; - public $email; - public $start; - public $duration; - public $fk_bookcal_availability; - // END MODULEBUILDER PROPERTIES - - - // If this object has a subtable with lines - - // /** - // * @var string Name of subtable line - // */ - // public $table_element_line = 'bookcal_bookingline'; - - // /** - // * @var string Field with ID of parent key if this object has a parent - // */ - // public $fk_element = 'fk_booking'; - - // /** - // * @var string Name of subtable class that manage subtable lines - // */ - // public $class_element_line = 'Bookingline'; - - // /** - // * @var array List of child tables. To test if we can delete object. - // */ - // protected $childtables = array(); - - // /** - // * @var array List of child tables. To know object to delete on cascade. - // * If name matches '@ClassNAme:FilePathClass;ParentFkFieldName' it will - // * call method deleteByParentField(parentId, ParentFkFieldName) to fetch and delete child object - // */ - // protected $childtablesoncascade = array('bookcal_bookingdet'); - - // /** - // * @var BookingLine[] Array of subtable lines - // */ - // public $lines = array(); - - - - /** - * Constructor - * - * @param DoliDb $db Database handler - */ - public function __construct(DoliDB $db) - { - global $conf, $langs; - - $this->db = $db; - - if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid']) && !empty($this->fields['ref'])) { - $this->fields['rowid']['visible'] = 0; - } - if (empty($conf->multicompany->enabled) && isset($this->fields['entity'])) { - $this->fields['entity']['enabled'] = 0; - } - - // Example to show how to set values of fields definition dynamically - /*if ($user->rights->bookcal->booking->read) { - $this->fields['myfield']['visible'] = 1; - $this->fields['myfield']['noteditable'] = 0; - }*/ - - // Unset fields that are disabled - foreach ($this->fields as $key => $val) { - if (isset($val['enabled']) && empty($val['enabled'])) { - unset($this->fields[$key]); - } - } - - // Translate some data of arrayofkeyval - if (is_object($langs)) { - foreach ($this->fields as $key => $val) { - if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) { - foreach ($val['arrayofkeyval'] as $key2 => $val2) { - $this->fields[$key]['arrayofkeyval'][$key2] = $langs->trans($val2); - } - } - } - } - } - - /** - * Create object into database - * - * @param User $user User that creates - * @param bool $notrigger false=launch triggers after, true=disable triggers - * @return int <0 if KO, Id of created object if OK - */ - public function create(User $user, $notrigger = false) - { - $resultcreate = $this->createCommon($user, $notrigger); - - //$resultvalidate = $this->validate($user, $notrigger); - - return $resultcreate; - } - - /** - * Clone an object into another one - * - * @param User $user User that creates - * @param int $fromid Id of object to clone - * @return mixed New object created, <0 if KO - */ - public function createFromClone(User $user, $fromid) - { - global $langs, $extrafields; - $error = 0; - - dol_syslog(__METHOD__, LOG_DEBUG); - - $object = new self($this->db); - - $this->db->begin(); - - // Load source object - $result = $object->fetchCommon($fromid); - if ($result > 0 && !empty($object->table_element_line)) { - $object->fetchLines(); - } - - // get lines so they will be clone - //foreach($this->lines as $line) - // $line->fetch_optionals(); - - // Reset some properties - unset($object->id); - unset($object->fk_user_creat); - unset($object->import_key); - - // Clear fields - if (property_exists($object, 'ref')) { - $object->ref = empty($this->fields['ref']['default']) ? "Copy_Of_".$object->ref : $this->fields['ref']['default']; - } - if (property_exists($object, 'label')) { - $object->label = empty($this->fields['label']['default']) ? $langs->trans("CopyOf")." ".$object->label : $this->fields['label']['default']; - } - if (property_exists($object, 'status')) { - $object->status = self::STATUS_DRAFT; - } - if (property_exists($object, 'date_creation')) { - $object->date_creation = dol_now(); - } - if (property_exists($object, 'date_modification')) { - $object->date_modification = null; - } - // ... - // Clear extrafields that are unique - if (is_array($object->array_options) && count($object->array_options) > 0) { - $extrafields->fetch_name_optionals_label($this->table_element); - foreach ($object->array_options as $key => $option) { - $shortkey = preg_replace('/options_/', '', $key); - if (!empty($extrafields->attributes[$this->table_element]['unique'][$shortkey])) { - //var_dump($key); - //var_dump($clonedObj->array_options[$key]); exit; - unset($object->array_options[$key]); - } - } - } - - // Create clone - $object->context['createfromclone'] = 'createfromclone'; - $result = $object->createCommon($user); - if ($result < 0) { - $error++; - $this->error = $object->error; - $this->errors = $object->errors; - } - - if (!$error) { - // copy internal contacts - if ($this->copy_linked_contact($object, 'internal') < 0) { - $error++; - } - } - - if (!$error) { - // copy external contacts if same company - if (!empty($object->socid) && property_exists($this, 'fk_soc') && $this->fk_soc == $object->socid) { - if ($this->copy_linked_contact($object, 'external') < 0) { - $error++; - } - } - } - - unset($object->context['createfromclone']); - - // End - if (!$error) { - $this->db->commit(); - return $object; - } else { - $this->db->rollback(); - return -1; - } - } - - /** - * Load object in memory from the database - * - * @param int $id Id object - * @param string $ref Ref - * @return int <0 if KO, 0 if not found, >0 if OK - */ - public function fetch($id, $ref = null) - { - $result = $this->fetchCommon($id, $ref); - if ($result > 0 && !empty($this->table_element_line)) { - $this->fetchLines(); - } - return $result; - } - - /** - * Load object lines in memory from the database - * - * @return int <0 if KO, 0 if not found, >0 if OK - */ - public function fetchLines() - { - $this->lines = array(); - - $result = $this->fetchLinesCommon(); - return $result; - } - - - /** - * Load list of objects in memory from the database. - * - * @param string $sortorder Sort Order - * @param string $sortfield Sort field - * @param int $limit limit - * @param int $offset Offset - * @param array $filter Filter array. Example array('field'=>'valueforlike', 'customurl'=>...) - * @param string $filtermode Filter mode (AND or OR) - * @return array|int int <0 if KO, array of pages if OK - */ - public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') - { - global $conf; - - dol_syslog(__METHOD__, LOG_DEBUG); - - $records = array(); - - $sql = "SELECT "; - $sql .= $this->getFieldList('t'); - $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element." as t"; - if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) { - $sql .= " WHERE t.entity IN (".getEntity($this->element).")"; - } else { - $sql .= " WHERE 1 = 1"; - } - // Manage filter - $sqlwhere = array(); - if (count($filter) > 0) { - foreach ($filter as $key => $value) { - if ($key == 't.rowid') { - $sqlwhere[] = $key." = ".((int) $value); - } elseif (in_array($this->fields[$key]['type'], array('date', 'datetime', 'timestamp'))) { - $sqlwhere[] = $key." = '".$this->db->idate($value)."'"; - } elseif ($key == 'customsql') { - $sqlwhere[] = $value; - } elseif (strpos($value, '%') === false) { - $sqlwhere[] = $key." IN (".$this->db->sanitize($this->db->escape($value)).")"; - } else { - $sqlwhere[] = $key." LIKE '%".$this->db->escape($value)."%'"; - } - } - } - if (count($sqlwhere) > 0) { - $sql .= " AND (".implode(" ".$filtermode." ", $sqlwhere).")"; - } - - if (!empty($sortfield)) { - $sql .= $this->db->order($sortfield, $sortorder); - } - if (!empty($limit)) { - $sql .= $this->db->plimit($limit, $offset); - } - - $resql = $this->db->query($sql); - if ($resql) { - $num = $this->db->num_rows($resql); - $i = 0; - while ($i < ($limit ? min($limit, $num) : $num)) { - $obj = $this->db->fetch_object($resql); - - $record = new self($this->db); - $record->setVarsFromFetchObj($obj); - - $records[$record->id] = $record; - - $i++; - } - $this->db->free($resql); - - return $records; - } else { - $this->errors[] = 'Error '.$this->db->lasterror(); - dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); - - return -1; - } - } - - /** - * Update object into database - * - * @param User $user User that modifies - * @param bool $notrigger false=launch triggers after, true=disable triggers - * @return int <0 if KO, >0 if OK - */ - public function update(User $user, $notrigger = false) - { - return $this->updateCommon($user, $notrigger); - } - - /** - * Delete object in database - * - * @param User $user User that deletes - * @param bool $notrigger false=launch triggers after, true=disable triggers - * @return int <0 if KO, >0 if OK - */ - public function delete(User $user, $notrigger = false) - { - return $this->deleteCommon($user, $notrigger); - //return $this->deleteCommon($user, $notrigger, 1); - } - - /** - * Delete a line of object in database - * - * @param User $user User that delete - * @param int $idline Id of line to delete - * @param bool $notrigger false=launch triggers after, true=disable triggers - * @return int >0 if OK, <0 if KO - */ - public function deleteLine(User $user, $idline, $notrigger = false) - { - if ($this->status < 0) { - $this->error = 'ErrorDeleteLineNotAllowedByObjectStatus'; - return -2; - } - - return $this->deleteLineCommon($user, $idline, $notrigger); - } - - - /** - * Validate object - * - * @param User $user User making status change - * @param int $notrigger 1=Does not execute triggers, 0= execute triggers - * @return int <=0 if OK, 0=Nothing done, >0 if KO - */ - public function validate($user, $notrigger = 0) - { - global $conf, $langs; - - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - - $error = 0; - - // Protection - if ($this->status == self::STATUS_VALIDATED) { - dol_syslog(get_class($this)."::validate action abandonned: already validated", LOG_WARNING); - return 0; - } - - /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->bookcal->booking->write)) - || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->bookcal->booking->booking_advance->validate)))) - { - $this->error='NotEnoughPermissions'; - dol_syslog(get_class($this)."::valid ".$this->error, LOG_ERR); - return -1; - }*/ - - $now = dol_now(); - - $this->db->begin(); - - // Define new ref - if (!$error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref))) { // empty should not happened, but when it occurs, the test save life - $num = $this->getNextNumRef(); - } else { - $num = $this->ref; - } - $this->newref = $num; - - if (!empty($num)) { - // Validate - $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element; - $sql .= " SET ref = '".$this->db->escape($num)."',"; - $sql .= " status = ".self::STATUS_VALIDATED; - if (!empty($this->fields['date_validation'])) { - $sql .= ", date_validation = '".$this->db->idate($now)."'"; - } - if (!empty($this->fields['fk_user_valid'])) { - $sql .= ", fk_user_valid = ".((int) $user->id); - } - $sql .= " WHERE rowid = ".((int) $this->id); - - dol_syslog(get_class($this)."::validate()", LOG_DEBUG); - $resql = $this->db->query($sql); - if (!$resql) { - dol_print_error($this->db); - $this->error = $this->db->lasterror(); - $error++; - } - - if (!$error && !$notrigger) { - // Call trigger - $result = $this->call_trigger('BOOKING_VALIDATE', $user); - if ($result < 0) { - $error++; - } - // End call triggers - } - } - - if (!$error) { - $this->oldref = $this->ref; - - // Rename directory if dir was a temporary ref - if (preg_match('/^[\(]?PROV/i', $this->ref)) { - // Now we rename also files into index - $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->db->escape($this->newref)."', SUBSTR(filename, ".(strlen($this->ref) + 1).")), filepath = 'booking/".$this->db->escape($this->newref)."'"; - $sql .= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'booking/".$this->db->escape($this->ref)."' and entity = ".$conf->entity; - $resql = $this->db->query($sql); - if (!$resql) { - $error++; $this->error = $this->db->lasterror(); - } - - // We rename directory ($this->ref = old ref, $num = new ref) in order not to lose the attachments - $oldref = dol_sanitizeFileName($this->ref); - $newref = dol_sanitizeFileName($num); - $dirsource = $conf->bookcal->dir_output.'/booking/'.$oldref; - $dirdest = $conf->bookcal->dir_output.'/booking/'.$newref; - if (!$error && file_exists($dirsource)) { - dol_syslog(get_class($this)."::validate() rename dir ".$dirsource." into ".$dirdest); - - if (@rename($dirsource, $dirdest)) { - dol_syslog("Rename ok"); - // Rename docs starting with $oldref with $newref - $listoffiles = dol_dir_list($conf->bookcal->dir_output.'/booking/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/')); - foreach ($listoffiles as $fileentry) { - $dirsource = $fileentry['name']; - $dirdest = preg_replace('/^'.preg_quote($oldref, '/').'/', $newref, $dirsource); - $dirsource = $fileentry['path'].'/'.$dirsource; - $dirdest = $fileentry['path'].'/'.$dirdest; - @rename($dirsource, $dirdest); - } - } - } - } - } - - // Set new ref and current status - if (!$error) { - $this->ref = $num; - $this->status = self::STATUS_VALIDATED; - } - - if (!$error) { - $this->db->commit(); - return 1; - } else { - $this->db->rollback(); - return -1; - } - } - - - /** - * Set draft status - * - * @param User $user Object user that modify - * @param int $notrigger 1=Does not execute triggers, 0=Execute triggers - * @return int <0 if KO, >0 if OK - */ - public function setDraft($user, $notrigger = 0) - { - // Protection - if ($this->status <= self::STATUS_DRAFT) { - return 0; - } - - /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->bookcal->write)) - || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->bookcal->bookcal_advance->validate)))) - { - $this->error='Permission denied'; - return -1; - }*/ - - return $this->setStatusCommon($user, self::STATUS_DRAFT, $notrigger, 'BOOKING_UNVALIDATE'); - } - - /** - * Set cancel status - * - * @param User $user Object user that modify - * @param int $notrigger 1=Does not execute triggers, 0=Execute triggers - * @return int <0 if KO, 0=Nothing done, >0 if OK - */ - public function cancel($user, $notrigger = 0) - { - // Protection - if ($this->status != self::STATUS_VALIDATED) { - return 0; - } - - /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->bookcal->write)) - || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->bookcal->bookcal_advance->validate)))) - { - $this->error='Permission denied'; - return -1; - }*/ - - return $this->setStatusCommon($user, self::STATUS_CANCELED, $notrigger, 'BOOKING_CANCEL'); - } - - /** - * Set back to validated status - * - * @param User $user Object user that modify - * @param int $notrigger 1=Does not execute triggers, 0=Execute triggers - * @return int <0 if KO, 0=Nothing done, >0 if OK - */ - public function reopen($user, $notrigger = 0) - { - // Protection - if ($this->status != self::STATUS_CANCELED) { - return 0; - } - - /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->bookcal->write)) - || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->bookcal->bookcal_advance->validate)))) - { - $this->error='Permission denied'; - return -1; - }*/ - - return $this->setStatusCommon($user, self::STATUS_VALIDATED, $notrigger, 'BOOKING_REOPEN'); - } - - /** - * Return a link to the object card (with optionaly the picto) - * - * @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto) - * @param string $option On what the link point to ('nolink', ...) - * @param int $notooltip 1=Disable tooltip - * @param string $morecss Add more css on link - * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking - * @return string String with URL - */ - public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) - { - global $conf, $langs, $hookmanager; - - if (!empty($conf->dol_no_mouse_hover)) { - $notooltip = 1; // Force disable tooltips - } - - $result = ''; - - $label = img_picto('', $this->picto).' '.$langs->trans("Booking").''; - if (isset($this->status)) { - $label .= ' '.$this->getLibStatut(5); - } - $label .= '
'; - $label .= ''.$langs->trans('Ref').': '.$this->ref; - - $url = dol_buildpath('/bookcal/booking_card.php', 1).'?id='.$this->id; - - 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 ($url && $add_save_lastsearch_values) { - $url .= '&save_lastsearch_values=1'; - } - } - - $linkclose = ''; - if (empty($notooltip)) { - if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { - $label = $langs->trans("ShowBooking"); - $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; - } - $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; - } else { - $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); - } - - if ($option == 'nolink' || empty($url)) { - $linkstart = ''; - if ($option == 'nolink' || empty($url)) { - $linkend = ''; - } else { - $linkend = ''; - } - - $result .= $linkstart; - - if (empty($this->showphoto_on_popup)) { - 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); - } - } else { - if ($withpicto) { - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - - list($class, $module) = explode('@', $this->picto); - $upload_dir = $conf->$module->multidir_output[$conf->entity]."/$class/".dol_sanitizeFileName($this->ref); - $filearray = dol_dir_list($upload_dir, "files"); - $filename = $filearray[0]['name']; - if (!empty($filename)) { - $pospoint = strpos($filearray[0]['name'], '.'); - - $pathtophoto = $class.'/'.$this->ref.'/thumbs/'.substr($filename, 0, $pospoint).'_mini'.substr($filename, $pospoint); - if (!getDolGlobalString(strtoupper($module.'_'.$class).'_FORMATLISTPHOTOSASUSERS')) { - $result .= '
No photo
'; - } else { - $result .= '
No photo
'; - } - - $result .= '
'; - } else { - $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; - //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : ''); - - global $action, $hookmanager; - $hookmanager->initHooks(array('bookingdao')); - $parameters = array('id'=>$this->id, 'getnomurl' => &$result); - $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - if ($reshook > 0) { - $result = $hookmanager->resPrint; - } else { - $result .= $hookmanager->resPrint; - } - - return $result; - } - - /** - * Return the label of the status - * - * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto - * @return string Label of status - */ - public function getLabelStatus($mode = 0) - { - return $this->LibStatut($this->status, $mode); - } - - /** - * Return the label of the status - * - * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto - * @return string Label of status - */ - public function getLibStatut($mode = 0) - { - return $this->LibStatut($this->status, $mode); - } - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Return the status - * - * @param int $status Id status - * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto - * @return string Label of status - */ - public function LibStatut($status, $mode = 0) - { - // phpcs:enable - if (empty($this->labelStatus) || empty($this->labelStatusShort)) { - global $langs; - //$langs->load("agenda"); - $this->labelStatus[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv('Draft'); - $this->labelStatus[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('Enabled'); - $this->labelStatus[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv('Disabled'); - $this->labelStatusShort[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv('Draft'); - $this->labelStatusShort[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('Enabled'); - $this->labelStatusShort[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv('Disabled'); - } - - $statusType = 'status'.$status; - //if ($status == self::STATUS_VALIDATED) $statusType = 'status1'; - if ($status == self::STATUS_CANCELED) { - $statusType = 'status6'; - } - - return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode); - } - - /** - * Load the info information in the object - * - * @param int $id Id of object - * @return void - */ - public function info($id) - { - $sql = "SELECT rowid,"; - $sql .= " date_creation as datec, tms as datem,"; - $sql .= " fk_user_creat, fk_user_modif"; - $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element." as t"; - $sql .= " WHERE t.rowid = ".((int) $id); - - $result = $this->db->query($sql); - if ($result) { - if ($this->db->num_rows($result)) { - $obj = $this->db->fetch_object($result); - - $this->id = $obj->rowid; - - $this->user_creation_id = $obj->fk_user_creat; - $this->user_modification_id = $obj->fk_user_modif; - if (!empty($obj->fk_user_valid)) { - $this->user_validation_id = $obj->fk_user_valid; - } - $this->date_creation = $this->db->jdate($obj->datec); - $this->date_modification = empty($obj->datem) ? '' : $this->db->jdate($obj->datem); - if (!empty($obj->datev)) { - $this->date_validation = empty($obj->datev) ? '' : $this->db->jdate($obj->datev); - } - } - - $this->db->free($result); - } else { - dol_print_error($this->db); - } - } - - /** - * Initialise object with example values - * Id must be 0 if object instance is a specimen - * - * @return void - */ - public function initAsSpecimen() - { - // Set here init that are not commonf fields - // $this->property1 = ... - // $this->property2 = ... - - $this->initAsSpecimenCommon(); - } - - /** - * Create an array of lines - * - * @return array|int array of lines if OK, <0 if KO - */ - public function getLinesArray() - { - $this->lines = array(); - - $objectline = new BookingLine($this->db); - $result = $objectline->fetchAll('ASC', 'position', 0, 0, array('customsql'=>'fk_booking = '.((int) $this->id))); - - if (is_numeric($result)) { - $this->error = $objectline->error; - $this->errors = $objectline->errors; - return $result; - } else { - $this->lines = $result; - return $this->lines; - } - } - - /** - * Returns the reference to the following non used object depending on the active numbering module. - * - * @return string Object free reference - */ - public function getNextNumRef() - { - global $langs, $conf; - $langs->load("agenda"); - - if (empty($conf->global->BOOKCAL_BOOKING_ADDON)) { - $conf->global->BOOKCAL_BOOKING_ADDON = 'mod_booking_standard'; - } - - if (!empty($conf->global->BOOKCAL_BOOKING_ADDON)) { - $mybool = false; - - $file = $conf->global->BOOKCAL_BOOKING_ADDON.".php"; - $classname = $conf->global->BOOKCAL_BOOKING_ADDON; - - // Include file with class - $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); - foreach ($dirmodels as $reldir) { - $dir = dol_buildpath($reldir."core/modules/bookcal/"); - - // Load file with numbering class (if found) - $mybool |= @include_once $dir.$file; - } - - if ($mybool === false) { - dol_print_error('', "Failed to include file ".$file); - return ''; - } - - if (class_exists($classname)) { - $obj = new $classname(); - $numref = $obj->getNextValue($this); - - if ($numref != '' && $numref != '-1') { - return $numref; - } else { - $this->error = $obj->error; - //dol_print_error($this->db,get_class($this)."::getNextNumRef ".$obj->error); - return ""; - } - } else { - print $langs->trans("Error")." ".$langs->trans("ClassNotFound").' '.$classname; - return ""; - } - } else { - print $langs->trans("ErrorNumberingModuleNotSetup", $this->element); - return ""; - } - } - - /** - * Create a document onto disk according to template module. - * - * @param string $modele Force template to use ('' to not force) - * @param Translate $outputlangs objet lang a utiliser pour traduction - * @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 - * @return int 0 if KO, 1 if OK - */ - public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null) - { - global $conf, $langs; - - $result = 0; - $includedocgeneration = 0; - - $langs->load("agenda"); - - if (!dol_strlen($modele)) { - $modele = 'standard_booking'; - - if (!empty($this->model_pdf)) { - $modele = $this->model_pdf; - } elseif (!empty($conf->global->BOOKING_ADDON_PDF)) { - $modele = $conf->global->BOOKING_ADDON_PDF; - } - } - - $modelpath = "core/modules/bookcal/doc/"; - - if ($includedocgeneration && !empty($modele)) { - $result = $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams); - } - - return $result; - } - - /** - * Action executed by scheduler - * CAN BE A CRON TASK. In such a case, parameters come from the schedule job setup field 'Parameters' - * Use public function doScheduledJob($param1, $param2, ...) to get parameters - * - * @return int 0 if OK, <>0 if KO (this function is used also by cron so only 0 is OK) - */ - public function doScheduledJob() - { - global $conf, $langs; - - //$conf->global->SYSLOG_FILE = 'DOL_DATA_ROOT/dolibarr_mydedicatedlofile.log'; - - $error = 0; - $this->output = ''; - $this->error = ''; - - dol_syslog(__METHOD__, LOG_DEBUG); - - $now = dol_now(); - - $this->db->begin(); - - // ... - - $this->db->commit(); - - return $error; - } -} - - -require_once DOL_DOCUMENT_ROOT.'/core/class/commonobjectline.class.php'; - -/** - * Class BookingLine. You can also remove this and generate a CRUD class for lines objects. - */ -class BookingLine extends CommonObjectLine -{ - // To complete with content of an object BookingLine - // We should have a field rowid, fk_booking and position - - /** - * @var int Does object support extrafields ? 0=No, 1=Yes - */ - public $isextrafieldmanaged = 0; - - /** - * Constructor - * - * @param DoliDb $db Database handler - */ - public function __construct(DoliDB $db) - { - $this->db = $db; - } -} diff --git a/htdocs/bookcal/class/calendar.class.php b/htdocs/bookcal/class/calendar.class.php index 60ea456541a..a8669bebae4 100644 --- a/htdocs/bookcal/class/calendar.class.php +++ b/htdocs/bookcal/class/calendar.class.php @@ -128,6 +128,8 @@ class Calendar extends CommonObject 'fk_user_modif' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserModif', 'picto'=>'user', 'enabled'=>'1', 'position'=>511, 'notnull'=>-1, 'visible'=>-2, 'csslist'=>'tdoverflowmax150',), 'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>'1', 'position'=>1000, 'notnull'=>-1, 'visible'=>-2,), 'status' => array('type'=>'integer', 'label'=>'Status', 'enabled'=>'1', 'position'=>2000, 'notnull'=>1, 'visible'=>1, 'index'=>1, 'arrayofkeyval'=>array('0'=>'Brouillon', '1'=>'Validé', '9'=>'Annulé'), 'validate'=>'1',), + 'type' => array('type'=>'integer', 'label'=>'Type', 'enabled'=>'1', 'position'=>40, 'notnull'=>1, 'visible'=>1, 'arrayofkeyval'=>array('0'=>'Client', '1'=>'Supplier', '3'=>'Autre'),), + 'visibility' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'Visibility', 'enabled'=>'1', 'position'=>41, 'notnull'=>1, 'visible'=>1,), ); public $rowid; public $ref; @@ -143,6 +145,8 @@ class Calendar extends CommonObject public $fk_user_modif; public $import_key; public $status; + public $type; + public $visibility; // END MODULEBUILDER PROPERTIES diff --git a/htdocs/bookcal/lib/bookcal_booking.lib.php b/htdocs/bookcal/lib/bookcal_booking.lib.php deleted file mode 100644 index c0dec7d6d2e..00000000000 --- a/htdocs/bookcal/lib/bookcal_booking.lib.php +++ /dev/null @@ -1,110 +0,0 @@ - - * - * 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 lib/bookcal_booking.lib.php - * \ingroup bookcal - * \brief Library files with common functions for Booking - */ - -/** - * Prepare array of tabs for Booking - * - * @param Booking $object Booking - * @return array Array of tabs - */ -function bookingPrepareHead($object) -{ - global $db, $langs, $conf; - - $langs->load("agenda"); - - $showtabofpagecontact = 1; - $showtabofpagenote = 1; - $showtabofpagedocument = 1; - $showtabofpageagenda = 1; - - $h = 0; - $head = array(); - - $head[$h][0] = dol_buildpath("/bookcal/booking_card.php", 1).'?id='.$object->id; - $head[$h][1] = $langs->trans("Card"); - $head[$h][2] = 'card'; - $h++; - - if ($showtabofpagecontact) { - $head[$h][0] = dol_buildpath("/bookcal/booking_contact.php", 1).'?id='.$object->id; - $head[$h][1] = $langs->trans("Contacts"); - $head[$h][2] = 'contact'; - $h++; - } - - if ($showtabofpagenote) { - if (isset($object->fields['note_public']) || isset($object->fields['note_private'])) { - $nbNote = 0; - if (!empty($object->note_private)) { - $nbNote++; - } - if (!empty($object->note_public)) { - $nbNote++; - } - $head[$h][0] = dol_buildpath('/bookcal/booking_note.php', 1).'?id='.$object->id; - $head[$h][1] = $langs->trans('Notes'); - if ($nbNote > 0) { - $head[$h][1] .= (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) ? ''.$nbNote.'' : ''); - } - $head[$h][2] = 'note'; - $h++; - } - } - - if ($showtabofpagedocument) { - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; - $upload_dir = $conf->bookcal->dir_output."/booking/".dol_sanitizeFileName($object->ref); - $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); - $nbLinks = Link::count($db, $object->element, $object->id); - $head[$h][0] = dol_buildpath("/bookcal/booking_document.php", 1).'?id='.$object->id; - $head[$h][1] = $langs->trans('Documents'); - if (($nbFiles + $nbLinks) > 0) { - $head[$h][1] .= ''.($nbFiles + $nbLinks).''; - } - $head[$h][2] = 'document'; - $h++; - } - - if ($showtabofpageagenda) { - $head[$h][0] = dol_buildpath("/bookcal/booking_agenda.php", 1).'?id='.$object->id; - $head[$h][1] = $langs->trans("Events"); - $head[$h][2] = 'agenda'; - $h++; - } - - // Show more tabs from modules - // Entries must be declared in modules descriptor with line - //$this->tabs = array( - // 'entity:+tabname:Title:@bookcal:/bookcal/mypage.php?id=__ID__' - //); // to add new tab - //$this->tabs = array( - // 'entity:-tabname:Title:@bookcal:/bookcal/mypage.php?id=__ID__' - //); // to remove a tab - complete_head_from_modules($conf, $langs, $object, $head, $h, 'booking@bookcal'); - - complete_head_from_modules($conf, $langs, $object, $head, $h, 'booking@bookcal', 'remove'); - - return $head; -} diff --git a/htdocs/bookmarks/class/bookmark.class.php b/htdocs/bookmarks/class/bookmark.class.php index 389603fb161..afac3563dee 100644 --- a/htdocs/bookmarks/class/bookmark.class.php +++ b/htdocs/bookmarks/class/bookmark.class.php @@ -49,11 +49,6 @@ class Bookmark extends CommonObject */ public $picto = 'bookmark'; - /** - * @var DoliDB Database handler. - */ - public $db; - /** * Last error code on a local method * @var int Error number diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index a6c00785c31..a6b47b1b31f 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -1332,9 +1332,9 @@ if ($action == 'create') { } print '     -     '; if (GETPOST("afaire") == 1) { - print $form->selectDate($datef, 'p2', 1, 1, 1, "action", 1, 0, 0, 'fulldayend', '', '', '', 1, '', '', 'tzuserrel'); + print $form->selectDate($datef, 'p2', 1, 1, 1, "action", 1, 2, 0, 'fulldayend', '', '', '', 1, '', '', 'tzuserrel'); } else { - print $form->selectDate($datef, 'p2', 1, 1, 1, "action", 1, 0, 0, 'fulldayend', '', '', '', 1, '', '', 'tzuserrel'); + print $form->selectDate($datef, 'p2', 1, 1, 1, "action", 1, 2, 0, 'fulldayend', '', '', '', 1, '', '', 'tzuserrel'); } print ''; diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index a3f2e4c56db..2de8736b39f 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -1816,7 +1816,7 @@ class ActionComm extends CommonObject $result .= $linkstart; if ($withpicto) { - $result .= img_object(($notooltip ? '' : $langs->trans("ShowAction").': '.$label), ($overwritepicto ? $overwritepicto : 'action'), (($this->type_color && $overwritepicto) ? 'style="color: #'.$this->type_color.' !important;" ' : '').($notooltip ? 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'"' : $dataparams.' class="'.(($withpicto != 2) ? 'paddingright ' : '').$classfortooltip.'"'), 0, 0, $notooltip ? 0 : 1); + $result .= img_object(($notooltip ? '' : $langs->trans("ShowAction").': '.$label), ($overwritepicto ? $overwritepicto : 'action'), (($this->type_color && $overwritepicto) ? 'style="color: #'.$this->type_color.' !important;" ' : '').($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : ' class="'.(($withpicto != 2) ? 'paddingright ' : '').'"'), 0, 0, $notooltip ? 0 : 1); } $result .= dol_escape_htmltag($labelshort); $result .= $linkend; diff --git a/htdocs/comm/index.php b/htdocs/comm/index.php index 1ae1ae0a6fb..30fcf10f681 100644 --- a/htdocs/comm/index.php +++ b/htdocs/comm/index.php @@ -34,12 +34,14 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php'; require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; -require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; require_once DOL_DOCUMENT_ROOT.'/societe/class/client.class.php'; require_once DOL_DOCUMENT_ROOT.'/supplier_proposal/class/supplier_proposal.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/propal.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/order.lib.php'; +if (isModEnabled('contrat')) { + require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; +} if (isModEnabled('ficheinter')) { require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php'; } diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 670a620db6a..a5f27670338 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -2799,35 +2799,35 @@ if ($action == 'create') { print ''; print '' . $langs->trans('AmountHT') . ''; - print '' . price($object->total_ht, '', $langs, 0, -1, -1, $conf->currency) . ''; + print '' . price($object->total_ht, '', $langs, 1, -1, -1, $conf->currency) . ''; if (isModEnabled("multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) { - print '' . price($object->multicurrency_total_ht, '', $langs, 0, -1, -1, $object->multicurrency_code) . ''; + print '' . price($object->multicurrency_total_ht, '', $langs, 1, -1, -1, $object->multicurrency_code) . ''; } print ''; print ''; print '' . $langs->trans('AmountVAT') . ''; - print '' . price($object->total_tva, '', $langs, 0, -1, -1, $conf->currency) . ''; + print '' . price($object->total_tva, '', $langs, 1, -1, -1, $conf->currency) . ''; if (isModEnabled("multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) { - print '' . price($object->multicurrency_total_tva, '', $langs, 0, -1, -1, $object->multicurrency_code) . ''; + print '' . price($object->multicurrency_total_tva, '', $langs, 1, -1, -1, $object->multicurrency_code) . ''; } print ''; if ($mysoc->localtax1_assuj == "1" || $object->total_localtax1 != 0) { print ''; print '' . $langs->transcountry("AmountLT1", $mysoc->country_code) . ''; - print '' . price($object->total_localtax1, '', $langs, 0, -1, -1, $conf->currency) . ''; + print '' . price($object->total_localtax1, '', $langs, 1, -1, -1, $conf->currency) . ''; if (isModEnabled("multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) { - print '' . price($object->total_localtax1, '', $langs, 0, -1, -1, $object->multicurrency_code) . ''; + print '' . price($object->total_localtax1, '', $langs, 1, -1, -1, $object->multicurrency_code) . ''; } print ''; if ($mysoc->localtax2_assuj == "1" || $object->total_localtax2 != 0) { print ''; print '' . $langs->transcountry("AmountLT2", $mysoc->country_code) . ''; - print '' . price($object->total_localtax2, '', $langs, 0, -1, -1, $conf->currency) . ''; + print '' . price($object->total_localtax2, '', $langs, 1, -1, -1, $conf->currency) . ''; if (isModEnabled("multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) { - print '' . price($object->total_localtax2, '', $langs, 0, -1, -1, $object->multicurrency_code) . ''; + print '' . price($object->total_localtax2, '', $langs, 1, -1, -1, $object->multicurrency_code) . ''; } print ''; } @@ -2835,9 +2835,9 @@ if ($action == 'create') { print ''; print '' . $langs->trans('AmountTTC') . ''; - print '' . price($object->total_ttc, '', $langs, 0, -1, -1, $conf->currency) . ''; + print '' . price($object->total_ttc, '', $langs, 1, -1, -1, $conf->currency) . ''; if (isModEnabled("multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) { - print '' . price($object->multicurrency_total_ttc, '', $langs, 0, -1, -1, $object->multicurrency_code) . ''; + print '' . price($object->multicurrency_total_ttc, '', $langs, 1, -1, -1, $object->multicurrency_code) . ''; } print ''; diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index 97ea30f394d..93a2db80072 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -1185,7 +1185,7 @@ if ($resql) { $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); print '
'; - print ''."\n"; + print '
'."\n"; print ''; diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index df69e0265c5..250d6c49aa0 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -82,6 +82,11 @@ class Commande extends CommonOrder */ public $ismultientitymanaged = 1; + /** + * @var int Does object support extrafields ? 0=No, 1=Yes + */ + public $isextrafieldmanaged = 1; + /** * 0=Default, 1=View may be restricted to sales representative only if no permission to see all or to company of external user if external user * @var integer diff --git a/htdocs/compta/deplacement/class/deplacement.class.php b/htdocs/compta/deplacement/class/deplacement.class.php index badb8acc5f8..d5d2cc191e2 100644 --- a/htdocs/compta/deplacement/class/deplacement.class.php +++ b/htdocs/compta/deplacement/class/deplacement.class.php @@ -103,10 +103,6 @@ class Deplacement extends CommonObject public $statut; public $extraparams = array(); - public $statuts = array(); - public $statuts_short = array(); - public $statuts_logo = array(); - /** * Draft status @@ -131,10 +127,6 @@ class Deplacement extends CommonObject public function __construct(DoliDB $db) { $this->db = $db; - - $this->statuts_short = array(0 => 'Draft', 1 => 'Validated', 2 => 'Refunded'); - $this->statuts = array(0 => 'Draft', 1 => 'Validated', 2 => 'Refunded'); - $this->statuts_logo = array(0 => 'status0', 1=>'status4', 2 => 'status1', 4 => 'status6', 5 => 'status4', 6 => 'status6', 99 => 'status5'); } /** @@ -222,8 +214,6 @@ class Deplacement extends CommonObject */ public function update($user) { - global $langs; - // Clean parameters $this->km = price2num($this->km); @@ -366,12 +356,21 @@ class Deplacement extends CommonObject // phpcs:enable global $langs; - $labelStatus = $langs->transnoentitiesnoconv($this->statuts[$status]); - $labelStatusShort = $langs->transnoentitiesnoconv($this->statuts_short[$status]); + if (empty($this->labelStatus) || empty($this->labelStatusShort)) { + global $langs; + //$langs->load("mymodule@mymodule"); + $this->labelStatus[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv('Draft'); + $this->labelStatus[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('Validated'); + $this->labelStatus[self::STATUS_REFUNDED] = $langs->transnoentitiesnoconv('Refunded'); + $this->labelStatusShort[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv('Draft'); + $this->labelStatusShort[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('Validated'); + $this->labelStatusShort[self::STATUS_REFUNDED] = $langs->transnoentitiesnoconv('Refunded'); + } - $statusType = $this->statuts_logo[$status]; + $status_logo = array(0 => 'status0', 1=>'status4', 2 => 'status1', 4 => 'status6', 5 => 'status4', 6 => 'status6', 99 => 'status5'); + $statusType = $status_logo[$status]; - return dolGetStatus($labelStatus, $labelStatusShort, '', $statusType, $mode); + return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode); } /** diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index a7b625c1629..0b20b4ddae8 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -90,6 +90,11 @@ class Facture extends CommonInvoice */ public $ismultientitymanaged = 1; + /** + * @var int Does object support extrafields ? 0=No, 1=Yes + */ + public $isextrafieldmanaged = 1; + /** * 0=Default, 1=View may be restricted to sales representative only if no permission to see all or to company of external user if external user * @var integer diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index c4c7b081242..b1fe18462b1 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -180,8 +180,6 @@ $result = restrictedArea($user, 'facture', $id, '', '', 'fk_soc', $fieldid); $diroutputmassaction = $conf->facture->dir_output.'/temp/massgeneration/'.$user->id; -$object = new Facture($db); - $now = dol_now(); $error = 0; diff --git a/htdocs/compta/paiement/card.php b/htdocs/compta/paiement/card.php index 262205fd36b..d101becc1b5 100644 --- a/htdocs/compta/paiement/card.php +++ b/htdocs/compta/paiement/card.php @@ -592,8 +592,13 @@ if (!empty($conf->global->BILL_ADD_PAYMENT_VALIDATION)) { } } +$params = array(); +if (! empty($title_button)) { + $params['attr'] = array('title' => $title_button); +} + if ($user->socid == 0 && $action == '') { - print dolGetButtonAction($langs->trans("Delete"), '', 'delete', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken(), 'delete', $user->hasRight('facture', 'paiement') && !$disable_delete); + print dolGetButtonAction($langs->trans("Delete"), '', 'delete', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken(), 'delete', $user->hasRight('facture', 'paiement') && !$disable_delete, $params); } print ''; diff --git a/htdocs/compta/paiement/class/cpaiement.class.php b/htdocs/compta/paiement/class/cpaiement.class.php index 683e9fc3679..7c7a275e8b6 100644 --- a/htdocs/compta/paiement/class/cpaiement.class.php +++ b/htdocs/compta/paiement/class/cpaiement.class.php @@ -25,17 +25,15 @@ * \brief This file is to manage CRUD function of type of payments */ +// Put here all includes required by your class file +require_once DOL_DOCUMENT_ROOT.'/core/class/commondict.class.php'; + /** * Class Cpaiement */ -class Cpaiement +class Cpaiement extends CommonDict { - /** - * @var DoliDB Database handler. - */ - public $db; - /** * @var string Id to identify managed objects */ @@ -46,18 +44,6 @@ class Cpaiement */ public $table_element = 'c_paiement'; - public $code; - - /** - * @var int ID - */ - public $id; - - /** - * @var string[] array of errors messages - */ - public $errors; - /** * @var string * @deprecated @@ -65,11 +51,6 @@ class Cpaiement */ public $libelle; - /** - * @var string - */ - public $label; - public $type; public $active; public $accountancy_code; diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index baf1bb43901..54c9f961f75 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -60,6 +60,11 @@ class Contact extends CommonObject */ public $ismultientitymanaged = 1; + /** + * @var int Does object support extrafields ? 0=No, 1=Yes + */ + public $isextrafieldmanaged = 1; + /** * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png */ @@ -107,7 +112,7 @@ class Contact extends CommonObject 'fk_departement' =>array('type'=>'integer', 'label'=>'Fk departement', 'enabled'=>1, 'visible'=>3, 'position'=>70), 'fk_pays' =>array('type'=>'integer', 'label'=>'Fk pays', 'enabled'=>1, 'visible'=>3, 'position'=>75), 'fk_soc' =>array('type'=>'integer', 'label'=>'ThirdParty', 'enabled'=>1, 'visible'=>1, 'position'=>77, 'searchall'=>1), - 'birthday' =>array('type'=>'date', 'label'=>'Birthday', 'enabled'=>1, 'visible'=>3, 'position'=>80), + 'birthday' =>array('type'=>'date', 'label'=>'Birthday', 'enabled'=>1, 'visible'=>-1, 'position'=>80), 'phone' =>array('type'=>'varchar(30)', 'label'=>'Phone', 'enabled'=>1, 'visible'=>1, 'position'=>90, 'searchall'=>1), 'phone_perso' =>array('type'=>'varchar(30)', 'label'=>'PhonePerso', 'enabled'=>1, 'visible'=>-1, 'position'=>95, 'searchall'=>1), 'phone_mobile' =>array('type'=>'varchar(30)', 'label'=>'PhoneMobile', 'enabled'=>1, 'visible'=>1, 'position'=>100, 'searchall'=>1), diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index b6e8bdc3996..15483f80c2a 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -106,6 +106,8 @@ $search_country = GETPOST("search_country", 'intcomma'); $search_roles = GETPOST("search_roles", 'array'); $search_level = GETPOST("search_level", 'array'); $search_stcomm = GETPOST('search_stcomm', 'int'); +$search_birthday_start = dol_mktime(0, 0, 0, GETPOST('search_birthday_startmonth', 'int'), GETPOST('search_birthday_startday', 'int'), GETPOST('search_birthday_startyear', 'int')); +$search_birthday_end = dol_mktime(23, 59, 59, GETPOST('search_birthday_endmonth', 'int'), GETPOST('search_birthday_endday', 'int'), GETPOST('search_birthday_endyear', 'int')); if ($search_status === '') { $search_status = 1; // always display active customer first @@ -334,6 +336,8 @@ if (empty($reshook)) { $toselect = array(); $search_array_options = array(); $search_roles = array(); + $search_birthday_start = ''; + $search_birthday_end = ''; } // Mass actions @@ -406,7 +410,7 @@ if ($resql) { // Build and execute select // -------------------------------------------------------------------- $sql = "SELECT s.rowid as socid, s.nom as name, s.name_alias as alias,"; -$sql .= " p.rowid, p.lastname as lastname, p.statut, p.firstname, p.address, p.zip, p.town, p.poste, p.email,"; +$sql .= " p.rowid, p.lastname as lastname, p.statut, p.firstname, p.address, p.zip, p.town, p.poste, p.email, p.birthday,"; $sql .= " p.socialnetworks, p.photo,"; $sql .= " p.phone as phone_pro, p.phone_mobile, p.phone_perso, p.fax, p.fk_pays, p.priv, p.datec as date_creation, p.tms as date_update,"; $sql .= " p.import_key, p.fk_stcommcontact as stcomm_id, p.fk_prospectlevel,"; @@ -674,6 +678,12 @@ if ($type == "o") { // filter on type if (!empty($socid)) { $sql .= " AND s.rowid = ".((int) $socid); } +if ($search_birthday_start) { + $sql .= " AND p.birthday >= '".$db->idate($search_birthday_start)."'"; +} +if ($search_birthday_end) { + $sql .= " AND p.birthday <= '".$db->idate($search_birthday_end)."'"; +} // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; @@ -834,7 +844,12 @@ if ($optioncss != '') { if (count($search_roles) > 0) { $param .= implode('&search_roles[]=', $search_roles); } - +if ($search_birthday_start) { + $param .= '&search_birthday_start='.urlencode(dol_print_date($search_birthday_start, '%d')).'&search_birthday_startmonth='.urlencode(dol_print_date($search_birthday_start, '%m')).'&search_birthday_startyear='.urlencode(dol_print_date($search_birthday_start, '%Y')); +} +if ($search_birthday_end) { + $param .= '&search_birthday_end='.urlencode(dol_print_date($search_birthday_end, '%d')).'&search_birthday_endmonth='.urlencode(dol_print_date($search_birthday_end, '%m')).'&search_birthday_endyear='.urlencode(dol_print_date($search_birthday_end, '%Y')); +} // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; @@ -1093,6 +1108,17 @@ if (!empty($arrayfields['p.fk_stcommcontact']['checked'])) { print $form->selectarray('search_stcomm', $arraystcomm, $search_stcomm, -2, 0, 0, '', 0, 0, 0, '', 'nowrap '); print ''; } +if (!empty($arrayfields['p.birthday']['checked'])) { + print ''; +} + // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; @@ -1230,6 +1256,10 @@ if (!empty($arrayfields['p.fk_stcommcontact']['checked'])) { print_liste_field_titre($arrayfields['p.fk_stcommcontact']['label'], $_SERVER["PHP_SELF"], "p.fk_stcommcontact", "", $param, '', $sortfield, $sortorder, 'center '); $totalarray['nbfield']++; } +if (!empty($arrayfields['p.birthday']['checked'])) { + print_liste_field_titre($arrayfields['p.birthday']['label'], $_SERVER["PHP_SELF"], "p.birthday", "", $param, '', $sortfield, $sortorder, 'center '); + $totalarray['nbfield']++; +} // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields @@ -1554,6 +1584,16 @@ while ($i < $imaxinloop) { } } + // Birthday + if (!empty($arrayfields['p.birthday']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php index 1df1ee37122..c30b1d6e27e 100644 --- a/htdocs/core/class/CMailFile.class.php +++ b/htdocs/core/class/CMailFile.class.php @@ -877,7 +877,7 @@ class CMailFile } } elseif ($this->sendmode == 'smtps') { if (!is_object($this->smtps)) { - $this->error = "Failed to send mail with smtps lib to HOST=".$server.", PORT=".$conf->global->$keyforsmtpport."
Constructor of object CMailFile was not initialized without errors."; + $this->error = "Failed to send mail with smtps lib
Constructor of object CMailFile was not initialized without errors."; dol_syslog("CMailFile::sendfile: mail end error=".$this->error, LOG_ERR); return false; } @@ -895,7 +895,7 @@ class CMailFile } // If we use SSL/TLS - $server = $conf->global->$keyforsmtpserver; + $server = getDolGlobalString($keyforsmtpserver); $secure = ''; if (!empty($conf->global->$keyfortls) && function_exists('openssl_open')) { $secure = 'ssl'; @@ -905,7 +905,7 @@ class CMailFile } $server = ($secure ? $secure.'://' : '').$server; - $port = $conf->global->$keyforsmtpport; + $port = getDolGlobalInt($keyforsmtpport); $this->smtps->setHost($server); $this->smtps->setPort($port); // 25, 465...; @@ -922,6 +922,8 @@ class CMailFile } if (getDolGlobalString($keyforsmtpauthtype) === "XOAUTH2") { + $supportedoauth2array = array(); + require_once DOL_DOCUMENT_ROOT.'/core/lib/oauth.lib.php'; // define $supportedoauth2array $keyforsupportedoauth2array = $conf->global->$keyforsmtpoauthservice; @@ -933,7 +935,7 @@ class CMailFile $keyforsupportedoauth2array = preg_replace('/-.*$/', '', $keyforsupportedoauth2array); $keyforsupportedoauth2array = 'OAUTH_'.$keyforsupportedoauth2array.'_NAME'; - if (isset($supportedoauth2array)) { + if (!empty($supportedoauth2array)) { $OAUTH_SERVICENAME = (empty($supportedoauth2array[$keyforsupportedoauth2array]['name']) ? 'Unknown' : $supportedoauth2array[$keyforsupportedoauth2array]['name'].($keyforprovider ? '-'.$keyforprovider : '')); } else { $OAUTH_SERVICENAME = 'Unknown'; @@ -1075,6 +1077,8 @@ class CMailFile $this->transport->setPassword($conf->global->$keyforsmtppw); } if (getDolGlobalString($keyforsmtpauthtype) === "XOAUTH2") { + $supportedoauth2array = array(); + require_once DOL_DOCUMENT_ROOT.'/core/lib/oauth.lib.php'; // define $supportedoauth2array $keyforsupportedoauth2array = getDolGlobalString($keyforsmtpoauthservice); diff --git a/htdocs/core/class/canvas.class.php b/htdocs/core/class/canvas.class.php index 1ed16b2e1ce..41086045e7a 100644 --- a/htdocs/core/class/canvas.class.php +++ b/htdocs/core/class/canvas.class.php @@ -121,7 +121,6 @@ class Canvas $controlclassfile = dol_buildpath('/'.$this->dirmodule.'/canvas/'.$this->canvas.'/actions_'.$this->card.'_'.$this->canvas.'.class.php'); if (file_exists($controlclassfile)) { // Include actions class (controller) - $this->control_file = $controlclassfile; require_once $controlclassfile; // Instantiate actions class (controller) diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index c349348ed6c..bfec5a6c199 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -109,6 +109,11 @@ abstract class CommonDocGenerator public $option_escompte; public $option_credit_note; + public $tva; + public $tva_array; + public $localtax1; + public $localtax2; + /** * @var int Tab Title Height */ @@ -150,7 +155,10 @@ abstract class CommonDocGenerator public $posxdesc; // For description public $posxqty; public $posxpuht; - + public $posxtva; + public $atleastonephoto; + public $atleastoneratenotnull; + public $atleastonediscount; /** * Constructor diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index bd96e29850d..a665e7b18e2 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -659,10 +659,30 @@ abstract class CommonObject */ public $alreadypaid; + /** + * @var array Array with label of status + */ public $labelStatus; + /** + * @var array array of status string + * @deprecated Use instead labelStatus + */ + public $statuts = array(); + + /** + * @var array Array with short label of status + */ protected $labelStatusShort; + /** + * @var array array of short status string + * @deprecated Use instead labelStatusShort + */ + public $statuts_short = array(); + + + /** * @var int show photo on popup */ @@ -673,6 +693,7 @@ abstract class CommonObject */ public $nb = array(); + /** * @var string output */ @@ -4294,6 +4315,9 @@ abstract class CommonObject if (empty($fk_object_where) || empty($field_where) || empty($table_element)) { return -1; } + if (!preg_match('/^[_a-zA-Z0-9]+$/', $field_select)) { + dol_syslog('Invalid value $field_select for parameter '.$field_select.' in call to getAllItemsLinkedByObjectID(). Must be a single field name.', LOG_ERR); + } global $db; @@ -4310,6 +4334,35 @@ abstract class CommonObject return $TRes; } + /** + * Count items linked to an object id in association table + * + * @param int $fk_object_where id of object we need to get linked items + * @param string $field_where name of field of object we need to get linked items + * @param string $table_element name of association table + * @return array|int Array of record, -1 if empty + */ + public static function getCountOfItemsLinkedByObjectID($fk_object_where, $field_where, $table_element) + { + if (empty($fk_object_where) || empty($field_where) || empty($table_element)) { + return -1; + } + + global $db; + + $sql = "SELECT COUNT(*) as nb FROM ".$db->prefix().$table_element." WHERE ".$field_where." = ".((int) $fk_object_where); + $resql = $db->query($sql); + $n = 0; + if ($resql) { + $res = $db->fetch_object($resql); + if ($res) { + $n = $res->nb; + } + } + + return $n; + } + /** * Function used to remove all items linked to an object id in association table * @@ -7475,13 +7528,13 @@ abstract class CommonObject * Return HTML string to show a field into a page * Code very similar with showOutputField of extra fields * - * @param array $val Array of properties of field to show - * @param string $key Key of attribute - * @param string $value Preselected value to show (for date type it must be in timestamp format, for amount or price it must be a php numeric value) - * @param string $moreparam To add more parametes on html input tag - * @param string $keysuffix Prefix string to add into name and id of field (can be used to avoid duplicate names) - * @param string $keyprefix Suffix string to add into name and id of field (can be used to avoid duplicate names) - * @param mixed $morecss Value for css to define size. May also be a numeric. + * @param array $val Array of properties of field to show + * @param string $key Key of attribute + * @param string $value Preselected value to show (for date type it must be in timestamp format, for amount or price it must be a php numeric value) + * @param string $moreparam To add more parameters on html tag + * @param string $keysuffix Prefix string to add into name and id of field (can be used to avoid duplicate names) + * @param string $keyprefix Suffix string to add into name and id of field (can be used to avoid duplicate names) + * @param mixed $morecss Value for CSS to use (Old usage: May also be a numeric to define a size). * @return string */ public function showOutputField($val, $key, $value, $moreparam = '', $keysuffix = '', $keyprefix = '', $morecss = '') diff --git a/htdocs/core/class/commonstickergenerator.class.php b/htdocs/core/class/commonstickergenerator.class.php index 0e5b76516d8..b908a7f4cb8 100644 --- a/htdocs/core/class/commonstickergenerator.class.php +++ b/htdocs/core/class/commonstickergenerator.class.php @@ -71,8 +71,10 @@ abstract class CommonStickerGenerator extends CommonDocGenerator // phpcs:disable PEAR.NamingConventions.ValidVariableName.PublicUnderscore // protected - // Nom du format de l'etiquette + // Name of stick protected $_Avery_Name = ''; + // Code of stick + protected $_Avery_Code = ''; // Marge de gauche de l'etiquette protected $_Margin_Left = 0; // marge en haut de la page avant la premiere etiquette diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index b356675ad7e..bbaed873c6a 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -70,6 +70,8 @@ class Conf public $theme; // Contains current theme ("eldy", "auguria", ...) public $css; // Contains full path of css page ("/theme/eldy/style.css.php", ...) + public $email_from; + //! Used to store current menu handler public $standard_menu; // List of activated modules @@ -138,6 +140,7 @@ class Conf public $agenda; public $commande; public $propal; + public $order; /** * @deprecated Use invoice */ @@ -284,7 +287,6 @@ class Conf $this->commande = new stdClass(); $this->propal = new stdClass(); $this->facture = new stdClass(); - $this->contrat = new stdClass(); $this->user = new stdClass(); $this->adherent = new stdClass(); $this->bank = new stdClass(); diff --git a/htdocs/core/class/hookmanager.class.php b/htdocs/core/class/hookmanager.class.php index 1cc1244d8df..6f951eff6ea 100644 --- a/htdocs/core/class/hookmanager.class.php +++ b/htdocs/core/class/hookmanager.class.php @@ -200,7 +200,7 @@ class HookManager 'insertExtraFooter', 'printLeftBlock', 'formAddObjectLine', - 'formBuilddocOption', + 'formBuilddocOptions', 'showSocinfoOnPrint' ))) { $hooktype = 'output'; @@ -241,8 +241,8 @@ class HookManager $actionclassinstance->error = 0; $actionclassinstance->errors = array(); - if (getDolGlobalInt('MAIN_DEBUG_SHOW_EACH_QUALIFIED_HOOK_CALL') >= 2) { - // This his too much verbose, enabled in develop only + if (getDolGlobalInt('MAIN_DEBUG_HOOK')) { + // This his too much verbose, enabled if const enabled only dol_syslog(get_class($this)."::executeHooks Qualified hook found (hooktype=".$hooktype."). We call method ".get_class($actionclassinstance).'->'.$method.", context=".$context.", module=".$module.", action=".$action.((is_object($object) && property_exists($object, 'id')) ? ', object id='.$object->id : '').((is_object($object) && property_exists($object, 'element')) ? ', object element='.$object->element : ''), LOG_DEBUG); } @@ -283,7 +283,10 @@ class HookManager continue; } - //dol_syslog("Call method ".$method." of class ".get_class($actionclassinstance).", module=".$module.", hooktype=".$hooktype, LOG_DEBUG); + if (getDolGlobalInt('MAIN_DEBUG_HOOK')) { + dol_syslog("Call method ".$method." of class ".get_class($actionclassinstance).", module=".$module.", hooktype=".$hooktype, LOG_DEBUG); + } + $resactiontmp = $actionclassinstance->$method($parameters, $object, $action, $this); // $object and $action can be changed by method ($object->id during creation for example or $action to go back to other action for example) $resaction += $resactiontmp; diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 5925a0b233d..eecc41bd4eb 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -6606,7 +6606,7 @@ class Form * @param int $disabled Disable input fields * @param int $fullday When a checkbox with this html name is on, hour and day are set with 00:00 or 23:59 * @param string $addplusone Add a link "+1 hour". Value must be name of another select_date field. - * @param datetime $adddateof Add a link "Date of invoice" using the following date. + * @param int|string $adddateof Add a link "Date of invoice" using the following date. * @return string '' or HTML component string if nooutput is 1 * @deprecated * @see selectDate(), form_date(), select_month(), select_year(), select_dayofweek() @@ -6614,6 +6614,7 @@ class Form public function select_date($set_time = '', $prefix = 're', $h = 0, $m = 0, $empty = 0, $form_name = "", $d = 1, $addnowlink = 0, $nooutput = 0, $disabled = 0, $fullday = '', $addplusone = '', $adddateof = '') { // phpcs:enable + dol_syslog(__METHOD__ . ': using select_date is deprecated. Use selectDate instead.', LOG_WARNING); $retstring = $this->selectDate($set_time, $prefix, $h, $m, $empty, $form_name, $d, $addnowlink, $disabled, $fullday, $addplusone, $adddateof); if (!empty($nooutput)) { return $retstring; @@ -6668,7 +6669,7 @@ class Form * @param int $disabled Disable input fields * @param int $fullday When a checkbox with id #fullday is checked, hours are set with 00:00 (if value if 'fulldaystart') or 23:59 (if value is 'fulldayend') * @param string $addplusone Add a link "+1 hour". Value must be name of another selectDate field. - * @param datetime|string|array $adddateof Add a link "Date of ..." using the following date. Must be array(array('adddateof'=>..., 'labeladddateof'=>...)) + * @param int|string|array $adddateof Add a link "Date of ..." using the following date. Must be array(array('adddateof'=>..., 'labeladddateof'=>...)) * @param string $openinghours Specify hour start and hour end for the select ex 8,20 * @param int $stepminutes Specify step for minutes between 1 and 30 * @param string $labeladddateof Label to use for the $adddateof parameter. Deprecated. Used only when $adddateof is not an array. @@ -7097,7 +7098,7 @@ class Form $arrayofdateof = $adddateof; } foreach ($arrayofdateof as $valuedateof) { - $tmpadddateof = $valuedateof['adddateof']; + $tmpadddateof = $valuedateof['adddateof'] != '' ? $valuedateof['adddateof'] : 0; $tmplabeladddateof = $valuedateof['labeladddateof']; $tmparray = dol_getdate($tmpadddateof); if (empty($tmplabeladddateof)) { @@ -8055,6 +8056,9 @@ class Form // Search data $sql = "SELECT t.rowid, " . $fieldstoshow . " FROM " . $this->db->prefix() . $objecttmp->table_element . " as t"; + if (!empty($objecttmp->isextrafieldmanaged)) { + $sql .= " LEFT JOIN " . $this->db->prefix() . $objecttmp->table_element . "_extrafields as e ON t.rowid=e.fk_object"; + } if (isset($objecttmp->ismultientitymanaged)) { if (!is_numeric($objecttmp->ismultientitymanaged)) { $tmparray = explode('@', $objecttmp->ismultientitymanaged); @@ -8236,9 +8240,8 @@ class Form $addjscombo = 0; } } - $idname = str_replace(array('[', ']'), array('', ''), $htmlname); - $out .= ''; //if ($user->admin && $help) $out .= info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); } else { - $out = $langs->trans("ErrorNoAccountingCategoryForThisCountry", $mysoc->country_code); + $out = $langs->trans("ErrorNoAccountingCategoryForThisCountry", $mysoc->country_code, $langs->trans("Accounting"), $langs->trans("Setup"), $langs->trans("AccountingCategories")); } } else { dol_print_error($this->db); diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 8246f785fe1..1b3f335e8b4 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -704,6 +704,9 @@ class FormFile $out .= '
'; + print '
'; + print $form->selectDate($search_birthday_start ? $search_birthday_start : -1, 'search_birthday_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')); + print '
'; + print '
'; + print $form->selectDate($search_birthday_end ? $search_birthday_end : -1, 'search_birthday_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to')); + print '
'; + print '
'; + print dol_print_date($db->jdate($obj->birthday), 'day', 'tzuser'); + print '
'; $out .= ''; + $addcolumforpicto = ($delallowed || $printer || $morepicto); + $colspan = (4 + ($addcolumforpicto ? 1 : 0)); + $colspanmore = 0; $out .= ''."\n"; + print ''."\n"; $dejafait = $numerojour; } } @@ -490,10 +505,10 @@ for ($i = 0; $i < $nbrejourmois + $premierjourmois; $i++) { if (isset($dejafait) === false || $dejafait != $numerojour) { // green button if (($numerojour >= $jourAJ && $_SESSION["mois"] == $moisAJ && $_SESSION["annee"] == $anneeAJ) || ($_SESSION["mois"] > $moisAJ && $_SESSION["annee"] == $anneeAJ) || $_SESSION["annee"] > $anneeAJ) { - print ''."\n"; + print ''."\n"; } else { // grey button - print ''."\n"; + print ''."\n"; } } } @@ -530,12 +545,13 @@ if (issetAndNoEmpty('totalchoixjour', $_SESSION) || $erreur) { print ''."\n"; - //affichage de la liste des jours choisis + // Show list of selected days + $nbofchoice = count($_SESSION["totalchoixjour"]); for ($i = 0; $i < $nbofchoice; $i++) { print ''."\n"; - print ''; + print ''; //affichage des cases d'horaires for ($j = 0; $j < $_SESSION["nbrecaseshoraires"]; $j++) { @@ -555,7 +571,9 @@ if (issetAndNoEmpty('totalchoixjour', $_SESSION) || $erreur) { // show buttons to cancel, delete days or create survey print '
'; @@ -719,7 +722,40 @@ class FormFile if ($conf->browser->layout == 'phone') { $morecss = 'maxwidth100'; } - $out .= $form->selectarray('model', $modellist, $modelselected, $showempty, 0, 0, '', 0, 0, 0, '', $morecss); + $out .= $form->selectarray('model', $modellist, $modelselected, $showempty, 0, 0, '', 0, 0, 0, '', $morecss, 1, '', 0, 0); + // script for select the separator + /* TODO This must appear on export feature only + $out .= ''; + $out .= ''; + $out .= ''; + + $out .= ''; + */ if ($conf->use_javascript_ajax) { $out .= ajax_combobox('model'); } @@ -977,6 +1013,18 @@ class FormFile } } $out .= ''."\n"; + + $out .= ''; //return ($i?$i:$headershown); return $out; } diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index d117140e156..264ed21b512 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -134,6 +134,7 @@ class FormMail extends Form public $withtocc; public $withtoccc; public $withtopic; + public $witherrorsto; /** * @var int 0=No attaches files, 1=Show attached files, 2=Can add new attached files @@ -150,13 +151,21 @@ class FormMail extends Form public $withreplytoreadonly; public $withtoreadonly; public $withtoccreadonly; + public $witherrorstoreadonly; public $withtocccreadonly; public $withtopicreadonly; + public $withbodyreadonly; public $withfilereadonly; public $withdeliveryreceipt; public $withcancel; + public $withdeliveryreceiptreadonly; public $withfckeditor; + /** + * @var string ckeditortoolbar + */ + public $ckeditortoolbar; + public $substit = array(); public $substit_lines = array(); public $param = array(); diff --git a/htdocs/core/class/html.formsms.class.php b/htdocs/core/class/html.formsms.class.php index 940f76d0ae8..8e20cb8d33c 100644 --- a/htdocs/core/class/html.formsms.class.php +++ b/htdocs/core/class/html.formsms.class.php @@ -62,6 +62,7 @@ class FormSms public $withreplytoreadonly; public $withtoreadonly; public $withtopicreadonly; + public $withbodyreadonly; public $withcancel; public $substit = array(); diff --git a/htdocs/core/class/lessc.class.php b/htdocs/core/class/lessc.class.php index f1620898028..29feea57f29 100644 --- a/htdocs/core/class/lessc.class.php +++ b/htdocs/core/class/lessc.class.php @@ -56,8 +56,12 @@ class Lessc public $scope; public $formatter; + public $formatterName; + public $parser; + public $_parseFile; public $env; public $count; + public $inExp; protected $numberPrecision = null; @@ -2640,7 +2644,15 @@ class lessc_parser protected static $literalCache = array(); public $env; + public $buffer; public $count; + public $line; + public $eatWhiteDefault; + public $lessc; + public $sourceName; + public $writeComments; + public $seenComments; + public $currentProperty; public function __construct($lessc, $sourceName = null) @@ -4245,6 +4257,7 @@ class lessc_formatter_classic public $breakSelectors = false; public $compressColors = false; + public $indentLevel; public function __construct() { diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index e09282fe6ed..710ad9f3dce 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -3133,7 +3133,7 @@ function dol_print_size($size, $shortvalue = 0, $shortunit = 0) * @param string $morecss More CSS * @return string HTML Link */ -function dol_print_url($url, $target = '_blank', $max = 32, $withpicto = 0, $morecss = 'float') +function dol_print_url($url, $target = '_blank', $max = 32, $withpicto = 0, $morecss = '') { global $langs; @@ -3141,26 +3141,30 @@ function dol_print_url($url, $target = '_blank', $max = 32, $withpicto = 0, $mor return ''; } - $link = 'trans("URL").': '.$url.'"'; + $linkstart .= '>'; + + $link = ''; if (!preg_match('/^http/i', $url)) { $link .= 'http://'; } $link .= dol_trunc($url, $max); - $link .= ''; - if ($morecss == 'float') { + $linkend = ''; + + if ($morecss == 'float') { // deprecated return '
'.($withpicto ?img_picto($langs->trans("Url"), 'globe').' ' : '').$link.'
'; } else { - return ''.($withpicto ?img_picto($langs->trans("Url"), 'globe').' ' : '').$link.''; + return $linkstart.''.($withpicto ?img_picto('', 'globe').' ' : '').$link.''.$linkend; } } @@ -3706,7 +3710,7 @@ function dol_print_phone($phone, $countrycode = '', $cid = 0, $socid = 0, $addli */ function dol_print_ip($ip, $mode = 0) { - global $conf, $langs; + global $langs; $ret = ''; @@ -7337,7 +7341,7 @@ function dolGetFirstLineOfText($text, $nboflines = 1, $charset = 'UTF-8') * @param int $nl2brmode 0=Adding br before \n, 1=Replacing \n by br * @param bool $forxml false=Use
, true=Use
* @return string String encoded - * @see dol_nboflines(), dolGetFirstLineOfText() + * @see dol_htmlentitiesbr(), dol_nboflines(), dolGetFirstLineOfText() */ function dol_nl2br($stringtoencode, $nl2brmode = 0, $forxml = false) { @@ -7461,7 +7465,7 @@ function dol_htmlwithnojs($stringtoencode, $nouseofiframesandbox = 0, $check = ' * is used to build PDF, nl2brmode must be 1. * Note: When we output string on pages, we should use * - dol_htmlwithnojs(dol_string_onlythesehtmltags(dol_htmlentitiesbr(), 1, 1, 1)) for notes, - * - dol_escape_htmltag() for simple labels. + * - dol_escape_htmltag(dol_htmlentitiesbr()) for simple labels. * * @param string $stringtoencode String to encode * @param int $nl2brmode 0=Adding br before \n, 1=Replacing \n by br (for use with FPDF writeHTMLCell function for example) diff --git a/htdocs/core/lib/modulebuilder.lib.php b/htdocs/core/lib/modulebuilder.lib.php index 6f174397c3e..7281936216a 100644 --- a/htdocs/core/lib/modulebuilder.lib.php +++ b/htdocs/core/lib/modulebuilder.lib.php @@ -615,6 +615,52 @@ function reWriteAllPermissions($file, $permissions, $key, $right, $objectname, $ } } +/** + * Converts a formatted properties string into an associative array. + * + * @param string $string The formatted properties string. + * @return array The resulting associative array. + */ +function parsePropertyString($string) +{ + + $string = str_replace("'", '', $string); + + // Uses a regular expression to capture keys and values + preg_match_all('/\s*([^\s=>]+)\s*=>\s*([^,]+),?/', $string, $matches, PREG_SET_ORDER); + $propertyArray = []; + + foreach ($matches as $match) { + $key = trim($match[1]); + $value = trim($match[2]); + + if (strpos($value, 'array(') === 0) { + $nestedArray = substr($value, 6); + $nestedArray = parsePropertyString($nestedArray); + $value = $nestedArray; + } elseif (strpos($value, '"Id")') !== false) { + $value = str_replace(')', '', $value); + } else { + if (is_numeric($value)) { + if (strpos($value, '.') !== false) { + $value = (float) $value; + } else { + $value = (int) $value; + } + } else { + if ($value === 'true') { + $value = true; + } elseif ($value === 'false') { + $value = false; + } + } + } + $propertyArray[$key] = $value; + } + + return $propertyArray; +} + /** * Write all properties of the object in AsciiDoc format * @param string $file path of the class @@ -626,7 +672,7 @@ function writePropsInAsciiDoc($file, $objectname, $destfile) { // stock all properties in array - $attributesUnique = array ('label', 'type', 'arrayofkeyval', 'notnull', 'default', 'index', 'foreignkey', 'position', 'enabled', 'visible', 'noteditable', 'alwayseditable', 'searchall', 'isameasure', 'css','cssview','csslist', 'help', 'showoncombobox', 'validate','comment','picto' ); + $attributesUnique = array ('type','label', 'enabled', 'position', 'notnull', 'visible', 'noteditable', 'index', 'default' , 'foreignkey', 'arrayofkeyval', 'alwayseditable','validate', 'searchall','comment', 'isameasure', 'css', 'cssview','csslist', 'help', 'showoncombobox','picto' ); $start = "public \$fields=array("; $end = ");"; @@ -657,32 +703,53 @@ function writePropsInAsciiDoc($file, $objectname, $destfile) $table .= "|".$attUnique; } $table .="\n"; + $valuesModif = array(); foreach ($keys as $string) { $string = trim($string, "'"); $string = rtrim($string, ","); - $array = eval("return [$string];"); - // check if is array after cleaning string + $array = parsePropertyString($string); + + // Iterate through the array to merge all key to one array + $code = ''; + foreach ($array as $key => $value) { + if (is_array($value)) { + $code = $key; + continue; + } else { + $array[$code][$key] = $value; + unset($array[$key]); + } + } + // check if is array after parsing the string if (!is_array($array)) { return -1; } - $field = array_keys($array); + if ($field[0] === '') { + $field[0] = 'label'; + } $values = array_values($array)[0]; // check each field has all properties and add it if missed foreach ($attributesUnique as $attUnique) { + if ($attUnique == 'type' && $field[0] === 'label') { + $values[$attUnique] = 'varchar(255)'; + } if (!array_key_exists($attUnique, $values)) { - $values[$attUnique] = ''; + $valuesModif[$attUnique] = ''; + } else { + $valuesModif[$attUnique] = $values[$attUnique]; } } - $table .= "|*" . $field[0] . "*|"; - $table .= implode("|", $values) . "\n"; + $table .= implode("|", $valuesModif) . "\n"; } + // end table $table .= "|===\n"; $table .= "__ end table for object $objectname\n"; + //write in file $writeInFile = dolReplaceInFile($destfile, array('== DATA SPECIFICATIONS' => $table)); if ($writeInFile<0) { @@ -691,13 +758,14 @@ function writePropsInAsciiDoc($file, $objectname, $destfile) return 1; } + /** - * Delete property from documentation if we delete object + * Delete property and permissions from documentation if we delete object * @param string $file file or path * @param string $objectname name of object wants to deleted * @return void */ -function deletePropsFromDoc($file, $objectname) +function deletePropsAndPermsFromDoc($file, $objectname) { $start = "== Table of fields and their properties for object *".ucfirst($objectname)."* : "; @@ -706,8 +774,16 @@ function deletePropsFromDoc($file, $objectname) $search = '/' . preg_quote($start, '/') . '(.*?)' . preg_quote($end, '/') . '/s'; $new_contents = preg_replace($search, '', $str); file_put_contents($file, $new_contents); + + //perms If Exist + $perms = "|*".strtolower($objectname)."*|"; + $search_pattern_perms = '/' . preg_quote($perms, '/') . '.*?\n/'; + $new_contents = preg_replace($search_pattern_perms, '', $new_contents); + file_put_contents($file, $new_contents); } + + /** * Search a string and return all lines needed from file * @param string $file file for searching diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index 43b2c136044..07519ea55d2 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -214,7 +214,7 @@ function project_prepare_head(Project $project, $moreparam = '') if (isModEnabled('ticket') && $user->hasRight('ticket', 'read')) { require_once DOL_DOCUMENT_ROOT.'/ticket/class/ticket.class.php'; $Tickettatic = new Ticket($db); - $nbTicket = count($Tickettatic->getAllItemsLinkedByObjectID($project->id, '*', 'fk_project', 'ticket')); + $nbTicket = $Tickettatic->getCountOfItemsLinkedByObjectID($project->id, 'fk_project', 'ticket'); $head[$h][0] = DOL_URL_ROOT.'/ticket/list.php?projectid='.((int) $project->id); $head[$h][1] = $langs->trans("Ticket"); if ($nbTicket > 0) { diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 0194c45b457..a4b493359d5 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -396,7 +396,7 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = 'submenus' => array(), ); - // Tickets and knowledge base + // Tickets and Knowledge base $tmpentry = array( 'enabled'=>(isModEnabled('ticket') || isModEnabled('knowledgemanagement')), 'perms'=>($user->hasRight('ticket', 'read') || $user->hasRight('knowledgemanagement', 'knowledgerecord', 'read')), @@ -411,7 +411,7 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = $menu_arr[] = array( 'name' => 'Ticket', 'link' => $link, - 'title' => "Tickets", + 'title' => isModEnabled('ticket') ? "Tickets" : "MenuKnowledgeRecordShort", 'level' => 0, 'enabled' => $showmode = isVisibleToUserType($type_user, $tmpentry, $listofmodulesforexternal), 'target' => $atarget, diff --git a/htdocs/core/modules/export/export_csviso.modules.php b/htdocs/core/modules/export/export_csviso.modules.php index 4e12c32f66c..d9976031686 100644 --- a/htdocs/core/modules/export/export_csviso.modules.php +++ b/htdocs/core/modules/export/export_csviso.modules.php @@ -21,7 +21,7 @@ * \brief File of class to build exports with CSV format */ -require_once DOL_DOCUMENT_ROOT.'/core/modules/export/exportcsv.modules.php'; +require_once DOL_DOCUMENT_ROOT.'/core/modules/export/exportcsv.class.php'; // avoid timeout for big export set_time_limit(0); diff --git a/htdocs/core/modules/export/export_csvutf8.modules.php b/htdocs/core/modules/export/export_csvutf8.modules.php index a98f3f5f7f8..3fcf1db669c 100644 --- a/htdocs/core/modules/export/export_csvutf8.modules.php +++ b/htdocs/core/modules/export/export_csvutf8.modules.php @@ -16,12 +16,12 @@ */ /** - * \file htdocs/core/modules/export/export_csv.modules.php + * \file htdocs/core/modules/export/exportcsv.class.php * \ingroup export * \brief File of class to build exports with CSV format */ -require_once DOL_DOCUMENT_ROOT.'/core/modules/export/exportcsv.modules.php'; +require_once DOL_DOCUMENT_ROOT.'/core/modules/export/exportcsv.class.php'; // avoid timeout for big export set_time_limit(0); diff --git a/htdocs/core/modules/export/export_tsv.modules.php b/htdocs/core/modules/export/export_tsv.modules.php index 40ee75a1749..956639f0135 100644 --- a/htdocs/core/modules/export/export_tsv.modules.php +++ b/htdocs/core/modules/export/export_tsv.modules.php @@ -230,7 +230,7 @@ class ExportTsv extends ModeleExports * Output record line into file * * @param array $array_selected_sorted Array with list of field to export - * @param resource $objp A record from a fetch with all fields from select + * @param Resource $objp A record from a fetch with all fields from select * @param Translate $outputlangs Object lang to translate values * @param array $array_types Array with types of fields * @return int <0 if KO, >0 if OK diff --git a/htdocs/core/modules/export/exportcsv.modules.php b/htdocs/core/modules/export/exportcsv.class.php similarity index 98% rename from htdocs/core/modules/export/exportcsv.modules.php rename to htdocs/core/modules/export/exportcsv.class.php index fd96bf468f3..0e8c0a602ba 100644 --- a/htdocs/core/modules/export/exportcsv.modules.php +++ b/htdocs/core/modules/export/exportcsv.class.php @@ -16,7 +16,7 @@ */ /** - * \file htdocs/core/modules/export/exportcsv.modules.php + * \file htdocs/core/modules/export/exportcsv.class.php * \ingroup export * \brief File of class to build exports with CSV format */ @@ -213,7 +213,7 @@ class ExportCsv extends ModeleExports * Output record line into file * * @param array $array_selected_sorted Array with list of field to export - * @param resource $objp A record from a fetch with all fields from select + * @param Resource $objp A record from a fetch with all fields from select * @param Translate $outputlangs Object lang to translate values * @param array $array_types Array with types of fields * @return int <0 if KO, >0 if OK diff --git a/htdocs/core/modules/export/modules_export.php b/htdocs/core/modules/export/modules_export.php index 0cad4f76509..c55fa7d2a61 100644 --- a/htdocs/core/modules/export/modules_export.php +++ b/htdocs/core/modules/export/modules_export.php @@ -37,12 +37,43 @@ class ModeleExports extends CommonDocGenerator // This class can't be abstrac public $driverlabel = array(); + public $driverdesc = array(); + public $driverversion = array(); public $liblabel = array(); public $libversion = array(); + /** + * @var string picto + */ + public $picto; + + /** + * @var string description + */ + public $desc; + + /** + * @var string escape + */ + public $escape; + + /** + * @var string enclosure + */ + public $enclosure; + + /** + * @var int col + */ + public $col; + + /** + * @var int disabled + */ + public $disabled; /** * Load into memory list of available export format @@ -62,8 +93,12 @@ class ModeleExports extends CommonDocGenerator // This class can't be abstrac $i = 0; if (is_resource($handle)) { while (($file = readdir($handle)) !== false) { + $reg = array(); if (preg_match("/^export_(.*)\.modules\.php$/i", $file, $reg)) { $moduleid = $reg[1]; + if ($moduleid == 'csv') { + continue; // This may happen if on old file export_csv.modules.php was not correctly deleted + } // Loading Class $file = $dir."export_".$moduleid.".modules.php"; @@ -72,6 +107,7 @@ class ModeleExports extends CommonDocGenerator // This class can't be abstrac require_once $file; if (class_exists($classname)) { $module = new $classname($db); + // var_dump($classname); // Picto $this->picto[$module->id] = $module->picto; diff --git a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php index 33b4a07c104..aaa8bad5ee7 100644 --- a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php +++ b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php @@ -329,6 +329,34 @@ class doc_generic_invoice_odt extends ModelePDFFactures } } + // and determine category of operation + $categoryOfOperation = 0; + $nbProduct = 0; + $nbService = 0; + foreach ($object->lines as $line) { + // determine category of operation + if ($categoryOfOperation < 2) { + $lineProductType = $line->product_type; + if ($lineProductType == Product::TYPE_PRODUCT) { + $nbProduct++; + } elseif ($lineProductType == Product::TYPE_SERVICE) { + $nbService++; + } + if ($nbProduct > 0 && $nbService > 0) { + // mixed products and services + $categoryOfOperation = 2; + } + } + } + + // determine category of operation + if ($categoryOfOperation <= 0) { + // only services + if ($nbProduct == 0 && $nbService > 0) { + $categoryOfOperation = 1; + } + } + // Make substitution $substitutionarray = array( '__FROM_NAME__' => $this->emetteur->name, @@ -402,6 +430,7 @@ class doc_generic_invoice_odt extends ModelePDFFactures // TODO Search all tags {object_...:xxxx} into template then loop on this found tags to analyze them and the the corresponding // property of object and use the xxxx to know how to format it. // Before that, we hard code this substitution as if we have found them into the template. + $tmparray['object_PREVIOUS_MONTH'] = dol_print_date(dol_time_plus_duree($object->date, -1, 'm'), '%m'); $tmparray['object_MONTH'] = dol_print_date($object->date, '%m'); $tmparray['object_NEXT_MONTH'] = dol_print_date(dol_time_plus_duree($object->date, 1, 'm'), '%m'); @@ -411,6 +440,8 @@ class doc_generic_invoice_odt extends ModelePDFFactures $tmparray['object_PREVIOUS_YEAR'] = dol_print_date(dol_time_plus_duree($object->date, -1, 'y'), '%Y'); $tmparray['object_YEAR'] = dol_print_date($object->date, '%Y'); $tmparray['object_NEXT_YEAR'] = dol_print_date(dol_time_plus_duree($object->date, 1, 'y'), '%Y'); + $tmparray['object_productorservice_operation'] = $outputlangs->transnoentities("MentionCategoryOfOperations" . $categoryOfOperation); + // Call the ODTSubstitution hook $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); diff --git a/htdocs/core/modules/mailings/advthirdparties.modules.php b/htdocs/core/modules/mailings/advthirdparties.modules.php index 111943e99e0..7a40e1cdbda 100644 --- a/htdocs/core/modules/mailings/advthirdparties.modules.php +++ b/htdocs/core/modules/mailings/advthirdparties.modules.php @@ -37,11 +37,6 @@ class mailing_advthirdparties extends MailingTargets */ public $picto = 'company'; - /** - * @var DoliDB Database handler. - */ - public $db; - public $enabled = 'isModEnabled("societe")'; diff --git a/htdocs/core/modules/mailings/contacts1.modules.php b/htdocs/core/modules/mailings/contacts1.modules.php index 772c9900573..8452dacce1e 100644 --- a/htdocs/core/modules/mailings/contacts1.modules.php +++ b/htdocs/core/modules/mailings/contacts1.modules.php @@ -45,11 +45,6 @@ class mailing_contacts1 extends MailingTargets */ public $picto = 'contact'; - /** - * @var DoliDB Database handler. - */ - public $db; - /** * Constructor diff --git a/htdocs/core/modules/mailings/eventorganization.modules.php b/htdocs/core/modules/mailings/eventorganization.modules.php index 2a8e06693b9..73eea96f8c5 100644 --- a/htdocs/core/modules/mailings/eventorganization.modules.php +++ b/htdocs/core/modules/mailings/eventorganization.modules.php @@ -39,11 +39,6 @@ class mailing_eventorganization extends MailingTargets */ public $picto = 'conferenceorbooth'; - /** - * @var DoliDB Database handler. - */ - public $db; - public $enabled = 'isModEnabled("eventorganization")'; diff --git a/htdocs/core/modules/mailings/fraise.modules.php b/htdocs/core/modules/mailings/fraise.modules.php index 2096aeff135..aa8f0f5859a 100644 --- a/htdocs/core/modules/mailings/fraise.modules.php +++ b/htdocs/core/modules/mailings/fraise.modules.php @@ -48,10 +48,6 @@ class mailing_fraise extends MailingTargets */ public $picto = 'user'; - /** - * @var DoliDB Database handler. - */ - public $db; /** * Constructor diff --git a/htdocs/core/modules/mailings/modules_mailings.php b/htdocs/core/modules/mailings/modules_mailings.php index 28c9e6cc034..632e228ad69 100644 --- a/htdocs/core/modules/mailings/modules_mailings.php +++ b/htdocs/core/modules/mailings/modules_mailings.php @@ -32,30 +32,45 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php'; class MailingTargets // This can't be abstract as it is used for some method { /** - * @var DoliDB Database handler. + * @var DoliDb Database handler (result of a new DoliDB) */ public $db; + /** + * @var string Error code (or message) + */ + public $error = ''; + + /** + * @var array of errors + */ + public $errors; + /** * @var string Condition to be enabled */ public $enabled; /** - * @var string Error code (or message) + * @var string Name of the module */ - public $error = ''; + public $name; + /** + * @var string Description of the module + */ + public $desc; + + /** + * @var string Tooltip to show after description of the module + */ public $tooltip = ''; /** - * @var string The SQL string used to find the recipients + * @var string To store the SQL string used to find the recipients */ public $sql; - public $desc; - - public $name; public $evenunsubscribe = 0; // Set this to 1 if you want to flag you also want to include email in target that has opt-out. diff --git a/htdocs/core/modules/mailings/partnership.modules.php b/htdocs/core/modules/mailings/partnership.modules.php index 3e947b6ed93..2695444b334 100644 --- a/htdocs/core/modules/mailings/partnership.modules.php +++ b/htdocs/core/modules/mailings/partnership.modules.php @@ -39,11 +39,6 @@ class mailing_partnership extends MailingTargets */ public $picto = 'partnership'; - /** - * @var DoliDB Database handler. - */ - public $db; - public $enabled = 'isModEnabled("partnership")'; diff --git a/htdocs/core/modules/mailings/pomme.modules.php b/htdocs/core/modules/mailings/pomme.modules.php index 2d2dd7e1809..cd93813cf68 100644 --- a/htdocs/core/modules/mailings/pomme.modules.php +++ b/htdocs/core/modules/mailings/pomme.modules.php @@ -41,11 +41,6 @@ class mailing_pomme extends MailingTargets */ public $picto = 'user'; - /** - * @var DoliDB Database handler. - */ - public $db; - /** * Constructor diff --git a/htdocs/core/modules/mailings/thirdparties.modules.php b/htdocs/core/modules/mailings/thirdparties.modules.php index e678dab33ed..16194db6862 100644 --- a/htdocs/core/modules/mailings/thirdparties.modules.php +++ b/htdocs/core/modules/mailings/thirdparties.modules.php @@ -38,11 +38,6 @@ class mailing_thirdparties extends MailingTargets */ public $picto = 'company'; - /** - * @var DoliDB Database handler. - */ - public $db; - /** * Constructor diff --git a/htdocs/core/modules/mailings/thirdparties_services_expired.modules.php b/htdocs/core/modules/mailings/thirdparties_services_expired.modules.php index 6c6812759d7..0cf133df273 100644 --- a/htdocs/core/modules/mailings/thirdparties_services_expired.modules.php +++ b/htdocs/core/modules/mailings/thirdparties_services_expired.modules.php @@ -36,11 +36,6 @@ class mailing_thirdparties_services_expired extends MailingTargets */ public $picto = 'company'; - /** - * @var DoliDB Database handler. - */ - public $db; - public $arrayofproducts = array(); diff --git a/htdocs/core/modules/modPartnership.class.php b/htdocs/core/modules/modPartnership.class.php index b8aafc853fb..48244ae0455 100644 --- a/htdocs/core/modules/modPartnership.class.php +++ b/htdocs/core/modules/modPartnership.class.php @@ -253,8 +253,8 @@ class modPartnership extends DolibarrModules $datestart=dol_mktime(21, 15, 0, $arraydate['mon'], $arraydate['mday'], $arraydate['year']); $this->cronjobs = array( - 0 => array('priority'=>60, 'label'=>'CancelPartnershipForExpiredMembers', 'jobtype'=>'method', 'class'=>'/partnership/class/partnershiputils.class.php', 'objectname'=>'PartnershipUtils', 'method'=>'doCancelStatusOfMemberPartnership', 'parameters'=>'', 'comment'=>'Cancel status of partnership when subscription is expired + x days.', 'frequency'=>1, 'unitfrequency'=>86400, 'status'=>1, 'test'=>'$conf->partnership->enabled', 'datestart'=>$datestart), - 1 => array('priority'=>61, 'label'=>'PartnershipCheckBacklink', 'jobtype'=>'method', 'class'=>'/partnership/class/partnershiputils.class.php', 'objectname'=>'PartnershipUtils', 'method'=>'doWarningOfPartnershipIfDolibarrBacklinkNotfound', 'parameters'=>'', 'comment'=>'Warning of partnership if Dolibarr backlink not found on partner website.', 'frequency'=>1, 'unitfrequency'=>86400, 'status'=>0, 'test'=>'$conf->partnership->enabled', 'datestart'=>$datestart), + 0 => array('priority'=>60, 'label'=>'CancelPartnershipForExpiredMembers', 'jobtype'=>'method', 'class'=>'/partnership/class/partnershiputils.class.php', 'objectname'=>'PartnershipUtils', 'method'=>'doCancelStatusOfMemberPartnership', 'parameters'=>'', 'comment'=>'Cancel status of partnership when subscription is expired + x days.', 'frequency'=>1, 'unitfrequency'=>86400, 'status'=>1, 'test'=>'isModEnabled("partnership")', 'datestart'=>$datestart), + 1 => array('priority'=>61, 'label'=>'PartnershipCheckBacklink', 'jobtype'=>'method', 'class'=>'/partnership/class/partnershiputils.class.php', 'objectname'=>'PartnershipUtils', 'method'=>'doWarningOfPartnershipIfDolibarrBacklinkNotfound', 'parameters'=>'', 'comment'=>'Add a warning on partnership record if the backlink keyword is not found on the partner website.', 'frequency'=>1, 'unitfrequency'=>86400, 'status'=>0, 'test'=>'isModEnabled("partnership")', 'datestart'=>$datestart), ); // Permissions provided by this module diff --git a/htdocs/core/modules/modProduct.class.php b/htdocs/core/modules/modProduct.class.php index 9595226f701..9b0a3b1aa8b 100644 --- a/htdocs/core/modules/modProduct.class.php +++ b/htdocs/core/modules/modProduct.class.php @@ -68,7 +68,7 @@ class modProduct extends DolibarrModules // Dependencies $this->hidden = false; // A condition to hide module $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled - $this->requiredby = array("modStock", "modBarcode", "modProductBatch", "modVariants"); // List of module ids to disable if this one is disabled + $this->requiredby = array("modStock", "modBarcode", "modProductBatch", "modVariants", "modBom"); // List of module ids to disable if this one is disabled $this->conflictwith = array(); // List of module class names as string this module is in conflict with $this->phpmin = array(7, 0); // Minimum version of PHP required by module diff --git a/htdocs/core/modules/movement/doc/pdf_standard.modules.php b/htdocs/core/modules/movement/doc/pdf_standard.modules.php index d8daea8ff51..271c00a63f9 100644 --- a/htdocs/core/modules/movement/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/movement/doc/pdf_standard.modules.php @@ -37,32 +37,11 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; */ class pdf_standard extends ModelePDFMovement { - /** - * @var DoliDb Database handler - */ - public $db; - - /** - * @var string model description (short text) - */ - public $description; - /** * @var int Save the name of generated file as the main doc when generating a doc with this template */ public $update_main_doc_field; - /** - * @var string document type - */ - public $type; - - /** - * Dolibarr version of the loaded document - * @var string - */ - public $version = 'dolibarr'; - public $wref; public $posxidref; public $posxdatemouv; @@ -104,7 +83,6 @@ class pdf_standard extends ModelePDFMovement $this->marge_basse = getDolGlobalInt('MAIN_PDF_MARGIN_BOTTOM', 10); $this->option_logo = 1; // Display logo - $this->option_codestockservice = 0; // Display stock-service code $this->option_multilang = 1; // Available in several languages $this->option_freetext = 0; // Support add of a personalised text diff --git a/htdocs/core/modules/movement/modules_movement.php b/htdocs/core/modules/movement/modules_movement.php index 864f1bd4c7c..0525793a715 100644 --- a/htdocs/core/modules/movement/modules_movement.php +++ b/htdocs/core/modules/movement/modules_movement.php @@ -30,7 +30,26 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php'; */ abstract class ModelePDFMovement extends CommonDocGenerator { - public $option_codestockservice; + /** + * @var DoliDb Database handler + */ + public $db; + + /** + * @var string model description (short text) + */ + public $description; + + /** + * @var string document type + */ + public $type; + + /** + * Dolibarr version of the loaded document + * @var string + */ + public $version = 'dolibarr'; // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps diff --git a/htdocs/core/modules/project/doc/pdf_beluga.modules.php b/htdocs/core/modules/project/doc/pdf_beluga.modules.php index 0afff52ee73..a7cf4c50b96 100644 --- a/htdocs/core/modules/project/doc/pdf_beluga.modules.php +++ b/htdocs/core/modules/project/doc/pdf_beluga.modules.php @@ -88,10 +88,10 @@ class pdf_beluga extends ModelePDFProjects public $posxref; public $posxdate; - public $posxsociete; + public $posxsociety; public $posxamountht; public $posxamountttc; - public $posstatut; + public $posxstatut; /** @@ -156,10 +156,10 @@ class pdf_beluga extends ModelePDFProjects if ($this->page_largeur < 210) { // To work with US executive format $this->posxref -= 20; $this->posxdate -= 20; - $this->posxsociete -= 20; + $this->posxsociety -= 20; $this->posxamountht -= 20; $this->posxamountttc -= 20; - $this->posstatut -= 20; + $this->posxstatut -= 20; } } diff --git a/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php b/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php index 6311ab0f31b..d811d6c3b12 100644 --- a/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php +++ b/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php @@ -409,6 +409,13 @@ class doc_generic_proposal_odt extends ModelePDFPropales $array_soc = $this->get_substitutionarray_mysoc($mysoc, $outputlangs); $array_thirdparty = $this->get_substitutionarray_thirdparty($socobject, $outputlangs); $array_other = $this->get_substitutionarray_other($outputlangs); + + include_once DOL_DOCUMENT_ROOT.'/societe/class/companybankaccount.class.php'; + $companybankaccount = new CompanyBankAccount($this->db); + $companybankaccount->fetch(0, $object->thirdparty->id); + $array_objet['company_default_bank_iban']=$companybankaccount->iban; + $array_objet['company_default_bank_bic']=$companybankaccount->bic; + // retrieve contact information for use in object as contact_xxx tags $array_thirdparty_contact = array(); if ($usecontact && is_object($contactobject)) { diff --git a/htdocs/core/modules/stock/doc/pdf_standard.modules.php b/htdocs/core/modules/stock/doc/pdf_standard.modules.php index e951abb3622..35cf7c8e560 100644 --- a/htdocs/core/modules/stock/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/stock/doc/pdf_standard.modules.php @@ -38,32 +38,6 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; */ class pdf_standard extends ModelePDFStock { - /** - * @var DoliDb Database handler - */ - public $db; - - /** - * @var string model name - */ - public $name; - - /** - * @var string model description (short text) - */ - public $description; - - /** - * @var string document type - */ - public $type; - - /** - * Dolibarr version of the loaded document - * @var string - */ - public $version = 'dolibarr'; - public $wref; public $posxdesc; public $posxlabel; @@ -105,7 +79,6 @@ class pdf_standard extends ModelePDFStock $this->marge_basse = getDolGlobalInt('MAIN_PDF_MARGIN_BOTTOM', 10); $this->option_logo = 1; // Display logo - $this->option_codestockservice = 0; // Display product-service code $this->option_multilang = 1; // Available in several languages $this->option_freetext = 0; // Support add of a personalised text diff --git a/htdocs/core/modules/stock/modules_stock.php b/htdocs/core/modules/stock/modules_stock.php index 5966c27755c..e0acbea66e5 100644 --- a/htdocs/core/modules/stock/modules_stock.php +++ b/htdocs/core/modules/stock/modules_stock.php @@ -23,6 +23,32 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php'; */ abstract class ModelePDFStock extends CommonDocGenerator { + /** + * @var DoliDb Database handler + */ + public $db; + + /** + * @var string model name + */ + public $name; + + /** + * @var string model description (short text) + */ + public $description; + + /** + * @var string document type + */ + public $type; + + /** + * @var string Dolibarr version of the loaded document + */ + public $version = 'dolibarr'; + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of active generation modules diff --git a/htdocs/core/tpl/extrafields_list_search_param.tpl.php b/htdocs/core/tpl/extrafields_list_search_param.tpl.php index 7e58e106882..2ab5749b4e0 100644 --- a/htdocs/core/tpl/extrafields_list_search_param.tpl.php +++ b/htdocs/core/tpl/extrafields_list_search_param.tpl.php @@ -31,8 +31,14 @@ if (!empty($search_array_options) && is_array($search_array_options)) { // $extr $param .= '&'.$search_options_pattern.$tmpkey.'_endmin='.dol_print_date($val['end'], '%M'); $val = ''; } - if ($val != '') { - $param .= '&'.$search_options_pattern.$tmpkey.'='.urlencode($val); + if ($val !== '') { + if (is_array($val)) { + foreach ($val as $val2) { + $param .= '&'.$search_options_pattern.$tmpkey.'[]='.urlencode($val2); + } + } else { + $param .= '&'.$search_options_pattern.$tmpkey.'='.urlencode($val); + } } } } diff --git a/htdocs/don/class/don.class.php b/htdocs/don/class/don.class.php index c730c7d0b08..aad080fad2b 100644 --- a/htdocs/don/class/don.class.php +++ b/htdocs/don/class/don.class.php @@ -443,7 +443,6 @@ class Don extends CommonObject } } else { $this->error = $this->db->lasterror(); - $this->errno = $this->db->lasterrno(); $error++; } diff --git a/htdocs/emailcollector/class/emailcollector.class.php b/htdocs/emailcollector/class/emailcollector.class.php index af23d59698c..f20d21463af 100644 --- a/htdocs/emailcollector/class/emailcollector.class.php +++ b/htdocs/emailcollector/class/emailcollector.class.php @@ -1131,6 +1131,8 @@ class EmailCollector extends CommonObject if (!empty($conf->global->MAIN_IMAP_USE_PHPIMAP)) { if ($this->acces_type == 1) { // Mode OAUth2 with PHP-IMAP + $supportedoauth2array = array(); + require_once DOL_DOCUMENT_ROOT.'/core/lib/oauth.lib.php'; // define $supportedoauth2array $keyforsupportedoauth2array = $this->oauth_service; if (preg_match('/^.*-/', $keyforsupportedoauth2array)) { diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index 0392bc8c4eb..967b4e9a4fb 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -79,6 +79,11 @@ class Expedition extends CommonObject */ public $ismultientitymanaged = 1; + /** + * @var int Does object support extrafields ? 0=No, 1=Yes + */ + public $isextrafieldmanaged = 1; + /** * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png */ diff --git a/htdocs/exports/class/export.class.php b/htdocs/exports/class/export.class.php index ce232ee8c3b..17657431f9a 100644 --- a/htdocs/exports/class/export.class.php +++ b/htdocs/exports/class/export.class.php @@ -586,9 +586,10 @@ class Export * @param array $array_selected Filter on array of fields to export * @param array $array_filterValue Filter on array of fields with a filter * @param string $sqlquery If set, transmit the sql request for select (otherwise, sql request is generated from arrays) + * @param string $separator separator to fill $objmodel->separator with the new separator * @return int <0 if KO, >0 if OK */ - public function build_file($user, $model, $datatoexport, $array_selected, $array_filterValue, $sqlquery = '') + public function build_file($user, $model, $datatoexport, $array_selected, $array_filterValue, $sqlquery = '', $separator = '') { // phpcs:enable global $conf, $langs, $mysoc; @@ -612,6 +613,10 @@ class Export require_once $dir.$file; $objmodel = new $classname($this->db); + if (in_array($model, array('csvutf8', 'csviso')) && !empty($separator)) { + $objmodel->separator = $separator; + } + if (!empty($sqlquery)) { $sql = $sqlquery; } else { diff --git a/htdocs/exports/export.php b/htdocs/exports/export.php index 8fc16e43963..5b6116d153c 100644 --- a/htdocs/exports/export.php +++ b/htdocs/exports/export.php @@ -269,6 +269,7 @@ if ($step == 1 || $action == 'cleanselect') { } if ($action == 'builddoc') { + $separator = GETPOST('delimiter', 'alpha'); $max_execution_time_for_importexport = (empty($conf->global->EXPORT_MAX_EXECUTION_TIME) ? 300 : $conf->global->EXPORT_MAX_EXECUTION_TIME); // 5mn if not defined $max_time = @ini_get("max_execution_time"); if ($max_time && $max_time < $max_execution_time_for_importexport) { @@ -277,7 +278,7 @@ if ($action == 'builddoc') { } // Build export file - $result = $objexport->build_file($user, GETPOST('model', 'alpha'), $datatoexport, $array_selected, $array_filtervalue); + $result = $objexport->build_file($user, GETPOST('model', 'alpha'), $datatoexport, $array_selected, $array_filtervalue, '', $separator); if ($result < 0) { setEventMessages($objexport->error, $objexport->errors, 'errors'); $sqlusedforexport = $objexport->sqlusedforexport; diff --git a/htdocs/fourn/commande/list.php b/htdocs/fourn/commande/list.php index 58501c07246..22599d9eaba 100644 --- a/htdocs/fourn/commande/list.php +++ b/htdocs/fourn/commande/list.php @@ -1332,7 +1332,7 @@ if ($resql) { } print '
'; - print ''."\n"; + print '
'."\n"; print ''; // Action column diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index 5bed9183281..89db6a75f13 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -651,9 +651,6 @@ if (!empty($searchCategoryProductList)) { } } } -if ($search_status != '' && $search_status >= 0) { - $sql .= " AND f.fk_statut = ".((int) $search_status); -} if ($filter && $filter != -1) { $aFilter = explode(',', $filter); foreach ($aFilter as $fil) { diff --git a/htdocs/hrm/lib/hrm_job.lib.php b/htdocs/hrm/lib/hrm_job.lib.php index 599ee1c2871..47858460182 100644 --- a/htdocs/hrm/lib/hrm_job.lib.php +++ b/htdocs/hrm/lib/hrm_job.lib.php @@ -61,7 +61,7 @@ function jobPrepareHead($object) $head[$h][2] = 'skill_tab'; $h++; - $head[$h][0] = DOL_URL_ROOT."/hrm/position.php?fk_job=".$object->id; + $head[$h][0] = DOL_URL_ROOT."/hrm/position.php?id=".$object->id; $head[$h][1] = $langs->trans("PositionsWithThisProfile"); $nbResources = 0; $sql = "SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX."hrm_job_user WHERE fk_job = ".((int) $object->id); diff --git a/htdocs/hrm/skill_card.php b/htdocs/hrm/skill_card.php index 4b0659bfe5c..ab287ec115d 100644 --- a/htdocs/hrm/skill_card.php +++ b/htdocs/hrm/skill_card.php @@ -89,10 +89,14 @@ $upload_dir = $conf->hrm->multidir_output[isset($object->entity) ? $object->enti //if ($user->socid > 0) $socid = $user->socid; //$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0); //restrictedArea($user, $object->element, $object->id, $object->table_element, '', 'fk_soc', 'rowid', $isdraft); -if (empty($conf->hrm->enabled)) accessforbidden(); -if (!$permissiontoread || ($action === 'create' && !$permissiontoadd)) accessforbidden(); +if (empty($conf->hrm->enabled)) { + accessforbidden(); +} +if (!$permissiontoread || ($action === 'create' && !$permissiontoadd)) { + accessforbidden(); +} -$MaxNumberSkill = isset($conf->global->HRM_MAXRANK) ? $conf->global->HRM_MAXRANK : Skill::DEFAULT_MAX_RANK_PER_SKILL; +$MaxNumberSkill = getDolGlobalInt('HRM_MAXRANK', Skill::DEFAULT_MAX_RANK_PER_SKILL); /* @@ -167,7 +171,7 @@ if (empty($reshook)) { } // Actions to send emails - $triggersendname = 'hrm_SKILL_SENTBYMAIL'; + $triggersendname = 'HRM_SKILL_SENTBYMAIL'; $autocopy = 'MAIN_MAIL_AUTOCOPY_SKILL_TO'; $trackid = 'skill' . $object->id; include DOL_DOCUMENT_ROOT . '/core/actions_sendmails.inc.php'; @@ -182,7 +186,7 @@ $form = new Form($db); $formfile = new FormFile($db); $formproject = new FormProjets($db); -$title = $langs->trans("skill"); +$title = $langs->trans("Skill"); $help_url = ''; llxHeader('', $title, $help_url); @@ -468,9 +472,6 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea } } -//*---------------------------------------------------------------------------- -//*---------------------------------------------------------------------------- - //*--------------------------------------------------------------------------- @@ -589,27 +590,11 @@ if ($action != "create" && $action != "edit") { } else { $sql .= " WHERE 1 = 1 "; } + $sql .= " AND fk_skill = ".((int) $id); - if (!empty($id)) { - $sql .= " AND fk_skill = " . ((int) $id) . " "; - } - - // if total of record found is smaller than limit, no need to do paging and to restart another select with limits set. - if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit))) { - $num = $nbtotalofrecords; - } else { - if ($limit) { - $sql .= $db->plimit($limit + 1, $offset); - } - - $resql = $db->query($sql); - if (!$resql) { - dol_print_error($db); - exit; - } - - $num = $db->num_rows($resql); - } + $resql = $db->query($sql); + $nbtotalofrecords = $db->num_rows($resql); + $num = $db->num_rows($resql); print '' . "\n"; if ($optioncss != '') { diff --git a/htdocs/install/mysql/data/llx_10_c_regions.sql b/htdocs/install/mysql/data/llx_10_c_regions.sql index 84fbf7e006c..3a08a73fa6f 100644 --- a/htdocs/install/mysql/data/llx_10_c_regions.sql +++ b/htdocs/install/mysql/data/llx_10_c_regions.sql @@ -42,52 +42,52 @@ -- CONTENT ------------------------------------------------------------------- -- --- Algeria -> only for Departmements --- Andorra -> only for Departmements --- Angola -> only for Departmements +-- Algeria -> only for Departments/Counties +-- Andorra -> only for Departments/Counties +-- Angola -> only for Departments/Counties -- Argentina --- Australia -> only for Departmements --- Austria -> only for Departmements --- Barbados -> only for Departmements +-- Australia -> only for Departments/Counties +-- Austria -> only for Departments/Counties +-- Barbados -> only for Departments/Counties -- Belgium -- Bolivia --- Brazil -> only for Departmements +-- Brazil -> only for Departments/Counties -- Burundi --- Canada -> only for Departmements +-- Canada -> only for Departments/Counties -- Chile -- China --- Colombie -> only for Departmements +-- Colombie -> only for Departments/Counties -- Croatia -- Denmark -- France --- Germany -> only for Departmements +-- Germany -> only for Departments/Counties -- Greece --- Honduras -> only for Departmements +-- Honduras -> only for Departments/Counties -- Hungary --- India -> only for Departmements --- Indonesia -> only for Departmements +-- India -> only for Departments/Counties +-- Indonesia -> only for Departments/Counties -- Italy --- Japan -> only for Departmements +-- Japan -> only for Departments/Counties -- Luxembourg -- Mauritius --- Mexique -> only for Departmements +-- Mexique -> only for Departments/Counties -- Morocco --- Netherlands -> only for Departmements --- Panama -> only for Departmements +-- Netherlands -> only for Departments/Counties +-- Panama -> only for Departments/Counties -- Peru -- Portugal --- Romania -> only for Departmements +-- Romania -> only for Departments/Counties -- San Salvador -- Slovakia -- Slovenia -- Spain --- Switzerland/Suisse -> only for Departmements/Cantons --- Taiwan -> only for Departmements +-- Switzerland/Suisse -> only for Departments/Cantons +-- Taiwan -> only for Departments/Counties -- Tunesia -- Turkey --- United Arab Emirates -> only for Departmements +-- United Arab Emirates -> only for Departments/Counties -- United Kingdom --- USA -> only for Departmements +-- USA -> only for Departments/Counties -- Venezuela diff --git a/htdocs/install/mysql/migration/17.0.0-18.0.0.sql b/htdocs/install/mysql/migration/17.0.0-18.0.0.sql index 8bf51ea07b3..198daf1baef 100644 --- a/htdocs/install/mysql/migration/17.0.0-18.0.0.sql +++ b/htdocs/install/mysql/migration/17.0.0-18.0.0.sql @@ -60,6 +60,17 @@ ALTER TABLE llx_c_action_trigger ADD COLUMN contexts varchar(255) NULL; insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('PROJECT_CLOSE','Project closed','Executed when a project is closed','project',145); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('BILLREC_CREATE','Template invoices created','Executed when a Template invoices is created','facturerec',900); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('BILLREC_MODIFY','Template invoices update','Executed when a Template invoices is updated','facturerec',901); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('BILLREC_DELETE','Template invoices deleted','Executed when a Template invoices is deleted','facturerec',902); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('BILLREC_AUTOCREATEBILL','Template invoices use to create invoices with auto batch','Executed when a Template invoices is use to create invoice with auto batch','facturerec',903); + +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('PARTNERSHIP_CREATE','Partnership created','Executed when a partnership is created','partnership',58000); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('PARTNERSHIP_MODIFY','Partnership modified','Executed when a partnership is modified','partnership',58002); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('PARTNERSHIP_SENTBYMAIL','Mails sent from partnership file','Executed when you send email from partnership file','partnership',58004); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('PARTNERSHIP_DELETE','Partnership deleted','Executed when a partnership is deleted','partnership',58006); + + -- amount was removed in v12 ALTER TABLE llx_facture DROP COLUMN amount; diff --git a/htdocs/install/mysql/migration/18.0.0-19.0.0.sql b/htdocs/install/mysql/migration/18.0.0-19.0.0.sql index 447fc69a05d..cdebd4fc7c4 100644 --- a/htdocs/install/mysql/migration/18.0.0-19.0.0.sql +++ b/htdocs/install/mysql/migration/18.0.0-19.0.0.sql @@ -88,3 +88,7 @@ ALTER TABLE llx_societe DROP COLUMN skype; ALTER TABLE llx_prelevement_demande ADD INDEX idx_prelevement_demande_ext_payment_id (ext_payment_id); +ALTER TABLE llx_actioncomm ADD COLUMN fk_bookcal_availability integer DEFAULT NULL; + +ALTER TABLE llx_product_lot ADD COLUMN qc_frequency integer DEFAULT NULL; +ALTER TABLE llx_product_lot ADD COLUMN lifetime integer DEFAULT NULL; diff --git a/htdocs/install/mysql/tables/llx_actioncomm.sql b/htdocs/install/mysql/tables/llx_actioncomm.sql index a64513d5d9e..ba77e531f54 100644 --- a/htdocs/install/mysql/tables/llx_actioncomm.sql +++ b/htdocs/install/mysql/tables/llx_actioncomm.sql @@ -82,6 +82,8 @@ create table llx_actioncomm ip varchar(250), --ip used to create record (for public submission page) + fk_bookcal_availability integer DEFAULT NULL, --fk_bookcal_availability used to link booking to bookcal availability + import_key varchar(14), extraparams varchar(255) -- for other parameters with json format )ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_bookcal_availabilities-bookcal.sql b/htdocs/install/mysql/tables/llx_bookcal_availabilities-bookcal.sql index 786665a2545..738dea0090e 100644 --- a/htdocs/install/mysql/tables/llx_bookcal_availabilities-bookcal.sql +++ b/htdocs/install/mysql/tables/llx_bookcal_availabilities-bookcal.sql @@ -17,7 +17,6 @@ CREATE TABLE llx_bookcal_availabilities( -- BEGIN MODULEBUILDER FIELDS rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL, - ref varchar(128) NOT NULL, label varchar(255), description text, note_public text, @@ -32,7 +31,6 @@ CREATE TABLE llx_bookcal_availabilities( status integer NOT NULL, start date NOT NULL, end date NOT NULL, - type integer NOT NULL, duration integer DEFAULT 30 NOT NULL, startHour integer NOT NULL, endHour integer NOT NULL, diff --git a/htdocs/install/mysql/tables/llx_bookcal_booking-bookcal.key.sql b/htdocs/install/mysql/tables/llx_bookcal_booking-bookcal.key.sql deleted file mode 100644 index 5055cc59f1f..00000000000 --- a/htdocs/install/mysql/tables/llx_bookcal_booking-bookcal.key.sql +++ /dev/null @@ -1,28 +0,0 @@ --- Copyright (C) 2022 Alice Adminson --- --- 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 https://www.gnu.org/licenses/. - - --- BEGIN MODULEBUILDER INDEXES -ALTER TABLE llx_bookcal_booking ADD INDEX idx_bookcal_booking_rowid (rowid); -ALTER TABLE llx_bookcal_booking ADD INDEX idx_bookcal_booking_ref (ref); -ALTER TABLE llx_bookcal_booking ADD INDEX idx_bookcal_booking_fk_soc (fk_soc); -ALTER TABLE llx_bookcal_booking ADD INDEX idx_bookcal_booking_fk_project (fk_project); -ALTER TABLE llx_bookcal_booking ADD INDEX idx_bookcal_booking_status (status); --- END MODULEBUILDER INDEXES - ---ALTER TABLE llx_bookcal_booking ADD UNIQUE INDEX uk_bookcal_booking_fieldxy(fieldx, fieldy); - ---ALTER TABLE llx_bookcal_booking ADD CONSTRAINT llx_bookcal_booking_fk_field FOREIGN KEY (fk_field) REFERENCES llx_bookcal_myotherobject(rowid); - diff --git a/htdocs/install/mysql/tables/llx_bookcal_booking-bookcal.sql b/htdocs/install/mysql/tables/llx_bookcal_booking-bookcal.sql deleted file mode 100644 index 3457487aeb9..00000000000 --- a/htdocs/install/mysql/tables/llx_bookcal_booking-bookcal.sql +++ /dev/null @@ -1,41 +0,0 @@ --- Copyright (C) 2022 Alice Adminson --- --- 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 https://www.gnu.org/licenses/. - - -CREATE TABLE llx_bookcal_booking( - -- BEGIN MODULEBUILDER FIELDS - rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL, - ref varchar(128) NOT NULL, - fk_soc integer, - fk_project integer, - description text, - note_public text, - note_private text, - date_creation datetime NOT NULL, - tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - fk_user_creat integer, - fk_user_modif integer, - last_main_doc varchar(255), - import_key varchar(14), - model_pdf varchar(255), - status integer NOT NULL, - firstname varchar(128) NOT NULL, - lastname varchar(128) NOT NULL, - email varchar(128) NOT NULL, - start datetime NOT NULL, - duration integer NOT NULL, - fk_bookcal_availability integer NOT NULL - -- END MODULEBUILDER FIELDS -) ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_bookcal_calendar-bookcal.sql b/htdocs/install/mysql/tables/llx_bookcal_calendar-bookcal.sql index 061d3dbe01a..daf01d69999 100644 --- a/htdocs/install/mysql/tables/llx_bookcal_calendar-bookcal.sql +++ b/htdocs/install/mysql/tables/llx_bookcal_calendar-bookcal.sql @@ -29,6 +29,8 @@ CREATE TABLE llx_bookcal_calendar( fk_user_creat integer NOT NULL, fk_user_modif integer, import_key varchar(14), - status integer NOT NULL + status integer NOT NULL, + type integer NOT NULL, + visibility integer NOT NULL -- END MODULEBUILDER FIELDS ) ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_product_lot.sql b/htdocs/install/mysql/tables/llx_product_lot.sql index 4ab7e0865b1..cbd8c634b9a 100644 --- a/htdocs/install/mysql/tables/llx_product_lot.sql +++ b/htdocs/install/mysql/tables/llx_product_lot.sql @@ -29,6 +29,8 @@ CREATE TABLE llx_product_lot ( eol_date datetime NULL, manufacturing_date datetime NULL, -- date for first use of the lot scrapping_date datetime NULL, -- date when we decided to scrap all products of this lot + qc_frequency integer DEFAULT NULL, + lifetime integer DEFAULT NULL, barcode varchar(180) DEFAULT NULL, -- barcode fk_barcode_type integer DEFAULT NULL, -- barcode type model_pdf varchar(255), diff --git a/htdocs/install/repair.php b/htdocs/install/repair.php index e599dd336ab..8e0d3218df7 100644 --- a/htdocs/install/repair.php +++ b/htdocs/install/repair.php @@ -241,7 +241,7 @@ if ($ok && GETPOST('standard', 'alpha')) { 'fichinter'=>'fichinter', 'fichinterdet'=>'fichinterdet', 'inventory'=>'inventory', 'actioncomm'=>'actioncomm', 'bom_bom'=>'bom_bom', 'mrp_mo'=>'mrp_mo', - 'adherent_type'=>'adherent_type', 'user'=>'user', 'projet'=>'projet', 'projet_task'=>'projet_task', 'ticket'=>'ticket'); + 'adherent_type'=>'adherent_type', 'user'=>'user', 'partnershiap'=>'partnershiap', 'projet'=>'projet', 'projet_task'=>'projet_task', 'ticket'=>'ticket'); //$listofmodulesextra = array('fichinter'=>'fichinter'); print ''; diff --git a/htdocs/install/upgrade2.php b/htdocs/install/upgrade2.php index 0dadc7cb485..dfe1c7d9bc6 100644 --- a/htdocs/install/upgrade2.php +++ b/htdocs/install/upgrade2.php @@ -1951,7 +1951,7 @@ function migrate_price_commande_fournisseur($db, $langs, $conf) $commandeligne = new CommandeFournisseurLigne($db); $commandeligne->fetch($rowid); - $result = calcul_price_total($qty, $pu, $remise_percent, $vatrate, 0, 0, $remise_percent_global, 'HT', $info_bits, $commandeligne->product_type, $tmpsoc); + $result = calcul_price_total($qty, $pu, $remise_percent, $vatrate, 0, 0, $remise_percent_global, 'HT', $info_bits, $commandeligne->product_type, $mysoc); $total_ht = $result[0]; $total_tva = $result[1]; $total_ttc = $result[2]; @@ -4122,6 +4122,12 @@ function migrate_delete_old_files($db, $langs, $conf) '/core/menus/standard/auguria_frontoffice.php', '/core/menus/standard/eldy_backoffice.php', '/core/menus/standard/eldy_frontoffice.php', + '/core/modules/export/export_excel.modules.php', + '/core/modules/export/export_csv.modules.php', + '/core/modules/export/exportcsv.modules.php', + '/core/modules/export/export_excel2007new.modules.php', + '/core/modules/facture/pdf_crabe.modules.php', + '/core/modules/facture/pdf_oursin.modules.php', '/core/modules/mailings/contacts2.modules.php', '/core/modules/mailings/contacts3.modules.php', '/core/modules/mailings/contacts4.modules.php', @@ -4130,11 +4136,8 @@ function migrate_delete_old_files($db, $langs, $conf) '/core/modules/mailings/peche.modules.php', '/core/modules/mailings/poire.modules.php', '/core/modules/mailings/kiwi.modules.php', - '/core/modules/facture/pdf_crabe.modules.php', - '/core/modules/facture/pdf_oursin.modules.php', - '/core/modules/export/export_excel.modules.php', - '/core/modules/export/export_excel2007new.modules.php', '/core/boxes/box_members.php', + '/includes/restler/framework/Luracast/Restler/Data/Object.php', '/api/class/api_generic.class.php', '/asterisk/cidlookup.php', diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang index 2ba06c1c17c..af9fe858dfc 100644 --- a/htdocs/langs/en_US/accountancy.lang +++ b/htdocs/langs/en_US/accountancy.lang @@ -448,7 +448,7 @@ ConfirmMassDeleteBookkeepingWritingQuestion=This will delete the transaction fro ## Error SomeMandatoryStepsOfSetupWereNotDone=Some mandatory steps of setup was not done, please complete them -ErrorNoAccountingCategoryForThisCountry=No accounting account group available for country %s (See Home - Setup - Dictionaries) +ErrorNoAccountingCategoryForThisCountry=No accounting account group available for country %s (See %s - %s - %s) ErrorInvoiceContainsLinesNotYetBounded=You try to journalize some lines of the invoice %s, but some other lines are not yet bounded to accounting account. Journalization of all invoice lines for this invoice are refused. ErrorInvoiceContainsLinesNotYetBoundedShort=Some lines on invoice are not bound to accounting account. ExportNotSupported=The export format setuped is not supported into this page diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang index b50546183cb..2edd2d738fa 100644 --- a/htdocs/langs/en_US/bills.lang +++ b/htdocs/langs/en_US/bills.lang @@ -167,7 +167,7 @@ ActionsOnBill=Actions on invoice ActionsOnBillRec=Actions on recurring invoice RecurringInvoiceTemplate=Template / Recurring invoice NoQualifiedRecurringInvoiceTemplateFound=No recurring template invoice qualified for generation. -FoundXQualifiedRecurringInvoiceTemplate=Found %s recurring template invoice(s) qualified for generation. +FoundXQualifiedRecurringInvoiceTemplate=%s recurring template invoice(s) qualified for generation. NotARecurringInvoiceTemplate=Not a recurring template invoice NewBill=New invoice LastBills=Latest %s invoices diff --git a/htdocs/langs/en_US/cashdesk.lang b/htdocs/langs/en_US/cashdesk.lang index 9cde66460d3..3025d67d793 100644 --- a/htdocs/langs/en_US/cashdesk.lang +++ b/htdocs/langs/en_US/cashdesk.lang @@ -118,7 +118,7 @@ ScanToOrder=Scan QR code to order Appearance=Appearance HideCategoryImages=Hide Category Images HideProductImages=Hide Product Images -NumberOfLinesToShow=Number of lines of images to show +NumberOfLinesToShow=Maximum number of lines of text to show on thumb images DefineTablePlan=Define tables plan GiftReceiptButton=Add a "Gift receipt" button GiftReceipt=Gift receipt @@ -137,11 +137,11 @@ YearNotDefined=Year is not defined TakeposBarcodeRuleToInsertProduct=Barcode rule to insert product TakeposBarcodeRuleToInsertProductDesc=Rule to extract the product reference + a quantity from a scanned barcode.
If empty (default value), application will use the full barcode scanned to find the product.

If defined, syntax must be:
ref:NB+qu:NB+qd:NB+other:NB
where NB is the number of characters to use to extract data from the scanned barcode with:
  • ref : product reference
  • qu : quantity to set when inserting item (units)
  • qd : quantity to set when inserting item (decimals)
  • other : others characters
AlreadyPrinted=Already printed -HideCategories=Hide categories +HideCategories=Hide the whole section of categories selection HideStockOnLine=Hide stock on line ShowOnlyProductInStock=Show the products in stock ShowCategoryDescription=Show category description -ShowProductReference=Show reference of products +ShowProductReference=Show reference or label of products UsePriceHT=Use price excl. taxes and not price incl. taxes TerminalName=Terminal %s TerminalNameDesc=Terminal name diff --git a/htdocs/langs/en_US/knowledgemanagement.lang b/htdocs/langs/en_US/knowledgemanagement.lang index 050ecbcc03a..acf1bd62f11 100644 --- a/htdocs/langs/en_US/knowledgemanagement.lang +++ b/htdocs/langs/en_US/knowledgemanagement.lang @@ -39,6 +39,7 @@ KnowledgeManagementAboutPage = Knowledge Management about page KnowledgeManagementArea = Knowledge Management MenuKnowledgeRecord = Knowledge base +MenuKnowledgeRecordShort = Knowledge base ListKnowledgeRecord = List of articles NewKnowledgeRecord = New article ValidateReply = Validate solution diff --git a/htdocs/langs/en_US/partnership.lang b/htdocs/langs/en_US/partnership.lang index 105456dc719..31e2f5000bb 100644 --- a/htdocs/langs/en_US/partnership.lang +++ b/htdocs/langs/en_US/partnership.lang @@ -82,10 +82,10 @@ YourPartnershipRefusedTopic=Partnership refused YourPartnershipAcceptedTopic=Partnership accepted YourPartnershipCanceledTopic=Partnership canceled -YourPartnershipWillSoonBeCanceledContent=We inform you that your partnership will soon be canceled (Backlink not found) -YourPartnershipRefusedContent=We inform you that your partnership request has been refused. +YourPartnershipWillSoonBeCanceledContent=We would like to inform you that your partnership will soon be canceled (we did not get renewal or a prerequisite for our partnership is missing). Contact us by email if this is an error. +YourPartnershipRefusedContent=We inform you that your partnership request has been refused. May be a prerequisite is missing. Contact us if you need more information. YourPartnershipAcceptedContent=We inform you that your partnership request has been accepted. -YourPartnershipCanceledContent=We inform you that your partnership has been canceled. +YourPartnershipCanceledContent=We inform you that your partnership has been canceled. May be a prerequisite is missing. Contact us if you need more information. CountLastUrlCheckError=Number of errors for last URL check LastCheckBacklink=Date of last URL check diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 35ba6c86eae..7e89129cdd7 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -1735,7 +1735,7 @@ function top_htmlhead($head, $title = '', $disablejs = 0, $disablehead = 0, $arr } // Refresh value of MAIN_IHM_PARAMS_REV before forging the parameter line. if (GETPOST('dol_resetcache')) { - dolibarr_set_const($db, "MAIN_IHM_PARAMS_REV", ((int) $conf->global->MAIN_IHM_PARAMS_REV) + 1, 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_IHM_PARAMS_REV", getDolGlobalInt('MAIN_IHM_PARAMS_REV') + 1, 'chaine', 0, '', $conf->entity); } $themeparam = '?lang='.$langs->defaultlang.'&theme='.$conf->theme.(GETPOST('optioncss', 'aZ09') ? '&optioncss='.GETPOST('optioncss', 'aZ09', 1) : '').(empty($user->id) ? '' : ('&userid='.$user->id)).'&entity='.$conf->entity; diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index d7b833bad82..d3f8ee41052 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -1903,7 +1903,9 @@ if ($dirins && $action == 'confirm_deleteobject' && $objectname) { // check if documentation has been generated $file_doc = $dirins.'/'.strtolower($module).'/doc/Documentation.asciidoc'; - deletePropsFromDoc($file_doc, $objectname); + if (file_exists($file_doc)) { + deletePropsAndPermsFromDoc($file_doc, $objectname); + } clearstatcache(true); if (function_exists('opcache_invalidate')) { diff --git a/htdocs/modulebuilder/template/myobject_document.php b/htdocs/modulebuilder/template/myobject_document.php index d7eafaa78a3..8b97342da44 100644 --- a/htdocs/modulebuilder/template/myobject_document.php +++ b/htdocs/modulebuilder/template/myobject_document.php @@ -22,24 +22,26 @@ * \brief Tab for documents linked to MyObject */ -//if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); // Do not create database handler $db -//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('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('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). This include the NOIPCHECK too. -//if (! defined('NOIPCHECK')) define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip -//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("MAIN_SECURITY_FORCECSP")) define('MAIN_SECURITY_FORCECSP', 'none'); // Disable all Content Security Policies -//if (! defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN', '1'); // Force use of CSRF protection with tokens even for GET -//if (! defined('NOBROWSERNOTIF')) define('NOBROWSERNOTIF', '1'); // Disable browser notification +// General defined Options +//if (! defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN', '1'); // Force use of CSRF protection with tokens even for GET +//if (! defined('MAIN_AUTHENTICATION_MODE')) define('MAIN_AUTHENTICATION_MODE', 'aloginmodule'); // Force authentication handler +//if (! defined('MAIN_LANG_DEFAULT')) define('MAIN_LANG_DEFAULT', 'auto'); // Force LANG (language) to a particular value +//if (! defined('MAIN_SECURITY_FORCECSP')) define('MAIN_SECURITY_FORCECSP', 'none'); // Disable all Content Security Policies +//if (! defined('NOBROWSERNOTIF')) define('NOBROWSERNOTIF', '1'); // Disable browser notification +//if (! defined('NOIPCHECK')) define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip +//if (! defined('NOLOGIN')) define('NOLOGIN', '1'); // Do not use login - if this page is public (can be called outside logged session). This includes the NOIPCHECK too. +//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); // Do not load ajax.lib.php library +//if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); // Do not create database handler $db +//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); // Do not load html.form.class.php +//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // Do not load and show top and left menu +//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); // Do not load object $mysoc +//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); // Do not load object $langs +//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); // Do not load object $user +//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('NOSTYLECHECK')) define('NOSTYLECHECK', '1'); // Do not check style html tag into posted data +//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on) + // Load Dolibarr environment $res = 0; @@ -82,13 +84,12 @@ dol_include_once('/mymodule/lib/mymodule_myobject.lib.php'); // Load translation files required by the page $langs->loadLangs(array("mymodule@mymodule", "companies", "other", "mails")); - -$action = GETPOST('action', 'aZ09'); +// Get parameters +$action = GETPOST('action', 'aZ09'); $confirm = GETPOST('confirm'); -$id = (GETPOST('socid', 'int') ? GETPOST('socid', 'int') : GETPOST('id', 'int')); +$id = (GETPOST('socid', 'int') ? GETPOST('socid', 'int') : GETPOST('id', 'int')); $ref = GETPOST('ref', 'alpha'); -// Get parameters $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); @@ -112,6 +113,7 @@ $object = new MyObject($db); $extrafields = new ExtraFields($db); $diroutputmassaction = $conf->mymodule->dir_output.'/temp/massgeneration/'.$user->id; $hookmanager->initHooks(array($object->element.'document', 'globalcard')); // Note that conf->hooks_modules contains array + // Fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); @@ -122,15 +124,16 @@ if ($id > 0 || !empty($ref)) { $upload_dir = $conf->mymodule->multidir_output[$object->entity ? $object->entity : $conf->entity]."/myobject/".get_exdir(0, 0, 0, 1, $object); } -// There is several ways to check permission. +// Permissions +// (There are several ways to check permission.) // Set $enablepermissioncheck to 1 to enable a minimum low level of checks $enablepermissioncheck = 0; if ($enablepermissioncheck) { $permissiontoread = $user->rights->mymodule->myobject->read; - $permissiontoadd = $user->rights->mymodule->myobject->write; // Used by the include of actions_addupdatedelete.inc.php and actions_linkedfiles.inc.php + $permissiontoadd = $user->rights->mymodule->myobject->write; // Used by the include of actions_addupdatedelete.inc.php and actions_linkedfiles.inc.php } else { $permissiontoread = 1; - $permissiontoadd = 1; + $permissiontoadd = 1; } // Security check (enable the most restrictive one) @@ -163,10 +166,12 @@ include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; $form = new Form($db); +// Header +// ------ $title = $langs->trans("MyObject")." - ".$langs->trans("Files"); //$title = $object->ref." - ".$langs->trans("Files"); $help_url = ''; -//$help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; +//Example $help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; llxHeader('', $title, $help_url); // Show tabs diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php index 03976b562b0..a174dc9ffad 100644 --- a/htdocs/modulebuilder/template/myobject_list.php +++ b/htdocs/modulebuilder/template/myobject_list.php @@ -87,6 +87,7 @@ require_once __DIR__.'/class/myobject.class.php'; // Load translation files required by the page $langs->loadLangs(array("mymodule@mymodule", "other")); +// Get parameters $action = GETPOST('action', 'aZ09') ? GETPOST('action', 'aZ09') : 'view'; // The action 'create'/'add', 'edit'/'update', 'view', ... $massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists) $show_files = GETPOST('show_files', 'int'); // Show files area generated by bulk actions ? @@ -755,7 +756,7 @@ while ($i < $imaxinloop) { if (!empty($arrayfields['t.'.$key]['checked'])) { print '$key)) { + if (preg_match('/tdoverflow/', $cssforfield) && !in_array($val['type'], array('ip', 'url')) && !is_numeric($object->$key)) { print ' title="'.dol_escape_htmltag($object->$key).'"'; } print '>'; diff --git a/htdocs/opensurvey/css/style.css b/htdocs/opensurvey/css/style.css index e7f0d279a14..b4b2b69514a 100644 --- a/htdocs/opensurvey/css/style.css +++ b/htdocs/opensurvey/css/style.css @@ -363,7 +363,7 @@ div.cadre td.ok { } /*Case de tableau NON dans affichage de sondage*/ div.cadre td.non { - background-color: #FF7777; + background-color: #FFBBBB; min-width: 60px; } /*Case de tableau VIDE dans affichage de sondage*/ diff --git a/htdocs/opensurvey/results.php b/htdocs/opensurvey/results.php index d9191278edd..764ca877c58 100644 --- a/htdocs/opensurvey/results.php +++ b/htdocs/opensurvey/results.php @@ -331,7 +331,7 @@ for ($i = 0; $i < $nbcolonnes; $i++) { if ((GETPOST("effacecolonne".$i) || GETPOST("effacecolonne".$i."_x") || GETPOST("effacecolonne".$i.".x")) && $nbcolonnes > 1) { // effacecolonnei for chrome, effacecolonnei_x for firefox // Security check - if (!$user->rights->opensurvey->write) { + if (!$user->hasRight('opensurvey', 'write')) { accessforbidden(); } @@ -673,7 +673,7 @@ print ''; print '
'."\n"; // Start to show survey result -print '

*** Check fields into extra table structure match table of definition. If not add column into table
'."\n"; +print '
'."\n"; //reformatage des données des sujets du sondage $toutsujet = explode(",", $object->sujet); @@ -684,9 +684,9 @@ print ''."\n"; print ''."\n"; // loop to show the delete link -if ($user->rights->opensurvey->write) { +if ($user->hasRight('opensurvey', 'write')) { for ($i = 0; isset($toutsujet[$i]); $i++) { - print ''."\n"; + print ''."\n"; } } diff --git a/htdocs/opensurvey/wizard/choix_date.php b/htdocs/opensurvey/wizard/choix_date.php index d8f89b18e16..62e262ca6f9 100644 --- a/htdocs/opensurvey/wizard/choix_date.php +++ b/htdocs/opensurvey/wizard/choix_date.php @@ -179,6 +179,7 @@ if (GETPOST('confirmation')) { // Add survey into database if (!$erreur && $erreurNb == 0) { $_SESSION["toutchoix"] = substr("$choixdate", 1); + unset($_SESSION["nbrecaseshoraires"]); ajouter_sondage(); } @@ -215,10 +216,22 @@ llxHeader('', $langs->trans("OpenSurvey"), "", '', 0, 0, $arrayofjs, $arrayofcss //nombre de cases par défaut if (!isset($_SESSION["nbrecaseshoraires"])) { $_SESSION["nbrecaseshoraires"] = 5; -} elseif (GETPOST('ajoutcases') && $_SESSION["nbrecaseshoraires"] == 5) { +} elseif ((GETPOST('ajoutcases') || GETPOST("ajoutcases_y")) && $_SESSION["nbrecaseshoraires"] == 5) { $_SESSION["nbrecaseshoraires"] = 10; + //On sauvegarde les heures deja entrées + if (issetAndNoEmpty('totalchoixjour', $_SESSION) === true) { + $nbofchoice = count($_SESSION["totalchoixjour"]); + for ($i = 0; $i < $nbofchoice; $i++) { + //affichage des 5 cases horaires + for ($j = 0; $j < $_SESSION["nbrecaseshoraires"]; $j++) { + $horairesi = GETPOST("horaires".$i); + $_SESSION["horaires$i"][$j] = $horairesi[$j]; + } + } + } } + //valeurs de la date du jour actuel $jourAJ = date("j"); $moisAJ = date("n"); @@ -347,11 +360,13 @@ print ''."\n"; print '
'."\n"; print '
'."\n"; print '
'."\n"; // The div class=center has no effect on table, so we must keep the align=center for table -print ''; -print ''; -print ''; +print ''; +print ''; +print ''; +print ''."\n"; print '
'.$motmois.' '.$_SESSION["annee"].'
'; -print ''; -print '
'; +print '
'.$motmois.' '.$_SESSION["annee"].'
'; +print ''; +print '
'; print '
'."\n"; print '
'."\n"; @@ -407,7 +422,7 @@ if (issetAndNoEmpty('choixjourajout')) { $k = $i + 1; if (issetAndNoEmpty('horaires'.$i) === true && issetAndNoEmpty($i, $_POST['horaires'.$i]) === true) { for ($j = 0; $j < $_SESSION["nbrecaseshoraires"]; $j++) { - $horairesi = GETPOST("horaires".$i); + $horairesi = GETPOST("horaires".$i, 'array'); $_SESSION["horaires$i"][$j] = $horairesi[$j]; } } @@ -452,7 +467,7 @@ if (issetAndNoEmpty('reporterhoraires')) { } } -//report des horaires dans toutes les cases +//effacer les horaires dans toutes les cases if (issetAndNoEmpty('resethoraires')) { $nbofchoice = count($_SESSION["totalchoixjour"]); for ($i = 0; $i < $nbofchoice; $i++) { @@ -480,7 +495,7 @@ for ($i = 0; $i < $nbrejourmois + $premierjourmois; $i++) { for ($j = 0; $j < $nbofchoice; $j++) { // show red buttons if (date("j", $_SESSION["totalchoixjour"][$j]) == $numerojour && date("n", $_SESSION["totalchoixjour"][$j]) == $_SESSION["mois"] && date("Y", $_SESSION["totalchoixjour"][$j]) == $_SESSION["annee"]) { - print '
'.$numerojour.''.$numerojour.'
'.dol_print_date($_SESSION["totalchoixjour"][$i], 'daytext').' ('.dol_print_date($_SESSION["totalchoixjour"][$i], '%A').')'.dol_print_date($_SESSION["totalchoixjour"][$i], 'daytext').' ('.dol_print_date($_SESSION["totalchoixjour"][$i], '%A').')
'."\n"; print ''."\n"; - print ''."\n"; + print ''; + print ''; + print ''."\n"; print''."\n"; print ''."\n"; print '


'."\n"; diff --git a/htdocs/opensurvey/wizard/index.php b/htdocs/opensurvey/wizard/index.php index 4542ecfa3bd..ef7a35dd303 100644 --- a/htdocs/opensurvey/wizard/index.php +++ b/htdocs/opensurvey/wizard/index.php @@ -2,7 +2,7 @@ /* Copyright (C) 2013 Laurent Destailleur * Copyright (C) 2014 Marcos García * Copyright (C) 2016 Regis Houssin - * Copyright (C) 2019 Frédéric France + * Copyright (C) 2019 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 @@ -55,13 +55,18 @@ print '
'; print '
'; print '
'; print '
'; -print ''; +print ''; print '
'; print '
'; print '
'; -print ''; +print ''; print '
'; print '
'; +print '
'; print '
'; print '
'; diff --git a/htdocs/partnership/class/partnership.class.php b/htdocs/partnership/class/partnership.class.php index bb71d053dfe..871ddfaff2d 100644 --- a/htdocs/partnership/class/partnership.class.php +++ b/htdocs/partnership/class/partnership.class.php @@ -120,11 +120,11 @@ class Partnership extends CommonObject 'model_pdf' => array('type'=>'varchar(255)', 'label'=>'Model pdf', 'enabled'=>'1', 'position'=>1010, 'notnull'=>-1, 'visible'=>0,), 'date_partnership_start' => array('type'=>'date', 'label'=>'DatePartnershipStart', 'enabled'=>'1', 'position'=>52, 'notnull'=>1, 'visible'=>1,), 'date_partnership_end' => array('type'=>'date', 'label'=>'DatePartnershipEnd', 'enabled'=>'1', 'position'=>53, 'notnull'=>0, 'visible'=>1,), - 'url_to_check' => array('type'=>'varchar(255)', 'label'=>'UrlToCheck', 'enabled'=>'1', 'position'=>70, 'notnull'=>0, 'visible'=>-1,), + 'url_to_check' => array('type'=>'url', 'label'=>'UrlToCheck', 'enabled'=>'1', 'position'=>70, 'notnull'=>0, 'visible'=>-1, 'csslist'=>'tdoverflowmax150'), 'count_last_url_check_error' => array('type'=>'integer', 'label'=>'CountLastUrlCheckError', 'enabled'=>'1', 'position'=>71, 'notnull'=>0, 'visible'=>-2, 'default'=>'0',), 'last_check_backlink' => array('type'=>'datetime', 'label'=>'LastCheckBacklink', 'enabled'=>'1', 'position'=>72, 'notnull'=>0, 'visible'=>-2,), 'reason_decline_or_cancel' => array('type'=>'text', 'label'=>'ReasonDeclineOrCancel', 'enabled'=>'1', 'position'=>73, 'notnull'=>0, 'visible'=>-2,), - 'ip' => array('type'=>'varchar(250)', 'label'=>'Ip', 'enabled'=>'1', 'position'=>74, 'notnull'=>0, 'visible'=>-2,), + 'ip' => array('type'=>'ip', 'label'=>'Ip', 'enabled'=>'1', 'position'=>74, 'notnull'=>0, 'visible'=>-2,), 'status' => array('type'=>'smallint', 'label'=>'Status', 'enabled'=>'1', 'position'=>2000, 'notnull'=>1, 'visible'=>2, 'default'=>'0', 'index'=>1, 'arrayofkeyval'=>array('0'=>'Draft', '1'=>'Accepted', '2'=>'Refused', '8'=>'Suspended', '9'=>'Terminated'),), ); public $rowid; diff --git a/htdocs/partnership/class/partnershiputils.class.php b/htdocs/partnership/class/partnershiputils.class.php index 86722ed1da2..c73bc4230d4 100644 --- a/htdocs/partnership/class/partnershiputils.class.php +++ b/htdocs/partnership/class/partnershiputils.class.php @@ -233,6 +233,8 @@ class PartnershipUtils $this->output = ''; $this->error = ''; $partnershipsprocessed = array(); + $emailnotfound = ''; + $websitenotfound = ''; $gracedelay = $conf->global->PARTNERSHIP_NBDAYS_AFTER_MEMBER_EXPIRATION_BEFORE_CANCEL; if ($gracedelay < 1) { @@ -251,21 +253,16 @@ class PartnershipUtils $sql = "SELECT p.rowid, p.status, p.".$fk_partner; $sql .= ", p.last_check_backlink"; - $sql .= ', partner.url, partner.email'; - $sql .= " FROM ".MAIN_DB_PREFIX."partnership as p"; - if ($managedfor == 'member') { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."adherent as partner on (partner.rowid = p.fk_member)"; } else { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as partner on (partner.rowid = p.fk_soc)"; } - - $sql .= " WHERE 1 = 1"; - $sql .= " AND p.".$fk_partner." > 0"; - $sql .= " AND p.status = ".((int) $partnership::STATUS_APPROVED); // Only accepted not yet canceled - $sql .= " AND (p.last_check_backlink IS NULL OR p.last_check_backlink <= '".$this->db->idate($now - 7 * 24 * 3600)."')"; // Every week, check that website contains a link to dolibarr. + $sql .= " WHERE p.".$fk_partner." > 0"; + $sql .= " AND p.status = ".((int) $partnership::STATUS_APPROVED); // Only accepted and not yet canceled + $sql .= " AND (p.last_check_backlink IS NULL OR p.last_check_backlink <= '".$this->db->idate($now - 24 * 3600)."')"; // Never more than 1 check every day to check that website contains a referal link. $sql .= $this->db->order('p.rowid', 'ASC'); // Limit is managed into loop later @@ -274,7 +271,6 @@ class PartnershipUtils $numofexpiredmembers = $this->db->num_rows($resql); $somethingdoneonpartnership = 0; $ifetchpartner = 0; - $websitenotfound = ''; while ($ifetchpartner < $numofexpiredmembers) { $ifetchpartner++; @@ -376,18 +372,16 @@ class PartnershipUtils if (!$error) { $this->db->commit(); - $this->output = $numofexpiredmembers.' partnership checked'."\n"; - if ($erroremail) $this->output .= '. Got errors when sending some email : '.$erroremail."\n"; - if ($emailnotfound) $this->output .= '. Email not found for some partner : '.$emailnotfound."\n"; - if ($websitenotfound) $this->output .= '. Website not found for some partner : '.$websitenotfound."\n"; + $this->output = ""; } else { $this->db->rollback(); $this->output = "Rollback after error\n"; - $this->output .= $numofexpiredmembers.' partnership checked'."\n"; - if ($erroremail) $this->output .= '. Got errors when sending some email : '.$erroremail."\n"; - if ($emailnotfound) $this->output .= '. Email not found for some partner : '.$emailnotfound."\n"; - if ($websitenotfound) $this->output .= '. Website not found for some partner : '.$websitenotfound."\n"; } + $this->output .= $numofexpiredmembers.' partnership checked'."\n"; + if ($erroremail) $this->output .= '. Got errors when sending some email : '.$erroremail."\n"; + if ($emailnotfound) $this->output .= '. Email not found for some partner : '.$emailnotfound."\n"; + if ($websitenotfound) $this->output .= '. Website not found for some partner : '.$websitenotfound."\n"; + $this->output .= "\nSQL used to find partnerships to scan: ".$sql; return ($error ? 1 : 0); } diff --git a/htdocs/partnership/core/modules/partnership/mod_partnership_advanced.php b/htdocs/partnership/core/modules/partnership/mod_partnership_advanced.php index 821a9e67303..c3b3a888b54 100644 --- a/htdocs/partnership/core/modules/partnership/mod_partnership_advanced.php +++ b/htdocs/partnership/core/modules/partnership/mod_partnership_advanced.php @@ -3,7 +3,7 @@ * Copyright (C) 2004-2007 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2008 Raphael Bertrand (Resultic) - * Copyright (C) 2019 Frédéric France + * Copyright (C) 2019-2023 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 @@ -26,7 +26,7 @@ * \brief File containing class for advanced numbering model of Partnership */ -dol_include_once('/partnership/core/modules/partnership/modules_partnership.php'); +require_once DOL_DOCUMENT_ROOT.'/partnership/core/modules/partnership/modules_partnership.php'; /** @@ -54,22 +54,23 @@ class mod_partnership_advanced extends ModeleNumRefPartnership /** * Returns the description of the numbering model * + * @param Translate $langs Lang object to use for output * @return string Descriptive text */ - public function info() + public function info($langs) { - global $conf, $langs, $db; + global $db; $langs->load("bills"); $form = new Form($db); - $texte = $langs->trans('GenericNumRefModelDesc')."
\n"; - $texte .= '
'; - $texte .= ''; - $texte .= ''; - $texte .= ''; - $texte .= ''; + $text = $langs->trans('GenericNumRefModelDesc')."
\n"; + $text .= ''; + $text .= ''; + $text .= ''; + $text .= ''; + $text .= '
'; $tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("Partnership"), $langs->transnoentities("Partnership")); $tooltip .= $langs->trans("GenericMaskCodes2"); @@ -78,17 +79,17 @@ class mod_partnership_advanced extends ModeleNumRefPartnership $tooltip .= $langs->trans("GenericMaskCodes5"); // Parametrage du prefix - $texte .= ''; - $texte .= ''; + $text .= ''; + $text .= ''; - $texte .= ''; + $text .= ''; - $texte .= ''; + $text .= ''; - $texte .= '
'.$langs->trans("Mask").':'.$form->textwithpicto('', $tooltip, 1, 1).'
'.$langs->trans("Mask").':'.$form->textwithpicto('', $tooltip, 1, 1).'   
'; - $texte .= '
'; + $text .= ''; + $text .= ''; - return $texte; + return $text; } /** diff --git a/htdocs/partnership/core/modules/partnership/mod_partnership_standard.php b/htdocs/partnership/core/modules/partnership/mod_partnership_standard.php index 5de4b07f215..c7409aba85e 100644 --- a/htdocs/partnership/core/modules/partnership/mod_partnership_standard.php +++ b/htdocs/partnership/core/modules/partnership/mod_partnership_standard.php @@ -22,7 +22,7 @@ * \ingroup partnership * \brief File of class to manage Partnership numbering rules standard */ -dol_include_once('/partnership/core/modules/partnership/modules_partnership.php'); +require_once DOL_DOCUMENT_ROOT.'/partnership/core/modules/partnership/modules_partnership.php'; /** @@ -52,11 +52,11 @@ class mod_partnership_standard extends ModeleNumRefPartnership /** * Return description of numbering module * - * @return string Text with description + * @param Translate $langs Lang object to use for output + * @return string Text with description */ - public function info() + public function info($langs) { - global $langs; return $langs->trans("SimpleNumRefModelDesc", $this->prefix); } diff --git a/htdocs/partnership/core/modules/partnership/modules_partnership.php b/htdocs/partnership/core/modules/partnership/modules_partnership.php index 4d1f6c0b107..dafab0cc8ed 100644 --- a/htdocs/partnership/core/modules/partnership/modules_partnership.php +++ b/htdocs/partnership/core/modules/partnership/modules_partnership.php @@ -29,6 +29,7 @@ */ require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/commonnumrefgenerator.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // required for use by classes that inherit @@ -66,93 +67,7 @@ abstract class ModelePDFPartnership extends CommonDocGenerator /** * Parent class to manage numbering of Partnership */ -abstract class ModeleNumRefPartnership +abstract class ModeleNumRefPartnership extends CommonNumRefGenerator { - /** - * @var string Error code (or message) - */ - public $error = ''; - - /** - * Return if a module can be used or not - * - * @return boolean true if module can be used - */ - public function isEnabled() - { - return true; - } - - /** - * Returns the default description of the numbering template - * - * @return string Descriptive text - */ - public function info() - { - global $langs; - $langs->load("partnership"); - return $langs->trans("NoDescription"); - } - - /** - * Returns an example of numbering - * - * @return string Example - */ - public function getExample() - { - global $langs; - $langs->load("partnership"); - return $langs->trans("NoExample"); - } - - /** - * Checks if the numbers already in the database do not - * cause conflicts that would prevent this numbering working. - * - * @param Object $object Object we need next value for - * @return boolean false if conflict, true if ok - */ - public function canBeActivated($object) - { - return true; - } - - /** - * Returns next assigned value - * - * @param Object $object Object we need next value for - * @return string Valeur - */ - public function getNextValue($object) - { - global $langs; - return $langs->trans("NotAvailable"); - } - - /** - * Returns version of numbering module - * - * @return string Valeur - */ - public function getVersion() - { - global $langs; - $langs->load("admin"); - - if ($this->version == 'development') { - return $langs->trans("VersionDevelopment"); - } - if ($this->version == 'experimental') { - return $langs->trans("VersionExperimental"); - } - if ($this->version == 'dolibarr') { - return DOL_VERSION; - } - if ($this->version) { - return $this->version; - } - return $langs->trans("NotAvailable"); - } + // No overload code } diff --git a/htdocs/partnership/partnership_list.php b/htdocs/partnership/partnership_list.php index 98d78e0a2b2..27821a2b799 100644 --- a/htdocs/partnership/partnership_list.php +++ b/htdocs/partnership/partnership_list.php @@ -914,7 +914,7 @@ while ($i < $imaxinloop) { if (!empty($arrayfields['t.'.$key]['checked'])) { print '$key)) { + if (preg_match('/tdoverflow/', $cssforfield) && !in_array($val['type'], array('ip', 'url')) && !is_numeric($object->$key)) { print ' title="'.dol_escape_htmltag($object->$key).'"'; } print '>'; diff --git a/htdocs/paypal/lib/paypal.lib.php b/htdocs/paypal/lib/paypal.lib.php index 79003956f12..db949620440 100644 --- a/htdocs/paypal/lib/paypal.lib.php +++ b/htdocs/paypal/lib/paypal.lib.php @@ -145,7 +145,7 @@ function print_paypal_redirect($paymentAmount, $currencyCodeType, $paymentType, $ErrorSeverityCode = urldecode($resArray["L_SEVERITYCODE0"]); if ($ErrorCode == 10729) { - $mesg .= "PayPal can't accept payments for this thirdparty. An address is defined but is not complete (missing State).
Ask system administrator to fix address or to setup Paypal module to accept payments even on not complete addresses (remove option PAYPAL_REQUIRE_VALID_SHIPPING_ADDRESS).
\n"; + $mesg = "PayPal can't accept payments for this thirdparty. An address is defined but is not complete (missing State).
Ask system administrator to fix address or to setup Paypal module to accept payments even on not complete addresses (remove option PAYPAL_REQUIRE_VALID_SHIPPING_ADDRESS).
\n"; } else { $mesg = $langs->trans('SetExpressCheckoutAPICallFailed')."
\n"; $mesg .= $langs->trans('DetailedErrorMessage').": ".$ErrorLongMsg."
\n"; diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 28b30d38dc4..a10e9d1bb75 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -2063,7 +2063,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { // Default warehouse print ''.$langs->trans("DefaultWarehouse").''; print img_picto($langs->trans("DefaultWarehouse"), 'stock', 'class="pictofixedwidth"'); - print $formproduct->selectWarehouses((GETPOSTISSET('fk_default_warehouse') ? GETPOST('fk_default_warehouse') : $object->fk_default_warehouse), 'fk_default_warehouse', 'warehouseopen', 1); + print $formproduct->selectWarehouses((GETPOSTISSET('fk_default_warehouse') ? GETPOST('fk_default_warehouse') : $object->fk_default_warehouse), 'fk_default_warehouse', 'warehouseopen', 1, 0, 0, '', 0, 0, array(), 'maxwidth500 widthcentpercentminusxx'); print ' '; print ''; print ''; diff --git a/htdocs/product/list.php b/htdocs/product/list.php index 91f4d123f09..4028726096a 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -1270,7 +1270,7 @@ if (!empty($arrayfields['p.duration']['checked'])) { $totalarray['nbfield']++; } if (!empty($arrayfields['pac.fk_product_parent']['checked'])) { - print_liste_field_titre($arrayfields['pac.fk_product_parent']['label'], $_SERVER["PHP_SELF"], "pac.fk_product_parent", "", $param, '', $sortfield, $sortorder, '', $arrayfields['pac.fk_product_parent']['help']); + print_liste_field_titre($arrayfields['pac.fk_product_parent']['label'], $_SERVER["PHP_SELF"], "pac.fk_product_parent", "", $param, '', $sortfield, $sortorder, '', empty($arrayfields['pac.fk_product_parent']['help']) ? '' : $arrayfields['pac.fk_product_parent']['help']); } if (!empty($arrayfields['p.finished']['checked'])) { print_liste_field_titre($arrayfields['p.finished']['label'], $_SERVER["PHP_SELF"], "p.finished", "", $param, '', $sortfield, $sortorder, 'center '); diff --git a/htdocs/product/stock/class/productlot.class.php b/htdocs/product/stock/class/productlot.class.php index 815d0af1a50..ba38a96c220 100644 --- a/htdocs/product/stock/class/productlot.class.php +++ b/htdocs/product/stock/class/productlot.class.php @@ -106,11 +106,12 @@ class Productlot extends CommonObject 'batch' => array('type'=>'varchar(30)', 'label'=>'Batch', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'comment'=>'Batch', 'searchall'=>1, 'picto'=>'lot'), 'entity' => array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'default'=>1, 'notnull'=>1, 'index'=>1, 'position'=>20), 'sellby' => array('type'=>'date', 'label'=>'SellByDate', 'enabled'=>'empty($conf->global->PRODUCT_DISABLE_SELLBY)?1:0', 'visible'=>5, 'position'=>60), - 'eol_date' => array('type'=>'date', 'label'=>'EndOfLife', 'enabled'=>'empty($conf->global->PRODUCT_ENABLE_TRACEABILITY)?0:1', 'visible'=>5, 'position'=>70), - 'manufacturing_date' => array('type'=>'date', 'label'=>'ManufacturingDate', 'enabled'=>1, 'visible'=>1, 'position'=>80), - 'scrapping_date' => array('type'=>'date', 'label'=>'DestructionDate', 'enabled'=>'getDolGlobalInt("PRODUCT_ENABLE_TRACEABILITY", 0)', 'visible'=>5, 'position'=>90), - //'commissionning_date' => array('type'=>'date', 'label'=>'FirstUseDate', 'enabled'=>'getDolGlobalInt("PRODUCT_ENABLE_TRACEABILITY", 0)', 'visible'=>5, 'position'=>100), - //'qc_frequency' => array('type'=>'varchar(6)', 'label'=>'QCFrequency', 'enabled'=>'empty($conf->global->PRODUCT_ENABLE_QUALITYCONTROL)?1:0', 'visible'=>5, 'position'=>110), + 'eol_date' => array('type'=>'date', 'label'=>'EndOfLife', 'enabled'=>'getDolGlobalInt("PRODUCT_LOT_ENABLE_QUALITY_CONTROL")?1:0', 'visible'=>'getDolGlobalInt("PRODUCT_LOT_ENABLE_QUALITY_CONTROL")?5:0', 'position'=>70), + 'manufacturing_date' => array('type'=>'date', 'label'=>'ManufacturingDate', 'enabled'=>'getDolGlobalInt("PRODUCT_LOT_ENABLE_TRACEABILITY")?1:0', 'visible'=>'getDolGlobalInt("PRODUCT_LOT_ENABLE_TRACEABILITY")?5:0', 'position'=>80), + 'scrapping_date' => array('type'=>'date', 'label'=>'DestructionDate', 'enabled'=>'getDolGlobalInt("PRODUCT_LOT_ENABLE_TRACEABILITY")?1:0', 'visible'=>'getDolGlobalInt("PRODUCT_LOT_ENABLE_TRACEABILITY")?5:0', 'position'=>90), + //'commissionning_date' => array('type'=>'date', 'label'=>'FirstUseDate', 'enabled'=>'getDolGlobalInt("PRODUCT_LOT_ENABLE_TRACEABILITY", 0)', 'visible'=>5, 'position'=>100), + 'qc_frequency' => array('type'=>'integer', 'label'=>'QCFrequency', 'enabled'=>'getDolGlobalInt("PRODUCT_LOT_ENABLE_QUALITY_CONTROL")?1:0', 'visible'=>'getDolGlobalInt("PRODUCT_LOT_ENABLE_QUALITY_CONTROL")?5:0', 'position'=>110), + 'lifetime' => array('type'=>'integer', 'label'=>'Lifetime', 'enabled'=>'getDolGlobalInt("PRODUCT_LOT_ENABLE_QUALITY_CONTROL")?1:0', 'visible'=>'getDolGlobalInt("PRODUCT_LOT_ENABLE_QUALITY_CONTROL")?5:0', 'position'=>110), 'eatby' => array('type'=>'date', 'label'=>'EatByDate', 'enabled'=>'empty($conf->global->PRODUCT_DISABLE_EATBY)?1:0', 'visible'=>5, 'position'=>62), 'model_pdf' => array('type' => 'varchar(255)', 'label' => 'Model pdf', 'enabled' => 1, 'visible' => 0, 'position' => 215), 'last_main_doc' => array('type' => 'varchar(255)', 'label' => 'LastMainDoc', 'enabled' => 1, 'visible' => -2, 'position' => 310), @@ -141,7 +142,8 @@ class Productlot extends CommonObject public $manufacturing_date = ''; public $scrapping_date = ''; //public $commissionning_date = ''; - //public $qc_frequency = ''; + public $qc_frequency = ''; + public $lifetime = ''; public $datec = ''; public $tms = ''; @@ -227,7 +229,8 @@ class Productlot extends CommonObject $sql .= 'manufacturing_date,'; $sql .= 'scrapping_date,'; //$sql .= 'commissionning_date,'; - //$sql .= 'qc_frequency,'; + $sql .= 'qc_frequency,'; + $sql .= 'lifetime,'; $sql .= 'datec,'; $sql .= 'fk_user_creat,'; $sql .= 'fk_user_modif,'; @@ -242,7 +245,8 @@ class Productlot extends CommonObject $sql .= ' '.(!isset($this->manufacturing_date) || dol_strlen($this->manufacturing_date) == 0 ? 'NULL' : "'".$this->db->idate($this->manufacturing_date)."'").','; $sql .= ' '.(!isset($this->scrapping_date) || dol_strlen($this->scrapping_date) == 0 ? 'NULL' : "'".$this->db->idate($this->scrapping_date)."'").','; //$sql .= ' '.(!isset($this->commissionning_date) || dol_strlen($this->commissionning_date) == 0 ? 'NULL' : "'".$this->db->idate($this->commissionning_date)."'").','; - //$sql .= ' '.(!isset($this->qc_frequency) ? 'NULL' : $this->qc_frequency).','; + $sql .= ' '.(empty($this->qc_frequency) ? 'NULL' : $this->qc_frequency).','; + $sql .= ' '.(empty($this->lifetime) ? 'NULL' : $this->lifetime).','; $sql .= ' '."'".$this->db->idate(dol_now())."'".','; $sql .= ' '.(!isset($this->fk_user_creat) ? 'NULL' : $this->fk_user_creat).','; $sql .= ' '.(!isset($this->fk_user_modif) ? 'NULL' : $this->fk_user_modif).','; @@ -316,7 +320,8 @@ class Productlot extends CommonObject $sql .= " t.manufacturing_date,"; $sql .= " t.scrapping_date,"; //$sql .= " t.commissionning_date,"; - //$sql .= " t.qc_frequency,"; + $sql .= " t.qc_frequency,"; + $sql .= " t.lifetime,"; $sql .= " t.model_pdf,"; $sql .= " t.last_main_doc,"; $sql .= " t.datec,"; @@ -352,7 +357,8 @@ class Productlot extends CommonObject $this->manufacturing_date = $this->db->jdate($obj->manufacturing_date); $this->scrapping_date = $this->db->jdate($obj->scrapping_date); //$this->commissionning_date = $this->db->jdate($obj->commissionning_date); - //$this->qc_frequency = $obj->qc_frequency; + $this->qc_frequency = $obj->qc_frequency; + $this->lifetime = $obj->lifetime; $this->model_pdf = $obj->model_pdf; $this->last_main_doc = $obj->last_main_doc; @@ -434,7 +440,8 @@ class Productlot extends CommonObject $sql .= ' manufacturing_date = '.(!isset($this->manufacturing_date) || dol_strlen($this->manufacturing_date) != 0 ? "'".$this->db->idate($this->manufacturing_date)."'" : 'null').','; $sql .= ' scrapping_date = '.(!isset($this->scrapping_date) || dol_strlen($this->scrapping_date) != 0 ? "'".$this->db->idate($this->scrapping_date)."'" : 'null').','; //$sql .= ' commissionning_date = '.(!isset($this->first_use_date) || dol_strlen($this->first_use_date) != 0 ? "'".$this->db->idate($this->first_use_date)."'" : 'null').','; - //$sql .= ' qc_frequency = '.(!isset($this->qc_frequency) || dol_strlen($this->qc_frequency) != 0 ? "'".$this->db->escape($this->qc_frequency)."'" : 'null').','; + $sql .= ' qc_frequency = '.(!empty($this->qc_frequency) ? (int) $this->qc_frequency : 'null').','; + $sql .= ' lifetime = '.(!empty($this->lifetime) ? (int) $this->lifetime : 'null').','; $sql .= ' datec = '.(!isset($this->datec) || dol_strlen($this->datec) != 0 ? "'".$this->db->idate($this->datec)."'" : 'null').','; $sql .= ' tms = '.(dol_strlen($this->tms) != 0 ? "'".$this->db->idate($this->tms)."'" : "'".$this->db->idate(dol_now())."'").','; $sql .= ' fk_user_creat = '.(isset($this->fk_user_creat) ? $this->fk_user_creat : "null").','; diff --git a/htdocs/product/stock/productlot_card.php b/htdocs/product/stock/productlot_card.php index 5fa6afe983c..42adc0a471a 100644 --- a/htdocs/product/stock/productlot_card.php +++ b/htdocs/product/stock/productlot_card.php @@ -34,6 +34,8 @@ require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/stock/class/productlot.class.php'; +global $conf, $db, $langs, $user; + // Load translation files required by the page $langs->loadLangs(array('stocks', 'other', 'productbatch')); @@ -69,9 +71,9 @@ if (empty($action) && empty($id) && empty($ref)) { $action = 'view'; } -$batch = GETPOST('batch', 'alpha'); -$productid = GETPOST('productid', 'int'); -$ref = GETPOST('ref', 'alpha'); // ref is productid_batch +$batch = GETPOST('batch', 'alpha'); +$productid = GETPOST('productid', 'int'); +$ref = GETPOST('ref', 'alpha'); // ref is productid_batch $search_entity = GETPOST('search_entity', 'int'); $search_fk_product = GETPOST('search_fk_product', 'int'); @@ -106,13 +108,13 @@ if ($id || $ref) { $hookmanager->initHooks(array('productlotcard', 'globalcard')); -$permissionnote = $user->rights->stock->creer; // Used by the include of actions_setnotes.inc.php -$permissiondellink = $user->rights->stock->creer; // Used by the include of actions_dellink.inc.php -$permissiontoadd = $user->rights->stock->creer; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php +$permissionnote = $user->hasRight('stock', 'creer'); // Used by the include of actions_setnotes.inc.php +$permissiondellink = $user->hasRight('stock', 'creer'); // Used by the include of actions_dellink.inc.php +$permissiontoadd = $user->hasRight('stock', 'creer'); // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php -$usercanread = $user->rights->produit->lire; -$usercancreate = $user->rights->produit->creer; -$usercandelete = $user->rights->produit->supprimer; +$usercanread = $user->hasRight('produit', 'lire'); +$usercancreate = $user->hasRight('produit', 'creer'); +$usercandelete = $user->hasRight('produit', 'supprimer'); $upload_dir = $conf->productbatch->multidir_output[$conf->entity]; @@ -121,7 +123,7 @@ $permissiontoadd = $usercancreate; $permissiontodelete = $usercandelete; // Security check -if (empty($conf->productbatch->enabled)) { +if (!isModEnabled('productbatch')) { accessforbidden('Module not enabled'); } $socid = 0; @@ -130,7 +132,9 @@ if ($user->socid > 0) { // Protection if external user accessforbidden(); } //$result = restrictedArea($user, 'productbatch'); -if (!$permissiontoread) accessforbidden(); +if (!$permissiontoread) { + accessforbidden(); +} /* @@ -148,7 +152,7 @@ if (empty($reshook)) { $backurlforlist = dol_buildpath('/product/stock/productlot_list.php', 1); - if ($action == 'seteatby' && $user->rights->stock->creer && ! GETPOST('cancel', 'alpha')) { + if ($action == 'seteatby' && $user->hasRight('stock', 'creer') && ! GETPOST('cancel', 'alpha')) { $newvalue = dol_mktime(12, 0, 0, GETPOST('eatbymonth', 'int'), GETPOST('eatbyday', 'int'), GETPOST('eatbyyear', 'int')); $result = $object->setValueFrom('eatby', $newvalue, '', null, 'date', '', $user, 'PRODUCTLOT_MODIFY'); if ($result < 0) { @@ -159,7 +163,7 @@ if (empty($reshook)) { } } - if ($action == 'setsellby' && $user->rights->stock->creer && ! GETPOST('cancel', 'alpha')) { + if ($action == 'setsellby' && $user->hasRight('stock', 'creer') && ! GETPOST('cancel', 'alpha')) { $newvalue = dol_mktime(12, 0, 0, GETPOST('sellbymonth', 'int'), GETPOST('sellbyday', 'int'), GETPOST('sellbyyear', 'int')); $result = $object->setValueFrom('sellby', $newvalue, '', null, 'date', '', $user, 'PRODUCTLOT_MODIFY'); if ($result < 0) { @@ -170,7 +174,7 @@ if (empty($reshook)) { } } - if ($action == 'seteol_date' && $user->rights->stock->creer && ! GETPOST('cancel', 'alpha')) { + if ($action == 'seteol_date' && $user->hasRight('stock', 'creer') && ! GETPOST('cancel', 'alpha')) { $newvalue = dol_mktime(12, 0, 0, GETPOST('eol_datemonth', 'int'), GETPOST('eol_dateday', 'int'), GETPOST('eol_dateyear', 'int')); $result = $object->setValueFrom('eol_date', $newvalue, '', null, 'date', '', $user, 'PRODUCTLOT_MODIFY'); if ($result < 0) { @@ -181,7 +185,7 @@ if (empty($reshook)) { } } - if ($action == 'setmanufacturing_date' && $user->rights->stock->creer && ! GETPOST('cancel', 'alpha')) { + if ($action == 'setmanufacturing_date' && $user->hasRight('stock', 'creer') && ! GETPOST('cancel', 'alpha')) { $newvalue = dol_mktime(12, 0, 0, GETPOST('manufacturing_datemonth', 'int'), GETPOST('manufacturing_dateday', 'int'), GETPOST('manufacturing_dateyear', 'int')); $result = $object->setValueFrom('manufacturing_date', $newvalue, '', null, 'date', '', $user, 'PRODUCTLOT_MODIFY'); if ($result < 0) { @@ -192,7 +196,7 @@ if (empty($reshook)) { } } - if ($action == 'setscrapping_date' && $user->rights->stock->creer && ! GETPOST('cancel', 'alpha')) { + if ($action == 'setscrapping_date' && $user->hasRight('stock', 'creer') && ! GETPOST('cancel', 'alpha')) { $newvalue = dol_mktime(12, 0, 0, GETPOST('scrapping_datemonth', 'int'), GETPOST('scrapping_dateday', 'int'), GETPOST('scrapping_dateyear', 'int')); $result = $object->setValueFrom('scrapping_date', $newvalue, '', null, 'date', '', $user, 'PRODUCTLOT_MODIFY'); if ($result < 0) { @@ -203,7 +207,7 @@ if (empty($reshook)) { } } - /* if ($action == 'setcommissionning_date' && $user->rights->stock->creer && ! GETPOST('cancel', 'alpha')) { + /* if ($action == 'setcommissionning_date' && $user->hasRight('stock', 'creer') && ! GETPOST('cancel', 'alpha')) { $newvalue = dol_mktime(12, 0, 0, GETPOST('commissionning_datemonth', 'int'), GETPOST('commissionning_dateday', 'int'), GETPOST('commissionning_dateyear', 'int')); $result = $object->setValueFrom('commissionning_date', $newvalue, '', null, 'date', '', $user, 'PRODUCTLOT_MODIFY'); if ($result < 0) { @@ -214,7 +218,7 @@ if (empty($reshook)) { } } */ - if ($action == 'setqc_frequency' && $user->rights->stock->creer && ! GETPOST('cancel', 'alpha')) { + if ($action == 'setqc_frequency' && $user->hasRight('stock', 'creer') && ! GETPOST('cancel', 'alpha')) { $result = $object->setValueFrom('qc_frequency', GETPOST('qc_frequency'), '', null, 'int', '', $user, 'PRODUCT_MODIFY'); if ($result < 0) { // Prévoir un test de format de durée setEventMessages($object->error, null, 'errors'); @@ -229,20 +233,17 @@ if (empty($reshook)) { // Actions cancel, add, update, update_extras, confirm_validate, confirm_delete, confirm_deleteline, confirm_clone, confirm_close, confirm_setdraft, confirm_reopen include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php'; /* - if ($action == 'update_extras') - { + if ($action == 'update_extras') { $object->oldcopy = dol_clone($object); // Fill array 'array_options' with data from update form $ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute', 'restricthtml')); if ($ret < 0) $error++; - if (!$error) - { + if (!$error) { // Actions on extra fields $result = $object->insertExtraFields('PRODUCT_LOT_MODIFY'); - if ($result < 0) - { + if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); $error++; } @@ -254,10 +255,8 @@ if (empty($reshook)) { } // Action to add record - if ($action == 'add') - { - if (GETPOST('cancel', 'alpha')) - { + if ($action == 'add') { + if (GETPOST('cancel', 'alpha')) { $urltogo = $backtopage ? $backtopage : dol_buildpath('/stock/list.php', 1); header("Location: ".$urltogo); exit; @@ -272,17 +271,14 @@ if (empty($reshook)) { $object->fk_user_modif = GETPOST('fk_user_modif', 'int'); $object->import_key = GETPOST('import_key', 'int'); - if (empty($object->ref)) - { + if (empty($object->ref)) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Ref")), null, 'errors'); } - if (!$error) - { + if (!$error) { $result = $object->create($user); - if ($result > 0) - { + if ($result > 0) { // Creation OK $urltogo = $backtopage ? $backtopage : dol_buildpath('/stock/list.php', 1); header("Location: ".$urltogo); @@ -303,8 +299,7 @@ if (empty($reshook)) { if ($action == 'update' && GETPOST('cancel', 'alpha')) $action = 'view'; // Action to update record - if ($action == 'update' && !GETPOST('cancel', 'alpha')) - { + if ($action == 'update' && !GETPOST('cancel', 'alpha')) { $error = 0; $object->entity = GETPOST('entity', 'int'); @@ -314,17 +309,14 @@ if (empty($reshook)) { $object->fk_user_modif = GETPOST('fk_user_modif', 'int'); $object->import_key = GETPOST('import_key', 'int'); - if (empty($object->ref)) - { + if (empty($object->ref)) { $error++; setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("Ref")), null, 'errors'); } - if (!$error) - { + if (!$error) { $result = $object->update($user); - if ($result > 0) - { + if ($result > 0) { $action = 'view'; } else { // Creation KO @@ -338,11 +330,9 @@ if (empty($reshook)) { } // Action to delete - if ($action == 'confirm_delete') - { + if ($action == 'confirm_delete') { $result = $object->delete($user); - if ($result > 0) - { + if ($result > 0) { // Delete OK setEventMessages("RecordDeleted", null, 'mesgs'); header("Location: ".dol_buildpath('/stock/list.php', 1)); @@ -468,9 +458,9 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Sell by if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) { print ''; - print $form->editfieldkey($langs->trans('SellByDate'), 'sellby', $object->sellby, $object, $user->rights->stock->creer, 'datepicker'); + print $form->editfieldkey($langs->trans('SellByDate'), 'sellby', $object->sellby, $object, $user->hasRight('stock', 'creer'), 'datepicker'); print ''; - print $form->editfieldval($langs->trans('SellByDate'), 'sellby', $object->sellby, $object, $user->rights->stock->creer, 'datepicker', '', null, null, '', 1, '', 'id', 'auto', array(), $action); + print $form->editfieldval($langs->trans('SellByDate'), 'sellby', $object->sellby, $object, $user->hasRight('stock', 'creer'), 'datepicker', '', null, null, '', 1, '', 'id', 'auto', array(), $action); print ''; print ''; } @@ -478,32 +468,35 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Eat by if (empty($conf->global->PRODUCT_DISABLE_EATBY)) { print ''; - print $form->editfieldkey($langs->trans('EatByDate'), 'eatby', $object->eatby, $object, $user->rights->stock->creer, 'datepicker'); + print $form->editfieldkey($langs->trans('EatByDate'), 'eatby', $object->eatby, $object, $user->hasRight('stock', 'creer'), 'datepicker'); print ''; - print $form->editfieldval($langs->trans('EatByDate'), 'eatby', $object->eatby, $object, $user->rights->stock->creer, 'datepicker', '', null, null, '', 1, '', 'id', 'auto', array(), $action); + print $form->editfieldval($langs->trans('EatByDate'), 'eatby', $object->eatby, $object, $user->hasRight('stock', 'creer'), 'datepicker', '', null, null, '', 1, '', 'id', 'auto', array(), $action); print ''; print ''; } - if (!empty($conf->global->PRODUCT_LOT_ENABLE_TRACEABOLITY)) { - print ''.$form->editfieldkey($langs->trans('ManufacturingDate'), 'manufacturing_date', $object->manufacturing_date, $object, $user->rights->stock->creer).''; - print ''.$form->editfieldval($langs->trans('ManufacturingDate'), 'manufacturing_date', $object->manufacturing_date, $object, $user->rights->stock->creer, 'datepicker').''; + if (!empty($conf->global->PRODUCT_LOT_ENABLE_TRACEABILITY)) { + print ''.$form->editfieldkey($langs->trans('ManufacturingDate'), 'manufacturing_date', $object->manufacturing_date, $object, $user->hasRight('stock', 'creer')).''; + print ''.$form->editfieldval($langs->trans('ManufacturingDate'), 'manufacturing_date', $object->manufacturing_date, $object, $user->hasRight('stock', 'creer'), 'datepicker').''; print ''; - // print ''.$form->editfieldkey($langs->trans('FirstUseDate'), 'commissionning_date', $object->commissionning_date, $object, $user->rights->stock->creer).''; - // print ''.$form->editfieldval($langs->trans('FirstUseDate'), 'commissionning_date', $object->commissionning_date, $object, $user->rights->stock->creer, 'datepicker').''; + // print ''.$form->editfieldkey($langs->trans('FirstUseDate'), 'commissionning_date', $object->commissionning_date, $object, $user->hasRight('stock', 'creer')).''; + // print ''.$form->editfieldval($langs->trans('FirstUseDate'), 'commissionning_date', $object->commissionning_date, $object, $user->hasRight('stock', 'creer'), 'datepicker').''; // print ''; - print ''.$form->editfieldkey($langs->trans('DestructionDate'), 'scrapping_date', $object->scrapping_date, $object, $user->rights->stock->creer).''; - print ''.$form->editfieldval($langs->trans('DestructionDate'), 'scrapping_date', $object->scrapping_date, $object, $user->rights->stock->creer, 'datepicker').''; + print ''.$form->editfieldkey($langs->trans('DestructionDate'), 'scrapping_date', $object->scrapping_date, $object, $user->hasRight('stock', 'creer')).''; + print ''.$form->editfieldval($langs->trans('DestructionDate'), 'scrapping_date', $object->scrapping_date, $object, $user->hasRight('stock', 'creer'), 'datepicker').''; print ''; } // Quality control if (!empty($conf->global->PRODUCT_LOT_ENABLE_QUALITY_CONTROL)) { - print ''.$form->editfieldkey($langs->trans('EndOfLife'), 'eol_date', $object->eol_date, $object, $user->rights->stock->creer).''; - print ''.$form->editfieldval($langs->trans('EndOfLife'), 'eol_date', $object->eol_date, $object, $user->rights->stock->creer, 'datepicker').''; + print ''.$form->editfieldkey($langs->trans('EndOfLife'), 'eol_date', $object->eol_date, $object, $user->hasRight('stock', 'creer')).''; + print ''.$form->editfieldval($langs->trans('EndOfLife'), 'eol_date', $object->eol_date, $object, $user->hasRight('stock', 'creer'), 'datepicker').''; print ''; - print ''.$form->editfieldkey($langs->trans('QCFrequency'), 'qc_frequency', $object->qc_frequency, $object, $user->rights->stock->creer).''; - print ''.$form->editfieldval($langs->trans('QCFrequency'), 'qc_frequency', $object->qc_frequency, $object, $user->rights->stock->creer, 'numeric').''; + print ''.$form->editfieldkey($langs->trans('QCFrequency'), 'qc_frequency', $object->qc_frequency, $object, $user->hasRight('stock', 'creer')).''; + print ''.$form->editfieldval($langs->trans('QCFrequency'), 'qc_frequency', $object->qc_frequency, $object, $user->hasRight('stock', 'creer'), 'string').''; + print ''; + print ''.$form->editfieldkey($langs->trans('Lifetime'), 'lifetime', $object->lifetime, $object, $user->hasRight('stock', 'creer')).''; + print ''.$form->editfieldval($langs->trans('Lifetime'), 'lifetime', $object->lifetime, $object, $user->hasRight('stock', 'creer'), 'string').''; print ''; } @@ -536,8 +529,8 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea } if (empty($reshook)) { - /*TODO if ($user->rights->stock->lire) - { + /*TODO + if ($user->hasRight('stock', 'lire')) { print ''."\n"; } */ diff --git a/htdocs/product/stock/productlot_document.php b/htdocs/product/stock/productlot_document.php index 38c5b0503d8..0f4cb68df98 100644 --- a/htdocs/product/stock/productlot_document.php +++ b/htdocs/product/stock/productlot_document.php @@ -26,7 +26,7 @@ /** * \file htdocs/product/stock/productlot_document.php * \ingroup product - * \brief Page of attached documents for porudct lots + * \brief Page of attached documents for product lots */ // Load Dolibarr environment @@ -38,11 +38,13 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/stock/class/productlot.class.php'; +global $conf, $db, $langs, $user; + // Load translation files required by the page $langs->loadLangs(array('other', 'products')); -$id = GETPOST('id', 'int'); -$ref = GETPOST('ref', 'alpha'); +$id = GETPOST('id', 'int'); +$ref = GETPOST('ref', 'alpha'); $action = GETPOST('action', 'aZ09'); $confirm = GETPOST('confirm', 'alpha'); @@ -97,9 +99,9 @@ if ($id || $ref) { } } -$usercanread = $user->rights->produit->lire; -$usercancreate = $user->rights->produit->creer; -$usercandelete = $user->rights->produit->supprimer; +$usercanread = $user->hasRight('produit', 'lire'); +$usercancreate = $user->hasRight('produit', 'creer'); +$usercandelete = $user->hasRight('produit', 'supprimer'); if (empty($upload_dir)) { $upload_dir = $conf->productbatch->multidir_output[$conf->entity]; @@ -111,7 +113,7 @@ $permtoedit = $user->rights->produit->creer; //$permissiontodelete = $usercandelete; // Security check -if (empty($conf->productbatch->enabled)) { +if (!isModEnabled('productbatch')) { accessforbidden('Module not enabled'); } $socid = 0; diff --git a/htdocs/product/stock/stats/commande_fournisseur.php b/htdocs/product/stock/stats/commande_fournisseur.php index 432b8965db8..e75a8578bb8 100644 --- a/htdocs/product/stock/stats/commande_fournisseur.php +++ b/htdocs/product/stock/stats/commande_fournisseur.php @@ -173,7 +173,7 @@ if ($id > 0 || !empty($ref)) { // print ''; // } // - // if (!empty($conf->global->PRODUCT_LOT_ENABLE_TRACEABOLITY)) { + // if (!empty($conf->global->PRODUCT_LOT_ENABLE_TRACEABILITY)) { // print ''.$form->editfieldkey($langs->trans('ManufacturingDate'), 'manufacturing_date', $object->manufacturing_date, $object, $user->rights->stock->creer).''; // print ''.$form->editfieldval($langs->trans('ManufacturingDate'), 'manufacturing_date', $object->manufacturing_date, $object, $user->rights->stock->creer, 'datepicker').''; // print ''; diff --git a/htdocs/product/stock/stats/expedition.php b/htdocs/product/stock/stats/expedition.php index 01739862433..612b265a0b9 100644 --- a/htdocs/product/stock/stats/expedition.php +++ b/htdocs/product/stock/stats/expedition.php @@ -173,7 +173,7 @@ if ($id > 0 || !empty($ref)) { // print ''; // } // - // if (!empty($conf->global->PRODUCT_LOT_ENABLE_TRACEABOLITY)) { + // if (!empty($conf->global->PRODUCT_LOT_ENABLE_TRACEABILITY)) { // print ''.$form->editfieldkey($langs->trans('ManufacturingDate'), 'manufacturing_date', $object->manufacturing_date, $object, $user->rights->stock->creer).''; // print ''.$form->editfieldval($langs->trans('ManufacturingDate'), 'manufacturing_date', $object->manufacturing_date, $object, $user->rights->stock->creer, 'datepicker').''; // print ''; diff --git a/htdocs/product/stock/stats/reception.php b/htdocs/product/stock/stats/reception.php index f4bd6f10d87..b6a019ff012 100644 --- a/htdocs/product/stock/stats/reception.php +++ b/htdocs/product/stock/stats/reception.php @@ -173,7 +173,7 @@ if ($id > 0 || !empty($ref)) { // print ''; // } // - // if (!empty($conf->global->PRODUCT_LOT_ENABLE_TRACEABOLITY)) { + // if (!empty($conf->global->PRODUCT_LOT_ENABLE_TRACEABILITY)) { // print ''.$form->editfieldkey($langs->trans('ManufacturingDate'), 'manufacturing_date', $object->manufacturing_date, $object, $user->rights->stock->creer).''; // print ''.$form->editfieldval($langs->trans('ManufacturingDate'), 'manufacturing_date', $object->manufacturing_date, $object, $user->rights->stock->creer, 'datepicker').''; // print ''; diff --git a/htdocs/projet/activity/perweek.php b/htdocs/projet/activity/perweek.php index daf1dd0ac7b..d5108333f6d 100644 --- a/htdocs/projet/activity/perweek.php +++ b/htdocs/projet/activity/perweek.php @@ -760,7 +760,11 @@ if (count($tasksarray) > 0) { $projectstatic->loadTimeSpent($firstdaytoshow, 0, $usertoprocess->id); // Load time spent from table element_time for the project into this->weekWorkLoad and this->weekWorkLoadPerTask for all days of a week for ($idw = 0; $idw < 7; $idw++) { $tmpday = dol_time_plus_duree($firstdaytoshow, $idw, 'd'); - $totalforeachday[$tmpday] += $projectstatic->weekWorkLoad[$tmpday]; + if (empty($totalforeachday[$tmpday])) { + $totalforeachday[$tmpday] = empty($projectstatic->weekWorkLoad[$tmpday]) ? 0 : $projectstatic->weekWorkLoad[$tmpday]; + } else { + $totalforeachday[$tmpday] += empty($projectstatic->weekWorkLoad[$tmpday]) ? 0 : $projectstatic->weekWorkLoad[$tmpday]; + } } } diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index 4466138e006..99f0f375b4f 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -495,7 +495,6 @@ class Project extends CommonObject } } else { $this->error = $this->db->lasterror(); - $this->errno = $this->db->lasterrno(); $error++; } diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php index 643c020cc50..985be60b138 100644 --- a/htdocs/projet/list.php +++ b/htdocs/projet/list.php @@ -992,12 +992,12 @@ $includeonly = ''; if (empty($user->rights->user->user->lire)) { $includeonly = array($user->id); } -$moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$form->select_dolusers($search_project_user ? $search_project_user : '', 'search_project_user', $tmptitle, '', 0, $includeonly, '', 0, 0, 0, '', 0, '', 'maxwidth250 widthcentpercentminusx'); +$moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$form->select_dolusers($search_project_user ? $search_project_user : '', 'search_project_user', $tmptitle, '', 0, $includeonly, '', 0, 0, 0, '', 0, '', 'maxwidth300 widthcentpercentminusx'); $moreforfilter .= '
'; $moreforfilter .= '
'; $tmptitle = $langs->trans('ProjectsWithThisContact'); -$moreforfilter .= img_picto($tmptitle, 'contact', 'class="pictofixedwidth"').$form->selectcontacts(0, $search_project_contact ? $search_project_contact : '', 'search_project_contact', $tmptitle, '', '', 0, 'maxwidth250 widthcentpercentminusx'); +$moreforfilter .= img_picto($tmptitle, 'contact', 'class="pictofixedwidth"').$form->selectcontacts(0, $search_project_contact ? $search_project_contact : '', 'search_project_contact', $tmptitle, '', '', 0, 'maxwidth300 widthcentpercentminusx'); $moreforfilter .= '
'; // If the user can view thirdparties other than his' @@ -1005,14 +1005,14 @@ if ($user->rights->user->user->lire) { $langs->load("commercial"); $moreforfilter .= '
'; $tmptitle = $langs->trans('ThirdPartiesOfSaleRepresentative'); - $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, $tmptitle, 'maxwidth250 widthcentpercentminusx'); + $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, $tmptitle, 'maxwidth300 widthcentpercentminusx'); $moreforfilter .= '
'; } // Filter on categories if (isModEnabled('categorie') && $user->hasRight('categorie', 'lire')) { $formcategory = new FormCategory($db); - $moreforfilter .= $formcategory->getFilterBox(Categorie::TYPE_PROJECT, $search_category_array, 'minwidth300imp widthcentpercentminusx'); + $moreforfilter .= $formcategory->getFilterBox(Categorie::TYPE_PROJECT, $search_category_array, 'minwidth300imp minwidth300 widthcentpercentminusx'); } // Filter on customer categories if (!empty($conf->global->MAIN_SEARCH_CATEGORY_CUSTOMER_ON_PROJECT_LIST) && isModEnabled("categorie") && $user->hasRight('categorie', 'lire')) { @@ -1021,7 +1021,7 @@ if (!empty($conf->global->MAIN_SEARCH_CATEGORY_CUSTOMER_ON_PROJECT_LIST) && isMo $moreforfilter .= img_picto($tmptitle, 'category', 'class="pictofixedwidth"'); $categoriesArr = $form->select_all_categories(Categorie::TYPE_CUSTOMER, '', '', 64, 0, 1); $categoriesArr[-2] = '- '.$langs->trans('NotCategorized').' -'; - $moreforfilter .= Form::multiselectarray('search_category_customer_list', $categoriesArr, $searchCategoryCustomerList, 0, 0, 'minwidth300', 0, 0, '', 'category', $tmptitle); + $moreforfilter .= Form::multiselectarray('search_category_customer_list', $categoriesArr, $searchCategoryCustomerList, 0, 0, 'minwidth300im minwidth300 widthcentpercentminusx', 0, 0, '', 'category', $tmptitle); $moreforfilter .= ' '; $moreforfilter .= $form->textwithpicto('', $langs->trans('UseOrOperatorForCategories') . ' : ' . $tmptitle, 1, 'help', '', 0, 2, 'tooltip_cat_cus'); // Tooltip on click $moreforfilter .= ''; diff --git a/htdocs/public/bookcal/booking.php b/htdocs/public/bookcal/booking.php index d478046d143..74972cfc8f0 100644 --- a/htdocs/public/bookcal/booking.php +++ b/htdocs/public/bookcal/booking.php @@ -19,7 +19,7 @@ */ /** - * \file htdocs/public/onlinesign/newonlinesign.php + * \file htdocs/public/bookcal/booking.php * \ingroup core * \brief File to offer a way to make an online signature for a particular Dolibarr entity * Example of URL: https://localhost/public/bookcal/booking.php?ref=PR... @@ -44,7 +44,6 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/bookcal/class/calendar.class.php'; require_once DOL_DOCUMENT_ROOT.'/bookcal/class/availabilities.class.php'; -require_once DOL_DOCUMENT_ROOT.'/bookcal/class/booking.class.php'; $langs->loadLangs(array("main", "other", "dict", "agenda", "errors", "companies")); @@ -175,7 +174,7 @@ if ($action == 'add') { $user = new User($db); } - $booking = new Booking($db); + $booking = new ActionComm($db); $db->begin(); if (!GETPOST("lastname")) { diff --git a/htdocs/public/bookcal/index.php b/htdocs/public/bookcal/index.php index 530f37fc91e..cd4db57da4d 100644 --- a/htdocs/public/bookcal/index.php +++ b/htdocs/public/bookcal/index.php @@ -19,7 +19,7 @@ */ /** - * \file htdocs/public/onlinesign/newonlinesign.php + * \file htdocs/public/bookcal/index.php * \ingroup core * \brief File to offer a way to make an online signature for a particular Dolibarr entity * Example of URL: https://localhost/public/bookcal/booking.php?ref=PR... @@ -44,6 +44,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/bookcal/class/calendar.class.php'; require_once DOL_DOCUMENT_ROOT.'/bookcal/class/availabilities.class.php'; +require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; $langs->loadLangs(array("main", "other", "dict", "agenda", "errors", "bookcal")); diff --git a/htdocs/public/partnership/new.php b/htdocs/public/partnership/new.php index 174b35dc9b8..2bd0247a965 100644 --- a/htdocs/public/partnership/new.php +++ b/htdocs/public/partnership/new.php @@ -229,6 +229,7 @@ if (empty($reshook) && $action == 'add') { $partnership->date_partnership_start = dol_now(); $partnership->fk_user_creat = 0; $partnership->fk_type = GETPOST('partnershiptype', 'int'); + $partnership->url = GETPOST('url'); //$partnership->typeid = $conf->global->PARTNERSHIP_NEWFORM_FORCETYPE ? $conf->global->PARTNERSHIP_NEWFORM_FORCETYPE : GETPOST('typeid', 'int'); $partnership->ip = getUserRemoteIP(); @@ -253,16 +254,16 @@ if (empty($reshook) && $action == 'add') { } } } - // test if societe already exist + // test if thirdparty already exists $company = new Societe($db); $result = $company->fetch(0, GETPOST('societe')); - if ($result == 0) { // si il ya pas d'entree sur le nom on teste l'email + if ($result == 0) { // if entry with name not found, we search using the email $result1 = $company->fetch(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, GETPOST('email')); if ($result1 > 0) { $error++; $errmsg = $langs->trans("EmailAlreadyExistsPleaseRewriteYourCompanyName"); } else { - //create thirdparty + // create thirdparty $company = new Societe($db); $company->name = GETPOST('societe'); diff --git a/htdocs/reception/class/reception.class.php b/htdocs/reception/class/reception.class.php index c9cf763882c..9fb6a0cb6a9 100644 --- a/htdocs/reception/class/reception.class.php +++ b/htdocs/reception/class/reception.class.php @@ -93,6 +93,7 @@ class Reception extends CommonObject public $depth_units; // A denormalized value public $trueSize; + public $size_units; public $date_delivery; // Date delivery planed @@ -121,6 +122,11 @@ class Reception extends CommonObject public $meths; public $listmeths; // List of carriers + /** + * @var CommandeFournisseur + */ + public $commandeFournisseur; + /** * @var CommandeFournisseurDispatch[] */ diff --git a/htdocs/takepos/admin/appearance.php b/htdocs/takepos/admin/appearance.php index 54ed2f642a2..d351b90ae8c 100644 --- a/htdocs/takepos/admin/appearance.php +++ b/htdocs/takepos/admin/appearance.php @@ -46,6 +46,9 @@ if (GETPOST('action', 'alpha') == 'set') { $res = dolibarr_set_const($db, "TAKEPOS_COLOR_THEME", GETPOST('TAKEPOS_COLOR_THEME', 'alpha'), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "TAKEPOS_LINES_TO_SHOW", GETPOST('TAKEPOS_LINES_TO_SHOW', 'alpha'), 'chaine', 0, '', $conf->entity); + if (GETPOSTISSET('TAKEPOS_SHOW_PRODUCT_REFERENCE')) { + $res = dolibarr_set_const($db, "TAKEPOS_SHOW_PRODUCT_REFERENCE", GETPOST('TAKEPOS_SHOW_PRODUCT_REFERENCE', 'alpha'), 'chaine', 0, '', $conf->entity); + } dol_syslog("admin/cashdesk: level ".GETPOST('level', 'alpha')); @@ -91,72 +94,76 @@ print "\n"; // Color theme print ''; print $langs->trans("ColorTheme"); -print ''; +print ''; $array = array(0=>"Eldy", 1=>$langs->trans("Colorful")); print $form->selectarray('TAKEPOS_COLOR_THEME', $array, (empty($conf->global->TAKEPOS_COLOR_THEME) ? '0' : $conf->global->TAKEPOS_COLOR_THEME), 0); print "\n"; -// Hide category images to speed up +// Don't display category section print ''; -print $langs->trans('HideCategoryImages'); -print ''; -print ajax_constantonoff("TAKEPOS_HIDE_CATEGORY_IMAGES", array(), $conf->entity, 0, 0, 1, 0); +print $langs->trans('HideCategories'); +print ''; +print ajax_constantonoff("TAKEPOS_HIDE_CATEGORIES", array(), $conf->entity, 0, 0, 1, 0); print "\n"; +// Hide category images to speed up +if (!getDolGlobalString('TAKEPOS_HIDE_CATEGORIES')) { + print ''; + print $langs->trans('HideCategoryImages'); + print ''; + print ajax_constantonoff("TAKEPOS_HIDE_CATEGORY_IMAGES", array(), $conf->entity, 0, 0, 1, 0); + print "\n"; +} + // Hide category images to speed up print ''; print $langs->trans('HideProductImages'); -print ''; +print ''; print ajax_constantonoff("TAKEPOS_HIDE_PRODUCT_IMAGES", array(), $conf->entity, 0, 0, 1, 0); print "\n"; +// View reference or label of products +print ''; +print $langs->trans('ShowProductReference'); +print ''; +$array = array("0"=>$langs->trans("Label"), 1=>$langs->trans("Ref").'+'.$langs->trans("Label"), 2=>$langs->trans("Ref")); +print $form->selectarray('TAKEPOS_SHOW_PRODUCT_REFERENCE', $array, getDolGlobalInt('TAKEPOS_SHOW_PRODUCT_REFERENCE', 2), 0); +//print ajax_constantonoff("TAKEPOS_SHOW_PRODUCT_REFERENCE", array(), $conf->entity, 0, 0, 1, 0); +print "\n"; + // Lines to show print ''; print $langs->trans("NumberOfLinesToShow"); -print ''; +print ''; $array = array(1=>"1", 2=>"2", 3=>"3", 4=>"4", 5=>"5", 6=>"6"); print $form->selectarray('TAKEPOS_LINES_TO_SHOW', $array, getDolGlobalInt('TAKEPOS_LINES_TO_SHOW', 2), 0); print "\n"; -// D'ont display category -print ''; -print $langs->trans('HideCategories'); -print ''; -print ajax_constantonoff("TAKEPOS_HIDE_CATEGORIES", array(), $conf->entity, 0, 0, 1, 0); -print "\n"; - // Hide stock on line print ''; print $langs->trans('HideStockOnLine'); -print ''; +print ''; print ajax_constantonoff("TAKEPOS_HIDE_STOCK_ON_LINE", array(), $conf->entity, 0, 0, 1, 0); print "\n"; // Only the products in stock print ''; print $langs->trans('ShowOnlyProductInStock'); -print ''; +print ''; print ajax_constantonoff("TAKEPOS_PRODUCT_IN_STOCK", array(), $conf->entity, 0, 0, 1, 0); print "\n"; // View description of the categories print ''; print $langs->trans('ShowCategoryDescription'); -print ''; +print ''; print ajax_constantonoff("TAKEPOS_SHOW_CATEGORY_DESCRIPTION", array(), $conf->entity, 0, 0, 1, 0); print "\n"; -// View reference of products -print ''; -print $langs->trans('ShowProductReference'); -print ''; -print ajax_constantonoff("TAKEPOS_SHOW_PRODUCT_REFERENCE", array(), $conf->entity, 0, 0, 1, 0); -print "\n"; - // Use price excl. taxes (HT) and not price incl. taxes (TTC) print ''; print $langs->trans('UsePriceHT'); -print ''; +print ''; print ajax_constantonoff("TAKEPOS_CHANGE_PRICE_HT", array(), $conf->entity, 0, 0, 1, 0); print "\n"; diff --git a/htdocs/takepos/index.php b/htdocs/takepos/index.php index ff6371fe735..32d7301b6fe 100644 --- a/htdocs/takepos/index.php +++ b/htdocs/takepos/index.php @@ -361,6 +361,8 @@ function LoadProducts(position, issubcat) { echo '$("#prodivdesc"+ishow).show();'; if (getDolGlobalInt('TAKEPOS_SHOW_PRODUCT_REFERENCE') == 1) { echo '$("#prodesc"+ishow).html(data[parseInt(idata)][\'ref\'].bold() + \' - \' + data[parseInt(idata)][\'label\']);'; + } elseif (getDolGlobalInt('TAKEPOS_SHOW_PRODUCT_REFERENCE') == 2) { + echo '$("#prodesc"+ishow).html(data[parseInt(idata)][\'ref\'].bold());'; } else { echo '$("#prodesc"+ishow).html(data[parseInt(idata)][\'label\']);'; } @@ -449,9 +451,10 @@ function MoreProducts(moreorless) { $("#prodiv"+ishow).data("rowid",""); } else { $("#prodivdesc"+ishow).show(); - + $("#prodesc"+ishow).html(data[parseInt(idata)]['ref'].bold() + ' - ' + data[parseInt(idata)]['label']); + + $("#prodesc"+ishow).html(data[parseInt(idata)]['ref'].bold()); $("#prodesc"+ishow).html(data[parseInt(idata)]['label']); @@ -659,9 +662,10 @@ function Search2(keyCodeForEnter, moreorless) { $titlestring .= " + ' - ".dol_escape_js($langs->trans("Barcode").': ')."' + data[i]['barcode']"; ?> var titlestring = ; - - $("#prodesc" + i).html(data[i]['ref'].bold() + ' - ' + data[i]['label']); + + $("#prodesc" + i).html(data[i]['ref'].bold() + ' - ' + data[i]['label']); + + $("#prodesc" + i).html(data[i]['ref'].bold()); $("#prodesc" + i).html(data[i]['label']); diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index c5c34f6a3a4..037f8ed6dad 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -1560,6 +1560,8 @@ if ($placeid > 0) { } if (getDolGlobalInt('TAKEPOS_SHOW_PRODUCT_REFERENCE') == 1) { $htmlforlines .= $form->textwithpicto($line->product_label ? '' . $line->product_ref . ' - ' . $line->product_label : dolGetFirstLineOfText($line->desc, 1), $tooltiptext); + } elseif (getDolGlobalInt('TAKEPOS_SHOW_PRODUCT_REFERENCE') == 2) { + $htmlforlines .= $form->textwithpicto($line->product_ref ? ''.$line->product_ref.'' : dolGetFirstLineOfText($line->desc, 1), $tooltiptext); } else { $htmlforlines .= $form->textwithpicto($line->product_label ? $line->product_label : ($line->product_ref ? $line->product_ref : dolGetFirstLineOfText($line->desc, 1)), $tooltiptext); } diff --git a/htdocs/ticket/card.php b/htdocs/ticket/card.php index d55526054cb..09473a8c617 100755 --- a/htdocs/ticket/card.php +++ b/htdocs/ticket/card.php @@ -449,8 +449,6 @@ if (empty($reshook)) { if (!$error) { // Log action in ticket logs table $object->fetch_user($usertoassign); - //$log_action = $langs->trans('TicketLogAssignedTo', $object->user->getFullName($langs)); - setEventMessages($langs->trans('TicketAssigned'), null, 'mesgs'); header("Location: card.php?track_id=".$object->track_id); @@ -500,9 +498,6 @@ if (empty($reshook)) { if ($_SESSION['email_customer'] == $object->origin_email || $_SESSION['email_customer'] == $object->thirdparty->email) { $object->close($user); - // Log action in ticket logs table - //$log_action = $langs->trans('TicketLogClosedBy', $_SESSION['email_customer']); - setEventMessages('
'.$langs->trans('TicketMarkedAsClosed').'
', null, 'mesgs'); $url = 'card.php?track_id='.GETPOST('track_id', 'alpha'); @@ -589,9 +584,6 @@ if (empty($reshook)) { if ($object->status == Ticket::STATUS_CLOSED || $object->status == Ticket::STATUS_CANCELED) { $res = $object->setStatut(Ticket::STATUS_ASSIGNED); if ($res) { - // Log action in ticket logs table - //$log_action = $langs->trans('TicketLogReopen'); - $url = 'card.php?track_id='.$object->track_id; header("Location: ".$url); exit(); @@ -620,15 +612,13 @@ if (empty($reshook)) { } elseif ($action == "set_message" && $user->rights->ticket->manage) { if (!GETPOST('cancel')) { $object->fetch('', '', GETPOST('track_id', 'alpha')); - $oldvalue_message = $object->message; + //$oldvalue_message = $object->message; $fieldtomodify = GETPOST('message_initial', 'restricthtml'); $object->message = $fieldtomodify; $ret = $object->update($user); if ($ret > 0) { - //$log_action = $langs->trans('TicketInitialMessageModified')." \n"; - // include the Diff class - include_once DOL_DOCUMENT_ROOT.'/core/class/utils_diff.class.php'; + //include_once DOL_DOCUMENT_ROOT.'/core/class/utils_diff.class.php'; // output the result of comparing two files as plain text //$log_action .= Diff::toString(Diff::compare(strip_tags($oldvalue_message), strip_tags($object->message))); @@ -644,12 +634,9 @@ if (empty($reshook)) { // Reopen ticket if ($object->fetch(GETPOST('id', 'int'), GETPOST('track_id', 'alpha')) >= 0) { $new_status = GETPOST('new_status', 'int'); - $old_status = $object->status; + //$old_status = $object->status; $res = $object->setStatut($new_status); if ($res) { - // Log action in ticket logs table - $log_action = $langs->trans('TicketLogStatusChanged', $langs->transnoentities($object->statuts_short[$old_status]), $langs->transnoentities($object->statuts_short[$new_status])); - $url = 'card.php?track_id='.$object->track_id; header("Location: ".$url); exit(); @@ -694,8 +681,6 @@ if (empty($reshook)) { $ret = $object->update($user); if ($ret > 0) { - //$log_action = $langs->trans('TicketLogPropertyChanged', $oldvalue_label, $newvalue_label); - setEventMessages($langs->trans('TicketUpdated'), null, 'mesgs'); } else { $error++; diff --git a/htdocs/ticket/class/ticket.class.php b/htdocs/ticket/class/ticket.class.php index 86b9333e9a5..152520ae0b4 100644 --- a/htdocs/ticket/class/ticket.class.php +++ b/htdocs/ticket/class/ticket.class.php @@ -1401,7 +1401,7 @@ class Ticket extends CommonObject */ public function getLibStatut($mode = 0) { - return $this->libStatut($this->fk_statut, $mode, 0, $this->progress); + return $this->LibStatut($this->fk_statut, $mode, 0, $this->progress); } diff --git a/htdocs/webhook/class/target.class.php b/htdocs/webhook/class/target.class.php index e094ccfa4fb..2adb8f3f24c 100644 --- a/htdocs/webhook/class/target.class.php +++ b/htdocs/webhook/class/target.class.php @@ -299,25 +299,24 @@ class Target extends CommonObject $result = $object->createCommon($user); if ($result < 0) { $error++; - $this->error = $object->error; - $this->errors = $object->errors; + $this->setErrorsFromObject($object); } - if (!$error) { - // copy internal contacts - if ($this->copy_linked_contact($object, 'internal') < 0) { - $error++; - } - } + // if (!$error) { + // // copy internal contacts + // if ($this->copy_linked_contact($object, 'internal') < 0) { + // $error++; + // } + // } - if (!$error) { - // copy external contacts if same company - if (!empty($object->socid) && property_exists($this, 'fk_soc') && $this->fk_soc == $object->socid) { - if ($this->copy_linked_contact($object, 'external') < 0) { - $error++; - } - } - } + // if (!$error) { + // // copy external contacts if same company + // if (!empty($object->socid) && property_exists($this, 'fk_soc') && $this->fk_soc == $object->socid) { + // if ($this->copy_linked_contact($object, 'external') < 0) { + // $error++; + // } + // } + // } unset($object->context['createfromclone']); @@ -927,47 +926,38 @@ class Target extends CommonObject { global $langs, $conf; - if (empty($conf->global->WEBHOOK_TARGET_ADDON)) { - $conf->global->WEBHOOK_TARGET_ADDON = 'mod_target_standard'; + $mybool = false; + + $classname = getDolGlobalString('WEBHOOK_TARGET_ADDON', 'mod_target_standard'); + $file = $classname.".php"; + + // Include file with class + $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); + foreach ($dirmodels as $reldir) { + $dir = dol_buildpath($reldir."core/modules/webhook/"); + + // Load file with numbering class (if found) + $mybool |= @include_once $dir.$file; } - if (!empty($conf->global->WEBHOOK_TARGET_ADDON)) { - $mybool = false; + if ($mybool === false) { + dol_print_error('', "Failed to include file ".$file); + return ''; + } - $file = $conf->global->WEBHOOK_TARGET_ADDON.".php"; - $classname = $conf->global->WEBHOOK_TARGET_ADDON; + if (class_exists($classname)) { + $obj = new $classname(); + $numref = $obj->getNextValue($this); - // Include file with class - $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); - foreach ($dirmodels as $reldir) { - $dir = dol_buildpath($reldir."core/modules/webhook/"); - - // Load file with numbering class (if found) - $mybool |= @include_once $dir.$file; - } - - if ($mybool === false) { - dol_print_error('', "Failed to include file ".$file); - return ''; - } - - if (class_exists($classname)) { - $obj = new $classname(); - $numref = $obj->getNextValue($this); - - if ($numref != '' && $numref != '-1') { - return $numref; - } else { - $this->error = $obj->error; - //dol_print_error($this->db,get_class($this)."::getNextNumRef ".$obj->error); - return ""; - } + if ($numref != '' && $numref != '-1') { + return $numref; } else { - print $langs->trans("Error")." ".$langs->trans("ClassNotFound").' '.$classname; + $this->error = $obj->error; + //dol_print_error($this->db,get_class($this)."::getNextNumRef ".$obj->error); return ""; } } else { - print $langs->trans("ErrorNumberingModuleNotSetup", $this->element); + print $langs->trans("Error")." ".$langs->trans("ClassNotFound").' '.$classname; return ""; } } diff --git a/htdocs/webhook/target_card.php b/htdocs/webhook/target_card.php index 367c335ea5a..410afa94b0d 100644 --- a/htdocs/webhook/target_card.php +++ b/htdocs/webhook/target_card.php @@ -26,8 +26,10 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; -dol_include_once('/webhook/class/target.class.php'); -dol_include_once('/webhook/lib/webhook_target.lib.php'); +require_once DOL_DOCUMENT_ROOT.'/webhook/class/target.class.php'; +require_once DOL_DOCUMENT_ROOT.'/webhook/lib/webhook_target.lib.php'; + +global $conf, $db, $hookmanager, $langs, $user; // Load translation files required by the page $langs->loadLangs(array('other')); @@ -75,11 +77,11 @@ include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be includ // Set $enablepermissioncheck to 1 to enable a minimum low level of checks $enablepermissioncheck = 0; if ($enablepermissioncheck) { - $permissiontoread = $user->rights->webhook->target->read; - $permissiontoadd = $user->rights->webhook->target->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php - $permissiontodelete = $user->rights->webhook->target->delete || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT); - $permissionnote = $user->rights->webhook->target->write; // Used by the include of actions_setnotes.inc.php - $permissiondellink = $user->rights->webhook->target->write; // Used by the include of actions_dellink.inc.php + $permissiontoread = $user->hasRight('webhook', 'target', 'read'); + $permissiontoadd = $user->hasRight('webhook', 'target', 'write'); // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php + $permissiontodelete = $user->hasRight('webhook', 'target', 'delete') || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT); + $permissionnote = $user->hasRight('webhook', 'target', 'write'); // Used by the include of actions_setnotes.inc.php + $permissiondellink = $user->hasRight('webhook', 'target', 'write'); // Used by the include of actions_dellink.inc.php } else { $permissiontoread = 1; $permissiontoadd = 1; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php @@ -402,7 +404,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Show object lines $result = $object->getLinesArray(); - print '
+ print ' diff --git a/htdocs/webhook/target_list.php b/htdocs/webhook/target_list.php index 69b838733d8..cfca93ba7d3 100644 --- a/htdocs/webhook/target_list.php +++ b/htdocs/webhook/target_list.php @@ -31,8 +31,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; // load webhook libraries require_once DOL_DOCUMENT_ROOT.'/webhook/class/target.class.php'; -// for other modules -//dol_include_once('/othermodule/class/otherobject.class.php'); +global $conf, $db, $hookmanager, $langs, $user; // Load translation files required by the page $langs->loadLangs(array('other')); @@ -52,7 +51,7 @@ if (empty($mode)) { $mode = 'modulesetup'; } -$id = GETPOST('id', 'int'); +$id = GETPOST('id', 'int'); // Load variable for pagination $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; @@ -137,9 +136,9 @@ $arrayfields = dol_sort_array($arrayfields, 'position'); // Set $enablepermissioncheck to 1 to enable a minimum low level of checks $enablepermissioncheck = 0; if ($enablepermissioncheck) { - $permissiontoread = $user->rights->webhook->target->read; - $permissiontoadd = $user->rights->webhook->target->write; - $permissiontodelete = $user->rights->webhook->target->delete; + $permissiontoread = $user->hasRight('webhook', 'target', 'read'); + $permissiontoadd = $user->hasRight('webhook', 'target', 'write'); + $permissiontodelete = $user->hasRight('webhook', 'target', 'delete'); } else { $permissiontoread = 1; $permissiontoadd = 1; @@ -152,7 +151,7 @@ if ($user->socid > 0) accessforbidden(); //$socid = 0; if ($user->socid > 0) $socid = $user->socid; //$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0); //restrictedArea($user, $object->element, 0, $object->table_element, '', 'fk_soc', 'rowid', $isdraft); -if (empty($conf->webhook->enabled)) accessforbidden('Module not enabled'); +if (!isModEnabled('webhook')) accessforbidden('Module not enabled'); if (!$permissiontoread) accessforbidden(); diff --git a/htdocs/workstation/workstation_agenda.php b/htdocs/workstation/workstation_agenda.php index 1e181ac46bd..cf5fb59a258 100644 --- a/htdocs/workstation/workstation_agenda.php +++ b/htdocs/workstation/workstation_agenda.php @@ -31,6 +31,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/workstation/class/workstation.class.php'; require_once DOL_DOCUMENT_ROOT.'/workstation/lib/workstation_workstation.lib.php'; +global $conf, $db, $hookmanager, $langs, $user; + // Load translation files required by the page $langs->loadLangs(array('mrp', 'other')); @@ -87,7 +89,7 @@ if ($id > 0 || !empty($ref)) { } // Permissions -$permissiontoadd = $user->rights->workstation->workstation->write; // Used by the include of actions_addupdatedelete.inc.php +$permissiontoadd = $user->hasRight('workstation', 'workstation', 'write'); // Used by the include of actions_addupdatedelete.inc.php // Security check $isdraft = 0; diff --git a/htdocs/workstation/workstation_card.php b/htdocs/workstation/workstation_card.php index dfeccf54a87..0a1eb0a4c78 100644 --- a/htdocs/workstation/workstation_card.php +++ b/htdocs/workstation/workstation_card.php @@ -32,6 +32,8 @@ require_once DOL_DOCUMENT_ROOT.'/workstation/class/workstation.class.php'; require_once DOL_DOCUMENT_ROOT.'/workstation/class/workstationusergroup.class.php'; require_once DOL_DOCUMENT_ROOT.'/workstation/lib/workstation_workstation.lib.php'; +global $conf, $db, $hookmanager, $langs, $user; + // Load translation files required by the page $langs->loadLangs(array('mrp', 'other')); @@ -78,11 +80,11 @@ if (empty($action) && empty($id) && empty($ref)) { include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once. // Permissions -$permissiontoread = $user->rights->workstation->workstation->read; -$permissiontoadd = $user->rights->workstation->workstation->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php -$permissiontodelete = $user->rights->workstation->workstation->delete || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT); -$permissionnote = $user->rights->workstation->workstation->write; // Used by the include of actions_setnotes.inc.php -$permissiondellink = $user->rights->workstation->workstation->write; // Used by the include of actions_dellink.inc.php +$permissiontoread = $user->hasRight('workstation', 'workstation', 'read'); +$permissiontoadd = $user->hasRight('workstation', 'workstation', 'write'); // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php +$permissiontodelete = $user->hasRight('workstation', 'workstation', 'delete') || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DISABLED); +$permissionnote = $user->hasRight('workstation', 'workstation', 'write'); // Used by the include of actions_setnotes.inc.php +$permissiondellink = $user->hasRight('workstation', 'workstation', 'write'); // Used by the include of actions_dellink.inc.php $upload_dir = $conf->workstation->multidir_output[isset($object->entity) ? $object->entity : 1]; @@ -161,7 +163,7 @@ llxHeader('', $title, $help_url); // jquery code ?> -