diff --git a/htdocs/comm/action/fiche.php b/htdocs/comm/action/fiche.php
index b6da5a0ce74..a08dd71f377 100644
--- a/htdocs/comm/action/fiche.php
+++ b/htdocs/comm/action/fiche.php
@@ -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 '';
}
else
{
print '
| '.$langs->trans("AddCalendarEntry").' | ';
- print 'webcal->syncro=='always' || $conf->webcal->syncro=='yesbydefault')?' checked':'').'> | ';
+ print 'global->PHPWEBCALENDAR_SYNCRO=='always' || $conf->global->PHPWEBCALENDAR_SYNCRO=='yesbydefault')?' checked':'').'> | ';
print '
';
$nbtr++;
}
diff --git a/htdocs/compta/facture/apercu.php b/htdocs/compta/facture/apercu.php
index 4bf9d8be4c2..acd76de0b43 100644
--- a/htdocs/compta/facture/apercu.php
+++ b/htdocs/compta/facture/apercu.php
@@ -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 '';
+ $rowspan=3;
// Societe
print '| '.$langs->trans("Company").' | ';
@@ -122,7 +116,7 @@ if ($_GET["facid"] > 0)
print '
| '.$langs->trans("Date").' | ';
print ''.dolibarr_print_date($fac->date,"%A %d %B %Y").' | ';
print ''.$langs->trans("DateClosing").' | ' . 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 " |
";
// Conditions et modes de réglement
@@ -148,27 +142,32 @@ if ($_GET["facid"] > 0)
{
print ' ';
}
- print " ";
}
else
{
print ' | ';
- print " | ";
}
- print '';
+ print ' | ';
+
+ // partie Droite sur $rowspan lignes
+ print '';
+
/*
- * 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 " |
\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 ''.$langs->trans("ErrorNoImagickReadimage").'';
}
}
}
-
- /*
- *
- *
- */
-
print "";
- print "| ".$langs->trans("Author")." | $author->fullname | ";
print '
| '.$langs->trans("GlobalDiscount").' | ';
print ''.$fac->remise_percent.' | ';
@@ -259,13 +253,20 @@ if ($_GET["facid"] > 0)
}
}
+// Si fichier png PDF d'1 page trouvé
if (file_exists($fileimage))
{
print '
';
}
-print '';
+// Si fichier png PDF de plus d'1 page trouvé
+elseif (file_exists($fileimagebis))
+ {
+ print '
';
+ }
+print '';
+
$db->close();
llxFooter('$Date$ - $Revision$');
diff --git a/htdocs/contrat/contrat.class.php b/htdocs/contrat/contrat.class.php
index c0692ebf9a0..8e745059dc8 100644
--- a/htdocs/contrat/contrat.class.php
+++ b/htdocs/contrat/contrat.class.php
@@ -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;
}
}
diff --git a/htdocs/contrat/fiche.php b/htdocs/contrat/fiche.php
index bcb01624007..b1333fe4a23 100644
--- a/htdocs/contrat/fiche.php
+++ b/htdocs/contrat/fiche.php
@@ -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')
diff --git a/htdocs/facture.class.php b/htdocs/facture.class.php
index f872a3f726a..154bdf2bacc 100644
--- a/htdocs/facture.class.php
+++ b/htdocs/facture.class.php
@@ -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);
diff --git a/htdocs/includes/triggers/interface_webcal.class.php b/htdocs/includes/triggers/interface_webcal.class.php
index f933b72f555..59077a3e1c8 100644
--- a/htdocs/includes/triggers/interface_webcal.class.php
+++ b/htdocs/includes/triggers/interface_webcal.class.php
@@ -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;
}
diff --git a/htdocs/langs/en_US/other.lang b/htdocs/langs/en_US/other.lang
index a034b69238a..65c881f02ef 100644
--- a/htdocs/langs/en_US/other.lang
+++ b/htdocs/langs/en_US/other.lang
@@ -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
\ No newline at end of file
+ChooseIfANewWindowMustBeOpenedOnClickOnBookmark=Choose if page opened by link must appear on current or new window
+NewCompanyToDolibarr=Company %s added into Dolibarr
\ No newline at end of file
diff --git a/htdocs/langs/fr_FR/other.lang b/htdocs/langs/fr_FR/other.lang
index 5a827c51ef1..b3817ac740f 100644
--- a/htdocs/langs/fr_FR/other.lang
+++ b/htdocs/langs/fr_FR/other.lang
@@ -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
\ No newline at end of file
+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
\ No newline at end of file
diff --git a/htdocs/master.inc.php b/htdocs/master.inc.php
index 1c49d90f509..c23bb222ce1 100644
--- a/htdocs/master.inc.php
+++ b/htdocs/master.inc.php
@@ -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";
diff --git a/htdocs/societe.class.php b/htdocs/societe.class.php
index b3ee65c8b59..05031a7defb 100644
--- a/htdocs/societe.class.php
+++ b/htdocs/societe.class.php
@@ -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)