From 91d6a1b6216547142c2f3f9c7704ec0b85031340 Mon Sep 17 00:00:00 2001 From: atm-greg Date: Tue, 27 Mar 2018 06:40:12 +0200 Subject: [PATCH 01/31] fix sql error using no category --- htdocs/compta/bank/bankentries_list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/bank/bankentries_list.php b/htdocs/compta/bank/bankentries_list.php index 91e496d998c..d773d8ce8e4 100644 --- a/htdocs/compta/bank/bankentries_list.php +++ b/htdocs/compta/bank/bankentries_list.php @@ -455,7 +455,7 @@ $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldListSelect',$parameters); // Note that $action and $object may have been modified by hook $sql.=$hookmanager->resPrint; $sql.= " FROM "; -if ($search_bid) $sql.= MAIN_DB_PREFIX."bank_class as l,"; +if ($search_bid>0) $sql.= MAIN_DB_PREFIX."bank_class as l,"; $sql.= " ".MAIN_DB_PREFIX."bank_account as ba,"; $sql.= " ".MAIN_DB_PREFIX."bank as b"; if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_extrafields as ef on (b.rowid = ef.fk_object)"; From 930512d9a2e50df08654ffd637fe780e535a3b0b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 27 Mar 2018 13:08:16 +0200 Subject: [PATCH 02/31] FIX Add a test to avoid to reset binding by error. --- htdocs/accountancy/customer/index.php | 28 +---------- htdocs/accountancy/customer/lines.php | 44 ++++++++++------- htdocs/accountancy/expensereport/index.php | 28 +---------- htdocs/accountancy/expensereport/lines.php | 47 +++++++++++-------- htdocs/accountancy/supplier/index.php | 28 +---------- htdocs/accountancy/supplier/lines.php | 45 +++++++++++------- .../core/class/html.formaccounting.class.php | 11 +++-- 7 files changed, 94 insertions(+), 137 deletions(-) diff --git a/htdocs/accountancy/customer/index.php b/htdocs/accountancy/customer/index.php index b7d61674fd8..aedaeda0e5b 100644 --- a/htdocs/accountancy/customer/index.php +++ b/htdocs/accountancy/customer/index.php @@ -117,30 +117,6 @@ if ($action == 'validatehistory') { $db->commit(); setEventMessages($langs->trans('AutomaticBindingDone'), null, 'mesgs'); } -} elseif ($action == 'cleanaccountancycode') { - $error = 0; - $db->begin(); - - // Now clean - $sql1 = "UPDATE " . MAIN_DB_PREFIX . "facturedet as fd"; - $sql1.= " SET fk_code_ventilation = 0"; - $sql1.= " WHERE fd.fk_facture IN ( SELECT f.rowid FROM " . MAIN_DB_PREFIX . "facture as f"; - $sql1.= " WHERE f.datef >= '" . $db->idate($search_date_start) . "'"; - $sql1.= " AND f.datef <= '" . $db->idate($search_date_end) . "'"; - $sql1.= " AND f.entity IN (" . getEntity('accountancy') . ")"; - $sql1.=")"; - - dol_syslog("htdocs/accountancy/customer/index.php cleanaccountancycode", LOG_DEBUG); - - $resql1 = $db->query($sql1); - if (! $resql1) { - $error ++; - $db->rollback(); - setEventMessage($db->lasterror(), 'errors'); - } else { - $db->commit(); - setEventMessage($langs->trans('Done'), 'mesgs'); - } } @@ -183,8 +159,6 @@ print '
'; $y = $year_current; $buttonbind = '' . $langs->trans("ValidateHistory") . ''; -$buttonreset = ''; -if ($conf->global->MAIN_FEATURES_LEVEL >= 2) $buttonreset = '' . $langs->trans("CleanHistory", $year_current) . ''; print_fiche_titre($langs->trans("OverviewOfAmountOfLinesNotBound"), $buttonbind, ''); @@ -262,7 +236,7 @@ print ''; print '
'; -print_fiche_titre($langs->trans("OverviewOfAmountOfLinesBound"), $buttonreset, ''); +print_fiche_titre($langs->trans("OverviewOfAmountOfLinesBound"), '', ''); print '
'; print ''; diff --git a/htdocs/accountancy/customer/lines.php b/htdocs/accountancy/customer/lines.php index c4c3d03ee97..e696b4774d1 100644 --- a/htdocs/accountancy/customer/lines.php +++ b/htdocs/accountancy/customer/lines.php @@ -110,27 +110,37 @@ if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x', if (is_array($changeaccount) && count($changeaccount) > 0) { $error = 0; + if (! (GETPOST('account_parent','int') >= 0)) + { + $error++; + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Account")), null, 'errors'); + } + $db->begin(); - $sql1 = "UPDATE " . MAIN_DB_PREFIX . "facturedet as l"; - $sql1 .= " SET l.fk_code_ventilation=" . GETPOST('account_parent','int'); - $sql1 .= ' WHERE l.rowid IN (' . implode(',', $changeaccount) . ')'; + if (! $error) + { + $sql1 = "UPDATE " . MAIN_DB_PREFIX . "facturedet as l"; + $sql1 .= " SET l.fk_code_ventilation=" . (GETPOST('account_parent','int') > 0 ? GETPOST('account_parent','int') : '0'); + $sql1 .= ' WHERE l.rowid IN (' . implode(',', $changeaccount) . ')'; - dol_syslog('accountancy/customer/lines.php::changeaccount sql= ' . $sql1); - $resql1 = $db->query($sql1); - if (! $resql1) { - $error ++; - setEventMessages($db->lasterror(), null, 'errors'); - } - if (! $error) { - $db->commit(); - setEventMessages($langs->trans('Save'), null, 'mesgs'); - } else { - $db->rollback(); - setEventMessages($db->lasterror(), null, 'errors'); + dol_syslog('accountancy/customer/lines.php::changeaccount sql= ' . $sql1); + $resql1 = $db->query($sql1); + if (! $resql1) { + $error ++; + setEventMessages($db->lasterror(), null, 'errors'); + } + if (! $error) { + $db->commit(); + setEventMessages($langs->trans('Save'), null, 'mesgs'); + } else { + $db->rollback(); + setEventMessages($db->lasterror(), null, 'errors'); + } + + $account_parent = ''; // Protection to avoid to mass apply it a second time } - $account_parent = ''; // Protection to avoid to mass apply it a second time } @@ -272,7 +282,7 @@ if ($result) { print $langs->trans("DescVentilDoneCustomer") . '
'; print '
' . $langs->trans("ChangeAccount") . '
'; - print $formaccounting->select_account($account_parent, 'account_parent', 1); + print $formaccounting->select_account($account_parent, 'account_parent', 2, array(), 0, 0, 'maxwidth300 maxwidthonsmartphone valignmiddle'); print '
'; $moreforfilter = ''; diff --git a/htdocs/accountancy/expensereport/index.php b/htdocs/accountancy/expensereport/index.php index 0768ee01bf8..cec7fbdced4 100644 --- a/htdocs/accountancy/expensereport/index.php +++ b/htdocs/accountancy/expensereport/index.php @@ -114,30 +114,6 @@ if ($action == 'validatehistory') { $db->commit(); setEventMessages($langs->trans('AutomaticBindingDone'), null, 'mesgs'); } -} elseif ($action == 'cleanaccountancycode') { - $error = 0; - $db->begin(); - - // Now clean - $sql1 = "UPDATE " . MAIN_DB_PREFIX . "expensereport_det as erd"; - $sql1.= " SET fk_code_ventilation = 0"; - $sql1.= " WHERE erd.fk_expensereport IN ( SELECT er.rowid FROM " . MAIN_DB_PREFIX . "expensereport as er"; - $sql1.= " WHERE er.date_debut >= '" . $db->idate($search_date_start) . "'"; - $sql1.= " AND er.date_debut <= '" . $db->idate($search_date_end) . "'"; - $sql1.= " AND er.entity IN (" . getEntity('accountancy') . ")"; - $sql1.=")"; - - dol_syslog("htdocs/accountancy/customer/index.php cleanaccountancycode", LOG_DEBUG); - - $resql1 = $db->query($sql1); - if (! $resql1) { - $error ++; - $db->rollback(); - setEventMessage($db->lasterror(), 'errors'); - } else { - $db->commit(); - setEventMessage($langs->trans('Done'), 'mesgs'); - } } @@ -180,8 +156,6 @@ print '
'; $y = $year_current; $buttonbind = '' . $langs->trans("ValidateHistory") . ''; -$buttonreset = ''; -if ($conf->global->MAIN_FEATURES_LEVEL >= 2) $buttonreset = '' . $langs->trans("CleanHistory", $year_current) . ''; print_fiche_titre($langs->trans("OverviewOfAmountOfLinesNotBound"), $buttonbind, ''); @@ -253,7 +227,7 @@ print ''; print '
'; -print_fiche_titre($langs->trans("OverviewOfAmountOfLinesBound"), $buttonreset, ''); +print_fiche_titre($langs->trans("OverviewOfAmountOfLinesBound"), '', ''); print '
'; diff --git a/htdocs/accountancy/expensereport/lines.php b/htdocs/accountancy/expensereport/lines.php index e00b4527818..28a44d23a5e 100644 --- a/htdocs/accountancy/expensereport/lines.php +++ b/htdocs/accountancy/expensereport/lines.php @@ -43,7 +43,7 @@ $langs->load("accountancy"); $langs->load("trips"); $langs->load("productbatch"); -$account_parent = GETPOST('account_parent'); +$account_parent = GETPOST('account_parent','int'); $changeaccount = GETPOST('changeaccount'); // Search Getpost $search_expensereport = GETPOST('search_expensereport', 'alpha'); @@ -103,27 +103,36 @@ if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x', if (is_array($changeaccount) && count($changeaccount) > 0) { $error = 0; + if (! (GETPOST('account_parent','int') >= 0)) + { + $error++; + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Account")), null, 'errors'); + } + $db->begin(); - $sql1 = "UPDATE " . MAIN_DB_PREFIX . "expensereport_det as erd"; - $sql1 .= " SET erd.fk_code_ventilation=" . GETPOST('account_parent','int'); - $sql1 .= ' WHERE erd.rowid IN (' . implode(',', $changeaccount) . ')'; + if (! $error) + { + $sql1 = "UPDATE " . MAIN_DB_PREFIX . "expensereport_det as erd"; + $sql1 .= " SET erd.fk_code_ventilation=" . (GETPOST('account_parent','int') > 0 ? GETPOST('account_parent','int') : '0'); + $sql1 .= ' WHERE erd.rowid IN (' . implode(',', $changeaccount) . ')'; - dol_syslog('accountancy/expensereport/lines.php::changeaccount sql= ' . $sql1); - $resql1 = $db->query($sql1); - if (! $resql1) { - $error ++; - setEventMessages($db->lasterror(), null, 'errors'); - } - if (! $error) { - $db->commit(); - setEventMessages($langs->trans('Save'), null, 'mesgs'); - } else { - $db->rollback(); - setEventMessages($db->lasterror(), null, 'errors'); - } + dol_syslog('accountancy/expensereport/lines.php::changeaccount sql= ' . $sql1); + $resql1 = $db->query($sql1); + if (! $resql1) { + $error ++; + setEventMessages($db->lasterror(), null, 'errors'); + } + if (! $error) { + $db->commit(); + setEventMessages($langs->trans('Save'), null, 'mesgs'); + } else { + $db->rollback(); + setEventMessages($db->lasterror(), null, 'errors'); + } - $account_parent = ''; // Protection to avoid to mass apply it a second time + $account_parent = ''; // Protection to avoid to mass apply it a second time + } } @@ -246,7 +255,7 @@ if ($result) { print $langs->trans("DescVentilDoneExpenseReport") . '
'; print '
' . $langs->trans("ChangeAccount") . '
'; - print $formaccounting->select_account(GETPOST('account_parent'), 'account_parent', 1); + print $formaccounting->select_account($account_parent, 'account_parent', 2, array(), 0, 0, 'maxwidth300 maxwidthonsmartphone valignmiddle'); print '
'; $moreforfilter = ''; diff --git a/htdocs/accountancy/supplier/index.php b/htdocs/accountancy/supplier/index.php index 1425dde58f7..e9935fc8d78 100644 --- a/htdocs/accountancy/supplier/index.php +++ b/htdocs/accountancy/supplier/index.php @@ -115,31 +115,9 @@ if ($action == 'validatehistory') { $db->commit(); setEventMessages($langs->trans('AutomaticBindingDone'), null, 'mesgs'); } -} elseif ($action == 'cleanaccountancycode') { - $error = 0; - $db->begin(); - - $sql1 = "UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det as fd"; - $sql1.= " SET fk_code_ventilation = 0"; - $sql1.= " WHERE fd.fk_facture_fourn IN ( SELECT f.rowid FROM " . MAIN_DB_PREFIX . "facture_fourn as f"; - $sql1.= " WHERE f.datef >= '" . $db->idate(dol_get_first_day($year_current, 1, false)) . "'"; - $sql1.= " AND f.datef <= '" . $db->idate(dol_get_last_day($year_current, 12, false)) . "'"; - $sql1.= " AND f.entity IN (" . getEntity('accountancy') . ")"; - $sql1.= ")"; - - dol_syslog("htdocs/accountancy/customer/index.php cleanaccountancycode", LOG_DEBUG); - - $resql1 = $db->query($sql1); - if (! $resql1) { - $error ++; - $db->rollback(); - setEventMessage($db->lasterror(), 'errors'); - } else { - $db->commit(); - setEventMessage($langs->trans('Done'), 'mesgs'); - } } + /* * View */ @@ -178,8 +156,6 @@ print '
'; $y = $year_current; $buttonbind = '' . $langs->trans("ValidateHistory") . ''; -$buttonreset = ''; -if ($conf->global->MAIN_FEATURES_LEVEL >= 2) $buttonreset = '' . $langs->trans("CleanHistory", $year_current) . ''; print_fiche_titre($langs->trans("OverviewOfAmountOfLinesNotBound"), $buttonbind, ''); @@ -252,7 +228,7 @@ print '
'; print '
'; -print_fiche_titre($langs->trans("OverviewOfAmountOfLinesBound"), $buttonreset, ''); +print_fiche_titre($langs->trans("OverviewOfAmountOfLinesBound"), '', ''); print '
'; print '
'; diff --git a/htdocs/accountancy/supplier/lines.php b/htdocs/accountancy/supplier/lines.php index af9d82e5056..6ad8731a415 100644 --- a/htdocs/accountancy/supplier/lines.php +++ b/htdocs/accountancy/supplier/lines.php @@ -111,27 +111,36 @@ if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x', if (is_array($changeaccount) && count($changeaccount) > 0) { $error = 0; + if (! (GETPOST('account_parent','int') >= 0)) + { + $error++; + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Account")), null, 'errors'); + } + $db->begin(); - $sql1 = "UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det as l"; - $sql1 .= " SET l.fk_code_ventilation=" . GETPOST('account_parent','int'); - $sql1 .= ' WHERE l.rowid IN (' . implode(',', $changeaccount) . ')'; + if (! $error) + { + $sql1 = "UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det as l"; + $sql1 .= " SET l.fk_code_ventilation=" . (GETPOST('account_parent','int') > 0 ? GETPOST('account_parent','int') : '0'); + $sql1 .= ' WHERE l.rowid IN (' . implode(',', $changeaccount) . ')'; - dol_syslog('accountancy/supplier/lines.php::changeaccount sql= ' . $sql1); - $resql1 = $db->query($sql1); - if (! $resql1) { - $error ++; - setEventMessages($db->lasterror(), null, 'errors'); - } - if (! $error) { - $db->commit(); - setEventMessages($langs->trans('Save'), null, 'mesgs'); - } else { - $db->rollback(); - setEventMessages($db->lasterror(), null, 'errors'); - } + dol_syslog('accountancy/supplier/lines.php::changeaccount sql= ' . $sql1); + $resql1 = $db->query($sql1); + if (! $resql1) { + $error ++; + setEventMessages($db->lasterror(), null, 'errors'); + } + if (! $error) { + $db->commit(); + setEventMessages($langs->trans('Save'), null, 'mesgs'); + } else { + $db->rollback(); + setEventMessages($db->lasterror(), null, 'errors'); + } - $account_parent = ''; // Protection to avoid to mass apply it a second time + $account_parent = ''; // Protection to avoid to mass apply it a second time + } } @@ -269,7 +278,7 @@ if ($result) { print $langs->trans("DescVentilDoneSupplier") . '
'; print '
' . $langs->trans("ChangeAccount") . '
'; - print $formaccounting->select_account($account_parent, 'account_parent', 1); + print $formaccounting->select_account($account_parent, 'account_parent', 2, array(), 0, 0, 'maxwidth300 maxwidthonsmartphone valignmiddle'); print '
'; $moreforfilter = ''; diff --git a/htdocs/core/class/html.formaccounting.class.php b/htdocs/core/class/html.formaccounting.class.php index aaae010c2fe..a79f01352e8 100644 --- a/htdocs/core/class/html.formaccounting.class.php +++ b/htdocs/core/class/html.formaccounting.class.php @@ -243,7 +243,7 @@ class FormAccounting extends Form * * @param string $selectid Preselected id or code of accounting accounts (depends on $select_in) * @param string $htmlname Name of HTML field id. If name start with '.', it is name of HTML css class, so several component with same name in different forms can be used. - * @param int $showempty Add an empty field + * @param int $showempty 1=Add an empty field, 2=Add an empty field+'None' field * @param array $event Event options * @param int $select_in 0=selectid value is a aa.rowid (default) or 1=selectid is aa.account_number * @param int $select_out Set value returned by select. 0=rowid (default), 1=account_number @@ -253,7 +253,7 @@ class FormAccounting extends Form */ function select_account($selectid, $htmlname = 'account', $showempty = 0, $event = array(), $select_in = 0, $select_out = 0, $morecss='maxwidth300 maxwidthonsmartphone', $usecache='') { - global $conf; + global $conf, $langs; require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; @@ -318,7 +318,12 @@ class FormAccounting extends Form } } - $out .= Form::selectarray($htmlname, $options, $selected, $showempty, 0, 0, '', 0, 0, 0, '', $morecss, 1); + if ($showempty == 2) + { + $options['0'] = $langs->trans("None"); + } + + $out .= Form::selectarray($htmlname, $options, $selected, ($showempty > 0 ? 1 : 0), 0, 0, '', 0, 0, 0, '', $morecss, 1); return $out; } From 2b588b9e43a03c3d2c7c18e27b9a45b4ea67b036 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 27 Mar 2018 13:37:40 +0200 Subject: [PATCH 03/31] FIX Initial month on report income/expense per predefined group --- htdocs/compta/resultat/clientfourn.php | 6 +++--- htdocs/compta/resultat/index.php | 7 ++++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/htdocs/compta/resultat/clientfourn.php b/htdocs/compta/resultat/clientfourn.php index d78cbabb34f..f105c11160c 100644 --- a/htdocs/compta/resultat/clientfourn.php +++ b/htdocs/compta/resultat/clientfourn.php @@ -107,13 +107,13 @@ if (empty($date_start) || empty($date_end)) // We define date_start and date_end if ($q==4) { $date_start=dol_get_first_day($year_start,10,false); $date_end=dol_get_last_day($year_start,12,false); } } -// $date_start and $date_end are defined. We force $start_year and $nbofyear +// $date_start and $date_end are defined. We force $year_start and $nbofyear $tmps=dol_getdate($date_start); -$start_year = $tmps['year']; +$year_start = $tmps['year']; $tmpe=dol_getdate($date_end); $year_end = $tmpe['year']; $nbofyear = ($year_end - $start_year) + 1; -//var_dump($start_year." ".$end_year." ".$nbofyear); +//var_dump("year_start=".$year_start." year_end=".$year_end." nbofyear=".$nbofyear." date_start=".dol_print_date($date_start, 'dayhour')." date_end=".dol_print_date($date_end, 'dayhour')); // Define modecompta ('CREANCES-DETTES' or 'RECETTES-DEPENSES' or 'BOOKKEEPING') $modecompta = $conf->global->ACCOUNTING_MODE; diff --git a/htdocs/compta/resultat/index.php b/htdocs/compta/resultat/index.php index 26f12e3f7c5..c35f084af40 100644 --- a/htdocs/compta/resultat/index.php +++ b/htdocs/compta/resultat/index.php @@ -85,13 +85,14 @@ if (empty($date_start) || empty($date_end)) // We define date_start and date_end if ($q==4) { $date_start=dol_get_first_day($year_start,10,false); $date_end=dol_get_last_day($year_start,12,false); } } -// $date_start and $date_end are defined. We force $start_year and $nbofyear +// $date_start and $date_end are defined. We force $year_start and $nbofyear $tmps=dol_getdate($date_start); -$start_year = $tmps['year']; +$year_start = $tmps['year']; $tmpe=dol_getdate($date_end); $year_end = $tmpe['year']; $nbofyear = ($year_end - $start_year) + 1; -//var_dump($start_year." ".$end_year." ".$nbofyear); +//var_dump("year_start=".$year_start." year_end=".$year_end." nbofyear=".$nbofyear." date_start=".dol_print_date($date_start, 'dayhour')." date_end=".dol_print_date($date_end, 'dayhour')); + // Security check $socid = GETPOST('socid','int'); From 0b13cd17acf2b0f604f2fb386c30adf9b112d091 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 27 Mar 2018 13:55:10 +0200 Subject: [PATCH 04/31] FIX Some report have data when several chart of accounts exists FIX Detail per account not visible when total < 0 --- htdocs/compta/resultat/clientfourn.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/resultat/clientfourn.php b/htdocs/compta/resultat/clientfourn.php index f105c11160c..2967e31be76 100644 --- a/htdocs/compta/resultat/clientfourn.php +++ b/htdocs/compta/resultat/clientfourn.php @@ -255,6 +255,7 @@ if ($modecompta == 'BOOKKEEPING') $sql.= " WHERE f.numero_compte = aa.account_number"; //$sql.= " AND fk_statut in (1,2)"; $sql.= " AND ".$predefinedgroupwhere; + $sql.= " AND fk_pcg_version = '".$db->escape($charofaccountstring)."'"; $sql.= " AND f.entity = ".$conf->entity; if (! empty($date_start) && ! empty($date_end)) $sql.= " AND f.doc_date >= '".$db->idate($date_start)."' AND f.doc_date <= '".$db->idate($date_end)."'"; @@ -295,7 +296,7 @@ if ($modecompta == 'BOOKKEEPING') if ($showaccountdetail != 'no') { $tmppredefinedgroupwhere="pcg_type = '".$db->escape($objp->pcg_type)."' AND pcg_subtype = '".$db->escape($objp->pcg_subtype)."'"; - $tmppredefinedgroupwhere.= " AND fk_pcg_version = '".$charofaccountstring."'"; + $tmppredefinedgroupwhere.= " AND fk_pcg_version = '".$db->escape($charofaccountstring)."'"; //$tmppredefinedgroupwhere.= " AND thirdparty_code = '".$db->escape($objp->name)."'"; // Get cpts of category/group @@ -312,7 +313,7 @@ if ($modecompta == 'BOOKKEEPING') } - if ($showaccountdetail == 'all' || $resultN > 0) + if ($showaccountdetail == 'all' || $resultN <> 0) { print ''; print ''; From f9ee2930e2bdd80e052120973c193190da619263 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 27 Mar 2018 14:16:59 +0200 Subject: [PATCH 05/31] FIX Data on income/expense report was always 0 --- htdocs/compta/resultat/clientfourn.php | 1 - htdocs/compta/resultat/index.php | 85 ++++++++++++++++---------- 2 files changed, 52 insertions(+), 34 deletions(-) diff --git a/htdocs/compta/resultat/clientfourn.php b/htdocs/compta/resultat/clientfourn.php index 2967e31be76..b717b58edd2 100644 --- a/htdocs/compta/resultat/clientfourn.php +++ b/htdocs/compta/resultat/clientfourn.php @@ -253,7 +253,6 @@ if ($modecompta == 'BOOKKEEPING') $sql.= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as f"; $sql.= ", ".MAIN_DB_PREFIX."accounting_account as aa"; $sql.= " WHERE f.numero_compte = aa.account_number"; - //$sql.= " AND fk_statut in (1,2)"; $sql.= " AND ".$predefinedgroupwhere; $sql.= " AND fk_pcg_version = '".$db->escape($charofaccountstring)."'"; $sql.= " AND f.entity = ".$conf->entity; diff --git a/htdocs/compta/resultat/index.php b/htdocs/compta/resultat/index.php index c35f084af40..1bbb8eca2cf 100644 --- a/htdocs/compta/resultat/index.php +++ b/htdocs/compta/resultat/index.php @@ -377,7 +377,6 @@ if (! empty($conf->tax->enabled) && ($modecompta == 'CREANCES-DETTES' || $modeco $result=$db->query($sql); if ($result) { $num = $db->num_rows($result); - $var=false; $i = 0; if ($num) { while ($i < $num) { @@ -410,7 +409,6 @@ if (! empty($conf->tax->enabled) && ($modecompta == 'CREANCES-DETTES' || $modeco $result=$db->query($sql); if ($result) { $num = $db->num_rows($result); - $var=false; $i = 0; if ($num) { while ($i < $num) { @@ -444,7 +442,6 @@ if (! empty($conf->tax->enabled) && ($modecompta == 'CREANCES-DETTES' || $modeco $result=$db->query($sql); if ($result) { $num = $db->num_rows($result); - $var=false; $i = 0; if ($num) { while ($i < $num) { @@ -475,7 +472,6 @@ if (! empty($conf->tax->enabled) && ($modecompta == 'CREANCES-DETTES' || $modeco $result=$db->query($sql); if ($result) { $num = $db->num_rows($result); - $var=false; $i = 0; if ($num) { while ($i < $num) { @@ -538,7 +534,6 @@ if (! empty($conf->tax->enabled) && ($modecompta == 'CREANCES-DETTES' || $modeco $result=$db->query($sql); if ($result) { $num = $db->num_rows($result); - $var=false; $i = 0; if ($num) { while ($i < $num) { @@ -601,7 +596,6 @@ if (! empty($conf->tax->enabled) && ($modecompta == 'CREANCES-DETTES' || $modeco $result=$db->query($sql); if ($result) { $num = $db->num_rows($result); - $var=false; $i = 0; if ($num) { while ($i < $num) { @@ -648,7 +642,6 @@ if (! empty($conf->salaries->enabled) && ($modecompta == 'CREANCES-DETTES' || $m $result = $db->query($sql); if ($result) { $num = $db->num_rows($result); - $var = false; $i = 0; if ($num) { while ($i < $num) { @@ -776,7 +769,6 @@ if (! empty($conf->don->enabled) && ($modecompta == 'CREANCES-DETTES' || $modeco if ($result) { $num = $db->num_rows($result); - $var=false; $i = 0; if ($num) { @@ -811,32 +803,35 @@ elseif ($modecompta == 'BOOKKEEPING') { if (! empty($conf->accounting->enabled) && ($modecompta == 'BOOKKEEPING')) { - $subtotal_ht = 0; - $subtotal_ttc = 0; + $predefinedgroupwhere = "("; + //$predefinedgroupwhere.= " (pcg_type = 'EXPENSE' and pcg_subtype in ('PRODUCT','SERVICE'))"; + $predefinedgroupwhere.= " (pcg_type = 'EXPENSE')"; + $predefinedgroupwhere.= " OR "; + //$predefinedgroupwhere.= " (pcg_type = 'INCOME' and pcg_subtype in ('PRODUCT','SERVICE'))"; + $predefinedgroupwhere.= " (pcg_type = 'INCOME')"; + $predefinedgroupwhere.= ")"; + + $charofaccountstring = $conf->global->CHARTOFACCOUNTS; + $charofaccountstring=dol_getIdFromCode($db, $conf->global->CHARTOFACCOUNTS, 'accounting_system', 'rowid', 'pcg_version'); $sql = "SELECT b.doc_ref, b.numero_compte, b.subledger_account, b.subledger_label, pcg_type, date_format(b.doc_date,'%Y-%m') as dm, sum(b.debit) as debit, sum(b.credit) as credit, sum(b.montant) as amount"; $sql.= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as b, ".MAIN_DB_PREFIX."accounting_account as aa"; $sql.= " WHERE b.numero_compte = aa.account_number AND b.entity = ".$conf->entity; - //$sql.= " AND fk_statut in (1,2)"; - $sql.= " AND ("; - //$sql.= " (pcg_type = 'EXPENSE' and pcg_subtype in ('PRODUCT','SERVICE'))"; - $sql.= " (pcg_type = 'EXPENSE')"; - $sql.= " OR "; - //$sql.= " (pcg_type = 'INCOME' and pcg_subtype in ('PRODUCT','SERVICE'))"; - $sql.= " (pcg_type = 'INCOME')"; - $sql.= ")"; - //$sql.= " AND code_journal in ('VT', 'AC')"; + $sql.= " AND ".$predefinedgroupwhere; + $sql.= " AND fk_pcg_version = '".$db->escape($charofaccountstring)."'"; if (! empty($date_start) && ! empty($date_end)) $sql.= " AND b.doc_date >= '".$db->idate($date_start)."' AND b.doc_date <= '".$db->idate($date_end)."'"; $sql.= " GROUP BY b.doc_ref, b.numero_compte, b.subledger_account, b.subledger_label, pcg_type, dm"; //print $sql; + $subtotal_ht = 0; + $subtotal_ttc = 0; + dol_syslog("get bookkeeping record"); $result=$db->query($sql); if ($result) { $num = $db->num_rows($result); - $var=false; $i = 0; if ($num) { @@ -846,9 +841,8 @@ if (! empty($conf->accounting->enabled) && ($modecompta == 'BOOKKEEPING')) if (! isset($encaiss[$obj->dm])) $encaiss[$obj->dm]=0; $encaiss[$obj->dm] += $obj->debit; - if (! isset($encaiss_ttc[$obj->dm])) $encaiss_ttc[$obj->dm]=0; - $encaiss_ttc[$obj->dm] += $obj->credit; + $encaiss_ttc[$obj->dm] += 0; $i++; } @@ -909,7 +903,6 @@ for ($annee = $year_start ; $annee <= $year_end ; $annee++) } print ''; -$var=True; // Loop on each month $nb_mois_decalage = $conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START-1):0; @@ -927,21 +920,44 @@ for ($mois = 1+$nb_mois_decalage ; $mois <= 12+$nb_mois_decalage ; $mois++) $case = strftime("%Y-%m",dol_mktime(12,0,0,$mois_modulo,1,$annee_decalage)); print '"; print '"; } @@ -952,7 +968,10 @@ for ($mois = 1+$nb_mois_decalage ; $mois <= 12+$nb_mois_decalage ; $mois++) // Total $nbcols=0; -print ''; +print ''; for ($annee = $year_start ; $annee <= $year_end ; $annee++) { $nbcols+=2; From 51cd793d80ccdb024af6d84c688a81beafb2c817 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 27 Mar 2018 14:37:29 +0200 Subject: [PATCH 06/31] Fix log and duplicate vat_by_date function --- htdocs/compta/localtax/index.php | 20 +++++++------- htdocs/compta/tva/index.php | 4 +-- htdocs/compta/tva/quadri_detail.php | 4 +-- htdocs/compta/tva/quarter_report.php | 4 +-- htdocs/core/lib/tax.lib.php | 40 +++++++--------------------- 5 files changed, 25 insertions(+), 47 deletions(-) diff --git a/htdocs/compta/localtax/index.php b/htdocs/compta/localtax/index.php index 5d17688fc68..6286bfaa4e4 100644 --- a/htdocs/compta/localtax/index.php +++ b/htdocs/compta/localtax/index.php @@ -45,14 +45,14 @@ if ($year == 0) // Security check $socid = isset($_GET["socid"])?$_GET["socid"]:''; -if ($user->societe_id) +if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'tax', '', '', 'charges'); // Define modetax (0 or 1) // 0=normal, 1=option vat for services is on debit $modetax = $conf->global->TAX_MODE; -if (isset($_GET["modetax"])) +if (isset($_GET["modetax"])) $modetax=$_GET["modetax"]; /** @@ -81,7 +81,7 @@ function pt ($db, $sql, $date) $var=True; while ($i < $num) { $obj = $db->fetch_object($result); - + print ''; print '\n"; $total = $total + $obj->mm; @@ -166,16 +166,16 @@ $var=True; $total=0; $subtotalcoll=0; $subtotalpaye=0; $subtotal=0; $i=0; for ($m = 1 ; $m < 13 ; $m++ ) { - $coll_listsell = vat_by_date($db, $y, 0, 0, 0, $modetax, 'sell', $m); - $coll_listbuy = vat_by_date($db, $y, 0, 0, 0, $modetax, 'buy', $m); - + $coll_listsell = tax_by_date('vat', $db, $y, 0, 0, 0, $modetax, 'sell', $m); + $coll_listbuy = tax_by_date('vat', $db, $y, 0, 0, 0, $modetax, 'buy', $m); + $action = "tva"; $object = array(&$coll_listsell, &$coll_listbuy); $parameters["mode"] = $modetax; $parameters["year"] = $y; $parameters["month"] = $m; $parameters["type"] = 'localtax'.$localTaxType; - + // Initialize technical object to manage hooks of expenses. Note that conf->hooks_modules contains array array $hookmanager->initHooks(array('externalbalance')); $reshook=$hookmanager->executeHooks('addVatLine',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks @@ -190,7 +190,7 @@ for ($m = 1 ; $m < 13 ; $m++ ) { break; } - + print ''; print ''; if($CalcLT==0) { @@ -221,7 +221,7 @@ for ($m = 1 ; $m < 13 ; $m++ ) { } $subtotalcoll = $subtotalcoll + $x_coll; print ""; - + } if($CalcLT==0) { @@ -231,7 +231,7 @@ for ($m = 1 ; $m < 13 ; $m++ ) { } elseif($CalcLT==2) { $diff= $x_coll; } - + $total = $total + $diff; $subtotal = $subtotal + $diff; diff --git a/htdocs/compta/tva/index.php b/htdocs/compta/tva/index.php index acbcc86e07d..1ac38a93c96 100644 --- a/htdocs/compta/tva/index.php +++ b/htdocs/compta/tva/index.php @@ -144,8 +144,8 @@ $total=0; $subtotalcoll=0; $subtotalpaye=0; $subtotal=0; $i=0; for ($m = 1 ; $m < 13 ; $m++ ) { - $coll_listsell = vat_by_date($db, $y, 0, 0, 0, $modetax, 'sell', $m); - $coll_listbuy = vat_by_date($db, $y, 0, 0, 0, $modetax, 'buy', $m); + $coll_listsell = tax_by_date('vat', $db, $y, 0, 0, 0, $modetax, 'sell', $m); + $coll_listbuy = tax_by_date('vat', $db, $y, 0, 0, 0, $modetax, 'buy', $m); $action = "tva"; $object = array(&$coll_listsell, &$coll_listbuy); diff --git a/htdocs/compta/tva/quadri_detail.php b/htdocs/compta/tva/quadri_detail.php index d4ccbf98804..5a05ef5974f 100644 --- a/htdocs/compta/tva/quadri_detail.php +++ b/htdocs/compta/tva/quadri_detail.php @@ -224,8 +224,8 @@ $total = 0; $i=0; // Load arrays of datas -$x_coll = vat_by_date($db, 0, 0, $date_start, $date_end, $modetax, 'sell'); -$x_paye = vat_by_date($db, 0, 0, $date_start, $date_end, $modetax, 'buy'); +$x_coll = tax_by_date('vat', $db, 0, 0, $date_start, $date_end, $modetax, 'sell'); +$x_paye = tax_by_date('vat', $db, 0, 0, $date_start, $date_end, $modetax, 'buy'); if (! is_array($x_coll) || ! is_array($x_paye)) { diff --git a/htdocs/compta/tva/quarter_report.php b/htdocs/compta/tva/quarter_report.php index 4c054923837..dd058c6ebc2 100644 --- a/htdocs/compta/tva/quarter_report.php +++ b/htdocs/compta/tva/quarter_report.php @@ -260,8 +260,8 @@ $i=0; $columns = 6; // Load arrays of datas -$x_coll = vat_by_date($db, 0, 0, $date_start, $date_end, $modetax, 'sell'); -$x_paye = vat_by_date($db, 0, 0, $date_start, $date_end, $modetax, 'buy'); +$x_coll = tax_by_date('vat', $db, 0, 0, $date_start, $date_end, $modetax, 'sell'); +$x_paye = tax_by_date('vat', $db, 0, 0, $date_start, $date_end, $modetax, 'buy'); if (!is_array($x_coll) || !is_array($x_paye)) { $langs->load("errors"); diff --git a/htdocs/core/lib/tax.lib.php b/htdocs/core/lib/tax.lib.php index 400ed453004..a0825cf6518 100644 --- a/htdocs/core/lib/tax.lib.php +++ b/htdocs/core/lib/tax.lib.php @@ -32,7 +32,7 @@ * Prepare array with list of tabs * * @param ChargeSociales $object Object related to tabs - * @return array Array of tabs to show + * @return array Array of tabs to show */ function tax_prepare_head(ChargeSociales $object) { @@ -184,7 +184,6 @@ function vat_by_thirdparty($db, $y, $date_start, $date_end, $modetax, $direction * Gets Tax to collect for the given year (and given quarter or month) * The function gets the Tax in split results, as the Tax declaration asks * to report the amounts for different Tax rates as different lines. - * This function also accounts recurrent invoices. * * @param string $type Tax type, either 'vat', 'localtax1' or 'localtax2' * @param DoliDB $db Database handler object @@ -236,7 +235,7 @@ function tax_by_date($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire $total_localtax1='total_localtax1'; $total_localtax2='total_localtax2'; - + // CAS DES BIENS // Define sql request @@ -318,7 +317,7 @@ function tax_by_date($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire if ($sql == 'TODO') return -2; if ($sql != 'TODO') { - dol_syslog("Tax.lib.php::vat_by_date", LOG_DEBUG); + dol_syslog("Tax.lib.php::tax_by_date", LOG_DEBUG); $resql = $db->query($sql); if ($resql) @@ -414,7 +413,7 @@ function tax_by_date($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire if ($date_start && $date_end) $sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'"; $sql.= " AND (d.product_type = 1"; // Limit to services $sql.= " OR d.date_start is NOT null OR d.date_end IS NOT NULL)"; // enhance detection of service - $sql.= " ORDER BY d.rowid, d.".$fk_facture; + $sql.= " ORDER BY d.rowid, d.".$fk_facture; } else // Option vat on delivery for goods (payments) and payments for services { @@ -458,13 +457,13 @@ function tax_by_date($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire if (! $sql) { - dol_syslog("Tax.lib.php::vat_by_date no accountancy module enabled".$sql,LOG_ERR); + dol_syslog("Tax.lib.php::tax_by_date no accountancy module enabled".$sql,LOG_ERR); return -1; // -1 = Not accountancy module enabled } if ($sql == 'TODO') return -2; // -2 = Feature not yet available if ($sql != 'TODO') { - dol_syslog("Tax.lib.php::vat_by_date", LOG_DEBUG); + dol_syslog("Tax.lib.php::tax_by_date", LOG_DEBUG); $resql = $db->query($sql); if ($resql) { @@ -550,19 +549,19 @@ function tax_by_date($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire } if ($q) $sql.= " AND (date_format(p.datep,'%m') > ".(($q-1)*3)." AND date_format(p.datep,'%m') <= ".($q*3).")"; if ($date_start && $date_end) $sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'"; - $sql.= " AND (d.product_type = -1"; + $sql.= " AND (d.product_type = -1"; $sql.= " OR e.date_debut is NOT null OR e.date_fin IS NOT NULL)"; // enhance detection of service $sql.= " ORDER BY e.rowid"; if (! $sql) { - dol_syslog("Tax.lib.php::vat_by_date no accountancy module enabled".$sql,LOG_ERR); + dol_syslog("Tax.lib.php::tax_by_date no accountancy module enabled".$sql,LOG_ERR); return -1; // -1 = Not accountancy module enabled } if ($sql == 'TODO') return -2; // -2 = Feature not yet available if ($sql != 'TODO') { - dol_syslog("Tax.lib.php::vat_by_date", LOG_DEBUG); + dol_syslog("Tax.lib.php::tax_by_date", LOG_DEBUG); $resql = $db->query($sql); if ($resql) { @@ -624,24 +623,3 @@ function tax_by_date($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire return $list; } -/** - * Gets VAT to collect for the given year (and given quarter or month) - * The function gets the VAT in split results, as the VAT declaration asks - * to report the amounts for different VAT rates as different lines. - * This function also accounts recurrent invoices. - * - * @param DoliDB $db Database handler object - * @param int $y Year - * @param int $q Quarter - * @param string $date_start Start date - * @param string $date_end End date - * @param int $modetax 0 or 1 (option vat on debit) - * @param int $direction 'sell' (customer invoice) or 'buy' (supplier invoices) - * @param int $m Month - * @return array List of quarters with vat - */ -function vat_by_date ($db, $y, $q, $date_start, $date_end, $modetax, $direction, $m=0) -{ - return tax_by_date('vat', $db, $y, $q, $date_start, $date_end, $modetax, $direction, $m); -} - From 460344fbfbe96f7a4377e87d8555755daf778d50 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 27 Mar 2018 16:02:06 +0200 Subject: [PATCH 07/31] Traduction --- htdocs/langs/fr_FR/holiday.lang | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/htdocs/langs/fr_FR/holiday.lang b/htdocs/langs/fr_FR/holiday.lang index a44463d0d1b..9412cb5ebee 100644 --- a/htdocs/langs/fr_FR/holiday.lang +++ b/htdocs/langs/fr_FR/holiday.lang @@ -81,6 +81,10 @@ EmployeeFirstname=Prénom du salarié TypeWasDisabledOrRemoved=Le type de congés (id %s) a été désactivé ou supprimé LastHolidays=Les %s dernières demandes de congés AllHolidays=Toutes les demandes de congés +LEAVE_PAID=Congé payés +LEAVE_SICK=Arrêt maladie +LEAVE_OTHER=Autre congé +LEAVE_PAID_FR=congé payés ## Configuration du Module ## LastUpdateCP=Dernière mise à jour automatique de l'allocation des congés From 925e0c46dd636193ac454dcb587080af97656885 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20G=C3=A9n=C3=A9r=C3=A9?= Date: Sat, 24 Mar 2018 17:50:40 +0100 Subject: [PATCH 08/31] BUG - Point of sale - buttons for cheque and CB are not displayed properly when one account is not defined I find out in the point of sale module that when you have an account for CB but not for check than you could use check but not CB. It seems quite obvious when you look to the previous code that a mistake was done. This is now fixed I expect. The workaround for now is to define both default accounts (for check and for CB). --- htdocs/cashdesk/tpl/facturation1.tpl.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/cashdesk/tpl/facturation1.tpl.php b/htdocs/cashdesk/tpl/facturation1.tpl.php index aed83d641f3..146ae3d40b6 100644 --- a/htdocs/cashdesk/tpl/facturation1.tpl.php +++ b/htdocs/cashdesk/tpl/facturation1.tpl.php @@ -183,7 +183,7 @@ $langs->load("cashdesk"); else print ''; print ''; print '
'; - if (empty($_SESSION['CASHDESK_ID_BANKACCOUNT_CHEQUE']) || $_SESSION['CASHDESK_ID_BANKACCOUNT_CHEQUE'] < 0) + if (empty($_SESSION['CASHDESK_ID_BANKACCOUNT_CB']) || $_SESSION['CASHDESK_ID_BANKACCOUNT_CB'] < 0) { $langs->load("errors"); print ''; @@ -191,7 +191,7 @@ $langs->load("cashdesk"); else print ''; print '
'; print '
'; - if (empty($_SESSION['CASHDESK_ID_BANKACCOUNT_CB']) || $_SESSION['CASHDESK_ID_BANKACCOUNT_CB'] < 0) + if (empty($_SESSION['CASHDESK_ID_BANKACCOUNT_CHEQUE']) || $_SESSION['CASHDESK_ID_BANKACCOUNT_CHEQUE'] < 0) { $langs->load("errors"); print ''; From 299c32d262c4141d19bd784f446c80e5ef3dfdaf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 27 Mar 2018 11:17:40 +0200 Subject: [PATCH 09/31] Update actions_sendmails.inc.php --- htdocs/core/actions_sendmails.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/actions_sendmails.inc.php b/htdocs/core/actions_sendmails.inc.php index 8a29a268e68..96a9e4987c3 100644 --- a/htdocs/core/actions_sendmails.inc.php +++ b/htdocs/core/actions_sendmails.inc.php @@ -384,7 +384,7 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO if ($mailfile->error) { - setEventMessage($mailfile->error, 'errors'); + setEventMessages($mailfile->error, $mailfile->errors, 'errors'); $action='presend'; } else From 7d7a00658315f8c4ebcf91dec7520181f3feb428 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Tue, 27 Mar 2018 18:12:42 +0200 Subject: [PATCH 10/31] Fix: best visibility of choices --- htdocs/core/class/html.formbarcode.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/html.formbarcode.class.php b/htdocs/core/class/html.formbarcode.class.php index e1ee7ae04ff..dba8c5d24e5 100644 --- a/htdocs/core/class/html.formbarcode.class.php +++ b/htdocs/core/class/html.formbarcode.class.php @@ -122,13 +122,13 @@ class FormBarCode if ($useempty && $num > 0) { - print ''; print ''; } else { $langs->load("errors"); - print ''; print ''; } From dec0164ff90fe39d1985a0cf4e12e962a1c608bc Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Tue, 27 Mar 2018 18:57:50 +0200 Subject: [PATCH 11/31] Fix: differentiate "card", "contact" and "agenda --- htdocs/contact/agenda.php | 2 +- htdocs/societe/contact.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/contact/agenda.php b/htdocs/contact/agenda.php index c513db1b49f..d443956a9fe 100644 --- a/htdocs/contact/agenda.php +++ b/htdocs/contact/agenda.php @@ -101,7 +101,7 @@ if (! $sortfield) $sortfield='a.datep, a.id'; if (! $sortorder) $sortorder='DESC'; // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$hookmanager->initHooks(array('contactcard','globalcard')); +$hookmanager->initHooks(array('contactagenda','globalcard')); /* diff --git a/htdocs/societe/contact.php b/htdocs/societe/contact.php index 32575beb8c7..297ff3e8a56 100644 --- a/htdocs/societe/contact.php +++ b/htdocs/societe/contact.php @@ -66,7 +66,7 @@ $extrafields = new ExtraFields($db); $extralabels=$extrafields->fetch_name_optionals_label($object->table_element); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$hookmanager->initHooks(array('thirdpartycard','globalcard')); +$hookmanager->initHooks(array('thirdpartycontact','globalcard')); if ($action == 'view' && $object->fetch($socid)<=0) { From 5b1efc22279d1a89d33ae14cdbc01f837fb6a052 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Tue, 27 Mar 2018 19:30:31 +0200 Subject: [PATCH 12/31] New [*use loadLangs for translation files*] and update code --- .../doc/pdf_aurore.modules.php | 105 +++++++++++++----- 1 file changed, 77 insertions(+), 28 deletions(-) diff --git a/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php b/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php index 5d790f3c6dc..52fbeac21d5 100644 --- a/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php +++ b/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php @@ -38,23 +38,78 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; */ class pdf_aurore extends ModelePDFSupplierProposal { - var $db; - var $name; - var $description; - var $type; + /** + * @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 $phpmin = array(4,3,0); // Minimum version of PHP required by module - var $version = 'dolibarr'; + /** + * @var array() Minimum version of PHP required by module. + * e.g.: PHP ≥ 5.3 = array(5, 3) + */ + public $phpmin = array(5, 2); + + /** + * Dolibarr version of the loaded document + * @public string + */ + public $version = 'dolibarr'; - var $page_largeur; - var $page_hauteur; - var $format; - var $marge_gauche; - var $marge_droite; - var $marge_haute; - var $marge_basse; + /** + * @var int page_largeur + */ + public $page_largeur; + + /** + * @var int page_hauteur + */ + public $page_hauteur; + + /** + * @var array format + */ + public $format; + + /** + * @var int marge_gauche + */ + public $marge_gauche; + + /** + * @var int marge_droite + */ + public $marge_droite; + + /** + * @var int marge_haute + */ + public $marge_haute; + + /** + * @var int marge_basse + */ + public $marge_basse; - var $emetteur; // Objet societe qui emet + /** + * Issuer + * @var Societe + */ + public $emetteur; /** @@ -62,9 +117,9 @@ class pdf_aurore extends ModelePDFSupplierProposal * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { - global $conf,$langs,$mysoc; + global $conf, $langs, $mysoc; // Translations $langs->loadLangs(array("main", "bills")); @@ -146,13 +201,9 @@ class pdf_aurore extends ModelePDFSupplierProposal if (! is_object($outputlangs)) $outputlangs=$langs; // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; - - $outputlangs->load("main"); - $outputlangs->load("dict"); - $outputlangs->load("companies"); - $outputlangs->load("bills"); - $outputlangs->load("supplier_proposal"); - $outputlangs->load("products"); + + // Translations + $outputlangs->loadLangs(array("main", "dict", "companies", "bills", "products", "supplier_proposal")); $nblignes = count($object->lines); @@ -1188,11 +1239,9 @@ class pdf_aurore extends ModelePDFSupplierProposal function _pagehead(&$pdf, $object, $showaddress, $outputlangs) { global $conf,$langs; - - $outputlangs->load("main"); - $outputlangs->load("bills"); - $outputlangs->load("supplier_proposal"); - $outputlangs->load("companies"); + + // Translations + $outputlangs->loadLangs(array("main", "bills", "supplier_proposal", "companies")); $default_font_size = pdf_getPDFFontSize($outputlangs); From 6e27da605accaabe3d06bcca11c7c51053ea1a7c Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Tue, 27 Mar 2018 21:41:25 +0200 Subject: [PATCH 13/31] Add label project in tooltip in customer/supplier list --- htdocs/compta/facture/list.php | 3 ++- htdocs/fourn/facture/list.php | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 087f6018354..a3576a438aa 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -366,7 +366,7 @@ $sql.= ' s.rowid as socid, s.nom as name, s.email, s.town, s.zip, s.fk_pays, s.c $sql.= " typent.code as typent_code,"; $sql.= " state.code_departement as state_code, state.nom as state_name,"; $sql.= " country.code as country_code,"; -$sql.= " p.rowid as project_id, p.ref as project_ref"; +$sql.= " p.rowid as project_id, p.ref as project_ref, p.title as project_label"; // We need dynamount_payed to be able to sort on status (value is surely wrong because we can count several lines several times due to other left join or link with contacts. But what we need is just 0 or > 0) // TODO Better solution to be able to sort on already payed or remain to pay is to store amount_payed in a denormalized field. if (! $sall) $sql.= ', SUM(pf.amount) as dynamount_payed'; @@ -979,6 +979,7 @@ if ($resql) { $projectstatic->id=$obj->project_id; $projectstatic->ref=$obj->project_ref; + $projectstatic->title=$obj->project_label; print $projectstatic->getNomUrl(1); } print ''; diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index 78ea00f205a..efe029d7adf 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -271,7 +271,7 @@ $sql.= " s.rowid as socid, s.nom as name, s.email, s.town, s.zip, s.fk_pays, s.c $sql.= " typent.code as typent_code,"; $sql.= " state.code_departement as state_code, state.nom as state_name,"; $sql.= " country.code as country_code,"; -$sql.= " p.rowid as project_id, p.ref as project_ref"; +$sql.= " p.rowid as project_id, p.ref as project_ref, p.title as project_label"; // We need dynamount_payed to be able to sort on status (value is surely wrong because we can count several lines several times due to other left join or link with contacts. But what we need is just 0 or > 0) // TODO Better solution to be able to sort on already payed or remain to pay is to store amount_payed in a denormalized field. if (! $search_all) $sql.= ', SUM(pf.amount) as dynamount_payed'; @@ -925,6 +925,7 @@ if ($resql) { $projectstatic->id=$obj->project_id; $projectstatic->ref=$obj->project_ref; + $projectstatic->title=$obj->project_label; print $projectstatic->getNomUrl(1); } print ''; From 63a5ff61efed5750526556bf81c5db6d09371248 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Wed, 28 Mar 2018 06:44:17 +0200 Subject: [PATCH 14/31] Fix: missing encrypt for llx_const --- htdocs/install/mysql/migration/7.0.0-8.0.0.sql | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/install/mysql/migration/7.0.0-8.0.0.sql b/htdocs/install/mysql/migration/7.0.0-8.0.0.sql index 665adb0768c..cd3e5b3b9ab 100644 --- a/htdocs/install/mysql/migration/7.0.0-8.0.0.sql +++ b/htdocs/install/mysql/migration/7.0.0-8.0.0.sql @@ -297,12 +297,12 @@ CREATE TABLE llx_societe_account( ALTER TABLE llx_const MODIFY type varchar(64) DEFAULT 'string'; UPDATE llx_const set type = 'text' where type = 'texte'; -UPDATE llx_const set type = 'html' where name in ('ADHERENT_AUTOREGISTER_NOTIF_MAIL','ADHERENT_AUTOREGISTER_MAIL','ADHERENT_MAIL_VALID','ADHERENT_MAIL_COTIS','ADHERENT_MAIL_RESIL'); +UPDATE llx_const set type = 'html' where name in (__ENCRYPT('ADHERENT_AUTOREGISTER_NOTIF_MAIL')__,__ENCRYPT('ADHERENT_AUTOREGISTER_MAIL')__,__ENCRYPT('ADHERENT_MAIL_VALID')__,__ENCRYPT('ADHERENT_MAIL_COTIS')__,__ENCRYPT('ADHERENT_MAIL_RESIL')__); ---UPDATE llx_const SET value = '', type = 'emailtemplate:member' WHERE name = 'ADHERENT_AUTOREGISTER_MAIL' AND type != 'emailtemplate:member'; ---UPDATE llx_const SET value = '', type = 'emailtemplate:member' WHERE name = 'ADHERENT_MAIL_VALID' AND type != 'emailtemplate:member'; ---UPDATE llx_const SET value = '', type = 'emailtemplate:member' WHERE name = 'ADHERENT_MAIL_COTIS' AND type != 'emailtemplate:member'; ---UPDATE llx_const SET value = '', type = 'emailtemplate:member' WHERE name = 'ADHERENT_MAIL_RESIL' AND type != 'emailtemplate:member'; +--UPDATE llx_const SET value = '', type = 'emailtemplate:member' WHERE name = __ENCRYPT('ADHERENT_AUTOREGISTER_MAIL')__ AND type != 'emailtemplate:member'; +--UPDATE llx_const SET value = '', type = 'emailtemplate:member' WHERE name = __ENCRYPT('ADHERENT_MAIL_VALID')__ AND type != 'emailtemplate:member'; +--UPDATE llx_const SET value = '', type = 'emailtemplate:member' WHERE name = __ENCRYPT('ADHERENT_MAIL_COTIS')__ AND type != 'emailtemplate:member'; +--UPDATE llx_const SET value = '', type = 'emailtemplate:member' WHERE name = __ENCRYPT('ADHERENT_MAIL_RESIL')__ AND type != 'emailtemplate:member'; ALTER TABLE llx_societe_account ADD COLUMN key_account varchar(128); From 6e616e1198bf889ab68cbbd50065f40137e1ae51 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Wed, 28 Mar 2018 10:06:00 +0200 Subject: [PATCH 15/31] Fix: better performance for openldap --- htdocs/adherents/class/adherent.class.php | 22 ++++++++++++------- .../adherents/class/adherent_type.class.php | 14 ++++++++---- htdocs/adherents/type_ldap.php | 2 +- ...interface_50_modLdap_Ldapsynchro.class.php | 12 +++++----- 4 files changed, 31 insertions(+), 19 deletions(-) diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index faba841e7c6..8ae6a18eb2f 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -1049,13 +1049,15 @@ class Adherent extends CommonObject /** * Load member from database * - * @param int $rowid Id of object to load - * @param string $ref To load member from its ref - * @param int $fk_soc To load member from its link to third party - * @param string $ref_ext External reference - * @return int >0 if OK, 0 if not found, <0 if KO + * @param int $rowid Id of object to load + * @param string $ref To load member from its ref + * @param int $fk_soc To load member from its link to third party + * @param string $ref_ext External reference + * @param bool $fetch_optionals To load optionals (extrafields) + * @param bool $fetch_subscriptions To load member subscriptions + * @return int >0 if OK, 0 if not found, <0 if KO */ - function fetch($rowid,$ref='',$fk_soc='',$ref_ext='') + function fetch($rowid,$ref='',$fk_soc='',$ref_ext='',$fetch_optionals=true,$fetch_subscriptions=true) { global $langs; @@ -1160,10 +1162,14 @@ class Adherent extends CommonObject // Retreive all extrafield // fetch optionals attributes and labels - $this->fetch_optionals(); + if ($fetch_optionals) { + $this->fetch_optionals(); + } // Load other properties - $result=$this->fetch_subscriptions(); + if ($fetch_subscriptions) { + $result=$this->fetch_subscriptions(); + } return $this->id; } diff --git a/htdocs/adherents/class/adherent_type.class.php b/htdocs/adherents/class/adherent_type.class.php index 2393d5dad3b..4a032457f0d 100644 --- a/htdocs/adherents/class/adherent_type.class.php +++ b/htdocs/adherents/class/adherent_type.class.php @@ -332,7 +332,9 @@ class AdherentType extends CommonObject * Return array of Member objects for member type this->id (or all if this->id not defined) * * @param string $excludefilter Filter to exclude - * @param int $mode 0=Return array of member instance, 1=Return array of members id only + * @param int $mode 0=Return array of member instance + * 1=Return array of member instance without extra data + * 2=Return array of members id only * @return mixed Array of members or -1 on error */ function listMembersForMemberType($excludefilter='', $mode=0) @@ -355,10 +357,14 @@ class AdherentType extends CommonObject { if (! array_key_exists($obj->rowid, $ret)) { - if ($mode != 1) + if ($mode < 2) { $memberstatic=new Adherent($this->db); - $memberstatic->fetch($obj->rowid); + if ($mode == 1) { + $memberstatic->fetch($obj->rowid,'','','',false, false); + } else { + $memberstatic->fetch($obj->rowid); + } $ret[$obj->rowid]=$memberstatic; } else $ret[$obj->rowid]=$obj->rowid; @@ -457,7 +463,7 @@ class AdherentType extends CommonObject foreach($this->members as $key=>$val) // This is array of users for group into dolibarr database. { $member=new Adherent($this->db); - $member->fetch($val->id); + $member->fetch($val->id,'','','',false,false); $info2 = $member->_load_ldap_info(); $valueofldapfield[] = $member->_load_ldap_dn($info2); } diff --git a/htdocs/adherents/type_ldap.php b/htdocs/adherents/type_ldap.php index b8fc22f8f75..7edb42e6c76 100644 --- a/htdocs/adherents/type_ldap.php +++ b/htdocs/adherents/type_ldap.php @@ -63,7 +63,7 @@ if (empty($reshook)) if ($result > 0) { - $object->listMembersForMemberType(); + $object->listMembersForMemberType('', 1); $info = $object->_load_ldap_info(); $dn = $object->_load_ldap_dn($info); diff --git a/htdocs/core/triggers/interface_50_modLdap_Ldapsynchro.class.php b/htdocs/core/triggers/interface_50_modLdap_Ldapsynchro.class.php index 1e9c2c2ec31..8cfece7dc89 100644 --- a/htdocs/core/triggers/interface_50_modLdap_Ldapsynchro.class.php +++ b/htdocs/core/triggers/interface_50_modLdap_Ldapsynchro.class.php @@ -440,7 +440,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers if ($object->typeid > 0) { $membertype->fetch($object->typeid); - $membertype->listMembersForMemberType(); + $membertype->listMembersForMemberType('', 1); $oldinfo=$membertype->_load_ldap_info(); $olddn=$membertype->_load_ldap_dn($oldinfo); @@ -560,7 +560,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers */ $newmembertype=new AdherentType($this->db); $newmembertype->fetch($object->typeid); - $newmembertype->listMembersForMemberType(); + $newmembertype->listMembersForMemberType('', 1); $oldinfo=$newmembertype->_load_ldap_info(); $olddn=$newmembertype->_load_ldap_dn($oldinfo); @@ -586,7 +586,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers */ $oldmembertype=new AdherentType($this->db); $oldmembertype->fetch($object->oldcopy->typeid); - $oldmembertype->listMembersForMemberType(); + $oldmembertype->listMembersForMemberType('', 1); $oldinfo=$oldmembertype->_load_ldap_info(); $olddn=$oldmembertype->_load_ldap_dn($oldinfo); @@ -684,7 +684,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers */ $membertype=new AdherentType($this->db); $membertype->fetch($object->typeid); - $membertype->listMembersForMemberType('a.rowid != ' . $object->id); // remove deleted member from the list + $membertype->listMembersForMemberType('a.rowid != ' . $object->id, 1); // remove deleted member from the list $oldinfo=$membertype->_load_ldap_info(); $olddn=$membertype->_load_ldap_dn($oldinfo); @@ -751,7 +751,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers $object->oldcopy = clone $object; } - $object->oldcopy->listMembersForMemberType(); + $object->oldcopy->listMembersForMemberType('', 1); $oldinfo=$object->oldcopy->_load_ldap_info(); $olddn=$object->oldcopy->_load_ldap_dn($oldinfo); @@ -765,7 +765,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers $olddn = ''; } - $object->listMembersForMemberType(); + $object->listMembersForMemberType('', 1); $info=$object->_load_ldap_info(); $dn=$object->_load_ldap_dn($info); From 36463749766a6192907441a0362a72600a0c9599 Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio Date: Wed, 28 Mar 2018 11:54:21 +0200 Subject: [PATCH 16/31] NEW: default warehouse field for products + prefill warehouses when dispatching supplier orders --- htdocs/fourn/commande/dispatch.php | 6 ++-- .../install/mysql/migration/7.0.0-8.0.0.sql | 4 +++ .../install/mysql/tables/llx_product.key.sql | 1 + htdocs/install/mysql/tables/llx_product.sql | 1 + htdocs/langs/en_US/stocks.lang | 2 ++ htdocs/product/card.php | 29 +++++++++++++++++-- htdocs/product/class/product.class.php | 4 ++- .../product/stock/tpl/stockcorrection.tpl.php | 2 +- .../product/stock/tpl/stocktransfer.tpl.php | 2 +- 9 files changed, 43 insertions(+), 8 deletions(-) diff --git a/htdocs/fourn/commande/dispatch.php b/htdocs/fourn/commande/dispatch.php index 43e70c03013..837e32f9ff6 100644 --- a/htdocs/fourn/commande/dispatch.php +++ b/htdocs/fourn/commande/dispatch.php @@ -484,7 +484,7 @@ if ($id > 0 || ! empty($ref)) { } $sql = "SELECT l.rowid, l.fk_product, l.subprice, l.remise_percent, SUM(l.qty) as qty,"; - $sql .= " p.ref, p.label, p.tobatch"; + $sql .= " p.ref, p.label, p.tobatch, p.fk_default_warehouse"; $sql .= " FROM " . MAIN_DB_PREFIX . "commande_fournisseurdet as l"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON l.fk_product=p.rowid"; $sql .= " WHERE l.fk_commande = " . $object->id; @@ -676,9 +676,9 @@ if ($id > 0 || ! empty($ref)) { // Warehouse print '
'; - // Stock min level if ($type != 1 && ! empty($conf->stock->enabled)) { + // Default warehouse + print ''; + // Stock min level print ''; @@ -1351,9 +1358,14 @@ else print ''; // Stock - /* if ($object->isProduct() && ! empty($conf->stock->enabled)) { + // Default warehouse + print ''; + /* print "".''; @@ -1361,7 +1373,9 @@ else print ''; + */ } + /* else { print ''; @@ -1757,6 +1771,17 @@ else print dol_print_url($object->url); print ''; + // Default warehouse + if ($object->isProduct() && ! empty($conf->stock->enabled)) + { + $warehouse = new Entrepot($db); + $warehouse->fetch($object->fk_default_warehouse); + + print ''; + } + //Parent product. if (!empty($conf->variants->enabled) && $object->isProduct()) { diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 6dbf49f69ef..12172342f2a 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -886,6 +886,7 @@ class Product extends CommonObject $sql.= ", surface_units = " . ($this->surface_units!='' ? "'".$this->db->escape($this->surface_units)."'" : 'null'); $sql.= ", volume = " . ($this->volume!='' ? "'".$this->db->escape($this->volume)."'" : 'null'); $sql.= ", volume_units = " . ($this->volume_units!='' ? "'".$this->db->escape($this->volume_units)."'" : 'null'); + $sql.= ", fk_default_warehouse = " . (! empty($this->fk_default_warehouse) ? $this->db->escape($this->fk_default_warehouse) : 'null'); $sql.= ", seuil_stock_alerte = " . ((isset($this->seuil_stock_alerte) && $this->seuil_stock_alerte != '') ? "'".$this->db->escape($this->seuil_stock_alerte)."'" : "null"); $sql.= ", description = '" . $this->db->escape($this->description) ."'"; $sql.= ", url = " . ($this->url?"'".$this->db->escape($this->url)."'":'null'); @@ -1864,7 +1865,7 @@ class Product extends CommonObject $sql = "SELECT rowid, ref, ref_ext, label, description, url, note as note_private, customcode, fk_country, price, price_ttc,"; $sql.= " price_min, price_min_ttc, price_base_type, cost_price, default_vat_code, tva_tx, recuperableonly as tva_npr, localtax1_tx, localtax2_tx, localtax1_type, localtax2_type, tosell,"; - $sql.= " tobuy, fk_product_type, duration, seuil_stock_alerte, canvas, weight, weight_units,"; + $sql.= " tobuy, fk_product_type, duration, fk_default_warehouse, seuil_stock_alerte, canvas, weight, weight_units,"; $sql.= " length, length_units, width, width_units, height, height_units,"; $sql.= " surface, surface_units, volume, volume_units, barcode, fk_barcode_type, finished,"; $sql.= " accountancy_code_buy, accountancy_code_sell, accountancy_code_sell_intra, accountancy_code_sell_export, stock, pmp,"; @@ -1946,6 +1947,7 @@ class Product extends CommonObject $this->accountancy_code_sell_intra = $obj->accountancy_code_sell_intra; $this->accountancy_code_sell_export = $obj->accountancy_code_sell_export; + $this->fk_default_warehouse = $obj->fk_default_warehouse; $this->seuil_stock_alerte = $obj->seuil_stock_alerte; $this->desiredstock = $obj->desiredstock; $this->stock_reel = $obj->stock; diff --git a/htdocs/product/stock/tpl/stockcorrection.tpl.php b/htdocs/product/stock/tpl/stockcorrection.tpl.php index d946a23bf70..3d2e1c99e9b 100644 --- a/htdocs/product/stock/tpl/stockcorrection.tpl.php +++ b/htdocs/product/stock/tpl/stockcorrection.tpl.php @@ -70,7 +70,7 @@ if (empty($conf) || ! is_object($conf)) { print ''; print ''; print ''; } if ($object->element == 'stock') From 125085acee13580126c284ca669cdcdc25db2d91 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 29 Mar 2018 03:01:05 +0200 Subject: [PATCH 17/31] Fix name of method to avoid ci errors --- htdocs/core/class/commonobject.class.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 8d08b828fd1..ceaa2f902ae 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -5804,7 +5804,7 @@ abstract class CommonObject { $labeltoshow = ''.$labeltoshow.''; } - + if (empty($onetrtd)) $out .= ''; foreach($object->fields as $key => $val) { - $align=''; - if (in_array($val['type'], array('date','datetime','timestamp'))) $align.=($align?' ':'').'center'; - if (in_array($val['type'], array('timestamp'))) $align.=($align?' ':'').'nowrap'; - if ($key == 'status') $align.=($align?' ':'').'center'; - if (! empty($arrayfields['t.'.$key]['checked'])) - { - print ''; - print $object->showOutputField($val, $key, $obj->$key, ''); - print ''; - if (! $i) $totalarray['nbfield']++; - if (! empty($val['isameasure'])) - { - if (! $i) $totalarray['pos'][$totalarray['nbfield']]='t.'.$key; - $totalarray['val']['t.'.$key] += $obj->$key; - } - } + $align=''; + if (in_array($val['type'], array('date','datetime','timestamp'))) $align.=($align?' ':'').'center'; + if (in_array($val['type'], array('timestamp'))) $align.=($align?' ':'').'nowrap'; + if ($key == 'status') $align.=($align?' ':'').'center'; + if (! empty($arrayfields['t.'.$key]['checked'])) + { + print ''; + print $object->showOutputField($val, $key, $obj->$key, ''); + print ''; + if (! $i) $totalarray['nbfield']++; + if (! empty($val['isameasure'])) + { + if (! $i) $totalarray['pos'][$totalarray['nbfield']]='t.'.$key; + $totalarray['val']['t.'.$key] += $obj->$key; + } + } } // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; From 22d64a2768247777b07ac88adcca0a81cf3619cb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 29 Mar 2018 12:50:03 +0200 Subject: [PATCH 24/31] Dolibarize module ticket --- htdocs/langs/en_US/ticketsup.lang | 1 + htdocs/ticketsup/list.php | 25 ++++++++----------------- 2 files changed, 9 insertions(+), 17 deletions(-) diff --git a/htdocs/langs/en_US/ticketsup.lang b/htdocs/langs/en_US/ticketsup.lang index cd79202c7fa..d46a6be5dbd 100644 --- a/htdocs/langs/en_US/ticketsup.lang +++ b/htdocs/langs/en_US/ticketsup.lang @@ -52,6 +52,7 @@ TypeContact_ticketsup_internal_SUPPORTTEC=Assigned user TypeContact_ticketsup_external_SUPPORTCLI=Customer contact / incident tracking TypeContact_ticketsup_external_CONTRIBUTOR=External contributor +OriginEmail=Email source Notify_TICKETMESSAGE_SENTBYMAIL=Send ticket answer by email # Status diff --git a/htdocs/ticketsup/list.php b/htdocs/ticketsup/list.php index 7715803f4de..82539a38eab 100644 --- a/htdocs/ticketsup/list.php +++ b/htdocs/ticketsup/list.php @@ -49,10 +49,10 @@ $backtopage = GETPOST('backtopage','alpha'); // Go back to a dedicated $optioncss = GETPOST('optioncss','aZ'); // Option for the css output (always '' except when 'print') $id = GETPOST('id','int'); - $msg_id = GETPOST('msg_id', 'int'); $socid = GETPOST('socid', 'int'); $projectid = GETPOST('projectid', 'int'); +$search_fk_soc=GETPOST('$search_fk_soc','int')?GETPOST('$search_fk_soc','int'):GETPOST('socid','int'); $search_fk_project=GETPOST('search_fk_project','int')?GETPOST('search_fk_project','int'):GETPOST('projectid','int'); $search_fk_status = GETPOST('search_fk_status', 'alpha'); $mode = GETPOST('mode', 'alpha'); @@ -113,23 +113,10 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab } $object->fields = dol_sort_array($object->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); -if ($projectid > 0) -{ - unset($arrayfields['t.fk_project']); -} +if ($socid > 0) unset($arrayfields['t.fk_soc']); +if ($projectid > 0) unset($arrayfields['t.fk_project']); -// Filters -// $search_soc = GETPOST("search_soc"); -// $search_fk_status = GETPOST("search_fk_status", 'alpha'); -// $search_subject = GETPOST("search_subject"); -// $search_type = GETPOST("search_type", 'alpha'); -// $search_category = GETPOST("search_category", 'alpha'); -// $search_severity = GETPOST("search_severity", 'alpha'); -// $search_fk_project = GETPOST("search_fk_project", 'int'); -// $search_fk_user_create = GETPOST("search_fk_user_create", 'int'); -// $search_fk_user_assign = GETPOST("search_fk_user_assign", 'int'); - // Security check if (!$user->rights->ticketsup->read) { accessforbidden(); @@ -223,6 +210,7 @@ foreach($search as $key => $val) if ($search[$key] != '') $sql.=natural_search($key, $search[$key], (($key == 'fk_statut')?2:$mode_search)); } if ($search_all) $sql.= natural_search(array_keys($fieldstosearchall), $search_all); +if ($search_fk_soc) $sql.= natural_search('fk_soc', $search_fk_soc); if ($search_fk_project) $sql.= natural_search('fk_project', $search_fk_project); if (!$user->societe_id && ($mode == "my_assign" || (!$user->admin && $conf->global->TICKETS_LIMIT_VIEW_ASSIGNED_ONLY))) { $sql.= " AND t.fk_user_assign=".$user->id; @@ -419,6 +407,8 @@ foreach($search as $key => $val) if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; +if ($socid) $param.='&socid='.urlencode($socid); +if ($projectid) $param.='&projectid='.urlencode($projectid); // List of mass actions available $arrayofmassactions = array( @@ -440,6 +430,8 @@ print ''; print ''; print ''; print ''; +if ($socid) print ''; +if ($projectid) print ''; $buttontocreate = '' . $langs->trans('NewTicket') . ''; @@ -461,7 +453,6 @@ if ($sall) print $langs->trans("FilterOnInto", $sall) . join(', ',$fieldstosearchall); } - if ($search_fk_status == 'non_closed') { print ''; $param .= '&search_fk_status=non_closed'; From 34ed6516e4f6cd39eff61328768bd10a5c03e98d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 29 Mar 2018 12:52:35 +0200 Subject: [PATCH 25/31] Fix field disappear --- htdocs/ticketsup/list.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/ticketsup/list.php b/htdocs/ticketsup/list.php index 82539a38eab..0e09333e7dd 100644 --- a/htdocs/ticketsup/list.php +++ b/htdocs/ticketsup/list.php @@ -113,8 +113,8 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab } $object->fields = dol_sort_array($object->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); -if ($socid > 0) unset($arrayfields['t.fk_soc']); -if ($projectid > 0) unset($arrayfields['t.fk_project']); +//if ($socid > 0) $arrayfields['t.fk_soc']['enabled']=0; +//if ($projectid > 0) $arrayfields['t.fk_project']['enabled']=0; // Security check From 072b6c02c07f17398b434eec315a8f1f8570fc8f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 29 Mar 2018 13:25:03 +0200 Subject: [PATCH 26/31] FIX Test on mandatory status when closing proposal failed --- htdocs/comm/propal/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 60db23814b3..a71b0eb5304 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -613,7 +613,7 @@ if (empty($reshook)) // Close proposal else if ($action == 'setstatut' && $user->rights->propal->cloturer && ! GETPOST('cancel','alpha')) { - if (! GETPOST('statut','int')) { + if (! (GETPOST('statut','int') > 0)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CloseAs")), null, 'errors'); $action = 'statut'; } else { From 188e5d286dcd5b8ec30708eafe31b2409ef6b6bb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 29 Mar 2018 13:28:29 +0200 Subject: [PATCH 27/31] Fix statut --- htdocs/install/mysql/migration/repair.sql | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/install/mysql/migration/repair.sql b/htdocs/install/mysql/migration/repair.sql index cdd5bb2b653..51c22c4dcb5 100755 --- a/htdocs/install/mysql/migration/repair.sql +++ b/htdocs/install/mysql/migration/repair.sql @@ -344,6 +344,8 @@ update llx_facturedet set product_type = 1 where product_type = 2; --update llx_commandedet as d set d.product_type = 1 where d.fk_product = 22 and d.product_type = 0; --update llx_facturedet as d set d.product_type = 1 where d.fk_product = 22 and d.product_type = 0; +update llx_propal set fk_statut = 1 where fk_statut = -1; + delete from llx_commande_fournisseur_dispatch where fk_commandefourndet = 0 or fk_commandefourndet IS NULL; From eee1cd91202f16bb56791fc3adfdb1f6ed4c2f9f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 29 Mar 2018 13:29:23 +0200 Subject: [PATCH 28/31] Fix data corrupted by v7 --- htdocs/install/mysql/migration/7.0.0-8.0.0.sql | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/install/mysql/migration/7.0.0-8.0.0.sql b/htdocs/install/mysql/migration/7.0.0-8.0.0.sql index 665adb0768c..e9cf5a87ff6 100644 --- a/htdocs/install/mysql/migration/7.0.0-8.0.0.sql +++ b/htdocs/install/mysql/migration/7.0.0-8.0.0.sql @@ -39,6 +39,8 @@ ALTER TABLE llx_website_page ADD COLUMN type_container varchar(16) NOT NULL DEFA DROP TABLE llx_c_accountancy_category; DROP TABLE llx_c_accountingaccount; +update llx_propal set fk_statut = 1 where fk_statut = -1; + -- For 8.0 From 03fe0d6b9e5da220d0d5f406db9259129298636b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 29 Mar 2018 13:50:08 +0200 Subject: [PATCH 29/31] Update 7.0.0-8.0.0.sql --- htdocs/install/mysql/migration/7.0.0-8.0.0.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/install/mysql/migration/7.0.0-8.0.0.sql b/htdocs/install/mysql/migration/7.0.0-8.0.0.sql index 6ca70396d16..8fbe6a283c6 100644 --- a/htdocs/install/mysql/migration/7.0.0-8.0.0.sql +++ b/htdocs/install/mysql/migration/7.0.0-8.0.0.sql @@ -330,6 +330,6 @@ INSERT INTO llx_c_email_templates (entity,module,type_template,lang,private,fk_u INSERT INTO llx_c_email_templates (entity,module,type_template,lang,private,fk_user,datec,label,position,enabled,active,topic,content,content_lines,joinfiles) VALUES (0,'adherent','member','',0,null,null,'(SendingEmailOnCancelation)' ,50,1,1,'[__[MAIN_INFO_SOCIETE_NOM]__] __(YourMembershipWasCanceled)__', '__(Hello)__ __MEMBER_FULLNAME__,

\n\n__(YourMembershipWasCanceled)__
\n

\n__(Sincerely)__
__USER_SIGNATURE__',null, 1); INSERT INTO llx_c_email_templates (entity,module,type_template,lang,private,fk_user,datec,label,position,enabled,active,topic,content,content_lines,joinfiles) VALUES (0,'adherent','member','',0,null,null,'(SendingAnEMailToMember)' ,60,1,1,'[__[MAIN_INFO_SOCIETE_NOM]__] __(CardContent)__', '__(Hello)__,

\n\n__(ThisIsContentOfYourCard)__
\n__(ID)__ : __ID__
\n__(Civiliyty)__ : __MEMBER_CIVILITY__
\n__(Firstname)__ : __MEMBER_FIRSTNAME__
\n__(Lastname)__ : __MEMBER_LASTNAME__
\n__(Fullname)__ : __MEMBER_FULLNAME__
\n__(Company)__ : __MEMBER_COMPANY__
\n__(Address)__ : __MEMBER_ADDRESS__
\n__(Zip)__ : __MEMBER_ZIP__
\n__(Town)__ : __MEMBER_TOWN__
\n__(Country)__ : __MEMBER_COUNTRY__
\n__(Email)__ : __MEMBER_EMAIL__
\n__(Birthday)__ : __MEMBER_BIRTH__
\n__(Photo)__ : __MEMBER_PHOTO__
\n__(Login)__ : __MEMBER_LOGIN__
\n__(Password)__ : __MEMBER_PASSWORD__
\n__(Phone)__ : __MEMBER_PHONE__
\n__(PhonePerso)__ : __MEMBER_PHONEPRO__
\n__(PhoneMobile)__ : __MEMBER_PHONEMOBILE__

\n__(Sincerely)__
__USER_SIGNATURE__',null, 1); -ALTER TABLE llx_product ADD COLUMN fk_default_warehouse int(11) DEFAULT NULL; +ALTER TABLE llx_product ADD COLUMN fk_default_warehouse integer DEFAULT NULL; ALTER TABLE llx_product ADD CONSTRAINT fk_product_default_warehouse FOREIGN KEY (fk_default_warehouse) REFERENCES llx_entrepot (rowid); From 6d796cfd2640d972af3b6b9f1e47c4004cc6c2a2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 29 Mar 2018 13:50:29 +0200 Subject: [PATCH 30/31] Update llx_product.sql --- htdocs/install/mysql/tables/llx_product.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/install/mysql/tables/llx_product.sql b/htdocs/install/mysql/tables/llx_product.sql index b38e4a4a61d..1e201038122 100755 --- a/htdocs/install/mysql/tables/llx_product.sql +++ b/htdocs/install/mysql/tables/llx_product.sql @@ -85,7 +85,7 @@ create table llx_product pmp double(24,8) DEFAULT 0 NOT NULL, -- To store valuation of stock calculated using average price method, for this product fifo double(24,8), -- To store valuation of stock calculated using fifo method, for this product. TODO Not used, should be replaced by stock value stored into movement table. lifo double(24,8), -- To store valuation of stock calculated using lifo method, for this product. TODO Not used, should be replaced by stock value stored into movement table. - fk_default_warehouse int(11) DEFAULT NULL, + fk_default_warehouse integer DEFAULT NULL, canvas varchar(32) DEFAULT NULL, finished tinyint DEFAULT NULL, -- 1=manufactured product, 0=matiere premiere hidden tinyint DEFAULT 0, -- Not used. Deprecated. From 0978c8f58bba0abc0b410a6313b11d5032da3dac Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 29 Mar 2018 16:07:49 +0200 Subject: [PATCH 31/31] CSS --- htdocs/core/class/extrafields.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 2d5ba165365..8deb214782e 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -1743,7 +1743,7 @@ class ExtraFields */ function showSeparator($key) { - $out = '
'; + $out = ''; return $out; }
 '; - if (isset($decaiss_ttc[$case]) && $decaiss_ttc[$case] != 0) + if ($modecompta == 'BOOKKEEPING') { - print ''.price(price2num($decaiss_ttc[$case],'MT')).''; - if (! isset($totsorties[$annee])) $totsorties[$annee]=0; - $totsorties[$annee]+=$decaiss_ttc[$case]; + if (isset($decaiss[$case]) && $decaiss[$case] != 0) + { + print ''.price(price2num($decaiss[$case],'MT')).''; + if (! isset($totsorties[$annee])) $totsorties[$annee]=0; + $totsorties[$annee]+=$decaiss[$case]; + } + } + else + { + if (isset($decaiss_ttc[$case]) && $decaiss_ttc[$case] != 0) + { + print ''.price(price2num($decaiss_ttc[$case],'MT')).''; + if (! isset($totsorties[$annee])) $totsorties[$annee]=0; + $totsorties[$annee]+=$decaiss_ttc[$case]; + } } print " '; - //if (isset($encaiss_ttc[$case]) && $encaiss_ttc[$case] != 0) - if (isset($encaiss_ttc[$case])) + if ($modecompta == 'BOOKKEEPING') { - print ''.price(price2num($encaiss_ttc[$case],'MT')).''; - if (! isset($totentrees[$annee])) $totentrees[$annee]=0; - $totentrees[$annee]+=$encaiss_ttc[$case]; + if (isset($encaiss[$case])) + { + print ''.price(price2num($encaiss[$case],'MT')).''; + if (! isset($totentrees[$annee])) $totentrees[$annee]=0; + $totentrees[$annee]+=$encaiss[$case]; + } + } + else + { + if (isset($encaiss_ttc[$case])) + { + print ''.price(price2num($encaiss_ttc[$case],'MT')).''; + if (! isset($totentrees[$annee])) $totentrees[$annee]=0; + $totentrees[$annee]+=$encaiss_ttc[$case]; + } } print "
'.$langs->trans("TotalTTC").'
'; +if ($modecompta == 'BOOKKEEPING') print $langs->trans("Total"); +else print $langs->trans("TotalTTC"); +print '
'.$obj->dm."
'.dol_print_date(dol_mktime(0,0,0,$m,1,$y),"%b %Y").'".price($x_coll)."'; if (count($listwarehouses) > 1) { - print $formproduct->selectWarehouses(GETPOST("entrepot" . $suffix), "entrepot" . $suffix, '', 1, 0, $objp->fk_product, '', 1); + print $formproduct->selectWarehouses(GETPOST("entrepot" . $suffix)?GETPOST("entrepot" . $suffix):($objp->fk_default_warehouse?$objp->fk_default_warehouse:''), "entrepot" . $suffix, '', 1, 0, $objp->fk_product, '', 1); } elseif (count($listwarehouses) == 1) { - print $formproduct->selectWarehouses(GETPOST("entrepot" . $suffix), "entrepot" . $suffix, '', 0, 0, $objp->fk_product, '', 1); + print $formproduct->selectWarehouses(GETPOST("entrepot" . $suffix)?GETPOST("entrepot" . $suffix):($objp->fk_default_warehouse?$objp->fk_default_warehouse:''), "entrepot" . $suffix, '', 0, 0, $objp->fk_product, '', 1); } else { $langs->load("errors"); print $langs->trans("ErrorNoWarehouseDefined"); diff --git a/htdocs/install/mysql/migration/7.0.0-8.0.0.sql b/htdocs/install/mysql/migration/7.0.0-8.0.0.sql index 665adb0768c..6ca70396d16 100644 --- a/htdocs/install/mysql/migration/7.0.0-8.0.0.sql +++ b/htdocs/install/mysql/migration/7.0.0-8.0.0.sql @@ -329,3 +329,7 @@ INSERT INTO llx_c_email_templates (entity,module,type_template,lang,private,fk_u INSERT INTO llx_c_email_templates (entity,module,type_template,lang,private,fk_user,datec,label,position,enabled,active,topic,content,content_lines,joinfiles) VALUES (0,'adherent','member','',0,null,null,'(SendingReminderForExpiredSubscription)',40,1,1,'[__[MAIN_INFO_SOCIETE_NOM]__] __(SubscriptionReminderEmail)__', '__(Hello)__ __MEMBER_FULLNAME__,

\n\n__(ThisIsContentOfSubscriptionReminderEmail)__
\n
__ONLINE_PAYMENT_TEXT_AND_URL__
\n

\n__(Sincerely)__
__USER_SIGNATURE__',null, 1); INSERT INTO llx_c_email_templates (entity,module,type_template,lang,private,fk_user,datec,label,position,enabled,active,topic,content,content_lines,joinfiles) VALUES (0,'adherent','member','',0,null,null,'(SendingEmailOnCancelation)' ,50,1,1,'[__[MAIN_INFO_SOCIETE_NOM]__] __(YourMembershipWasCanceled)__', '__(Hello)__ __MEMBER_FULLNAME__,

\n\n__(YourMembershipWasCanceled)__
\n

\n__(Sincerely)__
__USER_SIGNATURE__',null, 1); INSERT INTO llx_c_email_templates (entity,module,type_template,lang,private,fk_user,datec,label,position,enabled,active,topic,content,content_lines,joinfiles) VALUES (0,'adherent','member','',0,null,null,'(SendingAnEMailToMember)' ,60,1,1,'[__[MAIN_INFO_SOCIETE_NOM]__] __(CardContent)__', '__(Hello)__,

\n\n__(ThisIsContentOfYourCard)__
\n__(ID)__ : __ID__
\n__(Civiliyty)__ : __MEMBER_CIVILITY__
\n__(Firstname)__ : __MEMBER_FIRSTNAME__
\n__(Lastname)__ : __MEMBER_LASTNAME__
\n__(Fullname)__ : __MEMBER_FULLNAME__
\n__(Company)__ : __MEMBER_COMPANY__
\n__(Address)__ : __MEMBER_ADDRESS__
\n__(Zip)__ : __MEMBER_ZIP__
\n__(Town)__ : __MEMBER_TOWN__
\n__(Country)__ : __MEMBER_COUNTRY__
\n__(Email)__ : __MEMBER_EMAIL__
\n__(Birthday)__ : __MEMBER_BIRTH__
\n__(Photo)__ : __MEMBER_PHOTO__
\n__(Login)__ : __MEMBER_LOGIN__
\n__(Password)__ : __MEMBER_PASSWORD__
\n__(Phone)__ : __MEMBER_PHONE__
\n__(PhonePerso)__ : __MEMBER_PHONEPRO__
\n__(PhoneMobile)__ : __MEMBER_PHONEMOBILE__

\n__(Sincerely)__
__USER_SIGNATURE__',null, 1); + +ALTER TABLE llx_product ADD COLUMN fk_default_warehouse int(11) DEFAULT NULL; +ALTER TABLE llx_product ADD CONSTRAINT fk_product_default_warehouse FOREIGN KEY (fk_default_warehouse) REFERENCES llx_entrepot (rowid); + diff --git a/htdocs/install/mysql/tables/llx_product.key.sql b/htdocs/install/mysql/tables/llx_product.key.sql index 5157861ba4b..40b4eb130a9 100644 --- a/htdocs/install/mysql/tables/llx_product.key.sql +++ b/htdocs/install/mysql/tables/llx_product.key.sql @@ -35,3 +35,4 @@ ALTER TABLE llx_product ADD CONSTRAINT fk_product_fk_unit FOREIGN KEY (fk_unit) ALTER TABLE llx_product ADD CONSTRAINT fk_product_fk_country FOREIGN KEY (fk_country) REFERENCES llx_c_country (rowid); ALTER TABLE llx_product ADD CONSTRAINT fk_product_barcode_type FOREIGN KEY (fk_barcode_type) REFERENCES llx_c_barcode_type (rowid); +ALTER TABLE llx_product ADD CONSTRAINT fk_product_default_warehouse FOREIGN KEY (fk_default_warehouse) REFERENCES llx_entrepot (rowid); diff --git a/htdocs/install/mysql/tables/llx_product.sql b/htdocs/install/mysql/tables/llx_product.sql index 21da795cd4e..b38e4a4a61d 100755 --- a/htdocs/install/mysql/tables/llx_product.sql +++ b/htdocs/install/mysql/tables/llx_product.sql @@ -85,6 +85,7 @@ create table llx_product pmp double(24,8) DEFAULT 0 NOT NULL, -- To store valuation of stock calculated using average price method, for this product fifo double(24,8), -- To store valuation of stock calculated using fifo method, for this product. TODO Not used, should be replaced by stock value stored into movement table. lifo double(24,8), -- To store valuation of stock calculated using lifo method, for this product. TODO Not used, should be replaced by stock value stored into movement table. + fk_default_warehouse int(11) DEFAULT NULL, canvas varchar(32) DEFAULT NULL, finished tinyint DEFAULT NULL, -- 1=manufactured product, 0=matiere premiere hidden tinyint DEFAULT 0, -- Not used. Deprecated. diff --git a/htdocs/langs/en_US/stocks.lang b/htdocs/langs/en_US/stocks.lang index 62d2e23e66c..d8261fbe2ec 100644 --- a/htdocs/langs/en_US/stocks.lang +++ b/htdocs/langs/en_US/stocks.lang @@ -8,7 +8,9 @@ WarehouseEdit=Modify warehouse MenuNewWarehouse=New warehouse WarehouseSource=Source warehouse WarehouseSourceNotDefined=No warehouse defined, +AddWarehouse=Create warehouse AddOne=Add one +DefaultWarehouse=Default warehouse WarehouseTarget=Target warehouse ValidateSending=Delete sending CancelSending=Cancel sending diff --git a/htdocs/product/card.php b/htdocs/product/card.php index f65898bda68..a2794801fae 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -292,6 +292,7 @@ if (empty($reshook)) $object->country_id = GETPOST('country_id'); $object->duration_value = $duration_value; $object->duration_unit = $duration_unit; + $object->fk_default_warehouse = GETPOST('fk_default_warehouse'); $object->seuil_stock_alerte = GETPOST('seuil_stock_alerte')?GETPOST('seuil_stock_alerte'):0; $object->desiredstock = GETPOST('desiredstock')?GETPOST('desiredstock'):0; $object->canvas = GETPOST('canvas'); @@ -390,6 +391,7 @@ if (empty($reshook)) $object->status_buy = GETPOST('statut_buy'); $object->status_batch = GETPOST('status_batch'); // removed from update view so GETPOST always empty + $object->fk_default_warehouse = GETPOST('fk_default_warehouse'); /* $object->seuil_stock_alerte = GETPOST('seuil_stock_alerte'); $object->desiredstock = GETPOST('desiredstock'); @@ -995,9 +997,14 @@ else print ''; print '
'.$langs->trans("DefaultWarehouse").''; + print $formproduct->selectWarehouses(GETPOST('fk_default_warehouse'), 'fk_default_warehouse', 'warehouseopen', 1); + print ' '.$langs->trans("AddWarehouse").''; + print '
'.$form->textwithpicto($langs->trans("StockLimit"), $langs->trans("StockLimitDesc"), 1).''; print ''; print '
'.$langs->trans("DefaultWarehouse").''; + print $formproduct->selectWarehouses($object->fk_default_warehouse, 'fk_default_warehouse', 'warehouseopen', 1); + print ' '.$langs->trans("AddWarehouse").''; + print '
'.$langs->trans("StockLimit").''; print ''; print ''.$langs->trans("DesiredStock").''; print ''; print '
'.$langs->trans("DefaultWarehouse").''; + print (! empty($warehouse->id) ? $warehouse->getNomUrl(1) : ''); + print ''.$langs->trans("Warehouse").''; - print $formproduct->selectWarehouses((GETPOST("dwid")?GETPOST("dwid",'int'):(GETPOST('id_entrepot')?GETPOST('id_entrepot','int'):'ifone')), 'id_entrepot', 'warehouseopen,warehouseinternal', 1, 0, 0, '', 0, 0, null, 'minwidth100'); + print $formproduct->selectWarehouses((GETPOST("dwid")?GETPOST("dwid",'int'):(GETPOST('id_entrepot')?GETPOST('id_entrepot','int'):($object->element=='product' && $object->fk_default_warehouse?$object->fk_default_warehouse:'ifone'))), 'id_entrepot', 'warehouseopen,warehouseinternal', 1, 0, 0, '', 0, 0, null, 'minwidth100'); print '   '.$langs->trans("WarehouseSource").''; - print $formproduct->selectWarehouses((GETPOST("dwid")?GETPOST("dwid",'int'):(GETPOST('id_entrepot')?GETPOST('id_entrepot','int'):'ifone')), 'id_entrepot', 'warehouseopen,warehouseinternal', 1); + print $formproduct->selectWarehouses((GETPOST("dwid")?GETPOST("dwid",'int'):(GETPOST('id_entrepot')?GETPOST('id_entrepot','int'):($object->element=='product' && $object->fk_default_warehouse?$object->fk_default_warehouse:'ifone'))), 'id_entrepot', 'warehouseopen,warehouseinternal', 1); print ''; else $out .= ''; @@ -6111,7 +6111,7 @@ abstract class CommonObject * * @return array */ - protected function set_save_query() + protected function setSaveQuery() { global $conf; @@ -6210,7 +6210,7 @@ abstract class CommonObject * * @return string */ - protected function get_field_list() + protected function getFieldList() { $keys = array_keys($this->fields); return implode(',', $keys); @@ -6245,7 +6245,7 @@ abstract class CommonObject $now=dol_now(); - $fieldvalues = $this->set_save_query(); + $fieldvalues = $this->setSaveQuery(); if (array_key_exists('date_creation', $fieldvalues) && empty($fieldvalues['date_creation'])) $fieldvalues['date_creation']=$this->db->idate($now); if (array_key_exists('fk_user_creat', $fieldvalues) && ! ($fieldvalues['fk_user_creat'] > 0)) $fieldvalues['fk_user_creat']=$user->id; unset($fieldvalues['rowid']); // The field 'rowid' is reserved field name for autoincrement field so we don't need it into insert. @@ -6337,7 +6337,7 @@ abstract class CommonObject { if (empty($id) && empty($ref)) return false; - $sql = 'SELECT '.$this->get_field_list(); + $sql = 'SELECT '.$this->getFieldList(); $sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element; if(!empty($id)) $sql.= ' WHERE rowid = '.$id; @@ -6380,7 +6380,7 @@ abstract class CommonObject $now=dol_now(); - $fieldvalues = $this->set_save_query(); + $fieldvalues = $this->setSaveQuery(); if (array_key_exists('date_modification', $fieldvalues) && empty($fieldvalues['date_modification'])) $fieldvalues['date_modification']=$this->db->idate($now); if (array_key_exists('fk_user_modif', $fieldvalues) && ! ($fieldvalues['fk_user_modif'] > 0)) $fieldvalues['fk_user_modif']=$user->id; unset($fieldvalues['rowid']); // The field 'rowid' is reserved field name for autoincrement field so we don't need it into update. From 4a289d10d4762f5f4ed879664a66570e1510680b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 29 Mar 2018 03:02:52 +0200 Subject: [PATCH 18/31] Fix phpcs --- htdocs/dav/dav.class.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/htdocs/dav/dav.class.php b/htdocs/dav/dav.class.php index c0220d77a66..0122dbc3eaf 100644 --- a/htdocs/dav/dav.class.php +++ b/htdocs/dav/dav.class.php @@ -118,9 +118,8 @@ class CdavLib */ public function toVCalendar($calid, $obj) { - - $categ = []; - /*if($obj->soc_client) + /*$categ = array(); + if($obj->soc_client) { $nick[] = $obj->soc_code_client; $categ[] = $this->langs->transnoentitiesnoconv('Customer'); From 39f25c9fc21515f5a67c846700806f6a7223206a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 29 Mar 2018 08:28:36 +0200 Subject: [PATCH 19/31] Fix phpcs --- htdocs/core/lib/tax.lib.php | 4 ---- htdocs/dav/dav.class.php | 24 +++++++++++++++--------- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/htdocs/core/lib/tax.lib.php b/htdocs/core/lib/tax.lib.php index 3f0530e82fb..d2bc3b37183 100644 --- a/htdocs/core/lib/tax.lib.php +++ b/htdocs/core/lib/tax.lib.php @@ -236,11 +236,7 @@ function tax_by_date($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire $total_localtax1='total_localtax1'; $total_localtax2='total_localtax2'; -<<<<<<< HEAD // CAS DES BIENS/PRODUITS -======= - // CAS DES BIENS ->>>>>>> branch '7.0' of git@github.com:Dolibarr/dolibarr.git // Define sql request $sql=''; diff --git a/htdocs/dav/dav.class.php b/htdocs/dav/dav.class.php index 0122dbc3eaf..c0d411a9e47 100644 --- a/htdocs/dav/dav.class.php +++ b/htdocs/dav/dav.class.php @@ -23,10 +23,8 @@ /** - * Define Common function to access calendar items - * And format it in vCalendar - * */ - + * Define Common function to access calendar items and format it in vCalendar + */ class CdavLib { @@ -46,8 +44,9 @@ class CdavLib /** * Base sql request for calendar events * - * @param int calendar user id - * @param int actioncomm object id + * @param int $calid Calendard id + * @param int|boolean $oid Oid + * @param int|boolean $ouri Ouri * @return string */ public function getSqlCalEvents($calid, $oid=false, $ouri=false) @@ -113,7 +112,8 @@ class CdavLib /** * Convert calendar row to VCalendar string * - * @param row object + * @param int $calid Calendar id + * @param Object $obj Object id * @return string */ public function toVCalendar($calid, $obj) @@ -239,11 +239,17 @@ class CdavLib return $caldata; } + /** + * getFullCalendarObjects + * + * @param int $calendarId Calendar id + * @param int $bCalendarData Add calendar data + * @return array|string[][]|unknown[][]|NULL[][] + */ public function getFullCalendarObjects($calendarId, $bCalendarData) { - $calid = ($calendarId*1); - $calevents = [] ; + $calevents = array(); if(! $this->user->rights->agenda->myactions->read) return $calevents; From 202cf53bab7f52dbb185659d5bcbb687e12de52c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 29 Mar 2018 09:56:11 +0200 Subject: [PATCH 20/31] Fix phpcs --- htdocs/dav/dav.class.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/dav/dav.class.php b/htdocs/dav/dav.class.php index c0d411a9e47..25f2ac8ccc7 100644 --- a/htdocs/dav/dav.class.php +++ b/htdocs/dav/dav.class.php @@ -269,7 +269,7 @@ class CdavLib if($bCalendarData) { - $calevents[] = [ + $calevents[] = array( 'calendardata' => $calendardata, 'uri' => $obj->id.'-ev-'.CDAV_URI_KEY, 'lastmodified' => strtotime($obj->lastupd), @@ -277,11 +277,11 @@ class CdavLib 'calendarid' => $calendarId, 'size' => strlen($calendardata), 'component' => strpos($calendardata, 'BEGIN:VEVENT')>0 ? 'vevent' : 'vtodo', - ]; + ); } else { - $calevents[] = [ + $calevents[] = array( // 'calendardata' => $calendardata, not necessary because etag+size are present 'uri' => $obj->id.'-ev-'.CDAV_URI_KEY, 'lastmodified' => strtotime($obj->lastupd), @@ -289,7 +289,7 @@ class CdavLib 'calendarid' => $calendarId, 'size' => strlen($calendardata), 'component' => strpos($calendardata, 'BEGIN:VEVENT')>0 ? 'vevent' : 'vtodo', - ]; + ); } } } From b806b85761ffa13be65ceaf97e5e92f0e414adf5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 29 Mar 2018 11:15:50 +0200 Subject: [PATCH 21/31] Fix field filtert is set twice --- htdocs/comm/action/list.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/comm/action/list.php b/htdocs/comm/action/list.php index 54da96d7be0..c58c34f3d72 100644 --- a/htdocs/comm/action/list.php +++ b/htdocs/comm/action/list.php @@ -44,7 +44,7 @@ $month=GETPOST("month",'int'); $day=GETPOST("day",'int'); $pid=GETPOST("projectid",'int',3); $status=GETPOST("status",'alpha'); -$type=GETPOST('type'); +$type=GETPOST('type','alphanohtml'); $optioncss = GETPOST('optioncss','alpha'); // Set actioncode (this code must be same for setting actioncode into peruser, listacton and index) if (GETPOST('actioncode','array')) @@ -358,7 +358,7 @@ if ($resql) //if ($actioncode) $nav.=''; //if ($resourceid) $nav.=''; if ($filter) $nav.=''; - if ($filtert) $nav.=''; + //if ($filtert) $nav.=''; //if ($socid) $nav.=''; if ($showbirthday) $nav.=''; //if ($pid) $nav.=''; From ff505ba148ed48f2e9d29ed1d2d197efcdecc936 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 29 Mar 2018 11:34:01 +0200 Subject: [PATCH 22/31] Work on a page dedicated for external frontend (mobile, ...) --- htdocs/core/get_info.php | 209 +++++++++++++++++++++++++++++++ htdocs/core/get_menudiv.php | 4 +- htdocs/main.inc.php | 11 +- htdocs/theme/eldy/style.css.php | 10 ++ htdocs/theme/md/style.css.php | 10 ++ htdocs/user/class/user.class.php | 14 +-- 6 files changed, 241 insertions(+), 17 deletions(-) create mode 100644 htdocs/core/get_info.php diff --git a/htdocs/core/get_info.php b/htdocs/core/get_info.php new file mode 100644 index 00000000000..7b2c57b42e3 --- /dev/null +++ b/htdocs/core/get_info.php @@ -0,0 +1,209 @@ + + * + * This file is a modified version of datepicker.php from phpBSM to fix some + * bugs, to add new features and to dramatically increase speed. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/core/get_info.php + * \brief File to return a single page with just logged user info, to be used by other frontend + */ + +//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // Not disabled cause need to load personalized language +//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Not disabled cause need to load personalized language +//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); +//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); // Not disabled cause need to do translations +if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK',1); +if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL',1); +//if (! defined('NOLOGIN')) define('NOLOGIN',1); // Not disabled cause need to load personalized language +if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU',1); +//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML',1); + +require_once '../main.inc.php'; + +if (GETPOST('lang', 'aZ09')) $langs->setDefaultLang(GETPOST('lang', 'aZ09')); // If language was forced on URL by the main.inc.php + +$langs->load("main"); + +$right=($langs->trans("DIRECTION")=='rtl'?'left':'right'); +$left=($langs->trans("DIRECTION")=='rtl'?'right':'left'); + + +/* + * View + */ + +$title=$langs->trans("Info"); + +// URL http://mydolibarr/core/search_page?dol_use_jmobile=1 can be used for tests +$head=''."\n"; +$arrayofjs=array(); +$arrayofcss=array(); +top_htmlhead($head, $title, 0, 0, $arrayofjs, $arrayofcss); + + + +print ''."\n"; +print '
'; +//print '
'; + +$nbofsearch=0; + +// Define link to login card +$appli=constant('DOL_APPLICATION_TITLE'); +if (! empty($conf->global->MAIN_APPLICATION_TITLE)) +{ + $appli=$conf->global->MAIN_APPLICATION_TITLE; + if (preg_match('/\d\.\d/', $appli)) + { + if (! preg_match('/'.preg_quote(DOL_VERSION).'/', $appli)) $appli.=" (".DOL_VERSION.")"; // If new title contains a version that is different than core + } + else $appli.=" ".DOL_VERSION; +} +else $appli.=" ".DOL_VERSION; + +if (! empty($conf->global->MAIN_FEATURES_LEVEL)) $appli.="
".$langs->trans("LevelOfFeature").': '.$conf->global->MAIN_FEATURES_LEVEL; + +$logouttext=''; +if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) +{ + //$logouthtmltext=$appli.'
'; + if ($_SESSION["dol_authmode"] != 'forceuser' && $_SESSION["dol_authmode"] != 'http') + { + $logouthtmltext.=$langs->trans("Logout").'
'; + + $logouttext .=''; + //$logouttext .= img_picto($langs->trans('Logout').":".$langs->trans('Logout'), 'logout_top.png', 'class="login"', 0, 0, 1); + $logouttext .=''; + $logouttext .=''; + } + else + { + $logouthtmltext.=$langs->trans("NoLogoutProcessWithAuthMode",$_SESSION["dol_authmode"]); + $logouttext .= img_picto($langs->trans('Logout').":".$langs->trans('Logout'), 'logout_top.png', 'class="login"', 0, 0, 1); + } +} + +print ''; + +print $toprightmenu; + +print "
\n"; // end div class="login_block" + +print ''; +print ''."\n"; + +$db->close(); diff --git a/htdocs/core/get_menudiv.php b/htdocs/core/get_menudiv.php index 3ff299fa00c..3b49482a217 100644 --- a/htdocs/core/get_menudiv.php +++ b/htdocs/core/get_menudiv.php @@ -20,7 +20,7 @@ /** * \file htdocs/core/get_menudiv.php - * \brief File to return menu into a div tree + * \brief File to return menu into a div tree, to be used by other frontend */ //if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // Not disabled cause need to load personalized language @@ -37,8 +37,6 @@ if (! defined('DISABLE_JQUERY_TABLEDND')) define('DISABLE_JQUERY_TABLEDND',1); if (! defined('DISABLE_JQUERY_JNOTIFY')) define('DISABLE_JQUERY_JNOTIFY',1); if (! defined('DISABLE_JQUERY_FLOT')) define('DISABLE_JQUERY_FLOT',1); if (! defined('DISABLE_JQUERY_JEDITABLE')) define('DISABLE_JQUERY_JEDITABLE',1); -if (! defined('DISABLE_JQUERY_JEDITABLE')) define('DISABLE_JQUERY_JEDITABLE',1); -if (! defined('DISABLE_CKEDITOR')) define('DISABLE_CKEDITOR',1); if (! defined('DISABLE_CKEDITOR')) define('DISABLE_CKEDITOR',1); if (! defined('DISABLE_BROWSER_NOTIF')) define('DISABLE_BROWSER_NOTIF',1); if (! defined('DISABLE_DATE_PICKER')) define('DISABLE_DATE_PICKER',1); diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index c3bd5c184c0..0289fed4e14 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -1116,12 +1116,8 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs if (empty($conf->css)) $conf->css = '/theme/eldy/style.css.php'; // If not defined, eldy by default - if (! empty($conf->global->MAIN_ACTIVATE_HTML4)) { - $doctype = ''; - }else { - $doctype = ''; - } - print $doctype."\n"; + print ''."\n"; + if (! empty($conf->global->MAIN_USE_CACHE_MANIFEST)) print ''."\n"; else print ''."\n"; //print ''."\n"; @@ -1572,7 +1568,8 @@ function top_menu($head, $title='', $target='', $disablejs=0, $disablehead=0, $a print $toprightmenu; - print "\n"; + print "\n"; // end div class="login_block" + print ''; //unset($form); diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index 382a37b9cc3..f3769f9d79e 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -1939,6 +1939,16 @@ div.login_block_other { padding-top: 3px; text-align: right; } color: # !important; font-weight: normal !important; } +.login_block_getinfo { + text-align: center; +} +.login_block_getinfo div.login_block_user { + display: block; +} +.login_block_getinfo .atoplogin, .login_block_getinfo .atoplogin:hover { + color: #333 !important; + font-weight: normal !important; +} .alogin, .alogin:hover { font-weight: normal !important; font-size: px !important; diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index ae3c08013e1..f1a276bc96d 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -1201,6 +1201,16 @@ div.login_block { /* position: initial !important;*/ display: none; } +.login_block_getinfo { + text-align: center; +} +.login_block_getinfo div.login_block_user { + display: block; +} +.login_block_getinfo .atoplogin, .login_block_getinfo .atoplogin:hover { + color: #333 !important; + font-weight: normal !important; +} #id-right { padding-left: 0 ! important; } diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index bf9ff370e11..c70ab1acf13 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -2109,7 +2109,7 @@ class User extends CommonObject * * @param int $withpictoimg Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto, -1=Include photo into link, -2=Only picto photo, -3=Only photo very small) * @param string $option On what the link point to ('leave', 'nolink', ) - * @param integer $infologin Add complete info tooltip + * @param integer $infologin 0=Add default info tooltip, 1=Add complete info tooltip, -1=No info tooltip * @param integer $notooltip 1=Disable tooltip on picto and name * @param int $maxlen Max length of visible user name * @param int $hidethirdpartylogo Hide logo of thirdparty if user is external user @@ -2136,6 +2136,7 @@ class User extends CommonObject $label.= '
'; } + // Info Login $label.= '
'; $label.= '' . $langs->trans("User") . '
'; $label.= '' . $langs->trans('Name') . ': ' . $this->getFullName($langs,''); @@ -2144,20 +2145,18 @@ class User extends CommonObject $label.= '
' . $langs->trans("EMail").': '.$this->email; if (! empty($this->admin)) $label.= '
' . $langs->trans("Administrator").': '.yn($this->admin); - if (! empty($this->societe_id) ) // Add thirdparty for external users + if (! empty($this->socid) ) // Add thirdparty for external users { $thirdpartystatic = new Societe($db); - $thirdpartystatic->fetch($this->societe_id); + $thirdpartystatic->fetch($this->socid); if (empty($hidethirdpartylogo)) $companylink = ' '.$thirdpartystatic->getNomUrl(2, (($option == 'nolink')?'nolink':'')); // picto only of company $company=' ('.$langs->trans("Company").': '.$thirdpartystatic->name.')'; } - $type=($this->societe_id?$langs->trans("External").$company:$langs->trans("Internal")); + $type=($this->socid?$langs->trans("External").$company:$langs->trans("Internal")); $label.= '
' . $langs->trans("Type") . ': ' . $type; $label.= '
' . $langs->trans("Status").': '.$this->getLibStatut(0); $label.='
'; - - // Info Login - if ($infologin) + if ($infologin > 0) { $label.= '
'; $label.= '
'.$langs->trans("Connection").''; @@ -2176,6 +2175,7 @@ class User extends CommonObject if (! empty($conf->browser->phone)) $label.= '
'.$langs->trans("Phone").': '.$conf->browser->phone; if (! empty($_SESSION["disablemodules"])) $label.= '
'.$langs->trans("DisabledModules").':
'.join(', ',explode(',',$_SESSION["disablemodules"])); } + if ($infologin < 0) $label=''; $url = DOL_URL_ROOT.'/user/card.php?id='.$this->id; if ($option == 'leave') $url = DOL_URL_ROOT.'/holiday/list.php?id='.$this->id; From a7d472bf7bc2f6d96b5954d39ac2c6e8aee69362 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 29 Mar 2018 12:31:17 +0200 Subject: [PATCH 23/31] Dolibarize module ticket --- htdocs/ticketsup/list.php | 119 ++++++++++++++++++++------------------ 1 file changed, 62 insertions(+), 57 deletions(-) diff --git a/htdocs/ticketsup/list.php b/htdocs/ticketsup/list.php index d4b5733ef55..7715803f4de 100644 --- a/htdocs/ticketsup/list.php +++ b/htdocs/ticketsup/list.php @@ -34,7 +34,7 @@ if (!empty($conf->projet->enabled)) { } // Load traductions files requiredby by page -$langs->loadLangs(array("ticketsup","companies","other")); +$langs->loadLangs(array("ticketsup","companies","other","projects")); // Get parameters @@ -53,6 +53,7 @@ $id = GETPOST('id','int'); $msg_id = GETPOST('msg_id', 'int'); $socid = GETPOST('socid', 'int'); $projectid = GETPOST('projectid', 'int'); +$search_fk_project=GETPOST('search_fk_project','int')?GETPOST('search_fk_project','int'):GETPOST('projectid','int'); $search_fk_status = GETPOST('search_fk_status', 'alpha'); $mode = GETPOST('mode', 'alpha'); @@ -112,6 +113,10 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab } $object->fields = dol_sort_array($object->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); +if ($projectid > 0) +{ + unset($arrayfields['t.fk_project']); +} // Filters @@ -121,7 +126,7 @@ $arrayfields = dol_sort_array($arrayfields, 'position'); // $search_type = GETPOST("search_type", 'alpha'); // $search_category = GETPOST("search_category", 'alpha'); // $search_severity = GETPOST("search_severity", 'alpha'); -// $search_project = GETPOST("search_project", 'int'); +// $search_fk_project = GETPOST("search_fk_project", 'int'); // $search_fk_user_create = GETPOST("search_fk_user_create", 'int'); // $search_fk_user_assign = GETPOST("search_fk_user_assign", 'int'); @@ -218,7 +223,7 @@ foreach($search as $key => $val) if ($search[$key] != '') $sql.=natural_search($key, $search[$key], (($key == 'fk_statut')?2:$mode_search)); } if ($search_all) $sql.= natural_search(array_keys($fieldstosearchall), $search_all); - +if ($search_fk_project) $sql.= natural_search('fk_project', $search_fk_project); if (!$user->societe_id && ($mode == "my_assign" || (!$user->admin && $conf->global->TICKETS_LIMIT_VIEW_ASSIGNED_ONLY))) { $sql.= " AND t.fk_user_assign=".$user->id; } @@ -336,11 +341,14 @@ if ($socid && !$projectid && $user->rights->societe->lire) { } } -if ($projectid) { +if ($projectid > 0) { $projectstat = new Project($db); if ($projectstat->fetch($projectid) > 0) { $projectstat->fetch_thirdparty(); + $savobject = $object; + $object = $projectstat; + // To verify role of users //$userAccess = $object->restrictedProjectArea($user,'read'); $userWrite = $projectstat->restrictedProjectArea($user, 'write'); @@ -348,55 +356,52 @@ if ($projectid) { //print "userAccess=".$userAccess." userWrite=".$userWrite." userDelete=".$userDelete; $head = project_prepare_head($projectstat); - dol_fiche_head($head, 'ticketsup', $langs->trans("Project"), 0, ($projectstat->public ? 'projectpub' : 'project')); + dol_fiche_head($head, 'ticketsup', $langs->trans("Project"), -1, ($projectstat->public ? 'projectpub' : 'project')); + + // Project card + + $linkback = ''.$langs->trans("BackToList").''; + + $morehtmlref='
'; + // Title + $morehtmlref.=$object->title; + // Thirdparty + if ($object->thirdparty->id > 0) + { + $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1, 'project'); + } + $morehtmlref.='
'; + + // Define a complementary filter for search of next/prev ref. + if (! $user->rights->projet->all->lire) + { + $objectsListId = $object->getProjectsAuthorizedForUser($user,0,0); + $object->next_prev_filter=" rowid in (".(count($objectsListId)?join(',',array_keys($objectsListId)):'0').")"; + } + + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); + + print '
'; + print '
'; - /* - * Projet synthese pour rappel - */ print ''; - $linkback = '' . $langs->trans("BackToList") . ''; - - // Ref - print ''; - - // Label - print ''; - - // Customer - print ""; - print ''; - // Visibility - print ''; - // Statut - print ''; - print "
' . $langs->trans('Ref') . ''; - // Define a complementary filter for search of next/prev ref. - if (!$user->rights->projet->all->lire) { - $objectsListId = $projectstat->getProjectsAuthorizedForUser($user, $mine, 0); - $projectstat->next_prev_filter = " rowid in (" . (count($objectsListId) ? join(',', array_keys($objectsListId)) : '0') . ")"; - } - print $form->showrefnav($projectstat, 'ref', $linkback, 1, 'ref', 'ref', ''); - print '
' . $langs->trans("Label") . '' . $projectstat->title . '
" . $langs->trans("ThirdParty") . "'; - if ($projectstat->thirdparty->id > 0) { - print $projectstat->thirdparty->getNomUrl(1); - } else { - print ' '; - } - - print '
' . $langs->trans("Visibility") . ''; + print '
' . $langs->trans("Visibility") . ''; if ($projectstat->public) { print $langs->trans('SharedProject'); } else { print $langs->trans('PrivateProject'); } - print '
' . $langs->trans("Status") . '' . $projectstat->getLibStatut(4) . '
"; print '
'; + dol_fiche_end(); + + $object = $savobject; + } else { print "ErrorRecordNotFound"; } @@ -591,24 +596,24 @@ while ($i < min($num, $limit)) print '
'.$this->attribute_label[$key].'
'.$this->attribute_label[$key].'