Fix: regression

This commit is contained in:
Regis Houssin 2010-04-21 22:14:11 +00:00
parent ba479b95f0
commit 335c038dd8
36 changed files with 2327 additions and 224 deletions

View File

@ -108,9 +108,9 @@ class Skeleton_class // extends CommonObject
// want this action call a trigger.
//// Call triggers
//include_once(DOL_DOCUMENT_ROOT . "/workflow/class/interfaces.class.php");
//include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php");
//$interface=new Interfaces($this->db);
//$result=$interface->call_workflow('MYOBJECT_CREATE',$this,$user,$langs,$conf);
//$result=$interface->run_triggers('MYOBJECT_CREATE',$this,$user,$langs,$conf);
//if ($result < 0) { $error++; $this->errors=$interface->errors; }
//// End call triggers
}
@ -217,9 +217,9 @@ class Skeleton_class // extends CommonObject
// want this action call a trigger.
//// Call triggers
//include_once(DOL_DOCUMENT_ROOT . "/workflow/class/interfaces.class.php");
//include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php");
//$interface=new Interfaces($this->db);
//$result=$interface->call_workflow('MYOBJECT_MODIFY',$this,$user,$langs,$conf);
//$result=$interface->run_triggers('MYOBJECT_MODIFY',$this,$user,$langs,$conf);
//if ($result < 0) { $error++; $this->errors=$interface->errors; }
//// End call triggers
}
@ -272,9 +272,9 @@ class Skeleton_class // extends CommonObject
// want this action call a trigger.
//// Call triggers
//include_once(DOL_DOCUMENT_ROOT . "/workflow/class/interfaces.class.php");
//include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php");
//$interface=new Interfaces($this->db);
//$result=$interface->call_workflow('MYOBJECT_DELETE',$this,$user,$langs,$conf);
//$result=$interface->run_triggers('MYOBJECT_DELETE',$this,$user,$langs,$conf);
//if ($result < 0) { $error++; $this->errors=$interface->errors; }
//// End call triggers
}

View File

@ -327,9 +327,9 @@ class Adherent extends CommonObject
if (! $notrigger)
{
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/workflow/class/interfaces.class.php");
include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->call_workflow('MEMBER_CREATE',$this,$user,$langs,$conf);
$result=$interface->run_triggers('MEMBER_CREATE',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers
}
@ -546,9 +546,9 @@ class Adherent extends CommonObject
$this->use_webcal=($conf->global->PHPWEBCALENDAR_MEMBERSTATUS=='always'?1:0);
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/workflow/class/interfaces.class.php");
include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->call_workflow('MEMBER_MODIFY',$this,$user,$langs,$conf);
$result=$interface->run_triggers('MEMBER_MODIFY',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers
}
@ -670,9 +670,9 @@ class Adherent extends CommonObject
$this->use_webcal=($conf->global->PHPWEBCALENDAR_MEMBERSTATUS=='always'?1:0);
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/workflow/class/interfaces.class.php");
include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->call_workflow('MEMBER_DELETE',$this,$user,$langs,$conf);
$result=$interface->run_triggers('MEMBER_DELETE',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers
@ -795,9 +795,9 @@ class Adherent extends CommonObject
if (! $error && ! $notrigger)
{
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/workflow/class/interfaces.class.php");
include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->call_workflow('MEMBER_NEW_PASSWORD',$this,$user,$langs,$conf);
$result=$interface->run_triggers('MEMBER_NEW_PASSWORD',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers
}
@ -1239,9 +1239,9 @@ class Adherent extends CommonObject
$this->use_webcal=($conf->global->PHPWEBCALENDAR_MEMBERSTATUS=='always'?1:0);
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/workflow/class/interfaces.class.php");
include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->call_workflow('MEMBER_SUBSCRIPTION',$this,$user,$langs,$conf);
$result=$interface->run_triggers('MEMBER_SUBSCRIPTION',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers
@ -1294,9 +1294,9 @@ class Adherent extends CommonObject
$this->use_webcal=($conf->global->PHPWEBCALENDAR_MEMBERSTATUS=='always'?1:0);
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/workflow/class/interfaces.class.php");
include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->call_workflow('MEMBER_VALIDATE',$this,$user,$langs,$conf);
$result=$interface->run_triggers('MEMBER_VALIDATE',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers
@ -1342,9 +1342,9 @@ class Adherent extends CommonObject
$this->use_webcal=($conf->global->PHPWEBCALENDAR_MEMBERSTATUS=='always'?1:0);
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/workflow/class/interfaces.class.php");
include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->call_workflow('MEMBER_RESILIATE',$this,$user,$langs,$conf);
$result=$interface->run_triggers('MEMBER_RESILIATE',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers

View File

@ -0,0 +1,707 @@
<?php
/* Copyright (C) 2010 Regis Houssin <regis@dolibarr.fr>
*
* 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 2 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, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/**
* \file htdocs/business/class/business.class.php
* \ingroup business
* \brief Fichier de la classe de gestion des affaires
* \version $Id$
*/
require_once(DOL_DOCUMENT_ROOT ."/core/commonobject.class.php");
/**
* \class Business
* \brief Class to manage business
*/
class Business extends CommonObject
{
var $db; //!< To store db handler
var $error; //!< To return error code (or message)
var $errors=array(); //!< To return several error codes (or messages)
var $element='business'; //!< Id that identify managed objects
var $table_element='business'; //!< Name of table without prefix where object is stored
var $table_element_line='business_phase';
var $fk_element='fk_business';
var $id;
var $ref;
var $description;
var $statut;
var $label;
var $date_c;
var $date_m;
var $date_start;
var $date_end;
var $socid;
var $user_author_id; //!< Id of business creator. Not defined if shared business.
var $public; //!< Tell if this is a public or private business
var $note_private;
var $note_public;
var $statuts_short;
var $statuts;
/**
* \brief Constructeur de la classe
* \param DB handler acces base de donnees
*/
function Business($DB)
{
$this->db = $DB;
$this->societe = new Societe($DB);
$this->statuts_short=array(0=>'Draft',1=>'Validated',2=>'Closed');
$this->statuts=array(0=>'Draft',1=>'Validated',2=>'Closed');
}
/**
* \brief Create a business into database
* \param user Id utilisateur qui cree
* \return int <0 si ko, id du projet cree si ok
*/
function create($user, $notrigger=0)
{
global $conf;
$ret=0;
// Clean parameters
$this->label = trim($this->label);
$this->description = trim($this->description);
// Check parameters
if (! trim($this->ref))
{
$this->error='ErrorFieldsRequired';
dol_syslog("Business::Create error -1 ref null", LOG_ERR);
return -1;
}
$sql = "INSERT INTO ".MAIN_DB_PREFIX."business (";
$sql.= "ref";
$sql.= ", label";
$sql.= ", description";
$sql.= ", fk_soc";
$sql.= ", fk_user_creat";
$sql.= ", public";
$sql.= ", datec";
$sql.= ", dateo";
$sql.= ", datee";
$sql.= ") VALUES (";
$sql.= "'".addslashes($this->ref)."'";
$sql.= ", '".addslashes($this->label)."'";
$sql.= ", '".addslashes($this->description)."'";
$sql.= ", ".($this->socid > 0?$this->socid:"null");
$sql.= ", ".$user->id;
$sql.= ", ".($this->public?1:0);
$sql.= ", ".($this->date_c!=''?$this->db->idate($this->date_c):'null');
$sql.= ", ".($this->date_start!=''?$this->db->idate($this->date_start):'null');
$sql.= ", ".($this->date_end!=''?$this->db->idate($this->date_end):'null');
$sql.= ")";
dol_syslog("Business::create sql=".$sql,LOG_DEBUG);
$resql=$this->db->query($sql);
if ($resql)
{
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."business");
$ret = $this->id;
if (! $notrigger)
{
// Call triggers
include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->run_triggers('BUSINESS_CREATE',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// End call triggers
}
}
else
{
$this->error=$this->db->lasterror();
dol_syslog("Business::Create error -2 ".$this->error, LOG_ERR);
$ret = -2;
}
return $ret;
}
/**
* Update a business
*
* @param unknown_type $user
* @return unknown
*/
function update($user, $notrigger=0)
{
global $conf;
// Clean parameters
$this->label = trim($this->label);
$this->description = trim($this->description);
if (strlen(trim($this->ref)) > 0)
{
$sql = "UPDATE ".MAIN_DB_PREFIX."business SET";
$sql.= " ref='".$this->ref."'";
$sql.= ", label = '".addslashes($this->label)."'";
$sql.= ", description = '".addslashes($this->description)."'";
$sql.= ", fk_soc = ".($this->socid > 0?$this->socid:"null");
$sql.= ", fk_statut = ".$this->statut;
$sql.= ", public = ".($this->public?1:0);
$sql.= ", datec=".($this->date_c!=''?$this->db->idate($this->date_c):'null');
$sql.= ", dateo=".($this->date_start!=''?$this->db->idate($this->date_start):'null');
$sql.= ", datee=".($this->date_end!=''?$this->db->idate($this->date_end):'null');
$sql.= " WHERE rowid = ".$this->id;
dol_syslog("Business::Update sql=".$sql,LOG_DEBUG);
if ($this->db->query($sql) )
{
if (! $notrigger)
{
// Call triggers
include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->run_triggers('BUSINESS_MODIFY',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// End call triggers
}
$result = 1;
}
else
{
$this->error=$this->db->lasterror();
dol_syslog("Business::Update error -2 ".$this->error, LOG_ERR);
$result = -2;
}
}
else
{
dol_syslog("Business::Update ref null");
$result = -1;
}
return $result;
}
/**
* \brief Get object and lines from database
* \param rowid id of object to load
* \param ref Ref of business
* \return int >0 if OK, <0 if KO
*/
function fetch($id,$ref='')
{
if (empty($id) && empty($ref)) return -1;
$sql = "SELECT rowid, ref, label, description, public, datec";
$sql.= ", tms, dateo, datee, fk_soc, fk_user_creat, fk_statut, note_private, note_public";
$sql.= " FROM ".MAIN_DB_PREFIX."business";
if ($ref) $sql.= " WHERE ref='".$ref."'";
else $sql.= " WHERE rowid=".$id;
dol_syslog("Business::fetch sql=".$sql, LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql)
{
if ($this->db->num_rows($resql))
{
$obj = $this->db->fetch_object($resql);
$this->id = $obj->rowid;
$this->ref = $obj->ref;
$this->label = $obj->label;
$this->description = $obj->description;
$this->date_c = $this->db->jdate($obj->datec);
$this->date_m = $this->db->jdate($obj->tms);
$this->date_start = $this->db->jdate($obj->dateo);
$this->date_end = $this->db->jdate($obj->datee);
$this->note_private = $obj->note_private;
$this->note_public = $obj->note_public;
$this->socid = $obj->fk_soc;
$this->user_author_id = $obj->fk_user_creat;
$this->public = $obj->public;
$this->statut = $obj->fk_statut;
$this->db->free($resql);
return 1;
}
else
{
return -1;
}
}
else
{
$this->error=$this->db->lasterror();
dol_syslog("Business::fetch ".$this->error, LOG_ERR);
return -2;
}
}
/**
* \brief Return list of business
* \param socid To filter on a particular third party
* \return array Business list
*/
function liste_array($socid='')
{
global $conf;
$business = array();
$sql = "SELECT rowid, label";
$sql.= " FROM ".MAIN_DB_PREFIX."business";
$sql.= " WHERE entity = ".$conf->entity;
if (! empty($socid)) $sql.= " AND fk_soc = ".$socid;
$resql=$this->db->query($sql);
if ($resql)
{
$nump = $this->db->num_rows($resql);
if ($nump)
{
$i = 0;
while ($i < $nump)
{
$obj = $this->db->fetch_object($resql);
$business[$obj->rowid] = $obj->label;
$i++;
}
}
return $business;
}
else
{
print $this->db->lasterror();
}
}
/**
* \brief Delete business in database
* \param User
*/
function delete($user, $notrigger=0)
{
global $conf;
$this->db->begin();
$sql = "DELETE FROM ".MAIN_DB_PREFIX."business";
$sql.= " WHERE rowid=".$this->id;
$resql = $this->db->query($sql);
if ($resql)
{
// We remove directory
$businessref = dol_sanitizeFileName($this->ref);
if ($conf->business->dir_output)
{
$dir = $conf->business->dir_output . "/" . $businessref;
if (file_exists($dir))
{
$res=@dol_delete_dir($dir);
if (! $res)
{
$this->error='ErrorFailToDeleteDir';
$this->db->rollback();
return 0;
}
}
}
if (! $notrigger)
{
// Call triggers
include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->run_triggers('BUSINESS_DELETE',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// End call triggers
}
dol_syslog("Business::delete sql=".$sql, LOG_DEBUG);
$this->db->commit();
return 1;
}
else
{
$this->error=$this->db->lasterror();
dol_syslog("Business::delete ".$this->error, LOG_ERR);
$this->db->rollback();
return -1;
}
}
/**
* \brief Validate a business
* \param user User that validate
* \return int <0 if KO, >0 if OK
*/
function setValid($user, $outputdir)
{
global $langs, $conf;
if ($this->statut != 1)
{
$this->db->begin();
$sql = "UPDATE ".MAIN_DB_PREFIX."business";
$sql.= " SET fk_statut = 1";
$sql.= " WHERE rowid = ".$this->id;
$sql.= " AND entity = ".$conf->entity;
dol_syslog("Business::setValid sql=".$sql);
$resql=$this->db->query($sql);
if ($resql)
{
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->run_triggers('BUSINESS_VALIDATE',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers
if (! $error)
{
$this->db->commit();
return 1;
}
else
{
$this->db->rollback();
$this->error=join(',',$this->errors);
dol_syslog("Business::setValid ".$this->error,LOG_ERR);
return -1;
}
}
else
{
$this->db->rollback();
$this->error=$this->db->lasterror();
dol_syslog("Business::setValid ".$this->error,LOG_ERR);
return -1;
}
}
}
/**
* \brief Close a business
* \param user User that validate
* \return int <0 if KO, >0 if OK
*/
function setClose($user, $outputdir)
{
global $langs, $conf;
if ($this->statut != 2)
{
$this->db->begin();
$sql = "UPDATE ".MAIN_DB_PREFIX."business";
$sql.= " SET fk_statut = 2";
$sql.= " WHERE rowid = ".$this->id;
$sql.= " AND entity = ".$conf->entity;
$sql.= " AND fk_statut = 1";
dol_syslog("Business::setClose sql=".$sql);
$resql=$this->db->query($sql);
if ($resql)
{
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->run_triggers('BUSINESS_CLOSE',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers
if (! $error)
{
$this->db->commit();
return 1;
}
else
{
$this->db->rollback();
$this->error=join(',',$this->errors);
dol_syslog("Business::setClose ".$this->error,LOG_ERR);
return -1;
}
}
else
{
$this->db->rollback();
$this->error=$this->db->lasterror();
dol_syslog("Business::setClose ".$this->error,LOG_ERR);
return -1;
}
}
}
/**
* \brief Return status label of object
* \param mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto
* \return string Label
*/
function getLibStatut($mode=0)
{
return $this->LibStatut($this->statut,$mode);
}
/**
* \brief Return status label of object
* \param statut id statut
* \param mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto
* \return string Label
*/
function LibStatut($statut,$mode=0)
{
global $langs;
if ($mode == 0)
{
return $langs->trans($this->statuts[$statut]);
}
if ($mode == 1)
{
return $langs->trans($this->statuts_short[$statut]);
}
if ($mode == 2)
{
if ($statut==0) return img_picto($langs->trans($this->statuts_short[$statut]),'statut0').' '.$langs->trans($this->statuts_short[$statut]);
if ($statut==1) return img_picto($langs->trans($this->statuts_short[$statut]),'statut4').' '.$langs->trans($this->statuts_short[$statut]);
if ($statut==2) return img_picto($langs->trans($this->statuts_short[$statut]),'statut6').' '.$langs->trans($this->statuts_short[$statut]);
}
if ($mode == 3)
{
if ($statut==0) return img_picto($langs->trans($this->statuts_short[$statut]),'statut0');
if ($statut==1) return img_picto($langs->trans($this->statuts_short[$statut]),'statut4');
if ($statut==2) return img_picto($langs->trans($this->statuts_short[$statut]),'statut6');
}
if ($mode == 4)
{
if ($statut==0) return img_picto($langs->trans($this->statuts_short[$statut]),'statut0').' '.$langs->trans($this->statuts_short[$statut]);
if ($statut==1) return img_picto($langs->trans($this->statuts_short[$statut]),'statut4').' '.$langs->trans($this->statuts_short[$statut]);
if ($statut==2) return img_picto($langs->trans($this->statuts_short[$statut]),'statut6').' '.$langs->trans($this->statuts_short[$statut]);
}
if ($mode == 5)
{
if ($statut==0) return $langs->trans($this->statuts_short[$statut]).' '.img_picto($langs->trans($this->statuts_short[$statut]),'statut0');
if ($statut==1) return $langs->trans($this->statuts_short[$statut]).' '.img_picto($langs->trans($this->statuts_short[$statut]),'statut1');
if ($statut==2) return img_picto($langs->trans($this->statuts_short[$statut]),'statut6').' '.$langs->trans($this->statuts_short[$statut]);
}
}
/**
* \brief Renvoie nom clicable (avec eventuellement le picto)
* \param withpicto 0=Pas de picto, 1=Inclut le picto dans le lien, 2=Picto seul
* \param option Sur quoi pointe le lien
* \return string Chaine avec URL
*/
function getNomUrl($withpicto=0,$option='')
{
global $langs;
$result='';
$lien = '<a href="'.DOL_URL_ROOT.'/business/fiche.php?id='.$this->id.'">';
$lienfin='</a>';
$picto='businesspub@business';
if (! $this->public) $picto='business@business';
$label=$langs->trans("ShowBusiness").': '.$this->ref.($this->label?' - '.$this->label:'');
if ($withpicto) $result.=($lien.img_object($label,$picto).$lienfin);
if ($withpicto && $withpicto != 2) $result.=' ';
if ($withpicto != 2) $result.=$lien.$this->ref.$lienfin;
return $result;
}
/**
* \brief Check permissions
*/
function restrictedBusinessArea($user,$list=0)
{
// To verify role of users
$userAccess = 0;
if ((!empty($this->user_author_id) && $this->user_author_id == $user->id) || $user->rights->business->all->read)
{
$userAccess = 1;
}
else if ($this->public && $user->rights->business->read)
{
$userAccess = 1;
}
else
{
foreach(array('internal','external') as $source)
{
$userRole = $this->liste_contact(4,$source);
$num=sizeof($userRole);
$i = 0;
while ($i < $num)
{
if ($userRole[$i]['code'] == 'ACCOUNTMANAGER' && $user->id == $userRole[$i]['id'])
{
$userAccess++;
}
$i++;
}
}
}
if (!$userAccess && !$this->public)
{
if (!$list)
{
accessforbidden('',0);
}
else
{
return -1;
}
}
return $userAccess;
}
/**
* Return array of business authorized for a user
*
* @param unknown_type $user
* @return unknown
*/
function getBusinessAuthorizedForUser($user,$mine=0,$list=0)
{
global $conf;
$business = array();
$temp = array();
$sql = "SELECT DISTINCT b.rowid, b.ref";
$sql.= " FROM ".MAIN_DB_PREFIX."business as b";
$sql.= ", ".MAIN_DB_PREFIX."element_contact as ec";
$sql.= ", ".MAIN_DB_PREFIX."c_type_contact as ctc";
$sql.= " WHERE b.entity = ".$conf->entity;
if ($mine)
{
$sql.= " AND ec.element_id = b.rowid";
$sql.= " AND ctc.rowid = ec.fk_c_type_contact";
$sql.= " AND ctc.element = '".$this->element."'";
$sql.= " AND ec.fk_socpeople = ".$user->id;
}
else
{
$sql.= " AND ( b.public = 1";
$sql.= " OR b.fk_user_creat = ".$user->id;
$sql.= " OR ( ec.element_id = b.rowid";
$sql.= " AND ctc.rowid = ec.fk_c_type_contact";
$sql.= " AND ctc.element = '".$this->element."'";
$sql.= " AND ec.fk_socpeople = ".$user->id." ) )";
}
$resql = $this->db->query($sql);
if ($resql)
{
$num = $this->db->num_rows($resql);
$i = 0;
while ($i < $num)
{
$row = $this->db->fetch_row($resql);
$business[$row[0]] = $row[1];
$temp[] = $row[0];
$i++;
}
$this->db->free($resql);
if ($list)
{
if (empty($temp)) return 0;
$result = implode(',',$temp);
return $result;
}
}
else
{
dol_print_error($this->db);
}
return $business;
}
/**
* Return list of roles for a user for each projects or each tasks (or a particular project or task)
* @param user
* @param businessid Business id to filter on a business
* @return array Array (businessid => 'list of roles for business')
*/
function getUserRolesForBusiness($user,$businessid=0)
{
$businessrole = array();
dol_syslog("Phase::getUserRolesForBusiness user=".is_object($user)." businessid=".$businessid);
$sql = "SELECT b.rowid as businessid, ec.element_id, ctc.code";
$sql.= " FROM ".MAIN_DB_PREFIX."business as b";
$sql.= ", ".MAIN_DB_PREFIX."element_contact as ec";
$sql.= ", ".MAIN_DB_PREFIX."c_type_contact as ctc";
$sql.= " WHERE b.rowid = ec.element_id";
$sql.= " AND ctc.element = 'business'";
$sql.= " AND ctc.rowid = ec.fk_c_type_contact";
if (is_object($user)) $sql.= " AND ec.fk_socpeople = ".$user->id;
$sql.= " AND ec.statut = 4";
if ($businessid) $sql.= " AND b.rowid = ".$businessid;
print $sql.'<br>';
dol_syslog("Phase::getUserRolesForBusiness sql=".$sql);
$resql = $this->db->query($sql);
if ($resql)
{
$num = $this->db->num_rows($resql);
$i = 0;
while ($i < $num)
{
$obj = $this->db->fetch_object($resql);
if (empty($businessrole[$obj->businessid])) $businessrole[$obj->businessid] = $obj->code;
else $businessrole[$obj->businessid].=','.$obj->code;
$i++;
}
$this->db->free($resql);
}
else
{
dol_print_error($this->db);
}
return $businessrole;
}
}
?>

View File

@ -0,0 +1,890 @@
<?php
/* Copyright (C) 2010 Regis Houssin <regis@dolibarr.fr>
*
* 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 2 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, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/**
* \file htdocs/business/class/phase.class.php
* \ingroup business
* \brief This file is a class to manage phases of business
* \version $Id$
*/
/**
* \class Phase
* \brief Class to manage phases of business
*/
class Phase extends CommonObject
{
var $db; //!< To store db handler
var $error; //!< To return error code (or message)
var $errors=array(); //!< To return several error codes (or messages)
var $element='business_phase'; //!< Id that identify managed objects
var $table_element='business_phase'; //!< Name of table without prefix where object is stored
var $id;
var $fk_business;
var $fk_milestone;
var $label;
var $description;
var $date_c;
var $date_start;
var $date_end;
var $progress;
var $priority;
var $fk_user_creat;
var $fk_user_valid;
var $statut;
var $note_private;
var $note_public;
var $total_ht; // Total net of tax
var $total_tva; // Total VAT
var $total_ttc; // Total with tax
var $tva_tx;
/**
* \brief Constructor
* \param DB Database handler
*/
function Phase($DB)
{
$this->db = $DB;
$this->statuts_short=array(0=>'Draft',1=>'Validated',2=>'ActionRunningShort',5=>'ToBill');
$this->statuts=array(0=>'Draft',1=>'Validated',2=>'ActionRunningShort',5=>'ToBill');
}
/**
* \brief Create in database
* \param user User that create
* \param notrigger 0=launch triggers after, 1=disable triggers
* \return int <0 if KO, Id of created object if OK
*/
function create($user, $notrigger=0)
{
global $conf, $langs;
include_once(DOL_DOCUMENT_ROOT.'/lib/price.lib.php');
$error=0;
// Clean parameters
$this->label = trim($this->label);
$this->description = trim($this->description);
$total_ht = price2num($this->total_ht);
$tva_tx = price2num($this->tva_tx);
$tabprice=calcul_price_total(1, $total_ht, 0, $tva_tx);
$total_ht = $tabprice[0];
$total_tva = $tabprice[1];
$total_ttc = $tabprice[2];
// Check parameters
// Put here code to add control on parameters values
// Insert request
$sql = "INSERT INTO ".MAIN_DB_PREFIX."business_phase (";
$sql.= "fk_business";
//$sql.= ", fk_milestone";
$sql.= ", label";
$sql.= ", description";
$sql.= ", datec";
$sql.= ", fk_user_creat";
$sql.= ", dateo";
$sql.= ", datee";
$sql.= ", total_ht";
$sql.= ", total_tva";
$sql.= ", total_ttc";
$sql.= ", tva_tx";
$sql.= ", progress";
$sql.= ") VALUES (";
$sql.= $this->fk_business;
//$sql.= ", ".$this->fk_milestone;
$sql.= ", '".addslashes($this->label)."'";
$sql.= ", '".addslashes($this->description)."'";
$sql.= ", ".$this->db->idate($this->date_c);
$sql.= ", ".$user->id;
$sql.= ", ".($this->date_start!=''?$this->db->idate($this->date_start):'null');
$sql.= ", ".($this->date_end!=''?$this->db->idate($this->date_end):'null');
$sql.= ", '".$total_ht."'";
$sql.= ", '".$total_tva."'";
$sql.= ", '".$total_ttc."'";
$sql.= ", '".$tva_tx."'";
$sql.= ", ".($this->progress!=''?$this->progress:0);
$sql.= ")";
$this->db->begin();
dol_syslog(get_class($this)."::create sql=".$sql, LOG_DEBUG);
$resql=$this->db->query($sql);
if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
if (! $error)
{
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."business_phase");
if (! $notrigger)
{
// Call triggers
include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->run_triggers('PHASE_CREATE',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// End call triggers
}
}
// Commit or rollback
if ($error)
{
foreach($this->errors as $errmsg)
{
dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR);
$this->error.=($this->error?', '.$errmsg:$errmsg);
}
$this->db->rollback();
return -1*$error;
}
else
{
$this->db->commit();
return $this->id;
}
}
/**
* \brief Load object in memory from database
* \param id id object
* \return int <0 if KO, >0 if OK
*/
function fetch($id)
{
global $langs;
$sql = "SELECT ";
$sql.= "p.rowid";
$sql.= ", p.fk_business";
$sql.= ", p.label";
$sql.= ", p.description";
//$sql.= ", p.duration_effective";
$sql.= ", p.dateo";
$sql.= ", p.datee";
$sql.= ", p.fk_user_creat";
$sql.= ", p.fk_user_valid";
$sql.= ", p.fk_statut";
$sql.= ", p.progress";
$sql.= ", p.priority";
$sql.= ", p.note_private";
$sql.= ", p.note_public";
$sql.= ", p.total_ht";
$sql.= ", p.total_tva";
$sql.= ", p.total_ttc";
$sql.= ", p.tva_tx";
$sql.= " FROM ".MAIN_DB_PREFIX."business_phase as p";
$sql.= " WHERE p.rowid = ".$id;
dol_syslog(get_class($this)."::fetch sql=".$sql, LOG_DEBUG);
$resql=$this->db->query($sql);
if ($resql)
{
if ($this->db->num_rows($resql))
{
$obj = $this->db->fetch_object($resql);
$this->id = $obj->rowid;
$this->ref = $obj->rowid;
$this->fk_business = $obj->fk_business;
//$this->fk_milestone = $obj->fk_milestone;
$this->label = $obj->label;
$this->description = $obj->description;
//$this->duration_effective = $obj->duration_effective;
$this->date_c = $this->db->jdate($obj->datec);
$this->date_start = $this->db->jdate($obj->dateo);
$this->date_end = $this->db->jdate($obj->datee);
$this->fk_user_creat = $obj->fk_user_creat;
$this->fk_user_valid = $obj->fk_user_valid;
$this->statut = $obj->fk_statut;
$this->progress = $obj->progress;
$this->priority = $obj->priority;
$this->note_private = $obj->note_private;
$this->note_public = $obj->note_public;
$this->total_ht = $obj->total_ht;
$this->total_tva = $obj->total_tva;
$this->total_ttc = $obj->total_ttc;
$this->tva_tx = $obj->tva_tx;
}
$this->db->free($resql);
return 1;
}
else
{
$this->error="Error ".$this->db->lasterror();
dol_syslog(get_class($this)."::fetch ".$this->error, LOG_ERR);
return -1;
}
}
/**
* \brief Update database
* \param user User that modify
* \param notrigger 0=launch triggers after, 1=disable triggers
* \return int <0 if KO, >0 if OK
*/
function update($user=0, $notrigger=0)
{
global $conf, $langs;
include_once(DOL_DOCUMENT_ROOT.'/lib/price.lib.php');
$error=0;
// Clean parameters
if (isset($this->label)) $this->label=trim($this->label);
if (isset($this->description)) $this->description=trim($this->description);
//if (isset($this->duration_effective)) $this->duration_effective=trim($this->duration_effective);
// Check parameters
$total_ht = price2num($this->total_ht);
$tva_tx = price2num($this->tva_tx);
$tabprice=calcul_price_total(1, $total_ht, 0, $tva_tx);
$total_ht = $tabprice[0];
$total_tva = $tabprice[1];
$total_ttc = $tabprice[2];
// Update request
$sql = "UPDATE ".MAIN_DB_PREFIX."business_phase SET";
$sql.= " label=".(isset($this->label)?"'".addslashes($this->label)."'":"null").",";
$sql.= " description=".(isset($this->description)?"'".addslashes($this->description)."'":"null").",";
//$sql.= " duration_effective=".(isset($this->duration_effective)?$this->duration_effective:"null").",";
$sql.= " dateo=".($this->date_start!=''?$this->db->idate($this->date_start):'null').",";
$sql.= " datee=".($this->date_end!=''?$this->db->idate($this->date_end):'null').",";
$sql.= " total_ht='".$total_ht."',";
$sql.= " total_tva='".$total_tva."',";
$sql.= " total_ttc='".$total_ttc."',";
$sql.= " tva_tx='".$tva_tx."',";
$sql.= " progress=".$this->progress;
$sql.= " WHERE rowid=".$this->id;
$this->db->begin();
dol_syslog(get_class($this)."::update sql=".$sql, LOG_DEBUG);
$resql = $this->db->query($sql);
if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
if (! $error)
{
if (! $notrigger)
{
// Call triggers
include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->run_triggers('PHASE_MODIFY',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// End call triggers
}
}
// Commit or rollback
if ($error)
{
foreach($this->errors as $errmsg)
{
dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR);
$this->error.=($this->error?', '.$errmsg:$errmsg);
}
$this->db->rollback();
return -1*$error;
}
else
{
$this->db->commit();
return 1;
}
}
/**
* \brief Delete object in database
* \param user User that delete
* \param notrigger 0=launch triggers after, 1=disable triggers
* \return int <0 if KO, >0 if OK
*/
function delete($user, $notrigger=0)
{
global $conf, $langs;
$error=0;
$this->db->begin();
if ($this->hasChildren() > 0)
{
dol_syslog(get_class($this)."::delete Can't delete record as it has some child", LOG_WARNING);
$this->error='ErrorRecordHasChildren';
$this->db->rollback();
return 0;
}
$sql = "DELETE FROM ".MAIN_DB_PREFIX."projet_task";
$sql.= " WHERE rowid=".$this->id;
dol_syslog(get_class($this)."::delete sql=".$sql);
$resql = $this->db->query($sql);
if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
if (! $error)
{
if (! $notrigger)
{
// Call triggers
include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->run_triggers('TASK_DELETE',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// End call triggers
}
}
// Commit or rollback
if ($error)
{
foreach($this->errors as $errmsg)
{
dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR);
$this->error.=($this->error?', '.$errmsg:$errmsg);
}
$this->db->rollback();
return -1*$error;
}
else
{
$this->db->commit();
return 1;
}
}
/**
* \brief Return nb of children
* \return <0 if KO, 0 if no children, >0 if OK
*/
function hasChildren()
{
$ret=0;
$sql = "SELECT COUNT(*) as nb";
$sql.= " FROM ".MAIN_DB_PREFIX."projet_task";
$sql.= " WHERE fk_task_parent=".$this->id;
dol_syslog(get_class($this)."::hasChildren sql=".$sql, LOG_DEBUG);
$resql = $this->db->query($sql);
if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
else
{
$obj=$this->db->fetch_object($resql);
if ($obj) $ret=$obj->nb;
}
if (! $error)
{
return $ret;
}
else
{
return -1;
}
}
/**
* \brief Renvoie nom clicable (avec eventuellement le picto)
* \param withpicto 0=Pas de picto, 1=Inclut le picto dans le lien, 2=Picto seul
* \param option Sur quoi pointe le lien
* \return string Chaine avec URL
*/
function getNomUrl($withpicto=0,$option='')
{
global $langs;
$result='';
$lien = '<a href="'.DOL_URL_ROOT.'/business/phases/phase.php?id='.$this->id.'">';
$lienfin='</a>';
$picto='projecttask';
$label=$langs->trans("ShowPhase").': '.$this->ref.($this->label?' - '.$this->label:'');
if ($withpicto) $result.=($lien.img_object($label,$picto).$lienfin);
if ($withpicto && $withpicto != 2) $result.=' ';
if ($withpicto != 2) $result.=$lien.$this->ref.$lienfin;
return $result;
}
/**
* \brief Initialise object with example values
* \remarks id must be 0 if object instance is a specimen.
*/
function initAsSpecimen()
{
$this->id=0;
$this->fk_projet='';
$this->fk_task_parent='';
$this->title='';
$this->duration_effective='';
$this->fk_user_creat='';
$this->statut='';
$this->note='';
}
/**
* Return list of phases for a business
* Sort order is on business
* @param user Object user to limit phase affected to a particular user
* @param businessid Business id
* @param socid Third party id
* @return array Array of tasks
*/
function getPhasesArray($user=0, $businessid=0, $socid=0)
{
global $conf;
$phases = array();
$sql = "SELECT b.rowid as businessid, b.ref, b.label as business_label, b.public";
$sql.= ", p.rowid as phaseid, p.label as phase_label, p.progress, p.total_ht, p.total_ttc, p.fk_statut";
$sql.= " FROM ".MAIN_DB_PREFIX."business as b";
$sql.= " RIGHT JOIN ".MAIN_DB_PREFIX."business_phase as p on p.fk_business = b.rowid";
$sql.= " WHERE b.entity = ".$conf->entity;
if ($socid) $sql.= " AND b.fk_soc = ".$socid;
if ($businessid) $sql.= " AND b.rowid =".$businessid;
$sql.= " ORDER BY p.rang ASC, p.rowid";
//print $sql;
dol_syslog("Phase::getPhasesArray sql=".$sql, LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql)
{
$num = $this->db->num_rows($resql);
$i = 0;
// Loop on each record found, so each couple (project id, task id)
while ($i < $num)
{
$error=0;
$obj = $this->db->fetch_object($resql);
if ((! $obj->public) && is_object($user)) // If not public and we ask a filter on user
{
if (! $this->getUserRolesForPhase($user, $obj->phaseid) && ! $user->rights->business->all->read)
{
$error++;
//print '<br>error<br>';
}
}
if (! $error)
{
$phases[$i]->id = $obj->phaseid;
$phases[$i]->businessid = $obj->businessid;
$phases[$i]->businessref = $obj->ref;
$phases[$i]->businesslabel = $obj->business_label;
$phases[$i]->label = $obj->phase_label;
$phases[$i]->description = $obj->description;
$phases[$i]->total_ht = $obj->total_ht;
$phases[$i]->total_ttc = $obj->total_ttc;
//$phases[$i]->fk_milestone = $obj->fk_milestone;
//$phases[$i]->duration = $obj->duration_effective;
$phases[$i]->statut = $obj->fk_statut;
$phases[$i]->progress = $obj->progress;
$phases[$i]->public = $obj->public;
}
$i++;
}
$this->db->free($resql);
}
else
{
dol_print_error($this->db);
}
return $phases;
}
/**
* Return list of roles for a user for each projects or each tasks (or a particular project or task)
* @param user
* @param businessid Business id to filter on a business
* @return array Array (businessid => 'list of roles for business')
*/
function getUserRolesForPhase($user,$phaseid=0)
{
$phaserole = array();
dol_syslog("Phase::getUserRolesForPhase user=".is_object($user)." phaseid=".$phaseid);
$sql = "SELECT p.rowid as phaseid, ec.element_id, ctc.code";
$sql.= " FROM ".MAIN_DB_PREFIX."business_phase as p";
$sql.= ", ".MAIN_DB_PREFIX."element_contact as ec";
$sql.= ", ".MAIN_DB_PREFIX."c_type_contact as ctc";
$sql.= " WHERE p.rowid = ec.element_id";
$sql.= " AND ctc.element = 'business_phase'";
$sql.= " AND ctc.rowid = ec.fk_c_type_contact";
if (is_object($user)) $sql.= " AND ec.fk_socpeople = ".$user->id;
$sql.= " AND ec.statut = 4";
if ($phaseid) $sql.= " AND p.rowid = ".$phaseid;
//print $sql.'<br>';
dol_syslog("Phase::getUserRolesForPhase sql=".$sql);
$resql = $this->db->query($sql);
if ($resql)
{
$num = $this->db->num_rows($resql);
$i = 0;
while ($i < $num)
{
$obj = $this->db->fetch_object($resql);
if (empty($phaserole[$obj->phaseid])) $phaserole[$obj->phaseid] = $obj->code;
else $phaserole[$obj->phaseid].=','.$obj->code;
$i++;
}
$this->db->free($resql);
}
else
{
dol_print_error($this->db);
}
return $phaserole;
}
/**
* \brief Add time spent
* \param user user id
* \param notrigger 0=launch triggers after, 1=disable triggers
*/
function addTimeSpent($user, $notrigger=0)
{
$ret = 0;
// Clean parameters
if (isset($this->timespent_note)) $this->timespent_note = trim($this->timespent_note);
$sql = "INSERT INTO ".MAIN_DB_PREFIX."projet_task_time (";
$sql.= "fk_task";
$sql.= ", task_date";
$sql.= ", task_duration";
$sql.= ", fk_user";
$sql.= ", note";
$sql.= ") VALUES (";
$sql.= $this->id;
$sql.= ", '".$this->db->idate($this->timespent_date)."'";
$sql.= ", ".$this->timespent_duration;
$sql.= ", ".$this->timespent_fk_user;
$sql.= ", ".(isset($this->timespent_note)?"'".addslashes($this->timespent_note)."'":"null");
$sql.= ")";
dol_syslog(get_class($this)."::addTimeSpent sql=".$sql, LOG_DEBUG);
if ($this->db->query($sql) )
{
$task_id = $this->db->last_insert_id(MAIN_DB_PREFIX."projet_task_time");
$ret = $task_id;
if (! $notrigger)
{
// Call triggers
include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->run_triggers('TASK_TIMESPENT_CREATE',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// End call triggers
}
}
else
{
$this->error=$this->db->lasterror();
dol_syslog(get_class($this)."::addTimeSpent error -1 ".$this->error,LOG_ERR);
$ret = -1;
}
if ($ret >= 0)
{
$sql = "UPDATE ".MAIN_DB_PREFIX."projet_task";
$sql.= " SET duration_effective = duration_effective + '".price2num($this->timespent_duration)."'";
$sql.= " WHERE rowid = ".$this->id;
dol_syslog(get_class($this)."::addTimeSpent sql=".$sql, LOG_DEBUG);
if (! $this->db->query($sql) )
{
$this->error=$this->db->lasterror();
dol_syslog(get_class($this)."::addTimeSpent error -2 ".$this->error, LOG_ERR);
$ret = -2;
}
}
return $ret;
}
/**
* \brief Load object in memory from database
* \param id id object
* \return int <0 if KO, >0 if OK
*/
function fetchTimeSpent($id)
{
global $langs;
$sql = "SELECT";
$sql.= " t.rowid,";
$sql.= " t.fk_task,";
$sql.= " t.task_date,";
$sql.= " t.task_duration,";
$sql.= " t.fk_user,";
$sql.= " t.note";
$sql.= " FROM ".MAIN_DB_PREFIX."projet_task_time as t";
$sql.= " WHERE t.rowid = ".$id;
dol_syslog(get_class($this)."::fetchTimeSpent sql=".$sql, LOG_DEBUG);
$resql=$this->db->query($sql);
if ($resql)
{
if ($this->db->num_rows($resql))
{
$obj = $this->db->fetch_object($resql);
$this->timespent_id = $obj->rowid;
$this->id = $obj->fk_task;
$this->timespent_date = $obj->task_date;
$this->timespent_duration = $obj->task_duration;
$this->timespent_user = $obj->fk_user;
$this->timespent_note = $obj->note;
}
$this->db->free($resql);
return 1;
}
else
{
$this->error="Error ".$this->db->lasterror();
dol_syslog(get_class($this)."::fetchTimeSpent ".$this->error, LOG_ERR);
return -1;
}
}
/**
* \brief Update time spent
* \param user User id
* \param notrigger 0=launch triggers after, 1=disable triggers
*/
function updateTimeSpent($user, $notrigger=0)
{
$ret = 0;
// Clean parameters
if (isset($this->timespent_note)) $this->timespent_note = trim($this->timespent_note);
$sql = "UPDATE ".MAIN_DB_PREFIX."projet_task_time SET";
$sql.= " task_date = '".$this->db->idate($this->timespent_date)."',";
$sql.= " task_duration = ".$this->timespent_duration.",";
$sql.= " fk_user = ".$this->timespent_fk_user.",";
$sql.= " note = ".(isset($this->timespent_note)?"'".addslashes($this->timespent_note)."'":"null");
$sql.= " WHERE rowid = ".$this->timespent_id;
dol_syslog(get_class($this)."::updateTimeSpent sql=".$sql, LOG_DEBUG);
if ($this->db->query($sql) )
{
if (! $notrigger)
{
// Call triggers
include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->run_triggers('TASK_TIMESPENT_MODIFY',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// End call triggers
}
$ret = 1;
}
else
{
$this->error=$this->db->lasterror();
dol_syslog(get_class($this)."::updateTimeSpent error -1 ".$this->error,LOG_ERR);
$ret = -1;
}
if ($ret == 1 && ($this->timespent_old_duration != $this->timespent_duration))
{
$newDuration = $this->timespent_duration - $this->timespent_old_duration;
$sql = "UPDATE ".MAIN_DB_PREFIX."projet_task";
$sql.= " SET duration_effective = duration_effective + '".$newDuration."'";
$sql.= " WHERE rowid = ".$this->id;
dol_syslog(get_class($this)."::updateTimeSpent sql=".$sql, LOG_DEBUG);
if (! $this->db->query($sql) )
{
$this->error=$this->db->lasterror();
dol_syslog(get_class($this)."::addTimeSpent error -2 ".$this->error, LOG_ERR);
$ret = -2;
}
}
return $ret;
}
/**
* \brief Delete time spent
* \param user User that delete
* \param notrigger 0=launch triggers after, 1=disable triggers
* \return int <0 if KO, >0 if OK
*/
function delTimeSpent($user, $notrigger=0)
{
global $conf, $langs;
$error=0;
$this->db->begin();
$sql = "DELETE FROM ".MAIN_DB_PREFIX."projet_task_time";
$sql.= " WHERE rowid = ".$this->timespent_id;
dol_syslog(get_class($this)."::delTimeSpent sql=".$sql);
$resql = $this->db->query($sql);
if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
if (! $error)
{
if (! $notrigger)
{
// Call triggers
include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->run_triggers('TASK_TIMESPENT_DELETE',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// End call triggers
}
}
if (! $error)
{
$sql = "UPDATE ".MAIN_DB_PREFIX."projet_task";
$sql.= " SET duration_effective = duration_effective - '".$this->timespent_duration."'";
$sql.= " WHERE rowid = ".$this->id;
dol_syslog(get_class($this)."::delTimeSpent sql=".$sql, LOG_DEBUG);
if ($this->db->query($sql) )
{
$result = 0;
}
else
{
$this->error=$this->db->lasterror();
dol_syslog(get_class($this)."::addTimeSpent error -3 ".$this->error, LOG_ERR);
$result = -2;
}
}
// Commit or rollback
if ($error)
{
foreach($this->errors as $errmsg)
{
dol_syslog(get_class($this)."::delTimeSpent ".$errmsg, LOG_ERR);
$this->error.=($this->error?', '.$errmsg:$errmsg);
}
$this->db->rollback();
return -1*$error;
}
else
{
$this->db->commit();
return 1;
}
}
/**
* \brief Return status label of object
* \param mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto
* \return string Label
*/
function getLibStatut($mode=0)
{
return $this->LibStatut($this->statut,$mode);
}
/**
* \brief Return status label of object
* \param statut id statut
* \param mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto
* \return string Label
*/
function LibStatut($statut,$mode=0)
{
global $langs;
if ($mode == 0)
{
return $langs->trans($this->statuts[$statut]);
}
if ($mode == 1)
{
return $langs->trans($this->statuts_short[$statut]);
}
if ($mode == 2)
{
if ($statut==0) return img_picto($langs->trans($this->statuts_short[$statut]),'statut0').' '.$langs->trans($this->statuts_short[$statut]);
if ($statut==1) return img_picto($langs->trans($this->statuts_short[$statut]),'statut1').' '.$langs->trans($this->statuts_short[$statut]);
if ($statut==2) return img_picto($langs->trans($this->statuts_short[$statut]),'statut3').' '.$langs->trans($this->statuts_short[$statut]);
if ($statut==5) return img_picto($langs->trans($this->statuts_short[$statut]),'statut4').' '.$langs->trans($this->statuts_short[$statut]);
}
if ($mode == 3)
{
if ($statut==0) return img_picto($langs->trans($this->statuts_short[$statut]),'statut0');
if ($statut==1) return img_picto($langs->trans($this->statuts_short[$statut]),'statut1');
if ($statut==2) return img_picto($langs->trans($this->statuts_short[$statut]),'statut3');
if ($statut==5) return img_picto($langs->trans($this->statuts_short[$statut]),'statut4');
}
if ($mode == 4)
{
if ($statut==0) return img_picto($langs->trans($this->statuts_short[$statut]),'statut0').' '.$langs->trans($this->statuts_short[$statut]);
if ($statut==1) return img_picto($langs->trans($this->statuts_short[$statut]),'statut1').' '.$langs->trans($this->statuts_short[$statut]);
if ($statut==2) return img_picto($langs->trans($this->statuts_short[$statut]),'statut3').' '.$langs->trans($this->statuts_short[$statut]);
if ($statut==5) return img_picto($langs->trans($this->statuts_short[$statut]),'statut4').' '.$langs->trans($this->statuts_short[$statut]);
}
if ($mode == 5)
{
if ($statut==0) return $langs->trans($this->statuts_short[$statut]).' '.img_picto($langs->trans($this->statuts_short[$statut]),'statut0');
if ($statut==1) return $langs->trans($this->statuts_short[$statut]).' '.img_picto($langs->trans($this->statuts_short[$statut]),'statut1');
if ($statut==2) return $langs->trans($this->statuts_short[$statut]).' '.img_picto($langs->trans($this->statuts_short[$statut]),'statut3');
if ($statut==5) return $langs->trans($this->statuts_short[$statut]).' '.img_picto($langs->trans($this->statuts_short[$statut]),'statut4');
}
}
}
?>

View File

@ -169,9 +169,9 @@ class Categorie
}
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/workflow/class/interfaces.class.php");
include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->call_workflow('CATEGORY_CREATE',$this,$user,$langs,$conf);
$result=$interface->run_triggers('CATEGORY_CREATE',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers
@ -249,9 +249,9 @@ class Categorie
$this->db->commit();
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/workflow/class/interfaces.class.php");
include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->call_workflow('CATEGORY_MODIFY',$this,$user,$langs,$conf);
$result=$interface->run_triggers('CATEGORY_MODIFY',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers
@ -303,9 +303,9 @@ class Categorie
else
{
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/workflow/class/interfaces.class.php");
include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->call_workflow('CATEGORY_DELETE',$this,$user,$langs,$conf);
$result=$interface->run_triggers('CATEGORY_DELETE',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers

View File

@ -189,9 +189,9 @@ class ActionComm
if (! $notrigger)
{
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/workflow/class/interfaces.class.php");
include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->call_workflow('ACTION_CREATE',$this,$user,$langs,$conf);
$result=$interface->run_triggers('ACTION_CREATE',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers
}

View File

@ -549,9 +549,9 @@ if ($_POST['action'] == 'send' && ! $_POST['addfile'] && ! $_POST['removedfile']
$propal->propalrowid=$propal->id;
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/workflow/class/interfaces.class.php");
include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php");
$interface=new Interfaces($db);
$result=$interface->call_workflow('PROPAL_SENTBYMAIL',$propal,$user,$langs,$conf);
$result=$interface->run_triggers('PROPAL_SENTBYMAIL',$propal,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers

View File

@ -459,9 +459,9 @@ class Propal extends CommonObject
if (! $notrigger)
{
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/workflow/class/interfaces.class.php");
include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php");
$interface=new Interfaces($this->db);
$result = $interface->call_workflow('LINEPROPAL_UPDATE',$this,$user,$langs,$conf);
$result = $interface->run_triggers('LINEPROPAL_UPDATE',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers
}
@ -665,9 +665,9 @@ class Propal extends CommonObject
if (! $notrigger)
{
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/workflow/class/interfaces.class.php");
include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->call_workflow('PROPAL_CREATE',$this,$user,$langs,$conf);
$result=$interface->run_triggers('PROPAL_CREATE',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers
}
@ -976,9 +976,9 @@ class Propal extends CommonObject
if (! $notrigger)
{
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/workflow/class/interfaces.class.php");
include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->call_workflow('PROPAL_VALIDATE',$this,$user,$langs,$conf);
$result=$interface->run_triggers('PROPAL_VALIDATE',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers
}
@ -1249,9 +1249,9 @@ class Propal extends CommonObject
$this->use_webcal=($conf->global->PHPWEBCALENDAR_PROPALSTATUS=='always'?1:0);
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/workflow/class/interfaces.class.php");
include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->call_workflow('PROPAL_CLOSE_SIGNED',$this,$user,$langs,$conf);
$result=$interface->run_triggers('PROPAL_CLOSE_SIGNED',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers
}
@ -1260,9 +1260,9 @@ class Propal extends CommonObject
$this->use_webcal=($conf->global->PHPWEBCALENDAR_PROPALSTATUS=='always'?1:0);
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/workflow/class/interfaces.class.php");
include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->call_workflow('PROPAL_CLOSE_REFUSED',$this,$user,$langs,$conf);
$result=$interface->run_triggers('PROPAL_CLOSE_REFUSED',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers
}
@ -1623,9 +1623,9 @@ class Propal extends CommonObject
if (! $notrigger)
{
// Call triggers
include_once(DOL_DOCUMENT_ROOT . "/workflow/class/interfaces.class.php");
include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->call_workflow('PROPAL_DELETE',$this,$user,$langs,$conf);
$result=$interface->run_triggers('PROPAL_DELETE',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// End call triggers
}
@ -2309,9 +2309,9 @@ class PropaleLigne
if (! $notrigger)
{
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/workflow/class/interfaces.class.php");
include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php");
$interface=new Interfaces($this->db);
$result = $interface->call_workflow('LINEPROPAL_INSERT',$this,$user,$langs,$conf);
$result = $interface->run_triggers('LINEPROPAL_INSERT',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers
}

View File

@ -328,9 +328,9 @@ class Commande extends CommonObject
if (! $error)
{
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/workflow/class/interfaces.class.php");
include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->call_workflow('ORDER_VALIDATE',$this,$user,$langs,$conf);
$result=$interface->run_triggers('ORDER_VALIDATE',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers
}
@ -451,9 +451,9 @@ class Commande extends CommonObject
$this->use_webcal=($conf->global->PHPWEBCALENDAR_BILLSTATUS=='always'?1:0);
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/workflow/class/interfaces.class.php");
include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->call_workflow('BILL_REOPEN',$this,$user,$langs,$conf);
$result=$interface->run_triggers('BILL_REOPEN',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers
}
@ -700,9 +700,9 @@ class Commande extends CommonObject
}
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/workflow/class/interfaces.class.php");
include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->call_workflow('ORDER_CREATE',$this,$user,$langs,$conf);
$result=$interface->run_triggers('ORDER_CREATE',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers
@ -1893,9 +1893,9 @@ class Commande extends CommonObject
$this->update_price();
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/workflow/class/interfaces.class.php");
include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->call_workflow('LINEORDER_UPDATE',$this,$user,$langs,$conf);
$result=$interface->run_triggers('LINEORDER_UPDATE',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers
@ -1987,9 +1987,9 @@ class Commande extends CommonObject
if ($err == 0)
{
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/workflow/class/interfaces.class.php");
include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->call_workflow('ORDER_DELETE',$this,$user,$langs,$conf);
$result=$interface->run_triggers('ORDER_DELETE',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers
@ -2484,9 +2484,9 @@ class OrderLine
if ($resql)
{
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/workflow/class/interfaces.class.php");
include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->call_workflow('LINEORDER_DELETE',$this,$user,$langs,$conf);
$result=$interface->run_triggers('LINEORDER_DELETE',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers
@ -2583,9 +2583,9 @@ class OrderLine
if (! $notrigger)
{
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/workflow/class/interfaces.class.php");
include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->call_workflow('LINEORDER_INSERT',$this,$user,$langs,$conf);
$result=$interface->run_triggers('LINEORDER_INSERT',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers
}

View File

@ -944,9 +944,9 @@ if ($_POST['action'] == 'send' && ! $_POST['addfile'] && ! $_POST['removedfile']
$commande->orderrowid=$commande->id;
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/workflow/class/interfaces.class.php");
include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php");
$interface=new Interfaces($db);
$result=$interface->call_workflow('ORDER_SENTBYMAIL',$commande,$user,$langs,$conf);
$result=$interface->run_triggers('ORDER_SENTBYMAIL',$commande,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers

View File

@ -103,9 +103,9 @@ class BankCateg // extends CommonObject
// want this action call a trigger.
//// Call triggers
//include_once(DOL_DOCUMENT_ROOT . "/workflow/class/interfaces.class.php");
//include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php");
//$interface=new Interfaces($this->db);
//$result=$interface->call_workflow('MYOBJECT_CREATE',$this,$user,$langs,$conf);
//$result=$interface->run_triggers('MYOBJECT_CREATE',$this,$user,$langs,$conf);
//if ($result < 0) { $error++; $this->errors=$interface->errors; }
//// End call triggers
}
@ -207,9 +207,9 @@ class BankCateg // extends CommonObject
// want this action call a trigger.
//// Call triggers
//include_once(DOL_DOCUMENT_ROOT . "/workflow/class/interfaces.class.php");
//include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php");
//$interface=new Interfaces($this->db);
//$result=$interface->call_workflow('MYOBJECT_MODIFY',$this,$user,$langs,$conf);
//$result=$interface->run_triggers('MYOBJECT_MODIFY',$this,$user,$langs,$conf);
//if ($result < 0) { $error++; $this->errors=$interface->errors; }
//// End call triggers
}
@ -263,9 +263,9 @@ class BankCateg // extends CommonObject
// want this action call a trigger.
//// Call triggers
//include_once(DOL_DOCUMENT_ROOT . "/workflow/class/interfaces.class.php");
//include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php");
//$interface=new Interfaces($this->db);
//$result=$interface->call_workflow('MYOBJECT_DELETE',$this,$user,$langs,$conf);
//$result=$interface->run_triggers('MYOBJECT_DELETE',$this,$user,$langs,$conf);
//if ($result < 0) { $error++; $this->errors=$interface->errors; }
//// End call triggers
}

View File

@ -584,9 +584,9 @@ class PaiementCharge extends CommonObject
// want this action call a trigger.
//// Call triggers
//include_once(DOL_DOCUMENT_ROOT . "/workflow/class/interfaces.class.php");
//include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php");
//$interface=new Interfaces($this->db);
//$result=$interface->call_workflow('MYOBJECT_MODIFY',$this,$user,$langs,$conf);
//$result=$interface->run_triggers('MYOBJECT_MODIFY',$this,$user,$langs,$conf);
//if ($result < 0) { $error++; $this->errors=$interface->errors; }
//// End call triggers
}
@ -639,9 +639,9 @@ class PaiementCharge extends CommonObject
// want this action call a trigger.
//// Call triggers
//include_once(DOL_DOCUMENT_ROOT . "/workflow/class/interfaces.class.php");
//include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php");
//$interface=new Interfaces($this->db);
//$result=$interface->call_workflow('MYOBJECT_DELETE',$this,$user,$langs,$conf);
//$result=$interface->run_triggers('MYOBJECT_DELETE',$this,$user,$langs,$conf);
//if ($result < 0) { $error++; $this->errors=$interface->errors; }
//// End call triggers
}

View File

@ -1365,9 +1365,9 @@ if (($_POST['action'] == 'send' || $_POST['action'] == 'relance') && ! $_POST['a
$fac->facid=$fac->id;
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/workflow/class/interfaces.class.php");
include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php");
$interface=new Interfaces($db);
$result=$interface->call_workflow('BILL_SENTBYMAIL',$fac,$user,$langs,$conf);
$result=$interface->run_triggers('BILL_SENTBYMAIL',$fac,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers

View File

@ -340,9 +340,9 @@ class Facture extends CommonObject
if ($resql)
{
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/workflow/class/interfaces.class.php");
include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->call_workflow('BILL_CREATE',$this,$user,$langs,$conf);
$result=$interface->run_triggers('BILL_CREATE',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers
@ -823,9 +823,9 @@ class Facture extends CommonObject
// want this action call a trigger.
//// Call triggers
//include_once(DOL_DOCUMENT_ROOT . "/workflow/class/interfaces.class.php");
//include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php");
//$interface=new Interfaces($this->db);
//$result=$interface->call_workflow('MYOBJECT_MODIFY',$this,$user,$langs,$conf);
//$result=$interface->run_triggers('MYOBJECT_MODIFY',$this,$user,$langs,$conf);
//if ($result < 0) { $error++; $this->errors=$interface->errors; }
//// End call triggers
}
@ -1014,9 +1014,9 @@ class Facture extends CommonObject
if ($resql)
{
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/workflow/class/interfaces.class.php");
include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->call_workflow('BILL_DELETE',$this,$user,$langs,$conf);
$result=$interface->run_triggers('BILL_DELETE',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers
@ -1140,9 +1140,9 @@ class Facture extends CommonObject
$this->use_webcal=($conf->global->PHPWEBCALENDAR_BILLSTATUS=='always'?1:0);
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/workflow/class/interfaces.class.php");
include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->call_workflow('BILL_PAYED',$this,$user,$langs,$conf);
$result=$interface->run_triggers('BILL_PAYED',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers
}
@ -1196,9 +1196,9 @@ class Facture extends CommonObject
$this->use_webcal=($conf->global->PHPWEBCALENDAR_BILLSTATUS=='always'?1:0);
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/workflow/class/interfaces.class.php");
include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->call_workflow('BILL_UNPAYED',$this,$user,$langs,$conf);
$result=$interface->run_triggers('BILL_UNPAYED',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers
}
@ -1258,9 +1258,9 @@ class Facture extends CommonObject
$this->use_webcal=($conf->global->PHPWEBCALENDAR_BILLSTATUS=='always'?1:0);
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/workflow/class/interfaces.class.php");
include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->call_workflow('BILL_CANCEL',$this,$user,$langs,$conf);
$result=$interface->run_triggers('BILL_CANCEL',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers
@ -1466,9 +1466,9 @@ class Facture extends CommonObject
if (! $error)
{
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/workflow/class/interfaces.class.php");
include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->call_workflow('BILL_VALIDATE',$this,$user,$langs,$conf);
$result=$interface->run_triggers('BILL_VALIDATE',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers
}
@ -1839,9 +1839,9 @@ class Facture extends CommonObject
$result=$this->update_price();
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/workflow/class/interfaces.class.php");
include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php");
$interface=new Interfaces($this->db);
$result = $interface->call_workflow('LINEBILL_DELETE',$this,$user,$langs,$conf);
$result = $interface->run_triggers('LINEBILL_DELETE',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers
@ -3097,9 +3097,9 @@ class FactureLigne
if (! $notrigger)
{
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/workflow/class/interfaces.class.php");
include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php");
$interface=new Interfaces($this->db);
$result = $interface->call_workflow('LINEBILL_INSERT',$this,$user,$langs,$conf);
$result = $interface->run_triggers('LINEBILL_INSERT',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers
}
@ -3166,9 +3166,9 @@ class FactureLigne
if (! $notrigger)
{
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/workflow/class/interfaces.class.php");
include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php");
$interface=new Interfaces($this->db);
$result = $interface->call_workflow('LINEBILL_UPDATE',$this,$user,$langs,$conf);
$result = $interface->run_triggers('LINEBILL_UPDATE',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers
}

View File

@ -125,9 +125,9 @@ class Tva extends CommonObject
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."tva");
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/workflow/class/interfaces.class.php");
include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->call_workflow('MYOBJECT_CREATE',$this,$user,$langs,$conf);
$result=$interface->run_triggers('MYOBJECT_CREATE',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers
@ -193,9 +193,9 @@ class Tva extends CommonObject
if (! $notrigger)
{
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/workflow/class/interfaces.class.php");
include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->call_workflow('MYOBJECT_MODIFY',$this,$user,$langs,$conf);
$result=$interface->run_triggers('MYOBJECT_MODIFY',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers
}
@ -291,9 +291,9 @@ class Tva extends CommonObject
}
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/workflow/class/interfaces.class.php");
include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->call_workflow('MYOBJECT_DELETE',$this,$user,$langs,$conf);
$result=$interface->run_triggers('MYOBJECT_DELETE',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers

View File

@ -120,9 +120,9 @@ class Contact extends CommonObject
}
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/workflow/class/interfaces.class.php");
include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->call_workflow('CONTACT_CREATE',$this,$user,$langs,$conf);
$result=$interface->run_triggers('CONTACT_CREATE',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers
@ -193,9 +193,9 @@ class Contact extends CommonObject
if (! $error && ! $notrigger)
{
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/workflow/class/interfaces.class.php");
include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->call_workflow('CONTACT_MODIFY',$this,$user,$langs,$conf);
$result=$interface->run_triggers('CONTACT_MODIFY',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers
}
@ -628,9 +628,9 @@ class Contact extends CommonObject
if (! $error && ! $notrigger)
{
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/workflow/class/interfaces.class.php");
include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->call_workflow('CONTACT_DELETE',$this,$user,$langs,$conf);
$result=$interface->run_triggers('CONTACT_DELETE',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers

View File

@ -116,9 +116,9 @@ class Contrat extends CommonObject
if ($resql)
{
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/workflow/class/interfaces.class.php");
include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->call_workflow('CONTRACT_SERVICE_ACTIVATE',$this,$user,$langs,$conf);
$result=$interface->run_triggers('CONTRACT_SERVICE_ACTIVATE',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers
@ -161,9 +161,9 @@ class Contrat extends CommonObject
if ($resql)
{
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/workflow/class/interfaces.class.php");
include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->call_workflow('CONTRACT_SERVICE_CLOSE',$this,$user,$langs,$conf);
$result=$interface->run_triggers('CONTRACT_SERVICE_CLOSE',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers
@ -247,9 +247,9 @@ class Contrat extends CommonObject
$this->use_webcal=($conf->global->PHPWEBCALENDAR_CONTRACTSTATUS=='always'?1:0);
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/workflow/class/interfaces.class.php");
include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->call_workflow('CONTRACT_VALIDATE',$this,$user,$langs,$conf);
$result=$interface->run_triggers('CONTRACT_VALIDATE',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers
@ -570,9 +570,9 @@ class Contrat extends CommonObject
if (! $error)
{
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/workflow/class/interfaces.class.php");
include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->call_workflow('CONTRACT_CREATE',$this,$user,$langs,$conf);
$result=$interface->run_triggers('CONTRACT_CREATE',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers
@ -747,9 +747,9 @@ class Contrat extends CommonObject
if (! $error)
{
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/workflow/class/interfaces.class.php");
include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->call_workflow('CONTRACT_DELETE',$this,$user,$langs,$conf);
$result=$interface->run_triggers('CONTRACT_DELETE',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers
@ -994,9 +994,9 @@ class Contrat extends CommonObject
}
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/workflow/class/interfaces.class.php");
include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->call_workflow('CONTRACTLINE_DELETE',$this,$user,$langs,$conf);
$result=$interface->run_triggers('CONTRACTLINE_DELETE',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers
@ -1699,9 +1699,9 @@ class ContratLigne
if (! $notrigger)
{
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/workflow/class/interfaces.class.php");
include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->call_workflow('MYOBJECT_MODIFY',$this,$user,$langs,$conf);
$result=$interface->run_triggers('MYOBJECT_MODIFY',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers
}

View File

@ -19,21 +19,19 @@
*/
/**
* \file htdocs/workflow/class/interfaces.class.php
* \file htdocs/core/interfaces.class.php
* \ingroup workflow
* \brief Fichier de la classe de gestion des triggers
* \version $Id$
*/
require_once(DOL_DOCUMENT_ROOT ."/workflow/class/workflow.class.php");
/**
* \class Interfaces
* \brief Classe de la gestion des triggers
*/
class Interfaces extends Workflow
class Interfaces
{
var $dir; // Directory with all core and external triggers files
var $errors = array(); // Array for errors

View File

@ -147,9 +147,9 @@ class EcmDirectory // extends CommonObject
$result=create_exdir($dir);
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/workflow/class/interfaces.class.php");
include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->call_workflow('MYECMDIR_CREATE',$this,$user,$langs,$conf);
$result=$interface->run_triggers('MYECMDIR_CREATE',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers
@ -215,9 +215,9 @@ class EcmDirectory // extends CommonObject
if (! $error && ! $notrigger)
{
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/workflow/class/interfaces.class.php");
include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->call_workflow('MYECMDIR_MODIFY',$this,$user,$langs,$conf);
$result=$interface->run_triggers('MYECMDIR_MODIFY',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers
}
@ -361,9 +361,9 @@ class EcmDirectory // extends CommonObject
if (! $error)
{
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/workflow/class/interfaces.class.php");
include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->call_workflow('MYECMDIR_DELETE',$this,$user,$langs,$conf);
$result=$interface->run_triggers('MYECMDIR_DELETE',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers
}

View File

@ -447,9 +447,9 @@ class Expedition extends CommonObject
if (! $error)
{
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/workflow/class/interfaces.class.php");
include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->call_workflow('ORDER_SHIPPING',$this,$user,$langs,$conf);
$result=$interface->run_triggers('ORDER_SHIPPING',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers
}

View File

@ -401,9 +401,9 @@ class Export
// want this action call a trigger.
//// Call triggers
//include_once(DOL_DOCUMENT_ROOT . "/workflow/class/interfaces.class.php");
//include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php");
//$interface=new Interfaces($this->db);
//$result=$interface->call_workflow('MYOBJECT_DELETE',$this,$user,$langs,$conf);
//$result=$interface->run_triggers('MYOBJECT_DELETE',$this,$user,$langs,$conf);
//if ($result < 0) { $error++; $this->errors=$interface->errors; }
//// End call triggers
}

View File

@ -287,9 +287,9 @@ class Fichinter extends CommonObject
if ($resql)
{
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/workflow/class/interfaces.class.php");
include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->call_workflow('FICHEINTER_VALIDATE',$this,$user,$langs,$conf);
$result=$interface->run_triggers('FICHEINTER_VALIDATE',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers

View File

@ -175,9 +175,9 @@ class PaiementFourn
if (! $error)
{
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/workflow/class/interfaces.class.php");
include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->call_workflow('PAYMENT_SUPPLIER_CREATE',$this,$user,$langs,$conf);
$result=$interface->run_triggers('PAYMENT_SUPPLIER_CREATE',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers
}

View File

@ -303,9 +303,9 @@ class CommandeFournisseur extends Commande
if (! $error)
{
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/workflow/class/interfaces.class.php");
include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->call_workflow('ORDER_SUPPLIER_VALIDATE',$this,$user,$langs,$conf);
$result=$interface->run_triggers('ORDER_SUPPLIER_VALIDATE',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers
}
@ -357,9 +357,9 @@ class CommandeFournisseur extends Commande
$this->log($user, $statut, time());
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/workflow/class/interfaces.class.php");
include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->call_workflow('ORDER_SUPPLIER_VALIDATE',$this,$user,$langs,$conf);
$result=$interface->run_triggers('ORDER_SUPPLIER_VALIDATE',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers
@ -585,9 +585,9 @@ class CommandeFournisseur extends Commande
if ($error == 0)
{
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/workflow/class/interfaces.class.php");
include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->call_workflow('ORDER_SUPPLIER_APPROVE',$this,$user,$langs,$conf);
$result=$interface->run_triggers('ORDER_SUPPLIER_APPROVE',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers
}
@ -643,9 +643,9 @@ class CommandeFournisseur extends Commande
if ($error == 0)
{
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/workflow/class/interfaces.class.php");
include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->call_workflow('ORDER_SUPPLIER_REFUSE',$this,$user,$langs,$conf);
$result=$interface->run_triggers('ORDER_SUPPLIER_REFUSE',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers
}
@ -745,9 +745,9 @@ class CommandeFournisseur extends Commande
$this->log($user, 0, time());
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/workflow/class/interfaces.class.php");
include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->call_workflow('ORDER_SUPPLIER_CREATE',$this,$user,$langs,$conf);
$result=$interface->run_triggers('ORDER_SUPPLIER_CREATE',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers
@ -1057,9 +1057,9 @@ class CommandeFournisseur extends Commande
if ($err == 0)
{
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/workflow/class/interfaces.class.php");
include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->call_workflow('ORDER_SUPPLIER_DELETE',$this,$user,$langs,$conf);
$result=$interface->run_triggers('ORDER_SUPPLIER_DELETE',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers

View File

@ -465,9 +465,9 @@ class FactureFournisseur extends Facture
$this->use_webcal=($conf->global->PHPWEBCALENDAR_BILLSTATUS=='always'?1:0);
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/workflow/class/interfaces.class.php");
include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->call_workflow('BILL_SUPPLIER_PAYED',$this,$user,$langs,$conf);
$result=$interface->run_triggers('BILL_SUPPLIER_PAYED',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers
}
@ -517,9 +517,9 @@ class FactureFournisseur extends Facture
$this->use_webcal=($conf->global->PHPWEBCALENDAR_BILLSTATUS=='always'?1:0);
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/workflow/class/interfaces.class.php");
include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->call_workflow('BILL_SUPPLIER_UNPAYED',$this,$user,$langs,$conf);
$result=$interface->run_triggers('BILL_SUPPLIER_UNPAYED',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers
}
@ -591,9 +591,9 @@ class FactureFournisseur extends Facture
if ($error == 0)
{
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/workflow/class/interfaces.class.php");
include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->call_workflow('BILL_SUPPLIER_VALIDATE',$this,$user,$langs,$conf);
$result=$interface->run_triggers('BILL_SUPPLIER_VALIDATE',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers
}

View File

@ -313,9 +313,9 @@ class Import
// want this action call a trigger.
//// Call triggers
//include_once(DOL_DOCUMENT_ROOT . "/workflow/class/interfaces.class.php");
//include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php");
//$interface=new Interfaces($this->db);
//$result=$interface->call_workflow('MYOBJECT_DELETE',$this,$user,$langs,$conf);
//$result=$interface->run_triggers('MYOBJECT_DELETE',$this,$user,$langs,$conf);
//if ($result < 0) { $error++; $this->errors=$interface->errors; }
//// End call triggers
}

View File

@ -328,9 +328,9 @@ if (! defined('NOLOGIN'))
$test=false;
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/workflow/class/interfaces.class.php");
include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php");
$interface=new Interfaces($db);
$result=$interface->call_workflow('USER_LOGIN_FAILED',$user,$user,$langs,$conf,$_POST["entity"]);
$result=$interface->run_triggers('USER_LOGIN_FAILED',$user,$user,$langs,$conf,$_POST["entity"]);
if ($result < 0) { $error++; }
// Fin appel triggers
}
@ -386,9 +386,9 @@ if (! defined('NOLOGIN'))
$_SESSION["dol_loginmesg"]=$langs->trans("ErrorBadLoginPassword");
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/workflow/class/interfaces.class.php");
include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php");
$interface=new Interfaces($db);
$result=$interface->call_workflow('USER_LOGIN_FAILED',$user,$user,$langs,$conf,$_POST["entity"]);
$result=$interface->run_triggers('USER_LOGIN_FAILED',$user,$user,$langs,$conf,$_POST["entity"]);
if ($result < 0) { $error++; }
// Fin appel triggers
}
@ -426,9 +426,9 @@ if (! defined('NOLOGIN'))
}
// Call triggers
include_once(DOL_DOCUMENT_ROOT . "/workflow/class/interfaces.class.php");
include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php");
$interface=new Interfaces($db);
$result=$interface->call_workflow('USER_LOGIN_FAILED',$user,$user,$langs,$conf,$_POST["entity"]);
$result=$interface->run_triggers('USER_LOGIN_FAILED',$user,$user,$langs,$conf,$_POST["entity"]);
if ($result < 0) { $error++; }
// End call triggers
@ -466,9 +466,9 @@ if (! defined('NOLOGIN'))
}
// Call triggers
include_once(DOL_DOCUMENT_ROOT . "/workflow/class/interfaces.class.php");
include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php");
$interface=new Interfaces($db);
$result=$interface->call_workflow('USER_LOGIN_FAILED',$user,$user,$langs,$conf,(isset($_POST["entity"])?$_POST["entity"]:0));
$result=$interface->run_triggers('USER_LOGIN_FAILED',$user,$user,$langs,$conf,(isset($_POST["entity"])?$_POST["entity"]:0));
if ($result < 0) { $error++; }
// End call triggers
@ -494,9 +494,9 @@ if (! defined('NOLOGIN'))
$user->update_last_login_date();
// Call triggers
include_once(DOL_DOCUMENT_ROOT . "/workflow/class/interfaces.class.php");
include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php");
$interface=new Interfaces($db);
$result=$interface->call_workflow('USER_LOGIN',$user,$user,$langs,$conf,$_POST["entity"]);
$result=$interface->run_triggers('USER_LOGIN',$user,$user,$langs,$conf,$_POST["entity"]);
if ($result < 0) { $error++; }
// End call triggers

View File

@ -0,0 +1,518 @@
<?php
/* Copyright (C) 2010 Regis Houssin <regis@dolibarr.fr>
*
* 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 2 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, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/**
* \file htdocs/milestone/milestone.class.php
* \ingroup milestone
* \brief Fichier de la classe des jalons
* \version $Id$
*/
/**
* \class Milestone
* \brief Classe permettant la gestion des jalons
*/
class Milestone
{
var $error;
var $db;
var $id;
var $label;
var $description;
var $statut;
var $fk_element;
var $elementtype;
var $cats=array(); // Tableau en memoire des categories
/**
* Constructor
* @param DB acces base de donnees
* @param id milestone id
*/
function Milestone($DB)
{
$this->db = $DB;
}
/**
* Charge le jalon
* @param id id du jalon a charger
*/
function fetch($id)
{
$sql = "SELECT rowid, label, description, visible, type";
$sql.= " FROM ".MAIN_DB_PREFIX."milestone";
$sql.= " WHERE rowid = ".$id;
dol_syslog("Milestone::fetch sql=".$sql);
$resql = $this->db->query ($sql);
if ($resql)
{
$res = $this->db->fetch_array($resql);
$this->id = $res['rowid'];
$this->label = $res['label'];
$this->description = $res['description'];
$this->type = $res['type'];
$this->db->free($resql);
}
else
{
dol_print_error ($this->db);
return -1;
}
}
/**
* Ajoute le jalon dans la base de donnees
* @return int -1 : erreur SQL
* -2 : nouvel ID inconnu
* -3 : jalon invalide
*/
function create($user)
{
global $conf,$langs;
$langs->load('milestone');
// Clean parameters
$this->label=trim($this->label);
$this->description=trim($this->description);
if ($this->already_exists())
{
$this->error = $langs->trans("ImpossibleAddMilestone");
$this->error.=" : ".$langs->trans("MilestoneAlreadyExists");
return -1;
}
$sql = "INSERT INTO ".MAIN_DB_PREFIX."milestone (";
$sql.= "label";
$sql.= ", description";
$sql.= ", type";
$sql.= ") VALUES (";
$sql.= "'".addslashes($this->label)."'";
$sql.= ", '".addslashes($this->description)."'";
$sql.= ", ".$this->type;
$sql.= ")";
$res = $this->db->query ($sql);
if ($res)
{
$id = $this->db->last_insert_id (MAIN_DB_PREFIX."milestone");
if ($id > 0)
{
$this->id = $id;
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->run_triggers('MILESTONE_CREATE',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers
return $id;
}
else
{
return -2;
}
}
else
{
dol_print_error ($this->db);
return -1;
}
}
/**
* Update milestone
* @return int 1 : OK
* -1 : SQL error
* -2 : invalid milestone
*/
function update($user)
{
global $conf;
// Clean parameters
$this->label=trim($this->label);
$this->description=trim($this->description);
$this->db->begin();
$sql = "UPDATE ".MAIN_DB_PREFIX."milestone SET";
$sql.= " label = '".addslashes($this->label)."'";
$sql.= ", description = '".addslashes($this->description)."'";
$sql.= " WHERE rowid = ".$this->id;
dol_syslog("Milestone::update sql=".$sql);
if ($this->db->query($sql))
{
$this->db->commit();
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->run_triggers('MILESTONE_MODIFY',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers
return 1;
}
else
{
$this->db->rollback();
dol_print_error($this->db);
return -1;
}
}
/**
* Delete milestone
*/
function remove()
{
$sql = "DELETE FROM ".MAIN_DB_PREFIX."element_milestone";
$sql.= " WHERE fk_categorie = ".$this->id;
if (!$this->db->query($sql))
{
dol_print_error($this->db);
return -1;
}
$sql = "DELETE FROM ".MAIN_DB_PREFIX."milestone";
$sql.= " WHERE rowid = ".$this->id;
if (!$this->db->query($sql))
{
dol_print_error($this->db);
return -1;
}
else
{
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->run_triggers('MILESTONE_DELETE',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers
return 1;
}
}
/**
* \brief Link an object to the category
* \param obj Object to link to category
* \param type Type of category
* \return int 1 : OK, -1 : erreur SQL, -2 : id non renseign, -3 : Already linked
*/
function add_type($obj,$type)
{
if ($this->id == -1)
{
return -2;
}
$sql = "INSERT INTO ".MAIN_DB_PREFIX."categorie_".$type." (fk_categorie, fk_".($type=='fournisseur'?'societe':$type).")";
$sql .= " VALUES (".$this->id.", ".$obj->id.")";
if ($this->db->query($sql))
{
return 1;
}
else
{
if ($this->db->lasterrno() == 'DB_ERROR_RECORD_ALREADY_EXISTS')
{
$this->error=$this->db->lasterrno();
return -3;
}
else
{
$this->error=$this->db->error().' sql='.$sql;
}
return -1;
}
}
/**
* Suppresion d'un produit de la categorie
* @param $prod est un objet de type produit
* retour : 1 : OK
* -1 : erreur SQL
*/
function del_type($obj,$type)
{
$sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_".$type;
$sql .= " WHERE fk_categorie = ".$this->id;
$sql .= " AND fk_".($type=='fournisseur'?'societe':$type)." = ".$obj->id;
if ($this->db->query($sql))
{
return 1;
}
else
{
$this->error=$this->db->error().' sql='.$sql;
return -1;
}
}
/**
* \brief Return list of contents of a category
* \param field Field name for select in table. Full field name will be fk_field.
* \param class PHP Class of object to store entity
* \param table Table name for select in table. Full table name will be PREFIX_categorie_table.
*/
function get_type($field,$classname,$table='')
{
$objs = array();
// Clean parameters
if (empty($table)) $table=$field;
$sql = "SELECT fk_".$field." FROM ".MAIN_DB_PREFIX."categorie_".$table;
$sql.= " WHERE fk_categorie = ".$this->id;
dol_syslog("Categorie::get_type sql=".$sql);
$resql = $this->db->query($sql);
if ($resql)
{
while ($rec = $this->db->fetch_array($resql))
{
$obj = new $classname($this->db);
$obj->fetch($rec['fk_'.$field]);
$objs[] = $obj;
}
return $objs;
}
else
{
$this->error=$this->db->error().' sql='.$sql;
dol_syslog("Categorie::get_type ".$this->error, LOG_ERR);
return -1;
}
}
/**
* retourne la description d'une categorie
*/
function get_desc ($cate)
{
$sql = "SELECT description FROM ".MAIN_DB_PREFIX."categorie ";
$sql .= "WHERE rowid = '".$cate."'";
$res = $this->db->query ($sql);
$n = $this->db->fetch_array ($res);
return ($n[0]);
}
/**
* \brief Retourne toutes les categories
* \return array Tableau d'objet Categorie
*/
function get_all_categories ()
{
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."categorie";
$res = $this->db->query ($sql);
if ($res)
{
$cats = array ();
while ($record = $this->db->fetch_array ($res))
{
$cat = new Categorie ($this->db, $record['rowid']);
$cats[$record['rowid']] = $cat;
}
return $cats;
}
else
{
dol_print_error ($this->db);
return -1;
}
}
/**
* \brief Retourne le nombre total de categories
* \return int Nombre de categories
*/
function get_nb_categories ()
{
$sql = "SELECT count(rowid)";
$sql.= " FROM ".MAIN_DB_PREFIX."categorie";
$res = $this->db->query ($sql);
if ($res)
{
$res = $this->db->fetch_array($res);
return $res[0];
}
else
{
dol_print_error ($this->db);
return -1;
}
}
/**
* \brief Check if no category with same label already exists
* \return boolean 1 if already exist, 0 otherwise, -1 if error
*/
function already_exists()
{
$sql = "SELECT count(c.rowid)";
$sql.= " FROM ".MAIN_DB_PREFIX."categorie as c, ".MAIN_DB_PREFIX."categorie_association as ca";
$sql.= " WHERE c.label = '".addslashes($this -> label)."' AND type=".$this->type;
dol_syslog("Categorie::already_exists sql=".$sql);
$res = $this->db->query($sql);
if ($res)
{
$obj = $this->db->fetch_array($res);
if($obj[0] > 0) return 1;
else return 0;
}
else
{
dol_print_error ($this->db);
return -1;
}
}
/**
* Return list of categories linked to element of type $type with id $typeid
* @param id Id of element
* @param typeid Type id of link (0,1,2,3...)
* @return array List of category objects
*/
function containing($id,$typeid)
{
$cats = array ();
$table=''; $type='';
if ($typeid == 0) { $table='product'; $type='product'; }
if ($typeid == 1) { $table='societe'; $type='fournisseur'; }
if ($typeid == 2) { $table='societe'; $type='societe'; }
if ($typeid == 3) { $table='member'; $type='member'; }
$sql = "SELECT ct.fk_categorie";
$sql.= " FROM ".MAIN_DB_PREFIX."categorie_".$type." as ct";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie as c ON ct.fk_categorie = c.rowid";
$sql.= " WHERE ct.fk_".$table." = ".$id." AND c.type = ".$typeid;
$res = $this->db->query ($sql);
if ($res)
{
while ($cat = $this->db->fetch_array ($res))
{
$cats[] = new Categorie ($this->db, $cat['fk_categorie']);
}
return $cats;
}
else
{
dol_print_error ($this->db);
return -1;
}
}
/**
* \brief Retourne les categories dont l'id ou le nom correspond
* ajoute des wildcards au nom sauf si $exact = true
*/
function rechercher($id, $nom, $type, $exact = false)
{
$cats = array ();
// Generation requete recherche
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."categorie ";
$sql .= "WHERE type = ".$type." ";
if ($nom)
{
if (! $exact)
{
$nom = '%'.str_replace ('*', '%', $nom).'%';
}
$sql.= "AND label LIKE '".$nom."'";
}
if ($id)
{
$sql.="AND rowid = '".$id."'";
}
$res = $this->db->query ($sql);
if ($res)
{
while ($id = $this->db->fetch_array ($res))
{
$cats[] = new Categorie ($this->db, $id['rowid']);
}
return $cats;
}
else
{
$this->error=$this->db->error().' sql='.$sql;
dol_syslog("Categorie::rechercher ".$this->error, LOG_ERR);
return -1;
}
}
/**
* \brief Return name and link of category (with picto)
* \param withpicto 0=Pas de picto, 1=Inclut le picto dans le lien, 2=Picto seul
* \param option Sur quoi pointe le lien ('', 'xyz')
* \param maxlength Max length of text
* \return string Chaine avec URL
*/
function getNomUrl($withpicto=0,$option='',$maxlength=0)
{
global $langs;
$result='';
$lien = '<a href="'.DOL_URL_ROOT.'/categories/viewcat.php?id='.$this->id.'&type='.$this->type.'">';
$label=$langs->trans("ShowCategory").': '.$this->label;
$lienfin='</a>';
$picto='category';
if ($withpicto) $result.=($lien.img_object($label,$picto).$lienfin);
if ($withpicto && $withpicto != 2) $result.=' ';
if ($withpicto != 2) $result.=$lien.dol_trunc($this->ref,$maxlength).$lienfin;
return $result;
}
}
?>

View File

@ -180,9 +180,9 @@ class Paiement
if (! $error)
{
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/workflow/class/interfaces.class.php");
include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->call_workflow('PAYMENT_CUSTOMER_CREATE',$this,$user,$langs,$conf);
$result=$interface->run_triggers('PAYMENT_CUSTOMER_CREATE',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers
}

View File

@ -557,9 +557,9 @@ class Product extends CommonObject
}
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/workflow/class/interfaces.class.php");
include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->call_workflow('PRODUCT_DELETE',$this,$user,$langs,$conf);
$result=$interface->run_triggers('PRODUCT_DELETE',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers

View File

@ -118,9 +118,9 @@ class Project extends CommonObject
if (! $notrigger)
{
// Call triggers
include_once(DOL_DOCUMENT_ROOT . "/workflow/class/interfaces.class.php");
include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->call_workflow('PROJECT_CREATE',$this,$user,$langs,$conf);
$result=$interface->run_triggers('PROJECT_CREATE',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// End call triggers
}
@ -168,9 +168,9 @@ class Project extends CommonObject
if (! $notrigger)
{
// Call triggers
include_once(DOL_DOCUMENT_ROOT . "/workflow/class/interfaces.class.php");
include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->call_workflow('PROJECT_MODIFY',$this,$user,$langs,$conf);
$result=$interface->run_triggers('PROJECT_MODIFY',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// End call triggers
}
@ -393,9 +393,9 @@ class Project extends CommonObject
if (! $notrigger)
{
// Call triggers
include_once(DOL_DOCUMENT_ROOT . "/workflow/class/interfaces.class.php");
include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->call_workflow('PROJECT_DELETE',$this,$user,$langs,$conf);
$result=$interface->run_triggers('PROJECT_DELETE',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// End call triggers
}
@ -436,9 +436,9 @@ class Project extends CommonObject
if ($resql)
{
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/workflow/class/interfaces.class.php");
include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->call_workflow('PROJECT_VALIDATE',$this,$user,$langs,$conf);
$result=$interface->run_triggers('PROJECT_VALIDATE',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers
@ -489,9 +489,9 @@ class Project extends CommonObject
if ($resql)
{
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/workflow/class/interfaces.class.php");
include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->call_workflow('PROJECT_CLOSE',$this,$user,$langs,$conf);
$result=$interface->run_triggers('PROJECT_CLOSE',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers

View File

@ -133,9 +133,9 @@ class Task extends CommonObject
if (! $notrigger)
{
// Call triggers
include_once(DOL_DOCUMENT_ROOT . "/workflow/class/interfaces.class.php");
include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->call_workflow('TASK_CREATE',$this,$user,$langs,$conf);
$result=$interface->run_triggers('TASK_CREATE',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// End call triggers
}
@ -272,9 +272,9 @@ class Task extends CommonObject
if (! $notrigger)
{
// Call triggers
include_once(DOL_DOCUMENT_ROOT . "/workflow/class/interfaces.class.php");
include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->call_workflow('TASK_MODIFY',$this,$user,$langs,$conf);
$result=$interface->run_triggers('TASK_MODIFY',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// End call triggers
}
@ -333,9 +333,9 @@ class Task extends CommonObject
if (! $notrigger)
{
// Call triggers
include_once(DOL_DOCUMENT_ROOT . "/workflow/class/interfaces.class.php");
include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->call_workflow('TASK_DELETE',$this,$user,$langs,$conf);
$result=$interface->run_triggers('TASK_DELETE',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// End call triggers
}
@ -627,9 +627,9 @@ class Task extends CommonObject
if (! $notrigger)
{
// Call triggers
include_once(DOL_DOCUMENT_ROOT . "/workflow/class/interfaces.class.php");
include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->call_workflow('TASK_TIMESPENT_CREATE',$this,$user,$langs,$conf);
$result=$interface->run_triggers('TASK_TIMESPENT_CREATE',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// End call triggers
}
@ -731,9 +731,9 @@ class Task extends CommonObject
if (! $notrigger)
{
// Call triggers
include_once(DOL_DOCUMENT_ROOT . "/workflow/class/interfaces.class.php");
include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->call_workflow('TASK_TIMESPENT_MODIFY',$this,$user,$langs,$conf);
$result=$interface->run_triggers('TASK_TIMESPENT_MODIFY',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// End call triggers
}
@ -792,9 +792,9 @@ class Task extends CommonObject
if (! $notrigger)
{
// Call triggers
include_once(DOL_DOCUMENT_ROOT . "/workflow/class/interfaces.class.php");
include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->call_workflow('TASK_TIMESPENT_DELETE',$this,$user,$langs,$conf);
$result=$interface->run_triggers('TASK_TIMESPENT_DELETE',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// End call triggers
}

View File

@ -213,9 +213,9 @@ class Societe extends CommonObject
$this->use_webcal=($conf->global->PHPWEBCALENDAR_COMPANYCREATE=='always'?1:0);
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/workflow/class/interfaces.class.php");
include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->call_workflow('COMPANY_CREATE',$this,$user,$langs,$conf);
$result=$interface->run_triggers('COMPANY_CREATE',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers
@ -489,9 +489,9 @@ class Societe extends CommonObject
if ($call_trigger)
{
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/workflow/class/interfaces.class.php");
include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->call_workflow('COMPANY_MODIFY',$this,$user,$langs,$conf);
$result=$interface->run_triggers('COMPANY_MODIFY',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers
}
@ -889,9 +889,9 @@ class Societe extends CommonObject
if ($sqr == 4)
{
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/workflow/class/interfaces.class.php");
include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->call_workflow('COMPANY_DELETE',$this,$user,$langs,$conf);
$result=$interface->run_triggers('COMPANY_DELETE',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers

View File

@ -465,9 +465,9 @@ class UserGroup extends CommonObject
if ($result)
{
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/workflow/class/interfaces.class.php");
include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->call_workflow('USER_DELETE',$this,$user,$langs,$conf);
$result=$interface->run_triggers('USER_DELETE',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers
@ -502,9 +502,9 @@ class UserGroup extends CommonObject
if ($this->update(1) < 0) return -2;
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/workflow/class/interfaces.class.php");
include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->call_workflow('GROUP_CREATE',$this,$user,$langs,$conf);
$result=$interface->run_triggers('GROUP_CREATE',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers
@ -541,9 +541,9 @@ class UserGroup extends CommonObject
if (!$error && ! $notrigger)
{
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/workflow/class/interfaces.class.php");
include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->call_workflow('GROUP_MODIFY',$this,$user,$langs,$conf);
$result=$interface->run_triggers('GROUP_MODIFY',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers
}

View File

@ -614,9 +614,9 @@ class User extends CommonObject
if ($result)
{
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/workflow/class/interfaces.class.php");
include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->call_workflow('USER_ENABLEDISABLE',$this,$user,$langs,$conf);
$result=$interface->run_triggers('USER_ENABLEDISABLE',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers
}
@ -670,9 +670,9 @@ class User extends CommonObject
if ($result)
{
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/workflow/class/interfaces.class.php");
include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->call_workflow('USER_DELETE',$this,$user,$langs,$conf);
$result=$interface->run_triggers('USER_DELETE',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers
@ -771,9 +771,9 @@ class User extends CommonObject
if (! $notrigger)
{
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/workflow/class/interfaces.class.php");
include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php");
$interface = new Interfaces($this->db);
$result = $interface->call_workflow('USER_CREATE',$this,$user,$langs,$conf);
$result = $interface->run_triggers('USER_CREATE',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers
}
@ -1109,9 +1109,9 @@ class User extends CommonObject
if (! $error && ! $notrigger)
{
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/workflow/class/interfaces.class.php");
include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->call_workflow('USER_MODIFY',$this,$user,$langs,$conf);
$result=$interface->run_triggers('USER_MODIFY',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers
}
@ -1254,9 +1254,9 @@ class User extends CommonObject
if (! $error && ! $notrigger)
{
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/workflow/class/interfaces.class.php");
include_once(DOL_DOCUMENT_ROOT . "/core/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->call_workflow('USER_NEW_PASSWORD',$this,$user,$langs,$conf);
$result=$interface->run_triggers('USER_NEW_PASSWORD',$this,$user,$langs,$conf);
if ($result < 0) $this->errors=$interface->errors;
// Fin appel triggers
}

View File

@ -42,15 +42,5 @@ class Workflow
$this->db = $DB ;
}
/**
* \brief Fonction appelee lors du declenchement d'un evenement Dolibarr.
* Cette fonction declenche la gestion du workflow.
* TODO under construction
*/
function call_workflow($action,$object,$user,$langs,$conf)
{
$this->run_triggers($action,$object,$user,$langs,$conf);
}
}
?>