diff --git a/htdocs/admin/fichinter.php b/htdocs/admin/fichinter.php
index fe02656d37a..ade26bbafdd 100644
--- a/htdocs/admin/fichinter.php
+++ b/htdocs/admin/fichinter.php
@@ -30,6 +30,7 @@
require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/fichinter.lib.php';
require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php';
$langs->load("admin");
@@ -204,15 +205,9 @@ print_fiche_titre($langs->trans("InterventionsSetup"),$linkback,'setup');
print "
";
-$h = 0;
+$head=fichinter_admin_prepare_head();
-$head[$h][0] = DOL_URL_ROOT."/admin/fichinter.php";
-$head[$h][1] = $langs->trans("Interventions");
-$head[$h][2] = 'Ficheinter';
-$hselected=$h;
-$h++;
-
-dol_fiche_head($head, $hselected, $langs->trans("ModuleSetup"));
+dol_fiche_head($head, 'ficheinter', $langs->trans("ModuleSetup"));
// Interventions numbering model
diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php
index a748ef0f549..5fcb865897c 100644
--- a/htdocs/fichinter/class/fichinter.class.php
+++ b/htdocs/fichinter/class/fichinter.class.php
@@ -82,9 +82,11 @@ class Fichinter extends CommonObject
/**
* Create an intervention into data base
*
+ * @param User $user Objet user that make creation
+ * @param int $notrigger Disable all triggers
* @return int <0 if KO, >0 if OK
*/
- function create()
+ function create($user, $notrigger=0)
{
global $conf, $user, $langs;
@@ -142,7 +144,7 @@ class Fichinter extends CommonObject
$sql.= ", '".$this->db->idate($now)."'";
$sql.= ", '".$this->ref."'";
$sql.= ", ".$conf->entity;
- $sql.= ", ".$this->author;
+ $sql.= ", ".$user->id;
$sql.= ", ".($this->description?"'".$this->db->escape($this->description)."'":"null");
$sql.= ", '".$this->modelpdf."'";
$sql.= ", ".($this->fk_project ? $this->fk_project : 0);
@@ -173,16 +175,16 @@ class Fichinter extends CommonObject
if (! $ret) dol_print_error($this->db);
}
+ if (! $notrigger)
+ {
// Appel des triggers
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
$interface=new Interfaces($this->db);
- $tmpuser=new User($this->db);
- $tmpuser->fetch($this->author);
- $result=$interface->run_triggers('FICHINTER_CREATE',$this,$tmpuser,$langs,$conf);
+ $result=$interface->run_triggers('FICHINTER_CREATE',$this,$user,$langs,$conf);
if ($result < 0) {
$error++; $this->errors=$interface->errors;
}
- // Fin appel triggers
+ }
if (! $error)
{
@@ -210,9 +212,11 @@ class Fichinter extends CommonObject
/**
* Update an intervention
*
+ * @param User $user Objet user that make creation
+ * @param int $notrigger Disable all triggers
* @return int <0 if KO, >0 if OK
*/
- function update()
+ function update($user, $notrigger=0)
{
if (! is_numeric($this->duree)) { $this->duree = 0; }
if (! dol_strlen($this->fk_project)) { $this->fk_project = 0; }
@@ -230,6 +234,9 @@ class Fichinter extends CommonObject
dol_syslog(get_class($this)."::update sql=".$sql, LOG_DEBUG);
if ($this->db->query($sql))
{
+
+ if (! $notrigger)
+ {
// Appel des triggers
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
$interface=new Interfaces($this->db);
@@ -238,6 +245,7 @@ class Fichinter extends CommonObject
$error++; $this->errors=$interface->errors;
}
// Fin appel triggers
+ }
$this->db->commit();
return 1;
@@ -295,6 +303,13 @@ class Fichinter extends CommonObject
if ($this->statut == 0) $this->brouillon = 1;
+ require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php');
+ $extrafields=new ExtraFields($this->db);
+ $extralabels=$extrafields->fetch_name_optionals_label($this->table_element,true);
+ if (count($extralabels)>0) {
+ $this->fetch_optionals($this->id,$extralabels);
+ }
+
/*
* Lines
*/
@@ -1021,7 +1036,7 @@ class FichinterLigne
$sql.= ' (fk_fichinter, description, date, duree, rang)';
$sql.= " VALUES (".$this->fk_fichinter.",";
$sql.= " '".$this->db->escape($this->desc)."',";
- $sql.= " ".$this->db->idate($this->datei).",";
+ $sql.= " '".$this->db->idate($this->datei)."',";
$sql.= " ".$this->duration.",";
$sql.= ' '.$rangToUse;
$sql.= ')';
diff --git a/htdocs/fichinter/fiche.php b/htdocs/fichinter/fiche.php
index 941b5232f54..9d0db13f1bc 100644
--- a/htdocs/fichinter/fiche.php
+++ b/htdocs/fichinter/fiche.php
@@ -41,6 +41,7 @@ if (! empty($conf->global->FICHEINTER_ADDON) && is_readable(DOL_DOCUMENT_ROOT ."
require_once DOL_DOCUMENT_ROOT ."/core/modules/fichinter/mod_".$conf->global->FICHEINTER_ADDON.'.php';
}
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
+require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
$langs->load("companies");
$langs->load("interventions");
@@ -67,6 +68,8 @@ $result = restrictedArea($user, 'ficheinter', $id, 'fichinter');
$hookmanager->initHooks(array('interventioncard'));
$object = new Fichinter($db);
+$extrafields = new ExtraFields($db);
+$extralabels=$extrafields->fetch_name_optionals_label($object->table_element);
/*
@@ -134,7 +137,6 @@ else if ($action == 'add' && $user->rights->ficheinter->creer)
$object->socid = $socid;
$object->duree = GETPOST('duree','int');
$object->fk_project = GETPOST('projectid','int');
- $object->author = $user->id;
$object->description = GETPOST('description');
$object->ref = $ref;
$object->modelpdf = GETPOST('model','alpha');
@@ -155,9 +157,15 @@ else if ($action == 'add' && $user->rights->ficheinter->creer)
}
// For compatibility
- if ($element == 'order') { $element = $subelement = 'commande'; }
- if ($element == 'propal') { $element = 'comm/propal'; $subelement = 'propal'; }
- if ($element == 'contract') { $element = $subelement = 'contrat'; }
+ if ($element == 'order') {
+ $element = $subelement = 'commande';
+ }
+ if ($element == 'propal') {
+ $element = 'comm/propal'; $subelement = 'propal';
+ }
+ if ($element == 'contract') {
+ $element = $subelement = 'contrat';
+ }
$object->origin = $origin;
$object->origin_id = $originid;
@@ -270,7 +278,7 @@ else if ($action == 'add' && $user->rights->ficheinter->creer)
}
else
{
- $result = $object->create();
+ $result = $object->create($user);
if ($result > 0)
{
$id=$result; // Force raffraichissement sur fiche venant d'etre cree
@@ -300,7 +308,10 @@ else if ($action == 'update' && $user->rights->ficheinter->creer)
$object->description = GETPOST('description','alpha');
$object->ref = $ref;
- $object->update();
+ $result=$object->update($user);
+ if ($result<0) {
+ setEventMessage($object->error,'errors');
+ }
}
/*
@@ -632,11 +643,7 @@ if ($action == 'send' && ! GETPOST('cancel','alpha') && (empty($conf->global->MA
if ($object->fetch($id) > 0)
{
-// $objectref = dol_sanitizeFileName($object->ref);
-// $file = $conf->ficheinter->dir_output . '/' . $objectref . '/' . $objectref . '.pdf';
-// if (is_readable($file))
-// {
$object->fetch_thirdparty();
if (GETPOST('sendto','alpha'))
@@ -722,7 +729,9 @@ if ($action == 'send' && ! GETPOST('cancel','alpha') && (empty($conf->global->MA
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
$interface=new Interfaces($db);
$result=$interface->run_triggers('FICHINTER_SENTBYMAIL',$object,$user,$langs,$conf);
- if ($result < 0) { $error++; $this->errors=$interface->errors; }
+ if ($result < 0) {
+ $error++; $this->errors=$interface->errors;
+ }
// Fin appel triggers
if ($error)
@@ -760,13 +769,6 @@ if ($action == 'send' && ! GETPOST('cancel','alpha') && (empty($conf->global->MA
$mesg='