Ajout trigger Phenix - non oprationnel
This commit is contained in:
parent
cce9f482b0
commit
ae873ca72d
@ -160,7 +160,8 @@ if ($_POST["action"] == 'add_action')
|
||||
$societe->fetch($_REQUEST["socid"]);
|
||||
$actioncomm->societe = $societe;
|
||||
}
|
||||
if ($_POST["add_webcal"] == 'on') $actioncomm->use_webcal=1;
|
||||
if ($_POST["add_webcal"] == 'on' && $conf->webcal->enabled) $actioncomm->use_webcal=1;
|
||||
if ($_POST["add_phenix"] == 'on' && $conf->phenix->enabled) $actioncomm->use_phenix=1;
|
||||
|
||||
// On crée l'action
|
||||
$idaction=$actioncomm->add($user);
|
||||
@ -384,7 +385,7 @@ if ($_GET["action"] == 'create')
|
||||
$html->select_duree("duree");
|
||||
print '</td></tr>';
|
||||
|
||||
add_row_for_webcal_link();
|
||||
add_row_for_calendar_link();
|
||||
|
||||
// Note
|
||||
print '<tr><td valign="top">'.$langs->trans("Note").'</td><td>';
|
||||
@ -528,7 +529,7 @@ if ($_GET["action"] == 'create')
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
add_row_for_webcal_link();
|
||||
add_row_for_calendar_link();
|
||||
|
||||
// Note
|
||||
print '<tr><td valign="top">'.$langs->trans("Note").'</td><td>';
|
||||
@ -782,44 +783,77 @@ llxFooter('$Date$ - $Revision$');
|
||||
|
||||
|
||||
/**
|
||||
\brief Ajoute une ligne de tableau a 2 colonnes pour avoir l'option webcalendar
|
||||
\brief Ajoute une ligne de tableau a 2 colonnes pour avoir l'option synchro calendrier
|
||||
\return int Retourne le nombre de lignes ajoutées
|
||||
*/
|
||||
function add_row_for_webcal_link()
|
||||
function add_row_for_calendar_link()
|
||||
{
|
||||
global $conf,$langs,$user;
|
||||
$nbtr=0;
|
||||
global $conf,$langs,$user;
|
||||
$nbtr=0;
|
||||
|
||||
// Lien avec calendrier si module activé
|
||||
if ($conf->webcal->enabled)
|
||||
// Lien avec calendrier si module activé
|
||||
if ($conf->webcal->enabled)
|
||||
{
|
||||
if ($conf->global->PHPWEBCALENDAR_SYNCRO != 'never')
|
||||
{
|
||||
if ($conf->global->PHPWEBCALENDAR_SYNCRO != 'never')
|
||||
$langs->load("other");
|
||||
|
||||
print '<tr><td width="25%" nowrap>'.$langs->trans("AddCalendarEntry","Webcalendar").'</td>';
|
||||
|
||||
if (! $user->webcal_login)
|
||||
{
|
||||
print '<td><input type="checkbox" disabled name="add_webcal">';
|
||||
print ' '.$langs->transnoentities("ErrorWebcalLoginNotDefined","<a href=\"".DOL_URL_ROOT."/user/fiche.php?id=".$user->id."\">".$user->login."</a>");
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
$nbtr++;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($conf->global->PHPWEBCALENDAR_SYNCRO == 'always')
|
||||
{
|
||||
$langs->load("other");
|
||||
if (! $user->webcal_login)
|
||||
{
|
||||
print '<tr><td width="25%" nowrap>'.$langs->trans("AddCalendarEntry").'</td>';
|
||||
print '<td><input type="checkbox" disabled name="add_webcal">';
|
||||
print ' '.$langs->transnoentities("ErrorWebcalLoginNotDefined","<a href=\"".DOL_URL_ROOT."/user/fiche.php?id=".$user->id."\">".$user->login."</a>");
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
$nbtr++;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($conf->global->PHPWEBCALENDAR_SYNCRO == 'always')
|
||||
{
|
||||
print '<input type="hidden" name="add_webcal" value="on">';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<tr><td width="25%" nowrap>'.$langs->trans("AddCalendarEntry").'</td>';
|
||||
print '<td><input type="checkbox" name="add_webcal"'.(($conf->global->PHPWEBCALENDAR_SYNCRO=='always' || $conf->global->PHPWEBCALENDAR_SYNCRO=='yesbydefault')?' checked':'').'></td>';
|
||||
print '</tr>';
|
||||
$nbtr++;
|
||||
}
|
||||
}
|
||||
print '<input type="hidden" name="add_webcal" value="on">';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<td><input type="checkbox" name="add_webcal"'.(($conf->global->PHPWEBCALENDAR_SYNCRO=='always' || $conf->global->PHPWEBCALENDAR_SYNCRO=='yesbydefault')?' checked':'').'></td>';
|
||||
print '</tr>';
|
||||
$nbtr++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($conf->phenix->enabled)
|
||||
{
|
||||
if ($conf->global->PHPPHENIX_SYNCRO != 'never')
|
||||
{
|
||||
$langs->load("other");
|
||||
|
||||
print '<tr><td width="25%" nowrap>'.$langs->trans("AddCalendarEntry","Phenix").'</td>';
|
||||
|
||||
if (! $user->phenix_login)
|
||||
{
|
||||
print '<td><input type="checkbox" disabled name="add_phenix">';
|
||||
print ' '.$langs->transnoentities("ErrorPhenixLoginNotDefined","<a href=\"".DOL_URL_ROOT."/user/fiche.php?id=".$user->id."\">".$user->login."</a>");
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
$nbtr++;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($conf->global->PHPPHENIX_SYNCRO == 'always')
|
||||
{
|
||||
print '<input type="hidden" name="add_phenix" value="on">';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<td><input type="checkbox" name="add_phenix"'.(($conf->global->PHPPHENIX_SYNCRO=='always' || $conf->global->PHPPHENIX_SYNCRO=='yesbydefault')?' checked':'').'></td>';
|
||||
print '</tr>';
|
||||
$nbtr++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $nbtr;
|
||||
|
||||
@ -0,0 +1,417 @@
|
||||
<?php
|
||||
/* Copyright (C) 2005-2008 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2008 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.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
/**
|
||||
\file htdocs/includes/triggers/interface_modPhenix_Phenixsynchro.class.php
|
||||
\ingroup phenix
|
||||
\brief Fichier de gestion des triggers phenix
|
||||
*/
|
||||
|
||||
include_once(DOL_DOCUMENT_ROOT.'/phenix/phenix.class.php');
|
||||
|
||||
|
||||
/**
|
||||
\class InterfacePhenixsynchro
|
||||
\brief Classe des fonctions triggers des actions phenix
|
||||
*/
|
||||
|
||||
class InterfacePhenixsynchro
|
||||
{
|
||||
var $db;
|
||||
var $error;
|
||||
|
||||
var $date;
|
||||
var $duree;
|
||||
var $texte;
|
||||
var $desc;
|
||||
|
||||
/**
|
||||
* \brief Constructeur.
|
||||
* \param DB Handler d'accès base
|
||||
*/
|
||||
function InterfacePhenixsynchro($DB)
|
||||
{
|
||||
$this->db = $DB ;
|
||||
|
||||
$this->name = "Phenixsynchro";
|
||||
$this->family = "phenix";
|
||||
$this->description = "Les triggers de ce composant permettent d'insérer un évênement dans le calendrier phenix pour chaque grand évênement Dolibarr.";
|
||||
$this->version = 'experimental'; // 'experimental' or 'dolibarr' or version
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Renvoi nom du lot de triggers
|
||||
* \return string Nom du lot de triggers
|
||||
*/
|
||||
function getName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Renvoi descriptif du lot de triggers
|
||||
* \return string Descriptif du lot de triggers
|
||||
*/
|
||||
function getDesc()
|
||||
{
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Renvoi version du lot de triggers
|
||||
* \return string Version du lot de triggers
|
||||
*/
|
||||
function getVersion()
|
||||
{
|
||||
global $langs;
|
||||
$langs->load("admin");
|
||||
|
||||
if ($this->version == 'experimental') return $langs->trans("Experimental");
|
||||
elseif ($this->version == 'dolibarr') return DOL_VERSION;
|
||||
elseif ($this->version) return $this->version;
|
||||
else return $langs->trans("Unknown");
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Fonction appelée lors du déclenchement d'un évènement Dolibarr.
|
||||
* D'autres fonctions run_trigger peuvent etre présentes dans includes/triggers
|
||||
* \param action Code de l'evenement
|
||||
* \param object Objet concerné
|
||||
* \param user Objet user
|
||||
* \param lang Objet lang
|
||||
* \param conf Objet conf
|
||||
* \return int <0 si ko, 0 si aucune action faite, >0 si ok
|
||||
*/
|
||||
function run_trigger($action,$object,$user,$langs,$conf)
|
||||
{
|
||||
// Mettre ici le code à exécuter en réaction de l'action
|
||||
// Les données de l'action sont stockées dans $object
|
||||
|
||||
if (! $conf->phenix->enabled) return 0; // Module non actif
|
||||
if (! $object->use_phenix) return 0; // Option syncro phenix non active
|
||||
|
||||
// Actions
|
||||
if ($action == 'ACTION_CREATE')
|
||||
{
|
||||
dolibarr_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||
$langs->load("other");
|
||||
|
||||
// Initialisation donnees (date,duree,texte,desc)
|
||||
if ($object->type_id == 5 && $object->contact->fullname)
|
||||
{
|
||||
$libellecal =$langs->transnoentities("TaskRDVWith",$object->contact->getFullName($langs))."\n";
|
||||
$libellecal.=$object->note;
|
||||
}
|
||||
else
|
||||
{
|
||||
$libellecal="";
|
||||
if ($langs->transnoentities("Action".$object->type_code) != "Action".$object->type_code)
|
||||
{
|
||||
$libellecal.=$langs->transnoentities("Action".$object->type_code)."\n";
|
||||
}
|
||||
$libellecal.=($object->label!=$libellecal?$object->label."\n":"");
|
||||
$libellecal.=($object->note?$object->note:"");
|
||||
}
|
||||
|
||||
$this->date=$object->date ? $object->date : $object->datep;
|
||||
$this->duree=$object->duree;
|
||||
$this->texte=$object->societe->nom;
|
||||
$this->desc=$libellecal;
|
||||
}
|
||||
|
||||
// Third parties
|
||||
elseif ($action == 'COMPANY_CREATE')
|
||||
{
|
||||
dolibarr_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||
$langs->load("other");
|
||||
|
||||
// Initialisation donnees (date,duree,texte,desc)
|
||||
$this->date=time();
|
||||
$this->duree=0;
|
||||
$this->texte=$langs->transnoentities("NewCompanyToDolibarr",$object->nom);
|
||||
$this->desc=$langs->transnoentities("NewCompanyToDolibarr",$object->nom);
|
||||
if ($object->prefix) $this->desc.=" (".$object->prefix.")";
|
||||
//$this->desc.="\n".$langs->transnoentities("Customer").': '.yn($object->client);
|
||||
//$this->desc.="\n".$langs->transnoentities("Supplier").': '.yn($object->fournisseur);
|
||||
$this->desc.="\n".$langs->transnoentities("Author").': '.$user->login;
|
||||
}
|
||||
|
||||
// Contracts
|
||||
elseif ($action == 'CONTRACT_VALIDATE')
|
||||
{
|
||||
dolibarr_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||
$langs->load("other");
|
||||
|
||||
// Initialisation donnees (date,duree,texte,desc)
|
||||
$this->date=time();
|
||||
$this->duree=0;
|
||||
$this->texte=$langs->transnoentities("ContractValidatedInDolibarr",$object->ref);
|
||||
$this->desc=$langs->transnoentities("ContractValidatedInDolibarr",$object->ref);
|
||||
$this->desc.="\n".$langs->transnoentities("Author").': '.$user->login;
|
||||
}
|
||||
elseif ($action == 'CONTRACT_CANCEL')
|
||||
{
|
||||
dolibarr_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||
$langs->load("other");
|
||||
|
||||
$this->date=time();
|
||||
$this->duree=0;
|
||||
$this->texte=$langs->transnoentities("ContractCanceledInDolibarr",$object->ref);
|
||||
$this->desc=$langs->transnoentities("ContractCanceledInDolibarr",$object->ref);
|
||||
$this->desc.="\n".$langs->transnoentities("Author").': '.$user->login;
|
||||
}
|
||||
elseif ($action == 'CONTRACT_CLOSE')
|
||||
{
|
||||
dolibarr_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||
$langs->load("other");
|
||||
|
||||
$this->date=time();
|
||||
$this->duree=0;
|
||||
$this->texte=$langs->transnoentities("ContractClosedInDolibarr",$object->ref);
|
||||
$this->desc=$langs->transnoentities("ContractClosedInDolibarr",$object->ref);
|
||||
$this->desc.="\n".$langs->transnoentities("Author").': '.$user->login;
|
||||
}
|
||||
|
||||
// Proposals
|
||||
elseif ($action == 'PROPAL_VALIDATE')
|
||||
{
|
||||
dolibarr_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||
$langs->load("other");
|
||||
|
||||
$this->date=time();
|
||||
$this->duree=0;
|
||||
$this->texte=$langs->transnoentities("PropalValidatedInDolibarr",$object->ref);
|
||||
$this->desc=$langs->transnoentities("PropalValidatedInDolibarr",$object->ref);
|
||||
$this->desc.="\n".$langs->transnoentities("Author").': '.$user->login;
|
||||
}
|
||||
elseif ($action == 'PROPAL_CLOSE_SIGNED')
|
||||
{
|
||||
dolibarr_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||
$langs->load("other");
|
||||
|
||||
$this->date=time();
|
||||
$this->duree=0;
|
||||
$this->texte=$langs->transnoentities("PropalClosedSignedInDolibarr",$object->ref);
|
||||
$this->desc=$langs->transnoentities("PropalClosedSignedInDolibarr",$object->ref);
|
||||
$this->desc.="\n".$langs->transnoentities("Author").': '.$user->login;
|
||||
}
|
||||
elseif ($action == 'PROPAL_CLOSE_REFUSED')
|
||||
{
|
||||
dolibarr_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||
$langs->load("other");
|
||||
|
||||
$this->date=time();
|
||||
$this->duree=0;
|
||||
$this->texte=$langs->transnoentities("PropalClosedRefusedInDolibarr",$object->ref);
|
||||
$this->desc=$langs->transnoentities("PropalClosedRefusedInDolibarr",$object->ref);
|
||||
$this->desc.="\n".$langs->transnoentities("Author").': '.$user->login;
|
||||
}
|
||||
|
||||
// Invoices
|
||||
elseif ($action == 'BILL_VALIDATE')
|
||||
{
|
||||
dolibarr_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||
$langs->load("other");
|
||||
|
||||
$this->date=time();
|
||||
$this->duree=0;
|
||||
$this->texte=$langs->transnoentities("InvoiceValidatedInDolibarr",$object->ref);
|
||||
$this->desc=$langs->transnoentities("InvoiceValidatedInDolibarr",$object->ref);
|
||||
$this->desc.="\n".$langs->transnoentities("Author").': '.$user->login;
|
||||
}
|
||||
elseif ($action == 'BILL_PAYED')
|
||||
{
|
||||
dolibarr_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||
$langs->load("other");
|
||||
|
||||
$this->date=time();
|
||||
$this->duree=0;
|
||||
$this->texte=$langs->transnoentities("InvoicePayedInDolibarr",$object->ref);
|
||||
$this->desc=$langs->transnoentities("InvoicePayedInDolibarr",$object->ref);
|
||||
$this->desc.="\n".$langs->transnoentities("Author").': '.$user->login;
|
||||
}
|
||||
elseif ($action == 'BILL_CANCELED')
|
||||
{
|
||||
dolibarr_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||
$langs->load("other");
|
||||
|
||||
$this->date=time();
|
||||
$this->duree=0;
|
||||
$this->texte=$langs->transnoentities("InvoiceCanceledInDolibarr",$object->ref);
|
||||
$this->desc=$langs->transnoentities("InvoiceCanceledInDolibarr",$object->ref);
|
||||
$this->desc.="\n".$langs->transnoentities("Author").': '.$user->login;
|
||||
}
|
||||
|
||||
// Payments
|
||||
elseif ($action == 'PAYMENT_CUSTOMER_CREATE')
|
||||
{
|
||||
dolibarr_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||
$langs->load("other");
|
||||
|
||||
$this->date=time();
|
||||
$this->duree=0;
|
||||
$this->texte=$langs->transnoentities("CustomerPaymentDoneInDolibarr",$object->ref);
|
||||
$this->desc=$langs->transnoentities("CustomerPaymentDoneInDolibarr",$object->ref);
|
||||
$this->desc.="\n".$langs->transnoentities("AmountTTC").': '.$object->total;
|
||||
$this->desc.="\n".$langs->transnoentities("Author").': '.$user->login;
|
||||
}
|
||||
elseif ($action == 'PAYMENT_SUPPLIER_CREATE')
|
||||
{
|
||||
dolibarr_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||
$langs->load("other");
|
||||
|
||||
$this->date=time();
|
||||
$this->duree=0;
|
||||
$this->texte=$langs->transnoentities("SupplierPaymentDoneInDolibarr",$object->ref);
|
||||
$this->desc=$langs->transnoentities("SupplierPaymentDoneInDolibarr",$object->ref);
|
||||
$this->desc.="\n".$langs->transnoentities("AmountTTC").': '.$object->total;
|
||||
$this->desc.="\n".$langs->transnoentities("Author").': '.$user->login;
|
||||
}
|
||||
|
||||
// Members
|
||||
elseif ($action == 'MEMBER_CREATE')
|
||||
{
|
||||
}
|
||||
elseif ($action == 'MEMBER_VALIDATE')
|
||||
{
|
||||
dolibarr_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||
$langs->load("other");
|
||||
$langs->load("members");
|
||||
|
||||
$this->date=time();
|
||||
$this->duree=0;
|
||||
$this->texte=$langs->transnoentities("MemberValidatedInDolibarr",$object->id);
|
||||
$this->desc=$langs->transnoentities("MemberValidatedInDolibarr",$object->id);
|
||||
$this->desc.="\n".$langs->transnoentities("Member").': '.$object->fullname;
|
||||
$this->desc.="\n".$langs->transnoentities("Type").': '.$object->type;
|
||||
$this->desc.="\n".$langs->transnoentities("Author").': '.$user->login;
|
||||
}
|
||||
elseif ($action == 'MEMBER_SUBSCRIPTION')
|
||||
{
|
||||
dolibarr_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||
$langs->load("other");
|
||||
$langs->load("members");
|
||||
|
||||
$this->date=time();
|
||||
$this->duree=0;
|
||||
$this->texte=$langs->transnoentities("MemberSubscriptionInDolibarr",$object->id);
|
||||
$this->desc=$langs->transnoentities("MemberSubscriptionInDolibarr",$object->id);
|
||||
$this->desc.="\n".$langs->transnoentities("Member").': '.$object->fullname;
|
||||
$this->desc.="\n".$langs->transnoentities("Type").': '.$object->type;
|
||||
$this->desc.="\n".$langs->transnoentities("Amount").': '.$object->last_subscription_amount;
|
||||
$this->desc.="\n".$langs->transnoentities("Period").': '.dolibarr_print_date($object->last_subscription_date_start,'day').' - '.dolibarr_print_date($object->last_subscription_date_end,'day');
|
||||
$this->desc.="\n".$langs->transnoentities("Author").': '.$user->login;
|
||||
}
|
||||
elseif ($action == 'MEMBER_MODIFY')
|
||||
{
|
||||
dolibarr_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||
$langs->load("other");
|
||||
$langs->load("members");
|
||||
|
||||
$this->date=time();
|
||||
$this->duree=0;
|
||||
$this->texte=$langs->transnoentities("MemberModifiedInDolibarr",$object->id);
|
||||
$this->desc=$langs->transnoentities("MemberModifiedInDolibarr",$object->id);
|
||||
$this->desc.="\n".$langs->transnoentities("Member").': '.$object->fullname;
|
||||
$this->desc.="\n".$langs->transnoentities("Type").': '.$object->type;
|
||||
$this->desc.="\n".$langs->transnoentities("Author").': '.$user->login;
|
||||
}
|
||||
elseif ($action == 'MEMBER_RESILIATE')
|
||||
{
|
||||
dolibarr_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||
$langs->load("other");
|
||||
$langs->load("members");
|
||||
|
||||
$this->date=time();
|
||||
$this->duree=0;
|
||||
$this->texte=$langs->transnoentities("MemberResiliatedInDolibarr",$object->id);
|
||||
$this->desc=$langs->transnoentities("MemberResiliatedInDolibarr",$object->id);
|
||||
$this->desc.="\n".$langs->transnoentities("Member").': '.$object->fullname;
|
||||
$this->desc.="\n".$langs->transnoentities("Type").': '.$object->type;
|
||||
$this->desc.="\n".$langs->transnoentities("Author").': '.$user->login;
|
||||
}
|
||||
elseif ($action == 'MEMBER_DELETE')
|
||||
{
|
||||
dolibarr_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||
$langs->load("other");
|
||||
$langs->load("members");
|
||||
|
||||
$this->date=time();
|
||||
$this->duree=0;
|
||||
$this->texte=$langs->transnoentities("MemberDeletedInDolibarr",$object->id);
|
||||
$this->desc=$langs->transnoentities("MemberDeletedInDolibarr",$object->id);
|
||||
$this->desc.="\n".$langs->transnoentities("Member").': '.$object->fullname;
|
||||
$this->desc.="\n".$langs->transnoentities("Type").': '.$object->type;
|
||||
$this->desc.="\n".$langs->transnoentities("Author").': '.$user->login;
|
||||
}
|
||||
|
||||
// If not found
|
||||
/*
|
||||
else
|
||||
{
|
||||
dolibarr_syslog("Trigger '".$this->name."' for action '$action' was ran by ".__FILE__." but no handler found for this action.");
|
||||
return 0;
|
||||
}
|
||||
*/
|
||||
|
||||
// Ajoute entrée dans phenix
|
||||
if ($this->date)
|
||||
{
|
||||
|
||||
// Crée objet phenix et connexion avec params $conf->phenix->db->xxx
|
||||
$phenix = new Phenix();
|
||||
if (! $phenix->localdb->ok)
|
||||
{
|
||||
// Si la creation de l'objet n'as pu se connecter
|
||||
$error ="Dolibarr n'a pu se connecter à la base Phenix avec les identifiants définis (host=".$conf->phenix->db->host." dbname=".$conf->phenix->db->name." user=".$conf->phenix->db->user."). ";
|
||||
$error.="La mise a jour Webcalendar a été ignorée.";
|
||||
$this->error=$error;
|
||||
|
||||
//dolibarr_syslog("interface_phenix.class.php: ".$this->error);
|
||||
return -1;
|
||||
}
|
||||
|
||||
$phenix->date=$this->date;
|
||||
$phenix->duree=$this->duree;
|
||||
$phenix->texte=$this->texte;
|
||||
$phenix->desc=$this->desc;
|
||||
|
||||
$result=$phenix->add($user);
|
||||
if ($result > 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$error ="Echec insertion dans phenix: ".$phenix->error." ";
|
||||
$error.="La mise a jour Phenix a été ignorée.";
|
||||
$this->error=$error;
|
||||
|
||||
//dolibarr_syslog("interface_phenix.class.php: ".$this->error);
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
@ -85,8 +85,11 @@ EnableGDLibraryDesc=Install or enable GD library with your PHP for use this opti
|
||||
EnablePhpAVModuleDesc=You need to install a module compatible with your anti-virus. (Clamav : php4-clamavlib ou php5-clamavlib)
|
||||
##### Webcal #####
|
||||
LoginWebcal=Login for Webcalendar
|
||||
AddCalendarEntry=Add entry in calendar
|
||||
ErrorWebcalLoginNotDefined=The Webcalendar login associated to your Dolibarr login <b>%s</b> is not defined.
|
||||
##### Phenix #####
|
||||
ErrorPhenixLoginNotDefined=The Phenix login associated to your Dolibarr login <b>%s</b> is not defined.
|
||||
##### Calendar common #####
|
||||
AddCalendarEntry=Add entry in calendar %s
|
||||
NewCompanyToDolibarr=Company %s added into Dolibarr
|
||||
ContractValidatedInDolibarr=Contract %s validated in Dolibarr
|
||||
ContractCanceledInDolibarr=Contract %s canceled in Dolibarr
|
||||
|
||||
@ -85,8 +85,11 @@ EnableGDLibraryDesc=Vous devez activer ou installer la librairie GD avec votre P
|
||||
EnablePhpAVModuleDesc=Vous devez installer un module PHP compatible avec votre anti-virus. (Clamav : php4-clamavlib ou php5-clamavlib)
|
||||
##### Webcal #####
|
||||
LoginWebcal=Login Webcalendar
|
||||
AddCalendarEntry=Ajouter entrée dans le calendrier
|
||||
ErrorWebcalLoginNotDefined=Le login Webcalendar associé à votre login Dolibarr <b>%s</b> n'est pas défini.
|
||||
##### Phenix #####
|
||||
ErrorPhenixLoginNotDefined=Le login Phenix associé à votre login Dolibarr <b>%s</b> n'est pas défini.
|
||||
##### Calendar common #####
|
||||
AddCalendarEntry=Ajouter entrée dans le calendrier %s
|
||||
NewCompanyToDolibarr=Société %s ajoutée dans Dolibarr
|
||||
ContractValidatedInDolibarr=Contrat %s validé dans Dolibarr
|
||||
ContractCanceledInDolibarr=Contrat %s annulé dans Dolibarr
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/* Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2007 Regis Houssin <regis@dolibarr.fr>
|
||||
* Copyright (C) 2005-2008 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
|
||||
@ -50,129 +50,131 @@ class Phenix {
|
||||
*/
|
||||
function Phenix()
|
||||
{
|
||||
global $conf;
|
||||
global $dolibarr_main_db_type,$dolibarr_main_db_host,$dolibarr_main_db_user;
|
||||
global $dolibarr_main_db_pass,$dolibarr_main_db_name;
|
||||
global $conf;
|
||||
global $dolibarr_main_db_type,$dolibarr_main_db_host,$dolibarr_main_db_user;
|
||||
global $dolibarr_main_db_pass,$dolibarr_main_db_name;
|
||||
|
||||
// Défini parametres phenix (avec substitution eventuelle)
|
||||
$phenixtype=eregi_replace('__dolibarr_main_db_type__',$dolibarr_main_db_type,$conf->phenix->db->type);
|
||||
$phenixhost=eregi_replace('__dolibarr_main_db_host__',$dolibarr_main_db_host,$conf->phenix->db->host);
|
||||
$phenixuser=eregi_replace('__dolibarr_main_db_user__',$dolibarr_main_db_user,$conf->phenix->db->user);
|
||||
$phenixpass=eregi_replace('__dolibarr_main_db_pass__',$dolibarr_main_db_pass,$conf->phenix->db->pass);
|
||||
$phenixname=eregi_replace('__dolibarr_main_db_name__',$dolibarr_main_db_name,$conf->phenix->db->name);
|
||||
// Défini parametres phenix (avec substitution eventuelle)
|
||||
$phenixtype=eregi_replace('__dolibarr_main_db_type__',$dolibarr_main_db_type,$conf->phenix->db->type);
|
||||
$phenixhost=eregi_replace('__dolibarr_main_db_host__',$dolibarr_main_db_host,$conf->phenix->db->host);
|
||||
$phenixuser=eregi_replace('__dolibarr_main_db_user__',$dolibarr_main_db_user,$conf->phenix->db->user);
|
||||
$phenixpass=eregi_replace('__dolibarr_main_db_pass__',$dolibarr_main_db_pass,$conf->phenix->db->pass);
|
||||
$phenixname=eregi_replace('__dolibarr_main_db_name__',$dolibarr_main_db_name,$conf->phenix->db->name);
|
||||
|
||||
// On initie la connexion à la base Phenix
|
||||
require_once (DOL_DOCUMENT_ROOT ."/lib/databases/".$phenixtype.".lib.php");
|
||||
$this->localdb = new DoliDb($phenixtype,$phenixhost,$phenixuser,$phenixpass,$phenixname);
|
||||
// On initie la connexion à la base Phenix
|
||||
require_once (DOL_DOCUMENT_ROOT ."/lib/databases/".$phenixtype.".lib.php");
|
||||
$this->localdb = new DoliDb($phenixtype,$phenixhost,$phenixuser,$phenixpass,$phenixname);
|
||||
}
|
||||
|
||||
// TODO : Modifier la suite....
|
||||
// Ajouter variable pour l'extension du nom des tables "px_" qui peut etre different
|
||||
// récupérer id du user à partir de son login
|
||||
|
||||
|
||||
/**
|
||||
\brief Ajoute objet en tant qu'entree dans le calendrier de l'utilisateur
|
||||
\param[in] user Le login de l'utilisateur
|
||||
\return int 1 en cas de succès, -1,-2,-3 en cas d'erreur, -4 si login webcal non défini
|
||||
\param[in] user Le login de l'utilisateur
|
||||
\return int 1 en cas de succès, -1,-2,-3 en cas d'erreur, -4 si login phenix non défini
|
||||
*/
|
||||
function add($user)
|
||||
{
|
||||
global $langs;
|
||||
|
||||
dolibarr_syslog("Webcal::add user=".$user->id);
|
||||
|
||||
// Test si login webcal défini pour le user
|
||||
if (! $user->webcal_login)
|
||||
{
|
||||
$langs->load("other");
|
||||
$this->error=$langs->transnoentities("ErrorWebcalLoginNotDefined","<a href=\"".DOL_URL_ROOT."/user/fiche.php?id=".$user->id."\">".$user->login."</a>");
|
||||
dolibarr_syslog("Webcal::add ERROR ".$this->error);
|
||||
return -4;
|
||||
}
|
||||
|
||||
$this->localdb->begin();
|
||||
|
||||
// Recupère l'id max+1 dans la base webcalendar
|
||||
$id = $this->get_next_id();
|
||||
|
||||
if ($id > 0)
|
||||
{
|
||||
$cal_id = $id;
|
||||
$cal_create_by = $user->webcal_login;
|
||||
$cal_date = strftime('%Y%m%d', $this->date);
|
||||
$cal_time = strftime('%H%M%S', $this->date);
|
||||
$cal_mod_date = strftime('%Y%m%d', time());
|
||||
$cal_mod_time = strftime('%H%M%S', time());
|
||||
$cal_duration = round($this->duree / 60);
|
||||
$cal_priority = 2; // Medium avec 1.0, Haute avec 1.1
|
||||
// Rem: 1.0: 1=bas, 2=medium, 3=haut
|
||||
// 1.1: 1=haut, 2=haut, 3=haut, 4=medium ... 9=bas
|
||||
$cal_type = "E"; // Evenement de type "intemporel"
|
||||
$cal_access = "P"; // Acces publique
|
||||
$cal_name = $this->texte; // Title for event
|
||||
$cal_description = $this->desc; // Desc for event
|
||||
|
||||
$sql = "INSERT INTO webcal_entry (cal_id, cal_create_by,cal_date,cal_time,cal_mod_date, cal_mod_time,cal_duration,cal_priority,cal_type, cal_access, cal_name,cal_description)";
|
||||
$sql.= " VALUES ($cal_id, '$cal_create_by', '$cal_date', '$cal_time', '$cal_mod_date', '$cal_mod_time', $cal_duration, $cal_priority, '$cal_type', '$cal_access', '$cal_name','$cal_description')";
|
||||
|
||||
dolibarr_syslog("Webcal::add sql=".$sql);
|
||||
$resql=$this->localdb->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$sql = "INSERT INTO webcal_entry_user (cal_id, cal_login, cal_status)";
|
||||
$sql .= " VALUES ($cal_id, '$cal_create_by', 'A')";
|
||||
|
||||
$resql=$this->localdb->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
// OK
|
||||
$this->localdb->commit();
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->localdb->rollback();
|
||||
$this->error = $this->localdb->error() . '<br>' .$sql;
|
||||
dolibarr_syslog("Webcal::add ERROR ".$this->error);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->localdb->rollback();
|
||||
$this->error = $this->localdb->error() . '<br>' .$sql;
|
||||
dolibarr_syslog("Webcal::add ERROR ".$this->error);
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->localdb->rollback();
|
||||
$this->error = $this->localdb->error() . '<br>' .$sql;
|
||||
dolibarr_syslog("Webcal::add ERROR ".$this->error);
|
||||
return -3;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
\brief Obtient l'id suivant dans le webcalendar
|
||||
\return int Retourne l'id suivant dans webcalendar, <0 si ko
|
||||
*/
|
||||
function get_next_id()
|
||||
{
|
||||
$sql = "SELECT max(cal_id) as id FROM webcal_entry";
|
||||
global $langs;
|
||||
|
||||
dolibarr_syslog("Phenix::add user=".$user->id);
|
||||
|
||||
// Test si login phenix défini pour le user
|
||||
if (! $user->phenix_login)
|
||||
{
|
||||
$langs->load("other");
|
||||
$this->error=$langs->transnoentities("ErrorPhenixLoginNotDefined","<a href=\"".DOL_URL_ROOT."/user/fiche.php?id=".$user->id."\">".$user->login."</a>");
|
||||
dolibarr_syslog("Phenix::add ERROR ".$this->error);
|
||||
return -4;
|
||||
}
|
||||
|
||||
$this->localdb->begin();
|
||||
|
||||
// Recupère l'id max+1 dans la base webcalendar
|
||||
$id = $this->get_next_id();
|
||||
|
||||
if ($id > 0)
|
||||
{
|
||||
$age_id = $id;
|
||||
$age_createur_id = $user->id;
|
||||
$cal_date = strftime('%Y%m%d', $this->date);
|
||||
$cal_time = strftime('%H%M%S', $this->date);
|
||||
$cal_mod_date = strftime('%Y%m%d', time());
|
||||
$cal_mod_time = strftime('%H%M%S', time());
|
||||
$cal_duration = round($this->duree / 60);
|
||||
$cal_priority = 2; // Medium avec 1.0, Haute avec 1.1
|
||||
// Rem: 1.0: 1=bas, 2=medium, 3=haut
|
||||
// 1.1: 1=haut, 2=haut, 3=haut, 4=medium ... 9=bas
|
||||
$cal_type = "E"; // Evenement de type "intemporel"
|
||||
$cal_access = "P"; // Acces publique
|
||||
$cal_name = $this->texte; // Title for event
|
||||
$cal_description = $this->desc; // Desc for event
|
||||
|
||||
$sql = "INSERT INTO px_agenda (age_id, age_createur_id, cal_date, cal_time, cal_mod_date, cal_mod_time, cal_duration, cal_priority, cal_type, cal_access, cal_name,cal_description)";
|
||||
$sql.= " VALUES ($age_id, '$age_createur_id', '$cal_date', '$cal_time', '$cal_mod_date', '$cal_mod_time', $cal_duration, $cal_priority, '$cal_type', '$cal_access', '$cal_name','$cal_description')";
|
||||
|
||||
dolibarr_syslog("Phenix::add sql=".$sql);
|
||||
$resql=$this->localdb->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$obj=$this->localdb->fetch_object($resql);
|
||||
return ($obj->id + 1);
|
||||
$sql = "INSERT INTO webcal_entry_user (cal_id, cal_login, cal_status)";
|
||||
$sql .= " VALUES ($cal_id, '$cal_create_by', 'A')";
|
||||
|
||||
$resql=$this->localdb->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
// OK
|
||||
$this->localdb->commit();
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->localdb->rollback();
|
||||
$this->error = $this->localdb->error() . '<br>' .$sql;
|
||||
dolibarr_syslog("Phenix::add ERROR ".$this->error);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error=$this->localdb->error();
|
||||
return -1;
|
||||
$this->localdb->rollback();
|
||||
$this->error = $this->localdb->error() . '<br>' .$sql;
|
||||
dolibarr_syslog("Phenix::add ERROR ".$this->error);
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->localdb->rollback();
|
||||
$this->error = $this->localdb->error() . '<br>' .$sql;
|
||||
dolibarr_syslog("Phenix::add ERROR ".$this->error);
|
||||
return -3;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
\brief Obtient l'id suivant dans phenix
|
||||
\return int Retourne l'id suivant dans phenix, <0 si ko
|
||||
*/
|
||||
function get_next_id()
|
||||
{
|
||||
$sql = "SELECT max(age_id) as id FROM px_agenda";
|
||||
|
||||
$resql=$this->localdb->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$obj=$this->localdb->fetch_object($resql);
|
||||
return ($obj->id + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error=$this->localdb->error();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user