From 8bc795c05555cafaf08366e88d290dee0c16cabf Mon Sep 17 00:00:00 2001 From: John BOTELLA Date: Thu, 14 Mar 2019 15:19:38 +0100 Subject: [PATCH 1/5] Fix missing hook for export agenda --- htdocs/comm/action/class/actioncomm.class.php | 11 +++++++++++ htdocs/public/agenda/agendaexport.php | 2 ++ 2 files changed, 13 insertions(+) diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index e5a90c86661..0205281f117 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -1456,6 +1456,11 @@ class ActionComm extends CommonObject $sql.= " FROM (".MAIN_DB_PREFIX."c_actioncomm as c, ".MAIN_DB_PREFIX."actioncomm as a)"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on u.rowid = a.fk_user_author"; // Link to get author of event for export $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on s.rowid = a.fk_soc"; + + $parameters=array('filters' => $filters); + $reshook=$hookmanager->executeHooks('printFieldListFrom', $parameters); // Note that $action and $object may have been modified by hook + $sql.=$hookmanager->resPrint; + // We must filter on assignement table if ($filters['logint']) $sql.=", ".MAIN_DB_PREFIX."actioncomm_resources as ar"; $sql.= " WHERE a.fk_action=c.id"; @@ -1501,7 +1506,13 @@ class ActionComm extends CommonObject elseif ($result < 0 || $condition == '=') $sql.= " AND ar.fk_element = 0"; } } + $sql.= " AND a.datep IS NOT NULL"; // To exclude corrupted events and avoid errors in lightning/sunbird import + + $parameters=array('filters' => $filters); + $reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook + $sql.=$hookmanager->resPrint; + $sql.= " ORDER by datep"; //print $sql;exit; diff --git a/htdocs/public/agenda/agendaexport.php b/htdocs/public/agenda/agendaexport.php index 6e08f06d630..a69c940f7e2 100644 --- a/htdocs/public/agenda/agendaexport.php +++ b/htdocs/public/agenda/agendaexport.php @@ -106,6 +106,8 @@ if (empty($_GET["exportkey"]) || $conf->global->MAIN_AGENDA_XCAL_EXPORTKEY != $_ exit; } +// Initialize technical object to manage hooks. Note that conf->hooks_modules contains array of hooks +$hookmanager->initHooks(array('agendaexport')); // Define filename with prefix on filters predica (each predica set must have on cache file) $shortfilename='dolibarrcalendar'; From 5ccfba12106cc55d8101153a9310bf0659669da6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 14 Mar 2019 16:03:37 +0100 Subject: [PATCH 2/5] FIX Edit of personalized groups Conflicts: htdocs/accountancy/admin/categories.php --- htdocs/accountancy/admin/categories.php | 13 +++++++------ .../class/accountancycategory.class.php | 15 +++++++++++---- htdocs/langs/en_US/accountancy.lang | 3 ++- 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/htdocs/accountancy/admin/categories.php b/htdocs/accountancy/admin/categories.php index 6e003738173..9b3ca9ebddc 100644 --- a/htdocs/accountancy/admin/categories.php +++ b/htdocs/accountancy/admin/categories.php @@ -60,8 +60,8 @@ $accountingcategory = new AccountancyCategory($db); // si ajout de comptes if (! empty($selectcpt)) { - $cpts = array (); - foreach ( $selectcpt as $selectedoption ) { + $cpts = array(); + foreach ($selectcpt as $selectedoption) { if (! array_key_exists($selectedoption, $cpts)) $cpts[$selectedoption] = "'" . $selectedoption . "'"; } @@ -71,13 +71,13 @@ if (! empty($selectcpt)) { if ($return<0) { setEventMessages($langs->trans('errors'), $accountingcategory->errors, 'errors'); } else { - setEventMessages($langs->trans('SetupSaved'), null, 'mesgs'); + setEventMessages($langs->trans('RecordModifiedSuccessfully'), null, 'mesgs'); } } if ($action == 'delete') { if ($cpt_id) { if ($accountingcategory->deleteCptCat($cpt_id)) { - setEventMessages($langs->trans('CategoryDeleted'), null, 'mesgs'); + setEventMessages($langs->trans('AccountRemovedFromGroup'), null, 'mesgs'); } else { setEventMessages($langs->trans('errors'), null, 'errors'); } @@ -173,8 +173,9 @@ if ($action == 'display' || $action == 'delete') { print '' . $cpt->label . ''; print ''; print ""; - print img_delete($langs->trans("DeleteFromCat")).' '; - print $langs->trans("DeleteFromCat").""; + print $langs->trans("DeleteFromCat"); + print img_picto($langs->trans("DeleteFromCat"), 'unlink'); + print ""; print ""; print "\n"; } diff --git a/htdocs/accountancy/class/accountancycategory.class.php b/htdocs/accountancy/class/accountancycategory.class.php index a6c9f09c7cb..f7421acba3c 100644 --- a/htdocs/accountancy/class/accountancycategory.class.php +++ b/htdocs/accountancy/class/accountancycategory.class.php @@ -514,7 +514,7 @@ class AccountancyCategory // extends CommonObject /** * Function to select accounting category of an accounting account present in chart of accounts * - * @param int $id Id category + * @param int $id Id of category to know which account to exclude * * @return int <0 if KO, 0 if not found, >0 if OK */ @@ -569,12 +569,13 @@ class AccountancyCategory // extends CommonObject require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; - $sql = "SELECT aa.rowid,aa.account_number "; + $sql = "SELECT aa.rowid, aa.account_number"; $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as aa"; $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version"; $sql .= " AND asy.rowid = " . $conf->global->CHARTOFACCOUNTS; $sql .= " AND aa.active = 1"; $sql .= " AND aa.entity = " . $conf->entity; + $sql .= " ORDER BY LENGTH(aa.account_number) DESC;"; // LENGTH is ok with mysql and postgresql $this->db->begin(); @@ -587,10 +588,16 @@ class AccountancyCategory // extends CommonObject return -1; } - while ( $obj = $this->db->fetch_object($resql)) + $accountincptsadded=array(); + while ($obj = $this->db->fetch_object($resql)) { - if (array_key_exists(length_accountg($obj->account_number), $cpts)) + $account_number_formated=length_accountg($obj->account_number); + if (! empty($accountincptsadded[$account_number_formated])) continue; + + if (array_key_exists($account_number_formated, $cpts)) { + $accountincptsadded[$account_number_formated]=1; + // We found an account number that is in list $cpts of account to add $sql = "UPDATE " . MAIN_DB_PREFIX . "accounting_account"; $sql .= " SET fk_accounting_category=" . $id_cat; $sql .= " WHERE rowid=".$obj->rowid; diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang index e2f6083e6a6..31f3d5e264a 100644 --- a/htdocs/langs/en_US/accountancy.lang +++ b/htdocs/langs/en_US/accountancy.lang @@ -238,7 +238,7 @@ NotYetAccounted=Not yet accounted in ledger ## Admin ApplyMassCategories=Apply mass categories -AddAccountFromBookKeepingWithNoCategories=Available account not yet in a personalized group +AddAccountFromBookKeepingWithNoCategories=Available account not yet in the personalized group CategoryDeleted=Category for the accounting account has been removed AccountingJournals=Accounting journals AccountingJournal=Accounting journal @@ -287,6 +287,7 @@ PredefinedGroups=Predefined groups WithoutValidAccount=Without valid dedicated account WithValidAccount=With valid dedicated account ValueNotIntoChartOfAccount=This value of accounting account does not exist into chart of account +AccountRemovedFromGroup=Account removed from group ## Dictionary Range=Range of accounting account From 31e588dbab8a6a9d93793e0f934298de75c2f8f9 Mon Sep 17 00:00:00 2001 From: John BOTELLA Date: Thu, 14 Mar 2019 16:13:32 +0100 Subject: [PATCH 3/5] fix hookmanager global --- htdocs/comm/action/class/actioncomm.class.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 0205281f117..fd91864af04 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -1391,6 +1391,8 @@ class ActionComm extends CommonObject */ function build_exportfile($format,$type,$cachedelay,$filename,$filters) { + global $hookmanager; + // phpcs:enable global $conf,$langs,$dolibarr_main_url_root,$mysoc; From 8410d59182c558ecb36cbea899ca587c9af71444 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 14 Mar 2019 16:16:50 +0100 Subject: [PATCH 4/5] FIX Missing field "In sale" in list --- htdocs/accountancy/admin/productaccount.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/accountancy/admin/productaccount.php b/htdocs/accountancy/admin/productaccount.php index 246d3752f56..389dd8df7b8 100644 --- a/htdocs/accountancy/admin/productaccount.php +++ b/htdocs/accountancy/admin/productaccount.php @@ -65,6 +65,8 @@ $accounting_product_mode = GETPOST('accounting_product_mode', 'alpha'); $btn_changeaccount = GETPOST('changeaccount', 'alpha'); $btn_changetype = GETPOST('changetype', 'alpha'); +if (empty($accounting_product_mode)) $accounting_product_mode='ACCOUNTANCY_SELL'; + $limit = GETPOST('limit','int')?GETPOST('limit','int'):(empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)?$conf->liste_limit:$conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION); $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); @@ -112,8 +114,6 @@ if ($action == 'update') { 'ACCOUNTANCY_BUY' ); - $accounting_product_mode = GETPOST('accounting_product_mode', 'alpha'); - if (in_array($accounting_product_mode, $accounting_product_modes)) { if (! dolibarr_set_const($db, 'ACCOUNTING_PRODUCT_MODE', $accounting_product_mode, 'chaine', 0, '', $conf->entity)) { From b67429218df35b67d5df8c4a38840155e267fa1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 14 Mar 2019 08:19:22 +0100 Subject: [PATCH 5/5] Update html.formmail.class.php Conflicts: htdocs/core/class/html.formmail.class.php --- htdocs/core/class/html.formmail.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index 6dd2264bf8b..c42acac2549 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -78,7 +78,7 @@ class FormMail extends Form /** * @var int * @deprecated Fill withto with array before calling method. - * @see withto + * @see $withto */ public $withtosocid; @@ -1290,7 +1290,7 @@ class FormMail extends Form * @param CommonObject $object Object to use * @param Translate $outputlangs Object lang * @return void - * @see getCommonSubstitutionArray + * @see getCommonSubstitutionArray() */ function setSubstitFromObject($object, $outputlangs) {