From 273386f52ff4bda2c6c89f82a1c2a98924b87d9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 11 Nov 2024 18:26:57 +0100 Subject: [PATCH] display fichinter rec link (#31767) * display fichinter rec link * display fichinter rec link * display fichinter rec link * display fichinter rec link * display fichinter rec link * display fichinter rec link --- build/phpstan/phpstan-baseline.neon | 20 ----------- dev/translation/ignore_translation_keys.lst | 1 - htdocs/fichinter/card-rec.php | 14 ++++---- htdocs/fichinter/class/fichinter.class.php | 2 +- htdocs/fichinter/class/fichinterrec.class.php | 9 +++-- htdocs/fichinter/index.php | 34 +++++++++++-------- htdocs/langs/en_US/interventions.lang | 1 + 7 files changed, 34 insertions(+), 47 deletions(-) diff --git a/build/phpstan/phpstan-baseline.neon b/build/phpstan/phpstan-baseline.neon index 834cef0ff27..2252487db57 100644 --- a/build/phpstan/phpstan-baseline.neon +++ b/build/phpstan/phpstan-baseline.neon @@ -9170,11 +9170,6 @@ parameters: count: 1 path: ../../htdocs/core/lib/ftp.lib.php - - - message: "#^Array has 2 duplicate keys with value 6 \\(\\\\LOG_INFO, \\\\LOG_DEBUG\\)\\.$#" - count: 1 - path: ../../htdocs/core/lib/functions.lib.php - - message: "#^Comparison operation \"\\>\" between int\\<1, max\\> and 0 is always true\\.$#" count: 1 @@ -11470,11 +11465,6 @@ parameters: count: 1 path: ../../htdocs/core/modules/supplier_proposal/mod_supplier_proposal_marbre.php - - - message: "#^Array has 2 duplicate keys with value 6 \\(\\\\LOG_INFO, \\\\LOG_DEBUG\\)\\.$#" - count: 1 - path: ../../htdocs/core/modules/syslog/mod_syslog_file.php - - message: "#^Parameter \\#2 \\$config of class Odf constructor expects string, array\\ given\\.$#" count: 1 @@ -14205,11 +14195,6 @@ parameters: count: 1 path: ../../htdocs/fichinter/index.php - - - message: "#^Variable \\$user might not be defined\\.$#" - count: 1 - path: ../../htdocs/fichinter/index.php - - message: "#^Ternary operator condition is always false\\.$#" count: 1 @@ -17955,11 +17940,6 @@ parameters: count: 1 path: ../../htdocs/opensurvey/class/opensurveysondage.class.php - - - message: "#^Unreachable statement \\- code above always terminates\\.$#" - count: 1 - path: ../../htdocs/opensurvey/exportcsv.php - - message: "#^Empty array passed to foreach\\.$#" count: 1 diff --git a/dev/translation/ignore_translation_keys.lst b/dev/translation/ignore_translation_keys.lst index 678efe4c096..d870ff1504b 100644 --- a/dev/translation/ignore_translation_keys.lst +++ b/dev/translation/ignore_translation_keys.lst @@ -787,7 +787,6 @@ ShowEmailcollectorFilter ShowEvaluation ShowEvaluationdet ShowFichinter -ShowInterventionModel ShowInventory ShowJob ShowKnowledgeRecord diff --git a/htdocs/fichinter/card-rec.php b/htdocs/fichinter/card-rec.php index 4447c9f1e1c..93b6157ea19 100644 --- a/htdocs/fichinter/card-rec.php +++ b/htdocs/fichinter/card-rec.php @@ -278,6 +278,7 @@ $help_url = ''; llxHeader('', $langs->trans("RepeatableIntervention"), $help_url, '', 0, 0, '', '', '', 'mod-fichinter page-card-rec'); $form = new Form($db); +$fichinterrecstatic = new FichinterRec($db); $companystatic = new Societe($db); if (isModEnabled('contract')) { $contratstatic = new Contrat($db); @@ -786,7 +787,7 @@ if ($action == 'create') { } else { // List mode - $sql = "SELECT f.rowid as fich_rec, s.nom as name, s.rowid as socid, f.rowid as facid, f.title,"; + $sql = "SELECT f.rowid as id, s.nom as name, s.rowid as socid, f.title,"; $sql .= " f.duree, f.fk_contrat, f.fk_projet as fk_project, f.frequency, f.nb_gen_done, f.nb_gen_max,"; $sql .= " f.date_last_gen, f.date_when, f.datec, f.status"; @@ -851,16 +852,17 @@ if ($action == 'create') { print "\n"; - // les filtres à faire ensuite + // TODO filters if ($num > 0) { while ($i < min($num, $limit)) { $objp = $db->fetch_object($resql); + $fichinterrecstatic->id = $objp->id; + $fichinterrecstatic->ref = $objp->title; + $fichinterrecstatic->title = $objp->title; print ''; - print ''; - print img_object($langs->trans("ShowIntervention"), "intervention").' '.$objp->title; - print "\n"; + print ''.$fichinterrecstatic->getNomUrl(1)."\n"; if ($objp->socid) { $companystatic->id = $objp->socid; $companystatic->name = $objp->name; @@ -919,7 +921,7 @@ if ($action == 'create') { if ($user->hasRight('ficheinter', 'creer')) { if (empty($objp->frequency) || $db->jdate($objp->date_when) <= $today) { print ''; + print '&socid='.$objp->socid.'&id='.$objp->id.'&token='.newToken().'">'; print $langs->trans("NewIntervention").''; } else { print $langs->trans("DateIsNotEnough"); diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index d8046af6f16..33d4eda3805 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -875,7 +875,7 @@ class Fichinter extends CommonObject $langs->load('interventions'); $datas = []; - $datas['picto'] = img_picto('', $this->picto).' '.$langs->trans("Intervention").''; + $datas['picto'] = img_picto('', $this->picto).' '.$langs->trans("ShowIntervention").''; if (isset($this->status)) { $datas['picto'] .= ' '.$this->getLibStatut(5); } diff --git a/htdocs/fichinter/class/fichinterrec.class.php b/htdocs/fichinter/class/fichinterrec.class.php index c8fae403ec2..a623c2d7237 100644 --- a/htdocs/fichinter/class/fichinterrec.class.php +++ b/htdocs/fichinter/class/fichinterrec.class.php @@ -640,7 +640,7 @@ class FichinterRec extends Fichinter */ public function getNomUrl($withpicto = 0, $option = '', $max = 0, $short = 0, $moretitle = '') { - global $langs, $hookmanager; + global $action, $langs, $hookmanager; $result = ''; $label = $langs->trans("ShowInterventionModel").': '.$this->ref; @@ -651,13 +651,11 @@ class FichinterRec extends Fichinter return $url; } - $picto = 'intervention'; - $link = ''; $linkend = ''; if ($withpicto) { - $result .= $link.img_object($label, $picto, 'class="classfortooltip"').$linkend; + $result .= $link.img_object($label, $this->picto, 'class="classfortooltip"').$linkend; } if ($withpicto && $withpicto != 2) { $result .= ' '; @@ -665,7 +663,7 @@ class FichinterRec extends Fichinter if ($withpicto != 2) { $result .= $link.$this->ref.$linkend; } - global $action; + $hookmanager->initHooks(array($this->element . 'dao')); $parameters = array('id' => $this->id, 'getnomurl' => &$result); $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks @@ -674,6 +672,7 @@ class FichinterRec extends Fichinter } else { $result .= $hookmanager->resPrint; } + return $result; } diff --git a/htdocs/fichinter/index.php b/htdocs/fichinter/index.php index 7129ed2e85c..f4e3193bade 100644 --- a/htdocs/fichinter/index.php +++ b/htdocs/fichinter/index.php @@ -31,10 +31,7 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/notify.class.php'; require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php'; - -if (!$user->hasRight('ficheinter', 'lire')) { - accessforbidden(); -} +require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; /** * @var Conf $conf @@ -44,6 +41,10 @@ if (!$user->hasRight('ficheinter', 'lire')) { * @var User $user */ +if (!$user->hasRight('ficheinter', 'lire')) { + accessforbidden(); +} + // Load translation files required by the page $langs->load("interventions"); @@ -66,6 +67,7 @@ $max = getDolGlobalInt('MAIN_SIZE_SHORTLIST_LIMIT', 5); */ $fichinterstatic = new Fichinter($db); +$companystatic = new Societe($db); $form = new Form($db); $formfile = new FormFile($db); @@ -178,7 +180,7 @@ if ($resql) { /* - * Draft orders + * Draft interventions */ if (isModEnabled('intervention')) { $sql = "SELECT f.rowid, f.ref, s.nom as name, s.rowid as socid"; @@ -209,10 +211,14 @@ if (isModEnabled('intervention')) { $i = 0; while ($i < $num) { $obj = $db->fetch_object($resql); + $fichinterstatic->id = $obj->rowid; + $fichinterstatic->ref = $obj->ref; print ''; - print ''; - print "rowid."\">".img_object($langs->trans("ShowFichinter"), "intervention").' '.$obj->ref.""; - print ''.img_object($langs->trans("ShowCompany"), "company").' '.dol_trunc($obj->name, 24).''; + print ''.$fichinterstatic->getNomUrl(1).''; + $companystatic->id = $obj->socid; + $companystatic->name = $obj->name; + print ''.$companystatic->getNomUrl(1, 'customer').''; + print ''; $i++; } } @@ -283,8 +289,9 @@ if ($resql) { print ''; print ''; - - print ''.img_object($langs->trans("ShowCompany"), "company").' '.$obj->name.''; + $companystatic->id = $obj->socid; + $companystatic->name = $obj->name; + print ''.$companystatic->getNomUrl(1, 'customer').''; print ''.dol_print_date($db->jdate($obj->datem), 'day').''; print ''.$fichinterstatic->LibStatut($obj->fk_statut, 5).''; print ''; @@ -355,11 +362,10 @@ if (isModEnabled('intervention')) { print ''; print ''; - - print ''.img_object($langs->trans("ShowCompany"), "company").' '.dol_trunc($obj->name, 24).''; - + $companystatic->id = $obj->socid; + $companystatic->name = $obj->name; + print ''.$companystatic->getNomUrl(1, 'customer').''; print ''.$fichinterstatic->LibStatut($obj->fk_statut, 5).''; - print ''; $i++; } diff --git a/htdocs/langs/en_US/interventions.lang b/htdocs/langs/en_US/interventions.lang index c52163a5e43..1d7b2ada84f 100644 --- a/htdocs/langs/en_US/interventions.lang +++ b/htdocs/langs/en_US/interventions.lang @@ -85,3 +85,4 @@ TypeContact_fichinter_internal_INTERVENING=Intervenant TypeContact_fichinter_external_BILLING=Customer contact of intervention billing TypeContact_fichinter_external_CUSTOMER=Customer contact of intervention follow-up NotARecurringInterventionalTemplate=Not a recurring intervention template +ShowInterventionModel=Show intervention model