diff --git a/.github/workflows/code_quality.yml b/.github/workflows/code_quality.yml index 9b4fd68efe7..f35dc90f0b8 100644 --- a/.github/workflows/code_quality.yml +++ b/.github/workflows/code_quality.yml @@ -18,7 +18,7 @@ jobs: fetch-depth: 1 #php-version: '7.1' - name: 'Qodana Scan' - uses: JetBrains/qodana-action@v2022.3.3 + uses: JetBrains/qodana-action@v2022.3.4 #with: # php-version: '7.1' env: diff --git a/build/debian/compat b/build/debian/compat index c7930257dfe..9a037142aa3 100644 --- a/build/debian/compat +++ b/build/debian/compat @@ -1 +1 @@ -7 \ No newline at end of file +10 \ No newline at end of file diff --git a/build/makepack-dolibarr.pl b/build/makepack-dolibarr.pl index 5d958787243..f0433da142b 100755 --- a/build/makepack-dolibarr.pl +++ b/build/makepack-dolibarr.pl @@ -524,12 +524,13 @@ if ($nboftargetok) { $ret=`rm -fr $BUILDROOT/$PROJECT/dev/ansible`; $ret=`rm -fr $BUILDROOT/$PROJECT/dev/codesniffer`; $ret=`rm -fr $BUILDROOT/$PROJECT/dev/codetemplates`; - $ret=`rm -fr $BUILDROOT/$PROJECT/dev/dbmodel`; + $ret=`rm -fr $BUILDROOT/$PROJECT/dev/examples/ldap`; + $ret=`rm -fr $BUILDROOT/$PROJECT/dev/examples/zapier`; $ret=`rm -fr $BUILDROOT/$PROJECT/dev/initdata`; $ret=`rm -fr $BUILDROOT/$PROJECT/dev/initdemo`; - $ret=`rm -fr $BUILDROOT/$PROJECT/dev/iso-normes`; - $ret=`rm -fr $BUILDROOT/$PROJECT/dev/ldap`; - $ret=`rm -fr $BUILDROOT/$PROJECT/dev/licence`; + $ret=`rm -fr $BUILDROOT/$PROJECT/dev/resources/dbmodel`; + $ret=`rm -fr $BUILDROOT/$PROJECT/dev/resources/iso-normes`; + $ret=`rm -fr $BUILDROOT/$PROJECT/dev/resources/licence`; $ret=`rm -fr $BUILDROOT/$PROJECT/dev/mail`; $ret=`rm -fr $BUILDROOT/$PROJECT/dev/multitail`; $ret=`rm -fr $BUILDROOT/$PROJECT/dev/phpcheckstyle`; @@ -894,7 +895,7 @@ if ($nboftargetok) { $ret=`rm -fr $BUILDROOT/$PROJECT.tmp`; $ret=`rm -fr $BUILDROOT/$PROJECT-$MAJOR.$MINOR.$build`; - + print "Copy $BUILDROOT/$PROJECT to $BUILDROOT/$PROJECT.tmp\n"; $cmd="cp -pr \"$BUILDROOT/$PROJECT\" \"$BUILDROOT/$PROJECT.tmp\""; $ret=`$cmd`; diff --git a/build/tgz/tar_exclude.txt b/build/tgz/tar_exclude.txt index c590ca2154f..4a69b4e87dc 100644 --- a/build/tgz/tar_exclude.txt +++ b/build/tgz/tar_exclude.txt @@ -1,15 +1,17 @@ *~ .#* +.git +.gitignore +.scrutinizer.yml Thumbs.db build/exe build/html -dev/dbmodel -dev/fpdf +dev/examples/zapier dev/initdemo dev/initdata -dev/iso-normes -dev/licence -dev/load +dev/resources/dbmodel +dev/resources/iso-normes +dev/resources/licence htdocs/conf/conf.php htdocs/conf/conf.php.mysql htdocs/conf/conf.php.old diff --git a/htdocs/accountancy/admin/accountmodel.php b/htdocs/accountancy/admin/accountmodel.php index c5b8fd20045..f2a7842dbbb 100644 --- a/htdocs/accountancy/admin/accountmodel.php +++ b/htdocs/accountancy/admin/accountmodel.php @@ -504,8 +504,8 @@ if ($id) { print ''; print ''; print ''; - print ''; - print ''; + print ''; + print ''; print ''; // Line to enter new values diff --git a/htdocs/accountancy/admin/categories_list.php b/htdocs/accountancy/admin/categories_list.php index 0fd7b9012eb..e77b97fe92d 100644 --- a/htdocs/accountancy/admin/categories_list.php +++ b/htdocs/accountancy/admin/categories_list.php @@ -545,9 +545,9 @@ if ($tabname[$id]) { print ''; print ''; print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; print ''; // Line to enter new values diff --git a/htdocs/accountancy/admin/journals_list.php b/htdocs/accountancy/admin/journals_list.php index ba2d867ebd6..ef8a0f2767f 100644 --- a/htdocs/accountancy/admin/journals_list.php +++ b/htdocs/accountancy/admin/journals_list.php @@ -431,9 +431,9 @@ if ($id) { print ''; print ''; print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; print ''; // Line to enter new values diff --git a/htdocs/accountancy/admin/productaccount.php b/htdocs/accountancy/admin/productaccount.php index 018a0cfd5e8..620e4158ceb 100644 --- a/htdocs/accountancy/admin/productaccount.php +++ b/htdocs/accountancy/admin/productaccount.php @@ -194,7 +194,7 @@ if ($action == 'update') { } if ($result <= 0) { // setEventMessages(null, $accounting->errors, 'errors'); - $msg .= '
'.$langs->trans("ErrorDB").' : '.$langs->trans("Product").' '.$productid.' '.$langs->trans("NotVentilatedinAccount").' : id='.$accounting_account_id.'
'.$sql.'
'; + $msg .= '
'.$langs->trans("ErrorDB").' : '.$langs->trans("Product").' '.$productid.' '.$langs->trans("NotVentilatedinAccount").' : id='.$accounting_account_id.'
'.$sql.'
'; $ko++; } else { $sql = ''; @@ -203,7 +203,7 @@ if ($action == 'update') { $sql_exists .= " WHERE fk_product = " . ((int) $productid) . " AND entity = " . ((int) $conf->entity); $resql_exists = $db->query($sql_exists); if (!$resql_exists) { - $msg .= '
'.$langs->trans("ErrorDB").' : '.$langs->trans("Product").' '.$productid.' '.$langs->trans("NotVentilatedinAccount").' : id='.$accounting_account_id.'
'.$resql_exists.'
'; + $msg .= '
'.$langs->trans("ErrorDB").' : '.$langs->trans("Product").' '.$productid.' '.$langs->trans("NotVentilatedinAccount").' : id='.$accounting_account_id.'
'.$resql_exists.'
'; $ko++; } else { $nb_exists = $db->num_rows($resql_exists); diff --git a/htdocs/accountancy/bookkeeping/card.php b/htdocs/accountancy/bookkeeping/card.php index 42ac08383ea..384f43223bc 100644 --- a/htdocs/accountancy/bookkeeping/card.php +++ b/htdocs/accountancy/bookkeeping/card.php @@ -527,7 +527,7 @@ if (!empty($object->piece_num)) { print dol_get_fiche_end(); - print '
'; + print '
'; print '
'; diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index 23bb513a85b..2aed109ce26 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -505,7 +505,7 @@ if (empty($reshook)) { $objectlabel = 'Bookkeeping'; $permissiontoread = $user->hasRight('societe', 'lire'); $permissiontodelete = $user->hasRight('societe', 'supprimer'); - $permissiontoadd = $user->rights->societe->creer; + $permissiontoadd = $user->hasRight('societe', 'creer'); $uploaddir = $conf->societe->dir_output; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; @@ -1006,7 +1006,7 @@ if (empty($reshook)) { $newcardbutton .= ''.$langs->trans("ClickToHideAlreadyExportedLines").''; $newcardbutton .= ''; } else { - $newcardbutton .= ''.img_picto($langs->trans("DocsAlreadyExportedAreExcluded"), 'switch_on', 'class="warning size15x valignmiddle"').''; + $newcardbutton .= ''.img_picto($langs->trans("DocsAlreadyExportedAreExcluded"), 'switch_on', 'class="warning size15x valignmiddle"'); $newcardbutton .= ''.$langs->trans("DocsAlreadyExportedAreExcluded").''; $newcardbutton .= ''; } diff --git a/htdocs/accountancy/bookkeeping/listbyaccount.php b/htdocs/accountancy/bookkeeping/listbyaccount.php index 78aea811a5d..17ebe24546a 100644 --- a/htdocs/accountancy/bookkeeping/listbyaccount.php +++ b/htdocs/accountancy/bookkeeping/listbyaccount.php @@ -413,7 +413,7 @@ if (empty($reshook)) { $objectlabel = 'Bookkeeping'; $permissiontoread = $user->hasRight('societe', 'lire'); $permissiontodelete = $user->hasRight('societe', 'supprimer'); - $permissiontoadd = $user->rights->societe->creer; + $permissiontoadd = $user->hasRight('societe', 'creer'); $uploaddir = $conf->societe->dir_output; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; diff --git a/htdocs/accountancy/class/accountancycategory.class.php b/htdocs/accountancy/class/accountancycategory.class.php index d68f4e79f5e..92d493b8b29 100644 --- a/htdocs/accountancy/class/accountancycategory.class.php +++ b/htdocs/accountancy/class/accountancycategory.class.php @@ -839,20 +839,29 @@ class AccountancyCategory // extends CommonObject exit(); } + $pcgverid = $conf->global->CHARTOFACCOUNTS; + $pcgvercode = dol_getIdFromCode($this->db, $pcgverid, 'accounting_system', 'rowid', 'pcg_version'); + if (empty($pcgvercode)) { + $pcgvercode = $pcgverid; + } + if (!empty($cat_id)) { $sql = "SELECT t.rowid, t.account_number, t.label as account_label"; $sql .= " FROM ".MAIN_DB_PREFIX."accounting_account as t"; $sql .= " WHERE t.fk_accounting_category = ".((int) $cat_id); $sql .= " AND t.entity = ".$conf->entity; + $sql .= " AND t.active = 1"; + $sql .= " AND t.fk_pcg_version = '".$this->db->escape($pcgvercode)."'"; $sql .= " ORDER BY t.account_number"; } else { $sql = "SELECT t.rowid, t.account_number, t.label as account_label"; $sql .= " FROM ".MAIN_DB_PREFIX."accounting_account as t"; $sql .= " WHERE ".$predefinedgroupwhere; $sql .= " AND t.entity = ".$conf->entity; + $sql .= ' AND t.active = 1'; + $sql .= " AND t.fk_pcg_version = '".$this->db->escape($pcgvercode)."'"; $sql .= " ORDER BY t.account_number"; } - //echo $sql; $resql = $this->db->query($sql); if ($resql) { diff --git a/htdocs/accountancy/class/accountancyexport.class.php b/htdocs/accountancy/class/accountancyexport.class.php index d34f89d95d3..ed51a2aea5e 100644 --- a/htdocs/accountancy/class/accountancyexport.class.php +++ b/htdocs/accountancy/class/accountancyexport.class.php @@ -2130,14 +2130,16 @@ class AccountancyExport //Calcul de la longueur des numéros de comptes $taille_numero = strlen(length_accountg($line->numero_compte)); - //Création du numéro de client générique + //Création du numéro de client et fournisseur générique $numero_cpt_client = '411'; + $numero_cpt_fourn = '401'; for ($i = 1; $i <= ($taille_numero - 3); $i++) { $numero_cpt_client .= '0'; + $numero_cpt_fourn .= '0'; } - //Création des comptes auxiliaire des clients - if (length_accountg($line->numero_compte) == $numero_cpt_client) { + //Création des comptes auxiliaire des clients et fournisseur + if (length_accountg($line->numero_compte) == $numero_cpt_client || length_accountg($line->numero_compte) == $numero_cpt_fourn) { $tab[] = rtrim(length_accounta($line->subledger_account), "0"); } else { $tab[] = length_accountg($line->numero_compte); diff --git a/htdocs/accountancy/class/accountancysystem.class.php b/htdocs/accountancy/class/accountancysystem.class.php index a62dddd6a26..99f908e70e3 100644 --- a/htdocs/accountancy/class/accountancysystem.class.php +++ b/htdocs/accountancy/class/accountancysystem.class.php @@ -38,6 +38,11 @@ class AccountancySystem */ public $error = ''; + /** + * @var string[] Array of Errors code (or messages) + */ + public $errors = array(); + /** * @var int ID */ diff --git a/htdocs/accountancy/expensereport/list.php b/htdocs/accountancy/expensereport/list.php index 1cf9149024a..4ad8c80a2c1 100644 --- a/htdocs/accountancy/expensereport/list.php +++ b/htdocs/accountancy/expensereport/list.php @@ -159,7 +159,6 @@ if (empty($reshook)) { if ($massaction == 'ventil' && $user->rights->accounting->bind->write) { $msg = ''; - //print '
' . $langs->trans("Processing") . '...
'; if (!empty($mesCasesCochees)) { $msg = '
'.$langs->trans("SelectedLines").': '.count($mesCasesCochees).'
'; $msg .= '
'; @@ -173,7 +172,7 @@ if ($massaction == 'ventil' && $user->rights->accounting->bind->write) { $monCompte = GETPOST('codeventil'.$monId); if ($monCompte <= 0) { - $msg .= '
'.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("NoAccountSelected").'
'; + $msg .= '
'.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("NoAccountSelected").'
'; $ko++; } else { $sql = " UPDATE ".MAIN_DB_PREFIX."expensereport_det"; @@ -185,10 +184,10 @@ if ($massaction == 'ventil' && $user->rights->accounting->bind->write) { dol_syslog('accountancy/expensereport/list.php:: sql='.$sql, LOG_DEBUG); if ($db->query($sql)) { - $msg .= '
'.$langs->trans("LineOfExpenseReport").' '.$monId.' - '.$langs->trans("VentilatedinAccount").' : '.length_accountg($accountventilated->account_number).'
'; + $msg .= '
'.$langs->trans("LineOfExpenseReport").' '.$monId.' - '.$langs->trans("VentilatedinAccount").' : '.length_accountg($accountventilated->account_number).'
'; $ok++; } else { - $msg .= '
'.$langs->trans("ErrorDB").' : '.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("NotVentilatedinAccount").' : '.length_accountg($accountventilated->account_number).'
'.$sql.'
'; + $msg .= '
'.$langs->trans("ErrorDB").' : '.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("NotVentilatedinAccount").' : '.length_accountg($accountventilated->account_number).'
'.$sql.'
'; $ko++; } } diff --git a/htdocs/accountancy/journal/bankjournal.php b/htdocs/accountancy/journal/bankjournal.php index c23392cada0..544f077f1ea 100644 --- a/htdocs/accountancy/journal/bankjournal.php +++ b/htdocs/accountancy/journal/bankjournal.php @@ -434,7 +434,7 @@ if ($result) { $tabpay[$obj->rowid]["paymentsalid"] = $paymentsalstatic->id; // This part of code is no more required. it is here to solve case where a link were missing (ith v14.0.0) and keep writing in accountancy complete. - // Note: A better way to fix this is to delete payement of salary and recreate it, or to fix the bookkeeping table manually after. + // Note: A better way to fix this is to delete payment of salary and recreate it, or to fix the bookkeeping table manually after. if (!empty($conf->global->ACCOUNTANCY_AUTOFIX_MISSING_LINK_TO_USEr_ON_SALARY_BANK_PAYMENT)) { $tmpsalary = new Salary($db); $tmpsalary->fetch($paymentsalstatic->id); diff --git a/htdocs/accountancy/supplier/list.php b/htdocs/accountancy/supplier/list.php index aae34a51e03..3ec92f490bd 100644 --- a/htdocs/accountancy/supplier/list.php +++ b/htdocs/accountancy/supplier/list.php @@ -170,7 +170,6 @@ if (empty($reshook)) { if ($massaction == 'ventil' && $user->rights->accounting->bind->write) { $msg = ''; - //print '
' . $langs->trans("Processing") . '...
'; if (!empty($mesCasesCochees)) { $msg = '
'.$langs->trans("SelectedLines").': '.count($mesCasesCochees).'
'; $msg .= '
'; @@ -184,7 +183,7 @@ if ($massaction == 'ventil' && $user->rights->accounting->bind->write) { $monCompte = GETPOST('codeventil'.$monId); if ($monCompte <= 0) { - $msg .= '
'.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("NoAccountSelected").'
'; + $msg .= '
'.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("NoAccountSelected").'
'; $ko++; } else { $sql = " UPDATE ".MAIN_DB_PREFIX."facture_fourn_det"; @@ -196,10 +195,10 @@ if ($massaction == 'ventil' && $user->rights->accounting->bind->write) { dol_syslog('accountancy/supplier/list.php', LOG_DEBUG); if ($db->query($sql)) { - $msg .= '
'.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("VentilatedinAccount").' : '.length_accountg($accountventilated->account_number).'
'; + $msg .= '
'.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("VentilatedinAccount").' : '.length_accountg($accountventilated->account_number).'
'; $ok++; } else { - $msg .= '
'.$langs->trans("ErrorDB").' : '.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("NotVentilatedinAccount").' : '.length_accountg($accountventilated->account_number).'
'.$sql.'
'; + $msg .= '
'.$langs->trans("ErrorDB").' : '.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("NotVentilatedinAccount").' : '.length_accountg($accountventilated->account_number).'
'.$sql.'
'; $ko++; } } diff --git a/htdocs/adherents/admin/member_extrafields.php b/htdocs/adherents/admin/member_extrafields.php index 5776828c078..4bca5e91db1 100644 --- a/htdocs/adherents/admin/member_extrafields.php +++ b/htdocs/adherents/admin/member_extrafields.php @@ -65,7 +65,7 @@ require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php'; $textobject = $langs->transnoentitiesnoconv("Members"); -$help_url = 'EN:Module_Foundations|FR:Module_Adhérents|ES:Módulo_Miembros'; +$help_url = 'EN:Module_Foundations|FR:Module_Adhérents|ES:Módulo_Miembros|DE:Modul_Mitglieder'; llxHeader('', $langs->trans("MembersSetup"), $help_url); diff --git a/htdocs/adherents/admin/website.php b/htdocs/adherents/admin/website.php index 0ba5641b149..c04cfadec20 100644 --- a/htdocs/adherents/admin/website.php +++ b/htdocs/adherents/admin/website.php @@ -99,7 +99,7 @@ if ($action == 'update') { $form = new Form($db); $title = $langs->trans("MembersSetup"); -$help_url = 'EN:Module_Foundations|FR:Module_Adhérents|ES:Módulo_Miembros'; +$help_url = 'EN:Module_Foundations|FR:Module_Adhérents|ES:Módulo_Miembros|DE:Modul_Mitglieder'; llxHeader('', $title, $help_url); diff --git a/htdocs/adherents/agenda.php b/htdocs/adherents/agenda.php index 918eaa5d27e..6bf2a084563 100644 --- a/htdocs/adherents/agenda.php +++ b/htdocs/adherents/agenda.php @@ -66,11 +66,15 @@ if (GETPOST('actioncode', 'array')) { } else { $actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : getDolGlobalString('AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT')); } +$search_rowid = GETPOST('search_rowid'); $search_agenda_label = GETPOST('search_agenda_label'); // Get object canvas (By default, this is not defined, so standard usage of dolibarr) $objcanvas = null; +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context +$hookmanager->initHooks(array('memberagenda')); + // Security check $result = restrictedArea($user, 'adherent', $id); @@ -105,6 +109,7 @@ if (empty($reshook)) { // Purge search criteria if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All test are required to be compatible with all browsers $actioncode = ''; + $search_rowid = ''; $search_agenda_label = ''; } } @@ -184,6 +189,7 @@ if ($object->id > 0) { // List of all actions $filters = array(); $filters['search_agenda_label'] = $search_agenda_label; + $filters['search_rowid'] = $search_rowid; // TODO Replace this with same code than into list.php show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder); diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index f9a43e47f0f..4bc3e3e55e4 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -1873,7 +1873,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print "\n"; print "
\n"; - print '
'; + print '
'; print dol_get_fiche_end(); diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 6e77fd3fa95..f8d37ff30ca 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -2286,9 +2286,11 @@ class Adherent extends CommonObject { global $conf, $langs; - $datas = []; + $langs->loadLangs(['members', 'companies']); + $nofetch = !empty($params['nofetch']); + + $datas = array(); - $nofetch = empty($params['nofetch']) ? false : true; if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { $langs->load("users"); return ['optimize' => $langs->trans("ShowUser")]; @@ -2298,11 +2300,13 @@ class Adherent extends CommonObject $photo .= Form::showphoto('memberphoto', $this, 80, 0, 0, 'photoref photowithmargin photologintooltip', 'small', 0, 1); $photo .= ''; $datas['photo'] = $photo; - //$label .= '
'; } $datas['divopen'] = '
'; $datas['picto'] = img_picto('', $this->picto).' '.$langs->trans("Member").' '.$this->getLibStatut(4); + if (!empty($this->morphy)) { + $datas['picto'] .= ' ' . $this->getmorphylib('', 1); + } if (!empty($this->ref)) { $datas['ref'] = '
'.$langs->trans('Ref').': '.$this->ref; } @@ -2407,7 +2411,7 @@ class Adherent extends CommonObject if ($withpictoimg) { $paddafterimage = ''; if (abs($withpictoimg) == 1) { - $paddafterimage = 'style="margin-right: 3px;"'; + $morecss .= ' paddingrightonly'; } // Only picto if ($withpictoimg > 0) { diff --git a/htdocs/adherents/class/adherent_type.class.php b/htdocs/adherents/class/adherent_type.class.php index a744ce71bdc..eda018e6dca 100644 --- a/htdocs/adherents/class/adherent_type.class.php +++ b/htdocs/adherents/class/adherent_type.class.php @@ -706,6 +706,18 @@ class AdherentType extends CommonObject if (isset($this->subscription)) { $datas['subscription'] = '
'.$langs->trans("SubscriptionRequired").': '.yn($this->subscription); } + if (isset($this->vote)) { + $datas['vote'] = '
'.$langs->trans("VoteAllowed").': '.yn($this->vote); + } + if (isset($this->duration)) { + $datas['duration'] = '
'.$langs->trans("Duration").': '.$this->duration_value; + if ($this->duration_value > 1) { + $dur = array("i"=>$langs->trans("Minutes"), "h"=>$langs->trans("Hours"), "d"=>$langs->trans("Days"), "w"=>$langs->trans("Weeks"), "m"=>$langs->trans("Months"), "y"=>$langs->trans("Years")); + } elseif ($this->duration_value > 0) { + $dur = array("i"=>$langs->trans("Minute"), "h"=>$langs->trans("Hour"), "d"=>$langs->trans("Day"), "w"=>$langs->trans("Week"), "m"=>$langs->trans("Month"), "y"=>$langs->trans("Year")); + } + $datas['duration'] .= " " . (!empty($this->duration_unit) && isset($dur[$this->duration_unit]) ? $langs->trans($dur[$this->duration_unit]) : ''); + } return $datas; } @@ -733,6 +745,7 @@ class AdherentType extends CommonObject 'id' => $this->id, 'objecttype' => $this->element, 'option' => $option, + 'nofetch' => 1, ]; if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) { $classfortooltip = 'classforajaxtooltip'; diff --git a/htdocs/adherents/index.php b/htdocs/adherents/index.php index a5f9c26f192..fd031421c8b 100644 --- a/htdocs/adherents/index.php +++ b/htdocs/adherents/index.php @@ -77,7 +77,7 @@ $form = new Form($db); // Load $resultboxes (selectboxlist + boxactivated + boxlista + boxlistb) $resultboxes = FormOther::getBoxesArea($user, "2"); -llxHeader('', $langs->trans("Members"), 'EN:Module_Foundations|FR:Module_Adhérents|ES:Módulo_Miembros'); +llxHeader('', $langs->trans("Members"), 'EN:Module_Foundations|FR:Module_Adhérents|ES:Módulo_Miembros|DE:Modul_Mitglieder'); $staticmember = new Adherent($db); $statictype = new AdherentType($db); diff --git a/htdocs/adherents/ldap.php b/htdocs/adherents/ldap.php index 83b7e5f3764..c466ff7ff9d 100644 --- a/htdocs/adherents/ldap.php +++ b/htdocs/adherents/ldap.php @@ -104,7 +104,7 @@ if ($action == 'dolibarr2ldap') { $form = new Form($db); -llxHeader('', $langs->trans("Member"), 'EN:Module_Foundations|FR:Module_Adhérents|ES:Módulo_Miembros'); +llxHeader('', $langs->trans("Member"), 'EN:Module_Foundations|FR:Module_Adhérents|ES:Módulo_Miembros|DE:Modul_Mitglieder'); $head = member_prepare_head($object); diff --git a/htdocs/adherents/list.php b/htdocs/adherents/list.php index 7684b175ccb..b44abce662d 100644 --- a/htdocs/adherents/list.php +++ b/htdocs/adherents/list.php @@ -325,7 +325,7 @@ $membertypestatic = new AdherentType($db); $memberstatic = new Adherent($db); // Page Header -$title = $langs->trans("Members")." - ".$langs->trans("List");; +$title = $langs->trans("Members")." - ".$langs->trans("List"); $help_url = 'EN:Module_Foundations|FR:Module_Adhérents|ES:Módulo_Miembros|DE:Modul_Mitglieder'; llxHeader('', $title, $help_url); @@ -1051,7 +1051,7 @@ while ($i < min($num, $limit)) { if ($mode == 'kanban') { if ($i == 0) { print ''; - print '
'; + print '
'; } $membertypestatic->id = $obj->type_id; $membertypestatic->label = $obj->type; diff --git a/htdocs/adherents/stats/index.php b/htdocs/adherents/stats/index.php index 30b79f4bd76..0efdda9fbd2 100644 --- a/htdocs/adherents/stats/index.php +++ b/htdocs/adherents/stats/index.php @@ -225,7 +225,7 @@ print ''; print '
'; -print '
'; +print '
'; print dol_get_fiche_end(); diff --git a/htdocs/adherents/subscription.php b/htdocs/adherents/subscription.php index 004bd7eaf4b..a1aa8b8baa9 100644 --- a/htdocs/adherents/subscription.php +++ b/htdocs/adherents/subscription.php @@ -664,7 +664,7 @@ if ($rowid > 0) { print "\n"; print "
\n"; - print '
'; + print '
'; print dol_get_fiche_end(); diff --git a/htdocs/adherents/subscription/card.php b/htdocs/adherents/subscription/card.php index ea47ffc9362..b97fac372e5 100644 --- a/htdocs/adherents/subscription/card.php +++ b/htdocs/adherents/subscription/card.php @@ -160,7 +160,7 @@ if ($action == 'confirm_delete' && $confirm == 'yes' && $user->hasRight('adheren $form = new Form($db); -$help_url = 'EN:Module_Foundations|FR:Module_Adhérents|ES:Módulo_Miembros'; +$help_url = 'EN:Module_Foundations|FR:Module_Adhérents|ES:Módulo_Miembros|DE:Modul_Mitglieder'; llxHeader('', $langs->trans("SubscriptionCard"), $help_url); @@ -375,8 +375,8 @@ if ($rowid && $action != 'edit') { $filename = dol_sanitizeFileName($object->ref); $filedir = $conf->facture->dir_output . '/' . dol_sanitizeFileName($object->ref); $urlsource = $_SERVER['PHP_SELF'] . '?facid=' . $object->id; - $genallowed = $user->rights->facture->lire; - $delallowed = $user->rights->facture->creer; + $genallowed = $user->hasRight('facture', 'lire'); + $delallowed = $user->hasRight('facture', 'creer'); print $formfile->showdocuments('facture', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang); $somethingshown = $formfile->numoffiles; diff --git a/htdocs/adherents/subscription/list.php b/htdocs/adherents/subscription/list.php index 40a9c042bd4..45fbc99b816 100644 --- a/htdocs/adherents/subscription/list.php +++ b/htdocs/adherents/subscription/list.php @@ -249,7 +249,7 @@ if (!empty($date_select)) { $title .= ' ('.$langs->trans("Year").' '.$date_select.')'; } -$help_url = 'EN:Module_Foundations|FR:Module_Adhérents|ES:Módulo_Miembros'; +$help_url = 'EN:Module_Foundations|FR:Module_Adhérents|ES:Módulo_Miembros|DE:Modul_Mitglieder'; llxHeader('', $title, $help_url); $i = 0; @@ -532,7 +532,7 @@ while ($i < min($num, $limit)) { if ($mode == 'kanban') { if ($i == 0) { print ''; - print '
'; + print '
'; } //fetch informations needs on this mode diff --git a/htdocs/adherents/type.php b/htdocs/adherents/type.php index c91915f7bdb..207acc53e6f 100644 --- a/htdocs/adherents/type.php +++ b/htdocs/adherents/type.php @@ -37,10 +37,12 @@ require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; +// Load translation files required by the page $langs->load("members"); $rowid = GETPOST('rowid', 'int'); $action = GETPOST('action', 'aZ09'); +$massaction = GETPOST('massaction', 'alpha'); $cancel = GETPOST('cancel', 'alpha'); $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : str_replace('_', '', basename(dirname(__FILE__)).basename(__FILE__, '.php')); // To manage different context of search $backtopage = GETPOST('backtopage', 'alpha'); @@ -55,13 +57,15 @@ $type = GETPOST('type', 'intcomma'); $status = GETPOST('status', 'alpha'); $optioncss = GETPOST('optioncss', 'alpha'); +// Load variable for pagination $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); -if (empty($page) || $page == -1) { +if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) { + // If $page is not defined, or '' or -1 or if we click on clear filters $page = 0; -} // If $page is not defined, or '' or -1 +} $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; @@ -84,14 +88,12 @@ $comment = GETPOST("comment", 'restricthtml'); $mail_valid = GETPOST("mail_valid", 'restricthtml'); $caneditamount = GETPOSTINT("caneditamount"); -// Security check -$result = restrictedArea($user, 'adherent', $rowid, 'adherent_type'); - +// Initialize technical objects $object = new AdherentType($db); - $extrafields = new ExtraFields($db); +$hookmanager->initHooks(array('membertypecard', 'globalcard')); -// fetch optionals attributes and labels +// Fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers @@ -103,14 +105,22 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter_x' } -// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$hookmanager->initHooks(array('membertypecard', 'globalcard')); +// Security check +$result = restrictedArea($user, 'adherent', $rowid, 'adherent_type'); /* * Actions */ +if (GETPOST('cancel', 'alpha')) { + $action = 'list'; + $massaction = ''; +} +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { + $massaction = ''; +} + if ($cancel) { $action = ''; @@ -327,7 +337,7 @@ if (!$rowid && $action != 'create' && $action != 'edit') { if ($mode == 'kanban') { if ($i == 0) { print ''; - print '
'; + print '
'; } //output kanban $membertype->label = $objp->label; @@ -340,9 +350,7 @@ if (!$rowid && $action != 'create' && $action != 'edit') { print ''; if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { if ($user->rights->adherent->configurer) { - print 'rowid.'">'.img_edit().''; - } else { - print ' '; + print 'rowid.'">'.img_edit().''; } } print ''; @@ -367,8 +375,6 @@ if (!$rowid && $action != 'create' && $action != 'edit') { if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { if ($user->rights->adherent->configurer) { print 'rowid.'">'.img_edit().''; - } else { - print ' '; } } print ""; @@ -384,7 +390,7 @@ if (!$rowid && $action != 'create' && $action != 'edit') { $colspan++; } }*/ - $colspan = 8; + $colspan = 9; print ''.$langs->trans("NoRecordFound").''; } @@ -522,7 +528,7 @@ if ($rowid > 0) { print ''.$langs->trans("Duration").''.$object->duration_value.' '; if ($object->duration_value > 1) { - $dur = array("i"=>$langs->trans("Minute"), "h"=>$langs->trans("Hours"), "d"=>$langs->trans("Days"), "w"=>$langs->trans("Weeks"), "m"=>$langs->trans("Months"), "y"=>$langs->trans("Years")); + $dur = array("i"=>$langs->trans("Minutes"), "h"=>$langs->trans("Hours"), "d"=>$langs->trans("Days"), "w"=>$langs->trans("Weeks"), "m"=>$langs->trans("Months"), "y"=>$langs->trans("Years")); } elseif ($object->duration_value > 0) { $dur = array("i"=>$langs->trans("Minute"), "h"=>$langs->trans("Hour"), "d"=>$langs->trans("Day"), "w"=>$langs->trans("Week"), "m"=>$langs->trans("Month"), "y"=>$langs->trans("Year")); } diff --git a/htdocs/admin/agenda.php b/htdocs/admin/agenda.php index c62101ab70b..a3c9a3d3bb4 100644 --- a/htdocs/admin/agenda.php +++ b/htdocs/admin/agenda.php @@ -115,7 +115,7 @@ if ($action == "save" && empty($cancel)) { // $wikihelp = 'EN:Module_Agenda_En|FR:Module_Agenda|ES:Módulo_Agenda'; -$help_url = 'EN:Module_Agenda_En|FR:Module_Agenda|ES:Módulo_Agenda'; +$help_url = 'EN:Module_Agenda_En|FR:Module_Agenda|ES:Módulo_Agenda|DE:Modul_Terminplanung'; llxHeader('', $langs->trans("AgendaSetup"), $help_url); diff --git a/htdocs/admin/agenda_extrafields.php b/htdocs/admin/agenda_extrafields.php index cade3a90e71..eed059c3ca7 100644 --- a/htdocs/admin/agenda_extrafields.php +++ b/htdocs/admin/agenda_extrafields.php @@ -72,7 +72,7 @@ require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php'; $textobject = $langs->transnoentitiesnoconv("Agenda"); -$wikihelp = 'EN:Module_Agenda_En|FR:Module_Agenda|ES:Módulo_Agenda'; +$wikihelp = 'EN:Module_Agenda_En|FR:Module_Agenda|ES:Módulo_Agenda|DE:Modul_Terminplanung'; llxHeader('', $langs->trans("AgendaSetup"), $wikihelp); $linkback = ''.$langs->trans("BackToModuleList").''; diff --git a/htdocs/admin/agenda_extsites.php b/htdocs/admin/agenda_extsites.php index 83391e6ce3d..8389c7e0d82 100644 --- a/htdocs/admin/agenda_extsites.php +++ b/htdocs/admin/agenda_extsites.php @@ -185,7 +185,7 @@ $formother = new FormOther($db); $arrayofjs = array(); $arrayofcss = array(); -$wikihelp = 'EN:Module_Agenda_En|FR:Module_Agenda|ES:Módulo_Agenda'; +$wikihelp = 'EN:Module_Agenda_En|FR:Module_Agenda|ES:Módulo_Agenda|DE:Modul_Terminplanung'; llxHeader('', $langs->trans("AgendaSetup"), $wikihelp, '', 0, 0, $arrayofjs, $arrayofcss); $linkback = ''.$langs->trans("BackToModuleList").''; diff --git a/htdocs/admin/agenda_other.php b/htdocs/admin/agenda_other.php index aef46db26ef..3ed883bffa6 100644 --- a/htdocs/admin/agenda_other.php +++ b/htdocs/admin/agenda_other.php @@ -182,7 +182,7 @@ if ($action == 'set') { $formactions = new FormActions($db); $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); -$wikihelp = 'EN:Module_Agenda_En|FR:Module_Agenda|ES:Módulo_Agenda'; +$wikihelp = 'EN:Module_Agenda_En|FR:Module_Agenda|ES:Módulo_Agenda|DE:Modul_Terminplanung'; llxHeader('', $langs->trans("AgendaSetup"), $wikihelp); $linkback = ''.$langs->trans("BackToModuleList").''; diff --git a/htdocs/admin/agenda_xcal.php b/htdocs/admin/agenda_xcal.php index 499d7233ed0..9ed5b5d0615 100644 --- a/htdocs/admin/agenda_xcal.php +++ b/htdocs/admin/agenda_xcal.php @@ -70,7 +70,7 @@ if (!isset($conf->global->MAIN_AGENDA_EXPORT_PAST_DELAY)) { $conf->global->MAIN_AGENDA_EXPORT_PAST_DELAY = 100; } -$wikihelp = 'EN:Module_Agenda_En|FR:Module_Agenda|ES:Módulo_Agenda'; +$wikihelp = 'EN:Module_Agenda_En|FR:Module_Agenda|ES:Módulo_Agenda|DE:Modul_Terminplanung'; llxHeader('', $langs->trans("AgendaSetup"), $wikihelp); $linkback = ''.$langs->trans("BackToModuleList").''; diff --git a/htdocs/admin/const.php b/htdocs/admin/const.php index e5625b0f975..895ce8c1b08 100644 --- a/htdocs/admin/const.php +++ b/htdocs/admin/const.php @@ -32,10 +32,6 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/security.lib.php'; // Load translation files required by the page $langs->load("admin"); -if (!$user->admin) { - accessforbidden(); -} - $rowid = GETPOST('rowid', 'int'); $entity = GETPOST('entity', 'int'); $action = GETPOST('action', 'aZ09'); @@ -44,7 +40,6 @@ $consts = GETPOST('const', 'array'); $constname = GETPOST('constname', 'alphanohtml'); $constvalue = GETPOST('constvalue', 'restricthtml'); // We should be able to send everything here $constnote = GETPOST('constnote', 'alpha'); - // Load variable for pagination $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); @@ -63,12 +58,30 @@ if (empty($sortorder)) { $sortorder = 'ASC'; } +if ($action == 'add' && GETPOST('update')) { // Click on button update must be used in priority before param $action + $action = 'update'; +} +if ($action == 'add' && GETPOST('delete')) { // Click on button update must be used in priority before param $action + $action = 'delete'; +} +if ($action == 'update' && GETPOST('add')) { // Click on button add must be used in priority before param $action + $action = 'add'; +} +if ($action == 'delete' && GETPOST('add')) { // Click on button add must be used in priority before param $action + $action = 'add'; +} + +if (!$user->admin) { + accessforbidden(); +} + /* * Actions */ -if ($action == 'add' || (GETPOST('add') && $action != 'update')) { +// Add a new record +if ($action == 'add') { $error = 0; if (empty($constname)) { @@ -157,13 +170,12 @@ jQuery(document).ready(function() { jQuery("#delconst").hide(); jQuery(".checkboxfordelete").click(function() { jQuery("#delconst").show(); - jQuery("#action").val('delete'); }); jQuery(".inputforupdate").keyup(function() { // keypress does not support back var field_id = jQuery(this).attr("id"); var row_num = field_id.split("_"); jQuery("#updateconst").show(); - jQuery("#action").val('update'); + jQuery("#action").val('update'); // so default action if we type enter will be update, but correct action is also detected correctly without that when clicking on "Update" button. jQuery("#check_" + row_num[1]).prop("checked",true); }); }); @@ -180,7 +192,7 @@ $param = ''; print '
entity) && $debug) ? '?debug=1' : '').'" method="POST">'; print ''; -print ''; +print ''; print ''; print ''; diff --git a/htdocs/admin/dolistore/class/dolistore.class.php b/htdocs/admin/dolistore/class/dolistore.class.php index f890262695f..37cfb53d493 100644 --- a/htdocs/admin/dolistore/class/dolistore.class.php +++ b/htdocs/admin/dolistore/class/dolistore.class.php @@ -329,7 +329,6 @@ class Dolistore $html .= ''; $html .= ' '.dol_print_date(dol_stringtotime($product->date_upd), 'dayhour').' - '.$langs->trans('Ref').': '.dol_escape_htmltag($product->reference).' - '.dol_escape_htmltag($langs->trans('Id')).': '.((int) $product->id).'

'.dol_escape_htmltag($product->description_short->language[$this->lang - 1]).''; // do not load if display none - //$html .= ''.$product->description->language[$this->lang - 1].''; $html .= ''; $html .= $price; $html .= ''; diff --git a/htdocs/admin/emailcollector_list.php b/htdocs/admin/emailcollector_list.php index de18b57b297..3913d10df56 100644 --- a/htdocs/admin/emailcollector_list.php +++ b/htdocs/admin/emailcollector_list.php @@ -552,7 +552,7 @@ while ($i < $imaxinloop) { if ($mode == 'kanban') { if ($i == 0) { print ''; - print '
'; + print '
'; } // Output Kanban print $object->getKanbanView(''); diff --git a/htdocs/admin/external_rss.php b/htdocs/admin/external_rss.php index d46f1897b71..9026ed1a474 100644 --- a/htdocs/admin/external_rss.php +++ b/htdocs/admin/external_rss.php @@ -296,9 +296,13 @@ if ($resql) { $imageurl = $rssparser->getImageUrl(); $linkrss = $rssparser->getLink(); if (!preg_match('/^http/', $imageurl)) { - $imageurl = $linkrss.$imageurl; + include_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; + if (image_format_supported($imageurl) >= 0) { + // If we are sure imageurl is a path to an image file, and if it does not start with http, we append root url to it. + $imageurl = $linkrss.$imageurl; + } } - if ($imageurl) { + if ($imageurl && preg_match('/^http', $imageurl)) { print ''; } else { print $langs->trans("None"); diff --git a/htdocs/admin/ihm.php b/htdocs/admin/ihm.php index 5347eebd392..b868a847e9e 100644 --- a/htdocs/admin/ihm.php +++ b/htdocs/admin/ihm.php @@ -6,6 +6,7 @@ * Copyright (C) 2018 Ferran Marcet * Copyright (C) 2021 Alexandre Spangaro * Copyright (C) 2021 Anthony Berton + * Copyright (C) 2023 Eric Seigne * * 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 @@ -298,13 +299,19 @@ if ($action == 'update') { } } + if ($mode == 'css') { + //file_put_contents(DOL_DATA_ROOT.'/admin/customcss.css', $data); + //dol_chmod(DOL_DATA_ROOT.'/admin/customcss.css'); + dolibarr_set_const($db, "MAIN_IHM_CUSTOM_CSS", GETPOST('MAIN_IHM_CUSTOM_CSS', 'restricthtml'), 'chaine', 0, '', $conf->entity); + } + $_SESSION["mainmenu"] = ""; // The menu manager may have changed if (GETPOST('dol_resetcache')) { dolibarr_set_const($db, "MAIN_IHM_PARAMS_REV", ((int) $conf->global->MAIN_IHM_PARAMS_REV) + 1, 'chaine', 0, '', $conf->entity); } - header("Location: ".$_SERVER["PHP_SELF"]."?mainmenu=home&leftmenu=setup".'&mode='.$mode.(GETPOSTISSET('page_y') ? '&page_y='.GETPOST('page_y', 'int') : '')); + header("Location: ".$_SERVER["PHP_SELF"]."?mainmenu=home&leftmenu=setup&mode=".$mode.(GETPOSTISSET('page_y') ? '&page_y='.GETPOST('page_y', 'int') : '')); exit; } @@ -314,7 +321,13 @@ if ($action == 'update') { */ $wikihelp = 'EN:First_setup|FR:Premiers_paramétrages|ES:Primeras_configuraciones'; -llxHeader('', $langs->trans("Setup"), $wikihelp); + +llxHeader('', $langs->trans("Setup"), $wikihelp, '', 0, 0, + array( + '/includes/ace/src/ace.js', + '/includes/ace/src/ext-statusbar.js', + '/includes/ace/src/ext-language_tools.js', + ), array()); $form = new Form($db); $formother = new FormOther($db); @@ -679,8 +692,27 @@ if ($mode == 'login') { print '
'; } +if ($mode == 'css') { + print '
'; + print ''; + + print ''; + print ''."\n"; + + print '
'; + + //$customcssValue = file_get_contents(DOL_DATA_ROOT.'/admin/customcss.css'); + $customcssValue = getDolGlobalString('MAIN_IHM_CUSTOM_CSS'); + + $doleditor = new DolEditor('MAIN_IHM_CUSTOM_CSS', $customcssValue, '80%', 400, 'Basic', 'In', true, false, 'ace', 10, '90%'); + $doleditor->Create(0, '', true, 'css', 'css'); + print '
'."\n"; + print '
'; +} + + print '
'; -print ''; +print ''; print ''; print '
'; diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index c3f066a464e..9dc1b6e0811 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -582,8 +582,6 @@ if ($mode == 'common' || $mode == 'commonkanban') { $moreforfilter .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=commonkanban'.$param, '', ($mode == 'commonkanban' ? 2 : 1), array('morecss'=>'reposition')); $moreforfilter .= '
'; - //$moreforfilter .= '
'.$moreinfo.' '.$moreinfo2.'
'; - $moreforfilter .= '
'; $moreforfilter .= '
'; $moreforfilter .= img_picto($langs->trans("Filter"), 'filter', 'class="paddingright opacityhigh hideonsmartphone"').''; @@ -761,7 +759,7 @@ if ($mode == 'common' || $mode == 'commonkanban') { print load_fiche_titre($familytext, '', '', 0, '', 'modulefamilygroup'); if ($mode == 'commonkanban') { - print '
'; + print '
'; } else { print '
'; print ''."\n"; diff --git a/htdocs/admin/security_file.php b/htdocs/admin/security_file.php index 5538e0ad952..5ea581296af 100644 --- a/htdocs/admin/security_file.php +++ b/htdocs/admin/security_file.php @@ -80,8 +80,18 @@ if ($action == 'updateform') { } if (!$error) { + $tmpumask = GETPOST('MAIN_UMASK', 'alpha'); + $tmpumask = (octdec($tmpumask) & 0666); + $tmpumask = decoct($tmpumask); + if (!preg_match('/^0/', $tmpumask)) { + $tmpumask = '0'.$tmpumask; + } + if (empty($tmpumask) || $tmpumask === '0') { + $tmpumask = '0664'; + } + $res3 = dolibarr_set_const($db, 'MAIN_UPLOAD_DOC', GETPOST('MAIN_UPLOAD_DOC', 'alpha'), 'chaine', 0, '', $conf->entity); - $res4 = dolibarr_set_const($db, "MAIN_UMASK", GETPOST('MAIN_UMASK', 'alpha'), 'chaine', 0, '', $conf->entity); + $res4 = dolibarr_set_const($db, "MAIN_UMASK", $tmpumask, 'chaine', 0, '', $conf->entity); $res5 = dolibarr_set_const($db, "MAIN_ANTIVIRUS_COMMAND", trim($antivircommand), 'chaine', 0, '', $conf->entity); $res6 = dolibarr_set_const($db, "MAIN_ANTIVIRUS_PARAM", trim($antivirparam), 'chaine', 0, '', $conf->entity); if ($res3 && $res4 && $res5 && $res6) { diff --git a/htdocs/admin/system/perf.php b/htdocs/admin/system/perf.php index cc9ab7658db..fd586e24c95 100644 --- a/htdocs/admin/system/perf.php +++ b/htdocs/admin/system/perf.php @@ -82,14 +82,14 @@ print '
'; // Module log print '
'; print ''.$langs->trans("Syslog").': '; -$test = empty($conf->syslog->enabled); +$test = !isModEnabled('syslog'); if ($test) { print img_picto('', 'tick.png').' '.$langs->trans("NotInstalled").' '.$langs->trans("NotSlowedDownByThis").''; } else { - if ($conf->global->SYSLOG_LEVEL > LOG_NOTICE) { + if (getDolGlobalInt('SYSLOG_LEVEL') > LOG_NOTICE) { print img_picto('', 'warning').' '.$langs->trans("ModuleActivatedWithTooHighLogLevel", $langs->transnoentities("Syslog")); } else { - print img_picto('', 'tick.png').' '.$langs->trans("ModuleSyslogActivatedButLevelNotTooVerbose", $langs->transnoentities("Syslog"), $conf->global->SYSLOG_LEVEL); + print img_picto('', 'tick.png').' '.$langs->trans("ModuleSyslogActivatedButLevelNotTooVerbose", $langs->transnoentities("Syslog"), getDolGlobalInt('SYSLOG_LEVEL')); } //print ' '.$langs->trans("MoreInformation").' XDebug admin page'; } diff --git a/htdocs/admin/system/security.php b/htdocs/admin/system/security.php index e1b47b5beaa..5775ea5404e 100644 --- a/htdocs/admin/system/security.php +++ b/htdocs/admin/system/security.php @@ -453,14 +453,14 @@ print load_fiche_titre($langs->trans("Modules"), '', 'folder'); // Module log print ''.$langs->trans("Syslog").': '; -$test = empty($conf->syslog->enabled); +$test = !isModEnabled('syslog'); if ($test) { print img_picto('', 'tick.png').' '.$langs->trans("NotInstalled").' - '.$langs->trans("NotRiskOfLeakWithThis"); } else { - if ($conf->global->SYSLOG_LEVEL > LOG_NOTICE) { + if (getDolGlobalInt('SYSLOG_LEVEL') > LOG_NOTICE) { print img_picto('', 'warning').' '.$langs->trans("ModuleActivatedWithTooHighLogLevel", $langs->transnoentities("Syslog")); } else { - print img_picto('', 'tick.png').' '.$langs->trans("ModuleSyslogActivatedButLevelNotTooVerbose", $langs->transnoentities("Syslog"), $conf->global->SYSLOG_LEVEL); + print img_picto('', 'tick.png').' '.$langs->trans("ModuleSyslogActivatedButLevelNotTooVerbose", $langs->transnoentities("Syslog"), getDolGlobalInt('SYSLOG_LEVEL')); } //print ' '.$langs->trans("MoreInformation").' XDebug admin page'; } @@ -580,14 +580,15 @@ print '
'; print 'MAIN_DOCUMENT_IS_OUTSIDE_WEBROOT_SO_NOEXE_NOT_REQUIRED = '.getDolGlobalString('MAIN_DOCUMENT_IS_OUTSIDE_WEBROOT_SO_NOEXE_NOT_REQUIRED', ''.$langs->trans("Undefined").'   ('.$langs->trans("Recommended").': '.$langs->trans("Undefined").' '.$langs->trans("or").' 0)')."
"; print '
'; -print 'MAIN_SECURITY_FORCECSP = '.getDolGlobalString('MAIN_SECURITY_FORCECSP', ''.$langs->trans("Undefined").'').'   ('.$langs->trans("Example").": \"frame-ancestors 'self'; default-src 'self'; img-src *;\")
"; +print 'MAIN_SECURITY_FORCECSP = '.getDolGlobalString('MAIN_SECURITY_FORCECSP', ''.$langs->trans("Undefined").'').'   ('.$langs->trans("Example").": \"frame-ancestors 'self'; default-src *; img-src * data:; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline';\")
"; print '
'; print 'MAIN_SECURITY_FORCERP = '.getDolGlobalString('MAIN_SECURITY_FORCERP', ''.$langs->trans("Undefined").'').'   ('.$langs->trans("Recommended").': '.$langs->trans("Undefined").' '.$langs->trans("or")." \"same-origin\" so browser doesn't send any referrer when going into another web site domain)
"; print '
'; print 'WEBSITE_MAIN_SECURITY_FORCECSP = '.getDolGlobalString('WEBSITE_MAIN_SECURITY_FORCECSP', ''.$langs->trans("Undefined").''); -print '   ('.$langs->trans("Example").": \"frame-ancestors 'self'; default-src 'self'; style-src https://cdnjs.cloudflare.com https://fonts.googleapis.com; script-src https://cdn.transifex.com https://www.googletagmanager.com; object-src https://youtube.com; frame-src https://youtube.com; img-src *;\")
"; +print '   ('.$langs->trans("Example").": \"frame-ancestors 'self'; default-src 'self' 'unsafe-inline'; style-src https://cdnjs.cloudflare.com https://fonts.googleapis.com 'unsafe-inline'; script-src https://cdn.transifex.com https://www.googletagmanager.com 'unsafe-inline'; object-src https://youtube.com; frame-src https://youtube.com; img-src * data:;\")
"; + print '
'; print 'WEBSITE_MAIN_SECURITY_FORCERP = '.getDolGlobalString('WEBSITE_MAIN_SECURITY_FORCERP', ''.$langs->trans("Undefined").'').'   ('.$langs->trans("Recommended").': '.$langs->trans("Undefined").' '.$langs->trans("or")." \"strict-origin-when-cross-origin\")
"; diff --git a/htdocs/admin/tools/dolibarr_export.php b/htdocs/admin/tools/dolibarr_export.php index 8afd1f7e03c..3ce6dbd48a4 100644 --- a/htdocs/admin/tools/dolibarr_export.php +++ b/htdocs/admin/tools/dolibarr_export.php @@ -169,7 +169,7 @@ print ''; print ''; -print ''; } @@ -373,6 +376,9 @@ if ($modecompta == 'CREANCES-DETTES') { //$r = $AccCat->calculate($result); $r = dol_eval($result, 1, 1, '1'); + if (is_nan($r)) { + $r = 0; + } print ''; if (empty($sommes[$code]['N'])) { @@ -392,6 +398,9 @@ if ($modecompta == 'CREANCES-DETTES') { //$r = $AccCat->calculate($result); $r = dol_eval($result, 1, 1, '1'); + if (is_nan($r)) { + $r = 0; + } print ''; if (empty($sommes[$code]['M'][$k])) { @@ -412,6 +421,9 @@ if ($modecompta == 'CREANCES-DETTES') { //$r = $AccCat->calculate($result); $r = dol_eval($result, 1, 1, '1'); + if (is_nan($r)) { + $r = 0; + } print ''; if (empty($sommes[$code]['M'][$k])) { diff --git a/htdocs/compta/sociales/list.php b/htdocs/compta/sociales/list.php index a132a3650dc..498a28a54f5 100644 --- a/htdocs/compta/sociales/list.php +++ b/htdocs/compta/sociales/list.php @@ -614,7 +614,7 @@ while ($i < min($num, $limit)) { if ($mode == 'kanban') { if ($i == 0) { print '
'; print $langs->trans("DatabaseName").' : '.$dolibarr_main_db_name.'
'; print '
'; +print '
'; print ''; diff --git a/htdocs/admin/tools/purge.php b/htdocs/admin/tools/purge.php index ee95fd7b44e..6c771abbd32 100644 --- a/htdocs/admin/tools/purge.php +++ b/htdocs/admin/tools/purge.php @@ -38,8 +38,8 @@ $nbsecondsold = GETPOSTINT('nbsecondsold'); // Define filelog to discard it from purge $filelog = ''; -if (!empty($conf->syslog->enabled)) { - $filelog = $conf->global->SYSLOG_FILE; +if (isModEnabled('syslog')) { + $filelog = getDolGlobalString('SYSLOG_FILE'); $filelog = preg_replace('/DOL_DATA_ROOT/i', DOL_DATA_ROOT, $filelog); } @@ -96,7 +96,7 @@ print '
'; print ''; + if ($action == 'treeview') print ''; print ''; print ''; print ''; @@ -226,13 +227,17 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea foreach ($TChildBom as $fk_bom => $TProduct) { $repeatChar = ' '; if (!empty($TProduct['bom'])) { + $prod = new Product($db); + $prod->fetch($TProduct['bom']->fk_product); if ($TProduct['parentid'] != $object->id) print ''; else print ''; - print ''; + if ($action == 'treeview') print ''; print ''; print ''; print ''; @@ -247,6 +252,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea if ($fk_bom != $object->id) print ''; else print ''; print ''; + if ($action == 'treeview') print ''; print ''; print ''; print ''; @@ -290,20 +296,30 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea '; - $tmp = $tmp.''; - $desc = $form->textwithpicto($tmp, $langs->transnoentities("InvoiceDepositDesc"), 1, 'help', '', 0, 3); print '
'; -if (!empty($conf->syslog->enabled)) { +if (isModEnabled('syslog')) { print ' - * Copyright (C) 2022 SuperAdmin * * 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 @@ -23,39 +22,7 @@ */ // Load Dolibarr environment -$res = 0; -// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) { - $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; -} -// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME -$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; -while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { - $i--; $j--; -} -if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) { - $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; -} -if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) { - $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; -} -// Try main.inc.php using relative path -if (!$res && file_exists("../main.inc.php")) { - $res = @include "../main.inc.php"; -} -if (!$res && file_exists("../../main.inc.php")) { - $res = @include "../../main.inc.php"; -} -if (!$res && file_exists("../../../main.inc.php")) { - $res = @include "../../../main.inc.php"; -} -if (!$res) { - die("Include of main fails"); -} - -global $langs, $user; - -// Libraries +require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php"; require_once DOL_DOCUMENT_ROOT.'/webhook/lib/webhook.lib.php'; @@ -80,65 +47,27 @@ $label = GETPOST('label', 'alpha'); $scandir = GETPOST('scan_dir', 'alpha'); $type = 'myobject'; -$arrayofparameters = array( - 'WEBHOOK_MYPARAM1'=>array('type'=>'string', 'css'=>'minwidth500' ,'enabled'=>0), - //'WEBHOOK_MYPARAM2'=>array('type'=>'textarea','enabled'=>1), - //'WEBHOOK_MYPARAM3'=>array('type'=>'category:'.Categorie::TYPE_CUSTOMER, 'enabled'=>1), - //'WEBHOOK_MYPARAM4'=>array('type'=>'emailtemplate:thirdparty', 'enabled'=>1), - //'WEBHOOK_MYPARAM5'=>array('type'=>'yesno', 'enabled'=>1), - //'WEBHOOK_MYPARAM5'=>array('type'=>'thirdparty_type', 'enabled'=>1), - //'WEBHOOK_MYPARAM6'=>array('type'=>'securekey', 'enabled'=>1), - //'WEBHOOK_MYPARAM7'=>array('type'=>'product', 'enabled'=>1), -); $error = 0; $setupnotempty = 0; // Set this to 1 to use the factory to manage constants. Warning, the generated module will be compatible with version v15+ only -$useFormSetup = 0; -// Convert arrayofparameter into a formSetup object -if ($useFormSetup && (float) DOL_VERSION >= 15) { - require_once DOL_DOCUMENT_ROOT.'/core/class/html.formsetup.class.php'; - $formSetup = new FormSetup($db); +$useFormSetup = 1; - // you can use the param convertor - $formSetup->addItemsFromParamsArray($arrayofparameters); - - // or use the new system see exemple as follow (or use both because you can ;-) ) - - /* - // Hôte - $item = $formSetup->newItem('NO_PARAM_JUST_TEXT'); - $item->fieldOverride = (empty($_SERVER['HTTPS']) ? 'http://' : 'https://') . $_SERVER['HTTP_HOST']; - $item->cssClass = 'minwidth500'; - - // Setup conf WEBHOOK_MYPARAM1 as a simple string input - $item = $formSetup->newItem('WEBHOOK_MYPARAM1'); - - // Setup conf WEBHOOK_MYPARAM1 as a simple textarea input but we replace the text of field title - $item = $formSetup->newItem('WEBHOOK_MYPARAM2'); - $item->nameText = $item->getNameText().' more html text '; - - // Setup conf WEBHOOK_MYPARAM3 - $item = $formSetup->newItem('WEBHOOK_MYPARAM3'); - $item->setAsThirdpartyType(); - - // Setup conf WEBHOOK_MYPARAM4 : exemple of quick define write style - $formSetup->newItem('WEBHOOK_MYPARAM4')->setAsYesNo(); - - // Setup conf WEBHOOK_MYPARAM5 - $formSetup->newItem('WEBHOOK_MYPARAM5')->setAsEmailTemplate('thirdparty'); - - // Setup conf WEBHOOK_MYPARAM6 - $formSetup->newItem('WEBHOOK_MYPARAM6')->setAsSecureKey()->enabled = 0; // disabled - - // Setup conf WEBHOOK_MYPARAM7 - $formSetup->newItem('WEBHOOK_MYPARAM7')->setAsProduct(); - */ - - $setupnotempty = count($formSetup->items); +if (!class_exists('FormSetup')) { + // For retrocompatibility Dolibarr < 16.0 + if (floatval(DOL_VERSION) < 16.0 && !class_exists('FormSetup')) { + require_once __DIR__.'/../backport/v16/core/class/html.formsetup.class.php'; + } else { + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formsetup.class.php'; + } } +$formSetup = new FormSetup($db); + + +$setupnotempty = count($formSetup->items); + $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); @@ -179,7 +108,7 @@ if ($action == 'updateMask') { $file = dol_buildpath($reldir."core/modules/webhook/doc/pdf_".$modele."_".strtolower($tmpobjectkey).".modules.php", 0); if (file_exists($file)) { $filefound = 1; - $classname = "pdf_".$modele; + $classname = "pdf_".$modele."_".strtolower($tmpobjectkey); break; } } @@ -190,7 +119,7 @@ if ($action == 'updateMask') { $module = new $classname($db); if ($module->write_file($tmpobject, $langs) > 0) { - header("Location: ".DOL_URL_ROOT."/document.php?modulepart=".strtolower($tmpobjectkey)."&file=SPECIMEN.pdf"); + header("Location: ".DOL_URL_ROOT."/document.php?modulepart=webhook-".strtolower($tmpobjectkey)."&file=SPECIMEN.pdf"); return; } else { setEventMessages($module->error, null, 'errors'); @@ -266,7 +195,7 @@ print load_fiche_titre($langs->trans($page_name), $linkback, 'title_setup'); // Configuration header $head = webhookAdminPrepareHead(); -print dol_get_fiche_head($head, 'settings', $langs->trans($page_name), -1, "webhook@webhook"); +print dol_get_fiche_head($head, 'settings', $langs->trans($page_name), -1, "webhook"); // Setup page goes here echo ''.$langs->trans("WebhookSetupPage").'

'; diff --git a/htdocs/api/class/api_documents.class.php b/htdocs/api/class/api_documents.class.php index 8dae305a989..846e9272fb6 100644 --- a/htdocs/api/class/api_documents.class.php +++ b/htdocs/api/class/api_documents.class.php @@ -746,7 +746,7 @@ class Documents extends DolibarrApi if ($fhandle) { $nbofbyteswrote = fwrite($fhandle, $newfilecontent); fclose($fhandle); - @chmod($destfiletmp, octdec($conf->global->MAIN_UMASK)); + dolChmod($destfiletmp); } else { throw new RestException(500, "Failed to open file '".$destfiletmp."' for write"); } diff --git a/htdocs/asset/accountancy_codes.php b/htdocs/asset/accountancy_codes.php index 224380fc295..c6d3d0099ad 100644 --- a/htdocs/asset/accountancy_codes.php +++ b/htdocs/asset/accountancy_codes.php @@ -53,7 +53,7 @@ if ($id > 0 || !empty($ref)) { $upload_dir = $conf->asset->multidir_output[$object->entity] . "/" . $object->id; } -$permissiontoadd = $user->rights->asset->write; // Used by the include of actions_addupdatedelete.inc.php +$permissiontoadd = $user->hasRight('asset', 'write'); // Used by the include of actions_addupdatedelete.inc.php // Security check (enable the most restrictive one) if ($user->socid > 0) accessforbidden(); diff --git a/htdocs/asset/agenda.php b/htdocs/asset/agenda.php index c86697b207d..166eb12935c 100644 --- a/htdocs/asset/agenda.php +++ b/htdocs/asset/agenda.php @@ -48,6 +48,7 @@ if (GETPOST('actioncode', 'array')) { } else { $actioncode = GETPOST("actioncode", "alpha", 3) ? GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : getDolGlobalString('AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT')); } +$search_rowid = GETPOST('search_rowid'); $search_agenda_label = GETPOST('search_agenda_label'); $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; @@ -81,7 +82,7 @@ if ($id > 0 || !empty($ref)) { $upload_dir = $conf->asset->multidir_output[$object->entity]."/".$object->id; } -$permissiontoadd = $user->rights->asset->write; // Used by the include of actions_addupdatedelete.inc.php +$permissiontoadd = $user->hasRight('asset', 'write'); // Used by the include of actions_addupdatedelete.inc.php // Security check (enable the most restrictive one) if ($user->socid > 0) accessforbidden(); @@ -125,7 +126,7 @@ $form = new Form($db); if ($object->id > 0) { $title = $langs->trans("Agenda"); //if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/',$conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->name." - ".$title; - $help_url = 'EN:Module_Agenda_En'; + $help_url = 'EN:Module_Agenda_En|DE:Modul_Terminplanung'; llxHeader('', $title, $help_url); if (isModEnabled('notification')) { @@ -205,6 +206,7 @@ if ($object->id > 0) { // List of all actions $filters = array(); $filters['search_agenda_label'] = $search_agenda_label; + $filters['search_rowid'] = $search_rowid; // TODO Replace this with same code than into list.php show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder, $object->module); diff --git a/htdocs/asset/card.php b/htdocs/asset/card.php index dba49857aec..bd3255491fc 100644 --- a/htdocs/asset/card.php +++ b/htdocs/asset/card.php @@ -69,11 +69,11 @@ if (empty($action) && empty($id) && empty($ref)) { // Load object include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once. -$permissiontoread = $user->rights->asset->read; -$permissiontoadd = $user->rights->asset->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php -$permissiontodelete = $user->rights->asset->delete || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT); -$permissionnote = $user->rights->asset->write; // Used by the include of actions_setnotes.inc.php -$permissiondellink = $user->rights->asset->write; // Used by the include of actions_dellink.inc.php +$permissiontoread = $user->hasRight('asset', 'read'); +$permissiontoadd = $user->hasRight('asset', 'write'); // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php +$permissiontodelete = $user->hasRight('asset', 'delete') || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT); +$permissionnote = $user->hasRight('asset', 'write'); // Used by the include of actions_setnotes.inc.php +$permissiondellink = $user->hasRight('asset', 'write'); // Used by the include of actions_dellink.inc.php $upload_dir = $conf->asset->multidir_output[isset($object->entity) ? $object->entity : 1]; // Security check (enable the most restrictive one) @@ -395,8 +395,8 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $relativepath = $objref.'/'.$objref.'.pdf'; $filedir = $conf->asset->dir_output.'/'.$objref; $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; - $genallowed = $user->rights->asset->read; // If you can read, you can build the PDF to read content - $delallowed = $user->rights->asset->write; // If you can create/edit, you can remove a file on card + $genallowed = $user->hasRight('asset', 'read'); // If you can read, you can build the PDF to read content + $delallowed = $user->hasRight('asset', 'write'); // If you can create/edit, you can remove a file on card print $formfile->showdocuments('asset:Asset', $objref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', '', '', $langs->defaultlang); } diff --git a/htdocs/asset/class/asset.class.php b/htdocs/asset/class/asset.class.php index c01f4b967c4..5cf9e748d00 100644 --- a/htdocs/asset/class/asset.class.php +++ b/htdocs/asset/class/asset.class.php @@ -157,6 +157,11 @@ class Asset extends CommonObject public $status; public $user_cloture_id; + /** + * @var Asset object oldcopy + */ + public $oldcopy; + // /** // * @var string Field with ID of parent key if this object has a parent // */ diff --git a/htdocs/asset/depreciation_options.php b/htdocs/asset/depreciation_options.php index f4558ae6157..5d232670105 100644 --- a/htdocs/asset/depreciation_options.php +++ b/htdocs/asset/depreciation_options.php @@ -53,7 +53,7 @@ if ($id > 0 || !empty($ref)) { $upload_dir = $conf->asset->multidir_output[$object->entity] . "/" . $object->id; } -$permissiontoadd = $user->rights->asset->write; // Used by the include of actions_addupdatedelete.inc.php +$permissiontoadd = $user->hasRight('asset', 'write'); // Used by the include of actions_addupdatedelete.inc.php // Security check (enable the most restrictive one) if ($user->socid > 0) accessforbidden(); diff --git a/htdocs/asset/disposal.php b/htdocs/asset/disposal.php index 0f1b71e1929..46c5be78a79 100644 --- a/htdocs/asset/disposal.php +++ b/htdocs/asset/disposal.php @@ -51,8 +51,8 @@ if ($id > 0 || !empty($ref)) { $upload_dir = $conf->asset->multidir_output[$object->entity]."/".$object->id; } -$permissionnote = $user->rights->asset->write; // Used by the include of actions_setnotes.inc.php -$permissiontoadd = $user->rights->asset->write; // Used by the include of actions_addupdatedelete.inc.php +$permissionnote = $user->hasRight('asset', 'write'); // Used by the include of actions_setnotes.inc.php +$permissiontoadd = $user->hasRight('asset', 'write'); // Used by the include of actions_addupdatedelete.inc.php // Security check (enable the most restrictive one) if ($user->socid > 0) accessforbidden(); diff --git a/htdocs/asset/document.php b/htdocs/asset/document.php index ee5f7845aed..3ead3b3ed57 100644 --- a/htdocs/asset/document.php +++ b/htdocs/asset/document.php @@ -142,9 +142,9 @@ if ($object->id) { print dol_get_fiche_end(); $modulepart = 'asset'; - $permissiontoadd = $user->rights->asset->write; + $permissiontoadd = $user->hasRight('asset', 'write'); // $permissiontoadd = 1; - $permtoedit = $user->rights->asset->write; + $permtoedit = $user->hasRight('asset', 'write'); // $permtoedit = 1; $param = '&id=' . $object->id; diff --git a/htdocs/asset/list.php b/htdocs/asset/list.php index 1ddfd2a1c82..ee35a817be3 100644 --- a/htdocs/asset/list.php +++ b/htdocs/asset/list.php @@ -120,9 +120,9 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; $object->fields = dol_sort_array($object->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); -$permissiontoread = $user->rights->asset->read; -$permissiontoadd = $user->rights->asset->write; -$permissiontodelete = $user->rights->asset->delete; +$permissiontoread = $user->hasRight('asset', 'read'); +$permissiontoadd = $user->hasRight('asset', 'write'); +$permissiontodelete = $user->hasRight('asset', 'delete'); // Security check if (!isModEnabled('asset')) { diff --git a/htdocs/asset/model/agenda.php b/htdocs/asset/model/agenda.php index 8758d22879c..51a55e0e144 100644 --- a/htdocs/asset/model/agenda.php +++ b/htdocs/asset/model/agenda.php @@ -48,7 +48,8 @@ if (GETPOST('actioncode', 'array')) { } else { $actioncode = GETPOST("actioncode", "alpha", 3) ? GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : getDolGlobalString('AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT')); } -$search_agenda_label = GETPOST('search_agenda_label'); +//$search_rowid = GETPOST('search_rowid'); +//$search_agenda_label = GETPOST('search_agenda_label'); $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); @@ -127,7 +128,7 @@ $form = new Form($db); if ($object->id > 0) { $title = $langs->trans("Agenda"); //if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/',$conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->name." - ".$title; - $help_url = 'EN:Module_Agenda_En'; + $help_url = 'EN:Module_Agenda_En|DE:Modul_Terminplanung'; llxHeader('', $title, $help_url); if (isModEnabled('notification')) { @@ -207,6 +208,7 @@ if ($object->id > 0) { // // List of all actions // $filters = array(); // $filters['search_agenda_label'] = $search_agenda_label; + // $filters['search_rowid'] = $search_rowid; // // // TODO Replace this with same code than into list.php // show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder, $object->module); diff --git a/htdocs/asset/note.php b/htdocs/asset/note.php index fd404a77447..dd31b723cea 100644 --- a/htdocs/asset/note.php +++ b/htdocs/asset/note.php @@ -51,8 +51,8 @@ if ($id > 0 || !empty($ref)) { $upload_dir = $conf->asset->multidir_output[$object->entity]."/".$object->id; } -$permissionnote = $user->rights->asset->write; // Used by the include of actions_setnotes.inc.php -$permissiontoadd = $user->rights->asset->write; // Used by the include of actions_addupdatedelete.inc.php +$permissionnote = $user->hasRight('asset', 'write'); // Used by the include of actions_setnotes.inc.php +$permissiontoadd = $user->hasRight('asset', 'write'); // Used by the include of actions_addupdatedelete.inc.php // Security check (enable the most restrictive one) if ($user->socid > 0) accessforbidden(); diff --git a/htdocs/bom/bom_agenda.php b/htdocs/bom/bom_agenda.php index c7fcf64fb47..d22f457df85 100644 --- a/htdocs/bom/bom_agenda.php +++ b/htdocs/bom/bom_agenda.php @@ -52,6 +52,7 @@ if (GETPOST('actioncode', 'array')) { $actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : getDolGlobalString('AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT')); } +$search_rowid = GETPOST('search_rowid'); $search_agenda_label = GETPOST('search_agenda_label'); // Load variables for pagination @@ -249,6 +250,7 @@ if ($object->id > 0) { // List of all actions $filters = array(); $filters['search_agenda_label'] = $search_agenda_label; + $filters['search_rowid'] = $search_rowid; // TODO Replace this with same code than into list.php show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder); diff --git a/htdocs/bom/bom_card.php b/htdocs/bom/bom_card.php index 3901e18bac4..33e562a8a20 100644 --- a/htdocs/bom/bom_card.php +++ b/htdocs/bom/bom_card.php @@ -87,10 +87,10 @@ $isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0); $result = restrictedArea($user, 'bom', $object->id, 'bom_bom', '', '', 'rowid', $isdraft); // Permissions -$permissionnote = $user->rights->bom->write; // Used by the include of actions_setnotes.inc.php -$permissiondellink = $user->rights->bom->write; // Used by the include of actions_dellink.inc.php -$permissiontoadd = $user->rights->bom->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php -$permissiontodelete = $user->rights->bom->delete || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT); +$permissionnote = $user->hasRight('bom', 'write'); // Used by the include of actions_setnotes.inc.php +$permissiondellink = $user->hasRight('bom', 'write'); // Used by the include of actions_dellink.inc.php +$permissiontoadd = $user->hasRight('bom', 'write'); // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php +$permissiontodelete = $user->hasRight('bom', 'delete') || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT); $upload_dir = $conf->bom->multidir_output[isset($object->entity) ? $object->entity : 1]; @@ -768,8 +768,8 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $relativepath = $objref.'/'.$objref.'.pdf'; $filedir = $conf->bom->dir_output.'/'.$objref; $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; - $genallowed = $user->rights->bom->read; // If you can read, you can build the PDF to read content - $delallowed = $user->rights->bom->write; // If you can create/edit, you can remove a file on card + $genallowed = $user->hasRight('bom', 'read'); // If you can read, you can build the PDF to read content + $delallowed = $user->hasRight('bom', 'write'); // If you can create/edit, you can remove a file on card print $formfile->showdocuments('bom', $objref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', '', '', $langs->defaultlang); // Show links to link elements diff --git a/htdocs/bom/bom_document.php b/htdocs/bom/bom_document.php index 29aca029d36..03b9f416d43 100644 --- a/htdocs/bom/bom_document.php +++ b/htdocs/bom/bom_document.php @@ -85,7 +85,7 @@ if ($id > 0 || !empty($ref)) { $isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0); restrictedArea($user, 'bom', $object->id, 'bom_bom', '', '', 'rowid', $isdraft); -$permissiontoadd = $user->rights->bom->write; // Used by the include of actions_addupdatedelete.inc.php and actions_linkedfiles.inc.php +$permissiontoadd = $user->hasRight('bom', 'write'); // Used by the include of actions_addupdatedelete.inc.php and actions_linkedfiles.inc.php /* @@ -148,8 +148,8 @@ if ($object->id) { print dol_get_fiche_end(); $modulepart = 'bom'; - $permissiontoadd = $user->rights->bom->write; - $permtoedit = $user->rights->bom->write; + $permissiontoadd = $user->hasRight('bom', 'write'); + $permtoedit = $user->hasRight('bom', 'write'); $param = '&id='.$object->id; //$relativepathwithnofile='bom/' . dol_sanitizeFileName($object->id).'/'; diff --git a/htdocs/bom/bom_list.php b/htdocs/bom/bom_list.php index c5e5491dff8..730ad651d0c 100644 --- a/htdocs/bom/bom_list.php +++ b/htdocs/bom/bom_list.php @@ -121,9 +121,9 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; $object->fields = dol_sort_array($object->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); -$permissiontoread = $user->rights->bom->read; -$permissiontoadd = $user->rights->bom->write; -$permissiontodelete = $user->rights->bom->delete; +$permissiontoread = $user->hasRight('bom', 'read'); +$permissiontoadd = $user->hasRight('bom', 'write'); +$permissiontodelete = $user->hasRight('bom', 'delete'); // Security check if ($user->socid > 0) { @@ -175,8 +175,8 @@ if (empty($reshook)) { // Mass actions $objectclass = 'BOM'; $objectlabel = 'BillOfMaterials'; - $permissiontoread = $user->rights->bom->read; - $permissiontodelete = $user->rights->bom->delete; + $permissiontoread = $user->hasRight('bom', 'read'); + $permissiontodelete = $user->hasRight('bom', 'delete'); $uploaddir = $conf->bom->dir_output; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; @@ -685,7 +685,7 @@ while ($i < $imaxinloop) { if ($mode == 'kanban') { if ($i == 0) { print '
'; - print '
'; + print '
'; } // Output kanban print $object->getKanbanView(''); diff --git a/htdocs/bom/bom_net_needs.php b/htdocs/bom/bom_net_needs.php index f6644590a2e..56683e82338 100644 --- a/htdocs/bom/bom_net_needs.php +++ b/htdocs/bom/bom_net_needs.php @@ -84,10 +84,10 @@ $isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0); $result = restrictedArea($user, 'bom', $object->id, 'bom_bom', '', '', 'rowid', $isdraft); // Permissions -$permissionnote = $user->rights->bom->write; // Used by the include of actions_setnotes.inc.php -$permissiondellink = $user->rights->bom->write; // Used by the include of actions_dellink.inc.php -$permissiontoadd = $user->rights->bom->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php -$permissiontodelete = $user->rights->bom->delete || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT); +$permissionnote = $user->hasRight('bom', 'write'); // Used by the include of actions_setnotes.inc.php +$permissiondellink = $user->hasRight('bom', 'write'); // Used by the include of actions_dellink.inc.php +$permissiontoadd = $user->hasRight('bom', 'write'); // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php +$permissiontodelete = $user->hasRight('bom', 'delete') || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT); $upload_dir = $conf->bom->multidir_output[isset($object->entity) ? $object->entity : 1]; @@ -214,6 +214,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''.img_picto('', 'folder', 'class="paddingright"').$langs->trans("UndoExpandAll").' '; } print '
'.$langs->trans('ProducedBy').''.$langs->trans('Quantity').''.$form->textwithpicto($langs->trans("PhysicalStock"), $text_stock_options, 1).''.$form->textwithpicto($langs->trans("VirtualStock"), $langs->trans("VirtualStockDesc")).'
'.str_repeat($repeatChar, $TProduct['level']).$TProduct['bom']->getNomUrl(1); + if ($action == 'treeview') print ''.str_repeat($repeatChar, $TProduct['level']).$prod->getNomUrl(1); + else print ''.str_repeat($repeatChar, $TProduct['level']).$TProduct['bom']->getNomUrl(1); print ' '; print img_picto('', 'folder-open'); print ''; print ''.$TProduct['bom']->getNomUrl(1).''.$TProduct['qty'].'
'.str_repeat($repeatChar, $TInfos['level']).$prod->getNomUrl(1).''.$TInfos['qty'].''.price2num($prod->stock_reel, 'MS').''.$prod->stock_theorique.'
'; print ''; if (($origin == 'propal') || ($origin == 'commande')) { @@ -3404,7 +3404,7 @@ if ($action == 'create') { print '
'; $tmp = ' '; $tmp = $tmp.''; - $desc = $form->textwithpicto($tmp, $langs->transnoentities("InvoiceFirstSituationDesc"), 1, 'help', '', 0, 3); + $desc = $form->textwithpicto($tmp, $langs->transnoentities("InvoiceFirstSituationDesc"), 1, 'help', '', 0, 3, 'firstsituationonsmartphone'); print $desc; print '
'; @@ -3417,7 +3417,7 @@ if ($action == 'create') { $tmp .= ' disabled'; } $tmp .= '> '; - $text = ' '; + $text = $tmp.' '; $text .= 'id > 0) { $text .= ' disabled'; @@ -3486,26 +3486,18 @@ if ($action == 'create') { if (!empty($conf->global->INVOICE_USE_SITUATION)) { print '
'; $tmp = ' '; - $text = ' '; + $text = $tmp.' '; $text .= '('.$langs->trans("YouMustCreateInvoiceFromThird").') '; - $desc = $form->textwithpicto($text, $langs->transnoentities("InvoiceFirstSituationDesc"), 1, 'help', '', 0, 3); - print $desc; - print '
'; - - print '
'; - $tmp = ' '; - $text = ' '; - $text .= '('.$langs->trans("YouMustCreateInvoiceFromThird").') '; - $desc = $form->textwithpicto($text, $langs->transnoentities("InvoiceFirstSituationDesc"), 1, 'help', '', 0, 3); + $desc = $form->textwithpicto($text, $langs->transnoentities("InvoiceFirstSituationDesc"), 1, 'help', '', 0, 3, 'firstsituationonsmartphone'); print $desc; print '
'; } print '
'; $tmp = ' '; - $text = ' '; - $text .= '('.$langs->trans("YouMustCreateInvoiceFromThird").') '; - $desc = $form->textwithpicto($text, $langs->transnoentities("InvoiceReplacementDesc"), 1, 'help', '', 0, 3); + $text = $tmp.' '; + //$text .= '('.$langs->trans("YouMustCreateInvoiceFromThird").') '; + $desc = $form->textwithpicto($text, $langs->transnoentities("InvoiceReplacementDesc").'

'.$langs->trans("YouMustCreateInvoiceFromThird"), 1, 'help', '', 0, 3, 'replacementonsmartphone'); print $desc; print '
'; } @@ -3565,7 +3557,6 @@ if ($action == 'create') { }); '; $text = ' '; - // $text.=''; $text .= ' 0 ? 'checked' : '').' /> "; print '
    0 ? 'checked' : '').' /> "; print ''; @@ -3595,9 +3586,9 @@ if ($action == 'create') { } else { $tmp = ' '; } - $text = ' '; - $text .= '('.$langs->trans("YouMustCreateInvoiceFromThird").') '; - $desc = $form->textwithpicto($text, $langs->transnoentities("InvoiceAvoirDesc"), 1, 'help', '', 0, 3); + $text = $tmp.' '; + //$text .= '('.$langs->trans("YouMustCreateInvoiceFromThird").') '; + $desc = $form->textwithpicto($text, $langs->transnoentities("InvoiceAvoirDesc").'

'.$langs->trans("YouMustCreateInvoiceFromThird"), 1, 'help', '', 0, 3, 'creditnoteonsmartphone'); print $desc; print ''."\n"; } @@ -3606,9 +3597,8 @@ if ($action == 'create') { // Template invoice print '
'; $tmp = ' '; - $text = ' '; - //$text.= '('.$langs->trans("YouMustCreateStandardInvoiceFirst").') '; - $desc = $form->textwithpicto($text, $langs->transnoentities("YouMustCreateStandardInvoiceFirstDesc"), 1, 'help', '', 0, 3); + $text = $tmp.' '; + $desc = $form->textwithpicto($text, $langs->transnoentities("YouMustCreateStandardInvoiceFirstDesc"), 1, 'help', '', 0, 3, 'templateonsmartphone'); print $desc; print '
'; @@ -3629,7 +3619,8 @@ if ($action == 'create') { $(document).ready(function() { var listType = {'.$jsListType.'}; $("[name=\'type\'").change(function() { - if($( this ).prop("checked")) + console.log("change name=type"); + if ($( this ).prop("checked")) { if(($( this ).val() in listType)) { @@ -4682,7 +4673,7 @@ if ($action == 'create') { print '
'; + $tmp = $tmp.''; + $desc = $form->textwithpicto($tmp, $langs->transnoentities("InvoiceDepositDesc"), 1, 'help', '', 0, 3, 'depositonsmartphone'); print $desc; print '
'; - if ($action != 'editretainedwarranty' && $user->rights->facture->creer && $object->statut == Facture::STATUS_DRAFT) { + if ($action != 'editretainedwarranty' && $user->hasRight('facture', 'creer') && $object->statut == Facture::STATUS_DRAFT) { print ''; } @@ -4705,7 +4696,7 @@ if ($action == 'create') { print '
'; print $langs->trans('RetainedWarranty'); print 'id.'">'.img_edit($langs->trans('setretainedwarranty'), 1).'
'; - if ($action != 'editretainedwarrantypaymentterms' && $user->rights->facture->creer && $object->statut == Facture::STATUS_DRAFT) { + if ($action != 'editretainedwarrantypaymentterms' && $user->hasRight('facture', 'creer') && $object->statut == Facture::STATUS_DRAFT) { print ''; } @@ -4740,7 +4731,7 @@ if ($action == 'create') { print '
'; print $langs->trans('PaymentConditionsShortRetainedWarranty'); print 'id.'">'.img_edit($langs->trans('setPaymentConditionsShortRetainedWarranty'), 1).'
'; - if ($action != 'editretainedwarrantydatelimit' && $user->rights->facture->creer && $object->statut == Facture::STATUS_DRAFT) { + if ($action != 'editretainedwarrantydatelimit' && $user->hasRight('facture', 'creer') && $object->statut == Facture::STATUS_DRAFT) { print ''; } diff --git a/htdocs/compta/facture/contact.php b/htdocs/compta/facture/contact.php index 2548284f97f..38d51f7b8b8 100644 --- a/htdocs/compta/facture/contact.php +++ b/htdocs/compta/facture/contact.php @@ -65,7 +65,7 @@ $usercancreate = $user->hasRight("facture", "creer"); * Add a new contact */ -if ($action == 'addcontact' && $user->rights->facture->creer) { +if ($action == 'addcontact' && $user->hasRight('facture', 'creer')) { if ($result > 0 && $id > 0) { $contactid = (GETPOST('userid') ? GETPOST('userid', 'int') : GETPOST('contactid', 'int')); $typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type')); @@ -83,10 +83,10 @@ if ($action == 'addcontact' && $user->rights->facture->creer) { setEventMessages($object->error, $object->errors, 'errors'); } } -} elseif ($action == 'swapstatut' && $user->rights->facture->creer) { +} elseif ($action == 'swapstatut' && $user->hasRight('facture', 'creer')) { // Toggle the status of a contact $result = $object->swapContactStatus(GETPOST('ligne', 'int')); -} elseif ($action == 'deletecontact' && $user->rights->facture->creer) { +} elseif ($action == 'deletecontact' && $user->hasRight('facture', 'creer')) { // Deletes a contact $result = $object->delete_contact($lineid); diff --git a/htdocs/compta/facture/document.php b/htdocs/compta/facture/document.php index 526bbe02068..af633e14f90 100644 --- a/htdocs/compta/facture/document.php +++ b/htdocs/compta/facture/document.php @@ -73,7 +73,7 @@ if ($object->fetch($id, $ref)) { $upload_dir = $conf->facture->dir_output."/".dol_sanitizeFileName($object->ref); } -$permissiontoadd = $user->rights->facture->creer; +$permissiontoadd = $user->hasRight('facture', 'creer'); // Security check if ($user->socid) { @@ -184,8 +184,8 @@ if ($id > 0 || !empty($ref)) { print dol_get_fiche_end(); $modulepart = 'facture'; - $permissiontoadd = $user->rights->facture->creer; - $permtoedit = $user->rights->facture->creer; + $permissiontoadd = $user->hasRight('facture', 'creer'); + $permtoedit = $user->hasRight('facture', 'creer'); $param = '&id='.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; } else { diff --git a/htdocs/compta/facture/invoicetemplate_list.php b/htdocs/compta/facture/invoicetemplate_list.php index f0d6001d892..addac069636 100644 --- a/htdocs/compta/facture/invoicetemplate_list.php +++ b/htdocs/compta/facture/invoicetemplate_list.php @@ -180,9 +180,9 @@ if ($socid > 0) { $objecttype = 'facture_rec'; -$permissionnote = $user->rights->facture->creer; // Used by the include of actions_setnotes.inc.php -$permissiondellink = $user->rights->facture->creer; // Used by the include of actions_dellink.inc.php -$permissiontoedit = $user->rights->facture->creer; // Used by the include of actions_lineupdonw.inc.php +$permissionnote = $user->hasRight('facture', 'creer'); // Used by the include of actions_setnotes.inc.php +$permissiondellink = $user->hasRight('facture', 'creer'); // Used by the include of actions_dellink.inc.php +$permissiontoedit = $user->hasRight('facture', 'creer'); // Used by the include of actions_lineupdonw.inc.php $result = restrictedArea($user, 'facture', $object->id, $objecttype); diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index fd60a6a84a4..23c7d87f87a 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -200,6 +200,7 @@ $fieldstosearchall = array( 'f.ref_client'=>'RefCustomer', 'f.note_public'=>'NotePublic', 's.nom'=>"ThirdParty", + 's.code_client'=>"CustomerCodeShort", 's.name_alias'=>"AliasNameShort", 's.zip'=>"Zip", 's.town'=>"Town", @@ -222,6 +223,7 @@ $arrayfields = array( 'p.title'=>array('label'=>"ProjectLabel", 'checked'=>0, 'enabled'=>(!isModEnabled('project') ? 0 : 1), 'position'=>41), 's.nom'=>array('label'=>"ThirdParty", 'checked'=>1, 'position'=>50), 's.name_alias'=>array('label'=>"AliasNameShort", 'checked'=>1, 'position'=>51), + 's.code_client'=>array('label'=>"CustomerCodeShort", 'checked'=>-1, 'position'=>52), 's2.nom'=>array('label'=>'ParentCompany', 'position'=>32, 'checked'=>0), 's.town'=>array('label'=>"Town", 'checked'=>-1, 'position'=>55), 's.zip'=>array('label'=>"Zip", 'checked'=>1, 'position'=>60), @@ -574,7 +576,7 @@ $sql .= ' f.datef, f.date_valid, f.date_lim_reglement as datelimite, f.module_so $sql .= ' f.paye as paye, f.fk_statut, f.close_code,'; $sql .= ' f.datec as date_creation, f.tms as date_update, f.date_closing as date_closing,'; $sql .= ' f.retained_warranty, f.retained_warranty_date_limit, f.situation_final, f.situation_cycle_ref, f.situation_counter,'; -$sql .= ' s.rowid as socid, s.nom as name, s.name_alias as alias, s.email, s.phone, s.fax, s.address, s.town, s.zip, s.fk_pays, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta as code_compta_client, s.code_compta_fournisseur,'; +$sql .= ' s.rowid as socid, s.nom as name, s.name_alias as alias, s.code_client as code_client, s.email, s.phone, s.fax, s.address, s.town, s.zip, s.fk_pays, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta as code_compta_client, s.code_compta_fournisseur,'; $sql .= " s.parent as fk_parent,"; $sql .= " s2.nom as name2,"; $sql .= ' typent.code as typent_code,'; @@ -687,6 +689,9 @@ if (empty($arrayfields['s.name_alias']['checked']) && $search_company) { if ($search_parent_name) { $sql .= natural_search('s2.nom', $search_parent_name); } +if ($search_company_code_client) { + $sql .= natural_search('s.code_client', $search_company_code_client); +} if ($search_town) { $sql .= natural_search('s.town', $search_town); } @@ -1382,19 +1387,19 @@ if ($resql) { } // Project ref if (!empty($arrayfields['p.ref']['checked'])) { - print ''; + print ''; } // Project label if (!empty($arrayfields['p.title']['checked'])) { - print ''; + print ''; } // Thirdparty if (!empty($arrayfields['s.nom']['checked'])) { - print ''; + print ''; } // Alias if (!empty($arrayfields['s.name_alias']['checked'])) { - print ''; + print ''; } // Parent company if (!empty($arrayfields['s2.nom']['checked'])) { @@ -1402,6 +1407,10 @@ if ($resql) { print ''; print ''; } + // Customer Code + if (!empty($arrayfields['s.code_client']['checked'])) { + print ''; + } // Town if (!empty($arrayfields['s.town']['checked'])) { print ''; @@ -1467,13 +1476,13 @@ if ($resql) { if (!empty($arrayfields['f.total_localtax1']['checked'])) { // Localtax1 print ''; } if (!empty($arrayfields['f.total_localtax2']['checked'])) { // Localtax2 print ''; } if (!empty($arrayfields['f.total_ttc']['checked'])) { @@ -1654,6 +1663,9 @@ if ($resql) { if (!empty($arrayfields['s2.nom']['checked'])) { print_liste_field_titre($arrayfields['s2.nom']['label'], $_SERVER['PHP_SELF'], 's2.nom', '', $param, '', $sortfield, $sortorder); } + if (!empty($arrayfields['s.code_client']['checked'])) { + print_liste_field_titre($arrayfields['s.code_client']['label'], $_SERVER['PHP_SELF'], 's.code_client', '', $param, '', $sortfield, $sortorder); + } if (!empty($arrayfields['s.town']['checked'])) { print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], 's.town', '', $param, '', $sortfield, $sortorder); } @@ -1850,6 +1862,7 @@ if ($resql) { $companystatic->id = $obj->socid; $companystatic->name = $obj->name; $companystatic->name_alias = $obj->alias; + $companystatic->code_client = $obj->code_client; $companystatic->client = $obj->client; $companystatic->fournisseur = $obj->fournisseur; $companystatic->code_client = $obj->code_client; @@ -1908,7 +1921,7 @@ if ($resql) { if ($mode == 'kanban') { if ($i == 0) { print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } // Town if (!empty($arrayfields['s.town']['checked'])) { print '
'; print $langs->trans('RetainedWarrantyDateLimit'); print 'id.'">'.img_edit($langs->trans('setretainedwarrantyDateLimit'), 1).' 0 ? " disabled" : "").'> 0 ? " disabled" : "").'>'; - print ''; + print ''; print ''; - print ''; + print ''; print '
'; - print '
'; + print '
'; } // Output Kanban $facturestatic->socid = $companystatic->getNomUrl(1, 'company', 15); @@ -2095,6 +2108,15 @@ if ($resql) { $totalarray['nbfield']++; } } + // Customer Code + if (!empty($arrayfields['s.code_client']['checked'])) { + print '
'; + print dol_escape_htmltag($companystatic->code_client); + print ''; diff --git a/htdocs/compta/facture/note.php b/htdocs/compta/facture/note.php index 40f8b969fac..459d32cde87 100644 --- a/htdocs/compta/facture/note.php +++ b/htdocs/compta/facture/note.php @@ -48,7 +48,7 @@ if ($id > 0 || !empty($ref)) { $object->fetch($id, $ref, '', '', (!empty($conf->global->INVOICE_USE_SITUATION) ? $conf->global->INVOICE_USE_SITUATION : 0)); } -$permissionnote = $user->rights->facture->creer; // Used by the include of actions_setnotes.inc.php +$permissionnote = $user->hasRight('facture', 'creer'); // Used by the include of actions_setnotes.inc.php // Security check $socid = 0; diff --git a/htdocs/compta/facture/prelevement.php b/htdocs/compta/facture/prelevement.php index 790dc9e26ca..8a9d4e6c198 100644 --- a/htdocs/compta/facture/prelevement.php +++ b/htdocs/compta/facture/prelevement.php @@ -87,7 +87,7 @@ if ($type == 'bank-transfer') { if ($type == 'bank-transfer') { $usercancreate = ($user->rights->fournisseur->facture->creer || $user->rights->supplier_invoice->creer); } else { - $usercancreate = $user->rights->facture->creer; + $usercancreate = $user->hasRight('facture', 'creer'); } @@ -483,7 +483,7 @@ if ($object->id > 0) { print ''; - if ($object->type != $object::TYPE_CREDIT_NOTE && $action != 'editinvoicedate' && !empty($object->brouillon) && $user->rights->facture->creer) { + if ($object->type != $object::TYPE_CREDIT_NOTE && $action != 'editinvoicedate' && !empty($object->brouillon) && $user->hasRight('facture', 'creer')) { print ''; } print '
'; print $langs->trans('DateInvoice'); print 'id.'&type='.urlencode($type).'">'.img_edit($langs->trans('SetDate'), 1).'
'; @@ -506,7 +506,7 @@ if ($object->id > 0) { print ''; - if ($object->type != $object::TYPE_CREDIT_NOTE && $action != 'editconditions' && !empty($object->brouillon) && $user->rights->facture->creer) { + if ($object->type != $object::TYPE_CREDIT_NOTE && $action != 'editconditions' && !empty($object->brouillon) && $user->hasRight('facture', 'creer')) { print ''; } print '
'; print $langs->trans('PaymentConditionsShort'); print 'id.'&type='.urlencode($type).'">'.img_edit($langs->trans('SetConditions'), 1).'
'; @@ -527,7 +527,7 @@ if ($object->id > 0) { print ''; - if ($object->type != $object::TYPE_CREDIT_NOTE && $action != 'editpaymentterm' && !empty($object->brouillon) && $user->rights->facture->creer) { + if ($object->type != $object::TYPE_CREDIT_NOTE && $action != 'editpaymentterm' && !empty($object->brouillon) && $user->hasRight('facture', 'creer')) { print ''; } print '
'; print $langs->trans('DateMaxPayment'); print 'id.'&type='.urlencode($type).'">'.img_edit($langs->trans('SetDate'), 1).'
'; @@ -556,7 +556,7 @@ if ($object->id > 0) { print ''; - if ($action != 'editmode' && !empty($object->brouillon) && $user->rights->facture->creer) { + if ($action != 'editmode' && !empty($object->brouillon) && $user->hasRight('facture', 'creer')) { print ''; } print '
'; print $langs->trans('PaymentMode'); print 'id.'&type='.urlencode($type).'">'.img_edit($langs->trans('SetMode'), 1).'
'; @@ -577,7 +577,7 @@ if ($object->id > 0) { print ''; } print '
'; print $langs->trans('BankAccount'); print ''; - if (($action != 'editbankaccount') && $user->rights->commande->creer && !empty($object->brouillon)) { + if (($action != 'editbankaccount') && $user->hasRight('commande', 'creer') && !empty($object->brouillon)) { print 'id.'&type='.urlencode($type).'">'.img_edit($langs->trans('SetBankAccount'), 1).'
'; @@ -662,7 +662,7 @@ if ($object->id > 0) { print ''; - if ($action != 'editrevenuestamp' && !empty($object->brouillon) && $user->rights->facture->creer) { + if ($action != 'editrevenuestamp' && !empty($object->brouillon) && $user->hasRight('facture', 'creer')) { print ''; } print '
'; print $langs->trans('RevenueStamp'); print 'id.'">'.img_edit($langs->trans('SetRevenuStamp'), 1).'
'; diff --git a/htdocs/compta/facture/stats/index.php b/htdocs/compta/facture/stats/index.php index e1f68a5f79a..5c23057b10b 100644 --- a/htdocs/compta/facture/stats/index.php +++ b/htdocs/compta/facture/stats/index.php @@ -421,7 +421,7 @@ print '
'; print ''; -print '
'; +print '
'; print dol_get_fiche_end(); diff --git a/htdocs/compta/localtax/list.php b/htdocs/compta/localtax/list.php index 42f4d326811..23fd1186e0e 100644 --- a/htdocs/compta/localtax/list.php +++ b/htdocs/compta/localtax/list.php @@ -96,7 +96,7 @@ if ($result) { if ($mode == 'kanban') { if ($i == 0) { print '
'; - print '
'; + print '
'; } // Output Kanban print $localtax_static->getKanbanView(''); diff --git a/htdocs/compta/paiement/card.php b/htdocs/compta/paiement/card.php index b0228e573ec..39dac0352e6 100644 --- a/htdocs/compta/paiement/card.php +++ b/htdocs/compta/paiement/card.php @@ -244,7 +244,7 @@ $thirdpartystatic = new Societe($db); $result = $object->fetch($id, $ref); if ($result <= 0) { - dol_print_error($db, 'Payement '.$id.' not found in database'); + dol_print_error($db, 'Payment '.$id.' not found in database'); exit; } diff --git a/htdocs/compta/paiement/cheque/class/remisecheque.class.php b/htdocs/compta/paiement/cheque/class/remisecheque.class.php index 6666f0fe1c4..53751cce194 100644 --- a/htdocs/compta/paiement/cheque/class/remisecheque.class.php +++ b/htdocs/compta/paiement/cheque/class/remisecheque.class.php @@ -261,7 +261,7 @@ class RemiseCheque extends CommonObject $this->errno = $this->db->lasterrno(); } - if (!$this->errno && !empty($conf->global->MAIN_DISABLEDRAFTSTATUS)) { + if (!$this->errno && (getDolGlobalString('MAIN_DISABLEDRAFTSTATUS') || getDolGlobalString('MAIN_DISABLEDRAFTSTATUS_CHEQUE'))) { $res = $this->validate($user); //if ($res < 0) $error++; } diff --git a/htdocs/compta/paiement/cheque/list.php b/htdocs/compta/paiement/cheque/list.php index 38db4fca14b..794db8df39b 100644 --- a/htdocs/compta/paiement/cheque/list.php +++ b/htdocs/compta/paiement/cheque/list.php @@ -243,7 +243,7 @@ if ($resql) { if ($mode == 'kanban') { if ($i == 0) { print '
'; - print '
'; + print '
'; } // Output Kanban print $checkdepositstatic->getKanbanView(''); diff --git a/htdocs/compta/paiement/class/cpaiement.class.php b/htdocs/compta/paiement/class/cpaiement.class.php index 1c7abf71c3b..77f15d6bde0 100644 --- a/htdocs/compta/paiement/class/cpaiement.class.php +++ b/htdocs/compta/paiement/class/cpaiement.class.php @@ -3,6 +3,7 @@ * Copyright (C) 2014 Juanjo Menent * Copyright (C) 2015 Florian Henry * Copyright (C) 2015 Raphaël Doursenaud + * Copyright (C) 2023 Frédéric France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -30,6 +31,11 @@ */ class Cpaiement { + /** + * @var DoliDB Database handler. + */ + public $db; + /** * @var string Id to identify managed objects */ diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index b9d1fd7c54a..266ddd3b79f 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -1700,9 +1700,7 @@ class BonPrelevement extends CommonObject } fclose($this->file); - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($this->filename, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($this->filename); return $result; } diff --git a/htdocs/compta/prelevement/list.php b/htdocs/compta/prelevement/list.php index 8d9489bbec7..ad8570d9268 100644 --- a/htdocs/compta/prelevement/list.php +++ b/htdocs/compta/prelevement/list.php @@ -282,7 +282,7 @@ if ($result) { if ($mode == 'kanban') { if ($i == 0) { print '
'; - print '
'; + print '
'; } // Output Kanban diff --git a/htdocs/compta/prelevement/orders_list.php b/htdocs/compta/prelevement/orders_list.php index bead580ab31..c2e8c5e4194 100644 --- a/htdocs/compta/prelevement/orders_list.php +++ b/htdocs/compta/prelevement/orders_list.php @@ -236,7 +236,7 @@ if ($result) { if ($mode == 'kanban') { if ($i == 0) { print '
'; - print '
'; + print '
'; } // Output Kanban diff --git a/htdocs/compta/recap-compta.php b/htdocs/compta/recap-compta.php index b8986a449ce..0808e5a7aab 100644 --- a/htdocs/compta/recap-compta.php +++ b/htdocs/compta/recap-compta.php @@ -117,7 +117,7 @@ if ($id > 0) { dol_banner_tab($object, 'socid', '', ($user->socid ? 0 : 1), 'rowid', 'nom', '', '', 0, '', '', 1); print dol_get_fiche_end(); - if (isModEnabled('facture') && $user->rights->facture->lire) { + if (isModEnabled('facture') && $user->hasRight('facture', 'lire')) { // Invoice list print load_fiche_titre($langs->trans("CustomerPreview")); diff --git a/htdocs/compta/resultat/index.php b/htdocs/compta/resultat/index.php index 4012994be58..73a4e7d902a 100644 --- a/htdocs/compta/resultat/index.php +++ b/htdocs/compta/resultat/index.php @@ -868,7 +868,7 @@ if (!empty($conf->global->ACCOUNTING_REPORTS_INCLUDE_VARPAY) && isModEnabled("ba //} /* - * Payement Loan + * Payment Loan */ if (!empty($conf->global->ACCOUNTING_REPORTS_INCLUDE_LOAN) && isModEnabled('loan') && ($modecompta == 'CREANCES-DETTES' || $modecompta == "RECETTES-DEPENSES")) { diff --git a/htdocs/compta/resultat/result.php b/htdocs/compta/resultat/result.php index e49f06034aa..0996b893a5f 100644 --- a/htdocs/compta/resultat/result.php +++ b/htdocs/compta/resultat/result.php @@ -349,6 +349,9 @@ if ($modecompta == 'CREANCES-DETTES') { //var_dump($result); //$r = $AccCat->calculate($result); $r = dol_eval($result, 1, 1, '1'); + if (is_nan($r)) { + $r = 0; + } print '
'.price($r).''.price($r).''.price($r).''.price($r).'
'; - print '
'; + print '
'; } // Output Kanban diff --git a/htdocs/compta/tva/list.php b/htdocs/compta/tva/list.php index 0497c05d204..80f73c6fe44 100644 --- a/htdocs/compta/tva/list.php +++ b/htdocs/compta/tva/list.php @@ -489,7 +489,7 @@ while ($i < min($num, $limit)) { if ($mode == 'kanban') { if ($i == 0) { print '
'; - print '
'; + print '
'; } // Output Kanban diff --git a/htdocs/contact/agenda.php b/htdocs/contact/agenda.php index d0d2211c21c..f1be48a063b 100644 --- a/htdocs/contact/agenda.php +++ b/htdocs/contact/agenda.php @@ -83,6 +83,7 @@ if (GETPOST('actioncode', 'array')) { } else { $actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : getDolGlobalString('AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT')); } +$search_rowid = GETPOST('search_rowid'); $search_agenda_label = GETPOST('search_agenda_label'); // Security check @@ -288,6 +289,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { // List of all actions $filters = array(); $filters['search_agenda_label'] = $search_agenda_label; + $filters['search_rowid'] = $search_rowid; show_actions_done($conf, $langs, $db, $objthirdparty, $object, 0, $actioncode, '', $filters, $sortfield, $sortorder); } diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php index cd94f4ebbac..d241bb02e9e 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -96,7 +96,7 @@ if (!($object->id > 0) && $action == 'view') { } $triggermodname = 'CONTACT_MODIFY'; -$permissiontoadd = $user->rights->societe->contact->creer; +$permissiontoadd = $user->hasRight('societe', 'contact', 'creer'); // Security check if ($user->socid) { @@ -1500,7 +1500,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print "
"; print '
'; - print '
'; + print '
'; print dol_get_fiche_end(); diff --git a/htdocs/contact/consumption.php b/htdocs/contact/consumption.php index bbd5bf005d2..7d9a95bad56 100644 --- a/htdocs/contact/consumption.php +++ b/htdocs/contact/consumption.php @@ -156,21 +156,21 @@ print ''; if ($object->thirdparty->client) { $thirdTypeArray['customer'] = $langs->trans("customer"); - if (isModEnabled("propal") && $user->rights->propal->lire) { + if (isModEnabled("propal") && $user->hasRight('propal', 'lire')) { $elementTypeArray['propal'] = $langs->transnoentitiesnoconv('Proposals'); } - if (isModEnabled('commande') && $user->rights->commande->lire) { + if (isModEnabled('commande') && $user->hasRight('commande', 'lire')) { $elementTypeArray['order'] = $langs->transnoentitiesnoconv('Orders'); } - if (isModEnabled('facture') && $user->rights->facture->lire) { + if (isModEnabled('facture') && $user->hasRight('facture', 'lire')) { $elementTypeArray['invoice'] = $langs->transnoentitiesnoconv('Invoices'); } - if (isModEnabled('contrat') && $user->rights->contrat->lire) { + if (isModEnabled('contrat') && $user->hasRight('contrat', 'lire')) { $elementTypeArray['contract'] = $langs->transnoentitiesnoconv('Contracts'); } } -if (isModEnabled('ficheinter') && $user->rights->ficheinter->lire) { +if (isModEnabled('ficheinter') && $user->hasRight('ficheinter', 'lire')) { $elementTypeArray['fichinter'] = $langs->transnoentitiesnoconv('Interventions'); } diff --git a/htdocs/contact/document.php b/htdocs/contact/document.php index f62e82ee5a1..ed8bc2d4d93 100644 --- a/htdocs/contact/document.php +++ b/htdocs/contact/document.php @@ -94,7 +94,7 @@ if ($user->socid) { } $result = restrictedArea($user, 'contact', $id, 'socpeople&societe', '', '', 'rowid', 0); // If we create a contact with no company (shared contacts), no check on write permission -$permissiontoadd = $user->rights->societe->contact->creer; // Used by the include of actions_dellink.inc.php +$permissiontoadd = $user->hasRight('societe', 'contact', 'creer'); // Used by the include of actions_dellink.inc.php /* @@ -192,8 +192,8 @@ if ($object->id) { print dol_get_fiche_end(); $modulepart = 'contact'; - $permissiontoadd = $user->rights->societe->contact->creer; - $permtoedit = $user->rights->societe->contact->creer; + $permissiontoadd = $user->hasRight('societe', 'contact', 'creer'); + $permtoedit = $user->hasRight('societe', 'contact', 'creer'); $param = '&id='.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; } else { diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index e6dd6baa1db..71154e23b28 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -319,7 +319,7 @@ if (empty($reshook)) { $objectlabel = 'Contact'; $permissiontoread = $user->hasRight('societe', 'lire'); $permissiontodelete = $user->hasRight('societe', 'supprimer'); - $permissiontoadd = $user->rights->societe->creer; + $permissiontoadd = $user->hasRight('societe', 'creer'); $uploaddir = $conf->societe->dir_output; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; @@ -1234,7 +1234,7 @@ while ($i < min($num, $limit)) { if ($mode == 'kanban') { if ($i == 0) { print ''; - print '
'; + print '
'; } $contactstatic->photo = $obj->photo; if ($obj->socid > 0) { diff --git a/htdocs/contact/note.php b/htdocs/contact/note.php index bf75a3350a7..148d9fb6f04 100644 --- a/htdocs/contact/note.php +++ b/htdocs/contact/note.php @@ -51,7 +51,7 @@ if ($user->socid > 0) { $result = restrictedArea($user, 'contact', $id, 'socpeople&societe'); -$permissionnote = $user->rights->societe->creer; // Used by the include of actions_setnotes.inc.php +$permissionnote = $user->hasRight('societe', 'creer'); // Used by the include of actions_setnotes.inc.php // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context // $hookmanager->initHooks(array('contactcard')); -> Name conflict with product/card.php diff --git a/htdocs/contrat/agenda.php b/htdocs/contrat/agenda.php index e631c6a4a60..c6c9acf7239 100644 --- a/htdocs/contrat/agenda.php +++ b/htdocs/contrat/agenda.php @@ -43,6 +43,8 @@ if (GETPOST('actioncode', 'array')) { } else { $actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : getDolGlobalString('AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT')); } + +$search_rowid = GETPOST('search_rowid'); $search_agenda_label = GETPOST('search_agenda_label'); $action = GETPOST('action', 'alpha'); @@ -265,6 +267,7 @@ if ($object->id > 0) { // List of all actions $filters = array(); $filters['search_agenda_label'] = $search_agenda_label; + $filters['search_rowid'] = $search_rowid; // TODO Replace this with same code than into list.php show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder); diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index 54779bb692d..10fe45ced69 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -214,7 +214,7 @@ if (empty($reshook)) { } // Add contract - if ($action == 'add' && $user->rights->contrat->creer) { + if ($action == 'add' && $user->hasRight('contrat', 'creer')) { // Check if (empty($datecontrat)) { $error++; @@ -408,9 +408,9 @@ if (empty($reshook)) { $action = 'create'; } } - } elseif ($action == 'classin' && $user->rights->contrat->creer) { + } elseif ($action == 'classin' && $user->hasRight('contrat', 'creer')) { $object->setProject(GETPOST('projectid')); - } elseif ($action == 'addline' && $user->rights->contrat->creer) { + } elseif ($action == 'addline' && $user->hasRight('contrat', 'creer')) { // Add a new line // Set if we used free entry or predefined product $predef = ''; @@ -682,7 +682,7 @@ if (empty($reshook)) { setEventMessages($object->error, $object->errors, 'errors'); } } - } elseif ($action == 'updateline' && $user->rights->contrat->creer && !GETPOST('cancel', 'alpha')) { + } elseif ($action == 'updateline' && $user->hasRight('contrat', 'creer') && !GETPOST('cancel', 'alpha')) { $error = 0; $predef = ''; @@ -795,7 +795,7 @@ if (empty($reshook)) { } else { $db->rollback(); } - } elseif ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->contrat->creer) { + } elseif ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->hasRight('contrat', 'creer')) { $result = $object->deleteline(GETPOST('lineid', 'int'), $user); if ($result >= 0) { @@ -804,7 +804,7 @@ if (empty($reshook)) { } else { setEventMessages($object->error, $object->errors, 'errors'); } - } elseif ($action == 'confirm_valid' && $confirm == 'yes' && $user->rights->contrat->creer) { + } elseif ($action == 'confirm_valid' && $confirm == 'yes' && $user->hasRight('contrat', 'creer')) { $result = $object->validate($user); if ($result > 0) { @@ -830,18 +830,18 @@ if (empty($reshook)) { } else { setEventMessages($object->error, $object->errors, 'errors'); } - } elseif ($action == 'reopen' && $user->rights->contrat->creer) { + } elseif ($action == 'reopen' && $user->hasRight('contrat', 'creer')) { $result = $object->reopen($user); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); } - } elseif ($action == 'confirm_close' && $confirm == 'yes' && $user->rights->contrat->creer) { + } elseif ($action == 'confirm_close' && $confirm == 'yes' && $user->hasRight('contrat', 'creer')) { // Close all lines $result = $object->closeAll($user); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); } - } elseif ($action == 'confirm_activate' && $confirm == 'yes' && $user->rights->contrat->creer) { + } elseif ($action == 'confirm_activate' && $confirm == 'yes' && $user->hasRight('contrat', 'creer')) { $date_start = dol_mktime(12, 0, 0, GETPOST('d_startmonth'), GETPOST('d_startday'), GETPOST('d_startyear')); $date_end = dol_mktime(12, 0, 0, GETPOST('d_endmonth'), GETPOST('d_endday'), GETPOST('d_endyear')); $comment = GETPOST('comment', 'alpha'); @@ -857,7 +857,7 @@ if (empty($reshook)) { } else { setEventMessages($object->error, $object->errors, 'errors'); } - } elseif ($action == 'confirm_move' && $confirm == 'yes' && $user->rights->contrat->creer) { + } elseif ($action == 'confirm_move' && $confirm == 'yes' && $user->hasRight('contrat', 'creer')) { if (GETPOST('newcid') > 0) { $contractline = new ContratLigne($db); $result = $contractline->fetch(GETPOSTINT('lineid')); @@ -995,7 +995,7 @@ if (empty($reshook)) { include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; - if (!empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->contrat->creer) { + if (!empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->hasRight('contrat', 'creer')) { if ($action == 'addcontact') { $contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid')); $typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type')); @@ -1351,7 +1351,7 @@ if ($action == 'create') { // Contract - if (!empty($object->brouillon) && $user->rights->contrat->creer) { + if (!empty($object->brouillon) && $user->hasRight('contrat', 'creer')) { print ''; print ''; print ''; @@ -1448,7 +1448,7 @@ if ($action == 'create') { print '
'; - if (!empty($object->brouillon) && $user->rights->contrat->creer) { + if (!empty($object->brouillon) && $user->hasRight('contrat', 'creer')) { print ''; } @@ -1826,7 +1826,7 @@ if ($action == 'create') { /* * Confirmation to delete service line of contract */ - if ($action == 'deleteline' && !$_REQUEST["cancel"] && $user->rights->contrat->creer && $object->lines[$cursorline - 1]->id == GETPOST('rowid')) { + if ($action == 'deleteline' && !$_REQUEST["cancel"] && $user->hasRight('contrat', 'creer') && $object->lines[$cursorline - 1]->id == GETPOST('rowid')) { print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id."&lineid=".GETPOST('rowid'), $langs->trans("DeleteContractLine"), $langs->trans("ConfirmDeleteContractLine"), "confirm_deleteline", '', 0, 1); if ($ret == 'html') { print '
'; @@ -1836,7 +1836,7 @@ if ($action == 'create') { /* * Confirmation to move service toward another contract */ - if ($action == 'move' && !$_REQUEST["cancel"] && $user->rights->contrat->creer && $object->lines[$cursorline - 1]->id == GETPOST('rowid')) { + if ($action == 'move' && !$_REQUEST["cancel"] && $user->hasRight('contrat', 'creer') && $object->lines[$cursorline - 1]->id == GETPOST('rowid')) { $arraycontractid = array(); foreach ($arrayothercontracts as $contractcursor) { $arraycontractid[$contractcursor->id] = $contractcursor->ref; diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 97b586a2cde..0007bc334b9 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -2062,7 +2062,7 @@ class Contrat extends CommonObject $label = implode($this->getTooltipContentArray($params)); $linkclose = ''; - if (empty($notooltip) && $user->rights->contrat->lire) { + if (empty($notooltip) && $user->hasRight('contrat', 'lire')) { if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { $label = $langs->trans("ShowContract"); $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; @@ -2840,7 +2840,7 @@ class Contrat extends CommonObject $return .= '
'.$this->societe.''; } if (property_exists($this, 'date_contrat')) { - $return .= '
'.$langs->trans("DateContract").' : '.dol_print_date($this->date_contrat).''; + $return .= '
'.$langs->trans("DateContract").' : '.dol_print_date($this->date_contrat, 'day').''; } if (method_exists($this, 'getLibStatut')) { $return .= '
'.$this->getLibStatut(5).'
'; diff --git a/htdocs/contrat/contact.php b/htdocs/contrat/contact.php index 6ca7b9b86ef..2af24364604 100644 --- a/htdocs/contrat/contact.php +++ b/htdocs/contrat/contact.php @@ -61,7 +61,7 @@ $permissiontoadd = $user->rights->contrat->creer; // Used by the include * Actions */ -if ($action == 'addcontact' && $user->rights->contrat->creer) { +if ($action == 'addcontact' && $user->hasRight('contrat', 'creer')) { $result = $object->fetch($id); if ($result > 0 && $id > 0) { @@ -86,7 +86,7 @@ if ($action == 'addcontact' && $user->rights->contrat->creer) { } // bascule du statut d'un contact -if ($action == 'swapstatut' && $user->rights->contrat->creer) { +if ($action == 'swapstatut' && $user->hasRight('contrat', 'creer')) { if ($object->fetch($id)) { $result = $object->swapContactStatus(GETPOST('ligne', 'int')); } else { @@ -95,7 +95,7 @@ if ($action == 'swapstatut' && $user->rights->contrat->creer) { } // Delete contact -if ($action == 'deletecontact' && $user->rights->contrat->creer) { +if ($action == 'deletecontact' && $user->hasRight('contrat', 'creer')) { $object->fetch($id); $result = $object->delete_contact(GETPOST("lineid", 'int')); diff --git a/htdocs/contrat/index.php b/htdocs/contrat/index.php index c40453ec7af..a8ca8a67444 100644 --- a/htdocs/contrat/index.php +++ b/htdocs/contrat/index.php @@ -239,7 +239,7 @@ print "

"; // Draft contracts -if (isModEnabled('contrat') && $user->rights->contrat->lire) { +if (isModEnabled('contrat') && $user->hasRight('contrat', 'lire')) { $sql = "SELECT c.rowid, c.ref,"; $sql .= " s.nom as name, s.name_alias, s.logo, s.rowid as socid, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur"; $sql .= " FROM ".MAIN_DB_PREFIX."contrat as c, ".MAIN_DB_PREFIX."societe as s"; diff --git a/htdocs/contrat/list.php b/htdocs/contrat/list.php index 38c37c1389e..03e65e18988 100644 --- a/htdocs/contrat/list.php +++ b/htdocs/contrat/list.php @@ -51,6 +51,7 @@ $show_files = GETPOST('show_files', 'int'); $confirm = GETPOST('confirm', 'alpha'); $toselect = GETPOST('toselect', 'array'); $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'contractlist'; // To manage different context of search +$optioncss = GETPOST('optioncss', 'alpha'); $mode = GETPOST('mode', 'alpha'); $search_name = GETPOST('search_name', 'alpha'); @@ -88,15 +89,15 @@ if (GETPOSTISSET('formfilteraction')) { } $searchCategoryCustomerList = GETPOST('search_category_customer_list', 'array'); -$optioncss = GETPOST('optioncss', 'alpha'); - +// Load variable for pagination $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); -if (empty($page) || $page == -1) { +if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) { + // If $page is not defined, or '' or -1 or if we click on clear filters $page = 0; -} // If $page is not defined, or '' or -1 +} $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; @@ -148,7 +149,9 @@ $reshook = $hookmanager->executeHooks('completeFieldsToSearchAll', $parameters, if ($reshook > 0) { $fieldstosearchall = $hookmanager->resArray['fieldstosearchall']; } elseif ($reshook == 0) { - $fieldstosearchall = array_merge($fieldstosearchall, $hookmanager->resArray['fieldstosearchall']); + if (!empty($hookmanager->resArray['fieldstosearchall'])) { + $fieldstosearchall = array_merge($fieldstosearchall, $hookmanager->resArray['fieldstosearchall']); + } } $arrayfields = array( @@ -175,6 +178,7 @@ $object->fields = dol_sort_array($object->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); $permissiontoread = $user->rights->contrat->lire; +$permissiontoadd = $user->rights->contrat->creer; $permissiontodelete = $user->rights->contrat->supprimer; @@ -183,7 +187,8 @@ $permissiontodelete = $user->rights->contrat->supprimer; */ if (GETPOST('cancel', 'alpha')) { - $action = 'list'; $massaction = ''; + $action = 'list'; + $massaction = ''; } if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; @@ -243,13 +248,15 @@ if (empty($reshook)) { * View */ -$now = dol_now(); $form = new Form($db); $formfile = new FormFile($db); $formother = new FormOther($db); $socstatic = new Societe($db); $formcompany = new FormCompany($db); $contracttmp = new Contrat($db); + +$now = dol_now(); + $title = ""; $sql = 'SELECT'; @@ -272,7 +279,8 @@ if (!empty($extrafields->attributes[$object->table_element]['label'])) { // Add fields from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object, $action); // Note that $action and $object may have been modified by hook -$sql .= $hookmanager->resPrint; +$sql .= preg_replace('/^,/', '', $hookmanager->resPrint); +$sql = preg_replace('/,\s*$/', '', $sql); $sqlfields = $sql; // $sql fields to remove for count total @@ -452,6 +460,7 @@ if (empty($reshook)) { } $sql .= $hookmanager->resPrint; +// Count total nb of records $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { //$result = $db->query($sql); @@ -485,8 +494,10 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $page = 0; $offset = 0; } + $db->free($resql); } +// Complete request and execute it with limit $sql .= $db->order($sortfield, $sortorder); if ($limit) { $sql .= $db->plimit($limit + 1, $offset); @@ -631,7 +642,7 @@ $newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars i $newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition')); $newcardbutton .= dolGetButtonTitle($langs->trans('NewContractSubscription'), '', 'fa fa-plus-circle', $url, '', $user->rights->contrat->creer); -print '
'; +print ''."\n"; if ($optioncss != '') { print ''; } @@ -725,10 +736,12 @@ if ($massactionbutton) { print '
'; print ''."\n"; +// Fields title search +// -------------------------------------------------------------------- print ''; // Action column if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print ''; @@ -837,81 +850,114 @@ if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { print $searchpicto; print ''; } -print "\n"; +print ''."\n"; +$totalarray = array(); +$totalarray['nbfield'] = 0; + +// Fields title label +// -------------------------------------------------------------------- print ''; if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); + $totalarray['nbfield']++; // For the column action } if (!empty($arrayfields['c.ref']['checked'])) { print_liste_field_titre($arrayfields['c.ref']['label'], $_SERVER["PHP_SELF"], "c.ref", "", $param, '', $sortfield, $sortorder); + $totalarray['nbfield']++; // For the column action } if (!empty($arrayfields['c.ref_customer']['checked'])) { print_liste_field_titre($arrayfields['c.ref_customer']['label'], $_SERVER["PHP_SELF"], "c.ref_customer", "", $param, '', $sortfield, $sortorder); + $totalarray['nbfield']++; // For the column action } if (!empty($arrayfields['c.ref_supplier']['checked'])) { print_liste_field_titre($arrayfields['c.ref_supplier']['label'], $_SERVER["PHP_SELF"], "c.ref_supplier", "", $param, '', $sortfield, $sortorder); + $totalarray['nbfield']++; // For the column action } if (!empty($arrayfields['s.nom']['checked'])) { print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", "", $param, '', $sortfield, $sortorder); + $totalarray['nbfield']++; // For the column action } if (!empty($arrayfields['s.email']['checked'])) { print_liste_field_titre($arrayfields['s.email']['label'], $_SERVER["PHP_SELF"], "s.email", "", $param, '', $sortfield, $sortorder); + $totalarray['nbfield']++; // For the column action } if (!empty($arrayfields['s.town']['checked'])) { print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], 's.town', '', $param, '', $sortfield, $sortorder); + $totalarray['nbfield']++; // For the column action } if (!empty($arrayfields['s.zip']['checked'])) { print_liste_field_titre($arrayfields['s.zip']['label'], $_SERVER["PHP_SELF"], 's.zip', '', $param, '', $sortfield, $sortorder); + $totalarray['nbfield']++; // For the column action } if (!empty($arrayfields['state.nom']['checked'])) { print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder); + $totalarray['nbfield']++; // For the column action } if (!empty($arrayfields['country.code_iso']['checked'])) { print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, '', $sortfield, $sortorder, 'center '); + $totalarray['nbfield']++; // For the column action } if (!empty($arrayfields['typent.code']['checked'])) { print_liste_field_titre($arrayfields['typent.code']['label'], $_SERVER["PHP_SELF"], "typent.code", "", $param, '', $sortfield, $sortorder, 'center '); + $totalarray['nbfield']++; // For the column action } if (!empty($arrayfields['sale_representative']['checked'])) { print_liste_field_titre($arrayfields['sale_representative']['label'], $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder); + $totalarray['nbfield']++; // For the column action } if (!empty($arrayfields['c.date_contrat']['checked'])) { print_liste_field_titre($arrayfields['c.date_contrat']['label'], $_SERVER["PHP_SELF"], "c.date_contrat", "", $param, '', $sortfield, $sortorder, 'center '); + $totalarray['nbfield']++; // For the column action } // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields -$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); +$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder, 'totalarray'=>&$totalarray); $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (!empty($arrayfields['c.datec']['checked'])) { print_liste_field_titre($arrayfields['c.datec']['label'], $_SERVER["PHP_SELF"], "c.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap '); + $totalarray['nbfield']++; // For the column action } if (!empty($arrayfields['c.tms']['checked'])) { print_liste_field_titre($arrayfields['c.tms']['label'], $_SERVER["PHP_SELF"], "c.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap '); + $totalarray['nbfield']++; // For the column action } if (!empty($arrayfields['lower_planned_end_date']['checked'])) { print_liste_field_titre($arrayfields['lower_planned_end_date']['label'], $_SERVER["PHP_SELF"], "lower_planned_end_date", "", $param, '', $sortfield, $sortorder, 'center '); + $totalarray['nbfield']++; // For the column action } if (!empty($arrayfields['status']['checked'])) { print_liste_field_titre($staticcontratligne->LibStatut(0, 3, -1, 'class="nochangebackground"'), '', '', '', '', 'width="16"'); + $totalarray['nbfield']++; // For the column action print_liste_field_titre($staticcontratligne->LibStatut(4, 3, 0, 'class="nochangebackground"'), '', '', '', '', 'width="16"'); + $totalarray['nbfield']++; // For the column action print_liste_field_titre($staticcontratligne->LibStatut(4, 3, 1, 'class="nochangebackground"'), '', '', '', '', 'width="16"'); + $totalarray['nbfield']++; // For the column action print_liste_field_titre($staticcontratligne->LibStatut(5, 3, -1, 'class="nochangebackground"'), '', '', '', '', 'width="16"'); + $totalarray['nbfield']++; // For the column action } if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); + $totalarray['nbfield']++; // For the column action } print "\n"; +// Loop on record +// -------------------------------------------------------------------- +$i = 0; +$savnbfield = $totalarray['nbfield']; $totalarray = array(); $totalarray['nbfield'] = 0; $typenArray = array(); $cacheCountryIDCode = array(); - -while ($i < min($num, $limit)) { +$imaxinloop = ($limit ? min($num, $limit) : $num); +while ($i < $imaxinloop) { $obj = $db->fetch_object($resql); + if (empty($obj)) { + break; // Should not happen + } $contracttmp->ref = $obj->ref; $contracttmp->id = $obj->rowid; @@ -938,23 +984,24 @@ while ($i < min($num, $limit)) { $socstatic->country_code = $cacheCountryIDCode[$obj->country_id]['code']; $socstatic->country = $cacheCountryIDCode[$obj->country_id]['label']; } - //mode kanban + if ($mode == 'kanban') { if ($i == 0) { - print ''; } } else { - print ''; + // Show here line of result + print ''; // Action column if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { print ''; + if (!$i) { + $totalarray['nbfield']++; + } } // Ref if (!empty($arrayfields['c.ref']['checked'])) { @@ -987,11 +1037,17 @@ while ($i < min($num, $limit)) { print ''; print ''; + if (!$i) { + $totalarray['nbfield']++; + } } // Ref thirdparty if (!empty($arrayfields['c.ref_customer']['checked'])) { print ''; + if (!$i) { + $totalarray['nbfield']++; + } } if (!empty($arrayfields['c.ref_supplier']['checked'])) { print ''; @@ -1140,6 +1196,12 @@ while ($i < min($num, $limit)) { print ''; print ''; print ''; + if (!$i) { + $totalarray['nbfield']++; + $totalarray['nbfield']++; + $totalarray['nbfield']++; + $totalarray['nbfield']++; + } } // Action column if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { @@ -1152,12 +1214,12 @@ while ($i < min($num, $limit)) { print ''; } print ''; - } - if (!$i) { - $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } - print "\n"; + print ''."\n"; } $i++; } @@ -1179,10 +1241,10 @@ $parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql); $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; -print '
'; + print ''; $searchpicto = $form->showFilterButtons('left'); print $searchpicto; print '
'; - print '
'; + print '
'; + print '
'; } // Output Kanban $contracttmp->societe = $socstatic->getNomUrl(); $contracttmp->date_contrat = $obj->date_contrat; print $contracttmp->getKanbanView(''); - if ($i == (min($num, $limit) - 1)) { + if ($i == ($imaxinloop - 1)) { print '
'; print '
'; @@ -966,6 +1013,9 @@ while ($i < min($num, $limit)) { print ''; } print ''.$contracttmp->getFormatedCustomerRef($obj->ref_customer).''.dol_escape_htmltag($obj->ref_supplier).''.($obj->nb_running > 0 ? $obj->nb_running : '').''.($obj->nb_expired > 0 ? $obj->nb_expired : '').''.($obj->nb_closed > 0 ? $obj->nb_closed : '').'
'; -print '
'; +print ''."\n"; +print '
'."\n"; -print ''; +print ''."\n"; $hidegeneratedfilelistifempty = 1; if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { @@ -1194,8 +1256,8 @@ $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortor $urlsource .= str_replace('&', '&', $param); $filedir = $diroutputmassaction; -$genallowed = $user->rights->contrat->lire; -$delallowed = $user->rights->contrat->lire; +$genallowed = $permissiontoread; +$delallowed = $permissiontoadd; print $formfile->showdocuments('massfilesarea_contract', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty); diff --git a/htdocs/core/actions_linkedfiles.inc.php b/htdocs/core/actions_linkedfiles.inc.php index 4e2cd2873b6..6c5ac91c9bb 100644 --- a/htdocs/core/actions_linkedfiles.inc.php +++ b/htdocs/core/actions_linkedfiles.inc.php @@ -188,7 +188,7 @@ if ($action == 'confirm_deletefile' && $confirm == 'yes' && !empty($permissionto //error fetching } } elseif ($action == 'renamefile' && GETPOST('renamefilesave', 'alpha') && !empty($permissiontoadd)) { - // For documents pages, upload_dir contains already path to file from module dir, so we clean path into urlfile. + // For documents pages, upload_dir contains already the path to the file from module dir if (!empty($upload_dir)) { $filenamefrom = dol_sanitizeFileName(GETPOST('renamefilefrom', 'alpha'), '_', 0); // Do not remove accents $filenameto = dol_sanitizeFileName(GETPOST('renamefileto', 'alpha'), '_', 0); // Do not remove accents @@ -200,7 +200,22 @@ if ($action == 'confirm_deletefile' && $confirm == 'yes' && !empty($permissionto $error++; setEventMessages($langs->trans('ErrorWrongFileName'), null, 'errors'); } - if (!$error && $filenamefrom != $filenameto) { + + // Check that filename is not the one of a reserved allowed CLI command + if (empty($error)) { + global $dolibarr_main_restrict_os_commands; + if (!empty($dolibarr_main_restrict_os_commands)) { + $arrayofallowedcommand = explode(',', $dolibarr_main_restrict_os_commands); + $arrayofallowedcommand = array_map('trim', $arrayofallowedcommand); + if (in_array(basename($filenameto), $arrayofallowedcommand)) { + $error++; + $langs->load("errors"); // key must be loaded because we can't rely on loading during output, we need var substitution to be done now. + setEventMessages($langs->trans("ErrorFilenameReserved", basename($filenameto)), null, 'errors'); + } + } + } + + if (empty($error) && $filenamefrom != $filenameto) { // Security: // Disallow file with some extensions. We rename them. // Because if we put the documents directory into a directory inside web root (very bad), this allows to execute on demand arbitrary code. @@ -236,17 +251,18 @@ if ($action == 'confirm_deletefile' && $confirm == 'yes' && !empty($permissionto // When we rename a file from the file manager in ecm, we must not regenerate thumbs (not a problem, we do pass here) // When we rename a file from the website module, we must not regenerate thumbs (module = medias in such a case) // but when we rename from a tab "Documents", we must regenerate thumbs - if (GETPOST('modulepart') == 'medias') { + if (GETPOST('modulepart', 'aZ09') == 'medias') { $generatethumbs = 0; } if ($generatethumbs) { - if ($object->id) { + if ($object->id > 0) { + // Create thumbs for the new file $object->addThumbs($destpath); - } - // TODO Add revert function of addThumbs to remove thumbs with old name - //$object->delThumbs($srcpath); + // Delete thumb files with old name + $object->delThumbs($srcpath); + } } setEventMessages($langs->trans("FileRenamed"), null); diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index 55d7ec6fdcf..c526f9312a0 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -684,7 +684,6 @@ if (!$error && $massaction == 'cancelorders') { $nbok = 0; - $orders = GETPOST('toselect', 'array'); foreach ($orders as $id_order) { $cmd = new Commande($db); @@ -820,9 +819,7 @@ if (!$error && $massaction == "builddoc" && $permissiontoread && !GETPOST('butto // check if pdftk is installed if (file_exists($file)) { - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); $langs->load("exports"); setEventMessages($langs->trans('FileSuccessfullyBuilt', $filename.'_'.dol_print_date($now, 'dayhourlog')), null, 'mesgs'); @@ -888,9 +885,7 @@ if (!$error && $massaction == "builddoc" && $permissiontoread && !GETPOST('butto $now = dol_now(); $file = $diroutputmassaction.'/'.$filename.'_'.dol_print_date($now, 'dayhourlog').'.pdf'; $pdf->Output($file, 'F'); - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); $langs->load("exports"); setEventMessages($langs->trans('FileSuccessfullyBuilt', $filename.'_'.dol_print_date($now, 'dayhourlog')), null, 'mesgs'); @@ -958,7 +953,14 @@ if (!$error && $massaction == 'validate' && $permissiontoadd) { foreach ($toselect as $toselectid) { $result = $objecttmp->fetch($toselectid); if ($result > 0) { - $result = $objecttmp->validate($user); + if (method_exists($objecttmp, 'validate')) { + $result = $objecttmp->validate($user); + } elseif (method_exists($objecttmp, 'setValid')) { + $result = $objecttmp->setValid($user); + } else { + $objecttmp->error = 'No method validate or setValid on this object'; + $result = -1; + } if ($result == 0) { $langs->load("errors"); setEventMessages($langs->trans("ErrorObjectMustHaveStatusDraftToBeValidated", $objecttmp->ref), null, 'errors'); @@ -977,8 +979,13 @@ if (!$error && $massaction == 'validate' && $permissiontoadd) { if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && GETPOST('lang_id', 'aZ09')) { $newlang = GETPOST('lang_id', 'aZ09'); } - if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) { - $newlang = $objecttmp->thirdparty->default_lang; + if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && property_exists($objecttmp, 'thirdparty')) { + if ((property_exists($objecttmp, 'socid') || property_exists($objecttmp, 'fk_soc')) && empty($objecttmp->thirdparty)) { + $objecttmp->fetch_thirdparty(); + } + if (!empty($objecttmp->thirdparty)) { + $newlang = $objecttmp->thirdparty->default_lang; + } } if (!empty($newlang)) { $outputlangs = new Translate("", $conf); diff --git a/htdocs/core/ajax/ajaxdirpreview.php b/htdocs/core/ajax/ajaxdirpreview.php index 76531832776..2f763c4e576 100644 --- a/htdocs/core/ajax/ajaxdirpreview.php +++ b/htdocs/core/ajax/ajaxdirpreview.php @@ -448,7 +448,7 @@ if ($useajax || $action == 'deletefile') { if ($useajax) { print ''."\n"; - print ''; // This ajax service is called only when a directory $selecteddir is opened but not when closed. - //print ''; } diff --git a/htdocs/core/ajax/ajaxtooltip.php b/htdocs/core/ajax/ajaxtooltip.php index 3933f03533b..8652908eced 100644 --- a/htdocs/core/ajax/ajaxtooltip.php +++ b/htdocs/core/ajax/ajaxtooltip.php @@ -118,7 +118,6 @@ if ($objecttype == 'facture' || $objecttype == 'invoice') { $module = 'contrat'; $myobject = 'contrat'; } elseif ($objecttype == 'member') { - $langs->load('members'); $classpath = 'adherents/class'; $module = 'adherent'; $myobject = 'adherent'; diff --git a/htdocs/core/ajax/flowjs-server.php b/htdocs/core/ajax/flowjs-server.php new file mode 100644 index 00000000000..e1f5feaaf10 --- /dev/null +++ b/htdocs/core/ajax/flowjs-server.php @@ -0,0 +1,161 @@ + + * + * 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/ajax/bankconciliate.php + * \brief File to set data for bank concilation + */ + +if (!defined('NOTOKENRENEWAL')) { + define('NOTOKENRENEWAL', '1'); // Disables token renewal +} +if (!defined('NOREQUIREMENU')) { + define('NOREQUIREMENU', '1'); +} +if (!defined('NOREQUIREHTML')) { + define('NOREQUIREHTML', '1'); +} +if (!defined('NOREQUIREAJAX')) { + define('NOREQUIREAJAX', '1'); +} +if (!defined('NOREQUIRESOC')) { + define('NOREQUIRESOC', '1'); +} +// If there is no need to load and show top and left menu +if (!defined("NOLOGIN")) { + define("NOLOGIN", '1'); +} +//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); // Required to know date format for dol_print_date + +// Load Dolibarr environment +require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + +$action = GETPOST('action', 'aZ09'); +$module = GETPOST('module', 'aZ09'); +$upload_dir = GETPOST('upload_dir', 'alpha'); +$flowFilename = GETPOST('flowFilename', 'alpha'); +$flowIdentifier = GETPOST('flowIdentifier', 'alpha'); +$flowChunkNumber = GETPOST('flowChunkNumber', 'alpha'); +$flowChunkSize = GETPOST('flowChunkSize', 'alpha'); +$flowTotalSize = GETPOST('flowTotalSize', 'alpha'); + +/* + * Action + */ + + +top_httphead(); +dol_syslog(join(',', $_GET)); + +$result = true; + +if (!empty($upload_dir)) { + $temp_dir = $upload_dir.'/'.$flowIdentifier; +} else { + $temp_dir = DOL_DATA_ROOT.'/'.$module.'/temp/'.$flowIdentifier; + $upload_dir = $temp_dir; +} + +if ($_SERVER['REQUEST_METHOD'] === 'GET') { + $chunk_file = $temp_dir.'/'.$flowFilename.'.part'.$flowChunkNumber; + if (file_exists($chunk_file)) { + header("HTTP/1.0 200 Ok"); + } else { + header("HTTP/1.0 404 Not Found"); + } +} else { + // loop through files and move the chunks to a temporarily created directory + if (file_exists($upload_dir.'/'.$flowFilename)) { + echo json_encode('File '.$flowIdentifier.' was already uploaded'); + header("HTTP/1.0 200 Ok"); + } elseif (!empty($_FILES)) foreach ($_FILES as $file) { + // check the error status + if ($file['error'] != 0) { + dol_syslog('error '.$file['error'].' in file '.$flowFilename); + continue; + } + + // init the destination file (format .part<#chunk> + // the file is stored in a temporary directory + $dest_file = $temp_dir.'/'.$flowFilename.'.part'.$flowChunkNumber; + + // create the temporary directory + if (!dol_is_dir($temp_dir)) { + dol_mkdir($temp_dir); + } + + // move the temporary file + if (!dol_move_uploaded_file($file['tmp_name'], $dest_file, 0)) { + dol_syslog('Error saving (move_uploaded_file) chunk '.$flowChunkNumber.' for file '.$flowFilename); + } else { + // check if all the parts present, and create the final destination file + $result = createFileFromChunks($temp_dir, $upload_dir, $flowFilename, $flowChunkSize, $flowTotalSize); + } + } +} +if ($result) { + echo json_encode('File '.$flowIdentifier.' uploaded'); +} else { + echo json_encode('Error while uploading file '.$flowIdentifier); +} + + +/** + * Check if all the parts exist, and + * gather all the parts of the file together + * @param string $temp_dir - the temporary directory holding all the parts of the file + * @param string $upload_dir - the temporary directory to create file + * @param string $fileName - the original file name + * @param string $chunkSize - each chunk size (in bytes) + * @param string $totalSize - original file size (in bytes) + * @return bool true if Ok false else + */ +function createFileFromChunks($temp_dir, $upload_dir, $fileName, $chunkSize, $totalSize) +{ + + dol_syslog(__METHOD__, LOG_DEBUG); + // count all the parts of this file + $total_files = 0; + $files = dol_dir_list($temp_dir, 'files'); + foreach ($files as $file) { + if (stripos($file, $fileName) !== false) { + $total_files++; + } + } + + // check that all the parts are present + // the size of the last part is between chunkSize and 2*$chunkSize + if ($total_files * $chunkSize >= ($totalSize - $chunkSize + 1)) { + // create the final destination file + if (($fp = fopen($upload_dir.'/'.$fileName, 'w')) !== false) { + for ($i=1; $i<=$total_files; $i++) { + fwrite($fp, file_get_contents($temp_dir.'/'.$fileName.'.part'.$i)); + dol_syslog('writing chunk '.$i); + } + fclose($fp); + } else { + dol_syslog('cannot create the destination file'); + return false; + } + + // rename the temporary directory (to avoid access from other + // concurrent chunks uploads) + @rename($temp_dir, $temp_dir.'_UNUSED'); + } + return true; +} diff --git a/htdocs/core/ajax/loadinplace.php b/htdocs/core/ajax/loadinplace.php index 1cdecf6306d..af033c8cdd3 100644 --- a/htdocs/core/ajax/loadinplace.php +++ b/htdocs/core/ajax/loadinplace.php @@ -80,7 +80,7 @@ if (!empty($field) && !empty($element) && !empty($table_element) && !empty($fk_e if ($user->rights->$element->lire || $user->rights->$element->read || (isset($subelement) && ($user->rights->$element->$subelement->lire || $user->rights->$element->$subelement->read)) - || ($element == 'payment' && $user->rights->facture->lire) + || ($element == 'payment' && $user->hasRight('facture', 'lire')) || ($element == 'payment_supplier' && $user->rights->fournisseur->facture->lire)) { if ($type == 'select') { $methodname = 'load_cache_'.$loadmethod; diff --git a/htdocs/core/ajax/row.php b/htdocs/core/ajax/row.php index 0254a7502f8..ec3ee105420 100644 --- a/htdocs/core/ajax/row.php +++ b/htdocs/core/ajax/row.php @@ -74,13 +74,13 @@ if (GETPOST('roworder', 'alpha', 3) && GETPOST('table_element_line', 'aZ09', 3) // Make test on permission $perm = 0; - if ($table_element_line == 'propaldet' && $user->rights->propal->creer) { + if ($table_element_line == 'propaldet' && $user->hasRight('propal', 'creer')) { $perm = 1; - } elseif ($table_element_line == 'commandedet' && $user->rights->commande->creer) { + } elseif ($table_element_line == 'commandedet' && $user->hasRight('commande', 'creer')) { $perm = 1; - } elseif ($table_element_line == 'facturedet' && $user->rights->facture->creer) { + } elseif ($table_element_line == 'facturedet' && $user->hasRight('facture', 'creer')) { $perm = 1; - } elseif ($table_element_line == 'facturedet_rec' && $user->rights->facture->creer) { + } elseif ($table_element_line == 'facturedet_rec' && $user->hasRight('facture', 'creer')) { $perm = 1; } elseif ($table_element_line == 'emailcollector_emailcollectoraction' && $user->admin) { $perm = 1; diff --git a/htdocs/core/boxes/box_actions.php b/htdocs/core/boxes/box_actions.php index ac0df03184a..a47f5d4f744 100644 --- a/htdocs/core/boxes/box_actions.php +++ b/htdocs/core/boxes/box_actions.php @@ -256,7 +256,7 @@ class box_actions extends ModeleBoxes } $out .= '
'; if ($actioncejour) { - $out .= ''; } else { - $out .= ''; } diff --git a/htdocs/core/boxes/box_external_rss.php b/htdocs/core/boxes/box_external_rss.php index 54f68c5e57f..8bc4943e50b 100644 --- a/htdocs/core/boxes/box_external_rss.php +++ b/htdocs/core/boxes/box_external_rss.php @@ -134,6 +134,9 @@ class box_external_rss extends ModeleBoxes if (!$date && isset($item['pubdate'])) { $date = $item['pubdate']; } + if (!$date && isset($item['pubDate'])) { + $date = $item['pubDate']; + } if (!$date && isset($item['dc']['date'])) { $date = $item['dc']['date']; } @@ -183,22 +186,22 @@ class box_external_rss extends ModeleBoxes 'td' => 'class="left" width="16"', 'text' => img_picto('', 'rss'), 'url' => $href, - 'tooltip' => $tooltip, + 'tooltip' => dol_escape_htmltag($tooltip), 'target' => 'newrss', ); $this->info_box_contents[$line][1] = array( 'td' => 'class="tdoverflowmax300"', - 'text' => $title, + 'text' => dol_escape_htmltag($title), 'url' => $href, - 'tooltip' => $tooltip, + 'tooltip' => dol_escape_htmltag($tooltip), 'maxlength' => 0, 'target' => 'newrss', ); $this->info_box_contents[$line][2] = array( 'td' => 'class="right nowrap"', - 'text' => $date, + 'text' => dol_escape_htmltag($date), ); } } diff --git a/htdocs/core/boxes/box_graph_invoices_permonth.php b/htdocs/core/boxes/box_graph_invoices_permonth.php index 03b0e1d087b..34dc015a1db 100644 --- a/htdocs/core/boxes/box_graph_invoices_permonth.php +++ b/htdocs/core/boxes/box_graph_invoices_permonth.php @@ -227,7 +227,7 @@ class box_graph_invoices_permonth extends ModeleBoxes if (!$mesg) { $stringtoshow = ''; - $stringtoshow .= ''; // set cookie by js - $boxcontent .= ''; + $boxcontent .= ''; } $this->info_box_contents[0][] = array( 'tr' => 'class="nohover showiffilter'.$this->boxcode.' hideobject"', diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php index 721e0582824..9e8593e6d1b 100644 --- a/htdocs/core/class/CMailFile.class.php +++ b/htdocs/core/class/CMailFile.class.php @@ -65,6 +65,7 @@ class CMailFile public $atleastonefile; + public $msg; public $eol; public $eol2; @@ -1212,9 +1213,7 @@ class CMailFile } fclose($fp); - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($outputfile, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($outputfile); } } @@ -1796,7 +1795,7 @@ class CMailFile if ($fhandle) { $nbofbyteswrote = fwrite($fhandle, base64_decode($filecontent)); fclose($fhandle); - @chmod($destfiletmp, octdec($conf->global->MAIN_UMASK)); + dolChmod($destfiletmp); } else { $this->errors[] = "Failed to open file '".$destfiletmp."' for write"; return -1; diff --git a/htdocs/core/class/CSMSFile.class.php b/htdocs/core/class/CSMSFile.class.php index 3f082ba6d53..a8dc4bfff9a 100644 --- a/htdocs/core/class/CSMSFile.class.php +++ b/htdocs/core/class/CSMSFile.class.php @@ -231,9 +231,7 @@ class CSMSFile fputs($fp, "Message:\n".$this->message); fclose($fp); - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($outputfile, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($outputfile); } } @@ -257,9 +255,7 @@ class CSMSFile fputs($fp, "\nResult id=".$result); fclose($fp); - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($outputfile, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($outputfile); } } } diff --git a/htdocs/core/class/cgenericdic.class.php b/htdocs/core/class/cgenericdic.class.php index 250fb3ec569..60ac9f7984e 100644 --- a/htdocs/core/class/cgenericdic.class.php +++ b/htdocs/core/class/cgenericdic.class.php @@ -30,6 +30,11 @@ */ class CGenericDic { + /** + * @var DoliDB Database handler. + */ + public $db; + /** * @var string Id to identify managed objects */ diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index 33d5e5a97c6..51fdbbcfdc8 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -145,7 +145,11 @@ abstract class CommonDocGenerator 'myuser_email'=>$user->email, 'myuser_logo'=>$logotouse, 'myuser_job'=>$user->job, - 'myuser_web'=>'' // url not exist in $user object + 'myuser_web'=>'', // url not exist in $user object + 'myuser_birth'=>dol_print_date($user->birth, 'day', 'gmt'), + 'myuser_dateemployment'=>dol_print_date($user->dateemployment, 'day', 'tzuser'), + 'myuser_dateemploymentend'=>dol_print_date($user->dateemploymentend, 'day', 'tzuser'), + 'myuser_gender'=>$user->gender, ); // Retrieve extrafields if (is_array($user->array_options) && count($user->array_options)) { diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php index 0c44bfd5b28..a7197d7c9ae 100644 --- a/htdocs/core/class/commoninvoice.class.php +++ b/htdocs/core/class/commoninvoice.class.php @@ -667,7 +667,7 @@ abstract class CommonInvoice extends CommonObject * conditions and billing date. * * @param integer $cond_reglement Condition of payment (code or id) to use. If 0, we use current condition. - * @return integer Date limite de reglement si ok, <0 si ko + * @return integer Date limit of payment if OK, <0 if KO */ public function calculate_date_lim_reglement($cond_reglement = 0) { @@ -678,6 +678,9 @@ abstract class CommonInvoice extends CommonObject if (!$cond_reglement) { $cond_reglement = $this->cond_reglement_id; } + if (!$cond_reglement) { + return $this->date; + } $cdr_nbjour = 0; $cdr_type = 0; diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 69188c9a7e4..26c5beb0b73 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -5743,12 +5743,12 @@ abstract class CommonObject */ public function addThumbs($file) { - global $maxwidthsmall, $maxheightsmall, $maxwidthmini, $maxheightmini, $quality; - - require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; // This define also $maxwidthsmall, $quality, ... - $file_osencoded = dol_osencode($file); if (file_exists($file_osencoded)) { + global $maxwidthsmall, $maxheightsmall, $maxwidthmini, $maxheightmini, $quality; + + require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; // This define also $maxwidthsmall, $quality, ... + // Create small thumbs for company (Ratio is near 16/9) // Used on logon for example vignette($file_osencoded, $maxwidthsmall, $maxheightsmall, '_small', $quality); @@ -5759,6 +5759,21 @@ abstract class CommonObject } } + /** + * Delete thumbs + * @todo Move this into files.lib.php + * + * @param string $file Path file in UTF8 to original file to delete thumbs. + * @return void + */ + public function delThumbs($file) + { + $imgThumbName = getImageFileNameForSize($file, '_small'); // Full path of thumb file + dol_delete_file($imgThumbName); + $imgThumbName = getImageFileNameForSize($file, '_mini'); // Full path of thumb file + dol_delete_file($imgThumbName); + } + /* Functions common to commonobject and commonobjectline */ @@ -7428,7 +7443,7 @@ abstract class CommonObject if (!empty($conf->use_javascript_ajax)) { $out .= ' - '; + $result .= ''; } return $result; @@ -724,7 +724,7 @@ class Form * @param string $extracss Add a CSS style to td, div or span tag * @param int $noencodehtmltext Do not encode into html entity the htmltext * @param int $notabs 0=Include table and tr tags, 1=Do not include table and tr tags, 2=use div, 3=use span - * @param string $tooltiptrigger ''=Tooltip on hover, 'abc'=Tooltip on click (abc is a unique key, clickable link is on image or on link if param $type='none' or on both if $type='xxxclickable') + * @param string $tooltiptrigger ''=Tooltip on hover and hidden on smartphone, 'abconsmartphone'=Tooltip on hover and on click on smartphone, 'abc'=Tooltip on click (abc is a unique key, clickable link is on image or on link if param $type='none' or on both if $type='xxxclickable') * @param int $forcenowrap Force no wrap between text and picto (works with notabs=2 only) * @return string HTML code of text, picto, tooltip */ @@ -732,11 +732,6 @@ class Form { global $conf, $langs; - $alt = ''; - if ($tooltiptrigger) { - $alt = $langs->transnoentitiesnoconv("ClickToShowHelp"); - } - //For backwards compatibility if ($type == '0') { $type = 'info'; @@ -744,6 +739,15 @@ class Form $type = 'help'; } + if (preg_match('/onsmartphone$/', $tooltiptrigger) && empty($conf->dol_no_mouse_hover)) { + $tooltiptrigger = preg_replace('/^.*onsmartphone$/', '', $tooltiptrigger); + } + + $alt = ''; + if ($tooltiptrigger) { + $alt = $langs->transnoentitiesnoconv("ClickToShowHelp"); + } + // If info or help with no javascript, show only text if (empty($conf->use_javascript_ajax)) { if ($type == 'info' || $type == 'infoclickable' || $type == 'help' || $type == 'helpclickable') { @@ -833,7 +837,7 @@ class Form if (!empty($conf->use_javascript_ajax)) { $ret .= ' - '; + print ''; + print 'console.log("hide the margin info"); $("#margintable").hide();'; } + print '});'; } print '
'; diff --git a/htdocs/core/class/html.formorder.class.php b/htdocs/core/class/html.formorder.class.php index b97175f1397..2e01fae85cf 100644 --- a/htdocs/core/class/html.formorder.class.php +++ b/htdocs/core/class/html.formorder.class.php @@ -78,7 +78,7 @@ class FormOrder extends Form * @param string $selected Id of preselected input method * @param string $htmlname Name of HTML select list * @param int $addempty 0=list with no empty value, 1=list with empty value - * @return array Tableau des sources de commandes + * @return int <0 if KO, >0 if OK */ public function selectInputMethod($selected = '', $htmlname = 'source_id', $addempty = 0) { diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php index 7e14474bc96..21e5b608a41 100644 --- a/htdocs/core/class/html.formother.class.php +++ b/htdocs/core/class/html.formother.class.php @@ -104,7 +104,7 @@ class FormOther $out .= '
'; $out .= '
'; - $out .= ''; - $out .= ''; + $out .= ''; - $out .= ''; + $out .= ''; } - $stringtoprint .=''; } else { // Default Header Redirect diff --git a/htdocs/core/class/rssparser.class.php b/htdocs/core/class/rssparser.class.php index da3257b09c9..6992612592d 100644 --- a/htdocs/core/class/rssparser.class.php +++ b/htdocs/core/class/rssparser.class.php @@ -295,10 +295,7 @@ class RssParser if ($fp) { fwrite($fp, $str); fclose($fp); - if (!empty($conf->global->MAIN_UMASK)) { - $newmask = $conf->global->MAIN_UMASK; - } - @chmod($newpathofdestfile, octdec($newmask)); + dolChmod($newpathofdestfile); $this->_lastfetchdate = $nowgmt; } else { @@ -322,54 +319,54 @@ class RssParser //var_dump($rss); if (!empty($conf->global->EXTERNALRSS_USE_SIMPLEXML)) { if (!empty($rss->channel->language)) { - $this->_language = (string) $rss->channel->language; + $this->_language = sanitizeVal((string) $rss->channel->language); } if (!empty($rss->channel->generator)) { - $this->_generator = (string) $rss->channel->generator; + $this->_generator = sanitizeVal((string) $rss->channel->generator); } if (!empty($rss->channel->copyright)) { - $this->_copyright = (string) $rss->channel->copyright; + $this->_copyright = sanitizeVal((string) $rss->channel->copyright); } if (!empty($rss->channel->lastbuilddate)) { - $this->_lastbuilddate = (string) $rss->channel->lastbuilddate; + $this->_lastbuilddate = sanitizeVal((string) $rss->channel->lastbuilddate); } if (!empty($rss->channel->image->url[0])) { - $this->_imageurl = (string) $rss->channel->image->url[0]; + $this->_imageurl = sanitizeVal((string) $rss->channel->image->url[0]); } if (!empty($rss->channel->link)) { - $this->_link = (string) $rss->channel->link; + $this->_link = sanitizeVal((string) $rss->channel->link); } if (!empty($rss->channel->title)) { - $this->_title = (string) $rss->channel->title; + $this->_title = sanitizeVal((string) $rss->channel->title); } if (!empty($rss->channel->description)) { - $this->_description = (string) $rss->channel->description; + $this->_description = sanitizeVal((string) $rss->channel->description); } } else { //var_dump($rss->channel); if (!empty($rss->channel['language'])) { - $this->_language = (string) $rss->channel['language']; + $this->_language = sanitizeVal((string) $rss->channel['language']); } if (!empty($rss->channel['generator'])) { - $this->_generator = (string) $rss->channel['generator']; + $this->_generator = sanitizeVal((string) $rss->channel['generator']); } if (!empty($rss->channel['copyright'])) { - $this->_copyright = (string) $rss->channel['copyright']; + $this->_copyright = sanitizeVal((string) $rss->channel['copyright']); } if (!empty($rss->channel['lastbuilddate'])) { - $this->_lastbuilddate = (string) $rss->channel['lastbuilddate']; + $this->_lastbuilddate = sanitizeVal((string) $rss->channel['lastbuilddate']); } if (!empty($rss->image['url'])) { - $this->_imageurl = (string) $rss->image['url']; + $this->_imageurl = sanitizeVal((string) $rss->image['url']); } if (!empty($rss->channel['link'])) { - $this->_link = (string) $rss->channel['link']; + $this->_link = sanitizeVal((string) $rss->channel['link']); } if (!empty($rss->channel['title'])) { - $this->_title = (string) $rss->channel['title']; + $this->_title = sanitizeVal((string) $rss->channel['title']); } if (!empty($rss->channel['description'])) { - $this->_description = (string) $rss->channel['description']; + $this->_description = sanitizeVal((string) $rss->channel['description']); } } @@ -383,40 +380,40 @@ class RssParser //var_dump($rss); if (!empty($conf->global->EXTERNALRSS_USE_SIMPLEXML)) { if (!empty($rss->generator)) { - $this->_generator = (string) $rss->generator; + $this->_generator = sanitizeVal((string) $rss->generator); } if (!empty($rss->lastbuilddate)) { - $this->_lastbuilddate = (string) $rss->modified; + $this->_lastbuilddate = sanitizeVal((string) $rss->modified); } if (!empty($rss->link->href)) { - $this->_link = (string) $rss->link->href; + $this->_link = sanitizeVal((string) $rss->link->href); } if (!empty($rss->title)) { - $this->_title = (string) $rss->title; + $this->_title = sanitizeVal((string) $rss->title); } if (!empty($rss->description)) { - $this->_description = (string) $rss->description; + $this->_description = sanitizeVal((string) $rss->description); } } else { //if (!empty($rss->channel['rss_language'])) $this->_language = (string) $rss->channel['rss_language']; if (!empty($rss->channel['generator'])) { - $this->_generator = (string) $rss->channel['generator']; + $this->_generator = sanitizeVal((string) $rss->channel['generator']); } //if (!empty($rss->channel['rss_copyright'])) $this->_copyright = (string) $rss->channel['rss_copyright']; if (!empty($rss->channel['modified'])) { - $this->_lastbuilddate = (string) $rss->channel['modified']; + $this->_lastbuilddate = sanitizeVal((string) $rss->channel['modified']); } //if (!empty($rss->image['rss_url'])) $this->_imageurl = (string) $rss->image['rss_url']; if (!empty($rss->channel['link'])) { - $this->_link = (string) $rss->channel['link']; + $this->_link = sanitizeVal((string) $rss->channel['link']); } if (!empty($rss->channel['title'])) { - $this->_title = (string) $rss->channel['title']; + $this->_title = sanitizeVal((string) $rss->channel['title']); } //if (!empty($rss->channel['rss_description'])) $this->_description = (string) $rss->channel['rss_description']; if (!empty($rss->channel)) { - $this->_imageurl = $this->getAtomImageUrl($rss->channel); + $this->_imageurl = sanitizeVal($this->getAtomImageUrl($rss->channel)); } } if (!empty($conf->global->EXTERNALRSS_USE_SIMPLEXML)) { @@ -437,19 +434,19 @@ class RssParser //var_dump($item);exit; if ($rss->_format == 'rss') { if (!empty($conf->global->EXTERNALRSS_USE_SIMPLEXML)) { - $itemLink = (string) $item->link; - $itemTitle = (string) $item->title; - $itemDescription = (string) $item->description; - $itemPubDate = (string) $item->pubDate; + $itemLink = sanitizeVal((string) $item->link); + $itemTitle = sanitizeVal((string) $item->title); + $itemDescription = sanitizeVal((string) $item->description); + $itemPubDate = sanitizeVal((string) $item->pubDate); $itemId = ''; $itemAuthor = ''; } else { - $itemLink = (string) $item['link']; - $itemTitle = (string) $item['title']; - $itemDescription = (string) $item['description']; - $itemPubDate = (string) $item['pubdate']; - $itemId = (string) $item['guid']; - $itemAuthor = (string) $item['author']; + $itemLink = sanitizeVal((string) $item['link']); + $itemTitle = sanitizeVal((string) $item['title']); + $itemDescription = sanitizeVal((string) $item['description']); + $itemPubDate = sanitizeVal((string) $item['pubdate']); + $itemId = sanitizeVal((string) $item['guid']); + $itemAuthor = sanitizeVal((string) $item['author']); } // Loop on each category @@ -461,19 +458,19 @@ class RssParser } } elseif ($rss->_format == 'atom') { if (!empty($conf->global->EXTERNALRSS_USE_SIMPLEXML)) { - $itemLink = (isset($item['link']) ? (string) $item['link'] : ''); - $itemTitle = (string) $item['title']; - $itemDescription = $this->getAtomItemDescription($item); - $itemPubDate = (string) $item['created']; - $itemId = (string) $item['id']; - $itemAuthor = (string) ($item['author'] ? $item['author'] : $item['author_name']); + $itemLink = (isset($item['link']) ? sanitizeVal((string) $item['link']) : ''); + $itemTitle = sanitizeVal((string) $item['title']); + $itemDescription = sanitizeVal($this->getAtomItemDescription($item)); + $itemPubDate = sanitizeVal((string) $item['created']); + $itemId = sanitizeVal((string) $item['id']); + $itemAuthor = sanitizeVal((string) ($item['author'] ? $item['author'] : $item['author_name'])); } else { - $itemLink = (isset($item['link']) ? (string) $item['link'] : ''); - $itemTitle = (string) $item['title']; - $itemDescription = $this->getAtomItemDescription($item); - $itemPubDate = (string) $item['created']; - $itemId = (string) $item['id']; - $itemAuthor = (string) ($item['author'] ? $item['author'] : $item['author_name']); + $itemLink = (isset($item['link']) ? sanitizeVal((string) $item['link']) : ''); + $itemTitle = sanitizeVal((string) $item['title']); + $itemDescription = sanitizeVal($this->getAtomItemDescription($item)); + $itemPubDate = sanitizeVal((string) $item['created']); + $itemId = sanitizeVal((string) $item['id']); + $itemAuthor = sanitizeVal((string) ($item['author'] ? $item['author'] : $item['author_name'])); } $itemCategory = array(); } else { diff --git a/htdocs/core/class/stats.class.php b/htdocs/core/class/stats.class.php index 60cdc5d5226..1ef45097594 100644 --- a/htdocs/core/class/stats.class.php +++ b/htdocs/core/class/stats.class.php @@ -119,10 +119,7 @@ abstract class Stats $fp = fopen($newpathofdestfile, 'w'); fwrite($fp, json_encode($data)); fclose($fp); - if (!empty($conf->global->MAIN_UMASK)) { - $newmask = $conf->global->MAIN_UMASK; - } - @chmod($newpathofdestfile, octdec($newmask)); + dolChmod($newpathofdestfile); $this->lastfetchdate[get_class($this).'_'.__FUNCTION__] = $nowgmt; } @@ -222,10 +219,7 @@ abstract class Stats if ($fp) { fwrite($fp, json_encode($data)); fclose($fp); - if (!empty($conf->global->MAIN_UMASK)) { - $newmask = $conf->global->MAIN_UMASK; - } - @chmod($newpathofdestfile, octdec($newmask)); + dolChmod($newpathofdestfile); } else { dol_syslog("Failed to write cache file", LOG_ERR); } @@ -332,10 +326,7 @@ abstract class Stats if ($fp) { fwrite($fp, json_encode($data)); fclose($fp); - if (!empty($conf->global->MAIN_UMASK)) { - $newmask = $conf->global->MAIN_UMASK; - } - @chmod($newpathofdestfile, octdec($newmask)); + dolChmod($newpathofdestfile); } $this->lastfetchdate[get_class($this).'_'.__FUNCTION__] = $nowgmt; } diff --git a/htdocs/core/class/translate.class.php b/htdocs/core/class/translate.class.php index 2315428b37a..7379877753b 100644 --- a/htdocs/core/class/translate.class.php +++ b/htdocs/core/class/translate.class.php @@ -41,6 +41,9 @@ class Translate public $cache_labels = array(); // Cache for labels return by getLabelFromKey method public $cache_currencies = array(); // Cache to store currency symbols private $cache_currencies_all_loaded = false; + public $origlang; + public $error; + public $errors = array(); /** @@ -416,7 +419,7 @@ class Translate * * Value for hash are: 1:Loaded from disk, 2:Not found, 3:Loaded from cache * - * @param Database $db Database handler + * @param DoliDB $db Database handler * @return int <0 if KO, 0 if already loaded or loading not required, >0 if OK */ public function loadFromDatabase($db) diff --git a/htdocs/core/class/utils.class.php b/htdocs/core/class/utils.class.php index 3e310ade5bc..f67702ca7c9 100644 --- a/htdocs/core/class/utils.class.php +++ b/htdocs/core/class/utils.class.php @@ -121,7 +121,7 @@ class Utils $filesarray = dol_dir_list($dolibarr_main_data_root, "files", 0, '.*\.log[\.0-9]*(\.gz)?$', 'install\.lock$', 'name', SORT_ASC, 0, 0, '', 1); } - if (!empty($conf->syslog->enabled)) { + if (isModEnabled('syslog')) { $filelog = $conf->global->SYSLOG_FILE; $filelog = preg_replace('/DOL_DATA_ROOT/i', DOL_DATA_ROOT, $filelog); @@ -494,9 +494,7 @@ class Utils } } - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($outputfile, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($outputfile); } else { $langs->load("errors"); dol_syslog("Failed to open file ".$outputfile, LOG_ERR); @@ -739,9 +737,7 @@ class Utils pclose($handlein); fclose($handle); } - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($outputfile, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($outputfile); } // Update with result @@ -1051,7 +1047,7 @@ class Utils fclose($sourcehandle); gzclose($gzfilehandle); - @chmod($logpath.'/'.$logname.'.1.gz', octdec(empty($conf->global->MAIN_UMASK) ? '0664' : $conf->global->MAIN_UMASK)); + dolChmod($logpath.'/'.$logname.'.1.gz'); } dol_delete_file($logpath.'/'.$logname, 0, 0, 0, null, false, 0); @@ -1061,7 +1057,7 @@ class Utils fclose($newlog); //var_dump($logpath.'/'.$logname." - ".octdec(empty($conf->global->MAIN_UMASK)?'0664':$conf->global->MAIN_UMASK)); - @chmod($logpath.'/'.$logname, octdec(empty($conf->global->MAIN_UMASK) ? '0664' : $conf->global->MAIN_UMASK)); + dolChmod($logpath.'/'.$logname); } } diff --git a/htdocs/core/customreports.php b/htdocs/core/customreports.php index fefdc5880c8..7a1f68e5c6c 100644 --- a/htdocs/core/customreports.php +++ b/htdocs/core/customreports.php @@ -93,19 +93,19 @@ $object = null; $ObjectClassName = ''; // Objects available by default $arrayoftype = array( - 'thirdparty' => array('label' => 'ThirdParties', 'ObjectClassName' => 'Societe', 'enabled' => isModEnabled('societe'), 'ClassPath' => "/societe/class/societe.class.php"), - 'contact' => array('label' => 'Contacts', 'ObjectClassName' => 'Contact', 'enabled' => isModEnabled('societ'), 'ClassPath' => "/contact/class/contact.class.php"), - 'proposal' => array('label' => 'Proposals', 'ObjectClassName' => 'Propal', 'enabled' => isModEnabled('propal'), 'ClassPath' => "/comm/propal/class/propal.class.php"), - 'order' => array('label' => 'Orders', 'ObjectClassName' => 'Commande', 'enabled' => isModEnabled('commande'), 'ClassPath' => "/commande/class/commande.class.php"), - 'invoice' => array('label' => 'Invoices', 'ObjectClassName' => 'Facture', 'enabled' => isModEnabled('facture'), 'ClassPath' => "/compta/facture/class/facture.class.php"), - 'invoice_template'=>array('label' => 'PredefinedInvoices', 'ObjectClassName' => 'FactureRec', 'enabled' => isModEnabled('facture'), 'ClassPath' => "/compta/class/facturerec.class.php", 'langs'=>'bills'), - 'contract' => array('label' => 'Contracts', 'ObjectClassName' => 'Contrat', 'enabled' => isModEnabled('contrat'), 'ClassPath' => "/contrat/class/contrat.class.php", 'langs'=>'contracts'), - 'contractdet' => array('label' => 'ContractLines', 'ObjectClassName' => 'ContratLigne', 'enabled' => isModEnabled('contrat'), 'ClassPath' => "/contrat/class/contrat.class.php", 'langs'=>'contracts'), - 'bom' => array('label' => 'BOM', 'ObjectClassName' => 'Bom', 'enabled' => isModEnabled('bom')), - 'mo' => array('label' => 'MO', 'ObjectClassName' => 'Mo', 'enabled' => isModEnabled('mrp'), 'ClassPath' => "/mrp/class/mo.class.php"), - 'ticket' => array('label' => 'Ticket', 'ObjectClassName' => 'Ticket', 'enabled' => isModEnabled('ticket')), - 'member' => array('label' => 'Adherent', 'ObjectClassName' => 'Adherent', 'enabled' => isModEnabled('adherent'), 'ClassPath' => "/adherents/class/adherent.class.php", 'langs'=>'members'), - 'cotisation' => array('label' => 'Subscriptions', 'ObjectClassName' => 'Subscription', 'enabled' => isModEnabled('adherent'), 'ClassPath' => "/adherents/class/subscription.class.php", 'langs'=>'members'), + 'thirdparty' => array('langs'=>'companies', 'label' => 'ThirdParties', 'picto'=>'company', 'ObjectClassName' => 'Societe', 'enabled' => isModEnabled('societe'), 'ClassPath' => "/societe/class/societe.class.php"), + 'contact' => array('label' => 'Contacts', 'picto'=>'contact', 'ObjectClassName' => 'Contact', 'enabled' => isModEnabled('societ'), 'ClassPath' => "/contact/class/contact.class.php"), + 'proposal' => array('label' => 'Proposals', 'picto'=>'proposal', 'ObjectClassName' => 'Propal', 'enabled' => isModEnabled('propal'), 'ClassPath' => "/comm/propal/class/propal.class.php"), + 'order' => array('label' => 'Orders', 'picto'=>'order', 'ObjectClassName' => 'Commande', 'enabled' => isModEnabled('commande'), 'ClassPath' => "/commande/class/commande.class.php"), + 'invoice' => array('langs'=>'facture', 'label' => 'Invoices', 'picto'=>'bill', 'ObjectClassName' => 'Facture', 'enabled' => isModEnabled('facture'), 'ClassPath' => "/compta/facture/class/facture.class.php"), + 'invoice_template'=>array('langs'=>'facture', 'label' => 'PredefinedInvoices', 'picto'=>'bill', 'ObjectClassName' => 'FactureRec', 'enabled' => isModEnabled('facture'), 'ClassPath' => "/compta/class/facturerec.class.php", 'langs'=>'bills'), + 'contract' => array('label' => 'Contracts', 'picto'=>'contract', 'ObjectClassName' => 'Contrat', 'enabled' => isModEnabled('contrat'), 'ClassPath' => "/contrat/class/contrat.class.php", 'langs'=>'contracts'), + 'contractdet' => array('label' => 'ContractLines', 'picto'=>'contract', 'ObjectClassName' => 'ContratLigne', 'enabled' => isModEnabled('contrat'), 'ClassPath' => "/contrat/class/contrat.class.php", 'langs'=>'contracts'), + 'bom' => array('label' => 'BOM', 'picto'=>'bom', 'ObjectClassName' => 'Bom', 'enabled' => isModEnabled('bom')), + 'mo' => array('label' => 'MO', 'picto'=>'mrp', 'ObjectClassName' => 'Mo', 'enabled' => isModEnabled('mrp'), 'ClassPath' => "/mrp/class/mo.class.php"), + 'ticket' => array('label' => 'Ticket', 'picto'=>'ticket', 'ObjectClassName' => 'Ticket', 'enabled' => isModEnabled('ticket')), + 'member' => array('label' => 'Adherent', 'picto'=>'member', 'ObjectClassName' => 'Adherent', 'enabled' => isModEnabled('adherent'), 'ClassPath' => "/adherents/class/adherent.class.php", 'langs'=>'members'), + 'cotisation' => array('label' => 'Subscriptions', 'picto'=>'member', 'ObjectClassName' => 'Subscription', 'enabled' => isModEnabled('adherent'), 'ClassPath' => "/adherents/class/subscription.class.php", 'langs'=>'members'), ); // Complete $arrayoftype by external modules @@ -432,18 +432,21 @@ $limit = 0; print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, -1, 'object_action', 0, $nav.''.$newcardbutton, '', $limit, 1, 0, 1, $viewmode); +foreach ($newarrayoftype as $tmpkey => $tmpval) { + $newarrayoftype[$tmpkey]['label'] = img_picto('', $tmpval['picto'], 'class="pictofixedwidth"').$langs->trans($tmpval['label']); +} print '
'; // Select object print '
'; print '
'.$langs->trans("StatisticsOn").'
'; -print $form->selectarray('objecttype', $newarrayoftype, $objecttype, 0, 0, 0, '', 1, 0, 0, '', 'minwidth200', 1); +print $form->selectarray('objecttype', $newarrayoftype, $objecttype, 0, 0, 0, '', 1, 0, 0, '', 'minwidth200', 1, '', 0, 1); if (empty($conf->use_javascript_ajax)) { print ''; } else { print ' - '."\n"; + print ''."\n"; } else { print ''.$langs->trans("Calendar").''; } @@ -93,7 +93,7 @@ $tradTemp = array( $langs->trans("November"), $langs->trans("December") ); -print ' + "; + gtag(\'config\', \''.trim($tmptag).'\'); + '; print "\n"; } } @@ -9769,7 +9786,7 @@ function dolExplodeIntoArray($string, $delimiter = ';', $kv = '=') function dol_set_focus($selector) { print "\n".''."\n"; - print ''."\n"; + print ''."\n"; } @@ -9798,7 +9815,7 @@ function dol_getmypid() * If param $mode is 0, can contains several keywords separated with a space or | * like "keyword1 keyword2" = We want record field like keyword1 AND field like keyword2 * or like "keyword1|keyword2" = We want record field like keyword1 OR field like keyword2 - * If param $mode is 1, can contains an operator <, > or = like "<10" or ">=100.5 < 1000" + * If param $mode is 1, can contains an operator <, > or = like "<10" or ">=100.5 < -1000" * If param $mode is 2, can contains a list of int id separated by comma like "1,3,4" * If param $mode is 3, can contains a list of string separated by comma like "a,b,c" * @param integer $mode 0=value is list of keyword strings, 1=value is a numeric test (Example ">5.5 <10"), 2=value is a list of ID separated with comma (Example '1,3,4') @@ -9836,23 +9853,35 @@ function natural_search($fields, $value, $mode = 0, $nofirstand = 0) $newres = ''; foreach ($fields as $field) { if ($mode == 1) { - $operator = '='; - $newcrit = preg_replace('/([!<>=]+)/', '', $crit); - - $reg = array(); - preg_match('/([!<>=]+)/', $crit, $reg); - if (!empty($reg[1])) { - $operator = $reg[1]; - } - if ($newcrit != '') { - $numnewcrit = price2num($newcrit); - if (is_numeric($numnewcrit)) { - $newres .= ($i2 > 0 ? ' OR ' : '').$field.' '.$operator.' '.((float) $numnewcrit); // should be a numeric - } else { - $newres .= ($i2 > 0 ? ' OR ' : '').'1 = 2'; // force false + $tmpcrits = explode('|', $crit); + $i3 = 0; // count the nb of valid criteria added for this field + foreach ($tmpcrits as $tmpcrit) { + if ($tmpcrit !== '0' && empty($tmpcrit)) { + continue; + } + $tmpcrit = trim($tmpcrit); + + $newres .= (($i2 > 0 || $i3 > 0) ? ' OR ' : ''); + + $operator = '='; + $newcrit = preg_replace('/([!<>=]+)/', '', $tmpcrit); + + $reg = array(); + preg_match('/([!<>=]+)/', $tmpcrit, $reg); + if (!empty($reg[1])) { + $operator = $reg[1]; + } + if ($newcrit != '') { + $numnewcrit = price2num($newcrit); + if (is_numeric($numnewcrit)) { + $newres .= $field.' '.$operator.' '.((float) $numnewcrit); // should be a numeric + } else { + $newres .= '1 = 2'; // force false, we received a corrupted data + } + $i3++; // a criteria was added to string } - $i2++; // a criteria was added to string } + $i2++; } elseif ($mode == 2 || $mode == -2) { $crit = preg_replace('/[^0-9,]/', '', $crit); // ID are always integer $newres .= ($i2 > 0 ? ' OR ' : '').$field." ".($mode == -2 ? 'NOT ' : ''); @@ -9894,28 +9923,36 @@ function natural_search($fields, $value, $mode = 0, $nofirstand = 0) } } } - } else // $mode=0 - { + } else { // $mode=0 $tmpcrits = explode('|', $crit); - $i3 = 0; + $i3 = 0; // count the nb of valid criteria added for this field foreach ($tmpcrits as $tmpcrit) { if ($tmpcrit !== '0' && empty($tmpcrit)) { continue; } + $tmpcrit = trim($tmpcrit); - $newres .= (($i2 > 0 || $i3 > 0) ? ' OR ' : ''); + if ($tmpcrit == '^$') { // If we search empty, we must combined different fields with AND + $newres .= (($i2 > 0 || $i3 > 0) ? ' AND ' : ''); + } else { + $newres .= (($i2 > 0 || $i3 > 0) ? ' OR ' : ''); + } if (preg_match('/\.(id|rowid)$/', $field)) { // Special case for rowid that is sometimes a ref so used as a search field - $newres .= $field." = ".(is_numeric(trim($tmpcrit)) ? ((float) trim($tmpcrit)) : '0'); + $newres .= $field." = ".(is_numeric($tmpcrit) ? ((float) $tmpcrit) : '0'); } else { - $tmpcrit = trim($tmpcrit); $tmpcrit2 = $tmpcrit; $tmpbefore = '%'; $tmpafter = '%'; + $tmps = ''; + if (preg_match('/^!/', $tmpcrit)) { - $newres .= $field." NOT LIKE '"; // ! as exclude character + $tmps .= $field." NOT LIKE "; // ! as exclude character $tmpcrit2 = preg_replace('/^!/', '', $tmpcrit2); - } else $newres .= $field." LIKE '"; + } else { + $tmps .= $field." LIKE "; + } + $tmps .= "'"; if (preg_match('/^[\^\$]/', $tmpcrit)) { $tmpbefore = ''; @@ -9925,12 +9962,17 @@ function natural_search($fields, $value, $mode = 0, $nofirstand = 0) $tmpafter = ''; $tmpcrit2 = preg_replace('/[\^\$]$/', '', $tmpcrit2); } + + if ($tmpcrit2 == '' || preg_match('/^!/', $tmpcrit)) { + $tmps = "(".$tmps; + } + $newres .= $tmps; $newres .= $tmpbefore; $newres .= $db->escape($tmpcrit2); $newres .= $tmpafter; $newres .= "'"; - if ($tmpcrit2 == '') { - $newres .= " OR ".$field." IS NULL"; + if ($tmpcrit2 == '' || preg_match('/^!/', $tmpcrit)) { + $newres .= " OR ".$field." IS NULL)"; } } @@ -9940,13 +9982,14 @@ function natural_search($fields, $value, $mode = 0, $nofirstand = 0) } $i++; } + if ($newres) { $res = $res.($res ? ' AND ' : '').($i2 > 1 ? '(' : '').$newres.($i2 > 1 ? ')' : ''); } $j++; } $res = ($nofirstand ? "" : " AND ")."(".$res.")"; - //print 'xx'.$res.'yy'; + return $res; } @@ -10071,7 +10114,7 @@ function getAdvancedPreviewUrl($modulepart, $relativepath, $alldata = 0, $param function ajax_autoselect($htmlname, $addlink = '', $textonlink = 'Link') { global $langs; - $out = '';*/ - print ''; // Note @@ -1656,15 +1647,6 @@ function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsr //$tableCell.=' '; print $tableCell; - // Comment for avoid unnecessary multiple calculation - /*$modeinput = 'hours'; - - print '';*/ - print ''; // Note @@ -2438,13 +2420,16 @@ function searchTaskInChild(&$inc, $parent, &$lines, &$taskrole) * @param int $status -1=No filter on statut, 0 or 1 = Filter on status * @param array $listofoppstatus List of opportunity status * @param array $hiddenfields List of info to not show ('projectlabel', 'declaredprogress', '...', ) + * @param int $max Max nb of record to show in HTML list * @return void */ -function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks = 0, $status = -1, $listofoppstatus = array(), $hiddenfields = array()) +function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks = 0, $status = -1, $listofoppstatus = array(), $hiddenfields = array(), $max = 0) { global $langs, $conf, $user; global $theme_datacolor; + $maxofloop = (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD); + require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; $listofstatus = array_keys($listofoppstatus); @@ -2475,8 +2460,6 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks $title = $langs->trans("Projects").' '.$langs->trans($projectstatic->statuts_long[$status]); } - $arrayidtypeofcontact = array(); - print ''; print '
'; print ''; @@ -2555,11 +2538,15 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks $resql = $db->query($sql2); if ($resql) { + $othernb = 0; $total_task = 0; $total_opp_amount = 0; $ponderated_opp_amount = 0; + $total_plannedworkload = 0; + $total_declaredprogressworkload = 0; $num = $db->num_rows($resql); + $nbofloop = min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD)); $i = 0; print ''; @@ -2586,11 +2573,23 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks } print "\n"; - $total_plannedworkload = 0; - $total_declaredprogressworkload = 0; - while ($i < $num) { + while ($i < $nbofloop) { $objp = $db->fetch_object($resql); + if ($max && $i >= $max) { + $othernb++; + $i++; + $total_task += $objp->nb; + $total_opp_amount += $objp->opp_amount; + $opp_weighted_amount = $objp->opp_percent * $objp->opp_amount / 100; + $ponderated_opp_amount += price2num($opp_weighted_amount); + $plannedworkload = $objp->planned_workload; + $total_plannedworkload += $plannedworkload; + $declaredprogressworkload = $objp->declared_progess_workload; + $total_declaredprogressworkload += $declaredprogressworkload; + continue; + } + $projectstatic->id = $objp->projectid; $projectstatic->user_author_id = $objp->fk_user_creat; $projectstatic->public = $objp->public; @@ -2697,13 +2696,21 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks print "\n"; - $total_task = $total_task + $objp->nb; - $total_opp_amount = $total_opp_amount + $objp->opp_amount; + $total_task += $objp->nb; + $total_opp_amount += $objp->opp_amount; } $i++; } + if ($othernb) { + print ''; + print ''; + print "\n"; + } + print ''; print '"; if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { @@ -2867,13 +2874,13 @@ function getTaskProgressView($task, $label = true, $progressNumber = true, $hide // good $out .= '
'; if (!empty($task->progress)) { - $out .= '
'; + $out .= '
'; } $out .= '
'; } else { // bad $out .= '
'; - $out .= '
'; + $out .= '
'; $out .= '
'; } $out .= ' '; diff --git a/htdocs/core/lib/propal.lib.php b/htdocs/core/lib/propal.lib.php index 3d380a3904a..b5e459c8637 100644 --- a/htdocs/core/lib/propal.lib.php +++ b/htdocs/core/lib/propal.lib.php @@ -47,10 +47,10 @@ function propal_prepare_head($object) $langs->load("sendings"); $text = ''; $head[$h][0] = DOL_URL_ROOT.'/expedition/propal.php?id='.$object->id; - if ($conf->expedition_bon->enabled) { + if (isModEnabled('expedition_bon')) { $text = $langs->trans("Shipment"); } - if ($conf->delivery_note->enabled) { + if (isModEnabled('delivery_note')) { $text .= '/'.$langs->trans("Receivings"); } $head[$h][1] = $text; diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index dcead2541bd..66de4ca6017 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -811,7 +811,7 @@ function checkUserAccessToObject($user, array $featuresarray, $object = 0, $tabl // Array to define rules of checks to do $check = array('adherent', 'banque', 'bom', 'don', 'mrp', 'user', 'usergroup', 'payment', 'payment_supplier', 'product', 'produit', 'service', 'produit|service', 'categorie', 'resource', 'expensereport', 'holiday', 'salaries', 'website', 'recruitment'); // Test on entity only (Objects with no link to company) $checksoc = array('societe'); // Test for object Societe - $checkother = array('contact', 'agenda'); // Test on entity + link to third party on field $dbt_keyfield. Allowed if link is empty (Ex: contacts...). + $checkother = array('contact', 'agenda', 'contrat'); // Test on entity + link to third party on field $dbt_keyfield. Allowed if link is empty (Ex: contacts...). $checkproject = array('projet', 'project'); // Test for project object $checktask = array('projet_task'); // Test for task object $checkhierarchy = array('expensereport', 'holiday'); // check permission among the hierarchy of user diff --git a/htdocs/core/lib/security2.lib.php b/htdocs/core/lib/security2.lib.php index 93da106aebd..c68bb49d93b 100644 --- a/htdocs/core/lib/security2.lib.php +++ b/htdocs/core/lib/security2.lib.php @@ -457,7 +457,7 @@ function encodedecode_dbpassconf($level = 0) // It's config file, so we set read permission for creator only. // Should set permission to web user and groups for users used by batch - //@chmod($file, octdec('0600')); + //dolChmod($file, '0600'); return 1; } else { @@ -570,7 +570,8 @@ function dolJSToSetRandomPassword($htmlname, $htmlnameofbutton = 'generate_token global $conf; if (!empty($conf->use_javascript_ajax)) { - print "\n".''."\n"; } elseif ($type == 'qa') { $ret = ''."\n"; - $ret .= ''; + $out .= ''; $out .= ''."\n"; // Reddit @@ -931,7 +931,7 @@ function getSocialNetworkSharingLinks() // Facebook $out .= ''; @@ -1047,11 +1047,11 @@ if (!empty($arrayfields['f.date_lim_reglement']['checked'])) { print ''; if (!$i) { $totalarray['nbfield']++; @@ -1539,7 +1540,7 @@ if ($num > 0) { // Alias if (!empty($arrayfields['s.name_alias']['checked'])) { print ''; if (!$i) { $totalarray['nbfield']++; @@ -1547,8 +1548,8 @@ if ($num > 0) { } // Town if (!empty($arrayfields['s.town']['checked'])) { - print ''; if (!$i) { $totalarray['nbfield']++; @@ -1556,7 +1557,7 @@ if ($num > 0) { } // Zip if (!empty($arrayfields['s.zip']['checked'])) { - print ''; if (!$i) { @@ -1565,7 +1566,9 @@ if ($num > 0) { } // State if (!empty($arrayfields['state.nom']['checked'])) { - print "\n"; + print '\n"; if (!$i) { $totalarray['nbfield']++; } @@ -1829,6 +1832,7 @@ if ($num > 0) { print "\n"; } + $i++; } @@ -1868,8 +1872,8 @@ $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortor $urlsource .= str_replace('&', '&', $param); $filedir = $diroutputmassaction; -$genallowed = $user->rights->facture->lire; -$delallowed = $user->rights->facture->creer; +$genallowed = $user->hasRight('facture', 'lire'); +$delallowed = $user->hasRight('facture', 'creer'); $title = ''; print $formfile->showdocuments('massfilesarea_supplier_invoice', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty); diff --git a/htdocs/ftp/index.php b/htdocs/ftp/index.php index e6c1aac1372..b73748ecf23 100644 --- a/htdocs/ftp/index.php +++ b/htdocs/ftp/index.php @@ -287,9 +287,7 @@ if ($action == 'download') { if ($result) { - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($localfile, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($localfile); // Define mime type $type = 'application/octet-stream'; diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php index e3a605a09aa..4717db8bea0 100644 --- a/htdocs/holiday/class/holiday.class.php +++ b/htdocs/holiday/class/holiday.class.php @@ -1311,13 +1311,31 @@ class Holiday extends CommonObject global $conf, $langs; $langs->load('holiday'); + $nofetch = !empty($params['nofetch']); - $datas = []; + $datas = array(); $datas['picto'] = img_picto('', $this->picto).' '.$langs->trans("Holiday").''; if (isset($this->statut)) { $datas['picto'] .= ' '.$this->getLibStatut(5); } - $datas['label'] = '
'.$langs->trans('Ref').': '.$this->ref; + $datas['ref'] = '
'.$langs->trans('Ref').': '.$this->ref; + // show type for this record only in ajax to not overload lists + if (!$nofetch && !empty($this->fk_type)) { + $typeleaves = $this->getTypes(1, -1); + $labeltoshow = (($typeleaves[$this->fk_type]['code'] && $langs->trans($typeleaves[$this->fk_type]['code']) != $typeleaves[$this->fk_type]['code']) ? $langs->trans($typeleaves[$this->fk_type]['code']) : $typeleaves[$this->fk_type]['label']); + $datas['type'] = '
'.$langs->trans("Type") . ': ' . (empty($labeltoshow) ? $langs->trans("TypeWasDisabledOrRemoved", $this->fk_type) : $labeltoshow); + } + if (isset($this->halfday) && !empty($this->date_debut) && !empty($this->date_fin)) { + $listhalfday = array( + 'morning' => $langs->trans("Morning"), + "afternoon" => $langs->trans("Afternoon") + ); + $starthalfday = ($this->halfday == -1 || $this->halfday == 2) ? 'afternoon' : 'morning'; + $endhalfday = ($this->halfday == 1 || $this->halfday == 2) ? 'morning' : 'afternoon'; + $datas['date_start'] = '
'.$langs->trans('DateDebCP') . ': '. dol_print_date($this->date_debut, 'day') . '  '.$langs->trans($listhalfday[$starthalfday]).''; + $datas['date_end'] = '
'.$langs->trans('DateFinCP') . ': '. dol_print_date($this->date_fin, 'day') . '  '.$langs->trans($listhalfday[$endhalfday]).''; + } + return $datas; } @@ -1339,13 +1357,13 @@ class Holiday extends CommonObject $params = [ 'id' => $this->id, 'objecttype' => $this->element, + 'nofetch' => 1, ]; $classfortooltip = 'classfortooltip'; $dataparams = ''; if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) { $classfortooltip = 'classforajaxtooltip'; - $dataparams = ' data-params='.json_encode($params); - // $label = $langs->trans('Loading'); + $dataparams = " data-params='".json_encode($params)."'"; } $label = implode($this->getTooltipContentArray($params)); @@ -1996,7 +2014,7 @@ class Holiday extends CommonObject * Return list of people with permission to validate leave requests. * Search for permission "approve leave requests" * - * @return array Array of user ids + * @return array|int Array of user ids or -1 if error */ public function fetch_users_approver_holiday() { diff --git a/htdocs/holiday/list.php b/htdocs/holiday/list.php index 05568e08992..421da582e0d 100644 --- a/htdocs/holiday/list.php +++ b/htdocs/holiday/list.php @@ -832,7 +832,7 @@ if ($resql) { if ($mode == 'kanban') { if ($i == 0) { print ''; - print ''; + // print ''; // Fields from hook @@ -807,7 +808,7 @@ if ($action != "create" && $action != "edit") { // If no record found if ($num == 0) { - $colspan = 1; + $colspan = 2; foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) { $colspan++; diff --git a/htdocs/hrm/skill_list.php b/htdocs/hrm/skill_list.php index 03302a812ff..e9d3564c1a4 100644 --- a/htdocs/hrm/skill_list.php +++ b/htdocs/hrm/skill_list.php @@ -556,7 +556,7 @@ while ($i < ($limit ? min($num, $limit) : $num)) { if ($mode == 'kanban') { if ($i == 0) { print ''; print ''; diff --git a/htdocs/includes/odtphp/odf.php b/htdocs/includes/odtphp/odf.php index 0bba0e59345..47226a60829 100644 --- a/htdocs/includes/odtphp/odf.php +++ b/htdocs/includes/odtphp/odf.php @@ -880,7 +880,7 @@ IMG; pclose($handlein); fclose($handle); } - if (! empty($conf->global->MAIN_UMASK)) @chmod($outputfile, octdec($conf->global->MAIN_UMASK)); + dolChmod($outputfile); } if ($retval == 0) { diff --git a/htdocs/includes/tcpdi/tcpdi_parser.php b/htdocs/includes/tcpdi/tcpdi_parser.php index 174c496d4f4..ef4162d5f4f 100644 --- a/htdocs/includes/tcpdi/tcpdi_parser.php +++ b/htdocs/includes/tcpdi/tcpdi_parser.php @@ -715,8 +715,7 @@ class tcpdi_parser { $next = strcspn($data, "\r\n", $offset); if ($next > 0) { $offset += $next; - list($obj, $unused) = $this->getRawObject($offset, $data); - return $obj; + return $this->getRawObject($offset, $data); } break; } diff --git a/htdocs/install/doctemplates/websites/website_template-corporate/containers/wrapper.php b/htdocs/install/doctemplates/websites/website_template-corporate/containers/wrapper.php index 26adb3ef220..9a8a8d5ab48 100644 --- a/htdocs/install/doctemplates/websites/website_template-corporate/containers/wrapper.php +++ b/htdocs/install/doctemplates/websites/website_template-corporate/containers/wrapper.php @@ -156,7 +156,7 @@ if ($rss) { // Create temp file $outputfiletmp = tempnam($dir_temp, 'tmp'); // Temporary file (allow call of function by different threads - @chmod($outputfiletmp, octdec($conf->global->MAIN_UMASK)); + dolChmod($outputfiletmp); // Write file $result = build_rssfile($format, $title, $desc, $eventarray, $outputfiletmp, '', $website->virtualhost.'/wrapper.php?rss=1'.($l ? '&l='.$l : ''), $l); diff --git a/htdocs/install/doctemplates/websites/website_template-homesubmenu/containers/wrapper.php b/htdocs/install/doctemplates/websites/website_template-homesubmenu/containers/wrapper.php index 26adb3ef220..9a8a8d5ab48 100644 --- a/htdocs/install/doctemplates/websites/website_template-homesubmenu/containers/wrapper.php +++ b/htdocs/install/doctemplates/websites/website_template-homesubmenu/containers/wrapper.php @@ -156,7 +156,7 @@ if ($rss) { // Create temp file $outputfiletmp = tempnam($dir_temp, 'tmp'); // Temporary file (allow call of function by different threads - @chmod($outputfiletmp, octdec($conf->global->MAIN_UMASK)); + dolChmod($outputfiletmp); // Write file $result = build_rssfile($format, $title, $desc, $eventarray, $outputfiletmp, '', $website->virtualhost.'/wrapper.php?rss=1'.($l ? '&l='.$l : ''), $l); diff --git a/htdocs/install/doctemplates/websites/website_template-noimg/containers/wrapper.php b/htdocs/install/doctemplates/websites/website_template-noimg/containers/wrapper.php index 26adb3ef220..9a8a8d5ab48 100644 --- a/htdocs/install/doctemplates/websites/website_template-noimg/containers/wrapper.php +++ b/htdocs/install/doctemplates/websites/website_template-noimg/containers/wrapper.php @@ -156,7 +156,7 @@ if ($rss) { // Create temp file $outputfiletmp = tempnam($dir_temp, 'tmp'); // Temporary file (allow call of function by different threads - @chmod($outputfiletmp, octdec($conf->global->MAIN_UMASK)); + dolChmod($outputfiletmp); // Write file $result = build_rssfile($format, $title, $desc, $eventarray, $outputfiletmp, '', $website->virtualhost.'/wrapper.php?rss=1'.($l ? '&l='.$l : ''), $l); diff --git a/htdocs/install/doctemplates/websites/website_template-onepageblackpurple/containers/wrapper.php b/htdocs/install/doctemplates/websites/website_template-onepageblackpurple/containers/wrapper.php index 26adb3ef220..9a8a8d5ab48 100644 --- a/htdocs/install/doctemplates/websites/website_template-onepageblackpurple/containers/wrapper.php +++ b/htdocs/install/doctemplates/websites/website_template-onepageblackpurple/containers/wrapper.php @@ -156,7 +156,7 @@ if ($rss) { // Create temp file $outputfiletmp = tempnam($dir_temp, 'tmp'); // Temporary file (allow call of function by different threads - @chmod($outputfiletmp, octdec($conf->global->MAIN_UMASK)); + dolChmod($outputfiletmp); // Write file $result = build_rssfile($format, $title, $desc, $eventarray, $outputfiletmp, '', $website->virtualhost.'/wrapper.php?rss=1'.($l ? '&l='.$l : ''), $l); diff --git a/htdocs/install/doctemplates/websites/website_template-restaurant/containers/wrapper.php b/htdocs/install/doctemplates/websites/website_template-restaurant/containers/wrapper.php index 26adb3ef220..9a8a8d5ab48 100644 --- a/htdocs/install/doctemplates/websites/website_template-restaurant/containers/wrapper.php +++ b/htdocs/install/doctemplates/websites/website_template-restaurant/containers/wrapper.php @@ -156,7 +156,7 @@ if ($rss) { // Create temp file $outputfiletmp = tempnam($dir_temp, 'tmp'); // Temporary file (allow call of function by different threads - @chmod($outputfiletmp, octdec($conf->global->MAIN_UMASK)); + dolChmod($outputfiletmp); // Write file $result = build_rssfile($format, $title, $desc, $eventarray, $outputfiletmp, '', $website->virtualhost.'/wrapper.php?rss=1'.($l ? '&l='.$l : ''), $l); diff --git a/htdocs/install/doctemplates/websites/website_template-stellar/containers/wrapper.php b/htdocs/install/doctemplates/websites/website_template-stellar/containers/wrapper.php index 4f1c281ee93..648b0e3ef6a 100644 --- a/htdocs/install/doctemplates/websites/website_template-stellar/containers/wrapper.php +++ b/htdocs/install/doctemplates/websites/website_template-stellar/containers/wrapper.php @@ -137,7 +137,7 @@ if ($rss) { // Create temp file $outputfiletmp = tempnam($dir_temp, 'tmp'); // Temporary file (allow call of function by different threads - @chmod($outputfiletmp, octdec($conf->global->MAIN_UMASK)); + dolChmod($outputfiletmp); // Write file $result = build_rssfile($format, $title, $desc, $eventarray, $outputfiletmp, '', $website->virtualhost.'/wrapper.php?rss=1'.($l ? '&l='.$l : ''), $l); diff --git a/htdocs/install/inc.php b/htdocs/install/inc.php index 970fd40261b..9dc12b18277 100644 --- a/htdocs/install/inc.php +++ b/htdocs/install/inc.php @@ -232,6 +232,9 @@ if ($islocked) { // Pages are locked // Force usage of log file for install and upgrades +if (!isset($conf->syslog) || !is_object($conf->syslog)) { + $conf->syslog = new stdClass(); +} $conf->syslog->enabled = 1; $conf->global->SYSLOG_LEVEL = constant('LOG_DEBUG'); if (!defined('SYSLOG_HANDLERS')) { @@ -341,6 +344,9 @@ function conf($dolibarr_main_document_root) $conf->db->dolibarr_main_db_cryptkey = $dolibarr_main_db_cryptkey; // Force usage of log file for install and upgrades + if (!isset($conf->syslog) || !is_object($conf->syslog)) { + $conf->syslog = new stdClass(); + } $conf->syslog->enabled = 1; $conf->global->SYSLOG_LEVEL = constant('LOG_DEBUG'); if (!defined('SYSLOG_HANDLERS')) { diff --git a/htdocs/install/mysql/data/llx_c_socialnetworks.sql b/htdocs/install/mysql/data/llx_c_socialnetworks.sql index 7741f8cdfef..2283832a98f 100644 --- a/htdocs/install/mysql/data/llx_c_socialnetworks.sql +++ b/htdocs/install/mysql/data/llx_c_socialnetworks.sql @@ -56,8 +56,8 @@ INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES ( 1, 'vero', 'Vero', 'https://vero.co/{socialid}', '', 0); INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES ( 1, 'viadeo', 'Viadeo', 'https://fr.viadeo.com/fr/{socialid}', 'fa-viadeo', 0); INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES ( 1, 'viber', 'Viber', '{socialid}', '', 0); -INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES ( 1, 'vimeo', 'Vimeo', '{socialid}', '', 0); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES ( 1, 'vimeo', 'Vimeo', '{socialid}', 'fa-vimeo', 0); INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES ( 1, 'whatsapp', 'Whatsapp', '{socialid}', 'fa-whatsapp', 1); -INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES ( 1, 'wikipedia', 'Wikipedia', '{socialid}', '', 0); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES ( 1, 'wikipedia', 'Wikipedia', '{socialid}', 'fa-wikipedia-w', 0); INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES ( 1, 'xing', 'Xing', '{socialid}', 'fa-xing', 0); INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES ( 1, 'youtube', 'Youtube', 'https://www.youtube.com/{socialid}', 'fa-youtube', 1); diff --git a/htdocs/install/mysql/migration/16.0.0-17.0.0.sql b/htdocs/install/mysql/migration/16.0.0-17.0.0.sql index a4b7fc3a72e..ed7bf8756a7 100644 --- a/htdocs/install/mysql/migration/16.0.0-17.0.0.sql +++ b/htdocs/install/mysql/migration/16.0.0-17.0.0.sql @@ -398,3 +398,7 @@ ALTER TABLE llx_c_tva ADD COLUMN use_default tinyint DEFAULT 0; ALTER TABLE llx_commande_fournisseurdet MODIFY COLUMN ref varchar(128); ALTER TABLE llx_facture_fourn_det MODIFY COLUMN ref varchar(128); + +ALTER TABLE llx_projet ADD COLUMN extraparams varchar(255); + + diff --git a/htdocs/install/mysql/tables/llx_commande.sql b/htdocs/install/mysql/tables/llx_commande.sql index 67712178bd3..e64ce7ff14f 100644 --- a/htdocs/install/mysql/tables/llx_commande.sql +++ b/htdocs/install/mysql/tables/llx_commande.sql @@ -77,7 +77,7 @@ create table llx_commande fk_incoterms integer, -- for incoterms location_incoterms varchar(255), -- for incoterms import_key varchar(14), - extraparams varchar(255), -- for stock other parameters with json format + extraparams varchar(255), -- to save other parameters with json format fk_multicurrency integer, multicurrency_code varchar(3), diff --git a/htdocs/install/mysql/tables/llx_projet.sql b/htdocs/install/mysql/tables/llx_projet.sql index 3b8bf1be05b..531f0992f2c 100644 --- a/htdocs/install/mysql/tables/llx_projet.sql +++ b/htdocs/install/mysql/tables/llx_projet.sql @@ -19,45 +19,46 @@ create table llx_projet ( - rowid integer AUTO_INCREMENT PRIMARY KEY, - fk_soc integer, - datec datetime, -- date creation project - tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - dateo date, -- date start project - datee date, -- date end project - ref varchar(50), - entity integer DEFAULT 1 NOT NULL, -- multi company id - title varchar(255) NOT NULL, - description text, - fk_user_creat integer NOT NULL, -- createur du projet - fk_user_modif integer, - public integer, -- project is public or not - fk_statut integer DEFAULT 0 NOT NULL, -- open or close - fk_opp_status integer DEFAULT NULL, -- if project is used to manage opportunities - opp_percent double(5,2), - fk_opp_status_end integer DEFAULT NULL, -- if project is used to manage opportunities (the opportunity status the project has when set to lose) - date_close datetime DEFAULT NULL, - fk_user_close integer DEFAULT NULL, - note_private text, - note_public text, - email_msgid varchar(175), -- if project or lead is created by email collector, we store here MSG ID. Do not use a too large value, it generates trouble with unique index - --budget_days real, -- budget in days is sum of field planned_workload of tasks - opp_amount double(24,8), - budget_amount double(24,8), + rowid integer AUTO_INCREMENT PRIMARY KEY, + fk_soc integer, + datec datetime, -- date creation project + tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + dateo date, -- date start project + datee date, -- date end project + ref varchar(50), + entity integer DEFAULT 1 NOT NULL, -- multi company id + title varchar(255) NOT NULL, + description text, + fk_user_creat integer NOT NULL, -- createur du projet + fk_user_modif integer, + public integer, -- project is public or not + fk_statut integer DEFAULT 0 NOT NULL, -- open or close + fk_opp_status integer DEFAULT NULL, -- if project is used to manage opportunities + opp_percent double(5,2), + fk_opp_status_end integer DEFAULT NULL, -- if project is used to manage opportunities (the opportunity status the project has when set to lose) + date_close datetime DEFAULT NULL, + fk_user_close integer DEFAULT NULL, + note_private text, + note_public text, + email_msgid varchar(175), -- if project or lead is created by email collector, we store here MSG ID. Do not use a too large value, it generates trouble with unique index + --budget_days real, -- budget in days is sum of field planned_workload of tasks + opp_amount double(24,8), + budget_amount double(24,8), usage_opportunity integer DEFAULT 0, -- Set to 1 if project is used to follow an opportunity usage_task integer DEFAULT 1, -- Set to 1 if project is used to manage tasks and/or record timesheet usage_bill_time integer DEFAULT 0, -- Set to 1 if time spent must be converted into invoices usage_organize_event integer DEFAULT 0, -- Set to 1 if you want to use project to organize an event or receive attendees registration - date_start_event datetime, -- date start event - date_end_event datetime, -- date end event - location varchar(255), -- location + date_start_event datetime, -- date start event + date_end_event datetime, -- date end event + location varchar(255), -- location accept_conference_suggestions integer DEFAULT 0, -- Set to 1 if you want to allow unknown people to suggest conferences - accept_booth_suggestions integer DEFAULT 0, -- Set to 1 if you want to Allow unknown people to suggest booth + accept_booth_suggestions integer DEFAULT 0, -- Set to 1 if you want to Allow unknown people to suggest booth max_attendees integer DEFAULT 0, price_registration double(24,8), - price_booth double(24,8), - model_pdf varchar(255), - ip varchar(250), --ip used to create record (for public submission page) - last_main_doc varchar(255), -- relative filepath+filename of last main generated document - import_key varchar(14) -- Import key + price_booth double(24,8), + model_pdf varchar(255), + ip varchar(250), -- ip used to create record (for public submission page) + last_main_doc varchar(255), -- relative filepath+filename of last main generated document + import_key varchar(14), -- Import key + extraparams varchar(255) -- to save other parameters with json format )ENGINE=innodb; diff --git a/htdocs/install/step5.php b/htdocs/install/step5.php index 6598843b882..40e1c1b799e 100644 --- a/htdocs/install/step5.php +++ b/htdocs/install/step5.php @@ -443,11 +443,12 @@ if ($action == "set") { $fp = @fopen($lockfile, "w"); if ($fp) { if (empty($force_install_lockinstall) || $force_install_lockinstall == 1) { - $force_install_lockinstall = 444; // For backward compatibility + $force_install_lockinstall = '444'; // For backward compatibility } fwrite($fp, "This is a lock file to prevent use of install or upgrade pages (set with permission ".$force_install_lockinstall.")"); fclose($fp); - @chmod($lockfile, octdec($force_install_lockinstall)); + dolChmod($lockfile, $force_install_lockinstall); + $createlock = 1; } } @@ -490,11 +491,12 @@ if ($action == "set") { $fp = @fopen($lockfile, "w"); if ($fp) { if (empty($force_install_lockinstall) || $force_install_lockinstall == 1) { - $force_install_lockinstall = 444; // For backward compatibility + $force_install_lockinstall = '444'; // For backward compatibility } fwrite($fp, "This is a lock file to prevent use of install or upgrade pages (set with permission ".$force_install_lockinstall.")"); fclose($fp); - @chmod($lockfile, octdec($force_install_lockinstall)); + dolChmod($lockfile, $force_install_lockinstall); + $createlock = 1; } } diff --git a/htdocs/intracommreport/card.php b/htdocs/intracommreport/card.php index 403c4b28eae..a5b17803f65 100644 --- a/htdocs/intracommreport/card.php +++ b/htdocs/intracommreport/card.php @@ -274,7 +274,7 @@ if ($id > 0 && $action != 'edit') { print "
'; + print ''.$langs->trans("More").'...'.($othernb < $maxofloop ? ' ('.$othernb.')' : '').''; + print '
'.$langs->trans("Total")."
'; - print '
'; + print '
'; } $thirdpartytmp->id = $obj->socid; diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index 2c1f8156d92..a8d9f38ac12 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -2177,7 +2177,7 @@ if ($action == 'create') { } else { print img_picto('', 'company').$form->select_company(empty($societe->id) ? 0 : $societe->id, 'socid', '(s.fournisseur = 1 AND s.status = 1)', 'SelectThirdParty', 1, 0, null, 0, 'minwidth175 widthcentpercentminusxx maxwidth500'); // reload page to retrieve supplier informations - if (!empty($conf->global->RELOAD_PAGE_ON_SUPPLIER_CHANGE)) { + if (empty($conf->global->RELOAD_PAGE_ON_SUPPLIER_CHANGE_DISABLED)) { print ''; diff --git a/htdocs/fourn/facture/list-rec.php b/htdocs/fourn/facture/list-rec.php index e77000b45d3..d45334eba9e 100644 --- a/htdocs/fourn/facture/list-rec.php +++ b/htdocs/fourn/facture/list-rec.php @@ -130,9 +130,9 @@ $extrafields->fetch_name_optionals_label($object->table_element); $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); -$permissionnote = $user->rights->facture->creer; // Used by the include of actions_setnotes.inc.php -$permissiondellink = $user->rights->facture->creer; // Used by the include of actions_dellink.inc.php -$permissiontoedit = $user->rights->facture->creer; // Used by the include of actions_lineupdonw.inc.php +$permissionnote = $user->hasRight('facture', 'creer'); // Used by the include of actions_setnotes.inc.php +$permissiondellink = $user->hasRight('facture', 'creer'); // Used by the include of actions_dellink.inc.php +$permissiontoedit = $user->hasRight('facture', 'creer'); // Used by the include of actions_lineupdonw.inc.php $arrayfields = array( 'f.titre'=>array('label'=>'Ref', 'checked'=>1), diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index 9b790050571..043a92b0648 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -1010,17 +1010,17 @@ if (!empty($arrayfields['f.ref_supplier']['checked'])) { if (!empty($arrayfields['f.type']['checked'])) { print '
'; $listtype = array( - FactureFournisseur::TYPE_STANDARD=>$langs->trans("InvoiceStandard"), - FactureFournisseur::TYPE_REPLACEMENT=>$langs->trans("InvoiceReplacement"), - FactureFournisseur::TYPE_CREDIT_NOTE=>$langs->trans("InvoiceAvoir"), - FactureFournisseur::TYPE_DEPOSIT=>$langs->trans("InvoiceDeposit"), + FactureFournisseur::TYPE_STANDARD=>$langs->trans("InvoiceStandard"), + FactureFournisseur::TYPE_REPLACEMENT=>$langs->trans("InvoiceReplacement"), + FactureFournisseur::TYPE_CREDIT_NOTE=>$langs->trans("InvoiceAvoir"), + FactureFournisseur::TYPE_DEPOSIT=>$langs->trans("InvoiceDeposit"), ); /* - if (!empty($conf->global->INVOICE_USE_SITUATION)) - { - $listtype[Facture::TYPE_SITUATION] = $langs->trans("InvoiceSituation"); - } - */ + if (!empty($conf->global->INVOICE_USE_SITUATION)) + { + $listtype[Facture::TYPE_SITUATION] = $langs->trans("InvoiceSituation"); + } + */ //$listtype[Facture::TYPE_PROFORMA]=$langs->trans("InvoiceProForma"); // A proformat invoice is not an invoice but must be an order. print $form->selectarray('search_type', $listtype, $search_type, 1, 0, 0, '', 0, 0, 0, 'ASC', 'maxwidth100'); print ''; print '
'; /* - print $langs->trans('From').' '; - print $form->selectDate($search_datelimit_start ? $search_datelimit_start : -1, 'search_datelimit_start', 0, 0, 1); - print '
'; - print '
'; - print $langs->trans('to').' ';*/ + print $langs->trans('From').' '; + print $form->selectDate($search_datelimit_start ? $search_datelimit_start : -1, 'search_datelimit_start', 0, 0, 1); + print '
'; + print '
'; + print $langs->trans('to').' ';*/ print $form->selectDate($search_datelimit_end ? $search_datelimit_end : -1, 'search_datelimit_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("Before")); print '
'.$langs->trans("Alert"); print '
'; @@ -1412,10 +1412,11 @@ if ($num > 0) { $remaintopay = -$facturestatic->getSumFromThisCreditNotesNotUsed(); } } + if ($mode == 'kanban') { if ($i == 0) { print '
'; - print '
'; + print '
'; } // Output Kanban $facturestatic->socid = $thirdparty->getNomUrl(1, 'supplier', 3); @@ -1483,7 +1484,7 @@ if ($num > 0) { // Label if (!empty($arrayfields['f.label']['checked'])) { print '
'; - print $obj->label; + print dol_escape_htmltag($obj->label); print ''; - print $thirdparty->name_alias; + print dol_escape_htmltag($thirdparty->name_alias); print ''; - print $obj->town; + print ''; + print dol_escape_htmltag($obj->town); print ''; + print ''; print dol_escape_htmltag($obj->zip); print '".$obj->state_name."'; + print dol_escape_htmltag($obj->state_name); + print "
'; - print '
'; + print '
'; } $holidaystatic->fk_type = $typeleaves[$obj->fk_type]['rowid']; diff --git a/htdocs/hrm/class/position.class.php b/htdocs/hrm/class/position.class.php index 479479d4b9d..4cb0eb670f8 100644 --- a/htdocs/hrm/class/position.class.php +++ b/htdocs/hrm/class/position.class.php @@ -1123,9 +1123,10 @@ class Position extends CommonObject * Return clicable link of object (with eventually picto) * * @param string $option Where point the link (0=> main card, 1,2 => shipment, 'nolink'=>No link) + * @param array $arraydata Array of data * @return string HTML Code for Kanban thumb. */ - public function getKanbanView($option = '') + public function getKanbanView($option = '', $arraydata = null) { global $selected, $langs; $return = '
'; diff --git a/htdocs/hrm/class/skill.class.php b/htdocs/hrm/class/skill.class.php index 8b7b6910f2b..1413bc36e0c 100644 --- a/htdocs/hrm/class/skill.class.php +++ b/htdocs/hrm/class/skill.class.php @@ -1131,7 +1131,7 @@ class Skill extends CommonObject $return .= ''; $return .= '
'; $return .= ''.(method_exists($this, 'getNomUrl') ? $this->getNomUrl() : $this->ref).''; - $return .= ''; + $return .= ''; if (property_exists($this, 'skill_type')) { $return .= '
'.$langs->trans("Type").''; $return .= ' : '.$this->fields['skill_type']['arrayofkeyval'][$this->skill_type].''; diff --git a/htdocs/hrm/compare.php b/htdocs/hrm/compare.php index cfb3f73f7cd..63b40cccb0e 100644 --- a/htdocs/hrm/compare.php +++ b/htdocs/hrm/compare.php @@ -188,7 +188,7 @@ $fk_usergroup1 = GETPOST('fk_usergroup1');
-
+
diff --git a/htdocs/hrm/core/tpl/skilldet.fiche.tpl.php b/htdocs/hrm/core/tpl/skilldet.fiche.tpl.php index 81e3f9f2155..42a4506ae96 100644 --- a/htdocs/hrm/core/tpl/skilldet.fiche.tpl.php +++ b/htdocs/hrm/core/tpl/skilldet.fiche.tpl.php @@ -65,9 +65,9 @@ $permission = $user->rights->fournisseur->commande->creer; $permission = $user->rights->supplier_order->creer; } } elseif ($module == 'societe') { -$permission = $user->rights->societe->creer; +$permission = $user->hasRight('societe', 'creer'); } elseif ($module == 'contact') { -$permission = $user->rights->societe->creer; +$permission = $user->hasRight('societe', 'creer'); } elseif ($module == 'shipping') { $permission = $user->rights->expedition->creer; } elseif ($module == 'product') { diff --git a/htdocs/hrm/evaluation_agenda.php b/htdocs/hrm/evaluation_agenda.php index dda7425547f..2124dca8a8d 100644 --- a/htdocs/hrm/evaluation_agenda.php +++ b/htdocs/hrm/evaluation_agenda.php @@ -55,6 +55,7 @@ if (GETPOST('actioncode', 'array')) { } else { $actioncode = GETPOST("actioncode", "alpha", 3) ? GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : getDolGlobalString('AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT')); } +$search_rowid = GETPOST('search_rowid'); $search_agenda_label = GETPOST('search_agenda_label'); $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; @@ -138,7 +139,7 @@ $form = new Form($db); if ($object->id > 0) { $title = $langs->trans("Agenda"); //if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/',$conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->name." - ".$title; - $help_url = 'EN:Module_Agenda_En'; + $help_url = 'EN:Module_Agenda_En|DE:Modul_Terminplanung'; llxHeader('', $title, $help_url); if (isModEnabled('notification')) { @@ -230,6 +231,7 @@ if ($object->id > 0) { // List of all actions $filters = array(); $filters['search_agenda_label'] = $search_agenda_label; + $filters['search_rowid'] = $search_rowid; // TODO Replace this with same code than into list.php show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder, $object->module); diff --git a/htdocs/hrm/evaluation_list.php b/htdocs/hrm/evaluation_list.php index adf642597f2..f39030cf3d5 100644 --- a/htdocs/hrm/evaluation_list.php +++ b/htdocs/hrm/evaluation_list.php @@ -579,7 +579,7 @@ while ($i < ($limit ? min($num, $limit) : $num)) { if ($mode == 'kanban') { if ($i == 0) { print '
'; - print '
'; + print '
'; } // Output Kanban $object->date_eval = $obj->date_eval; diff --git a/htdocs/hrm/job_agenda.php b/htdocs/hrm/job_agenda.php index b11e2124472..c108a7f113b 100644 --- a/htdocs/hrm/job_agenda.php +++ b/htdocs/hrm/job_agenda.php @@ -35,7 +35,6 @@ require_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT . '/hrm/class/job.class.php'; require_once DOL_DOCUMENT_ROOT . '/hrm/lib/hrm_job.lib.php'; - // Load translation files required by the page $langs->loadLangs(array('hrm', 'other')); @@ -54,6 +53,7 @@ if (GETPOST('actioncode', 'array')) { } else { $actioncode = GETPOST("actioncode", "alpha", 3) ? GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : getDolGlobalString('AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT')); } +$search_rowid = GETPOST('search_rowid'); $search_agenda_label = GETPOST('search_agenda_label'); $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; @@ -135,7 +135,7 @@ $form = new Form($db); if ($object->id > 0) { $title = $langs->trans("Agenda"); //if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/',$conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->name." - ".$title; - $help_url = 'EN:Module_Agenda_En'; + $help_url = 'EN:Module_Agenda_En|DE:Modul_Terminplanung'; llxHeader('', $title, $help_url); if (isModEnabled('notification')) { @@ -212,6 +212,7 @@ if ($object->id > 0) { // List of all actions $filters = array(); $filters['search_agenda_label'] = $search_agenda_label; + $filters['search_rowid'] = $search_rowid; // TODO Replace this with same code than into list.php show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder, $object->module); diff --git a/htdocs/hrm/job_list.php b/htdocs/hrm/job_list.php index c980cec9abf..b347c32848c 100644 --- a/htdocs/hrm/job_list.php +++ b/htdocs/hrm/job_list.php @@ -606,7 +606,7 @@ while ($i < $imaxinloop) { if ($i == 0) { print '
'; - print '
'; + print '
'; } // Output Kanban print $object->getKanbanView(''); diff --git a/htdocs/hrm/position_agenda.php b/htdocs/hrm/position_agenda.php index 99ad1736146..8386c0bb1df 100644 --- a/htdocs/hrm/position_agenda.php +++ b/htdocs/hrm/position_agenda.php @@ -55,6 +55,7 @@ if (GETPOST('actioncode', 'array')) { } else { $actioncode = GETPOST("actioncode", "alpha", 3) ? GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : getDolGlobalString('AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT')); } +$search_rowid = GETPOST('search_rowid'); $search_agenda_label = GETPOST('search_agenda_label'); $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; @@ -137,7 +138,7 @@ $form = new Form($db); if ($object->id > 0) { $title = $langs->trans("Agenda"); //if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/',$conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->name." - ".$title; - $help_url = 'EN:Module_Agenda_En'; + $help_url = 'EN:Module_Agenda_En|DE:Modul_Terminplanung'; llxHeader('', $title, $help_url); if (isModEnabled('notification')) { @@ -224,7 +225,9 @@ if ($object->id > 0) { // List of all actions $filters = array(); $filters['search_agenda_label'] = $search_agenda_label; - $object->fields['label']=array(); // Usefull to get only get agenda events linked to position (this object doesn't need label of ref field, but show_actions_done() needs it to work correctly) + $filters['search_rowid'] = $search_rowid; + + $object->fields['label']=array(); // Usefull to get only agenda events linked to position (this object doesn't need label of ref field, but show_actions_done() needs it to work correctly) // TODO Replace this with same code than into list.php show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder, $object->module); diff --git a/htdocs/hrm/position_card.php b/htdocs/hrm/position_card.php index 9004e8d2b13..d46548a4693 100644 --- a/htdocs/hrm/position_card.php +++ b/htdocs/hrm/position_card.php @@ -347,7 +347,7 @@ function displayPositionCard(&$object) // $filedir = $conf->societe->multidir_output[$object->entity].'/'.$object->id; // $urlsource = $_SERVER["PHP_SELF"]."?socid=".$object->id; // $genallowed = $user->hasRight('societe', 'lire'); -// $delallowed = $user->rights->societe->creer; +// $delallowed = $user->hasRight('societe', 'creer'); // // print $formfile->showdocuments('company', $object->id, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 0, 0, 0, 28, 0, 'entity='.$object->entity, 0, '', $object->default_lang); // } diff --git a/htdocs/hrm/position_list.php b/htdocs/hrm/position_list.php index 4518d28bf65..f5740834da7 100644 --- a/htdocs/hrm/position_list.php +++ b/htdocs/hrm/position_list.php @@ -615,7 +615,7 @@ while ($i < $imaxinloop) { if ($mode == 'kanban') { if ($i == 0) { print '
'; - print '
'; + print '
'; } // get info needed $object->date_start = $obj->date_start; diff --git a/htdocs/hrm/skill_agenda.php b/htdocs/hrm/skill_agenda.php index 7fc97c65c3c..e7814db1dc2 100644 --- a/htdocs/hrm/skill_agenda.php +++ b/htdocs/hrm/skill_agenda.php @@ -54,6 +54,7 @@ if (GETPOST('actioncode', 'array')) { } else { $actioncode = GETPOST("actioncode", "alpha", 3) ? GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : getDolGlobalString('AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT')); } +$search_rowid = GETPOST('search_rowid'); $search_agenda_label = GETPOST('search_agenda_label'); // Get Parameters for Pagination @@ -136,7 +137,7 @@ $form = new Form($db); if ($object->id > 0) { $title = $langs->trans("Agenda"); //if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/',$conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->name." - ".$title; - $help_url = 'EN:Module_Agenda_En'; + $help_url = 'EN:Module_Agenda_En|DE:Modul_Terminplanung'; llxHeader('', $title, $help_url); if (isModEnabled('notification')) { @@ -218,6 +219,7 @@ if ($object->id > 0) { // List of all actions $filters = array(); $filters['search_agenda_label'] = $search_agenda_label; + $filters['search_rowid'] = $search_rowid; // TODO Replace this with same code than into list.php show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder, $object->module); diff --git a/htdocs/hrm/skill_card.php b/htdocs/hrm/skill_card.php index 9c5de6bf7f5..d5b62b26151 100644 --- a/htdocs/hrm/skill_card.php +++ b/htdocs/hrm/skill_card.php @@ -4,6 +4,7 @@ * Copyright (C) 2021 Greg Rastklan * Copyright (C) 2021 Jean-Pascal BOUDET * Copyright (C) 2021 Grégory BLEMAND + * Copyright (C) 2023 Frédéric France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -774,16 +775,16 @@ if ($action != "create" && $action != "edit") { // LINE EDITION | SUPPRESSION print '
'; - print ''; + + // print ''; // add pencil //@todo change to proper call dol_ //print 'id, 1) . '">'; // add trash //@todo change to proper call dol_ //print 'id,1) .'">'; - //print '
'; - print '
'; + print '
'; } // Output Kanban diff --git a/htdocs/imports/import.php b/htdocs/imports/import.php index 4ba13d01cf0..d46bfb2605c 100644 --- a/htdocs/imports/import.php +++ b/htdocs/imports/import.php @@ -2407,8 +2407,7 @@ function show_elem($fieldssource, $pos, $key, $var, $nostyle = '') } else { print ' - '; } - //print ''.$langs->trans("ExampleOnFirstLine").': '; - print ''.$example.''; + print ''.dol_escape_htmltag($example).''; } print '
\n"; print "
\n"; - print '
'; + print '
'; print dol_get_fiche_end(); } diff --git a/htdocs/knowledgemanagement/class/knowledgerecord.class.php b/htdocs/knowledgemanagement/class/knowledgerecord.class.php index f85b2f8e9cf..275b0a2a2e3 100644 --- a/htdocs/knowledgemanagement/class/knowledgerecord.class.php +++ b/htdocs/knowledgemanagement/class/knowledgerecord.class.php @@ -727,8 +727,9 @@ class KnowledgeRecord extends CommonObject $langs->loadLangs(['knowledgemanagement', 'languages']); - $datas = []; - $nofetch = empty($params['nofetch']) ? false : true; + $datas = array(); + $nofetch = !empty($params['nofetch']); + $datas['picto'] = img_picto('', $this->picto).' '.$langs->trans("KnowledgeRecord").''; if (isset($this->statut)) { $datas['picto'] .= ' '.$this->getLibStatut(5); @@ -777,7 +778,7 @@ class KnowledgeRecord extends CommonObject $dataparams = ''; if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) { $classfortooltip = 'classforajaxtooltip'; - $dataparams = ' data-params='.json_encode($params); + $dataparams = " data-params='".json_encode($params)."'"; } $label = implode($this->getTooltipContentArray($params)); @@ -1136,12 +1137,12 @@ class KnowledgeRecord extends CommonObject $selected = 1; } $return .= ''; - if (property_exists($this, 'question')) { - $return .= '
'.$langs->trans('Question').' : '.$this->question.''; - } if (property_exists($this, 'lang') && !empty($this->lang)) { - $return .= '
'.$langs->trans("Language").' : lang).'">'.$langs->trans("Language_".$this->lang, '', '', '', '', 12).''; - $return .= picto_from_langcode($this->lang, 'class="paddingrightonly saturatemedium opacitylow"'); + //$return .= '
'.$langs->trans("Language").' : lang).'">'.$langs->trans("Language_".$this->lang, '', '', '', '', 12).''; + $return .= '
'.picto_from_langcode($this->lang, 'class="paddingrightonly saturatemedium opacitylow paddingrightonly"'); + } + if (property_exists($this, 'question')) { + $return .= ''.dolGetFirstLineOfText($this->question).''; } if (method_exists($this, 'getLibStatut')) { $return .= '
'.$this->getLibStatut(5).'
'; diff --git a/htdocs/knowledgemanagement/knowledgerecord_agenda.php b/htdocs/knowledgemanagement/knowledgerecord_agenda.php index 6cf8428d06b..18ab83e1ff2 100644 --- a/htdocs/knowledgemanagement/knowledgerecord_agenda.php +++ b/htdocs/knowledgemanagement/knowledgerecord_agenda.php @@ -51,6 +51,7 @@ if (GETPOST('actioncode', 'array')) { } else { $actioncode = GETPOST("actioncode", "alpha", 3) ? GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : getDolGlobalString('AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT')); } +$search_rowid = GETPOST('search_rowid'); $search_agenda_label = GETPOST('search_agenda_label'); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; @@ -245,6 +246,7 @@ if ($object->id > 0) { // List of all actions $filters = array(); $filters['search_agenda_label'] = $search_agenda_label; + $filters['search_rowid'] = $search_rowid; // TODO Replace this with same code than into list.php show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder, $object->module); diff --git a/htdocs/knowledgemanagement/knowledgerecord_list.php b/htdocs/knowledgemanagement/knowledgerecord_list.php index 3a916cb96ef..b70b7df6bf3 100644 --- a/htdocs/knowledgemanagement/knowledgerecord_list.php +++ b/htdocs/knowledgemanagement/knowledgerecord_list.php @@ -68,8 +68,9 @@ $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) { + // If $page is not defined, or '' or -1 or if we click on clear filters $page = 0; -} // If $page is not defined, or '' or -1 or if we click on clear filters +} $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; @@ -242,8 +243,11 @@ $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook $sql .= preg_replace('/^,/', '', $hookmanager->resPrint); $sql = preg_replace('/,\s*$/', '', $sql); + +$sqlfields = $sql; // $sql fields to remove for count total + $sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; -if (!empty($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { +if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)"; } // Add table from hooks @@ -268,7 +272,7 @@ foreach ($search as $key => $val) { $mode_search = 2; } if ($search[$key] != '') { - $sql .= natural_search($key, $search[$key], (($key == 'status') ? 2 : $mode_search)); + $sql .= natural_search("t.".$db->escape($key), $search[$key], (($key == 'status') ? 2 : $mode_search)); } } else { if (preg_match('/(_dtstart|_dtend)$/', $key) && $search[$key] != '') { @@ -322,7 +326,7 @@ if ($search_all) { include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; // Add where from hooks $parameters = array(); -$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook +$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object, $action); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; /* If a group by is required @@ -344,10 +348,18 @@ $sql=preg_replace('/,\s*$/','', $sql); // Count total nb of records $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { - $resql = $db->query($sql); - $nbtotalofrecords = $db->num_rows($resql); + /* The fast and low memory method to get and count full list converts the sql into a sql count */ + $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql); + $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount); + $resql = $db->query($sqlforcount); + if ($resql) { + $objforcount = $db->fetch_object($resql); + $nbtotalofrecords = $objforcount->nbtotalofrecords; + } else { + dol_print_error($db); + } - if (($page * $limit) > $nbtotalofrecords) { // if total of record found is smaller than page * limit, goto and load page 0 + if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller than the paging size (filtering), goto and load page 0 $page = 0; $offset = 0; } @@ -397,12 +409,16 @@ if ($limit > 0 && $limit != $conf->liste_limit) { $param .= '&limit='.urlencode($limit); } foreach ($search as $key => $val) { - if (is_array($search[$key]) && count($search[$key])) { + if (is_array($search[$key])) { foreach ($search[$key] as $skey) { if ($skey != '') { $param .= '&search_'.$key.'[]='.urlencode($skey); } } + } elseif (preg_match('/(_dtstart|_dtend)$/', $key) && !empty($val)) { + $param .= '&search_'.$key.'month='.((int) GETPOST('search_'.$key.'month', 'int')); + $param .= '&search_'.$key.'day='.((int) GETPOST('search_'.$key.'day', 'int')); + $param .= '&search_'.$key.'year='.((int) GETPOST('search_'.$key.'year', 'int')); } elseif ($search[$key] != '') { $param .= '&search_'.$key.'='.urlencode($search[$key]); } @@ -424,14 +440,12 @@ $arrayofmassactions = array( //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"), //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"), ); -if ($permissiontodelete) { - $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete"); -} - if (isModEnabled('category') && $user->hasRight('knowledgemanagement', 'knowledgerecord', 'write')) { $arrayofmassactions['preaffecttag'] = img_picto('', 'category', 'class="pictofixedwidth"').$langs->trans("AffectTag"); } - +if (!empty($permissiontodelete)) { + $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete"); +} if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) { $arrayofmassactions = array(); } @@ -446,12 +460,15 @@ print ''; print ''; print ''; +print ''; print ''; +print ''; print ''; $newcardbutton = ''; $newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition')); $newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition')); +$newcardbutton .= dolGetButtonTitleSeparator(); $newcardbutton .= dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', dol_buildpath('/knowledgemanagement/knowledgerecord_card.php', 1).'?action=create&backtopage='.urlencode($_SERVER['PHP_SELF']), '', $permissiontoadd); print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'object_'.$object->picto, 0, $newcardbutton, '', $limit, 0, 0, 1); @@ -491,7 +508,7 @@ if (isModEnabled('categorie') && $user->hasRight('categorie', 'lire')) { } $parameters = array(); -$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook +$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook if (empty($reshook)) { $moreforfilter .= $hookmanager->resPrint; } else { @@ -501,11 +518,14 @@ if (empty($reshook)) { if (!empty($moreforfilter)) { print '
'; print $moreforfilter; + $parameters = array('type'=>$type); + $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; print '
'; } $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; -$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')); // This also change content of $arrayfields +$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN', '')); // This also change content of $arrayfields $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table @@ -514,31 +534,30 @@ print ''; +print ''; // Action column -if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { - print ''; } foreach ($object->fields as $key => $val) { $searchkey = empty($search[$key]) ? '' : $search[$key]; - $cssforfield = (empty($val['css']) ? '' : $val['css']); + $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']); if ($key == 'status') { $cssforfield .= ($cssforfield ? ' ' : '').'center'; } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) { $cssforfield .= ($cssforfield ? ' ' : '').'center'; } elseif (in_array($val['type'], array('timestamp'))) { $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; - } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID' && empty($val['arrayofkeyval'])) { + } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $key != 'rowid' && $val['label'] != 'TechnicalID' && empty($val['arrayofkeyval'])) { $cssforfield .= ($cssforfield ? ' ' : '').'right'; } if (!empty($arrayfields['t.'.$key]['checked'])) { - print ''; @@ -580,8 +599,9 @@ $totalarray['nbfield'] = 0; // Fields title label // -------------------------------------------------------------------- print ''; -if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { +if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { print getTitleFieldOfList(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; + $totalarray['nbfield']++; } foreach ($object->fields as $key => $val) { $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']); @@ -591,34 +611,33 @@ foreach ($object->fields as $key => $val) { $cssforfield .= ($cssforfield ? ' ' : '').'center'; } elseif (in_array($val['type'], array('timestamp'))) { $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; - } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID' && empty($val['arrayofkeyval'])) { + } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $key != 'rowid' && $val['label'] != 'TechnicalID' && empty($val['arrayofkeyval'])) { $cssforfield .= ($cssforfield ? ' ' : '').'right'; } $cssforfield = preg_replace('/small\s*/', '', $cssforfield); // the 'small' css must not be used for the title label if (!empty($arrayfields['t.'.$key]['checked'])) { - print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''))."\n"; + print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''), 0, (empty($val['helplist']) ? '' : $val['helplist']))."\n"; $totalarray['nbfield']++; } } // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields -$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); -$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook +$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder, 'totalarray'=>&$totalarray); +$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Action column -if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { +if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { print getTitleFieldOfList(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; + $totalarray['nbfield']++; } -$totalarray['nbfield']++; print ''."\n"; - // Detect if we need a fetch on each output line $needToFetchEachLine = 0; -if (!empty($extrafields->attributes[$object->table_element]['computed']) && is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) { +if (isset($extrafields->attributes[$object->table_element]['computed']) && is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) { foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) { - if (preg_match('/\$object/', $val)) { + if ($val && preg_match('/\$object/', $val)) { $needToFetchEachLine++; // There is at least one compute field that use $object } } @@ -629,6 +648,7 @@ if (!empty($extrafields->attributes[$object->table_element]['computed']) && is_a // -------------------------------------------------------------------- $i = 0; $savnbfield = $totalarray['nbfield']; +$totalarray = array(); $totalarray['nbfield'] = 0; $imaxinloop = ($limit ? min($num, $limit) : $num); while ($i < $imaxinloop) { @@ -643,15 +663,10 @@ while ($i < $imaxinloop) { if ($mode == 'kanban') { if ($i == 0) { print ''; @@ -661,7 +676,7 @@ while ($i < $imaxinloop) { $j = 0; print ''; // Action column - if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { print ''; + if (!$i) { + $totalarray['nbfield']++; + } } foreach ($object->fields as $key => $val) { $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']); @@ -691,9 +709,9 @@ while ($i < $imaxinloop) { } //if (in_array($key, array('fk_soc', 'fk_user', 'fk_warehouse'))) $cssforfield = 'tdoverflowmax100'; if (!empty($arrayfields['t.'.$key]['checked'])) { - print ''; if ($key == 'status') { @@ -737,6 +755,8 @@ while ($i < $imaxinloop) { $labellang = ($object->lang ? $langs->trans('Language_'.$object->lang) : ''); print picto_from_langcode($object->lang, 'class="paddingrightonly saturatemedium opacitylow"'); print $labellang; + } elseif ($key == 'question') { + print dolGetFirstLineOfText($object->$key); } else { print $object->showOutputField($val, $key, $object->$key, ''); } @@ -762,10 +782,10 @@ while ($i < $imaxinloop) { include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; // Fields from hook $parameters = array('arrayfields'=>$arrayfields, 'object'=>$object, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); - $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Action column - if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { print ''; - } - if (!$i) { - $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } print ''."\n"; diff --git a/htdocs/langs/de_DE/main.lang b/htdocs/langs/de_DE/main.lang index 4aa75a20c80..56e9c337bfe 100644 --- a/htdocs/langs/de_DE/main.lang +++ b/htdocs/langs/de_DE/main.lang @@ -464,7 +464,7 @@ OtherStatistics=Weitere Statistiken Status=Status Favorite=Favorit ShortInfo=Info. -Ref=Artikelnummer +Ref=Ref.Nr. ExternalRef=Externe-ID RefSupplier=Lieferanten-Zeichen RefPayment=Zahlungsref.-Nr. diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 082bfc101e0..be79a33bf14 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -145,6 +145,7 @@ Box=Widget Boxes=Widgets MaxNbOfLinesForBoxes=Max. number of lines for widgets AllWidgetsWereEnabled=All available widgets are enabled +WidgetAvailable=Widget available PositionByDefault=Default order Position=Position MenusDesc=Menu managers set content of the two menu bars (horizontal and vertical). @@ -374,7 +375,7 @@ DoTestSendHTML=Test sending HTML ErrorCantUseRazIfNoYearInMask=Error, can't use option @ to reset counter each year if sequence {yy} or {yyyy} is not in mask. ErrorCantUseRazInStartedYearIfNoYearMonthInMask=Error, can't use option @ if sequence {yy}{mm} or {yyyy}{mm} is not in mask. UMask=UMask parameter for new files on Unix/Linux/BSD/Mac file system. -UMaskExplanation=This parameter allow you to define permissions set by default on files created by Dolibarr on server (during upload for example).
It must be the octal value (for example, 0666 means read and write for everyone).
This parameter is useless on a Windows server. +UMaskExplanation=This parameter allow you to define permissions set by default on files created by Dolibarr on server (during upload for example).
It must be the octal value (for example, 0666 means read and write for everyone.). Recommended value is 0600 or 0660
This parameter is useless on a Windows server. SeeWikiForAllTeam=Take a look at the Wiki page for a list of contributors and their organization UseACacheDelay= Delay for caching export response in seconds (0 or empty for no cache) DisableLinkToHelpCenter=Hide the link "Need help or support" on the login page @@ -2299,7 +2300,7 @@ ExportUseLowMemoryMode=Use a low memory mode ExportUseLowMemoryModeHelp=Use the low memory mode to generate the dump file (compression is done through a pipe instead of into the PHP memory). This method does not allow to check that the file is complete and error message can't be reported if it fails. Use it if you experience not enough memory errors. ModuleWebhookName = Webhook -ModuleWebhookDesc = Interface to catch dolibarr triggers and send it to an URL +ModuleWebhookDesc = Interface to catch dolibarr triggers and send data of the event to an URL WebhookSetup = Webhook setup Settings = Settings WebhookSetupPage = Webhook setup page @@ -2372,4 +2373,6 @@ WarningModuleHasChangedLastVersionCheckParameter=Warning: the module %s has set WarningModuleHasChangedSecurityCsrfParameter=Warning: the module %s has disabled the CSRF security of your instance. This action is suspect and your installation may no more be secured. Please contact the author of the module for explanation. EMailsInGoingDesc=Incoming emails are managed by the module %s. You must enable and configure it if you need to support ingoing emails. MAIN_IMAP_USE_PHPIMAP=Use the PHP-IMAP library for IMAP instead of native PHP IMAP. This also allows the use of an OAuth2 connection for IMAP (module OAuth must also be activated). -MAIN_CHECKBOX_LEFT_COLUMN=Show the column for field and line selection on the left (on the right by default) \ No newline at end of file +MAIN_CHECKBOX_LEFT_COLUMN=Show the column for field and line selection on the left (on the right by default) + +CSSPage=CSS Style diff --git a/htdocs/langs/en_US/errors.lang b/htdocs/langs/en_US/errors.lang index 164bfc3911c..6e60f238911 100644 --- a/htdocs/langs/en_US/errors.lang +++ b/htdocs/langs/en_US/errors.lang @@ -262,6 +262,7 @@ ErrorParameterMustBeEnabledToAllwoThisFeature=Error, parameter %s must be ErrorLoginDateValidity=Error, this login is outside the validity date range ErrorValueLength=Length of field '%s' must be higher than '%s' ErrorReservedKeyword=The word '%s' is a reserved keyword +ErrorFilenameReserved=The filename %s can't be used as it is a reserved and protected command. ErrorNotAvailableWithThisDistribution=Not available with this distribution ErrorPublicInterfaceNotEnabled=Public interface was not enabled ErrorLanguageRequiredIfPageIsTranslationOfAnother=The language of new page must be defined if it is set as a translation of another page diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 22f04a3ad44..6734168621c 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -514,6 +514,7 @@ NotYetAvailable=Not yet available NotAvailable=Not available Categories=Tags/categories Category=Tag/category +SelectTheTagsToAssign=Select the tags/categories to assign By=By From=From FromDate=From diff --git a/htdocs/langs/en_US/margins.lang b/htdocs/langs/en_US/margins.lang index a91b139ec7b..9101966eff2 100644 --- a/htdocs/langs/en_US/margins.lang +++ b/htdocs/langs/en_US/margins.lang @@ -6,6 +6,7 @@ TotalMargin=Total Margin MarginOnProducts=Margin / Products MarginOnServices=Margin / Services MarginRate=Margin rate +ModifyMarginRates=Modify margin rates MarkRate=Mark rate DisplayMarginRates=Display margin rates DisplayMarkRates=Display mark rates diff --git a/htdocs/langs/en_US/mrp.lang b/htdocs/langs/en_US/mrp.lang index 6c8af64f69a..6e80c399ae3 100644 --- a/htdocs/langs/en_US/mrp.lang +++ b/htdocs/langs/en_US/mrp.lang @@ -121,3 +121,4 @@ BOMProductsList=BOM's products BOMServicesList=BOM's services Manufacturing=Manufacturing Disassemble=Disassemble +ProducedBy=Produced by diff --git a/htdocs/langs/en_US/partnership.lang b/htdocs/langs/en_US/partnership.lang index 89a1bfa742d..f4ea73a1a8f 100644 --- a/htdocs/langs/en_US/partnership.lang +++ b/htdocs/langs/en_US/partnership.lang @@ -29,7 +29,7 @@ PartnershipCheckBacklink=Partnership: Check referring backlink # Menu # NewPartnership=New Partnership -NewPartnershipbyWeb= Your partnership was added successfully. +NewPartnershipbyWeb=Your partnership request has been added successfully. We may contact you soon... ListOfPartnerships=List of partnership # diff --git a/htdocs/langs/fr_FR/margins.lang b/htdocs/langs/fr_FR/margins.lang index a8a68c6599f..742b8ce76c0 100644 --- a/htdocs/langs/fr_FR/margins.lang +++ b/htdocs/langs/fr_FR/margins.lang @@ -8,6 +8,7 @@ MarginOnServices=Marge / Services MarginRate=Taux de marge MarkRate=Taux de marque DisplayMarginRates=Afficher les taux de marge +ModifyMarginRates=Modifier les taux de marge DisplayMarkRates=Afficher les taux de marque InputPrice=Saisir un prix margin=Gestion des marges diff --git a/htdocs/langs/fr_FR/mrp.lang b/htdocs/langs/fr_FR/mrp.lang index 26942e14743..ff105886987 100644 --- a/htdocs/langs/fr_FR/mrp.lang +++ b/htdocs/langs/fr_FR/mrp.lang @@ -119,3 +119,4 @@ BomCantAddChildBom=La nomenclature %s est déjà présente dans l'arbre menant BOMNetNeeds = Besoins nets BOMProductsList=Les produits de BOM BOMServicesList=Les services de BOM +ProducedBy=Produit par \ No newline at end of file diff --git a/htdocs/langs/fr_FR/partnership.lang b/htdocs/langs/fr_FR/partnership.lang index 20c3fc0d801..b12f139abc9 100644 --- a/htdocs/langs/fr_FR/partnership.lang +++ b/htdocs/langs/fr_FR/partnership.lang @@ -29,7 +29,7 @@ PartnershipCheckBacklink=Partenariat : Vérifiez le backlink référent # Menu # NewPartnership=Nouveau partenariat -NewPartnershipbyWeb= Votre partenariat a été ajouté avec succès. +NewPartnershipbyWeb=Votre demande de partenariat a été ajouté avec succès. Nous vous recontacterons surement d'ici peu... ListOfPartnerships=Listes des partenariats # diff --git a/htdocs/loan/card.php b/htdocs/loan/card.php index afa7aa5eaa8..921784e4c21 100644 --- a/htdocs/loan/card.php +++ b/htdocs/loan/card.php @@ -1,4 +1,6 @@ * Copyright (C) 2015 Frederic France * Copyright (C) 2017 Laurent Destailleur @@ -37,6 +39,7 @@ if (isModEnabled('accounting')) { } require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // Load translation files required by the page $langs->loadLangs(array("compta", "bills", "loan")); @@ -633,12 +636,14 @@ if ($id > 0) { /* * Payments */ - $sql = "SELECT p.rowid, p.num_payment, datep as dp,"; + $sql = "SELECT p.rowid, p.num_payment, p.datep as dp,"; $sql .= " p.amount_capital, p.amount_insurance, p.amount_interest,"; + $sql .= " b.fk_account,"; $sql .= " c.libelle as paiement_type"; $sql .= " FROM ".MAIN_DB_PREFIX."payment_loan as p"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON p.fk_typepayment = c.id"; - $sql .= ", ".MAIN_DB_PREFIX."loan as l"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON p.fk_bank = b.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON p.fk_typepayment = c.id,"; + $sql .= " ".MAIN_DB_PREFIX."loan as l"; $sql .= " WHERE p.fk_loan = ".((int) $id); $sql .= " AND p.fk_loan = l.rowid"; $sql .= " AND l.entity IN ( ".getEntity('loan').")"; @@ -659,11 +664,14 @@ if ($id > 0) { print ''; print ''; print ''; + print ''; print ''; print ''; print ''; print ''; + $conf->cache['bankaccount'] = array(); + while ($i < $num) { $objp = $db->fetch_object($resql); @@ -671,9 +679,19 @@ if ($id > 0) { print ''; print '\n"; print "\n"; - print '\n"; - print '\n"; - print '\n"; + print "\n"; + print '\n"; + print '\n"; + print '\n"; print ""; $total_capital += $objp->amount_capital; $i++; @@ -682,12 +700,12 @@ if ($id > 0) { $totalpaid = $total_capital; if ($object->paid == 0 || $object->paid == 2) { - print ''; - print ''; + print ''; + print ''; $staytopay = $object->capital - $totalpaid; - print ''; + print ''; print ''; diff --git a/htdocs/loan/class/loan.class.php b/htdocs/loan/class/loan.class.php index 6dd0f5fe92b..54ad6dfb92b 100644 --- a/htdocs/loan/class/loan.class.php +++ b/htdocs/loan/class/loan.class.php @@ -457,7 +457,7 @@ class Loan extends CommonObject // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Tag loan as payement as unpaid + * Tag loan as payment as unpaid * @deprecated * @see setUnpaid() * @param User $user Object user making change @@ -471,7 +471,7 @@ class Loan extends CommonObject } /** - * Tag loan as payement as unpaid + * Tag loan as payment as unpaid * * @param User $user Object user making change * @return int <0 if KO, >0 if OK diff --git a/htdocs/loan/list.php b/htdocs/loan/list.php index b864c9f09ab..d3eace18a88 100644 --- a/htdocs/loan/list.php +++ b/htdocs/loan/list.php @@ -285,7 +285,7 @@ if ($resql) { if ($mode == 'kanban') { if ($i == 0) { print '
'; +if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; $searchpicto = $form->showFilterButtons('left'); print $searchpicto; print ''; - + print ''; if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) { - print $form->selectarray('search_'.$key, $val['arrayofkeyval'], (isset($search[$key]) ? $search[$key] : ''), $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1); + print $form->selectarray('search_'.$key, $val['arrayofkeyval'], (isset($search[$key]) ? $search[$key] : ''), $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100'.($key == 'status' ? ' search_status width100 onrightofpage' : ''), 1); } elseif ((strpos($val['type'], 'integer:') === 0) || (strpos($val['type'], 'sellist:')=== 0)) { print $object->showInputField($val, $key, (isset($search[$key]) ? $search[$key] : ''), '', '', 'search_', $cssforfield.' maxwidth250', 1); } elseif (preg_match('/^(date|timestamp|datetime)/', $val['type'])) { @@ -563,11 +582,11 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; // Fields from hook $parameters = array('arrayfields'=>$arrayfields); -$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook +$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Action column -if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { - print ''; +if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; $searchpicto = $form->showFilterButtons(); print $searchpicto; print '
'; - print '
'; + print '
'; } // Output Kanban - if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - if ($massactionbutton || $massaction) { - $selected = 0; - } - print $object->getKanbanView(''); - } + print $object->getKanbanView(''); if ($i == ($imaxinloop - 1)) { print '
'; print '
'; if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined $selected = 0; @@ -671,6 +686,9 @@ while ($i < $imaxinloop) { print ''; } print ''; if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined $selected = 0; @@ -775,9 +795,9 @@ while ($i < $imaxinloop) { print ''; } print '
'.$langs->trans("RefPayment").''.$langs->trans("Date").''.$langs->trans("Type").''.$langs->trans("BankAccount").''.$langs->trans("Insurance").''.$langs->trans("Interest").''.$langs->trans("LoanCapital").'
'.img_object($langs->trans("Payment"), "payment").' '.$objp->rowid.''.dol_print_date($db->jdate($objp->dp), 'day')."".$objp->paiement_type.' '.$objp->num_payment."'.price($objp->amount_insurance, 0, $outputlangs, 1, -1, -1, $conf->currency)."'.price($objp->amount_interest, 0, $outputlangs, 1, -1, -1, $conf->currency)."'.price($objp->amount_capital, 0, $outputlangs, 1, -1, -1, $conf->currency).""; + if (!empty($conf->cache['bankaccount'][$objp->fk_account])) { + $tmpbank = $conf->cache['bankaccount'][$objp->fk_account]; + } else { + $tmpbank = new Account($db); + $tmpbank->fetch($objp->fk_account); + $conf->cache['bankaccount'][$objp->fk_account] = $tmpbank; + } + print $tmpbank->getNomUrl(1); + print "'.price($objp->amount_insurance, 0, $outputlangs, 1, -1, -1, $conf->currency)."'.price($objp->amount_interest, 0, $outputlangs, 1, -1, -1, $conf->currency)."'.price($objp->amount_capital, 0, $outputlangs, 1, -1, -1, $conf->currency)."
'.$langs->trans("AlreadyPaid").' :'.price($totalpaid, 0, $langs, 0, -1, -1, $conf->currency).'
'.$langs->trans("AmountExpected").' :'.price($object->capital, 0, $outputlangs, 1, -1, -1, $conf->currency).'
'.$langs->trans("AlreadyPaid").' :'.price($totalpaid, 0, $langs, 0, -1, -1, $conf->currency).'
'.$langs->trans("AmountExpected").' :'.price($object->capital, 0, $outputlangs, 1, -1, -1, $conf->currency).'
'.$langs->trans("RemainderToPay").' :
'.$langs->trans("RemainderToPay").' :'; print price($staytopay, 0, $langs, 0, -1, -1, $conf->currency); print '
'; - print '
'; + print '
'; } // Output Kanban $loan_static->datestart= $obj->datestart; diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 889a1900139..3d4a094c30b 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -16,6 +16,7 @@ * Copyright (C) 2021 Frédéric France * Copyright (C) 2021 Alexandre Spangaro * Copyright (C) 2023 Joachim Küter + * Copyright (C) 2023 Eric Seigne * * 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 @@ -1785,39 +1786,45 @@ function top_htmlhead($head, $title = '', $disablejs = 0, $disablehead = 0, $arr } } + // Custom CSS + if (getDolGlobalString('MAIN_IHM_CUSTOM_CSS')) { + // If a custom CSS was set, we add link to the custom css php file + print ''."\n"; + } + // Output standard javascript links if (!defined('DISABLE_JQUERY') && !$disablejs && !empty($conf->use_javascript_ajax)) { // JQuery. Must be before other includes print ''."\n"; if (defined('JS_JQUERY') && constant('JS_JQUERY')) { - print ''."\n"; + print ''."\n"; } else { - print ''."\n"; + print ''."\n"; } if (defined('JS_JQUERY_UI') && constant('JS_JQUERY_UI')) { - print ''."\n"; + print ''."\n"; } else { - print ''."\n"; + print ''."\n"; } // jQuery jnotify if (empty($conf->global->MAIN_DISABLE_JQUERY_JNOTIFY) && !defined('DISABLE_JQUERY_JNOTIFY')) { - print ''."\n"; + print ''."\n"; } // Table drag and drop lines if (empty($disableforlogin) && !defined('DISABLE_JQUERY_TABLEDND')) { - print ''."\n"; + print ''."\n"; } // Chart if (empty($disableforlogin) && (empty($conf->global->MAIN_JS_GRAPH) || $conf->global->MAIN_JS_GRAPH == 'chart') && !defined('DISABLE_JS_GRAPH')) { - print ''."\n"; + print ''."\n"; } // jQuery jeditable for Edit In Place features if (!empty($conf->global->MAIN_USE_JQUERY_JEDITABLE) && !defined('DISABLE_JQUERY_JEDITABLE')) { print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; print ''."\n"; - print ''."\n"; - print ''."\n"; + print ''."\n"; + print ''."\n"; } // jQuery Timepicker if (!empty($conf->global->MAIN_USE_JQUERY_TIMEPICKER) || defined('REQUIRE_JQUERY_TIMEPICKER')) { - print ''."\n"; - print ''."\n"; + print ''."\n"; + print ''."\n"; } if (!defined('DISABLE_SELECT2') && (!empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) || defined('REQUIRE_JQUERY_MULTISELECT'))) { // jQuery plugin "mutiselect", "multiple-select", "select2", ... $tmpplugin = empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) ?constant('REQUIRE_JQUERY_MULTISELECT') : $conf->global->MAIN_USE_JQUERY_MULTISELECT; - print ''."\n"; // We include full because we need the support of containerCssClass + print ''."\n"; // We include full because we need the support of containerCssClass } if (!defined('DISABLE_MULTISELECT')) { // jQuery plugin "mutiselect" to select with checkboxes. Can be removed once we have an enhanced search tool - print ''."\n"; + print ''."\n"; } } @@ -1856,7 +1863,7 @@ function top_htmlhead($head, $title = '', $disablejs = 0, $disablehead = 0, $arr // To use external ckeditor 4 js lib $pathckeditor = constant('JS_CKEDITOR'); } - print ''."\n"; + print ''."\n"; } } // Global js function print ''."\n"; - print ''."\n"; + print ''."\n"; // JS forced by modules (relative url starting with /) if (!empty($conf->modules_parts['js'])) { // $conf->modules_parts['js'] is array('module'=>array('file1','file2')) @@ -1901,7 +1908,8 @@ function top_htmlhead($head, $title = '', $disablejs = 0, $disablehead = 0, $arr // jsfile is a relative path $urlforjs = dol_buildpath($jsfile, 1); if ($urlforjs && $urlforjs != '/') { - print ''."\n".''."\n"; + print ''."\n"; + print ''."\n"; } else { dol_syslog("Warning: module ".$modjs." declared a js path file for a file we can't find.", LOG_WARNING); } @@ -1913,9 +1921,9 @@ function top_htmlhead($head, $title = '', $disablejs = 0, $disablehead = 0, $arr print ''."\n"; foreach ($arrayofjs as $jsfile) { if (preg_match('/^(http|\/\/)/i', $jsfile)) { - print ''."\n"; + print ''."\n"; } else { - print ''."\n"; + print ''."\n"; } } } @@ -1925,7 +1933,7 @@ function top_htmlhead($head, $title = '', $disablejs = 0, $disablehead = 0, $arr if (!empty($conf->global->ALLOW_THEME_JS)) { $theme_js = dol_buildpath('/theme/'.$conf->theme.'/'.$conf->theme.'.js', 0); if (file_exists($theme_js)) { - print ''."\n"; + print ''."\n"; } } @@ -2319,7 +2327,7 @@ function top_menu_user($hideloginname = 0, $urllogout = '') $profilLink = ' '.$langs->trans("Card").''; $urltovirtualcard = '/user/virtualcard.php?id='.((int) $user->id); $virtuelcardLink = dolButtonToOpenUrlInDialogPopup('publicvirtualcardmenu', $langs->trans("PublicVirtualCardUrl").(is_object($user) ? ' - '.$user->getFullName($langs) : ''), img_picto($langs->trans("PublicVirtualCardUrl"), 'card', ''), $urltovirtualcard, '', 'button-top-menu-dropdown marginleftonly nohover', "closeTopMenuLoginDropdown()", '', 'v'); - $logoutLink = ' '.$langs->trans("Logout").''; + $logoutLink = ''.$langs->trans("Logout").''; $profilName = $user->getFullName($langs).' ('.$user->login.')'; if (!empty($user->admin)) { @@ -2383,7 +2391,7 @@ function top_menu_user($hideloginname = 0, $urllogout = '')
'.$logoutLink.'
-
+
diff --git a/htdocs/margin/tabs/productMargins.php b/htdocs/margin/tabs/productMargins.php index 107189e5181..1bda53b5c5d 100644 --- a/htdocs/margin/tabs/productMargins.php +++ b/htdocs/margin/tabs/productMargins.php @@ -133,7 +133,7 @@ if ($id > 0 || !empty($ref)) { print "
"; print '
'; - print '
'; + print '
'; print dol_get_fiche_end(); diff --git a/htdocs/margin/tabs/thirdpartyMargins.php b/htdocs/margin/tabs/thirdpartyMargins.php index 00188256619..3202dcb93ce 100644 --- a/htdocs/margin/tabs/thirdpartyMargins.php +++ b/htdocs/margin/tabs/thirdpartyMargins.php @@ -163,7 +163,7 @@ if ($socid > 0) { print ""; print '
'; - print '
'; + print '
'; print dol_get_fiche_end(); diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index 299bae1d6ce..d386fda721c 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -1230,6 +1230,7 @@ if ($dirins && $action == 'initobject' && $module && $objectname) { ); } if (GETPOST('generatepermissions', 'aZ09')) { + $firstobjectname = 'myobject'; $pathtofile = $listofmodules[strtolower($module)]['moduledescriptorrelpath']; dol_include_once($pathtofile); $class = 'mod'.$module; @@ -1241,28 +1242,42 @@ if ($dirins && $action == 'initobject' && $module && $objectname) { dol_print_error($db, $e->getMessage()); } } - if (empty($firstobjectname)) { + $rights = $moduleobj->rights; + $obj = array(); + $existRight = 0; + foreach ($rights as $right) { + $obj[]= $right[4]; + } + + if (in_array(strtolower($firstobjectname), $obj)) { $rightToadd = preg_replace('/myobject/', $objectname, $rightToadd); } + if (in_array(strtolower($objectname), $obj)) { + $existRight++; + setEventMessages($langs->trans("PermissionAlreadyExist", $langs->transnoentities($objectname)), null, 'errors'); + } if ($objectname != $firstobjectname) { $rightToadd = " - \$this->rights[\$r][0] = \$this->numero . sprintf('%02d', \$r + 1); - \$this->rights[\$r][1] = 'Read objects of ".$module."'; + \$this->rights[\$r][0] = \$this->numero . sprintf('%02d', \$r + 1); + \$this->rights[\$r][1] = 'Read objects of ".$module."'; \$this->rights[\$r][4] = '".strtolower($objectname)."'; - \$this->rights[\$r][5] = 'read'; + \$this->rights[\$r][5] = 'read'; \$r++; - \$this->rights[\$r][0] = \$this->numero . sprintf('%02d', \$r + 1); - \$this->rights[\$r][1] = 'Create/Update objects of ".$module."'; + \$this->rights[\$r][0] = \$this->numero . sprintf('%02d', \$r + 1); + \$this->rights[\$r][1] = 'Create/Update objects of ".$module."'; \$this->rights[\$r][4] = '".strtolower($objectname)."'; - \$this->rights[\$r][5] = 'write'; + \$this->rights[\$r][5] = 'write'; \$r++; - \$this->rights[\$r][0] = \$this->numero . sprintf('%02d', \$r + 1); - \$this->rights[\$r][1] = 'Delete objects of ".$module."'; + \$this->rights[\$r][0] = \$this->numero . sprintf('%02d', \$r + 1); + \$this->rights[\$r][1] = 'Delete objects of ".$module."'; \$this->rights[\$r][4] = '".strtolower($objectname)."'; - \$this->rights[\$r][5] = 'delete'; + \$this->rights[\$r][5] = 'delete'; \$r++; "; - dolReplaceInFile($moduledescriptorfile, array('/* END MODULEBUILDER PERMISSIONS */' => '/*'.strtoupper($objectname).'*/'.$rightToadd."/*END ".strtoupper($objectname).'*/'."\n\t\t".'/* END MODULEBUILDER PERMISSIONS */')); + $moduledescriptorfile = $destdir.'/core/modules/mod'.$module.'.class.php'; + if (!$existRight) { + dolReplaceInFile($moduledescriptorfile, array('/* END MODULEBUILDER PERMISSIONS */' => '/*'.strtoupper($objectname).'*/'.$rightToadd."/*END ".strtoupper($objectname).'*/'."\n\t\t".'/* END MODULEBUILDER PERMISSIONS */')); + } } } @@ -1429,7 +1444,7 @@ if ($dirins && $action == 'initobject' && $module && $objectname) { 'mon module'=>$module, 'Mon module'=>$module, 'htdocs/modulebuilder/template/'=>strtolower($modulename), - 'myobject'=>strtolower($objectname), + //'myobject'=>strtolower($objectname), 'MyObject'=>$objectname, //'MYOBJECT'=>strtoupper($objectname), '---Put here your own copyright and developer email---'=>dol_print_date($now, '%Y').' '.$user->getFullName($langs).($user->email ? ' <'.$user->email.'>' : '') @@ -1835,24 +1850,24 @@ if ($dirins && $action == 'confirm_deleteobject' && $objectname) { // regenerate permissions and delete them $rights = " - \$this->rights[\$r][0] = \$this->numero . sprintf('%02d', \$r + 1); - \$this->rights[\$r][1] = 'Read objects of ".$module."'; + \$this->rights[\$r][0] = \$this->numero . sprintf('%02d', \$r + 1); + \$this->rights[\$r][1] = 'Read objects of ".$module."'; \$this->rights[\$r][4] = '".strtolower($objectname)."'; - \$this->rights[\$r][5] = 'read'; + \$this->rights[\$r][5] = 'read'; \$r++; - \$this->rights[\$r][0] = \$this->numero . sprintf('%02d', \$r + 1); - \$this->rights[\$r][1] = 'Create/Update objects of ".$module."'; + \$this->rights[\$r][0] = \$this->numero . sprintf('%02d', \$r + 1); + \$this->rights[\$r][1] = 'Create/Update objects of ".$module."'; \$this->rights[\$r][4] = '".strtolower($objectname)."'; - \$this->rights[\$r][5] = 'write'; + \$this->rights[\$r][5] = 'write'; \$r++; - \$this->rights[\$r][0] = \$this->numero . sprintf('%02d', \$r + 1); - \$this->rights[\$r][1] = 'Delete objects of ".$module."'; + \$this->rights[\$r][0] = \$this->numero . sprintf('%02d', \$r + 1); + \$this->rights[\$r][1] = 'Delete objects of ".$module."'; \$this->rights[\$r][4] = '".strtolower($objectname)."'; - \$this->rights[\$r][5] = 'delete'; + \$this->rights[\$r][5] = 'delete'; \$r++; "; - $deleteright = dolReplaceInFile($moduledescriptorfile, array('/*'.strtoupper($objectname).'*/' => '', $rights => '', "/*END ".strtoupper($objectname).'*/'."\n\t\t" => ''."\n\t\t")); + $deleteright = dolReplaceInFile($moduledescriptorfile, array('/*'.strtoupper($objectname).'*/' => '', $rights => '', "/*END ".strtoupper($objectname).'*/'."\n\t\t" => "\n\t\t")); if ($deleteright > 0) { if (isModEnabled(strtolower($module))) { $result = unActivateModule(strtolower($module)); @@ -2036,7 +2051,7 @@ if ($dirins && $action == 'addright' && !empty($module) && empty($cancel)) { // if not found permission for the object if (!in_array($objectForPerms, array_unique($allObject))) { $firstRight++; - $existRight = 0; + $existRight++; } if (!$error) { if (isModEnabled(strtolower($module))) { @@ -2050,19 +2065,18 @@ if ($dirins && $action == 'addright' && !empty($module) && empty($cancel)) { } //prepare stirng to add $rightToAdd = " - \$this->rights[\$r][0] = \$this->numero . sprintf('%02d', \$r + 1); - \$this->rights[\$r][1] = '$label'; + \$this->rights[\$r][0] = \$this->numero . sprintf('%02d', \$r + 1); + \$this->rights[\$r][1] = '$label'; \$this->rights[\$r][4] = '$objectForPerms'; - \$this->rights[\$r][5] = '$crud'; + \$this->rights[\$r][5] = '$crud'; \$r++; "; $moduledescriptorfile = $dirins.'/'.strtolower($module).'/core/modules/mod'.$module.'.class.php'; if (!$existRight) { - //var_dump(1);exit; dolReplaceInFile($moduledescriptorfile, array('/*END '.strtoupper($objectForPerms).'*/' => $rightToAdd.'/*END '.strtoupper($objectForPerms).'*/')); setEventMessages($langs->trans('PermissionAddedSuccesfuly'), null); } - if ($firstRight) { + if ($firstRight>0) { dolReplaceInFile($moduledescriptorfile, array('/* END MODULEBUILDER PERMISSIONS */' => '/*'.strtoupper($objectForPerms).'*/'.$rightToAdd."/*END ".strtoupper($objectForPerms).'*/'."\n\t\t".'/* END MODULEBUILDER PERMISSIONS */')); setEventMessages($langs->trans('PermissionAddedSuccesfuly'), null); } @@ -2152,18 +2166,18 @@ if ($dirins && GETPOST('action') == 'update_right' && GETPOST('modifyright')&& e //prepare right want to delete $right = " - \$this->rights[\$r][0] = \$this->numero . sprintf('%02d', \$r + 1); - \$this->rights[\$r][1] = '$x1'; + \$this->rights[\$r][0] = \$this->numero . sprintf('%02d', \$r + 1); + \$this->rights[\$r][1] = '$x1'; \$this->rights[\$r][4] = '$x2'; - \$this->rights[\$r][5] = '$x3'; + \$this->rights[\$r][5] = '$x3'; \$r++; "; // right after editing $rightUpdated = " - \$this->rights[\$r][0] = \$this->numero . sprintf('%02d', \$r + 1); - \$this->rights[\$r][1] = '$label'; + \$this->rights[\$r][0] = \$this->numero . sprintf('%02d', \$r + 1); + \$this->rights[\$r][1] = '$label'; \$this->rights[\$r][4] = '$objectForPerms'; - \$this->rights[\$r][5] = '$crud'; + \$this->rights[\$r][5] = '$crud'; \$r++; "; if (!$error) { @@ -2209,16 +2223,16 @@ if ($dirins && $action == 'confirm_deleteright' && !empty($module) && GETPOST('p $x3 = $permissions[$key][5]; //prepare right want to delete $rightTodelete = " - \$this->rights[\$r][0] = \$this->numero . sprintf('%02d', \$r + 1); - \$this->rights[\$r][1] = '$x1'; + \$this->rights[\$r][0] = \$this->numero . sprintf('%02d', \$r + 1); + \$this->rights[\$r][1] = '$x1'; \$this->rights[\$r][4] = '$x2'; - \$this->rights[\$r][5] = '$x3'; + \$this->rights[\$r][5] = '$x3'; \$r++; "; $moduledescriptorfile = $dirins.'/'.strtolower($module).'/core/modules/mod'.$module.'.class.php'; - $check = dolReplaceInFile($moduledescriptorfile, array($rightTodelete => ''."\n\t\t")); + $check = dolReplaceInFile($moduledescriptorfile, array($rightTodelete => "\n\t\t")); if ($check > 0) { //check if all permissions of object was deleted $permsForObj = array(); @@ -2286,7 +2300,7 @@ if ($action == 'savefile' && empty($cancel)) { dol_delete_file($pathoffile); $result = file_put_contents($pathoffile, $content); if ($result) { - @chmod($pathoffile, octdec($newmask)); + dolChmod($pathoffile, $newmask); setEventMessages($langs->trans("FileSaved"), null); } else { @@ -2394,19 +2408,19 @@ if ($dirins && $action == 'confirm_deletemenu' && GETPOST('menukey', 'int')) { if ($menus[$key]['type'] == 'top') { $menuTop = " \$this->menu[\$r++] = array( - 'fk_menu'=>'".$menus[$key]['fk_menu']."', - 'type'=>'".$menus[$key]['type']."', + 'fk_menu'=>'".$menus[$key]['fk_menu']."', + 'type'=>'".$menus[$key]['type']."', 'titre'=>'".$menus[$key]['titre']."', 'prefix' => img_picto('', \$this->picto, 'class=\"paddingright pictofixedwidth valignmiddle\"'), 'mainmenu'=>'".$menus[$key]['mainmenu']."', 'leftmenu'=> '', 'url'=>'".$menus[$key]['url']."', - 'langs'=>'".$menus[$key]['langs']."', + 'langs'=>'".$menus[$key]['langs']."', 'position'=>1000 + \$r, - 'enabled'=>'isModEnabled(\"".strtolower($module)."\")', + 'enabled'=>'isModEnabled(\"".strtolower($module)."\")', 'perms' =>'".$menus[$key]['perms']."', 'target'=>'".$menus[$key]['target']."', - 'user'=>".$menus[$key]['user'].", + 'user'=>".$menus[$key]['user'].", );"; $check = dolReplaceInFile($moduledescriptorfile, array($menuTop => '',"\t\t".'/*TOPMENU '.strtolower($menus[$key]['titre']).'*/'."\n" => '', '/*END TOPMENU '.strtolower($menus[$key]['titre']).'*/'."\n\t\t" => '')); } @@ -2579,19 +2593,19 @@ if ($dirins && $action == 'addmenu' && empty($cancel)) { if ($type == 'top') { $menuTop = " \$this->menu[\$r++] = array( - 'fk_menu'=>'".$fk_menu."', - 'type'=>'".strtolower($type)."', + 'fk_menu'=>'".$fk_menu."', + 'type'=>'".strtolower($type)."', 'titre'=>'".ucfirst($titre)."', 'prefix' => img_picto('', \$this->picto, 'class=\"paddingright pictofixedwidth valignmiddle\"'), 'mainmenu'=>'".$mainmenu."', 'leftmenu'=> '".$leftmenu."', 'url'=>'".$url."', - 'langs'=>'".strtolower($module)."@".strtolower($module)."', + 'langs'=>'".strtolower($module)."@".strtolower($module)."', 'position'=>1000 + \$r, - 'enabled'=>'isModEnabled(\"".strtolower($module)."\")', + 'enabled'=>'isModEnabled(\"".strtolower($module)."\")', 'perms' =>'".$perms."', 'target'=>'".$target."', - 'user'=>".$user.", + 'user'=>".$user.", );"; $addTopMenu = dolReplaceInFile($moduledescriptorfile, array('/* END MODULEBUILDER TOPMENU */' => '/*TOPMENU '.strtolower($titre).'*/'.$menuTop."\n\t\t".'/*END TOPMENU '.strtolower($titre).'*/'."\n\t\t/* END MODULEBUILDER TOPMENU */")); } @@ -2605,7 +2619,7 @@ if ($dirins && $action == 'addmenu' && empty($cancel)) { 'mainmenu'=>'".strtolower($module)."', 'leftmenu'=>'".strtolower($leftmenu)."', 'url'=>'".$url."', - 'langs'=>'".strtolower($module)."@".strtolower($module)."', + 'langs'=>'".strtolower($module)."@".strtolower($module)."', 'position'=>1100+\$r, 'enabled'=>'\$conf->".strtolower($module)."->enabled', 'perms'=>'".$perms."', @@ -2662,12 +2676,12 @@ if ($dirins && $action == "modify_menu" && GETPOST('menukey', 'int') && empty(GE 'mainmenu'=>'".$menus[$key]['mainmenu']."', 'leftmenu' =>'".$menus[$key]['leftmenu']."', 'url' =>'".$menus[$key]['url']."', - 'langs'=>'".$menus[$key]['langs']."', + 'langs'=>'".$menus[$key]['langs']."', 'position'=>1000 + \$r, - 'enabled'=>'isModEnabled(\"".strtolower($module)."\")', + 'enabled'=>'isModEnabled(\"".strtolower($module)."\")', 'perms' =>'".$menus[$key]['perms']."', 'target'=>'".$menus[$key]['target']."', - 'user'=>".$menus[$key]['user'].", + 'user'=>".$menus[$key]['user'].", );"; $fk_menu = GETPOST('fk_type', 'alpha'); @@ -2691,12 +2705,12 @@ if ($dirins && $action == "modify_menu" && GETPOST('menukey', 'int') && empty(GE 'mainmenu'=>'".$menus[$key]['mainmenu']."', 'leftmenu' =>'".$menus[$key]['leftmenu']."', 'url' =>'".$url."', - 'langs'=>'".$menus[$key]['langs']."', + 'langs'=>'".$menus[$key]['langs']."', 'position'=>1000 + \$r, - 'enabled'=>'".$menus[$key]['enabled']."', + 'enabled'=>'".$menus[$key]['enabled']."', 'perms' =>'".$perms."', 'target'=>'".$target."', - 'user'=>".$user.", + 'user'=>".$user.", );"; @@ -2716,12 +2730,12 @@ if ($dirins && $action == "modify_menu" && GETPOST('menukey', 'int') && empty(GE 'mainmenu'=>'".$menus[$key]['mainmenu']."', 'leftmenu' =>'".$menus[$key]['leftmenu']."', 'url' =>'".$url."', - 'langs'=>'".$menus[$key]['langs']."', + 'langs'=>'".$menus[$key]['langs']."', 'position'=>1000 + \$r, - 'enabled'=>'isModEnabled(\"".strtolower($module)."\")', + 'enabled'=>'isModEnabled(\"".strtolower($module)."\")', 'perms' =>'".$perms."', 'target'=>'".$target."', - 'user'=>'".$user."', + 'user'=>'".$user."', );"; dolReplaceInFile($moduledescriptorfile, array($menuTomodify => $modifiedMenu)); @@ -4720,8 +4734,8 @@ if ($module == 'initmodule') { print '
'; print ''; - print ''; - print ''; + print ''; + print ''; print ''; print ''; @@ -4772,84 +4786,85 @@ if ($module == 'initmodule') { $i = 0; foreach ($perms as $perm) { $i++; - // section for editing right - if ($action == 'edit_right' && $perm[0] == (int) GETPOST('permskey', 'int')) { - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + if ($perm[4] != 'myobject') { + // section for editing right + if ($action == 'edit_right' && $perm[0] == (int) GETPOST('permskey', 'int')) { + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; - print ''; + print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; - print ''; - print ''; + print ''; + for ($i = 0; $i<3; $i++) { + if ($perm[1] != $labels[$i]) { + print ''; + } } - } - print ''; + print ''; - print ''; + print ''; - print ''; - print ''; + print ''; + for ($i = 0; $i<3; $i++) { + if ($perm[5] != $crud[$i]) { + print ''; + } } - } - print ''; - print ''; + print ''; + print ''; - print ''; - print ''; - print '
'; - print ''; - print ''; + print ''; + print ''; + print '
'; + print ''; + print ''; - print '
'; - print ''; - } else { - print ''; + print ''; + print ''; + } else { + print ''; - print ''; - print $perm[0]; - print ''; + print ''; + print $perm[0]; + print ''; - print ''; - print $langs->trans($perm[1]); - print ''; + print ''; + print $langs->trans($perm[1]); + print ''; - print ''; - print $perm[4]; - print ''; + print ''; + print $perm[4]; + print ''; - print ''; - print $perm[5]; - print ''; + print ''; + print $perm[5]; + print ''; - print ''; - if ($perm[4] != 'myobject') { + print ''; print ''.img_edit().''; print ''.img_delete().''; - } - print ''; - print ''; + print ''; + + print ''; + } } } } else { diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index e4594e6d615..5143f8a9790 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -803,7 +803,7 @@ class MyObject extends CommonObject $dataparams = ''; if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) { $classfortooltip = 'classforajaxtooltip'; - $dataparams = ' data-params='.json_encode($params); + $dataparams = " data-params='".json_encode($params)."'"; // $label = $langs->trans('Loading'); } $label = implode($this->getTooltipContentArray($params)); diff --git a/htdocs/modulebuilder/template/core/modules/mymodule/doc/doc_generic_myobject_odt.modules.php b/htdocs/modulebuilder/template/core/modules/mymodule/doc/doc_generic_myobject_odt.modules.php index f89360e8774..bcd437ad21d 100644 --- a/htdocs/modulebuilder/template/core/modules/mymodule/doc/doc_generic_myobject_odt.modules.php +++ b/htdocs/modulebuilder/template/core/modules/mymodule/doc/doc_generic_myobject_odt.modules.php @@ -498,9 +498,7 @@ class doc_generic_myobject_odt extends ModelePDFMyObject $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); $reshook = $hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); $odfHandler = null; // Destroy object diff --git a/htdocs/modulebuilder/template/core/modules/mymodule/doc/pdf_standard_myobject.modules.php b/htdocs/modulebuilder/template/core/modules/mymodule/doc/pdf_standard_myobject.modules.php index b78a2a5f4d7..66d0ae14d58 100644 --- a/htdocs/modulebuilder/template/core/modules/mymodule/doc/pdf_standard_myobject.modules.php +++ b/htdocs/modulebuilder/template/core/modules/mymodule/doc/pdf_standard_myobject.modules.php @@ -783,13 +783,11 @@ class pdf_standard_myobject extends ModelePDFMyObject $this->errors = $hookmanager->errors; } - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); - $this->result = array('fullpath'=>$file); + $this->result = array('fullpath'=>$file); - return 1; // No error + return 1; // No error } else { $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); return 0; diff --git a/htdocs/modulebuilder/template/myobject_agenda.php b/htdocs/modulebuilder/template/myobject_agenda.php index a5dcfe6f5f3..40345aab00a 100644 --- a/htdocs/modulebuilder/template/myobject_agenda.php +++ b/htdocs/modulebuilder/template/myobject_agenda.php @@ -78,7 +78,6 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; dol_include_once('/mymodule/class/myobject.class.php'); dol_include_once('/mymodule/lib/mymodule_myobject.lib.php'); - // Load translation files required by the page $langs->loadLangs(array("mymodule@mymodule", "other")); @@ -97,6 +96,7 @@ if (GETPOST('actioncode', 'array')) { } else { $actioncode = GETPOST("actioncode", "alpha", 3) ? GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : getDolGlobalString('AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT')); } +$search_rowid = GETPOST('search_rowid'); $search_agenda_label = GETPOST('search_agenda_label'); $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; @@ -187,7 +187,7 @@ $form = new Form($db); if ($object->id > 0) { $title = $langs->trans("Agenda"); //if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/',$conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->name." - ".$title; - $help_url = 'EN:Module_Agenda_En'; + $help_url = 'EN:Module_Agenda_En|DE:Modul_Terminplanung'; llxHeader('', $title, $help_url); if (isModEnabled('notification')) { @@ -309,6 +309,7 @@ if ($object->id > 0) { // List of all actions $filters = array(); $filters['search_agenda_label'] = $search_agenda_label; + $filters['search_rowid'] = $search_rowid; // TODO Replace this with same code than into list.php show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder, $object->module); diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php index 8cdbd1f9938..52c4731f6a2 100644 --- a/htdocs/modulebuilder/template/myobject_list.php +++ b/htdocs/modulebuilder/template/myobject_list.php @@ -254,6 +254,9 @@ if (empty($reshook)) { $objectlabel = 'MyObject'; $uploaddir = $conf->mymodule->dir_output; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; + + // You can add more action here + // if ($action == 'xxx' && $permissiontoxxx) ... } @@ -285,7 +288,7 @@ if (!empty($extrafields->attributes[$object->table_element]['label'])) { } // Add fields from hooks $parameters = array(); -$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook +$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object, $action); // Note that $action and $object may have been modified by hook $sql .= preg_replace('/^,/', '', $hookmanager->resPrint); $sql = preg_replace('/,\s*$/', '', $sql); //$sql .= ", COUNT(rc.rowid) as anotherfield"; @@ -343,7 +346,7 @@ if ($search_all) { include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; // Add where from hooks $parameters = array(); -$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook +$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object, $action); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; /* If a group by is required @@ -385,7 +388,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { dol_print_error($db); } - if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0 + if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller than the paging size (filtering), goto and load page 0 $page = 0; $offset = 0; } @@ -544,6 +547,9 @@ if (empty($reshook)) { if (!empty($moreforfilter)) { print '
'; print $moreforfilter; + $parameters = array('type'=>$type); + $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; print '
'; } @@ -554,13 +560,12 @@ $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('che print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table print ''."\n"; - // Fields title search // -------------------------------------------------------------------- -print ''; +print ''; // Action column if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print ''; @@ -605,14 +610,14 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; // Fields from hook $parameters = array('arrayfields'=>$arrayfields); -$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook +$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; /*if (!empty($arrayfields['anotherfield']['checked'])) { print ''; }*/ // Action column if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print ''; @@ -627,6 +632,7 @@ $totalarray['nbfield'] = 0; print ''; if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { print getTitleFieldOfList(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; + $totalarray['nbfield']++; } foreach ($object->fields as $key => $val) { $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']); @@ -649,7 +655,7 @@ foreach ($object->fields as $key => $val) { include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder, 'totalarray'=>&$totalarray); -$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook +$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; /*if (!empty($arrayfields['anotherfield']['checked'])) { print ''; @@ -658,16 +664,15 @@ print $hookmanager->resPrint; // Action column if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { print getTitleFieldOfList(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; + $totalarray['nbfield']++; } -$totalarray['nbfield']++; // For the column action print ''."\n"; - // Detect if we need a fetch on each output line $needToFetchEachLine = 0; if (isset($extrafields->attributes[$object->table_element]['computed']) && is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) { foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) { - if (preg_match('/\$object/', $val)) { + if ($val && preg_match('/\$object/', $val)) { $needToFetchEachLine++; // There is at least one compute field that use $object } } @@ -693,7 +698,7 @@ while ($i < $imaxinloop) { if ($mode == 'kanban') { if ($i == 0) { print ''; diff --git a/htdocs/mrp/class/mo.class.php b/htdocs/mrp/class/mo.class.php index afdac2d16a8..446880684d5 100644 --- a/htdocs/mrp/class/mo.class.php +++ b/htdocs/mrp/class/mo.class.php @@ -1,7 +1,7 @@ * Copyright (C) 2020 Lenin Rivas - * Copyright (C) ---Put here your own copyright and developer email--- + * Copyright (C) 2023 Frédéric France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -26,8 +26,6 @@ // Put here all includes required by your class file require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/commonobjectline.class.php'; -//require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; -//require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; /** * Class for Mo @@ -231,10 +229,6 @@ class Mo extends CommonObject */ public $line = array(); - /** - * @var integer Mo parent line - * */ - /** * @var int ID of parent line */ @@ -1122,7 +1116,8 @@ class Mo extends CommonObject { global $conf, $langs; - $langs->load('mrp'); + $langs->loadLangs(['mrp', 'products']); + $nofetch = isset($params['nofetch']) ? true : false; $datas = []; @@ -1137,6 +1132,21 @@ class Mo extends CommonObject if (isset($this->mrptype)) { $datas['type'] = '
'.$langs->trans('Type').': '.$this->fields['mrptype']['arrayofkeyval'][$this->mrptype]; } + if (isset($this->qty)) { + $datas['qty'] = '
'.$langs->trans('QtyToProduce').': '.$this->qty; + } + if (!$nofetch && isset($this->fk_product)) { + require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; + $product = new Product($this->db); + $product->fetch($this->fk_product); + $datas['product'] = '
'.$langs->trans('Product').': '.$product->getNomUrl(1, '', 0, -1, 1); + } + if (!$nofetch && isset($this->fk_warehouse)) { + require_once DOL_DOCUMENT_ROOT . '/product/stock/class/entrepot.class.php'; + $warehouse = new Entrepot($this->db); + $warehouse->fetch($this->fk_warehouse); + $datas['warehouse'] = '
'.$langs->trans('WarehouseForProduction').': '.$warehouse->getNomUrl(1, '', 0, 1); + } return $datas; } @@ -1164,13 +1174,13 @@ class Mo extends CommonObject 'id' => $this->id, 'objecttype' => $this->element, 'option' => $option, + 'nofetch' => 1, ]; $classfortooltip = 'classfortooltip'; $dataparams = ''; if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) { $classfortooltip = 'classforajaxtooltip'; - $dataparams = ' data-params='.json_encode($params); - // $label = $langs->trans('Loading'); + $dataparams = " data-params='".json_encode($params)."'"; } $label = implode($this->getTooltipContentArray($params)); diff --git a/htdocs/mrp/mo_agenda.php b/htdocs/mrp/mo_agenda.php index e1ecffcf287..470d87b727e 100644 --- a/htdocs/mrp/mo_agenda.php +++ b/htdocs/mrp/mo_agenda.php @@ -52,6 +52,7 @@ if (GETPOST('actioncode', 'array')) { } else { $actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : getDolGlobalString('AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT')); } +$search_rowid = GETPOST('search_rowid'); $search_agenda_label = GETPOST('search_agenda_label'); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; @@ -131,7 +132,7 @@ $formproject = new FormProjets($db); if ($object->id > 0) { $title = $langs->trans("Agenda"); //if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/',$conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->name." - ".$title; - $help_url = 'EN:Module_Agenda_En|FR:Module_Agenda|ES:Módulo_Agenda|DE:Modul_Agenda'; + $help_url = 'EN:Module_Agenda_En|FR:Module_Agenda|ES:Módulo_Agenda|DE:|DE:Modul_Terminplanung'; llxHeader('', $title, $help_url); if (isModEnabled('notification')) { @@ -242,6 +243,7 @@ if ($object->id > 0) { // List of all actions $filters = array(); $filters['search_agenda_label'] = $search_agenda_label; + $filters['search_rowid'] = $search_rowid; // TODO Replace this with same code than into list.php show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder); diff --git a/htdocs/mrp/mo_list.php b/htdocs/mrp/mo_list.php index c3ae9247c9d..36dbe6c120a 100644 --- a/htdocs/mrp/mo_list.php +++ b/htdocs/mrp/mo_list.php @@ -609,7 +609,7 @@ while ($i < ($limit ? min($num, $limit) : $num)) { if ($mode == 'kanban') { if ($i == 0) { print '
'; // Action column -if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { +if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { print ''; -if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { +if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { print getTitleFieldOfList(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; + $totalarray['nbfield']++; // For the column action } foreach ($object->fields as $key => $val) { $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']); @@ -790,7 +812,7 @@ foreach ($object->fields as $key => $val) { } $cssforfield = preg_replace('/small\s*/', '', $cssforfield); // the 'small' css must not be used for the title label if (!empty($arrayfields['t.'.$key]['checked'])) { - print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''))."\n"; + print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''), 0, (empty($val['helplist']) ? '' : $val['helplist']))."\n"; $totalarray['nbfield']++; } } @@ -804,13 +826,13 @@ if ($managedfor == 'member') { include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder, 'totalarray'=>&$totalarray); -$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook +$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Action column -if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { +if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { print getTitleFieldOfList(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; + $totalarray['nbfield']++; // For the column action } -$totalarray['nbfield']++; print ''."\n"; @@ -844,7 +866,7 @@ while ($i < $imaxinloop) { if ($mode == 'kanban') { if ($i == 0) { print ''; // Action column - if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { print ''; + if (!$i) { + $totalarray['nbfield']++; + } } foreach ($object->fields as $key => $val) { $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']); @@ -888,7 +913,7 @@ while ($i < $imaxinloop) { //if (in_array($key, array('fk_soc', 'fk_user', 'fk_warehouse'))) $cssforfield = 'tdoverflowmax100'; if (!empty($arrayfields['t.'.$key]['checked'])) { - print 'executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Action column - if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { print ''; - } - if (!$i) { - $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } print ''."\n"; @@ -970,7 +995,9 @@ while ($i < $imaxinloop) { $i++; } -if ($managedfor != 'member') $totalarray['nbfield']++; // End of subscription date +if ($managedfor != 'member') { + $totalarray['nbfield']++; // End of subscription date +} // Show total line include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; @@ -983,7 +1010,9 @@ if ($num == 0) { $colspan++; } } - if ($managedfor != 'member') $colspan++; // End of subscription date + if ($managedfor != 'member') { + $colspan++; // End of subscription date + } print ''; } diff --git a/htdocs/product/agenda.php b/htdocs/product/agenda.php index a70591cc138..b780f1b3229 100644 --- a/htdocs/product/agenda.php +++ b/htdocs/product/agenda.php @@ -45,6 +45,7 @@ if (GETPOST('actioncode', 'array')) { } else { $actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : getDolGlobalString('AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT')); } +$search_rowid = GETPOST('search_rowid'); $search_agenda_label = GETPOST('search_agenda_label'); // Security check @@ -72,7 +73,7 @@ if (!$sortorder) { } // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$hookmanager->initHooks(array('agendathirdparty')); +$hookmanager->initHooks(array('productagenda')); $object = new Product($db); if ($id > 0 || !empty($ref)) { @@ -137,7 +138,7 @@ if ($id > 0 || $ref) { $title = $langs->trans("Agenda"); - $help_url = 'EN:Module_Agenda_En|FR:Module_Agenda'; + $help_url = 'EN:Module_Agenda_En|FR:Module_Agenda|DE:Modul_Terminplanung'; if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/productnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) { $title = $object->name." - ".$title; @@ -217,6 +218,7 @@ if ($id > 0 || $ref) { // List of all actions $filters = array(); $filters['search_agenda_label'] = $search_agenda_label; + $filters['search_rowid'] = $search_rowid; // TODO Replace this with same code than into list.php show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder); diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 5f58678985a..197626d69f3 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -2722,7 +2722,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print ''; print ''; - print '
'; + print '
'; print dol_get_fiche_end(); } @@ -2846,7 +2846,7 @@ if (!empty($conf->global->PRODUCT_ADD_FORM_ADD_TO) && $object->id && ($action == //print '
'; // Propals - if (isModEnabled("propal") && $user->rights->propal->creer) { + if (isModEnabled("propal") && $user->hasRight('propal', 'creer')) { $propal = new Propal($db); $langs->load("propal"); @@ -2867,7 +2867,7 @@ if (!empty($conf->global->PRODUCT_ADD_FORM_ADD_TO) && $object->id && ($action == } // Commande - if (isModEnabled('commande') && $user->rights->commande->creer) { + if (isModEnabled('commande') && $user->hasRight('commande', 'creer')) { $commande = new Commande($db); $langs->load("orders"); @@ -2887,7 +2887,7 @@ if (!empty($conf->global->PRODUCT_ADD_FORM_ADD_TO) && $object->id && ($action == } // Factures - if (isModEnabled('facture') && $user->rights->facture->creer) { + if (isModEnabled('facture') && $user->hasRight('facture', 'creer')) { $invoice = new Facture($db); $langs->load("bills"); diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 74025356811..8a6cfd5419c 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -5011,8 +5011,8 @@ class Product extends CommonObject $langs->load('products'); - $datas = []; - $nofetch = empty($params['nofetch']) ? false : true; + $datas = array(); + $nofetch = !empty($params['nofetch']); if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { return ['optimize' => $langs->trans("ShowProduct")]; @@ -5149,7 +5149,7 @@ class Product extends CommonObject $dataparams = ''; if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) { $classfortooltip = 'classforajaxtooltip'; - $dataparams = ' data-params='.json_encode($params); + $dataparams = " data-params='".json_encode($params)."'"; // $label = $langs->trans('Loading'); } @@ -6363,9 +6363,10 @@ class Product extends CommonObject * Return clicable link of object (with eventually picto) * * @param string $option Where point the link (0=> main card, 1,2 => shipment, 'nolink'=>No link) + * @param array $arraydata Array of data * @return string HTML Code for Kanban thumb. */ - public function getKanbanView($option = '') + public function getKanbanView($option = '', $arraydata = null) { global $langs,$conf; diff --git a/htdocs/product/document.php b/htdocs/product/document.php index c24082ae6e6..af75cbc71ce 100644 --- a/htdocs/product/document.php +++ b/htdocs/product/document.php @@ -259,7 +259,7 @@ if ($object->id) { print '
'; + print ''; $searchpicto = $form->showFilterButtons('left'); print $searchpicto; print ''; + print ''; $searchpicto = $form->showFilterButtons(); print $searchpicto; print '
'.$langs->trans("AnotherField").'
'; - print '
'; + print '
'; } // Output Kanban print $object->getKanbanView(''); @@ -774,7 +779,7 @@ while ($i < $imaxinloop) { include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; // Fields from hook $parameters = array('arrayfields'=>$arrayfields, 'object'=>$object, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); - $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; /*if (!empty($arrayfields['anotherfield']['checked'])) { print '
'.$obj->anotherfield.'
'; - print '
'; + print '
'; } $object->id = $obj->type_id; $bom->id = $obj->fk_bom; diff --git a/htdocs/mrp/mo_movements.php b/htdocs/mrp/mo_movements.php index a82f36c913e..c450baf92fe 100644 --- a/htdocs/mrp/mo_movements.php +++ b/htdocs/mrp/mo_movements.php @@ -151,7 +151,7 @@ $permissiontodelete = $user->rights->mrp->delete || ($permissiontoadd && isset($ $upload_dir = $conf->mrp->multidir_output[isset($object->entity) ? $object->entity : 1]; $permissiontoproduce = $permissiontoadd; -$permissiontoupdatecost = $user->rights->bom->write; // User who can define cost must have knowledge of pricing +$permissiontoupdatecost = $user->hasRight('bom', 'write'); // User who can define cost must have knowledge of pricing if ($permissiontoupdatecost) { $arrayfields['m.price']['enabled'] = 1; diff --git a/htdocs/mrp/mo_production.php b/htdocs/mrp/mo_production.php index 4e149201ba3..c4353bd264b 100644 --- a/htdocs/mrp/mo_production.php +++ b/htdocs/mrp/mo_production.php @@ -95,7 +95,7 @@ $permissiontodelete = $user->rights->mrp->delete || ($permissiontoadd && isset($ $upload_dir = $conf->mrp->multidir_output[isset($object->entity) ? $object->entity : 1]; $permissiontoproduce = $permissiontoadd; -$permissiontoupdatecost = $user->rights->bom->read; // User who can define cost must have knowledge of pricing +$permissiontoupdatecost = $user->hasRight('bom', 'read'); // User who can define cost must have knowledge of pricing /* diff --git a/htdocs/opensurvey/class/opensurveysondage.class.php b/htdocs/opensurvey/class/opensurveysondage.class.php index b141da8d392..9c3ced9be54 100644 --- a/htdocs/opensurvey/class/opensurveysondage.class.php +++ b/htdocs/opensurvey/class/opensurveysondage.class.php @@ -474,7 +474,7 @@ class Opensurveysondage extends CommonObject $dataparams = ''; if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) { $classfortooltip = 'classforajaxtooltip'; - $dataparams = ' data-params='.json_encode($params); + $dataparams = " data-params='".json_encode($params)."'"; // $label = $langs->trans('Loading'); } $label = implode($this->getTooltipContentArray($params)); diff --git a/htdocs/opensurvey/wizard/index.php b/htdocs/opensurvey/wizard/index.php index b8ccd0d8588..4542ecfa3bd 100644 --- a/htdocs/opensurvey/wizard/index.php +++ b/htdocs/opensurvey/wizard/index.php @@ -61,7 +61,7 @@ print '
'; print '
'; print ''; print '
'; -print '
'; +print '
'; print '
'; print '
'; diff --git a/htdocs/partnership/class/partnership.class.php b/htdocs/partnership/class/partnership.class.php index 840569082b2..ca2e061cbe4 100644 --- a/htdocs/partnership/class/partnership.class.php +++ b/htdocs/partnership/class/partnership.class.php @@ -104,7 +104,8 @@ class Partnership extends CommonObject 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>'1', 'position'=>1, 'notnull'=>1, 'visible'=>0, 'noteditable'=>'1', 'index'=>1, 'css'=>'left', 'comment'=>"Id"), 'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>'1', 'position'=>10, 'notnull'=>1, 'visible'=>4, 'noteditable'=>'1', 'default'=>'(PROV)', 'index'=>1, 'searchall'=>1, 'showoncombobox'=>'1', 'comment'=>"Reference of object"), 'entity' => array('type'=>'integer', 'label'=>'Entity', 'enabled'=>'1', 'position'=>15, 'notnull'=>1, 'visible'=>-2, 'default'=>'1', 'index'=>1,), - 'fk_type' => array('type'=>'integer:PartnershipType:partnership/class/partnership_type.class.php:0:active=1', 'label'=>'Type', 'enabled'=>'1', 'position'=>20, 'notnull'=>1, 'visible'=>1,), + 'fk_type' => array('type'=>'integer:PartnershipType:partnership/class/partnership_type.class.php:0:active=1', 'label'=>'Type', 'enabled'=>'1', 'position'=>20, 'notnull'=>1, 'visible'=>1, 'csslist'=>'tdoverflowmax100'), + 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php:1:status=1 AND entity IN (__SHARED_ENTITIES__)', 'label'=>'ThirdParty', 'picto'=>'company', 'enabled'=>'1', 'position'=>50, 'notnull'=>-1, 'visible'=>1, 'index'=>1, 'css'=>'maxwidth500', 'csslist'=>'tdoverflowmax125',), 'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>'1', 'position'=>61, 'notnull'=>0, 'visible'=>0,), 'note_private' => array('type'=>'html', 'label'=>'NotePrivate', 'enabled'=>'1', 'position'=>62, 'notnull'=>0, 'visible'=>0,), 'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>'1', 'position'=>500, 'notnull'=>1, 'visible'=>-2,), @@ -121,7 +122,6 @@ class Partnership extends CommonObject 'count_last_url_check_error' => array('type'=>'integer', 'label'=>'CountLastUrlCheckError', 'enabled'=>'1', 'position'=>71, 'notnull'=>0, 'visible'=>-2, 'default'=>'0',), 'last_check_backlink' => array('type'=>'datetime', 'label'=>'LastCheckBacklink', 'enabled'=>'1', 'position'=>72, 'notnull'=>0, 'visible'=>-2,), 'reason_decline_or_cancel' => array('type'=>'text', 'label'=>'ReasonDeclineOrCancel', 'enabled'=>'1', 'position'=>73, 'notnull'=>0, 'visible'=>-2,), - 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php:1:status=1 AND entity IN (__SHARED_ENTITIES__)', 'label'=>'ThirdParty', 'picto'=>'company', 'enabled'=>'1', 'position'=>50, 'notnull'=>-1, 'visible'=>1, 'index'=>1, 'css'=>'maxwidth500', 'csslist'=>'tdoverflowmax150',), 'ip' => array('type'=>'varchar(250)', 'label'=>'Ip', 'enabled'=>'1', 'position'=>74, 'notnull'=>0, 'visible'=>-2,), ); public $rowid; @@ -990,7 +990,7 @@ class Partnership extends CommonObject $dataparams = ''; if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) { $classfortooltip = 'classforajaxtooltip'; - $dataparams = ' data-params='.json_encode($params); + $dataparams = " data-params='".json_encode($params)."'"; // $label = $langs->trans('Loading'); } $label = implode($this->getTooltipContentArray($params)); @@ -1320,6 +1320,36 @@ class Partnership extends CommonObject return $error; } + + /** + * Return a thumb for kanban views + * + * @param string $option Where point the link (0=> main card, 1,2 => shipment, 'nolink'=>No link) + * @param array $arraydata Array of data + * @return string HTML Code for Kanban thumb. + */ + public function getKanbanView($option = '', $arraydata = null) + { + global $conf, $langs; + $return = '
'; + $return .= '
'; + $return .= ''; + $return .= img_picto('', $this->picto); + $return .= ''; + $return .= '
'; + $return .= ''.(method_exists($this, 'getNomUrl') ? $this->getNomUrl() : $this->ref).''; + if (property_exists($this, 'label')) { + $return .= '
'.$this->label.'
'; + } + if (method_exists($this, 'getLibStatut')) { + $return .= '
'.$this->getLibStatut(5).'
'; + } + $return .= '
'; + $return .= '
'; + $return .= '
'; + + return $return; + } } diff --git a/htdocs/partnership/partnership_agenda.php b/htdocs/partnership/partnership_agenda.php index 3ee9fd63ebb..8214e3e907d 100644 --- a/htdocs/partnership/partnership_agenda.php +++ b/htdocs/partnership/partnership_agenda.php @@ -51,6 +51,7 @@ if (GETPOST('actioncode', 'array')) { } else { $actioncode = GETPOST("actioncode", "alpha", 3) ? GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : getDolGlobalString('AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT')); } +$search_rowid = GETPOST('search_rowid'); $search_agenda_label = GETPOST('search_agenda_label'); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; diff --git a/htdocs/partnership/partnership_list.php b/htdocs/partnership/partnership_list.php index 7144f201022..4fc78fdbdde 100644 --- a/htdocs/partnership/partnership_list.php +++ b/htdocs/partnership/partnership_list.php @@ -39,7 +39,7 @@ require_once DOL_DOCUMENT_ROOT.'/partnership/class/partnership.class.php'; // Load translation files required by the page $langs->loadLangs(array("partnership", "members", "other")); -$action = GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ... +$action = GETPOST('action', 'aZ09') ? GETPOST('action', 'aZ09') : 'view'; // The action 'create'/'add', 'edit'/'update', 'view', ... $massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists) $show_files = GETPOST('show_files', 'int'); // Show files area generated by bulk actions ? $confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation @@ -48,7 +48,7 @@ $toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected i $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : str_replace('_', '', basename(dirname(__FILE__)).basename(__FILE__, '.php')); // To manage different context of search $backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') -$mode = GETPOST('mode', 'aZ'); +$mode = GETPOST('mode', 'aZ'); // The output mode ('list', 'kanban', 'hierarchy', 'calendar', ...) $id = GETPOST('id', 'int'); $socid = GETPOST('socid', 'int'); @@ -311,9 +311,12 @@ if (!empty($extrafields->attributes[$object->table_element]['label'])) { } // Add fields from hooks $parameters = array(); -$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook +$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object, $action); // Note that $action and $object may have been modified by hook $sql .= preg_replace('/^,/', '', $hookmanager->resPrint); $sql = preg_replace('/,\s*$/', '', $sql); + +$sqlfields = $sql; // $sql fields to remove for count total + $sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)"; @@ -420,7 +423,8 @@ $sql=preg_replace('/,\s*$/','', $sql); $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { /* The fast and low memory method to get and count full list converts the sql into a sql count */ - $sqlforcount = preg_replace('/^SELECT[a-zA-Z0-9\._\s\(\),=<>\:\-\']+\sFROM/Ui', 'SELECT COUNT(*) as nbtotalofrecords FROM', $sql); + $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql); + $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount); $resql = $db->query($sqlforcount); if ($resql) { $objforcount = $db->fetch_object($resql); @@ -429,7 +433,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { dol_print_error($db); } - if (($page * $limit) > $nbtotalofrecords) { // if total of record found is smaller than page * limit, goto and load page 0 + if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0 $page = 0; $offset = 0; } @@ -576,6 +580,9 @@ if ($managedfor == "member") { $arrayofselected = is_array($toselect) ? $toselect : array(); $param = ''; +if (!empty($mode)) { + $param .= '&mode='.urlencode($mode); +} if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.urlencode($contextpage); } @@ -589,12 +596,16 @@ if ($memberid) { $param .= '&rowid='.urlencode($memberid); } foreach ($search as $key => $val) { - if (is_array($search[$key]) && count($search[$key])) { + if (is_array($search[$key])) { foreach ($search[$key] as $skey) { if ($skey != '') { $param .= '&search_'.$key.'[]='.urlencode($skey); } } + } elseif (preg_match('/(_dtstart|_dtend)$/', $key) && !empty($val)) { + $param .= '&search_'.$key.'month='.((int) GETPOST('search_'.$key.'month', 'int')); + $param .= '&search_'.$key.'day='.((int) GETPOST('search_'.$key.'day', 'int')); + $param .= '&search_'.$key.'year='.((int) GETPOST('search_'.$key.'year', 'int')); } elseif ($search[$key] != '') { $param .= '&search_'.$key.'='.urlencode($search[$key]); } @@ -640,15 +651,22 @@ print ''; print ''; print ''; print ''; +print ''; print ''; if ($socid) { print ''; } elseif ($memberid) { print ''; } + + $newcardbutton = ''; +$newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition')); +$newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition')); +$newcardbutton .= dolGetButtonTitleSeparator(); $newcardbutton .= dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', dol_buildpath('/partnership/partnership_card.php', 1).'?action=create&backtopage='.urlencode($_SERVER['PHP_SELF']), '', $permissiontoadd); + print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'object_'.$object->picto, 0, $newcardbutton, '', $limit, 0, 0, 1); // Add code for pre mass action (confirmation or email presend form) @@ -674,7 +692,7 @@ $moreforfilter.= $langs->trans('MyFilter') . ': '; print $moreforfilter; + $parameters = array('type'=>$type); + $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; print ''; } @@ -704,7 +725,7 @@ if ($managedfor == 'member') { // -------------------------------------------------------------------- print '
'; $searchpicto = $form->showFilterButtons('left'); print $searchpicto; @@ -723,9 +744,9 @@ foreach ($object->fields as $key => $val) { $cssforfield .= ($cssforfield ? ' ' : '').'right'; } if (!empty($arrayfields['t.'.$key]['checked'])) { - print ''; + print ''; if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) { - print $form->selectarray('search_'.$key, $val['arrayofkeyval'], (isset($search[$key]) ? $search[$key] : ''), $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1); + print $form->selectarray('search_'.$key, $val['arrayofkeyval'], (isset($search[$key]) ? $search[$key] : ''), $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100'.($key == 'status' ? ' search_status width100 onrightofpage' : ''), 1); } elseif ((strpos($val['type'], 'integer:') === 0) || (strpos($val['type'], 'sellist:') === 0)) { print $object->showInputField($val, $key, (isset($search[$key]) ? $search[$key] : ''), '', '', 'search_', $cssforfield.' maxwidth250', 1); } elseif (preg_match('/^(date|timestamp|datetime)/', $val['type'])) { @@ -757,10 +778,10 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; // Fields from hook $parameters = array('arrayfields'=>$arrayfields); -$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook +$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Action column -if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { +if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { print ''; $searchpicto = $form->showFilterButtons(); print $searchpicto; @@ -774,8 +795,9 @@ $totalarray['nbfield'] = 0; // Fields title label // -------------------------------------------------------------------- print '
'; - print '
'; + print '
'; } // Output Kanban print $object->getKanbanView(''); @@ -857,7 +879,7 @@ while ($i < $imaxinloop) { $j = 0; print '
'; if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined $selected = 0; @@ -867,6 +889,9 @@ while ($i < $imaxinloop) { print ''; } print ''; if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined $selected = 0; @@ -960,9 +985,9 @@ while ($i < $imaxinloop) { print ''; } print '
'.$langs->trans("NoRecordFound").'
'; print '
'; - print '
'; + print '
'; print dol_get_fiche_end(); diff --git a/htdocs/product/fournisseurs.php b/htdocs/product/fournisseurs.php index c1b61913d9f..d82fa8b1c41 100644 --- a/htdocs/product/fournisseurs.php +++ b/htdocs/product/fournisseurs.php @@ -460,7 +460,7 @@ if ($id > 0 || $ref) { print ''; print '
'; - print '
'; + print '
'; print dol_get_fiche_end(); diff --git a/htdocs/product/list.php b/htdocs/product/list.php index 9bd1a202245..15f8e93dd6b 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -1417,7 +1417,7 @@ while ($i < $imaxinloop) { if ($mode == 'kanban') { if ($i == 0) { print ''; - print '
'; + print '
'; } $product_static->price = $obj->price; // Output Kanban diff --git a/htdocs/product/price.php b/htdocs/product/price.php index 788857dfd47..08757602907 100644 --- a/htdocs/product/price.php +++ b/htdocs/product/price.php @@ -1312,7 +1312,7 @@ if (!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_ print "\n"; print '
'; -print '
'; +print '
'; print dol_get_fiche_end(); diff --git a/htdocs/product/stats/bom.php b/htdocs/product/stats/bom.php index 66e673567a6..0ccc249b94f 100644 --- a/htdocs/product/stats/bom.php +++ b/htdocs/product/stats/bom.php @@ -121,7 +121,7 @@ if ($id > 0 || !empty($ref)) { print ""; print '
'; - print '
'; + print '
'; print dol_get_fiche_end(); diff --git a/htdocs/product/stats/commande.php b/htdocs/product/stats/commande.php index 5559eaf8413..1df4f70c063 100644 --- a/htdocs/product/stats/commande.php +++ b/htdocs/product/stats/commande.php @@ -131,7 +131,7 @@ if ($id > 0 || !empty($ref)) { print ""; print '
'; - print '
'; + print '
'; print dol_get_fiche_end(); diff --git a/htdocs/product/stats/commande_fournisseur.php b/htdocs/product/stats/commande_fournisseur.php index 6ae1d7881ef..4d5972529cd 100644 --- a/htdocs/product/stats/commande_fournisseur.php +++ b/htdocs/product/stats/commande_fournisseur.php @@ -131,7 +131,7 @@ if ($id > 0 || !empty($ref)) { print ""; print '
'; - print '
'; + print '
'; print dol_get_fiche_end(); diff --git a/htdocs/product/stats/contrat.php b/htdocs/product/stats/contrat.php index bcf9c8c0737..a53c71085fd 100644 --- a/htdocs/product/stats/contrat.php +++ b/htdocs/product/stats/contrat.php @@ -120,7 +120,7 @@ if ($id > 0 || !empty($ref)) { print ""; print '
'; - print '
'; + print '
'; print dol_get_fiche_end(); diff --git a/htdocs/product/stats/facture.php b/htdocs/product/stats/facture.php index 3ff0b00d56a..c0a4d36793c 100644 --- a/htdocs/product/stats/facture.php +++ b/htdocs/product/stats/facture.php @@ -147,7 +147,7 @@ if ($id > 0 || !empty($ref)) { print ""; print '
'; - print '
'; + print '
'; print dol_get_fiche_end(); diff --git a/htdocs/product/stats/facture_fournisseur.php b/htdocs/product/stats/facture_fournisseur.php index 20bb56a3c19..8e89a05273f 100644 --- a/htdocs/product/stats/facture_fournisseur.php +++ b/htdocs/product/stats/facture_fournisseur.php @@ -132,7 +132,7 @@ if ($id > 0 || !empty($ref)) { print ""; print ''; - print '
'; + print '
'; print dol_get_fiche_end(); diff --git a/htdocs/product/stats/facturerec.php b/htdocs/product/stats/facturerec.php index 9b982407825..b09e572763a 100644 --- a/htdocs/product/stats/facturerec.php +++ b/htdocs/product/stats/facturerec.php @@ -148,7 +148,7 @@ if ($id > 0 || !empty($ref)) { print ""; print ''; - print '
'; + print '
'; print dol_get_fiche_end(); diff --git a/htdocs/product/stats/mo.php b/htdocs/product/stats/mo.php index 085a6687f5c..561557e62fe 100644 --- a/htdocs/product/stats/mo.php +++ b/htdocs/product/stats/mo.php @@ -2,6 +2,7 @@ /* Copyright (C) 2003-2007 Rodolphe Quiedeville * Copyright (C) 2004-2021 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2023 Gauthier VERDOL * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -28,6 +29,7 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php'; require_once DOL_DOCUMENT_ROOT.'/mrp/class/mo.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; // Load translation files required by the page $langs->loadLangs(array('mrp', 'products', 'companies')); @@ -63,6 +65,14 @@ if (!$sortfield) { $sortfield = "c.date_valid"; } +$search_month = GETPOST('search_month', 'int'); +$search_year = GETPOST('search_year', 'int'); + +if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { + $search_month = ''; + $search_year = ''; +} + $result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); @@ -74,6 +84,7 @@ $staticmo = new Mo($db); $staticmoligne = new MoLine($db); $form = new Form($db); +$formother = new FormOther($db); if ($id > 0 || !empty($ref)) { $product = new Product($db); @@ -120,7 +131,7 @@ if ($id > 0 || !empty($ref)) { print ""; print ''; - print '
'; + print '
'; print dol_get_fiche_end(); @@ -139,6 +150,12 @@ if ($id > 0 || !empty($ref)) { $sql .= " WHERE c.rowid = cd.fk_mo"; $sql .= " AND c.entity IN (".getEntity('mo').")"; $sql .= " AND cd.fk_product = ".((int) $product->id); + if (!empty($search_month)) { + $sql .= ' AND MONTH(c.date_valid) IN ('.$db->sanitize($search_month).')'; + } + if (!empty($search_year)) { + $sql .= ' AND YEAR(c.date_valid) IN ('.$db->sanitize($search_year).')'; + } if ($socid) { $sql .= " AND s.rowid = ".((int) $socid); } @@ -190,6 +207,18 @@ if ($id > 0 || !empty($ref)) { $option .= '&page='.urlencode($page); } + print '
'; + print '
'; + print $langs->trans('Period').' ('.$langs->trans("DateCreation").') - '; + print $langs->trans('Month').': '; + print $langs->trans('Year').':'.$formother->selectyear($search_year ? $search_year : - 1, 'search_year', 1, 20, 5); + print '
'; + print ''; + print ''; + print '
'; + print '
'; + print '
'; + $i = 0; print '
'; print ''; diff --git a/htdocs/product/stats/propal.php b/htdocs/product/stats/propal.php index b70d2e08161..e1b46677c65 100644 --- a/htdocs/product/stats/propal.php +++ b/htdocs/product/stats/propal.php @@ -133,7 +133,7 @@ if ($id > 0 || !empty($ref)) { print "
"; print '
'; - print '
'; + print '
'; print dol_get_fiche_end(); diff --git a/htdocs/product/stats/supplier_proposal.php b/htdocs/product/stats/supplier_proposal.php index 50b17b0ac06..a182aa61eb6 100644 --- a/htdocs/product/stats/supplier_proposal.php +++ b/htdocs/product/stats/supplier_proposal.php @@ -132,7 +132,7 @@ if ($id > 0 || !empty($ref)) { print ""; print ''; - print '
'; + print '
'; print dol_get_fiche_end(); diff --git a/htdocs/product/stock/class/entrepot.class.php b/htdocs/product/stock/class/entrepot.class.php index d201463b169..006eb353a6c 100644 --- a/htdocs/product/stock/class/entrepot.class.php +++ b/htdocs/product/stock/class/entrepot.class.php @@ -706,9 +706,9 @@ class Entrepot extends CommonObject if (isset($this->statut)) { $datas['picto'] .= ' '.$this->getLibStatut(5); } - $datas['ref'] .= '
'.$langs->trans('Ref').': '.(empty($this->ref) ? $this->label : $this->ref); + $datas['ref'] = '
'.$langs->trans('Ref').': '.(empty($this->ref) ? $this->label : $this->ref); if (!empty($this->lieu)) { - $datas['locationsummary'] .= '
'.$langs->trans('LocationSummary').': '.$this->lieu; + $datas['locationsummary'] = '
'.$langs->trans('LocationSummary').': '.$this->lieu; } return $datas; @@ -748,7 +748,7 @@ class Entrepot extends CommonObject $dataparams = ''; if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) { $classfortooltip = 'classforajaxtooltip'; - $dataparams = ' data-params='.json_encode($params); + $dataparams = " data-params='".json_encode($params)."'"; // $label = $langs->trans('Loading'); } diff --git a/htdocs/product/stock/class/productlot.class.php b/htdocs/product/stock/class/productlot.class.php index 39a8d5721a9..7d12acae368 100644 --- a/htdocs/product/stock/class/productlot.class.php +++ b/htdocs/product/stock/class/productlot.class.php @@ -4,6 +4,7 @@ * Copyright (C) 2015 Florian Henry * Copyright (C) 2015 Raphaël Doursenaud * Copyright (C) 2018-2022 Frédéric France + * Copyright (C) 2023 Gauthier VERDOL * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -554,6 +555,289 @@ class Productlot extends CommonObject } } + /** + * Charge tableau des stats expedition pour le lot/numéro de série + * + * @param int $socid Id societe + * @return int Array of stats in $this->stats_expedition, <0 if ko or >0 if ok + */ + public function loadStatsExpedition($socid = 0) + { + // phpcs:enable + global $db, $conf, $user, $hookmanager, $action; + + $sql = "SELECT COUNT(DISTINCT exp.fk_soc) as nb_customers, COUNT(DISTINCT exp.rowid) as nb,"; + $sql .= " COUNT(ed.rowid) as nb_rows, SUM(edb.qty) as qty"; + $sql .= " FROM ".$this->db->prefix()."expeditiondet_batch as edb"; + $sql .= " INNER JOIN ".$this->db->prefix()."expeditiondet as ed ON (ed.rowid = edb.fk_expeditiondet)"; + $sql .= " INNER JOIN ".$this->db->prefix()."expedition as exp ON (exp.rowid = ed.fk_expedition)"; + // $sql .= ", ".$this->db->prefix()."societe as s"; + if (empty($user->rights->societe->client->voir) && !$socid) { + $sql .= ", ".$this->db->prefix()."societe_commerciaux as sc"; + } + $sql .= " WHERE exp.entity IN (".getEntity('expedition').")"; + $sql .= " AND edb.batch = '".($this->db->escape($this->batch))."'"; + if (empty($user->rights->societe->client->voir) && !$socid) { + $sql .= " AND exp.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id); + } + //$sql.= " AND exp.fk_statut != 0"; + if ($socid > 0) { + $sql .= " AND exp.fk_soc = ".((int) $socid); + } + + $result = $this->db->query($sql); + if ($result) { + $obj = $this->db->fetch_object($result); + $this->stats_expedition['customers'] = $obj->nb_customers; + $this->stats_expedition['nb'] = $obj->nb; + $this->stats_expedition['rows'] = $obj->nb_rows; + $this->stats_expedition['qty'] = $obj->qty ? $obj->qty : 0; + + + // Virtual products can't be used with kits (see langs with key ErrorNoteAlsoThatSubProductCantBeFollowedByLot) + + // if it's a virtual product, maybe it is in invoice by extension + // if (!empty($conf->global->PRODUCT_STATS_WITH_PARENT_PROD_IF_INCDEC)) { + // $TFather = $this->getFather(); + // if (is_array($TFather) && !empty($TFather)) { + // foreach ($TFather as &$fatherData) { + // $pFather = new Product($this->db); + // $pFather->id = $fatherData['id']; + // $qtyCoef = $fatherData['qty']; + // + // if ($fatherData['incdec']) { + // $pFather->loadStatsExpedition($socid); + // + // $this->stats_expedition['customers'] += $pFather->stats_expedition['customers']; + // $this->stats_expedition['nb'] += $pFather->stats_expedition['nb']; + // $this->stats_expedition['rows'] += $pFather->stats_expedition['rows']; + // $this->stats_expedition['qty'] += $pFather->stats_expedition['qty'] * $qtyCoef; + // } + // } + // } + // } + + $parameters = array('socid' => $socid); + $reshook = $hookmanager->executeHooks('loadStatsLotExpedition', $parameters, $this, $action); + if ($reshook > 0) { + $this->stats_expedition = $hookmanager->resArray['stats_expedition']; + } + + return 1; + } else { + $this->error = $this->db->error(); + return -1; + } + } + + /** + * Charge tableau des stats commande fournisseur pour le lot/numéro de série + * + * @param int $socid Id societe + * @return int Array of stats in $this->stats_expedition, <0 if ko or >0 if ok + */ + public function loadStatsSupplierOrder($socid = 0) + { + // phpcs:enable + global $db, $conf, $user, $hookmanager, $action; + + $sql = "SELECT COUNT(DISTINCT cf.fk_soc) as nb_customers, COUNT(DISTINCT cf.rowid) as nb,"; + $sql .= " COUNT(cfd.rowid) as nb_rows, SUM(cfdi.qty) as qty"; + $sql .= " FROM ".$this->db->prefix()."commande_fournisseur_dispatch as cfdi"; + $sql .= " INNER JOIN ".$this->db->prefix()."commande_fournisseurdet as cfd ON (cfd.rowid = cfdi.fk_commandefourndet)"; + $sql .= " INNER JOIN ".$this->db->prefix()."commande_fournisseur as cf ON (cf.rowid = cfd.fk_commande)"; + // $sql .= ", ".$this->db->prefix()."societe as s"; + if (empty($user->rights->societe->client->voir) && !$socid) { + $sql .= ", ".$this->db->prefix()."societe_commerciaux as sc"; + } + $sql .= " WHERE cf.entity IN (".getEntity('expedition').")"; + $sql .= " AND cfdi.batch = '".($this->db->escape($this->batch))."'"; + if (empty($user->rights->societe->client->voir) && !$socid) { + $sql .= " AND cf.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id); + } + //$sql.= " AND cf.fk_statut != 0"; + if ($socid > 0) { + $sql .= " AND cf.fk_soc = ".((int) $socid); + } + + $result = $this->db->query($sql); + if ($result) { + $obj = $this->db->fetch_object($result); + $this->stats_supplier_order['customers'] = $obj->nb_customers; + $this->stats_supplier_order['nb'] = $obj->nb; + $this->stats_supplier_order['rows'] = $obj->nb_rows; + $this->stats_supplier_order['qty'] = $obj->qty ? $obj->qty : 0; + + + // Virtual products can't be used with kits (see langs with key ErrorNoteAlsoThatSubProductCantBeFollowedByLot) + + // if it's a virtual product, maybe it is in invoice by extension + // if (!empty($conf->global->PRODUCT_STATS_WITH_PARENT_PROD_IF_INCDEC)) { + // $TFather = $this->getFather(); + // if (is_array($TFather) && !empty($TFather)) { + // foreach ($TFather as &$fatherData) { + // $pFather = new Product($this->db); + // $pFather->id = $fatherData['id']; + // $qtyCoef = $fatherData['qty']; + // + // if ($fatherData['incdec']) { + // $pFather->stats_supplier_order($socid); + // + // $this->stats_supplier_order['customers'] += $pFather->stats_supplier_order['customers']; + // $this->stats_supplier_order['nb'] += $pFather->stats_supplier_order['nb']; + // $this->stats_supplier_order['rows'] += $pFather->stats_supplier_order['rows']; + // $this->stats_supplier_order['qty'] += $pFather->stats_supplier_order['qty'] * $qtyCoef; + // } + // } + // } + // } + + $parameters = array('socid' => $socid); + $reshook = $hookmanager->executeHooks('loadStatsLotSupplierOrder', $parameters, $this, $action); + if ($reshook > 0) { + $this->stats_supplier_order = $hookmanager->resArray['stats_supplier_order']; + } + + return 1; + } else { + $this->error = $this->db->error(); + return -1; + } + } + + /** + * Charge tableau des stats expedition pour le lot/numéro de série + * + * @param int $socid Id societe + * @return int Array of stats in $this->stats_expedition, <0 if ko or >0 if ok + */ + public function loadStatsReception($socid = 0) + { + // phpcs:enable + global $db, $conf, $user, $hookmanager, $action; + + $sql = "SELECT COUNT(DISTINCT recep.fk_soc) as nb_customers, COUNT(DISTINCT recep.rowid) as nb,"; + $sql .= " COUNT(cfdi.rowid) as nb_rows, SUM(cfdi.qty) as qty"; + $sql .= " FROM ".$this->db->prefix()."commande_fournisseur_dispatch as cfdi"; + $sql .= " INNER JOIN ".$this->db->prefix()."reception as recep ON (recep.rowid = cfdi.fk_reception)"; + // $sql .= ", ".$this->db->prefix()."societe as s"; + if (empty($user->rights->societe->client->voir) && !$socid) { + $sql .= ", ".$this->db->prefix()."societe_commerciaux as sc"; + } + $sql .= " WHERE recep.entity IN (".getEntity('reception').")"; + $sql .= " AND cfdi.batch = '".($this->db->escape($this->batch))."'"; + if (empty($user->rights->societe->client->voir) && !$socid) { + $sql .= " AND recep.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id); + } + //$sql.= " AND exp.fk_statut != 0"; + if ($socid > 0) { + $sql .= " AND recep.fk_soc = ".((int) $socid); + } + + $result = $this->db->query($sql); + if ($result) { + $obj = $this->db->fetch_object($result); + $this->stats_reception['customers'] = $obj->nb_customers; + $this->stats_reception['nb'] = $obj->nb; + $this->stats_reception['rows'] = $obj->nb_rows; + $this->stats_reception['qty'] = $obj->qty ? $obj->qty : 0; + + + // Virtual products can't be used with kits (see langs with key ErrorNoteAlsoThatSubProductCantBeFollowedByLot) + + // if it's a virtual product, maybe it is in invoice by extension + // if (!empty($conf->global->PRODUCT_STATS_WITH_PARENT_PROD_IF_INCDEC)) { + // $TFather = $this->getFather(); + // if (is_array($TFather) && !empty($TFather)) { + // foreach ($TFather as &$fatherData) { + // $pFather = new Product($this->db); + // $pFather->id = $fatherData['id']; + // $qtyCoef = $fatherData['qty']; + // + // if ($fatherData['incdec']) { + // $pFather->loadStatsReception($socid); + // + // $this->stats_expedition['customers'] += $pFather->stats_expedition['customers']; + // $this->stats_expedition['nb'] += $pFather->stats_expedition['nb']; + // $this->stats_expedition['rows'] += $pFather->stats_expedition['rows']; + // $this->stats_expedition['qty'] += $pFather->stats_expedition['qty'] * $qtyCoef; + // } + // } + // } + // } + + $parameters = array('socid' => $socid); + $reshook = $hookmanager->executeHooks('loadStatsLotReception', $parameters, $this, $action); + if ($reshook > 0) { + $this->stats_expedition = $hookmanager->resArray['stats_expedition']; + } + + return 1; + } else { + $this->error = $this->db->error(); + return -1; + } + } + + /** + * Charge tableau des stats expedition pour le lot/numéro de série + * + * @param int $socid Id societe + * @return int Array of stats in $this->stats_expedition, <0 if ko or >0 if ok + */ + public function loadStatsMo($socid = 0) + { + // phpcs:enable + global $user, $hookmanager, $action; + + $error = 0; + + foreach (array('toconsume', 'consumed', 'toproduce', 'produced') as $role) { + $this->stats_mo['customers_'.$role] = 0; + $this->stats_mo['nb_'.$role] = 0; + $this->stats_mo['qty_'.$role] = 0; + + $sql = "SELECT COUNT(DISTINCT c.fk_soc) as nb_customers, COUNT(DISTINCT c.rowid) as nb,"; + $sql .= " SUM(mp.qty) as qty"; + $sql .= " FROM ".$this->db->prefix()."mrp_mo as c"; + $sql .= " INNER JOIN ".$this->db->prefix()."mrp_production as mp ON mp.fk_mo=c.rowid"; + if (empty($user->rights->societe->client->voir) && !$socid) { + $sql .= "INNER JOIN ".$this->db->prefix()."societe_commerciaux as sc ON sc.fk_soc=c.fk_soc AND sc.fk_user = ".((int) $user->id); + } + $sql .= " WHERE "; + $sql .= " c.entity IN (".getEntity('mo').")"; + + $sql .= " AND mp.batch = '".($this->db->escape($this->batch))."'"; + $sql .= " AND mp.role ='".$this->db->escape($role)."'"; + if ($socid > 0) { + $sql .= " AND c.fk_soc = ".((int) $socid); + } + + $result = $this->db->query($sql); + if ($result) { + $obj = $this->db->fetch_object($result); + $this->stats_mo['customers_'.$role] = $obj->nb_customers ? $obj->nb_customers : 0; + $this->stats_mo['nb_'.$role] = $obj->nb ? $obj->nb : 0; + $this->stats_mo['qty_'.$role] = $obj->qty ? price2num($obj->qty, 'MS') : 0; // qty may be a float due to the SUM() + } else { + $this->error = $this->db->error(); + $error++; + } + } + + if (!empty($error)) { + return -1; + } + + $parameters = array('socid' => $socid); + $reshook = $hookmanager->executeHooks('loadStatsCustomerMO', $parameters, $this, $action); + if ($reshook > 0) { + $this->stats_mo = $hookmanager->resArray['stats_mo']; + } + + return 1; + } + /** * Return label of status of object @@ -641,7 +925,7 @@ class Productlot extends CommonObject $dataparams = ''; if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) { $classfortooltip = 'classforajaxtooltip'; - $dataparams = ' data-params='.json_encode($params); + $dataparams = " data-params='".json_encode($params)."'"; // $label = $langs->trans('Loading'); } diff --git a/htdocs/product/stock/list.php b/htdocs/product/stock/list.php index 9ab992d537b..56f83c26f03 100644 --- a/htdocs/product/stock/list.php +++ b/htdocs/product/stock/list.php @@ -634,7 +634,7 @@ while ($i < min($num, $limit)) { if ($mode =='kanban') { if ($i == 0) { print ''; - print '
'; + print '
'; } // Output Kanban print $warehouse->getKanbanView(''); diff --git a/htdocs/product/stock/product.php b/htdocs/product/stock/product.php index b0771bc39d9..80a5f969a84 100644 --- a/htdocs/product/stock/product.php +++ b/htdocs/product/stock/product.php @@ -903,7 +903,7 @@ if ($id > 0 || $ref) { print '
'; print '
'; - print '
'; + print '
'; } print dol_get_fiche_end(); diff --git a/htdocs/product/stock/productlot_document.php b/htdocs/product/stock/productlot_document.php index be6c7f640a4..38c5b0503d8 100644 --- a/htdocs/product/stock/productlot_document.php +++ b/htdocs/product/stock/productlot_document.php @@ -197,7 +197,7 @@ if ($object->id) { print ''; print ''; - print '
'; + print '
'; print dol_get_fiche_end(); diff --git a/htdocs/product/stock/replenish.php b/htdocs/product/stock/replenish.php index 2520eb8f559..cf6d6b8352d 100644 --- a/htdocs/product/stock/replenish.php +++ b/htdocs/product/stock/replenish.php @@ -146,6 +146,7 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' $includeproductswithoutdesiredqty = ''; $draftorder = ''; } +$draftchecked = ""; if ($draftorder == 'on') { $draftchecked = "checked"; } diff --git a/htdocs/product/stock/stats/commande_fournisseur.php b/htdocs/product/stock/stats/commande_fournisseur.php new file mode 100644 index 00000000000..22be071ffc5 --- /dev/null +++ b/htdocs/product/stock/stats/commande_fournisseur.php @@ -0,0 +1,376 @@ + + * Copyright (C) 2004-2016 Laurent Destailleur + * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2014 Juanjo Menent + * Copyright (C) 2014 Florian Henry + * Copyright (C) 2023 Gauthier VERDOL + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * 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/product/stock/stats/commande_fournisseur.php + * \ingroup product service facture + * \brief Page of supplier order statistics for a batch + */ + +// Load Dolibarr environment +require '../../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; +require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; +require_once DOL_DOCUMENT_ROOT.'/product/stock/class/productlot.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; + +// Load translation files required by the page +$langs->loadLangs(array('companies', 'bills', 'products', 'orders')); + +$id = GETPOST('id', 'int'); +$ref = GETPOST('ref', 'alpha'); +$batch = GETPOST('batch', 'alpha'); +$objectid = GETPOST('productid', 'int'); + +// Security check +$fieldvalue = (!empty($id) ? $id : (!empty($ref) ? $ref : '')); +$fieldtype = (!empty($ref) ? 'ref' : 'rowid'); +$socid = ''; +if (!empty($user->socid)) { + $socid = $user->socid; +} + +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context +$hookmanager->initHooks(array('batchproductstatssupplierorder')); + +$showmessage = GETPOST('showmessage'); + +// Load variable for pagination +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); +if (empty($page) || $page == -1) { + $page = 0; +} // If $page is not defined, or '' or -1 +$offset = $limit * $page; +$pageprev = $page - 1; +$pagenext = $page + 1; +if (!$sortorder) { + $sortorder = "DESC"; +} +if (!$sortfield) { + $sortfield = "cf.date_commande"; +} + +$search_month = GETPOST('search_month', 'int'); +$search_year = GETPOST('search_year', 'int'); + +if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { + $search_month = ''; + $search_year = ''; +} + +if (!$user->rights->produit->lire) accessforbidden(); + + +/* + * View + */ + +$commandefournisseurstatic = new CommandeFournisseur($db); +$societestatic = new Societe($db); + +$form = new Form($db); +$formother = new FormOther($db); + +if ($id > 0 || !empty($ref)) { + $object = new ProductLot($db); + if ($ref) { + $tmp = explode('_', $ref); + $objectid = $tmp[0]; + $batch = $tmp[1]; + } + $result = $object->fetch($id, $objectid, $batch); + + $parameters = array('id'=>$id); + $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + } + + $helpurl = ''; + $shortlabel = dol_trunc($object->batch, 16); + $title = $langs->trans('Batch')." ".$shortlabel." - ".$langs->trans('Referers'); + $helpurl = 'EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos'; + + llxHeader('', $title, $helpurl); + + if ($result > 0) { + $head = productlot_prepare_head($object); + $titre = $langs->trans("CardProduct".$object->type); + $picto = 'lot'; + print dol_get_fiche_head($head, 'referers', $langs->trans("Batch"), -1, $object->picto); + + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + } + + $linkback = ''.$langs->trans("BackToList").''; + + $shownav = 1; + if ($user->socid && !in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) { + $shownav = 0; + } + + dol_banner_tab($object, 'id', $linkback, $shownav, 'rowid', 'batch', $morehtmlref); + + print '
'; + + print '
'; + print ''; + + + // Product + print ''; + print "
'.$langs->trans("Product").''; + $producttmp = new Product($db); + $producttmp->fetch($object->fk_product); + print $producttmp->getNomUrl(1, 'stock')." - ".$producttmp->label; + print '
"; + + echo '
'; + + // // Sell by + // if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) { + // print ''; + // print $form->editfieldkey($langs->trans('SellByDate'), 'sellby', $object->sellby, $object, $user->rights->stock->creer, 'datepicker'); + // print ''; + // print $form->editfieldval($langs->trans('SellByDate'), 'sellby', $object->sellby, $object, $user->rights->stock->creer, 'datepicker'); + // print ''; + // print ''; + // } + // + // // Eat by + // if (empty($conf->global->PRODUCT_DISABLE_EATBY)) { + // print ''; + // print $form->editfieldkey($langs->trans('EatByDate'), 'eatby', $object->eatby, $object, $user->rights->stock->creer, 'datepicker'); + // print ''; + // print $form->editfieldval($langs->trans('EatByDate'), 'eatby', $object->eatby, $object, $user->rights->stock->creer, 'datepicker'); + // print ''; + // print ''; + // } + // + // if (!empty($conf->global->PRODUCT_LOT_ENABLE_TRACEABOLITY)) { + // print ''.$form->editfieldkey($langs->trans('ManufacturingDate'), 'manufacturing_date', $object->manufacturing_date, $object, $user->rights->stock->creer).''; + // print ''.$form->editfieldval($langs->trans('ManufacturingDate'), 'manufacturing_date', $object->manufacturing_date, $object, $user->rights->stock->creer, 'datepicker').''; + // print ''; + // // print ''.$form->editfieldkey($langs->trans('FirstUseDate'), 'commissionning_date', $object->commissionning_date, $object, $user->rights->stock->creer).''; + // // print ''.$form->editfieldval($langs->trans('FirstUseDate'), 'commissionning_date', $object->commissionning_date, $object, $user->rights->stock->creer, 'datepicker').''; + // // print ''; + // print ''.$form->editfieldkey($langs->trans('DestructionDate'), 'scrapping_date', $object->scrapping_date, $object, $user->rights->stock->creer).''; + // print ''.$form->editfieldval($langs->trans('DestructionDate'), 'scrapping_date', $object->scrapping_date, $object, $user->rights->stock->creer, 'datepicker').''; + // print ''; + // } + // + // // Quality control + // if (!empty($conf->global->PRODUCT_LOT_ENABLE_QUALITY_CONTROL)) { + // print ''.$form->editfieldkey($langs->trans('EndOfLife'), 'eol_date', $object->eol_date, $object, $user->rights->stock->creer).''; + // print ''.$form->editfieldval($langs->trans('EndOfLife'), 'eol_date', $object->eol_date, $object, $user->rights->stock->creer, 'datepicker').''; + // print ''; + // print ''.$form->editfieldkey($langs->trans('QCFrequency'), 'qc_frequency', $object->qc_frequency, $object, $user->rights->stock->creer).''; + // print ''.$form->editfieldval($langs->trans('QCFrequency'), 'qc_frequency', $object->qc_frequency, $object, $user->rights->stock->creer, 'numeric').''; + // print ''; + // } + // + // // Other attributes + // include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; + + print ''; + + $nboflines = show_stats_for_batch($object, $socid); + + print "
"; + + print '
'; + print '
'; + + print dol_get_fiche_end(); + + if ($showmessage && $nboflines > 1) { + print ''.$langs->trans("ClinkOnALinkOfColumn", $langs->transnoentitiesnoconv("Referers")).''; + } elseif ($user->rights->fournisseur->commande->lire) { + $sql = "SELECT DISTINCT s.nom as name, s.rowid as socid, s.code_fournisseur,"; + $sql .= " cf.ref, cf.date_commande, cf.date_livraison as delivery_date, cf.fk_statut as statut, cf.rowid as facid,"; + $sql .= " cfd.rowid, SUM(cfdi.qty) as qty"; + // $sql.= ", cfd.total_ht * SUM(cfdi.qty) / cfd.qty as total_ht_pondere"; + if (empty($user->rights->societe->client->voir) && !$socid) { + $sql .= ", sc.fk_soc, sc.fk_user "; + } + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."commande_fournisseur as cf ON (cf.fk_soc = s.rowid)"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."commande_fournisseurdet as cfd ON (cfd.fk_commande = cf.rowid)"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."commande_fournisseur_dispatch as cfdi ON (cfdi.fk_commandefourndet = cfd.rowid)"; + if (empty($user->rights->societe->client->voir) && !$socid) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + } + $sql .= " WHERE cf.entity IN (".getEntity('product').")"; + $sql .= " AND cfdi.batch = '".($db->escape($object->batch))."'"; + if (!empty($search_month)) { + $sql .= ' AND MONTH(cf.date_commande) IN ('.$db->sanitize($search_month).')'; + } + if (!empty($search_year)) { + $sql .= ' AND YEAR(cf.date_commande) IN ('.$db->sanitize($search_year).')'; + } + if (empty($user->rights->societe->client->voir) && !$socid) { + $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); + } + if ($socid) { + $sql .= " AND cf.fk_soc = ".((int) $socid); + } + $sql .= " GROUP BY cf.rowid"; + $sql .= $db->order($sortfield, $sortorder); + + // Calcul total qty and amount for global if full scan list + $total_ht_pondere = 0; + $total_qty = 0; + + // Count total nb of records + $totalofrecords = ''; + if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { + $result = $db->query($sql); + $totalofrecords = $db->num_rows($result); + } + + $sql .= $db->plimit($limit + 1, $offset); + + $result = $db->query($sql); + if ($result) { + $num = $db->num_rows($result); + + $option .= '&id='.$object->id; + + if ($limit > 0 && $limit != $conf->liste_limit) { + $option .= '&limit='.urlencode($limit); + } + if (!empty($search_month)) { + $option .= '&search_month='.urlencode($search_month); + } + if (!empty($search_year)) { + $option .= '&search_year='.urlencode($search_year); + } + + print '
'."\n"; + print ''; + if (!empty($sortfield)) { + print ''; + } + if (!empty($sortorder)) { + print ''; + } + + print_barre_liste($langs->trans("SuppliersOrders"), $page, $_SERVER["PHP_SELF"], $option, $sortfield, $sortorder, '', $num, $totalofrecords, '', 0, '', '', $limit, 0, 0, 1); + + if (!empty($page)) { + $option .= '&page='.urlencode($page); + } + + print '
'; + print '
'; + print $langs->trans('Period').' ('.$langs->trans("OrderDate").') - '; + print $langs->trans('Month').': '; + print $langs->trans('Year').':'.$formother->selectyear($search_year ? $search_year : - 1, 'search_year', 1, 20, 5); + print '
'; + print ''; + print ''; + print '
'; + print '
'; + print '
'; + + $i = 0; + print '
'; + print ''; + print ''; + print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "s.rowid", "", $option, '', $sortfield, $sortorder); + print_liste_field_titre("Company", $_SERVER["PHP_SELF"], "s.nom", "", $option, '', $sortfield, $sortorder); + print_liste_field_titre("SupplierCode", $_SERVER["PHP_SELF"], "s.code_fournisseur", "", $option, '', $sortfield, $sortorder); + print_liste_field_titre("OrderDate", $_SERVER["PHP_SELF"], "cf.date_commande", "", $option, 'align="center"', $sortfield, $sortorder); + print_liste_field_titre("DateDeliveryPlanned", $_SERVER["PHP_SELF"], "cf.date_livraison", "", $option, 'align="center"', $sortfield, $sortorder); + print_liste_field_titre("Qty", $_SERVER["PHP_SELF"], "cfdi.qty", "", $option, 'align="center"', $sortfield, $sortorder); + // print_liste_field_titre("AmountHT", $_SERVER["PHP_SELF"], "total_ht_pondere", "", $option, 'align="right"', $sortfield, $sortorder); + print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "cf.fk_statut", "", $option, 'align="right"', $sortfield, $sortorder); + print "\n"; + + if ($num > 0) { + while ($i < min($num, $limit)) { + $objp = $db->fetch_object($result); + + if ($objp->type == Facture::TYPE_CREDIT_NOTE) { + $objp->qty = -($objp->qty); + } + + // $total_ht_pondere += $objp->total_ht_pondere; + $total_qty += $objp->qty; + + $commandefournisseurstatic->id = $objp->facid; + $commandefournisseurstatic->ref = $objp->ref; + $societestatic->fetch($objp->socid); + // $paiement = $commandefournisseurstatic->getSommePaiement(); + + print ''; + print '\n"; + print ''; + print "\n"; + print '"; + print '"; + print '\n"; + // print '\n"; + print ''; + print "\n"; + $i++; + } + } + print ''; + if ($num < $limit) { + print ''; + } else { + print ''; + } + print ''; + print ''; + print ''; + print ''; + // print ''; + print ''; + print "
'; + print $commandefournisseurstatic->getNomUrl(1); + print "'.$societestatic->getNomUrl(1).'".$objp->code_fournisseur."'; + print dol_print_date($db->jdate($objp->date_commande), 'dayhour')."'; + print dol_print_date($db->jdate($objp->delivery_date), 'dayhour')."'.$objp->qty."'.price($objp->total_ht_pondere)."'.$commandefournisseurstatic->LibStatut($objp->statut, 5).'
'.$langs->trans("Total").''.$langs->trans("Totalforthispage").''.$total_qty.''.$total_ht_pondere.'
"; + print '
'; + print '
'; + } else { + dol_print_error($db); + } + $db->free($result); + } + } +} else { + dol_print_error(); +} + +// End of page +llxFooter(); +$db->close(); diff --git a/htdocs/product/stock/stats/expedition.php b/htdocs/product/stock/stats/expedition.php new file mode 100644 index 00000000000..79beefa40cb --- /dev/null +++ b/htdocs/product/stock/stats/expedition.php @@ -0,0 +1,366 @@ + + * Copyright (C) 2004-2016 Laurent Destailleur + * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2014 Juanjo Menent + * Copyright (C) 2014 Florian Henry + * Copyright (C) 2023 Gauthier VERDOL + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * 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/product/stock/stats/expedition.php + * \ingroup product service facture + * \brief Page of expedition statistics for a batch + */ + +// Load Dolibarr environment +require '../../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php'; +require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; +require_once DOL_DOCUMENT_ROOT.'/product/stock/class/productlot.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; + +// Load translation files required by the page +$langs->loadLangs(array('companies', 'bills', 'products', 'supplier_proposal', 'productbatch')); + +$id = GETPOST('id', 'int'); +$ref = GETPOST('ref', 'alpha'); +$batch = GETPOST('batch', 'alpha'); +$objectid = GETPOST('productid', 'int'); + +// Security check +$fieldvalue = (!empty($id) ? $id : (!empty($ref) ? $ref : '')); +$fieldtype = (!empty($ref) ? 'ref' : 'rowid'); +$socid = ''; +if (!empty($user->socid)) { + $socid = $user->socid; +} + +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context +$hookmanager->initHooks(array('batchproductstatsexpedition')); + +$showmessage = GETPOST('showmessage'); + +// Load variable for pagination +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); +if (empty($page) || $page == -1) { + $page = 0; +} // If $page is not defined, or '' or -1 +$offset = $limit * $page; +$pageprev = $page - 1; +$pagenext = $page + 1; +if (!$sortorder) { + $sortorder = "DESC"; +} +if (!$sortfield) { + $sortfield = "exp.date_creation"; +} + +$search_month = GETPOST('search_month', 'int'); +$search_year = GETPOST('search_year', 'int'); + +if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { + $search_month = ''; + $search_year = ''; +} + +if (!$user->rights->produit->lire) accessforbidden(); + + +/* + * View + */ + +$expeditionstatic = new Expedition($db); +$societestatic = new Societe($db); + +$form = new Form($db); +$formother = new FormOther($db); + +if ($id > 0 || !empty($ref)) { + $object = new ProductLot($db); + if ($ref) { + $tmp = explode('_', $ref); + $objectid = $tmp[0]; + $batch = $tmp[1]; + } + $result = $object->fetch($id, $objectid, $batch); + + $parameters = array('id'=>$id); + $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + } + + $helpurl = ''; + $shortlabel = dol_trunc($object->batch, 16); + $title = $langs->trans('Batch')." ".$shortlabel." - ".$langs->trans('Referers'); + $helpurl = 'EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos'; + + llxHeader('', $title, $helpurl); + + if ($result > 0) { + $head = productlot_prepare_head($object); + $titre = $langs->trans("CardProduct".$object->type); + $picto = 'lot'; + print dol_get_fiche_head($head, 'referers', $langs->trans("Batch"), -1, $object->picto); + + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + } + + $linkback = ''.$langs->trans("BackToList").''; + + $shownav = 1; + if ($user->socid && !in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) { + $shownav = 0; + } + + dol_banner_tab($object, 'id', $linkback, $shownav, 'rowid', 'batch', $morehtmlref); + + print '
'; + + print '
'; + print ''; + + + // Product + print ''; + print "
'.$langs->trans("Product").''; + $producttmp = new Product($db); + $producttmp->fetch($object->fk_product); + print $producttmp->getNomUrl(1, 'stock')." - ".$producttmp->label; + print '
"; + + echo '
'; + + // // Sell by + // if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) { + // print ''; + // print $form->editfieldkey($langs->trans('SellByDate'), 'sellby', $object->sellby, $object, $user->rights->stock->creer, 'datepicker'); + // print ''; + // print $form->editfieldval($langs->trans('SellByDate'), 'sellby', $object->sellby, $object, $user->rights->stock->creer, 'datepicker'); + // print ''; + // print ''; + // } + // + // // Eat by + // if (empty($conf->global->PRODUCT_DISABLE_EATBY)) { + // print ''; + // print $form->editfieldkey($langs->trans('EatByDate'), 'eatby', $object->eatby, $object, $user->rights->stock->creer, 'datepicker'); + // print ''; + // print $form->editfieldval($langs->trans('EatByDate'), 'eatby', $object->eatby, $object, $user->rights->stock->creer, 'datepicker'); + // print ''; + // print ''; + // } + // + // if (!empty($conf->global->PRODUCT_LOT_ENABLE_TRACEABOLITY)) { + // print ''.$form->editfieldkey($langs->trans('ManufacturingDate'), 'manufacturing_date', $object->manufacturing_date, $object, $user->rights->stock->creer).''; + // print ''.$form->editfieldval($langs->trans('ManufacturingDate'), 'manufacturing_date', $object->manufacturing_date, $object, $user->rights->stock->creer, 'datepicker').''; + // print ''; + // // print ''.$form->editfieldkey($langs->trans('FirstUseDate'), 'commissionning_date', $object->commissionning_date, $object, $user->rights->stock->creer).''; + // // print ''.$form->editfieldval($langs->trans('FirstUseDate'), 'commissionning_date', $object->commissionning_date, $object, $user->rights->stock->creer, 'datepicker').''; + // // print ''; + // print ''.$form->editfieldkey($langs->trans('DestructionDate'), 'scrapping_date', $object->scrapping_date, $object, $user->rights->stock->creer).''; + // print ''.$form->editfieldval($langs->trans('DestructionDate'), 'scrapping_date', $object->scrapping_date, $object, $user->rights->stock->creer, 'datepicker').''; + // print ''; + // } + // + // // Quality control + // if (!empty($conf->global->PRODUCT_LOT_ENABLE_QUALITY_CONTROL)) { + // print ''.$form->editfieldkey($langs->trans('EndOfLife'), 'eol_date', $object->eol_date, $object, $user->rights->stock->creer).''; + // print ''.$form->editfieldval($langs->trans('EndOfLife'), 'eol_date', $object->eol_date, $object, $user->rights->stock->creer, 'datepicker').''; + // print ''; + // print ''.$form->editfieldkey($langs->trans('QCFrequency'), 'qc_frequency', $object->qc_frequency, $object, $user->rights->stock->creer).''; + // print ''.$form->editfieldval($langs->trans('QCFrequency'), 'qc_frequency', $object->qc_frequency, $object, $user->rights->stock->creer, 'numeric').''; + // print ''; + // } + // + // // Other attributes + // include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; + + print ''; + + $nboflines = show_stats_for_batch($object, $socid); + + print "
"; + + print '
'; + print '
'; + + print dol_get_fiche_end(); + + if ($showmessage && $nboflines > 1) { + print ''.$langs->trans("ClinkOnALinkOfColumn", $langs->transnoentitiesnoconv("Referers")).''; + } elseif ($user->rights->expedition->lire) { + $sql = "SELECT DISTINCT s.nom as name, s.rowid as socid, s.code_client,"; + $sql .= " exp.ref, exp.date_creation, exp.fk_statut as statut, exp.rowid as facid,"; + $sql .= " d.rowid, db.qty"; + // $sql.= ", d.total_ht as total_ht"; // We must keep the d.rowid here to not loose record because of the distinct used to ignore duplicate line when link on societe_commerciaux is used + if (empty($user->rights->societe->client->voir) && !$socid) { + $sql .= ", sc.fk_soc, sc.fk_user "; + } + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."expedition as exp ON (exp.fk_soc = s.rowid)"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."expeditiondet as d ON (d.fk_expedition = exp.rowid)"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."expeditiondet_batch as db ON (db.fk_expeditiondet = d.rowid)"; + if (empty($user->rights->societe->client->voir) && !$socid) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + } + $sql .= " WHERE exp.entity IN (".getEntity('product').")"; + $sql .= " AND db.batch = '".($db->escape($object->batch))."'"; + if (!empty($search_month)) { + $sql .= ' AND MONTH(exp.date_creation) IN ('.$db->sanitize($search_month).')'; + } + if (!empty($search_year)) { + $sql .= ' AND YEAR(exp.date_creation) IN ('.$db->sanitize($search_year).')'; + } + if (empty($user->rights->societe->client->voir) && !$socid) { + $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); + } + if ($socid) { + $sql .= " AND exp.fk_soc = ".((int) $socid); + } + $sql .= $db->order($sortfield, $sortorder); + + // Calcul total qty and amount for global if full scan list + $total_ht = 0; + $total_qty = 0; + + // Count total nb of records + $totalofrecords = ''; + if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { + $result = $db->query($sql); + $totalofrecords = $db->num_rows($result); + } + + $sql .= $db->plimit($limit + 1, $offset); + + $result = $db->query($sql); + if ($result) { + $num = $db->num_rows($result); + + $option .= '&id='.$object->id; + + if ($limit > 0 && $limit != $conf->liste_limit) { + $option .= '&limit='.urlencode($limit); + } + if (!empty($search_month)) { + $option .= '&search_month='.urlencode($search_month); + } + if (!empty($search_year)) { + $option .= '&search_year='.urlencode($search_year); + } + + print '
'."\n"; + print ''; + if (!empty($sortfield)) { + print ''; + } + if (!empty($sortorder)) { + print ''; + } + + print_barre_liste($langs->trans("Shipments"), $page, $_SERVER["PHP_SELF"], $option, $sortfield, $sortorder, '', $num, $totalofrecords, '', 0, '', '', $limit, 0, 0, 1); + + if (!empty($page)) { + $option .= '&page='.urlencode($page); + } + + print '
'; + print '
'; + print $langs->trans('Period').' ('.$langs->trans("DateCreation").') - '; + print $langs->trans('Month').': '; + print $langs->trans('Year').':'.$formother->selectyear($search_year ? $search_year : - 1, 'search_year', 1, 20, 5); + print '
'; + print ''; + print ''; + print '
'; + print '
'; + print '
'; + + $i = 0; + print '
'; + print ''; + print ''; + print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "s.rowid", "", $option, '', $sortfield, $sortorder); + print_liste_field_titre("Company", $_SERVER["PHP_SELF"], "s.nom", "", $option, '', $sortfield, $sortorder); + print_liste_field_titre("CustomerCode", $_SERVER["PHP_SELF"], "s.code_client", "", $option, '', $sortfield, $sortorder); + print_liste_field_titre("DateCreation", $_SERVER["PHP_SELF"], "exp.date_creation", "", $option, 'align="center"', $sortfield, $sortorder); + print_liste_field_titre("Qty", $_SERVER["PHP_SELF"], "d.qty", "", $option, 'align="center"', $sortfield, $sortorder); + // print_liste_field_titre("AmountHT", $_SERVER["PHP_SELF"], "d.total_ht", "", $option, 'align="right"', $sortfield, $sortorder); + print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "exp.fk_statut", "", $option, 'align="right"', $sortfield, $sortorder); + print "\n"; + + if ($num > 0) { + while ($i < min($num, $limit)) { + $objp = $db->fetch_object($result); + + $total_ht += $objp->total_ht; + $total_qty += $objp->qty; + + $expeditionstatic->id = $objp->facid; + $expeditionstatic->ref = $objp->ref; + $societestatic->fetch($objp->socid); + // $paiement = $expeditionstatic->getSommePaiement(); + + print ''; + print '\n"; + print ''; + print "\n"; + print '"; + print '\n"; + // print '\n"; + print ''; + print "\n"; + $i++; + } + } + print ''; + if ($num < $limit) { + print ''; + } else { + print ''; + } + print ''; + print ''; + print ''; + print ''; + print "
'; + print $expeditionstatic->getNomUrl(1); + print "'.$societestatic->getNomUrl(1).'".$objp->code_client."'; + print dol_print_date($db->jdate($objp->date_creation), 'dayhour')."'.$objp->qty."'.price($objp->total_ht)."'.$expeditionstatic->LibStatut($objp->statut, 5).'
'.$langs->trans("Total").''.$langs->trans("Totalforthispage").''.$total_qty.'
"; + print '
'; + print '
'; + } else { + dol_print_error($db); + } + $db->free($result); + } + } +} else { + dol_print_error(); +} + +// End of page +llxFooter(); +$db->close(); diff --git a/htdocs/product/stock/stats/mo.php b/htdocs/product/stock/stats/mo.php new file mode 100644 index 00000000000..f0be40d1a1d --- /dev/null +++ b/htdocs/product/stock/stats/mo.php @@ -0,0 +1,321 @@ + + * Copyright (C) 2004-2021 Laurent Destailleur + * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2023 Gauthier VERDOL + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * 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/product/stats/mo.php + * \ingroup product mo + * \brief Page of MO referring product + */ + +// Load Dolibarr environment +require '../../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/mrp/class/mo.class.php'; +require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; +require_once DOL_DOCUMENT_ROOT.'/product/stock/class/productlot.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; + +// Load translation files required by the page +$langs->loadLangs(array('mrp', 'products', 'companies', 'productbatch')); + +$id = GETPOST('id', 'int'); +$ref = GETPOST('ref', 'alpha'); + +// Security check +$fieldvalue = (!empty($id) ? $id : (!empty($ref) ? $ref : '')); +$fieldtype = (!empty($ref) ? 'ref' : 'rowid'); +if ($user->socid) { + $socid = $user->socid; +} + +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context +$hookmanager->initHooks(array('batchproductstatsmo')); + +// Load variable for pagination +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); +if (empty($page) || $page == -1) { + $page = 0; +} // If $page is not defined, or '' or -1 +$offset = $limit * $page; +$pageprev = $page - 1; +$pagenext = $page + 1; +if (!$sortorder) { + $sortorder = "DESC"; +} +if (!$sortfield) { + $sortfield = "c.date_valid"; +} + +$search_month = GETPOST('search_month', 'int'); +$search_year = GETPOST('search_year', 'int'); + +if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { + $search_month = ''; + $search_year = ''; +} + +if (!$user->rights->produit->lire) accessforbidden(); + + +/* + * View + */ + +$staticmo = new Mo($db); +$staticmoligne = new MoLine($db); + +$form = new Form($db); +$formother = new FormOther($db); + +if ($id > 0 || !empty($ref)) { + $object = new ProductLot($db); + if ($ref) { + $tmp = explode('_', $ref); + $objectid = $tmp[0]; + $batch = $tmp[1]; + } + $result = $object->fetch($id, $objectid, $batch); + + $parameters = array('id'=>$id); + $reshook = $hookmanager->executeHooks('doActions', $parameters, $product, $action); // Note that $action and $object may have been modified by some hooks + if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + } + + $helpurl = ''; + $shortlabel = dol_trunc($object->batch, 16); + $title = $langs->trans('Batch')." ".$shortlabel." - ".$langs->trans('Referers'); + $helpurl = 'EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos'; + + llxHeader('', $title, $helpurl); + + if ($result > 0) { + $head = productlot_prepare_head($object); + $titre = $langs->trans("CardProduct".$object->type); + $picto = 'lot'; + print dol_get_fiche_head($head, 'referers', $langs->trans("Batch"), -1, $object->picto); + + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $product, $action); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + } + + $linkback = ''.$langs->trans("BackToList").''; + + $shownav = 1; + if ($user->socid && !in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) { + $shownav = 0; + } + + dol_banner_tab($object, 'id', $linkback, $shownav, 'rowid', 'batch', $morehtmlref); + + print '
'; + + print '
'; + print ''; + + // Product + print ''; + print "
'.$langs->trans("Product").''; + $producttmp = new Product($db); + $producttmp->fetch($object->fk_product); + print $producttmp->getNomUrl(1, 'stock')." - ".$producttmp->label; + print '
"; + + echo '
'; + + print ''; + + $nboflines = show_stats_for_batch($object, $socid); + + print "
"; + + print '
'; + print '
'; + + print dol_get_fiche_end(); + + + $now = dol_now(); + + $sql = "SELECT"; + // $sql .= " sum(".$db->ifsql("cd.role='toconsume'", "cd.qty", 0).') as nb_toconsume,'; + $sql .= " sum(".$db->ifsql("cd.role='consumed'", "cd.qty", 0).') as nb_consumed,'; + // $sql .= " sum(".$db->ifsql("cd.role='toproduce'", "cd.qty", 0).') as nb_toproduce,'; + $sql .= " sum(".$db->ifsql("cd.role='produced'", "cd.qty", 0).') as nb_produced,'; + $sql .= " c.rowid as rowid, c.ref, c.date_valid, c.status"; + //$sql .= " s.nom as name, s.rowid as socid, s.code_client"; + $sql .= " FROM ".MAIN_DB_PREFIX."mrp_mo as c"; + $sql .= ", ".MAIN_DB_PREFIX."mrp_production as cd"; + $sql .= " WHERE c.rowid = cd.fk_mo"; + $sql .= " AND c.entity IN (".getEntity('mo').")"; + $sql .= " AND cd.batch = '".($db->escape($object->batch))."'"; + if (!empty($search_month)) { + $sql .= ' AND MONTH(c.date_valid) IN ('.$db->sanitize($search_month).')'; + } + if (!empty($search_year)) { + $sql .= ' AND YEAR(c.date_valid) IN ('.$db->sanitize($search_year).')'; + } + if ($socid) { + $sql .= " AND s.rowid = ".((int) $socid); + } + $sql .= " GROUP BY c.rowid, c.ref, c.date_valid, c.status"; + //$sql .= ", s.nom, s.rowid, s.code_client"; + $sql .= $db->order($sortfield, $sortorder); + + //Calcul total qty and amount for global if full scan list + $total_ht = 0; + $total_qty = 0; + + // Count total nb of records + $totalofrecords = ''; + if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { + $result = $db->query($sql); + $totalofrecords = $db->num_rows($result); + } + + $sql .= $db->plimit($limit + 1, $offset); + + $result = $db->query($sql); + if ($result) { + $num = $db->num_rows($result); + + $option = '&id='.$object->id; + + if ($limit > 0 && $limit != $conf->liste_limit) { + $option .= '&limit='.urlencode($limit); + } + if (!empty($search_month)) { + $option .= '&search_month='.urlencode($search_month); + } + if (!empty($search_year)) { + $option .= '&search_year='.urlencode($search_year); + } + + print '
'."\n"; + print ''; + if (!empty($sortfield)) { + print ''; + } + if (!empty($sortorder)) { + print ''; + } + + print_barre_liste($langs->trans("MOs"), $page, $_SERVER["PHP_SELF"], $option, $sortfield, $sortorder, '', $num, $totalofrecords, '', 0, '', '', $limit, 0, 0, 1); + + if (!empty($page)) { + $option .= '&page='.urlencode($page); + } + + print '
'; + print '
'; + print $langs->trans('Period').' ('.$langs->trans("DateCreation").') - '; + print $langs->trans('Month').': '; + print $langs->trans('Year').':'.$formother->selectyear($search_year ? $search_year : - 1, 'search_year', 1, 20, 5); + print '
'; + print ''; + print ''; + print '
'; + print '
'; + print '
'; + + $i = 0; + print '
'; + print ''; + + print ''; + + print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "c.rowid", "", $option."&id=".$object->id, '', $sortfield, $sortorder); + //print_liste_field_titre("Company", $_SERVER["PHP_SELF"], "s.nom", "", "&id=".$object->id, '', $sortfield, $sortorder); + print_liste_field_titre("Date", $_SERVER["PHP_SELF"], "c.date_valid", "", $option."&id=".$object->id, 'align="center"', $sortfield, $sortorder); + //print_liste_field_titre("AmountHT"),$_SERVER["PHP_SELF"],"c.amount","","&id=".$object->id,'align="right"',$sortfield,$sortorder); + // print_liste_field_titre("ToConsume", $_SERVER["PHP_SELF"], "", "", "&id=".$object->id, '', $sortfield, $sortorder, 'center '); + print_liste_field_titre("QtyAlreadyConsumed", $_SERVER["PHP_SELF"], "", "", $option."&id=".$object->id, '', $sortfield, $sortorder, 'center '); + // print_liste_field_titre("QtyToProduce", $_SERVER["PHP_SELF"], "", "", "&id=".$object->id, '', $sortfield, $sortorder, 'center '); + print_liste_field_titre("QtyAlreadyProduced", $_SERVER["PHP_SELF"], "", "", $option."&id=".$object->id, '', $sortfield, $sortorder, 'center '); + print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "c.status", "", $option."&id=".$object->id, '', $sortfield, $sortorder, 'right '); + print "\n"; + + $motmp = new Mo($db); + + $total_consumed=$total_produced=0; + + if ($num > 0) { + while ($i < min($num, $limit)) { + $objp = $db->fetch_object($result); + + $motmp->id = $objp->rowid; + $motmp->ref = $objp->ref; + $motmp->status = $objp->status; + + $total_consumed+=$objp->nb_consumed; + $total_produced+=$objp->nb_produced; + + print ''; + print '\n"; + print ""; + //print "\n"; + //print ''; + print ''; + // print ''; + print ''; + //$mostatic->LibStatut($objp->statut,5).''; + print ''; + print "\n"; + $i++; + } + } + print ''; + if ($num < $limit) { + print ''; + } else { + print ''; + } + print ''; + print ''; + print ''; + print ''; + print "
'; + print $motmp->getNomUrl(1, 'production'); + print ""; + print dol_print_date($db->jdate($objp->date_valid), 'dayhour')."".price($objp->total_ht)."'; + // print ''.($objp->nb_toconsume > 0 ? $objp->nb_toconsume : '').''.($objp->nb_consumed > 0 ? $objp->nb_consumed : '').''.($objp->nb_toproduce > 0 ? $objp->nb_toproduce : '').''.($objp->nb_produced > 0 ? $objp->nb_produced : '').''.$motmp->getLibStatut(2).'
'.$langs->trans("Total").''.$langs->trans("Totalforthispage").''.$total_consumed.''.$total_produced.'
"; + print '
'; + print '
'; + + print ''; + print ''; + print ''; + } else { + dol_print_error($db); + } + $db->free($result); + } +} else { + dol_print_error(); +} + +// End of page +llxFooter(); +$db->close(); diff --git a/htdocs/product/stock/stats/reception.php b/htdocs/product/stock/stats/reception.php new file mode 100644 index 00000000000..4e80dcf05f2 --- /dev/null +++ b/htdocs/product/stock/stats/reception.php @@ -0,0 +1,365 @@ + + * Copyright (C) 2004-2016 Laurent Destailleur + * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2014 Juanjo Menent + * Copyright (C) 2014 Florian Henry + * Copyright (C) 2023 Gauthier VERDOL + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * 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/product/stock/stats/reception.php + * \ingroup product service facture + * \brief Page of reception statistics for a batch + */ + +// Load Dolibarr environment +require '../../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/reception/class/reception.class.php'; +require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; +require_once DOL_DOCUMENT_ROOT.'/product/stock/class/productlot.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; + +// Load translation files required by the page +$langs->loadLangs(array('companies', 'bills', 'products', 'supplier_proposal', 'productbatch')); + +$id = GETPOST('id', 'int'); +$ref = GETPOST('ref', 'alpha'); +$batch = GETPOST('batch', 'alpha'); +$objectid = GETPOST('productid', 'int'); + +// Security check +$fieldvalue = (!empty($id) ? $id : (!empty($ref) ? $ref : '')); +$fieldtype = (!empty($ref) ? 'ref' : 'rowid'); +$socid = ''; +if (!empty($user->socid)) { + $socid = $user->socid; +} + +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context +$hookmanager->initHooks(array('batchproductstatsreception')); + +$showmessage = GETPOST('showmessage'); + +// Load variable for pagination +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); +if (empty($page) || $page == -1) { + $page = 0; +} // If $page is not defined, or '' or -1 +$offset = $limit * $page; +$pageprev = $page - 1; +$pagenext = $page + 1; +if (!$sortorder) { + $sortorder = "DESC"; +} +if (!$sortfield) { + $sortfield = "recep.date_creation"; +} + +$search_month = GETPOST('search_month', 'int'); +$search_year = GETPOST('search_year', 'int'); + +if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { + $search_month = ''; + $search_year = ''; +} + +if (!$user->rights->produit->lire) accessforbidden(); + + +/* + * View + */ + +$receptionstatic = new Reception($db); +$societestatic = new Societe($db); + +$form = new Form($db); +$formother = new FormOther($db); + +if ($id > 0 || !empty($ref)) { + $object = new ProductLot($db); + if ($ref) { + $tmp = explode('_', $ref); + $objectid = $tmp[0]; + $batch = $tmp[1]; + } + $result = $object->fetch($id, $objectid, $batch); + + $parameters = array('id'=>$id); + $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + } + + $title = $langs->trans('ProductServiceCard'); + $helpurl = ''; + $shortlabel = dol_trunc($object->batch, 16); + $title = $langs->trans('Batch')." ".$shortlabel." - ".$langs->trans('Referers'); + + llxHeader('', $title, $helpurl); + + if ($result > 0) { + $head = productlot_prepare_head($object); + $titre = $langs->trans("CardProduct".$object->type); + $picto = 'lot'; + print dol_get_fiche_head($head, 'referers', $langs->trans("Batch"), -1, $object->picto); + + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + } + + $linkback = ''.$langs->trans("BackToList").''; + + $shownav = 1; + if ($user->socid && !in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) { + $shownav = 0; + } + + dol_banner_tab($object, 'id', $linkback, $shownav, 'rowid', 'batch', $morehtmlref); + + print '
'; + + print '
'; + print ''; + + + // Product + print ''; + print "
'.$langs->trans("Product").''; + $producttmp = new Product($db); + $producttmp->fetch($object->fk_product); + print $producttmp->getNomUrl(1, 'stock')." - ".$producttmp->label; + print '
"; + + echo '
'; + + // // Sell by + // if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) { + // print ''; + // print $form->editfieldkey($langs->trans('SellByDate'), 'sellby', $object->sellby, $object, $user->rights->stock->creer, 'datepicker'); + // print ''; + // print $form->editfieldval($langs->trans('SellByDate'), 'sellby', $object->sellby, $object, $user->rights->stock->creer, 'datepicker'); + // print ''; + // print ''; + // } + // + // // Eat by + // if (empty($conf->global->PRODUCT_DISABLE_EATBY)) { + // print ''; + // print $form->editfieldkey($langs->trans('EatByDate'), 'eatby', $object->eatby, $object, $user->rights->stock->creer, 'datepicker'); + // print ''; + // print $form->editfieldval($langs->trans('EatByDate'), 'eatby', $object->eatby, $object, $user->rights->stock->creer, 'datepicker'); + // print ''; + // print ''; + // } + // + // if (!empty($conf->global->PRODUCT_LOT_ENABLE_TRACEABOLITY)) { + // print ''.$form->editfieldkey($langs->trans('ManufacturingDate'), 'manufacturing_date', $object->manufacturing_date, $object, $user->rights->stock->creer).''; + // print ''.$form->editfieldval($langs->trans('ManufacturingDate'), 'manufacturing_date', $object->manufacturing_date, $object, $user->rights->stock->creer, 'datepicker').''; + // print ''; + // // print ''.$form->editfieldkey($langs->trans('FirstUseDate'), 'commissionning_date', $object->commissionning_date, $object, $user->rights->stock->creer).''; + // // print ''.$form->editfieldval($langs->trans('FirstUseDate'), 'commissionning_date', $object->commissionning_date, $object, $user->rights->stock->creer, 'datepicker').''; + // // print ''; + // print ''.$form->editfieldkey($langs->trans('DestructionDate'), 'scrapping_date', $object->scrapping_date, $object, $user->rights->stock->creer).''; + // print ''.$form->editfieldval($langs->trans('DestructionDate'), 'scrapping_date', $object->scrapping_date, $object, $user->rights->stock->creer, 'datepicker').''; + // print ''; + // } + // + // // Quality control + // if (!empty($conf->global->PRODUCT_LOT_ENABLE_QUALITY_CONTROL)) { + // print ''.$form->editfieldkey($langs->trans('EndOfLife'), 'eol_date', $object->eol_date, $object, $user->rights->stock->creer).''; + // print ''.$form->editfieldval($langs->trans('EndOfLife'), 'eol_date', $object->eol_date, $object, $user->rights->stock->creer, 'datepicker').''; + // print ''; + // print ''.$form->editfieldkey($langs->trans('QCFrequency'), 'qc_frequency', $object->qc_frequency, $object, $user->rights->stock->creer).''; + // print ''.$form->editfieldval($langs->trans('QCFrequency'), 'qc_frequency', $object->qc_frequency, $object, $user->rights->stock->creer, 'numeric').''; + // print ''; + // } + // + // // Other attributes + // include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; + + print ''; + + $nboflines = show_stats_for_batch($object, $socid); + + print "
"; + + print '
'; + print '
'; + + print dol_get_fiche_end(); + + if ($showmessage && $nboflines > 1) { + print ''.$langs->trans("ClinkOnALinkOfColumn", $langs->transnoentitiesnoconv("Referers")).''; + } elseif ($user->rights->reception->lire) { + $sql = "SELECT DISTINCT s.nom as name, s.rowid as socid, s.code_fournisseur,"; + $sql .= " recep.ref, recep.date_creation, recep.fk_statut as statut, recep.rowid as facid,"; + $sql .= " d.qty"; + // $sql.= ", d.total_ht as total_ht"; // We must keep the d.rowid here to not loose record because of the distinct used to ignore duplicate line when link on societe_commerciaux is used + if (empty($user->rights->societe->client->voir) && !$socid) { + $sql .= ", sc.fk_soc, sc.fk_user "; + } + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."reception as recep ON (recep.fk_soc = s.rowid)"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."commande_fournisseur_dispatch as d ON (d.fk_reception = recep.rowid)"; + if (empty($user->rights->societe->client->voir) && !$socid) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + } + $sql .= " WHERE recep.entity IN (".getEntity('product').")"; + $sql .= " AND d.batch = '".($db->escape($object->batch))."'"; + if (!empty($search_month)) { + $sql .= ' AND MONTH(recep.date_creation) IN ('.$db->sanitize($search_month).')'; + } + if (!empty($search_year)) { + $sql .= ' AND YEAR(recep.date_creation) IN ('.$db->sanitize($search_year).')'; + } + if (empty($user->rights->societe->client->voir) && !$socid) { + $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); + } + if ($socid) { + $sql .= " AND recep.fk_soc = ".((int) $socid); + } + $sql .= $db->order($sortfield, $sortorder); + + // Calcul total qty and amount for global if full scan list + $total_ht = 0; + $total_qty = 0; + + // Count total nb of records + $totalofrecords = ''; + if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { + $result = $db->query($sql); + $totalofrecords = $db->num_rows($result); + } + + $sql .= $db->plimit($limit + 1, $offset); + + $result = $db->query($sql); + if ($result) { + $num = $db->num_rows($result); + + $option .= '&id='.$object->id; + + if ($limit > 0 && $limit != $conf->liste_limit) { + $option .= '&limit='.urlencode($limit); + } + if (!empty($search_month)) { + $option .= '&search_month='.urlencode($search_month); + } + if (!empty($search_year)) { + $option .= '&search_year='.urlencode($search_year); + } + + print '
'."\n"; + print ''; + if (!empty($sortfield)) { + print ''; + } + if (!empty($sortorder)) { + print ''; + } + + print_barre_liste($langs->trans("Receptions"), $page, $_SERVER["PHP_SELF"], $option, $sortfield, $sortorder, '', $num, $totalofrecords, '', 0, '', '', $limit, 0, 0, 1); + + if (!empty($page)) { + $option .= '&page='.urlencode($page); + } + + print '
'; + print '
'; + print $langs->trans('Period').' ('.$langs->trans("DateCreation").') - '; + print $langs->trans('Month').': '; + print $langs->trans('Year').':'.$formother->selectyear($search_year ? $search_year : - 1, 'search_year', 1, 20, 5); + print '
'; + print ''; + print ''; + print '
'; + print '
'; + print '
'; + + $i = 0; + print '
'; + print ''; + print ''; + print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "s.rowid", "", $option, '', $sortfield, $sortorder); + print_liste_field_titre("Company", $_SERVER["PHP_SELF"], "s.nom", "", $option, '', $sortfield, $sortorder); + print_liste_field_titre("SupplierCode", $_SERVER["PHP_SELF"], "s.code_fournisseur", "", $option, '', $sortfield, $sortorder); + print_liste_field_titre("DateCreation", $_SERVER["PHP_SELF"], "recep.date_creation", "", $option, 'align="center"', $sortfield, $sortorder); + print_liste_field_titre("Qty", $_SERVER["PHP_SELF"], "d.qty", "", $option, 'align="center"', $sortfield, $sortorder); + // print_liste_field_titre("AmountHT", $_SERVER["PHP_SELF"], "d.total_ht", "", $option, 'align="right"', $sortfield, $sortorder); + print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "recep.fk_statut", "", $option, 'align="right"', $sortfield, $sortorder); + print "\n"; + + if ($num > 0) { + while ($i < min($num, $limit)) { + $objp = $db->fetch_object($result); + + $total_ht += $objp->total_ht; + $total_qty += $objp->qty; + + $receptionstatic->id = $objp->facid; + $receptionstatic->ref = $objp->ref; + $societestatic->fetch($objp->socid); + // $paiement = $receptionstatic->getSommePaiement(); + + print ''; + print '\n"; + print ''; + print "\n"; + print '"; + print '\n"; + // print '\n"; + print ''; + print "\n"; + $i++; + } + } + print ''; + if ($num < $limit) { + print ''; + } else { + print ''; + } + print ''; + print ''; + print ''; + print ''; + print "
'; + print $receptionstatic->getNomUrl(1); + print "'.$societestatic->getNomUrl(1).'".$objp->code_fournisseur."'; + print dol_print_date($db->jdate($objp->date_creation), 'dayhour')."'.$objp->qty."'.price($objp->total_ht)."'.$receptionstatic->LibStatut($objp->statut, 5).'
'.$langs->trans("Total").''.$langs->trans("Totalforthispage").''.$total_qty.'
"; + print '
'; + print '
'; + } else { + dol_print_error($db); + } + $db->free($result); + } + } +} else { + dol_print_error(); +} + +// End of page +llxFooter(); +$db->close(); diff --git a/htdocs/product/stock/stocktransfer/stocktransfer_agenda.php b/htdocs/product/stock/stocktransfer/stocktransfer_agenda.php index 1f0d66cdac6..893bbf05ff6 100644 --- a/htdocs/product/stock/stocktransfer/stocktransfer_agenda.php +++ b/htdocs/product/stock/stocktransfer/stocktransfer_agenda.php @@ -47,6 +47,7 @@ if (GETPOST('actioncode', 'array')) { } else { $actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : getDolGlobalString('AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT')); } +$search_rowid = GETPOST('search_rowid'); $search_agenda_label = GETPOST('search_agenda_label'); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; @@ -221,9 +222,9 @@ if ($object->id > 0) { // List of all actions $filters = array(); $filters['search_agenda_label'] = $search_agenda_label; + $filters['search_rowid'] = $search_rowid; // TODO Replace this with same code than into list.php - show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder, ''); } } diff --git a/htdocs/product/stock/tpl/extrafields_add.tpl.php b/htdocs/product/stock/tpl/extrafields_add.tpl.php index 144c638a1cf..951704a4352 100644 --- a/htdocs/product/stock/tpl/extrafields_add.tpl.php +++ b/htdocs/product/stock/tpl/extrafields_add.tpl.php @@ -42,8 +42,14 @@ $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, print $hookmanager->resPrint; if (empty($reshook)) { $params = array(); - if (isset($tpl_context)) $params['tpl_context'] = $tpl_context; - $params['cols'] = $parameters['colspanvalue']; + $params['cols'] = key_exists('colspanvalue', $parameters) ? $parameters['colspanvalue'] : ''; + if (!empty($parameters['tdclass'])) { + $params['tdclass'] = $parameters['tdclass']; + } + if (!empty($parameters['tpl_context'])) { + $params['tpl_context'] = $parameters['tpl_context']; + } + print $object->showOptionals($extrafields, 'create', $params); } diff --git a/htdocs/projet/agenda.php b/htdocs/projet/agenda.php index bea22c4c0c4..a0840287c2a 100644 --- a/htdocs/projet/agenda.php +++ b/htdocs/projet/agenda.php @@ -61,6 +61,7 @@ if (GETPOST('actioncode', 'array')) { } else { $actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : getDolGlobalString('AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT')); } +$search_rowid = GETPOST('search_rowid'); $search_agenda_label = GETPOST('search_agenda_label'); $hookmanager->initHooks(array('projectcardinfo')); @@ -213,6 +214,8 @@ if (!empty($object->id)) { // List of all actions $filters = array(); $filters['search_agenda_label'] = $search_agenda_label; + $filters['search_rowid'] = $search_rowid; + show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder); } diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index 2adcf05fce9..42d5404f3c9 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -52,6 +52,7 @@ $backtopagejsfields = GETPOST('backtopagejsfields', 'alpha'); $cancel = GETPOST('cancel', 'alpha'); $confirm = GETPOST('confirm', 'aZ09'); +$dol_openinpopup = 0; if (!empty($backtopagejsfields)) { $tmpbacktopagejsfields = explode(':', $backtopagejsfields); $dol_openinpopup = $tmpbacktopagejsfields[0]; @@ -103,6 +104,8 @@ if ($id == '' && $ref == '' && ($action != "create" && $action != "add" && $acti accessforbidden(); } +$permissiontoadd = $user->rights->projet->creer; +$permissiontodelete = $user->rights->projet->supprimer; $permissiondellink = $user->rights->projet->creer; // Used by the include of actions_dellink.inc.php @@ -156,7 +159,20 @@ if (empty($reshook)) { include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, not include_once - if ($action == 'add' && $user->rights->projet->creer) { + // Action setdraft object + if ($action == 'confirm_setdraft' && $confirm == 'yes' && $permissiontoadd) { + $result = $object->setStatut($object::STATUS_DRAFT, null, '', 'PROJECT_MODIFY'); + if ($result >= 0) { + // Nothing else done + } else { + $error++; + setEventMessages($object->error, $object->errors, 'errors'); + } + $action = ''; + } + + // Action add + if ($action == 'add' && $permissiontoadd) { $error = 0; if (!GETPOST('ref')) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Ref")), null, 'errors'); @@ -264,7 +280,7 @@ if (empty($reshook)) { } } - if ($action == 'update' && empty(GETPOST('cancel')) && $user->rights->projet->creer) { + if ($action == 'update' && empty(GETPOST('cancel')) && $permissiontoadd) { $error = 0; if (empty($ref)) { @@ -380,7 +396,7 @@ if (empty($reshook)) { } // Build doc - if ($action == 'builddoc' && $user->rights->projet->creer) { + if ($action == 'builddoc' && $permissiontoadd) { // Save last template used to generate document if (GETPOST('model')) { $object->setDocModel($user, GETPOST('model', 'alpha')); @@ -399,7 +415,7 @@ if (empty($reshook)) { } // Delete file in doc form - if ($action == 'remove_file' && $user->rights->projet->creer) { + if ($action == 'remove_file' && $permissiontoadd) { if ($object->id > 0) { require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -417,28 +433,28 @@ if (empty($reshook)) { } - if ($action == 'confirm_validate' && $confirm == 'yes') { + if ($action == 'confirm_validate' && $confirm == 'yes' && $permissiontoadd) { $result = $object->setValid($user); if ($result <= 0) { setEventMessages($object->error, $object->errors, 'errors'); } } - if ($action == 'confirm_close' && $confirm == 'yes') { + if ($action == 'confirm_close' && $confirm == 'yes' && $permissiontoadd) { $result = $object->setClose($user); if ($result <= 0) { setEventMessages($object->error, $object->errors, 'errors'); } } - if ($action == 'confirm_reopen' && $confirm == 'yes') { + if ($action == 'confirm_reopen' && $confirm == 'yes' && $permissiontoadd) { $result = $object->setValid($user); if ($result <= 0) { setEventMessages($object->error, $object->errors, 'errors'); } } - if ($action == 'confirm_delete' && GETPOST("confirm") == "yes" && $user->rights->projet->supprimer) { + if ($action == 'confirm_delete' && $confirm == 'yes' && $permissiontodelete) { $object->fetch($id); $result = $object->delete($user); if ($result > 0) { @@ -451,7 +467,7 @@ if (empty($reshook)) { } } - if ($action == 'confirm_clone' && $user->rights->projet->creer && $confirm == 'yes') { + if ($action == 'confirm_clone' && $permissiontoadd && $confirm == 'yes') { $clone_contacts = GETPOST('clone_contacts') ? 1 : 0; $clone_tasks = GETPOST('clone_tasks') ? 1 : 0; $clone_project_files = GETPOST('clone_project_files') ? 1 : 0; @@ -1107,7 +1123,7 @@ if ($action == 'create' && $user->rights->projet->creer) { print ''.$langs->trans("OpportunityStatus").''; print ''; print '
'; - print $formproject->selectOpportunityStatus('opp_status', $object->opp_status, 1, 0, 0, 0, 'inline-block valignmiddle', 1, 1); + print $formproject->selectOpportunityStatus('opp_status', $object->opp_status, 1, 0, 0, 0, 'minwidth150 inline-block valignmiddle', 1, 1); // Opportunity probability print ' %'; @@ -1488,6 +1504,17 @@ if ($action == 'create' && $user->rights->projet->creer) { } */ + // Back to draft + if (!getDolGlobalString('MAIN_DISABLEDRAFTSTATUS') && !getDolGlobalString('MAIN_DISABLEDRAFTSTATUS_PROJECT')) { + if ($object->statut != Project::STATUS_DRAFT && $user->rights->projet->creer) { + if ($userWrite > 0) { + print dolGetButtonAction('', $langs->trans('SetToDraft'), 'default', $_SERVER["PHP_SELF"].'?action=confirm_setdraft&confirm=yes&token='.newToken().'&id='.$object->id, ''); + } else { + print dolGetButtonAction($langs->trans('NotOwnerOfProject'), $langs->trans('SetToDraft'), 'default', $_SERVER['PHP_SELF']. '#', '', false); + } + } + } + // Modify if ($object->statut != Project::STATUS_CLOSED && $user->rights->projet->creer) { if ($userWrite > 0) { @@ -1530,15 +1557,15 @@ if ($action == 'create' && $user->rights->projet->creer) { print''.$langs->trans("Create").''; print ''; -print '
'; +print '
'; print dol_get_fiche_end(); diff --git a/htdocs/projet/tasks.php b/htdocs/projet/tasks.php index ec10af0f884..e50855047d2 100644 --- a/htdocs/projet/tasks.php +++ b/htdocs/projet/tasks.php @@ -770,7 +770,7 @@ if ($action == 'create' && $user->rights->projet->creer && (empty($object->third if (is_array($contactsofproject) && count($contactsofproject)) { print $form->select_dolusers($user->id, 'userid', 0, '', 0, '', $contactsofproject, 0, 0, 0, '', 0, '', 'maxwidth300'); } else { - if ($projectid > 0 || $object->id > 0) { + if ((isset($projectid) && $projectid > 0) || $object->id > 0) { print ''.$langs->trans("NoUserAssignedToTheProject").''; } else { print $form->select_dolusers($user->id, 'userid', 0, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth300'); @@ -805,6 +805,7 @@ if ($action == 'create' && $user->rights->projet->creer && (empty($object->third // WYSIWYG editor include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; $cked_enabled = (!empty($conf->global->FCKEDITOR_ENABLE_SOCIETE) ? $conf->global->FCKEDITOR_ENABLE_SOCIETE : 0); + $nbrows = 0; if (!empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) { $nbrows = $conf->global->MAIN_INPUT_DESC_HEIGHT; } diff --git a/htdocs/projet/tasks/list.php b/htdocs/projet/tasks/list.php index bc4c8770f0f..00449a30a17 100644 --- a/htdocs/projet/tasks/list.php +++ b/htdocs/projet/tasks/list.php @@ -1127,7 +1127,7 @@ while ($i < $imaxinloop) { if ($mode == 'kanban') { if ($i == 0) { print ''; - print '
'; + print '
'; } // Output Kanban $object->fk_statut = $projectstatic->getLibStatut(1); diff --git a/htdocs/projet/tasks/stats/index.php b/htdocs/projet/tasks/stats/index.php index 07b0199d480..ee0bae2dc45 100644 --- a/htdocs/projet/tasks/stats/index.php +++ b/htdocs/projet/tasks/stats/index.php @@ -224,7 +224,7 @@ print $stringtoshow; print '
'; -print '
'; +print '
'; print dol_get_fiche_end(); diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index a4661911910..30f2a867af0 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -1109,7 +1109,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser //'builddoc'=>$langs->trans("PDFMerge"), ); } - if ( isModEnabled('ficheinter') && $user->rights->ficheinter->creer) { + if ( isModEnabled('ficheinter') && $user->hasRight('ficheinter', 'creer')) { $langs->load("interventions"); $arrayofmassactions['generateinter'] = $langs->trans("GenerateInter"); } @@ -1388,9 +1388,9 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser print ''; } elseif ($action == 'createtime' && $user->rights->projet->time) { print ''; - } elseif ($massaction == 'generateinvoice' && $user->rights->facture->creer) { + } elseif ($massaction == 'generateinvoice' && $user->hasRight('facture', 'creer')) { print ''; - } elseif ($massaction == 'generateinter' && $user->rights->ficheinter->creer) { + } elseif ($massaction == 'generateinter' && $user->hasRight('ficheinter', 'creer')) { print ''; } else { print ''; diff --git a/htdocs/public/members/new.php b/htdocs/public/members/new.php index 56bf2d3bd8d..953040d73af 100644 --- a/htdocs/public/members/new.php +++ b/htdocs/public/members/new.php @@ -506,7 +506,7 @@ $extrafields->fetch_name_optionals_label($object->table_element); // fetch optio llxHeaderVierge($langs->trans("NewSubscription")); - +print '
'; print load_fiche_titre($langs->trans("NewSubscription"), '', '', 0, 0, 'center'); @@ -686,7 +686,7 @@ if (!empty($conf->global->MEMBER_SKIP_TABLE) || !empty($conf->global->MEMBER_NEW print ''.$langs->trans("Public").''."\n"; // Other attributes - $tpl_context = 'public'; // define template context to public + $parameters['tpl_context']='public'; // define template context to public include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php'; // Comments diff --git a/htdocs/public/partnership/new.php b/htdocs/public/partnership/new.php index 49e7d986eb2..4fa4d25e543 100644 --- a/htdocs/public/partnership/new.php +++ b/htdocs/public/partnership/new.php @@ -535,7 +535,7 @@ $extrafields->fetch_name_optionals_label($object->table_element); // fetch optio llxHeaderVierge($langs->trans("NewPartnershipRequest")); - +print '
'; print load_fiche_titre($langs->trans("NewPartnershipRequest"), '', '', 0, 0, 'center'); @@ -577,44 +577,25 @@ jQuery(document).ready(function () { '; -print ''."\n"; - // Type -/* -if (empty($conf->global->PARTNERSHIP_NEWFORM_FORCETYPE)) { - $listoftype = $partnershipt->liste_array(); - $tmp = array_keys($listoftype); - $defaulttype = ''; - $isempty = 1; - if (count($listoftype) == 1) { - $defaulttype = $tmp[0]; - $isempty = 0; - } - print ''."\n"; -} else { - $partnershipt->fetch($conf->global->PARTNERSHIP_NEWFORM_FORCETYPE); - print ''; -} -*/ - $partnershiptype = new PartnershipType($db); -$listofpartnershipobj = $partnershiptype->fetchAll('', '', 1000); +$listofpartnershipobj = $partnershiptype->fetchAll('', '', 1000, 0, array('active'=>1)); $listofpartnership = array(); foreach ($listofpartnershipobj as $partnershipobj) { $listofpartnership[$partnershipobj->id] = $partnershipobj->label; } -if (empty($conf->global->PARTNERSHIP_NEWFORM_FORCETYPE)) { - print ''."\n"; -} else { +if (getDolGlobalString('PARTNERSHIP_NEWFORM_FORCETYPE')) { print $listofpartnership[$conf->global->PARTNERSHIP_NEWFORM_FORCETYPE]; print ''; } +print '
'.$langs->trans("Type").' *'; - print $form->selectarray("typeid", $partnershipt->liste_array(1), GETPOST('typeid') ? GETPOST('typeid') : $defaulttype, $isempty); - print '
'.$langs->trans('PartnershipType').' *'."\n"; - print $form->selectarray("partnershiptype", $listofpartnership, GETPOSTISSET('partnershiptype') ? GETPOST('partnershiptype', 'int') : 'ifone', 1); - print '
'."\n"; +if (!getDolGlobalString('PARTNERSHIP_NEWFORM_FORCETYPE')) { + print ''."\n"; +} // Company print ''."\n"; // Other attributes -$tpl_context = 'public'; // define template context to public +$parameters['tdclass']='titlefieldauto'; +$parameters['tpl_context']='public'; // define template context to public include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php'; // Comments print ''; diff --git a/htdocs/public/project/new.php b/htdocs/public/project/new.php index a70667ccb31..5644123392b 100644 --- a/htdocs/public/project/new.php +++ b/htdocs/public/project/new.php @@ -534,7 +534,7 @@ if (empty($conf->global->SOCIETE_DISABLE_STATE)) { } // Other attributes -$tpl_context = 'public'; // define template context to public +$parameters['tpl_context']='public'; // define template context to public include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php'; // Comments print ''; diff --git a/htdocs/public/ticket/index.php b/htdocs/public/ticket/index.php index 84652017b37..239d9f71d59 100644 --- a/htdocs/public/ticket/index.php +++ b/htdocs/public/ticket/index.php @@ -89,7 +89,7 @@ print ''; print ''; diff --git a/htdocs/public/ticket/view.php b/htdocs/public/ticket/view.php index edf2504fb0c..1bfc235ff65 100644 --- a/htdocs/public/ticket/view.php +++ b/htdocs/public/ticket/view.php @@ -206,7 +206,7 @@ if ($action == "view_ticket" || $action == "presend" || $action == "close" || $a $triggersendname = 'TICKET_SENTBYMAIL'; $paramname = 'id'; $autocopy = 'MAIN_MAIL_AUTOCOPY_TICKET_TO'; // used to know the automatic BCC to add -if (!empty($object->id)) $trackid = 'tic'.$object->id; +if (!empty($object->dao->id)) $trackid = 'tic'.$object->dao->id; include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; @@ -345,7 +345,7 @@ if ($action == "view_ticket" || $action == "presend" || $action == "close" || $a $formticket->action = "add_message"; $formticket->track_id = $object->dao->track_id; - $formticket->id = $object->dao->id; + $formticket->trackid = 'tic'.$object->dao->id; $formticket->param = array('track_id' => $object->dao->track_id, 'fk_user_create' => '-1', 'returnurl' => DOL_URL_ROOT.'/public/ticket/view.php'.(!empty($entity) && isModEnabled('multicompany')?'?entity='.$entity:'')); diff --git a/htdocs/reception/class/api_receptions.class.php b/htdocs/reception/class/api_receptions.class.php index 5e4c68fe468..a7b8bdb02ce 100644 --- a/htdocs/reception/class/api_receptions.class.php +++ b/htdocs/reception/class/api_receptions.class.php @@ -60,7 +60,6 @@ class Receptions extends DolibarrApi * * @param int $id ID of reception * @return Object Object with cleaned properties - * * @throws RestException */ public function get($id) @@ -386,14 +385,12 @@ class Receptions extends DolibarrApi /** * Delete a line to given reception * - * * @param int $id Id of reception to update * @param int $lineid Id of line to delete + * @return array * * @url DELETE {id}/lines/{lineid} * - * @return int - * * @throws RestException 401 * @throws RestException 404 */ @@ -412,23 +409,27 @@ class Receptions extends DolibarrApi throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - // TODO Check the lineid $lineid is a line of ojbect + // TODO Check the lineid $lineid is a line of object $updateRes = $this->reception->deleteline(DolibarrApiAccess::$user, $lineid); - if ($updateRes > 0) { - return $this->get($id); - } else { + if ($updateRes < 0) { throw new RestException(405, $this->reception->error); } + + return array( + 'success' => array( + 'code' => 200, + 'message' => 'Line deleted' + ) + ); } /** * Update reception general fields (won't touch lines of reception) * - * @param int $id Id of reception to update - * @param array $request_data Datas - * - * @return int + * @param int $id Id of reception to update + * @param array $request_data Datas + * @return Object Object with cleaned properties */ public function put($id, $request_data = null) { @@ -462,7 +463,6 @@ class Receptions extends DolibarrApi * Delete reception * * @param int $id Reception ID - * * @return array */ public function delete($id) diff --git a/htdocs/reception/stats/index.php b/htdocs/reception/stats/index.php index df11e2a9cd5..f951beca058 100644 --- a/htdocs/reception/stats/index.php +++ b/htdocs/reception/stats/index.php @@ -302,7 +302,7 @@ print '
'.$langs->trans('PartnershipType').' *'."\n"; + print $form->selectarray("partnershiptype", $listofpartnership, GETPOSTISSET('partnershiptype') ? GETPOST('partnershiptype', 'int') : 'ifone', 1); + print '
'.$langs->trans("Company").' *'; print img_picto('', 'company', 'class="pictofixedwidth"'); @@ -668,7 +649,8 @@ if (empty($conf->global->SOCIETE_DISABLE_STATE)) { // Logo //print '
'.$langs->trans("URLPhoto").'
'; print '
'; -print '
'; +print '
'; print dol_get_fiche_end(); diff --git a/htdocs/recruitment/class/api_recruitment.class.php b/htdocs/recruitment/class/api_recruitment.class.php index 9162a6250f3..c8e21a3e029 100644 --- a/htdocs/recruitment/class/api_recruitment.class.php +++ b/htdocs/recruitment/class/api_recruitment.class.php @@ -407,9 +407,9 @@ class Recruitment extends DolibarrApi /** * Update jobposition * - * @param int $id Id of jobposition to update - * @param array $request_data Datas - * @return int + * @param int $id Id of jobposition to update + * @param array $request_data Datas + * @return Object Object with cleaned properties * * @throws RestException * @@ -450,9 +450,9 @@ class Recruitment extends DolibarrApi /** * Update candidature * - * @param int $id Id of candidature to update - * @param array $request_data Datas - * @return int + * @param int $id Id of candidature to update + * @param array $request_data Datas + * @return Object Object with cleaned properties * * @throws RestException * diff --git a/htdocs/recruitment/core/modules/recruitment/doc/doc_generic_recruitmentjobposition_odt.modules.php b/htdocs/recruitment/core/modules/recruitment/doc/doc_generic_recruitmentjobposition_odt.modules.php index 147e8ec3519..a415cb5c940 100644 --- a/htdocs/recruitment/core/modules/recruitment/doc/doc_generic_recruitmentjobposition_odt.modules.php +++ b/htdocs/recruitment/core/modules/recruitment/doc/doc_generic_recruitmentjobposition_odt.modules.php @@ -482,9 +482,7 @@ class doc_generic_recruitmentjobposition_odt extends ModelePDFRecruitmentJobPosi $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); $reshook = $hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); $odfHandler = null; // Destroy object diff --git a/htdocs/recruitment/core/modules/recruitment/doc/pdf_standard_recruitmentjobposition.modules.php b/htdocs/recruitment/core/modules/recruitment/doc/pdf_standard_recruitmentjobposition.modules.php index 61c2eb3ff20..a0747f13f45 100644 --- a/htdocs/recruitment/core/modules/recruitment/doc/pdf_standard_recruitmentjobposition.modules.php +++ b/htdocs/recruitment/core/modules/recruitment/doc/pdf_standard_recruitmentjobposition.modules.php @@ -710,13 +710,11 @@ class pdf_standard_recruitmentjobposition extends ModelePDFRecruitmentJobPositio $this->errors = $hookmanager->errors; } - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); - $this->result = array('fullpath'=>$file); + $this->result = array('fullpath'=>$file); - return 1; // No error + return 1; // No error } else { $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); return 0; diff --git a/htdocs/recruitment/recruitmentcandidature_agenda.php b/htdocs/recruitment/recruitmentcandidature_agenda.php index e5e28f9a662..19e64bc9a09 100644 --- a/htdocs/recruitment/recruitmentcandidature_agenda.php +++ b/htdocs/recruitment/recruitmentcandidature_agenda.php @@ -51,6 +51,7 @@ if (GETPOST('actioncode', 'array')) { } else { $actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : getDolGlobalString('AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT')); } +$search_rowid = GETPOST('search_rowid'); $search_agenda_label = GETPOST('search_agenda_label'); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; @@ -128,7 +129,7 @@ $form = new Form($db); if ($object->id > 0) { $title = $object->ref." - ".$langs->trans('Agenda'); //if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/',$conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->name." - ".$title; - $help_url = 'Module_Agenda_En'; + $help_url = 'Module_Agenda_En|DE:Modul_Terminplanung'; llxHeader('', $title, $help_url); if (isModEnabled('notification')) { @@ -247,6 +248,7 @@ if ($object->id > 0) { // List of all actions $filters = array(); $filters['search_agenda_label'] = $search_agenda_label; + $filters['search_rowid'] = $search_rowid; // TODO Replace this with same code than into list.php show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder, 'recruitment'); diff --git a/htdocs/recruitment/recruitmentcandidature_list.php b/htdocs/recruitment/recruitmentcandidature_list.php index 95b6ac6203d..8fcd62fc078 100644 --- a/htdocs/recruitment/recruitmentcandidature_list.php +++ b/htdocs/recruitment/recruitmentcandidature_list.php @@ -733,7 +733,7 @@ while ($i < $imaxinloop) { if ($mode == 'kanban') { if ($i == 0) { print ''; - print '
'; + print '
'; } $recuitment = new RecruitmentJobPosition($db); $recuitment->fetch($obj->fk_recruitmentjobposition); diff --git a/htdocs/recruitment/recruitmentjobposition_agenda.php b/htdocs/recruitment/recruitmentjobposition_agenda.php index d935a4a588a..cacee2fd82c 100644 --- a/htdocs/recruitment/recruitmentjobposition_agenda.php +++ b/htdocs/recruitment/recruitmentjobposition_agenda.php @@ -50,6 +50,7 @@ if (GETPOST('actioncode', 'array')) { } else { $actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : getDolGlobalString('AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT')); } +$search_rowid = GETPOST('search_rowid'); $search_agenda_label = GETPOST('search_agenda_label'); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; @@ -243,6 +244,7 @@ if ($object->id > 0) { // List of all actions $filters = array(); $filters['search_agenda_label'] = $search_agenda_label; + $filters['search_rowid'] = $search_rowid; // TODO Replace this with same code than into list.php show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder, 'recruitment'); diff --git a/htdocs/recruitment/recruitmentjobposition_list.php b/htdocs/recruitment/recruitmentjobposition_list.php index 670eca08040..8a0d3f06540 100644 --- a/htdocs/recruitment/recruitmentjobposition_list.php +++ b/htdocs/recruitment/recruitmentjobposition_list.php @@ -591,7 +591,7 @@ while ($i < $imaxinloop) { if ($mode == 'kanban') { if ($i == 0) { print ''; - print '
'; + print '
'; } if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { if ($massactionbutton || $massaction) { diff --git a/htdocs/resource/agenda.php b/htdocs/resource/agenda.php index b5a0c099cff..d05b5070be3 100644 --- a/htdocs/resource/agenda.php +++ b/htdocs/resource/agenda.php @@ -54,6 +54,7 @@ if (GETPOST('actioncode', 'array')) { $actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : getDolGlobalString('AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT')); } +$search_rowid = GETPOST('search_rowid'); $search_agenda_label = GETPOST('search_agenda_label'); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; @@ -179,6 +180,7 @@ if ($object->id > 0) { // List of all actions $filters = array(); $filters['search_agenda_label'] = $search_agenda_label; + $filters['search_rowid'] = $search_rowid; // TODO Replace this with same code than into list.php show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder); diff --git a/htdocs/resource/class/dolresource.class.php b/htdocs/resource/class/dolresource.class.php index 5d0c0481b98..a2d8863f8ed 100644 --- a/htdocs/resource/class/dolresource.class.php +++ b/htdocs/resource/class/dolresource.class.php @@ -815,7 +815,7 @@ class Dolresource extends CommonObject $dataparams = ''; if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) { $classfortooltip = 'classforajaxtooltip'; - $dataparams = ' data-params='.json_encode($params); + $dataparams = " data-params='".json_encode($params)."'"; // $label = $langs->trans('Loading'); } $label = implode($this->getTooltipContentArray($params)); diff --git a/htdocs/salaries/card.php b/htdocs/salaries/card.php index 42fecf28b37..2b118d50d58 100644 --- a/htdocs/salaries/card.php +++ b/htdocs/salaries/card.php @@ -5,6 +5,8 @@ * Copyright (C) 2015 Charlie BENKE * Copyright (C) 2018-2022 Frédéric France * Copyright (C) 2021 Gauthier VERDOL + * Copyright (C) 2023 Maxime Nicolas + * Copyright (C) 2023 Benjamin GREMBI * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -148,6 +150,12 @@ if (empty($reshook)) { } $action = ''; } + // Actions to send emails + $triggersendname = 'COMPANY_SENTBYMAIL'; + $paramname = 'id'; + $mode = 'emailfromthirdparty'; + $trackid = 'thi'.$object->id; + include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; } // Link to a project @@ -382,7 +390,7 @@ if ($action == 'confirm_clone' && $confirm == 'yes' && ($user->rights->salaries- $object->id = $object->ref = null; if (GETPOST('amount', 'alphanohtml')) { - $object->amount = price2num(GETPOST('amount', 'alphanohtml'), 'MT', 2); + $object->amount = price2num(GETPOST('amount', 'alphanohtml'), 'MT', 2); } if (GETPOST('clone_label', 'alphanohtml')) { @@ -451,7 +459,6 @@ if (isModEnabled('project')) $formproject = new FormProjets($db); $title = $langs->trans('Salary')." - ".$object->ref; $help_url = ""; - llxHeader('', $title, $help_url); @@ -665,6 +672,7 @@ if ($action == 'create' && $permissiontoadd) { var fk_user = $("#fk_user").val() var url = "'.DOL_URL_ROOT.'/salaries/ajax/ajaxsalaries.php?fk_user="+fk_user; console.log("We click on link to autofill salary amount url="+url); + if (fk_user != -1) { $.get( url, @@ -704,7 +712,6 @@ if ($action == 'create' && $permissiontoadd) { print ''; } - // View mode if ($id > 0) { $head = salaries_prepare_head($object); @@ -969,11 +976,8 @@ if ($id > 0) { while ($i < $num) { $objp = $db->fetch_object($resql); - print ''; - // Date - print ''; + print ''; print ''.img_object($langs->trans("Payment"), "payment").' '.$objp->rowid.''; - // Date print ''.dol_print_date($db->jdate($objp->dp), 'dayhour', 'tzuserrel')."\n"; $labeltype = $langs->trans("PaymentType".$objp->type_code) != ("PaymentType".$objp->type_code) ? $langs->trans("PaymentType".$objp->type_code) : $objp->paiement_type; print "".$labeltype.' '.$objp->num_payment."\n"; @@ -1046,6 +1050,17 @@ if ($id > 0) { print '
'."\n"; if ($action != 'edit') { + // Dynamic send mail button + $parameters = array(); + $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if (empty($reshook)) { + if (empty($user->socid)) { + $canSendMail = true; + + print dolGetButtonAction($langs->trans('SendMail'), '', 'default', $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&action=presend&token='.newToken().'&mode=init#formmailbeforetitle', '', $canSendMail, $params); + } + } + // Reopen if ($object->paye && $user->rights->salaries->write) { print dolGetButtonAction('', $langs->trans('ReOpen'), 'default', $_SERVER["PHP_SELF"].'?action=reopen&token='.newToken().'&id='.$object->id, ''); @@ -1137,6 +1152,10 @@ if ($id > 0) { $trackid = 'salary'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php'; + + // Hook to add more things on page + $parameters = array(); + $reshook = $hookmanager->executeHooks('salaryCardTabAddMore', $parameters, $object, $action); // Note that $action and $object may have been modified by hook } // End of page diff --git a/htdocs/salaries/class/salary.class.php b/htdocs/salaries/class/salary.class.php index acf811b4f88..90666a6853d 100644 --- a/htdocs/salaries/class/salary.class.php +++ b/htdocs/salaries/class/salary.class.php @@ -539,7 +539,7 @@ class Salary extends CommonObject $dataparams = ''; if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) { $classfortooltip = 'classforajaxtooltip'; - $dataparams = ' data-params='.json_encode($params); + $dataparams = " data-params='".json_encode($params)."'"; // $label = $langs->trans('Loading'); } diff --git a/htdocs/salaries/list.php b/htdocs/salaries/list.php index 24b416295d1..35e82e96da1 100644 --- a/htdocs/salaries/list.php +++ b/htdocs/salaries/list.php @@ -570,7 +570,7 @@ while ($i < ($limit ? min($num, $limit) : $num)) { if ($mode == 'kanban') { if ($i == 0) { print ''; - print '
'; + print '
'; } // Output Kanban print $salstatic->getKanbanView(''); diff --git a/htdocs/salaries/payments.php b/htdocs/salaries/payments.php index 7bf61f3021f..807ae82f9af 100644 --- a/htdocs/salaries/payments.php +++ b/htdocs/salaries/payments.php @@ -575,7 +575,7 @@ while ($i < ($limit ? min($num, $limit) : $num)) { if ($mode == 'kanban') { if ($i == 0) { print ''; - print '
'; + print '
'; } // Output Kanban diff --git a/htdocs/salaries/stats/index.php b/htdocs/salaries/stats/index.php index ba5d254f22b..c18f59a754a 100644 --- a/htdocs/salaries/stats/index.php +++ b/htdocs/salaries/stats/index.php @@ -279,7 +279,7 @@ print ''; print '
'; -print '
'; +print '
'; print dol_get_fiche_end(); diff --git a/htdocs/societe/agenda.php b/htdocs/societe/agenda.php index 1b3cc7dbe9b..dbf006f840c 100644 --- a/htdocs/societe/agenda.php +++ b/htdocs/societe/agenda.php @@ -48,6 +48,7 @@ if (GETPOST('actioncode', 'array')) { $actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : getDolGlobalString('AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT')); } +$search_rowid = GETPOST('search_rowid'); $search_agenda_label = GETPOST('search_agenda_label'); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; @@ -199,12 +200,18 @@ if ($socid > 0) { $param .= '&limit='.urlencode($limit); } + // Try to know count of actioncomm from cache + require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php'; + $cachekey = 'count_events_thirdparty_'.$object->id; + $nbEvent = dol_getcache($cachekey); + // print load_fiche_titre($langs->trans("ActionsOnCompany"), $newcardbutton, ''); - print_barre_liste($langs->trans("ActionsOnCompany"), 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', 0, -1, '', 0, $morehtmlright, '', 0, 1, 1); + print_barre_liste($langs->trans("ActionsOnCompany").(is_numeric($nbEvent) ? '('.$nbEvent.')': ''), 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', 0, -1, '', 0, $morehtmlright, '', 0, 1, 1); // List of all actions $filters = array(); $filters['search_agenda_label'] = $search_agenda_label; + $filters['search_rowid'] = $search_rowid; // TODO Replace this with same code than into list.php show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder, $object->module); diff --git a/htdocs/societe/canvas/company/tpl/card_view.tpl.php b/htdocs/societe/canvas/company/tpl/card_view.tpl.php index 22c46cb93b5..50541de2dd6 100644 --- a/htdocs/societe/canvas/company/tpl/card_view.tpl.php +++ b/htdocs/societe/canvas/company/tpl/card_view.tpl.php @@ -284,7 +284,7 @@ for ($i = 1; $i <= 4; $i++) { $filedir = $conf->societe->multidir_output[$this->control->tpl['entity']].'/'.$socid; $urlsource = $_SERVER["PHP_SELF"]."?socid=".$socid; $genallowed = $user->hasRight('societe', 'lire'); -$delallowed = $user->rights->societe->creer; +$delallowed = $user->hasRight('societe', 'creer'); print $formfile->showdocuments('company', $socid, $filedir, $urlsource, $genallowed, $delallowed, '', 0, 0, 0, 28, 0, '', 0, '', $objcanvas->control->object->default_lang); ?> diff --git a/htdocs/societe/canvas/individual/tpl/card_view.tpl.php b/htdocs/societe/canvas/individual/tpl/card_view.tpl.php index 11716519f16..3d76eae2f4a 100644 --- a/htdocs/societe/canvas/individual/tpl/card_view.tpl.php +++ b/htdocs/societe/canvas/individual/tpl/card_view.tpl.php @@ -210,7 +210,7 @@ if ($this->control->tpl['action_delete']) { $filedir = $conf->societe->multidir_output[$this->control->tpl['entity']].'/'.$socid; $urlsource = $_SERVER["PHP_SELF"]."?socid=".$socid; $genallowed = $user->hasRight('societe', 'lire'); -$delallowed = $user->rights->societe->creer; +$delallowed = $user->hasRight('societe', 'creer'); print $formfile->showdocuments('company', $socid, $filedir, $urlsource, $genallowed, $delallowed, '', 0, 0, 0, 28, 0, '', 0, '', $objcanvas->control->object->default_lang); ?> diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index 02d0b042aab..1649a161034 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -617,7 +617,7 @@ if (empty($reshook)) { $result = $object->create($user); - if (empty($error) && !empty($conf->mailing->enabled) && !empty($object->email) && $object->no_email == 1) { + if (empty($error) && isModEnabled('mailing') && !empty($object->email) && $object->no_email == 1) { // Add mass emailing flag into table mailing_unsubscribe $result = $object->setNoEmail($object->no_email); if ($result < 0) { @@ -1633,7 +1633,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print ''.img_picto('', 'globe', 'class="pictofixedwidth"').' '; // Unsubscribe - if (!empty($conf->mailing->enabled)) { + if (isModEnabled('mailing')) { if ($conf->use_javascript_ajax && $conf->global->MAILING_CONTACT_DEFAULT_BULK_STATUS == 2) { print "\n".'