Merge pull request #955 from FHenry/3.4

Fix error management and SQL resquest in action comm
This commit is contained in:
Laurent Destailleur 2013-05-19 09:02:00 -07:00
commit 2ac738d8c4
14 changed files with 1260 additions and 1154 deletions

View File

@ -54,6 +54,7 @@ For users:
- New: [ task #741 ] Add intervention box. - New: [ task #741 ] Add intervention box.
- New: [ task #826 ] Optionnal increase stock when deleting an invoice already validated. - New: [ task #826 ] Optionnal increase stock when deleting an invoice already validated.
- New: [ task #823 ] Shipping_validate email notification. - New: [ task #823 ] Shipping_validate email notification.
- New: [ task #900 ] Review code of ficheinter.class.php
For translators: For translators:
- Update language files. - Update language files.

View File

@ -188,8 +188,8 @@ class ActionComm extends CommonObject
$sql.= (strval($this->datep)!=''?"'".$this->db->idate($this->datep)."'":"null").","; $sql.= (strval($this->datep)!=''?"'".$this->db->idate($this->datep)."'":"null").",";
$sql.= (strval($this->datef)!=''?"'".$this->db->idate($this->datef)."'":"null").","; $sql.= (strval($this->datef)!=''?"'".$this->db->idate($this->datef)."'":"null").",";
$sql.= (isset($this->durationp) && $this->durationp >= 0 && $this->durationp != ''?"'".$this->durationp."'":"null").","; $sql.= (isset($this->durationp) && $this->durationp >= 0 && $this->durationp != ''?"'".$this->durationp."'":"null").",";
$sql.= " '".$this->type_id."',"; $sql.= (isset($this->type_id)?$this->type_id:"null").",";
$sql.= " '".$this->code."',"; $sql.= (isset($this->code)?" '".$this->code."'":"null").",";
$sql.= (isset($this->societe->id) && $this->societe->id > 0?" '".$this->societe->id."'":"null").","; $sql.= (isset($this->societe->id) && $this->societe->id > 0?" '".$this->societe->id."'":"null").",";
$sql.= (isset($this->fk_project) && $this->fk_project > 0?" '".$this->fk_project."'":"null").","; $sql.= (isset($this->fk_project) && $this->fk_project > 0?" '".$this->fk_project."'":"null").",";
$sql.= " '".$this->db->escape($this->note)."',"; $sql.= " '".$this->db->escape($this->note)."',";

View File

@ -243,6 +243,7 @@ if ($action == 'add_action')
$db->rollback(); $db->rollback();
$langs->load("errors"); $langs->load("errors");
$error=$langs->trans($actioncomm->error); $error=$langs->trans($actioncomm->error);
setEventMessage($error,'errors');
$action = 'create'; $action = 'create';
} }
} }
@ -251,6 +252,7 @@ if ($action == 'add_action')
$db->rollback(); $db->rollback();
$langs->load("errors"); $langs->load("errors");
$error=$langs->trans($actioncomm->error); $error=$langs->trans($actioncomm->error);
setEventMessage($error,'errors');
$action = 'create'; $action = 'create';
} }
} }
@ -277,6 +279,7 @@ if ($action == 'confirm_delete' && GETPOST("confirm") == 'yes')
else else
{ {
$mesg=$actioncomm->error; $mesg=$actioncomm->error;
setEventMessage($mesg,'errors');
} }
} }
} }

View File

@ -1845,7 +1845,11 @@ else
foreach($extrafields->attribute_label as $key=>$label) foreach($extrafields->attribute_label as $key=>$label)
{ {
if ($action == 'edit_extras') {
$value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$object->array_options["options_".$key]); $value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$object->array_options["options_".$key]);
} else {
$value=$object->array_options["options_".$key];
}
if ($extrafields->attribute_type[$key] == 'separate') if ($extrafields->attribute_type[$key] == 'separate')
{ {
print $extrafields->showSeparator($key); print $extrafields->showSeparator($key);

View File

@ -2554,6 +2554,7 @@ class Propal extends CommonObject
$sql.= ' WHERE pt.fk_propal = '.$this->id; $sql.= ' WHERE pt.fk_propal = '.$this->id;
$sql.= ' ORDER BY pt.rang ASC, pt.rowid'; $sql.= ' ORDER BY pt.rang ASC, pt.rowid';
dol_syslog(get_class($this).'::getLinesArray sql='.$sql,LOG_DEBUG);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) if ($resql)
{ {

View File

@ -2834,7 +2834,7 @@ class Commande extends CommonOrder
} }
/** /**
* Update value of extrafields on the proposal * Update value of extrafields on order
* *
* @param User $user Object user that modify * @param User $user Object user that modify
* @return int <0 if ko, >0 if ok * @return int <0 if ko, >0 if ok

View File

@ -2145,7 +2145,11 @@ else
foreach($extrafields->attribute_label as $key=>$label) foreach($extrafields->attribute_label as $key=>$label)
{ {
if ($action == 'edit_extras') {
$value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$object->array_options["options_".$key]); $value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$object->array_options["options_".$key]);
} else {
$value=$object->array_options["options_".$key];
}
if ($extrafields->attribute_type[$key] == 'separate') if ($extrafields->attribute_type[$key] == 'separate')
{ {
print $extrafields->showSeparator($key); print $extrafields->showSeparator($key);

View File

@ -3291,7 +3291,11 @@ else if ($id > 0 || ! empty($ref))
foreach($extrafields->attribute_label as $key=>$label) foreach($extrafields->attribute_label as $key=>$label)
{ {
$value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$object->array_options["options_".$key]); if ($action == 'edit_extras') {
$value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$object->array_options["options_".$key]);
} else {
$value=$object->array_options["options_".$key];
}
if ($extrafields->attribute_type[$key] == 'separate') if ($extrafields->attribute_type[$key] == 'separate')
{ {
print $extrafields->showSeparator($key); print $extrafields->showSeparator($key);

View File

@ -3203,6 +3203,7 @@ class Facture extends CommonInvoice
$sql.= ' WHERE l.fk_facture = '.$this->id; $sql.= ' WHERE l.fk_facture = '.$this->id;
$sql.= ' ORDER BY l.rang ASC, l.rowid'; $sql.= ' ORDER BY l.rang ASC, l.rowid';
dol_syslog(get_class($this).'::getLinesArray sql='.$sql,LOG_DEBUG);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) if ($resql)
{ {

View File

@ -187,7 +187,7 @@ abstract class CommonObject
$sql = "INSERT INTO ".MAIN_DB_PREFIX."element_contact"; $sql = "INSERT INTO ".MAIN_DB_PREFIX."element_contact";
$sql.= " (element_id, fk_socpeople, datecreate, statut, fk_c_type_contact) "; $sql.= " (element_id, fk_socpeople, datecreate, statut, fk_c_type_contact) ";
$sql.= " VALUES (".$this->id.", ".$fk_socpeople." , " ; $sql.= " VALUES (".$this->id.", ".$fk_socpeople." , " ;
$sql.= $this->db->idate($datecreate); $sql.= "'".$this->db->idate($datecreate)."'";
$sql.= ", 4, '". $id_type_contact . "' "; $sql.= ", 4, '". $id_type_contact . "' ";
$sql.= ")"; $sql.= ")";
dol_syslog(get_class($this)."::add_contact sql=".$sql); dol_syslog(get_class($this)."::add_contact sql=".$sql);
@ -2517,6 +2517,9 @@ abstract class CommonObject
if ($objecttype == 'cabinetmed_cons') { if ($objecttype == 'cabinetmed_cons') {
$classpath = 'cabinetmed/class'; $module='cabinetmed'; $subelement='cabinetmedcons'; $classpath = 'cabinetmed/class'; $module='cabinetmed'; $subelement='cabinetmedcons';
} }
if ($objecttype == 'fichinter') {
$classpath = 'fichinter/class'; $module='ficheinter'; $subelement='fichinter';
}
//print "objecttype=".$objecttype." module=".$module." subelement=".$subelement; //print "objecttype=".$objecttype." module=".$module." subelement=".$subelement;

View File

@ -445,7 +445,7 @@ class ExtraFields
if(is_array($param) && count($param) > 0) if(is_array($param) && count($param) > 0)
{ {
$param = serialize($param); $param = $this->db->escape(serialize($param));
} }
$sql_del = "DELETE FROM ".MAIN_DB_PREFIX."extrafields"; $sql_del = "DELETE FROM ".MAIN_DB_PREFIX."extrafields";

View File

@ -49,8 +49,8 @@
else if (type == 'price') { size.val('').attr('disabled','disabled'); unique.attr('disabled','disabled'); jQuery("#value_choice").hide();} else if (type == 'price') { size.val('').attr('disabled','disabled'); unique.attr('disabled','disabled'); jQuery("#value_choice").hide();}
else if (type == 'select') { size.val('').attr('disabled','disabled'); unique.attr('disabled','disabled'); jQuery("#value_choice").show();jQuery("#helpselect").show();jQuery("#helpsellist").hide();} else if (type == 'select') { size.val('').attr('disabled','disabled'); unique.attr('disabled','disabled'); jQuery("#value_choice").show();jQuery("#helpselect").show();jQuery("#helpsellist").hide();}
else if (type == 'sellist') { size.val('').attr('disabled','disabled'); unique.attr('disabled','disabled'); jQuery("#value_choice").show();jQuery("#helpselect").hide();jQuery("#helpsellist").show();} else if (type == 'sellist') { size.val('').attr('disabled','disabled'); unique.attr('disabled','disabled'); jQuery("#value_choice").show();jQuery("#helpselect").hide();jQuery("#helpsellist").show();}
else if (type == 'checkbox') { size.val('').attr('disabled','disabled'); unique.attr('disabled','disabled'); jQuery("#value_choice").show();} else if (type == 'checkbox') { size.val('').attr('disabled','disabled'); unique.attr('disabled','disabled'); jQuery("#value_choice").show();jQuery("#helpselect").show();jQuery("#helpsellist").hide();}
else if (type == 'radio') { size.val('').attr('disabled','disabled'); unique.attr('disabled','disabled'); jQuery("#value_choice").show();} else if (type == 'radio') { size.val('').attr('disabled','disabled'); unique.attr('disabled','disabled'); jQuery("#value_choice").show();jQuery("#helpselect").show();jQuery("#helpsellist").hide();}
else if (type == 'separate') { size.val('').attr('disabled','disabled'); unique.attr('disabled','disabled'); required.val('').attr('disabled','disabled'); default_value.val('').attr('disabled','disabled'); jQuery("#value_choice").hide();} else if (type == 'separate') { size.val('').attr('disabled','disabled'); unique.attr('disabled','disabled'); required.val('').attr('disabled','disabled'); default_value.val('').attr('disabled','disabled'); jQuery("#value_choice").hide();}
else size.val('').attr('disabled','disabled'); else size.val('').attr('disabled','disabled');
} }

View File

@ -1,28 +1,28 @@
<?php <?php
/* Copyright (C) 2002-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2002-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2011-2013 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2011-2013 Juanjo Menent <jmenent@2byte.es>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or * the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
/** /**
* \file htdocs/fichinter/class/fichinter.class.php * \file htdocs/fichinter/class/fichinter.class.php
* \ingroup ficheinter * \ingroup ficheinter
* \brief Fichier de la classe des gestion des fiches interventions * \brief Fichier de la classe des gestion des fiches interventions
*/ */
require_once DOL_DOCUMENT_ROOT .'/core/class/commonobject.class.php'; require_once DOL_DOCUMENT_ROOT .'/core/class/commonobject.class.php';
@ -61,7 +61,7 @@ class Fichinter extends CommonObject
* Constructor * Constructor
* *
* @param DoliDB $db Database handler * @param DoliDB $db Database handler
*/ */
function __construct($db) function __construct($db)
{ {
$this->db = $db; $this->db = $db;
@ -82,16 +82,20 @@ class Fichinter extends CommonObject
/** /**
* Create an intervention into data base * 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 * @return int <0 if KO, >0 if OK
*/ */
function create() function create($user, $notrigger=0)
{ {
global $conf, $user, $langs; global $conf, $user, $langs;
dol_syslog(get_class($this)."::create ref=".$this->ref); dol_syslog(get_class($this)."::create ref=".$this->ref);
// Check parameters // Check parameters
if (! is_numeric($this->duree)) { $this->duree = 0; } if (! is_numeric($this->duree)) {
$this->duree = 0;
}
if ($this->socid <= 0) if ($this->socid <= 0)
{ {
$this->error='ErrorBadParameterForFunc'; $this->error='ErrorBadParameterForFunc';
@ -142,7 +146,7 @@ class Fichinter extends CommonObject
$sql.= ", '".$this->db->idate($now)."'"; $sql.= ", '".$this->db->idate($now)."'";
$sql.= ", '".$this->ref."'"; $sql.= ", '".$this->ref."'";
$sql.= ", ".$conf->entity; $sql.= ", ".$conf->entity;
$sql.= ", ".$this->author; $sql.= ", ".$user->id;
$sql.= ", ".($this->description?"'".$this->db->escape($this->description)."'":"null"); $sql.= ", ".($this->description?"'".$this->db->escape($this->description)."'":"null");
$sql.= ", '".$this->modelpdf."'"; $sql.= ", '".$this->modelpdf."'";
$sql.= ", ".($this->fk_project ? $this->fk_project : 0); $sql.= ", ".($this->fk_project ? $this->fk_project : 0);
@ -166,23 +170,23 @@ class Fichinter extends CommonObject
$resql=$this->db->query($sql); $resql=$this->db->query($sql);
if (! $resql) $error++; if (! $resql) $error++;
} }
// Add linked object // Add linked object
if (! $error && $this->origin && $this->origin_id) if (! $error && $this->origin && $this->origin_id)
{ {
$ret = $this->add_object_linked(); $ret = $this->add_object_linked();
if (! $ret) dol_print_error($this->db); if (! $ret) dol_print_error($this->db);
} }
// Appel des triggers if (! $notrigger)
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; {
$interface=new Interfaces($this->db); // Appel des triggers
$tmpuser=new User($this->db); include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
$tmpuser->fetch($this->author); $interface=new Interfaces($this->db);
$result=$interface->run_triggers('FICHINTER_CREATE',$this,$tmpuser,$langs,$conf); $result=$interface->run_triggers('FICHINTER_CREATE',$this,$user,$langs,$conf);
if ($result < 0) { if ($result < 0) {
$error++; $this->errors=$interface->errors; $error++; $this->errors=$interface->errors;
}
} }
// Fin appel triggers
if (! $error) if (! $error)
{ {
@ -210,12 +214,18 @@ class Fichinter extends CommonObject
/** /**
* Update an intervention * 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 * @return int <0 if KO, >0 if OK
*/ */
function update() function update($user, $notrigger=0)
{ {
if (! is_numeric($this->duree)) { $this->duree = 0; } if (! is_numeric($this->duree)) {
if (! dol_strlen($this->fk_project)) { $this->fk_project = 0; } $this->duree = 0;
}
if (! dol_strlen($this->fk_project)) {
$this->fk_project = 0;
}
$this->db->begin(); $this->db->begin();
@ -230,14 +240,18 @@ class Fichinter extends CommonObject
dol_syslog(get_class($this)."::update sql=".$sql, LOG_DEBUG); dol_syslog(get_class($this)."::update sql=".$sql, LOG_DEBUG);
if ($this->db->query($sql)) if ($this->db->query($sql))
{ {
// Appel des triggers
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; if (! $notrigger)
$interface=new Interfaces($this->db); {
$result=$interface->run_triggers('FICHINTER_MODIFY',$this,$user,$langs,$conf); // Appel des triggers
if ($result < 0) { include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
$error++; $this->errors=$interface->errors; $interface=new Interfaces($this->db);
$result=$interface->run_triggers('FICHINTER_UPDATE',$this,$user,$langs,$conf);
if ($result < 0) {
$error++; $this->errors=$interface->errors;
}
// Fin appel triggers
} }
// Fin appel triggers
$this->db->commit(); $this->db->commit();
return 1; return 1;
@ -297,7 +311,7 @@ class Fichinter extends CommonObject
/* /*
* Lines * Lines
*/ */
$result=$this->fetch_lines(); $result=$this->fetch_lines();
if ($result < 0) if ($result < 0)
{ {
@ -396,7 +410,9 @@ class Fichinter extends CommonObject
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
$interface=new Interfaces($this->db); $interface=new Interfaces($this->db);
$result=$interface->run_triggers('FICHINTER_VALIDATE',$this,$user,$langs,$conf); $result=$interface->run_triggers('FICHINTER_VALIDATE',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; } if ($result < 0) {
$error++; $this->errors=$interface->errors;
}
// Fin appel triggers // Fin appel triggers
if (! $error) if (! $error)
@ -510,7 +526,7 @@ class Fichinter extends CommonObject
* @param int $withpicto 0=_No picto, 1=Includes the picto in the linkn, 2=Picto only * @param int $withpicto 0=_No picto, 1=Includes the picto in the linkn, 2=Picto only
* @return string String with URL * @return string String with URL
*/ */
function getNomUrl($withpicto=0) function getNomUrl($withpicto=0,$option='')
{ {
global $langs; global $langs;
@ -636,18 +652,18 @@ class Fichinter extends CommonObject
* @param User $user Object user who delete * @param User $user Object user who delete
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
function delete($user) function delete($user, $notrigger=0)
{ {
global $conf; global $conf;
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
$error=0; $error=0;
$this->db->begin(); $this->db->begin();
// Delete linked object // Delete linked object
$res = $this->deleteObjectLinked(); $res = $this->deleteObjectLinked();
if ($res < 0) $error++; if ($res < 0) $error++;
// Delete linked contacts // Delete linked contacts
$res = $this->delete_linked_contact(); $res = $this->delete_linked_contact();
@ -703,15 +719,17 @@ class Fichinter extends CommonObject
} }
} }
// Appel des triggers if (! $notrigger)
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; {
$interface=new Interfaces($this->db); // Appel des triggers
$result=$interface->run_triggers('FICHINTER_DELETE',$this,$user,$langs,$conf); include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
if ($result < 0) { $interface=new Interfaces($this->db);
$error++; $this->errors=$interface->errors; $result=$interface->run_triggers('FICHINTER_DELETE',$this,$user,$langs,$conf);
if ($result < 0) {
$error++; $this->errors=$interface->errors;
}
// Fin appel triggers
} }
// Fin appel triggers
$this->db->commit(); $this->db->commit();
return 1; return 1;
} }
@ -799,13 +817,14 @@ class Fichinter extends CommonObject
/** /**
* Adding a line of intervention into data base * Adding a line of intervention into data base
* *
* @param user $user User that do the action
* @param int $fichinterid Id of intervention * @param int $fichinterid Id of intervention
* @param string $desc Line description * @param string $desc Line description
* @param date $date_intervention Intervention date * @param date $date_intervention Intervention date
* @param int $duration Intervention duration * @param int $duration Intervention duration
* @return int >0 if ok, <0 if ko * @return int >0 if ok, <0 if ko
*/ */
function addline($fichinterid, $desc, $date_intervention, $duration) function addline($user,$fichinterid, $desc, $date_intervention, $duration)
{ {
dol_syslog("Fichinter::Addline $fichinterid, $desc, $date_intervention, $duration"); dol_syslog("Fichinter::Addline $fichinterid, $desc, $date_intervention, $duration");
@ -821,7 +840,7 @@ class Fichinter extends CommonObject
$line->datei = $date_intervention; $line->datei = $date_intervention;
$line->duration = $duration; $line->duration = $duration;
$result=$line->insert(); $result=$line->insert($user);
if ($result > 0) if ($result > 0)
{ {
$this->db->commit(); $this->db->commit();
@ -839,11 +858,11 @@ class Fichinter extends CommonObject
/** /**
* Initialise an instance with random values. * Initialise an instance with random values.
* Used to build previews or test instances. * Used to build previews or test instances.
* id must be 0 if object instance is a specimen. * id must be 0 if object instance is a specimen.
* *
* @return void * @return void
*/ */
function initAsSpecimen() function initAsSpecimen()
{ {
@ -868,7 +887,7 @@ class Fichinter extends CommonObject
$line->desc=$langs->trans("Description")." ".$xnbp; $line->desc=$langs->trans("Description")." ".$xnbp;
$line->datei=($now-3600*(1+$xnbp)); $line->datei=($now-3600*(1+$xnbp));
$line->duration=600; $line->duration=600;
$line->fk_fichinter=0; $line->fk_fichinter=0;
$this->lines[$xnbp]=$line; $this->lines[$xnbp]=$line;
$xnbp++; $xnbp++;
@ -988,10 +1007,14 @@ class FichinterLigne
/** /**
* Insert the line into database * Insert the line into database
* *
* @param User $user Objet user that make creation
* @param int $notrigger Disable all triggers
* @return int <0 if ko, >0 if ok * @return int <0 if ko, >0 if ok
*/ */
function insert() function insert($user, $notrigger=0)
{ {
global $langs,$conf;
dol_syslog("FichinterLigne::insert rang=".$this->rang); dol_syslog("FichinterLigne::insert rang=".$this->rang);
$this->db->begin(); $this->db->begin();
@ -1021,7 +1044,7 @@ class FichinterLigne
$sql.= ' (fk_fichinter, description, date, duree, rang)'; $sql.= ' (fk_fichinter, description, date, duree, rang)';
$sql.= " VALUES (".$this->fk_fichinter.","; $sql.= " VALUES (".$this->fk_fichinter.",";
$sql.= " '".$this->db->escape($this->desc)."',"; $sql.= " '".$this->db->escape($this->desc)."',";
$sql.= " ".$this->db->idate($this->datei).","; $sql.= " '".$this->db->idate($this->datei)."',";
$sql.= " ".$this->duration.","; $sql.= " ".$this->duration.",";
$sql.= ' '.$rangToUse; $sql.= ' '.$rangToUse;
$sql.= ')'; $sql.= ')';
@ -1034,6 +1057,21 @@ class FichinterLigne
if ($result > 0) if ($result > 0)
{ {
$this->rang=$rangToUse; $this->rang=$rangToUse;
if (! $notrigger)
{
// Appel des triggers
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
$interface=new Interfaces($this->db);
$resulttrigger=$interface->run_triggers('FICHINTERDET_CREATE',$this,$user,$langs,$conf);
if ($resulttrigger < 0) {
$error++; $this->errors=$interface->errors;
}
// Fin appel triggers
}
}
if (!$error) {
$this->db->commit(); $this->db->commit();
return $result; return $result;
} }
@ -1056,10 +1094,14 @@ class FichinterLigne
/** /**
* Update intervention into database * Update intervention into database
* *
* @param User $user Objet user that make creation
* @param int $notrigger Disable all triggers
* @return int <0 if ko, >0 if ok * @return int <0 if ko, >0 if ok
*/ */
function update() function update($user,$notrigger=0)
{ {
global $langs,$conf;
$this->db->begin(); $this->db->begin();
// Mise a jour ligne en base // Mise a jour ligne en base
@ -1076,6 +1118,22 @@ class FichinterLigne
{ {
$result=$this->update_total(); $result=$this->update_total();
if ($result > 0) if ($result > 0)
{
if (! $notrigger)
{
// Appel des triggers
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
$interface=new Interfaces($this->db);
$resulttrigger=$interface->run_triggers('FICHINTERDET_UPDATE',$this,$user,$langs,$conf);
if ($resulttrigger < 0) {
$error++; $this->errors=$interface->errors;
}
// Fin appel triggers
}
}
if (!$error)
{ {
$this->db->commit(); $this->db->commit();
return $result; return $result;
@ -1152,10 +1210,14 @@ class FichinterLigne
/** /**
* Delete a intervention line * Delete a intervention line
* *
* @param User $user Objet user that make creation
* @param int $notrigger Disable all triggers
* @return int >0 if ok, <0 if ko * @return int >0 if ok, <0 if ko
*/ */
function deleteline() function deleteline($user,$notrigger=0)
{ {
global $langs,$conf;
if ($this->statut == 0) if ($this->statut == 0)
{ {
dol_syslog(get_class($this)."::deleteline lineid=".$this->rowid); dol_syslog(get_class($this)."::deleteline lineid=".$this->rowid);
@ -1171,6 +1233,19 @@ class FichinterLigne
if ($result > 0) if ($result > 0)
{ {
$this->db->commit(); $this->db->commit();
if (! $notrigger)
{
// Appel des triggers
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
$interface=new Interfaces($this->db);
$resulttrigger=$interface->run_triggers('FICHINTERDET_DELETE',$this,$user,$langs,$conf);
if ($resulttrigger < 0) {
$error++; $this->errors=$interface->errors;
}
// Fin appel triggers
}
return $result; return $result;
} }
else else

File diff suppressed because it is too large Load Diff