Gestion d'evennements supplmentaires dans les triggers:

COMPANY_CREATE, COMPANY_DELETE, COMPANY_MODIFY
CONTRACT_VALIDATE, CONTRACT_CANCEL, CONTRACT_CLOSE
BILL_VALIDATE,BILL_PAYED,BILL_CANCEL
This commit is contained in:
Laurent Destailleur 2005-10-01 15:57:05 +00:00
parent 9e7e9d0d5f
commit 26bc3098af
10 changed files with 389 additions and 283 deletions

View File

@ -542,8 +542,9 @@ function add_row_for_webcal_link()
$nbtr=0;
// Lien avec calendrier si module activé
if ($conf->webcal->enabled) {
if ($conf->webcal->syncro != 'never')
if ($conf->webcal->enabled)
{
if ($conf->global->PHPWEBCALENDAR_SYNCRO != 'never')
{
$langs->load("other");
if (! $user->webcal_login)
@ -557,14 +558,14 @@ function add_row_for_webcal_link()
}
else
{
if ($conf->webcal->syncro == 'always')
if ($conf->global->PHPWEBCALENDAR_SYNCRO == 'always')
{
print '<input type="hidden" name="todo_webcal" value="on">';
}
else
{
print '<tr><td width="25%" nowrap>'.$langs->trans("AddCalendarEntry").'</td>';
print '<td><input type="checkbox" name="todo_webcal"'.(($conf->webcal->syncro=='always' || $conf->webcal->syncro=='yesbydefault')?' checked':'').'></td>';
print '<td><input type="checkbox" name="todo_webcal"'.(($conf->global->PHPWEBCALENDAR_SYNCRO=='always' || $conf->global->PHPWEBCALENDAR_SYNCRO=='yesbydefault')?' checked':'').'></td>';
print '</tr>';
$nbtr++;
}

View File

@ -29,6 +29,9 @@
*/
require("./pre.inc.php");
require_once(DOL_DOCUMENT_ROOT."/facture.class.php");
if ($conf->projet->enabled) require_once(DOL_DOCUMENT_ROOT."/project.class.php");
$user->getrights('facture');
if (!$user->rights->facture->lire)
@ -37,24 +40,14 @@ if (!$user->rights->facture->lire)
$langs->load("bills");
$warning_delay=31*24*60*60; // Delai affichage warning retard (si retard paiement facture > delai)
require_once(DOL_DOCUMENT_ROOT."/facture.class.php");
if ($conf->projet->enabled) {
require_once(DOL_DOCUMENT_ROOT."/project.class.php");
}
/*
* Sécurité accés client
*/
// Sécurité accés client
if ($user->societe_id > 0)
{
$action = '';
$socidp = $user->societe_id;
}
llxHeader('',$langs->trans("Bill"),'Facture');
$html = new Form($db);
@ -111,6 +104,7 @@ if ($_GET["facid"] > 0)
* Facture
*/
print '<table class="border" width="100%">';
$rowspan=3;
// Societe
print '<tr><td>'.$langs->trans("Company").'</td>';
@ -122,7 +116,7 @@ if ($_GET["facid"] > 0)
print '<tr><td>'.$langs->trans("Date").'</td>';
print '<td colspan="3">'.dolibarr_print_date($fac->date,"%A %d %B %Y").'</td>';
print '<td>'.$langs->trans("DateClosing").'</td><td>' . dolibarr_print_date($fac->date_lim_reglement,"%A %d %B %Y");
if ($fac->paye == 0 && $fac->date_lim_reglement < (time() - $warning_delay)) print img_warning($langs->trans("Late"));
if ($fac->paye == 0 && $fac->date_lim_reglement < (time() - $conf->facture->client->warning_delay)) print img_warning($langs->trans("Late"));
print "</td></tr>";
// Conditions et modes de réglement
@ -148,27 +142,32 @@ if ($_GET["facid"] > 0)
{
print '&nbsp;';
}
print "&nbsp;</td>";
}
else
{
print '<td>&nbsp;</td><td colspan="3">';
print "&nbsp;</td>";
}
print '<td colspan="2" rowspan="4" valign="top" width="50%">';
print '</td>';
// partie Droite sur $rowspan lignes
print '<td colspan="2" rowspan="'.$rowspan.'" valign="top" width="50%">';
/*
* Documents
*
*/
* Documents
*/
$facref = sanitize_string($fac->ref);
$file = $conf->facture->dir_output . "/" . $facref . "/" . $facref . ".pdf";
$filedetail = $conf->facture->dir_output . "/" . $facref . "/" . $facref . "-detail.pdf";
$relativepath = "${facref}/${facref}.pdf";
$relativepathdetail = "${facref}/${facref}-detail.pdf";
$relativepathimage = "${facref}/${facref}.pdf.png";
$fileimage = $file.".png";
// Chemin vers png aperçus
$relativepathimage = "${facref}/${facref}.pdf.png";
$relativepathimagebis = "${facref}/${facref}.pdf.png.0";
$fileimage = $file.".png"; // Si PDF d'1 page
$fileimagebis = $file.".png.0"; // Si PDF de plus d'1 page
$var=true;
@ -200,9 +199,10 @@ if ($_GET["facid"] > 0)
print "</table>\n";
// Conversion du PDF en image png si fichier png non existant
if (!file_exists($fileimage))
if (! file_exists($fileimage) && ! file_exists($fileimagebis))
{
if (function_exists("imagick_readimage"))
{
if (function_exists(imagick_readimage)) {
$handle = imagick_readimage( $file ) ;
if ( imagick_iserror( $handle ) )
{
@ -224,22 +224,16 @@ if ($_GET["facid"] > 0)
imagick_writeimage( $handle, $file .".png");
}
else {
else
{
$langs->load("other");
print $langs->trans("ErrorNoImagickReadimage");
print '<font class="error">'.$langs->trans("ErrorNoImagickReadimage").'</font>';
}
}
}
/*
*
*
*/
print "</td></tr>";
print "<tr><td>".$langs->trans("Author")."</td><td colspan=\"3\">$author->fullname</td>";
print '<tr><td nowrap>'.$langs->trans("GlobalDiscount").'</td>';
print '<td align="right" colspan="2">'.$fac->remise_percent.'</td>';
@ -259,13 +253,20 @@ if ($_GET["facid"] > 0)
}
}
// Si fichier png PDF d'1 page trouvé
if (file_exists($fileimage))
{
print '<img src="'.DOL_URL_ROOT . '/viewimage.php?modulepart=apercufacture&file='.urlencode($relativepathimage).'">';
}
print '</div>';
// Si fichier png PDF de plus d'1 page trouvé
elseif (file_exists($fileimagebis))
{
print '<img src="'.DOL_URL_ROOT . '/viewimage.php?modulepart=apercupropal&file='.urlencode($relativepathimagebis).'">';
}
print '</div>';
$db->close();
llxFooter('$Date$ - $Revision$');

View File

@ -96,14 +96,13 @@ class Contrat
$sql.= " fk_user_ouverture = ".$user->id;
$sql.= " WHERE rowid = ".$line_id . " AND (statut = 0 OR statut = 3) ";
$result = $this->db->query($sql) ;
if ($result)
$resql = $this->db->query($sql);
if ($resql)
{
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
$interface=new Interfaces($this->db);
$interface->run_triggers('CONTRACT_SERVICE_ACTIVATE',$this,$user,$lang,$conf);
$result=$interface->run_triggers('CONTRACT_SERVICE_ACTIVATE',$this,$user,$langs,$conf);
// Fin appel triggers
return 1;
@ -132,14 +131,13 @@ class Contrat
$sql.= " fk_user_cloture = ".$user->id;
$sql.= " WHERE rowid = ".$line_id . " AND statut = 4";
$result = $this->db->query($sql) ;
if ($result)
$resql = $this->db->query($sql) ;
if ($resql)
{
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
$interface=new Interfaces($this->db);
$interface->run_triggers('CONTRACT_SERVICE_CLOSE',$this,$user,$lang,$conf);
$result=$interface->run_triggers('CONTRACT_SERVICE_CLOSE',$this,$user,$langs,$conf);
// Fin appel triggers
return 1;
@ -155,66 +153,97 @@ class Contrat
/**
* \brief Cloture un contrat
* \param user Objet User qui cloture
* \param lang Environnement langue de l'utilisateur
* \param langs Environnement langue de l'utilisateur
* \param conf Environnement de configuration lors de l'opération
*
*/
function cloture($user,$lang='',$conf='')
function cloture($user,$langs='',$conf='')
{
$sql = "UPDATE ".MAIN_DB_PREFIX."contrat SET statut = 2";
$sql .= " , date_cloture = now(), fk_user_cloture = ".$user->id;
$sql .= " WHERE rowid = ".$this->id . " AND statut = 1";
$result = $this->db->query($sql) ;
$resql = $this->db->query($sql) ;
if ($resql)
{
$this->use_webcal=($conf->global->PHPWEBCALENDAR_CONTRACTSTATUS=='always'?1:0);
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
$interface=new Interfaces($this->db);
$interface->run_triggers('CONTRACT_CLOSE',$this,$user,$lang,$conf);
// Fin appel triggers
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->run_triggers('CONTRACT_CLOSE',$this,$user,$langs,$conf);
// Fin appel triggers
return 1;
return 1;
}
else
{
$this->error=$this->db->error();
return -1;
}
}
/**
* \brief Valide un contrat
* \param user Objet User qui valide
* \param lang Environnement langue de l'utilisateur
* \param langs Environnement langue de l'utilisateur
* \param conf Environnement de configuration lors de l'opération
*/
function validate($user,$lang='',$conf='')
function validate($user,$langs='',$conf='')
{
$sql = "UPDATE ".MAIN_DB_PREFIX."contrat SET statut = 1";
$sql .= " WHERE rowid = ".$this->id . " AND statut = 0";
$result = $this->db->query($sql) ;
$resql = $this->db->query($sql) ;
if ($resql)
{
$this->use_webcal=($conf->global->PHPWEBCALENDAR_CONTRACTSTATUS=='always'?1:0);
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
$interface=new Interfaces($this->db);
$interface->run_triggers('CONTRACT_VALIDATE',$this,$user,$lang,$conf);
// Fin appel triggers
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->run_triggers('CONTRACT_VALIDATE',$this,$user,$langs,$conf);
// Fin appel triggers
return 1;
}
else
{
$this->error=$this->db->error();
return -1;
}
}
/**
* \brief Annule un contrat
* \param user Objet User qui annule
* \param lang Environnement langue de l'utilisateur
* \param langs Environnement langue de l'utilisateur
* \param conf Environnement de configuration lors de l'opération
*/
function annule($user,$lang='',$conf='')
function annule($user,$langs='',$conf='')
{
$sql = "UPDATE ".MAIN_DB_PREFIX."contrat SET statut = 0";
$sql .= " , date_cloture = now(), fk_user_cloture = ".$user->id;
$sql .= " WHERE rowid = ".$this->id . " AND statut = 1";
$result = $this->db->query($sql) ;
$resql = $this->db->query($sql) ;
if ($resql)
{
$this->use_webcal=($conf->global->PHPWEBCALENDAR_CONTRACTSTATUS=='always'?1:0);
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
$interface=new Interfaces($this->db);
$interface->run_triggers('CONTRACT_CANCEL',$this,$user,$lang,$conf);
// Fin appel triggers
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->run_triggers('CONTRACT_CANCEL',$this,$user,$langs,$conf);
// Fin appel triggers
return 1;
}
else
{
$this->error=$this->db->error();
return -1;
}
}
/**
@ -448,7 +477,7 @@ class Contrat
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->run_triggers('CONTRACT_CREATE',$this,$user,$lang,$conf);
$result=$interface->run_triggers('CONTRACT_CREATE',$this,$user,$langs,$conf);
if ($result < 0) $error++;
// Fin appel triggers
@ -477,7 +506,7 @@ class Contrat
}
else
{
$this->error=$lang->trans("UnknownError: ".$this->db->error()." - sql=".$sql);
$this->error=$langs->trans("UnknownError: ".$this->db->error()." - sql=".$sql);
dolibarr_syslog("Contrat::create - 10 - ".$this->error);
$this->db->rollback();
@ -489,26 +518,29 @@ class Contrat
/**
* \brief Supprime un contrat de la base
* \param user Utilisateur qui supprime
* \param lang Environnement langue de l'utilisateur
* \param langs Environnement langue de l'utilisateur
* \param conf Environnement de configuration lors de l'opération
* \return int < 0 si erreur, > 0 si ok
*/
function delete($user,$lang='',$conf='')
function delete($user,$langs='',$conf='')
{
$sql = "DELETE FROM ".MAIN_DB_PREFIX."contrat";
$sql.= " WHERE rowid=".$this->id;
if ($this->db->query($sql))
$resql=$this->db->query($sql);
if ($resql)
{
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
$interface=new Interfaces($this->db);
$interface->run_triggers('CONTRACT_DELETE',$this,$user,$lang,$conf);
$result=$interface->run_triggers('CONTRACT_DELETE',$this,$user,$langs,$conf);
// Fin appel triggers
return 1;
}
else
{
$this->error=$this->db->error();
return -1;
}
}

View File

@ -212,16 +212,14 @@ if ($_POST["action"] == 'confirm_valid' && $_POST["confirm"] == 'yes' && $user->
{
$contrat = new Contrat($db);
$contrat->fetch($_GET["id"]);
$soc = new Societe($db);
$soc->fetch($contrat->soc_id);
$result = $contrat->validate($user);
$result = $contrat->validate($user,$lang,$conf);
}
if ($_POST["action"] == 'confirm_close' && $_POST["confirm"] == 'yes' && $user->rights->contrat->creer)
{
$contrat = new Contrat($db);
$contrat->fetch($_GET["id"]);
$result = $contrat->cloture($user);
$result = $contrat->cloture($user,$lang,$conf);
}
if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == 'yes')

View File

@ -213,13 +213,13 @@ class Facture
}
}
$result=$this->updateprice($this->id);
if ($result)
$resql=$this->updateprice($this->id);
if ($resql)
{
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
$interface=new Interfaces($this->db);
$interface->run_triggers('BILL_CREATE',$this,$user,$lang,$conf);
$result=$interface->run_triggers('BILL_CREATE',$this,$user,$lang,$conf);
// Fin appel triggers
$this->db->commit();
@ -603,7 +603,7 @@ class Facture
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
$interface=new Interfaces($this->db);
$interface->run_triggers('BILL_DELETE',$this,$user,$lang,$conf);
$result=$interface->run_triggers('BILL_DELETE',$this,$user,$lang,$conf);
// Fin appel triggers
$this->db->commit();
@ -688,7 +688,6 @@ class Facture
return $datelim;
}
/**
* \brief Tag la facture comme payée complètement
* \param rowid id de la facture à modifier
@ -696,19 +695,31 @@ class Facture
function set_payed($rowid)
{
$sql = 'UPDATE '.MAIN_DB_PREFIX.'facture set paye=1 WHERE rowid = '.$rowid ;
$return = $this->db->query( $sql);
$resql = $this->db->query( $sql);
if ($resql)
{
$this->use_webcal=($conf->global->PHPWEBCALENDAR_BILLSTATUS=='always'?1:0);
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->run_triggers('BILL_PAYED',$this,$user,$lang,$conf);
// Fin appel triggers
}
}
/**
* \brief Tag la facture comme payée complètement
* \brief Tag la facture comme non payée complètement
* \param rowid id de la facture à modifier
*/
function set_unpayed($rowid)
{
$sql = 'UPDATE '.MAIN_DB_PREFIX.'facture set paye=0 WHERE rowid = '.$rowid ;
$return = $this->db->query( $sql);
$resql = $this->db->query( $sql);
}
/**
* \brief Tag la facture comme paiement commencée
* \brief Tag la facture comme payer partiellement
* \param rowid id de la facture à modifier
*/
function set_paiement_started($rowid)
@ -718,17 +729,28 @@ class Facture
}
/**
* \brief Tag la facture comme abandonnée
* \brief Tag la facture comme abandonnée + appel trigger BILL_CANCEL
* \param rowid id de la facture à modifier
*/
function set_canceled($rowid)
{
$sql = 'UPDATE '.MAIN_DB_PREFIX.'facture set fk_statut=3 WHERE rowid = '.$rowid;
$return = $this->db->query( $sql);
$resql = $this->db->query( $sql);
if ($resql)
{
$this->use_webcal=($conf->global->PHPWEBCALENDAR_BILLSTATUS=='always'?1:0);
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->run_triggers('BILL_CANCEL',$this,$user,$lang,$conf);
// Fin appel triggers
}
}
/**
* \brief Tag la facture comme validée et valide la facture
* \brief Tag la facture comme validée + appel trigger BILL_VALIDATE
* \param rowid id de la facture à valider
* \param user utilisateur qui valide la facture
* \param soc societe
@ -753,9 +775,11 @@ class Facture
$this->db->begin();
/*
* Lecture de la remise exceptionnelle
*
*/
* Affectation de la remise exceptionnelle
*
* \todo Appliquer la remise avoir dans les lignes quand brouillon plutot
* qu'au moment de la validation
*/
$sql = 'SELECT rowid, rc.amount_ht, fk_soc, fk_user';
$sql .= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc';
$sql .= ' WHERE rc.fk_soc ='. $this->socidp;
@ -776,8 +800,6 @@ class Facture
dolibarr_syslog('Facture::Valide Erreur lecture Remise');
$error++;
}
/* Affectation de la remise exceptionnelle */
if ( $this->_affect_remise_exceptionnelle() <> 0)
{
$error++;
@ -792,7 +814,7 @@ class Facture
$sql .= " SET facnumber='$numfa', fk_statut = 1, fk_user_valid = $user->id";
/* Si l'option est activée on force la date de facture */
if (defined('FAC_FORCE_DATE_VALIDATION') && FAC_FORCE_DATE_VALIDATION == '1')
if ($conf->global->FAC_FORCE_DATE_VALIDATION)
{
$this->date=time();
$datelim=$this->calculate_date_lim_reglement();
@ -809,7 +831,8 @@ class Facture
}
/*
* Update Stats
* Pour chaque produit, on met a jour indicateur nbvente
* On crée ici une dénormalisation des données pas forcément utilisée.
*/
$sql = 'SELECT fk_product FROM '.MAIN_DB_PREFIX.'facturedet WHERE fk_facture = '.$this->id;
$sql .= ' AND fk_product > 0';
@ -834,10 +857,12 @@ class Facture
if ($error == 0)
{
$this->use_webcal=($conf->global->PHPWEBCALENDAR_BILLSTATUS=='always'?1:0);
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
$interface=new Interfaces($this->db);
$interface->run_triggers('BILL_VALIDATE',$this,$user,$lang,$conf);
$result=$interface->run_triggers('BILL_VALIDATE',$this,$user,$lang,$conf);
// Fin appel triggers
$this->db->commit();
@ -846,8 +871,7 @@ class Facture
* Notify
*/
$facref = sanitize_string($this->ref);
$filepdf = FAC_OUTPUTDIR . '/' . $facref . '/' . $facref . '.pdf';
$filepdf = $conf->facture->dir_output . '/' . $facref . '/' . $facref . '.pdf';
$mesg = 'La facture '.$this->ref." a été validée.\n";
$notify = New Notify($this->db);

View File

@ -43,6 +43,10 @@ class InterfaceWebCal
var $db;
var $error;
var $date;
var $duree;
var $texte;
var $desc;
/**
* \brief Constructeur.
@ -114,19 +118,7 @@ class InterfaceWebCal
{
dolibarr_syslog("Trigger '".$this->name."' for action '$action' launched. id=".$object->id);
// Crée objet webcal et connexion avec params $conf->webcal->db->xxx
$webcal = new Webcal();
if (! $webcal->localdb->ok)
{
// Si la creation de l'objet n'as pu se connecter
$error ="Dolibarr n'a pu se connecter à la base Webcalendar avec les identifiants définis (host=".$conf->webcal->db->host." dbname=".$conf->webcal->db->name." user=".$conf->webcal->db->user.").";
$error.=" L'option de mise a jour Webcalendar a été ignorée.";
$this->error=$error;
return -1;
}
// Initialisation donnees webcal
// Initialisation donnees (date,duree,nom_societe,libelle)
if ($object->type_id == 5 && $object->contact->fullname)
{
$libellecal =$langs->trans("TaskRDVWith",$object->contact->fullname)."\n";
@ -142,14 +134,78 @@ class InterfaceWebCal
$libellecal.=($object->label!=$libellecal?$object->label."\n":"");
$libellecal.=($object->note?$object->note:"");
}
$webcal->date=$object->date;
$webcal->duree=$object->duree;
$webcal->texte=$object->societe->nom;
$webcal->desc=$libellecal;
// Ajoute entrée dans webcal
$this->date=$object->date;
$this->duree=$object->duree;
$this->texte=$object->societe->nom;
$this->desc=$libellecal;
}
if ($action == 'COMPANY_CREATE')
{
dolibarr_syslog("Trigger '".$this->name."' for action '$action' launched. id=".$object->id);
// Initialisation donnees (date,duree,nom_societe,libelle)
$this->date=time();
$this->duree=0;
$this->texte=$langs->trans("NewCompanyToDolibarr",$object->nom);
$this->desc=$langs->trans("NewCompanyToDolibarr",$object->nom);
$this->desc.="\n".$langs->trans("Prefix").': '.$object->prefix;
//$this->desc.="\n".$langs->trans("Customer").': '.yn($object->client);
//$this->desc.="\n".$langs->trans("Supplier").': '.yn($object->fournisseur);
$this->desc.="\n".$langs->trans("CreatedBy").': '.$user->code;
}
if ($action == 'CONTRACT_VALIDATE')
{
dolibarr_syslog("Trigger '".$this->name."' for action '$action' launched. id=".$object->id);
}
if ($action == 'CONTRACT_CANCEL')
{
dolibarr_syslog("Trigger '".$this->name."' for action '$action' launched. id=".$object->id);
}
if ($action == 'CONTRACT_CLOSE')
{
dolibarr_syslog("Trigger '".$this->name."' for action '$action' launched. id=".$object->id);
}
if ($action == 'BILL_VALIDATE')
{
dolibarr_syslog("Trigger '".$this->name."' for action '$action' launched. id=".$object->id);
}
if ($action == 'BILL_PAYED')
{
dolibarr_syslog("Trigger '".$this->name."' for action '$action' launched. id=".$object->id);
}
if ($action == 'BILL_CANCELED')
{
dolibarr_syslog("Trigger '".$this->name."' for action '$action' launched. id=".$object->id);
}
// Ajoute entrée dans webcal
if ($this->date)
{
// Crée objet webcal et connexion avec params $conf->webcal->db->xxx
$webcal = new Webcal();
if (! $webcal->localdb->ok)
{
// Si la creation de l'objet n'as pu se connecter
$error ="Dolibarr n'a pu se connecter à la base Webcalendar avec les identifiants définis (host=".$conf->webcal->db->host." dbname=".$conf->webcal->db->name." user=".$conf->webcal->db->user.").";
$error.=" L'option de mise a jour Webcalendar a été ignorée.";
$this->error=$error;
dolibarr_syslog("interface_webcal.class.php: ".$this->error);
return -1;
}
$webcal->date=$this->date;
$webcal->duree=$this->duree;
$webcal->texte=$this->texte;
$webcal->desc=$this->desc;
$result=$webcal->add($user);
if ($result)
if ($result > 0)
{
return 1;
}
@ -159,7 +215,7 @@ class InterfaceWebCal
return -1;
}
}
return 0;
}

View File

@ -36,4 +36,5 @@ BehaviourOnClick=Behaviour on click on URL
CreateBookmark=Create bookmark
SetHereATitleForLink=Set here a title for bookmark
UseAnExternalHttpLinkOrRelativeDolibarrLink=Use an external http URL or a relative Dolibarr URL
ChooseIfANewWindowMustBeOpenedOnClickOnBookmark=Choose if page opened by link must appear on current or new window
ChooseIfANewWindowMustBeOpenedOnClickOnBookmark=Choose if page opened by link must appear on current or new window
NewCompanyToDolibarr=Company %s added into Dolibarr

View File

@ -36,4 +36,5 @@ BehaviourOnClick=Comportement sur click de l'URL
CreateBookmark=Créer bookmark
SetHereATitleForLink=Saisir ici un titre pour le marque page
UseAnExternalHttpLinkOrRelativeDolibarrLink=Saisir une URL http externe ou une URL Dolibarr relative
ChooseIfANewWindowMustBeOpenedOnClickOnBookmark=Choisir si le raccourci doit ouvrir la page dans une nouvelle fenêtre ou fenêtre courante
ChooseIfANewWindowMustBeOpenedOnClickOnBookmark=Choisir si le raccourci doit ouvrir la page dans une nouvelle fenêtre ou fenêtre courante
NewCompanyToDolibarr=Société %s ajoutée dans Dolibarr

View File

@ -283,7 +283,7 @@ $conf->webcal->db->host=defined('PHPWEBCALENDAR_HOST')?PHPWEBCALENDAR_HOST:'';
$conf->webcal->db->user=defined('PHPWEBCALENDAR_USER')?PHPWEBCALENDAR_USER:'';
$conf->webcal->db->pass=defined('PHPWEBCALENDAR_PASS')?PHPWEBCALENDAR_PASS:'';
$conf->webcal->db->name=defined('PHPWEBCALENDAR_DBNAME')?PHPWEBCALENDAR_DBNAME:'';
$conf->webcal->syncro=defined('PHPWEBCALENDAR_SYNCRO')?PHPWEBCALENDAR_SYNCRO:'';
$conf->facture->enabled=defined("MAIN_MODULE_FACTURE")?MAIN_MODULE_FACTURE:0;
if ($conf->facture->enabled) require_once(DOL_DOCUMENT_ROOT ."/includes/modules/facture/modules_facture.php");
$conf->facture->dir_output=DOL_DATA_ROOT."/facture";

View File

@ -146,10 +146,12 @@ class Societe {
if ($ret == 0)
{
$this->use_webcal=($conf->global->PHPWEBCALENDAR_COMPANYCREATE=='always'?1:0);
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
$interface=new Interfaces($this->db);
$interface->run_triggers('COMPANY_CREATE',$this,$user,$lang,$conf);
$result=$interface->run_triggers('COMPANY_CREATE',$this,$user,$langs,$conf);
// Fin appel triggers
dolibarr_syslog("Societe::Create success id=".$this->id);
@ -375,7 +377,7 @@ class Societe {
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->run_triggers('COMPANY_MODIFY',$this,$user,$lang,$conf);
$result=$interface->run_triggers('COMPANY_MODIFY',$this,$user,$langs,$conf);
// Fin appel triggers
}
@ -572,117 +574,114 @@ class Societe {
return $result;
}
/**
* \brief Suppression d'une societe de la base avec ses dépendances (contacts, rib...)
* \param id id de la societe à supprimer
*/
function delete($id)
{
dolibarr_syslog("Societe::Delete");
$sqr = 0;
/**
* \brief Suppression d'une societe de la base avec ses dépendances (contacts, rib...)
* \param id id de la societe à supprimer
*/
function delete($id)
{
dolibarr_syslog("Societe::Delete");
$sqr = 0;
if ( $this->db->begin())
{
$sql = "DELETE from ".MAIN_DB_PREFIX."socpeople ";
$sql .= " WHERE fk_soc = " . $id .";";
if ($this->db->query($sql))
{
$sqr++;
}
else
{
$this->error .= "Impossible de supprimer les contacts.\n";
dolibarr_syslog("Societe::Delete erreur -1");
}
$sql = "DELETE from ".MAIN_DB_PREFIX."societe_rib ";
$sql .= " WHERE fk_soc = " . $id .";";
if ($this->db->query($sql))
{
$sqr++;
}
else
{
$this->error .= "Impossible de supprimer le RIB.\n";
dolibarr_syslog("Societe::Delete erreur -2");
}
$sql = "DELETE from ".MAIN_DB_PREFIX."societe ";
$sql .= " WHERE idp = " . $id .";";
if ($this->db->query($sql))
{
$sqr++;
}
else
{
$this->error .= "Impossible de supprimer la société.\n";
dolibarr_syslog("Societe::Delete erreur -3");
}
if ($sqr == 3)
{
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->run_triggers('COMPANY_DELETE',$this,$user,$langs,$conf);
// Fin appel triggers
$this->db->commit();
// Suppression du répertoire document
$docdir = $conf->societe->dir_output . "/" . $id;
if (file_exists ($docdir))
{
$this->deldir($docdir);
}
return 0;
}
else
{
$this->db->rollback();
return -1;
}
}
}
if ( $this->db->begin())
{
$sql = "DELETE from ".MAIN_DB_PREFIX."socpeople ";
$sql .= " WHERE fk_soc = " . $id .";";
if ($this->db->query($sql))
{
$sqr++;
}
else
{
$this->error .= "Impossible de supprimer les contacts.\n";
dolibarr_syslog("Societe::Delete erreur -1");
}
$sql = "DELETE from ".MAIN_DB_PREFIX."societe_rib ";
$sql .= " WHERE fk_soc = " . $id .";";
if ($this->db->query($sql))
{
$sqr++;
}
else
{
$this->error .= "Impossible de supprimer le RIB.\n";
dolibarr_syslog("Societe::Delete erreur -2");
}
$sql = "DELETE from ".MAIN_DB_PREFIX."societe ";
$sql .= " WHERE idp = " . $id .";";
if ($this->db->query($sql))
{
$sqr++;
}
else
{
$this->error .= "Impossible de supprimer la société.\n";
dolibarr_syslog("Societe::Delete erreur -3");
}
if ($sqr == 3)
{
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
$interface=new Interfaces($this->db);
$interface->run_triggers('COMPANY_DELETE',$this,$user,$lang,$conf);
// Fin appel triggers
$this->db->commit();
// Suppression du répertoire document
$docdir = $conf->societe->dir_output . "/" . $id;
if (file_exists ($docdir))
{
$this->deldir($docdir);
}
return 0;
}
else
{
$this->db->rollback();
return -1;
}
}
}
/**
* \brief Cette fonction permet de supprimer le répertoire de la societe
* et sous répertoire, meme s'ils contiennent des documents.
* \param dir repertoire a supprimer
*/
function deldir($dir)
{
$current_dir = opendir($dir);
while($entryname = readdir($current_dir))
{
if(is_dir("$dir/$entryname") and ($entryname != "." and $entryname!=".."))
{
deldir("${dir}/${entryname}");
}
elseif($entryname != "." and $entryname!="..")
{
unlink("${dir}/${entryname}");
}
}
closedir($current_dir);
rmdir(${dir});
}
/**
* \brief Cette fonction permet de supprimer le répertoire de la societe
* et sous répertoire, meme s'ils contiennent des documents.
* \param dir repertoire a supprimer
*/
function deldir($dir)
{
$current_dir = opendir($dir);
while($entryname = readdir($current_dir))
{
if(is_dir("$dir/$entryname") and ($entryname != "." and $entryname!=".."))
{
deldir("${dir}/${entryname}");
}
elseif($entryname != "." and $entryname!="..")
{
unlink("${dir}/${entryname}");
}
}
closedir($current_dir);
rmdir(${dir});
}
/**
* \brief Retournes les factures impayées de la société
* \return array tableau des id de factures impayées
*
*/
function factures_impayes()
{
$facimp = array();
@ -715,7 +714,6 @@ class Societe {
* \brief Attribut le prefix de la société en base
*
*/
function attribute_prefix()
{
$sql = "SELECT nom FROM ".MAIN_DB_PREFIX."societe WHERE idp = '$this->id'";
@ -771,7 +769,6 @@ class Societe {
* \param mot l'indice du mot à utiliser
*
*/
function genprefix($nom, $taille=4,$mot=0)
{
$retour = "";
@ -800,7 +797,6 @@ class Societe {
* \brief Définit la société comme un client
*
*/
function set_as_client()
{
if ($this->id)
@ -817,9 +813,7 @@ class Societe {
* \brief Définit la société comme un client
* \param remise montant de la remise
* \param user utilisateur qui place la remise
*
*/
function set_remise_client($remise, $user)
{
if ($this->id)
@ -841,13 +835,13 @@ class Societe {
}
}
/**
* \brief Définit la société comme un client
* \param remise montant de la remise
* \param user utilisateur qui place la remise
*
*/
function set_remise_except($remise, $user)
{
if ($this->id)
@ -870,8 +864,8 @@ class Societe {
}
}
/**
*
*
*
*/
@ -895,6 +889,7 @@ class Societe {
}
}
/**
*
*
@ -914,12 +909,12 @@ class Societe {
}
}
/**
* \brief Renvoie le nom d'une societe a partir d'un id
* \param id id de la société recherchée
*
*/
function get_nom($id)
{
@ -946,7 +941,6 @@ class Societe {
* \brief Renvoie la liste des contacts emails existant pour la société
* \return array tableau des contacts emails
*/
function contact_email_array()
{
$contact_email = array();
@ -981,7 +975,6 @@ class Societe {
* \brief Renvoie la liste des contacts de cette société
* \return array tableau des contacts
*/
function contact_array()
{
$contacts = array();
@ -1012,37 +1005,37 @@ class Societe {
}
/**
* \brief Renvoie l'email d'un contact par son id
* \param rowid id du contact
* \return string email du contact
*/
function contact_get_email($rowid)
{
/**
* \brief Renvoie l'email d'un contact par son id
* \param rowid id du contact
* \return string email du contact
*/
function contact_get_email($rowid)
{
$sql = "SELECT idp, email, name, firstname FROM ".MAIN_DB_PREFIX."socpeople WHERE idp = '$rowid'";
if ($this->db->query($sql) )
{
$nump = $this->db->num_rows();
if ($nump)
{
$obj = $this->db->fetch_object();
$contact_email = "$obj->firstname $obj->name <$obj->email>";
}
return $contact_email;
}
else
{
dolibarr_print_error($this->db);
}
}
$sql = "SELECT idp, email, name, firstname FROM ".MAIN_DB_PREFIX."socpeople WHERE idp = '$rowid'";
if ($this->db->query($sql) )
{
$nump = $this->db->num_rows();
if ($nump)
{
$obj = $this->db->fetch_object();
$contact_email = "$obj->firstname $obj->name <$obj->email>";
}
return $contact_email;
}
else
{
dolibarr_print_error($this->db);
}
}
/**
* \brief Renvoie la liste des libellés traduits types actifs de sociétés
@ -1134,10 +1127,10 @@ class Societe {
return $fj;
}
/**
* \brief Affiche le rib
*/
function display_rib()
{
global $langs;
@ -1182,7 +1175,6 @@ class Societe {
* \brief Verifie code client
* \return Renvoie 0 si ok, peut modifier le code client suivant le module utilisé
*/
function verif_codeclient()
{
if (defined('CODECLIENT_ADDON') && strlen(CODECLIENT_ADDON) > 0)
@ -1300,11 +1292,11 @@ class Societe {
}
/**
* \brief Défini la société mère pour les filiales
* \param id id compagnie mère à positionner
* \return int <0 si ko, >0 si ok
*/
/**
* \brief Défini la société mère pour les filiales
* \param id id compagnie mère à positionner
* \return int <0 si ko, >0 si ok
*/
function set_parent($id)
{
if ($this->id)
@ -1324,11 +1316,11 @@ class Societe {
}
}
/**
* \brief Supprime la société mère
* \param id id compagnie mère à effacer
* \return int <0 si ko, >0 si ok
*/
/**
* \brief Supprime la société mère
* \param id id compagnie mère à effacer
* \return int <0 si ko, >0 si ok
*/
function remove_parent($id)
{
if ($this->id)