Merge pull request #955 from FHenry/3.4
Fix error management and SQL resquest in action comm
This commit is contained in:
commit
2ac738d8c4
@ -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.
|
||||||
|
|||||||
@ -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)."',";
|
||||||
|
|||||||
@ -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');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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);
|
||||||
|
|||||||
@ -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)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -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
|
||||||
|
|||||||
@ -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);
|
||||||
|
|||||||
@ -3291,7 +3291,11 @@ else if ($id > 0 || ! empty($ref))
|
|||||||
|
|
||||||
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);
|
||||||
|
|||||||
@ -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)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -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;
|
||||||
|
|
||||||
|
|||||||
@ -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";
|
||||||
|
|||||||
@ -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');
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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);
|
||||||
@ -173,16 +177,16 @@ class Fichinter extends CommonObject
|
|||||||
if (! $ret) dol_print_error($this->db);
|
if (! $ret) dol_print_error($this->db);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (! $notrigger)
|
||||||
|
{
|
||||||
// Appel des triggers
|
// Appel des triggers
|
||||||
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);
|
||||||
$tmpuser=new User($this->db);
|
$result=$interface->run_triggers('FICHINTER_CREATE',$this,$user,$langs,$conf);
|
||||||
$tmpuser->fetch($this->author);
|
|
||||||
$result=$interface->run_triggers('FICHINTER_CREATE',$this,$tmpuser,$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();
|
||||||
|
|
||||||
@ -229,15 +239,19 @@ 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))
|
||||||
|
{
|
||||||
|
|
||||||
|
if (! $notrigger)
|
||||||
{
|
{
|
||||||
// Appel des triggers
|
// Appel des triggers
|
||||||
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_MODIFY',$this,$user,$langs,$conf);
|
$result=$interface->run_triggers('FICHINTER_UPDATE',$this,$user,$langs,$conf);
|
||||||
if ($result < 0) {
|
if ($result < 0) {
|
||||||
$error++; $this->errors=$interface->errors;
|
$error++; $this->errors=$interface->errors;
|
||||||
}
|
}
|
||||||
// Fin appel triggers
|
// Fin appel triggers
|
||||||
|
}
|
||||||
|
|
||||||
$this->db->commit();
|
$this->db->commit();
|
||||||
return 1;
|
return 1;
|
||||||
@ -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,7 +652,7 @@ 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';
|
||||||
@ -703,6 +719,8 @@ class Fichinter extends CommonObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (! $notrigger)
|
||||||
|
{
|
||||||
// Appel des triggers
|
// Appel des triggers
|
||||||
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);
|
||||||
@ -711,7 +729,7 @@ class Fichinter extends CommonObject
|
|||||||
$error++; $this->errors=$interface->errors;
|
$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();
|
||||||
@ -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
|
||||||
|
|||||||
@ -134,7 +134,6 @@ else if ($action == 'add' && $user->rights->ficheinter->creer)
|
|||||||
$object->socid = $socid;
|
$object->socid = $socid;
|
||||||
$object->duree = GETPOST('duree','int');
|
$object->duree = GETPOST('duree','int');
|
||||||
$object->fk_project = GETPOST('projectid','int');
|
$object->fk_project = GETPOST('projectid','int');
|
||||||
$object->author = $user->id;
|
|
||||||
$object->description = GETPOST('description');
|
$object->description = GETPOST('description');
|
||||||
$object->ref = $ref;
|
$object->ref = $ref;
|
||||||
$object->modelpdf = GETPOST('model','alpha');
|
$object->modelpdf = GETPOST('model','alpha');
|
||||||
@ -155,9 +154,15 @@ else if ($action == 'add' && $user->rights->ficheinter->creer)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// For compatibility
|
// For compatibility
|
||||||
if ($element == 'order') { $element = $subelement = 'commande'; }
|
if ($element == 'order') {
|
||||||
if ($element == 'propal') { $element = 'comm/propal'; $subelement = 'propal'; }
|
$element = $subelement = 'commande';
|
||||||
if ($element == 'contract') { $element = $subelement = 'contrat'; }
|
}
|
||||||
|
if ($element == 'propal') {
|
||||||
|
$element = 'comm/propal'; $subelement = 'propal';
|
||||||
|
}
|
||||||
|
if ($element == 'contract') {
|
||||||
|
$element = $subelement = 'contrat';
|
||||||
|
}
|
||||||
|
|
||||||
$object->origin = $origin;
|
$object->origin = $origin;
|
||||||
$object->origin_id = $originid;
|
$object->origin_id = $originid;
|
||||||
@ -240,6 +245,7 @@ else if ($action == 'add' && $user->rights->ficheinter->creer)
|
|||||||
$duration = 3600;
|
$duration = 3600;
|
||||||
|
|
||||||
$result = $object->addline(
|
$result = $object->addline(
|
||||||
|
$user,
|
||||||
$id,
|
$id,
|
||||||
$desc,
|
$desc,
|
||||||
$date_intervention,
|
$date_intervention,
|
||||||
@ -270,7 +276,7 @@ else if ($action == 'add' && $user->rights->ficheinter->creer)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$result = $object->create();
|
$result = $object->create($user);
|
||||||
if ($result > 0)
|
if ($result > 0)
|
||||||
{
|
{
|
||||||
$id=$result; // Force raffraichissement sur fiche venant d'etre cree
|
$id=$result; // Force raffraichissement sur fiche venant d'etre cree
|
||||||
@ -300,7 +306,10 @@ else if ($action == 'update' && $user->rights->ficheinter->creer)
|
|||||||
$object->description = GETPOST('description','alpha');
|
$object->description = GETPOST('description','alpha');
|
||||||
$object->ref = $ref;
|
$object->ref = $ref;
|
||||||
|
|
||||||
$object->update();
|
$result=$object->update($user);
|
||||||
|
if ($result<0) {
|
||||||
|
setEventMessage($object->error,'errors');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -365,7 +374,10 @@ else if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->fich
|
|||||||
{
|
{
|
||||||
$object->fetch($id);
|
$object->fetch($id);
|
||||||
$object->fetch_thirdparty();
|
$object->fetch_thirdparty();
|
||||||
$object->delete($user);
|
$result=$object->delete($user);
|
||||||
|
if ($result<0) {
|
||||||
|
setEventMessage($object->error,'errors');
|
||||||
|
}
|
||||||
|
|
||||||
header('Location: '.DOL_URL_ROOT.'/fichinter/list.php?leftmenu=ficheinter');
|
header('Location: '.DOL_URL_ROOT.'/fichinter/list.php?leftmenu=ficheinter');
|
||||||
exit;
|
exit;
|
||||||
@ -415,6 +427,7 @@ else if ($action == "addline" && $user->rights->ficheinter->creer)
|
|||||||
$duration = convertTime2Seconds(GETPOST('durationhour','int'), GETPOST('durationmin','int'));
|
$duration = convertTime2Seconds(GETPOST('durationhour','int'), GETPOST('durationmin','int'));
|
||||||
|
|
||||||
$result=$object->addline(
|
$result=$object->addline(
|
||||||
|
$user,
|
||||||
$id,
|
$id,
|
||||||
$desc,
|
$desc,
|
||||||
$date_intervention,
|
$date_intervention,
|
||||||
@ -490,7 +503,7 @@ else if ($action == 'updateline' && $user->rights->ficheinter->creer && GETPOST(
|
|||||||
$objectline->datei = $date_inter;
|
$objectline->datei = $date_inter;
|
||||||
$objectline->desc = $desc;
|
$objectline->desc = $desc;
|
||||||
$objectline->duration = $duration;
|
$objectline->duration = $duration;
|
||||||
$result = $objectline->update();
|
$result = $objectline->update($user);
|
||||||
if ($result < 0)
|
if ($result < 0)
|
||||||
{
|
{
|
||||||
dol_print_error($db);
|
dol_print_error($db);
|
||||||
@ -524,7 +537,7 @@ else if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->
|
|||||||
dol_print_error($db);
|
dol_print_error($db);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
$result=$objectline->deleteline();
|
$result=$objectline->deleteline($user);
|
||||||
|
|
||||||
if ($object->fetch($objectline->fk_fichinter) <= 0)
|
if ($object->fetch($objectline->fk_fichinter) <= 0)
|
||||||
{
|
{
|
||||||
@ -632,11 +645,7 @@ if ($action == 'send' && ! GETPOST('cancel','alpha') && (empty($conf->global->MA
|
|||||||
|
|
||||||
if ($object->fetch($id) > 0)
|
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();
|
$object->fetch_thirdparty();
|
||||||
|
|
||||||
if (GETPOST('sendto','alpha'))
|
if (GETPOST('sendto','alpha'))
|
||||||
@ -722,7 +731,9 @@ if ($action == 'send' && ! GETPOST('cancel','alpha') && (empty($conf->global->MA
|
|||||||
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
|
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
|
||||||
$interface=new Interfaces($db);
|
$interface=new Interfaces($db);
|
||||||
$result=$interface->run_triggers('FICHINTER_SENTBYMAIL',$object,$user,$langs,$conf);
|
$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
|
// Fin appel triggers
|
||||||
|
|
||||||
if ($error)
|
if ($error)
|
||||||
@ -760,13 +771,6 @@ if ($action == 'send' && ! GETPOST('cancel','alpha') && (empty($conf->global->MA
|
|||||||
$mesg='<div class="error">'.$langs->trans('ErrorMailRecipientIsEmpty').' !</div>';
|
$mesg='<div class="error">'.$langs->trans('ErrorMailRecipientIsEmpty').' !</div>';
|
||||||
dol_syslog('Recipient email is empty');
|
dol_syslog('Recipient email is empty');
|
||||||
}
|
}
|
||||||
/*}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$langs->load("errors");
|
|
||||||
$mesg='<div class="error">'.$langs->trans('ErrorCantReadFile',$file).'</div>';
|
|
||||||
dol_syslog('Failed to read file: '.$file);
|
|
||||||
}*/
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -881,9 +885,15 @@ if ($action == 'create')
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// For compatibility
|
// For compatibility
|
||||||
if ($element == 'order' || $element == 'commande') { $element = $subelement = 'commande'; }
|
if ($element == 'order' || $element == 'commande') {
|
||||||
if ($element == 'propal') { $element = 'comm/propal'; $subelement = 'propal'; }
|
$element = $subelement = 'commande';
|
||||||
if ($element == 'contract') { $element = $subelement = 'contrat'; }
|
}
|
||||||
|
if ($element == 'propal') {
|
||||||
|
$element = 'comm/propal'; $subelement = 'propal';
|
||||||
|
}
|
||||||
|
if ($element == 'contract') {
|
||||||
|
$element = $subelement = 'contrat';
|
||||||
|
}
|
||||||
|
|
||||||
dol_include_once('/'.$element.'/class/'.$subelement.'.class.php');
|
dol_include_once('/'.$element.'/class/'.$subelement.'.class.php');
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user