diff --git a/htdocs/actioncomm.class.php b/htdocs/actioncomm.class.php
index 595d80f2134..2c8cb31adb8 100644
--- a/htdocs/actioncomm.class.php
+++ b/htdocs/actioncomm.class.php
@@ -85,11 +85,11 @@ class ActionComm
/**
* \brief Ajout d'une action en base
- * \param author auteur de la creation de l'action
+ * \param user auteur de la creation de l'action
* \param notrigger 1 ne declenche pas les triggers, 0 sinon
* \return int id de l'action créée, < 0 si erreur
*/
- function add($author,$notrigger=0)
+ function add($user,$notrigger=0)
{
global $langs,$conf;
@@ -157,7 +157,7 @@ class ActionComm
$sql.= ($this->durationa >= 0?"'".$this->durationa."'":"null").",";
$sql.= "'".$this->type_id."', '".$this->societe->id."' ,'".addslashes($this->note)."',";
$sql.= ($this->contact->id > 0?"'".$this->contact->id."'":"null").",";
- $sql.= "'".$author->id."',";
+ $sql.= "'".$user->id."',";
$sql.= ($this->usertodo->id > 0?"'".$this->usertodo->id."'":"null").",";
$sql.= ($this->userdone->id > 0?"'".$this->userdone->id."'":"null").",";
$sql.= "'".addslashes($this->label)."','".$this->percentage."','".$this->priority."',";
@@ -177,7 +177,7 @@ class ActionComm
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
$interface=new Interfaces($this->db);
- $result=$interface->run_triggers('ACTION_CREATE',$this,$author,$langs,$conf);
+ $result=$interface->run_triggers('ACTION_CREATE',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers
}
diff --git a/htdocs/adherents/adherent.class.php b/htdocs/adherents/adherent.class.php
index 6b7cee5d1c4..a52a2d97acb 100644
--- a/htdocs/adherents/adherent.class.php
+++ b/htdocs/adherents/adherent.class.php
@@ -355,9 +355,9 @@ class Adherent extends CommonObject
\param notrigger 1 ne declenche pas les triggers, 0 sinon
\return int <0 si ko, >0 si ok
*/
- function create($user='',$notrigger=0)
+ function create($user,$notrigger=0)
{
- global $conf,$langs,$user;
+ global $conf,$langs;
// Verification parametres
if ($conf->global->ADHERENT_MAIL_REQUIRED && ! ValidEMail($this->email))
@@ -675,7 +675,7 @@ class Adherent extends CommonObject
*/
function delete($rowid)
{
- global $conf, $langs;
+ global $conf, $langs, $user;
$result = 0;
$this->db->begin();
@@ -1226,7 +1226,7 @@ class Adherent extends CommonObject
*/
function validate($user)
{
- global $user,$langs,$conf;
+ global $langs,$conf;
$sql = "UPDATE ".MAIN_DB_PREFIX."adherent SET";
$sql.= " statut=1, datevalid = now(),";
@@ -1267,7 +1267,7 @@ class Adherent extends CommonObject
*/
function resiliate($user)
{
- global $user,$langs,$conf;
+ global $langs,$conf;
$this->db->begin();
diff --git a/htdocs/adherents/fiche.php b/htdocs/adherents/fiche.php
index c66bbd70aeb..5f64bccb804 100644
--- a/htdocs/adherents/fiche.php
+++ b/htdocs/adherents/fiche.php
@@ -712,7 +712,7 @@ if ($action == 'create')
$nomfichier=$nomclass.".class.php";
//print DOL_DOCUMENT_ROOT."/includes/modules/security/generate/".$nomclass;
require_once(DOL_DOCUMENT_ROOT."/includes/modules/security/generate/".$nomfichier);
- $genhandler=new $nomclass($db,$conf,$lang,$user);
+ $genhandler=new $nomclass($db,$conf,$langs,$user);
$generated_password=$genhandler->getNewGeneratedPassword();
}
print '
| '.$langs->trans("Password").'* | ';
diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php
index 25910446092..c996b01a84c 100644
--- a/htdocs/comm/propal.php
+++ b/htdocs/comm/propal.php
@@ -197,7 +197,7 @@ if ($_POST['action'] == 'add' && $user->rights->propale->creer)
$propal->ref = $_POST['ref'];
$propal->statut = 0;
- $id = $propal->create_from();
+ $id = $propal->create_from($user);
}
else
{
diff --git a/htdocs/commande/commande.class.php b/htdocs/commande/commande.class.php
index 277456c369a..9216e68e720 100644
--- a/htdocs/commande/commande.class.php
+++ b/htdocs/commande/commande.class.php
@@ -101,7 +101,7 @@ class Commande extends CommonObject
*/
function create_from_propale($user, $propale_id)
{
- dolibarr_syslog("Commande.class::create_from_propale propale_id=$propale_id");
+ dolibarr_syslog("Commande::create_from_propale propale_id=$propale_id");
$propal = new Propal($this->db);
$propal->fetch($propale_id);
@@ -504,18 +504,18 @@ class Commande extends CommonObject
$this->db->begin();
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.'commande (';
- $sql.= 'fk_soc, date_creation, fk_user_author, fk_projet, date_commande, source, note, note_public, ref_client,';
+ $sql.= ' ref, fk_soc, date_creation, fk_user_author, fk_projet, date_commande, source, note, note_public, ref_client,';
$sql.= ' model_pdf, fk_cond_reglement, fk_mode_reglement, date_livraison, fk_adresse_livraison,';
$sql.= ' remise_absolue, remise_percent)';
- $sql.= ' VALUES ('.$this->socid.', now(), '.$user->id.', '.$this->projetid.',';
+ $sql.= " VALUES ('".$this->ref."',".$this->socid.', now(), '.$user->id.', '.$this->projetid.',';
$sql.= ' '.$this->db->idate($this->date_commande).',';
$sql.= ' '.$this->source.', ';
$sql.= " '".addslashes($this->note)."', ";
$sql.= " '".addslashes($this->note_public)."', ";
$sql.= " '".addslashes($this->ref_client)."', '".$this->modelpdf."', '".$this->cond_reglement_id."', '".$this->mode_reglement_id."',";
$sql.= " ".($this->date_livraison?"'".$this->db->idate($this->date_livraison)."'":"null").",";
- $sql.= " '".$this->adresse_livraison_id."',";
- $sql.= " '".$this->remise_absolue."',";
+ $sql.= " ".($this->adresse_livraison_id>0?$this->adresse_livraison_id:'NULL').",";
+ $sql.= " ".($this->remise_absolue>0?$this->remise_absolue:'NULL').",";
$sql.= " '".$this->remise_percent."')";
dolibarr_syslog("Commande::create sql=".$sql);
@@ -1670,9 +1670,10 @@ class Commande extends CommonObject
/**
- * \brief Supprime la commande
+ * \brief Supprime la commande
+ * \user User object
*/
- function delete()
+ function delete($user)
{
global $conf, $lang;
@@ -2177,11 +2178,12 @@ class CommandeLigne
/**
* \brief Supprime la ligne de commande en base
+ * \user User object
* \return int <0 si ko, >0 si ok
*/
- function delete()
+ function delete($user)
{
- global $langs, $conf, $user;
+ global $langs, $conf;
$sql = 'DELETE FROM '.MAIN_DB_PREFIX."commandedet WHERE rowid='".$this->id."';";
diff --git a/htdocs/contact.class.php b/htdocs/contact.class.php
index 1d32bc3c00d..25c06a7d8bf 100644
--- a/htdocs/contact.class.php
+++ b/htdocs/contact.class.php
@@ -1,7 +1,7 @@
* Copyright (C) 2004 Benoit Mortier
- * Copyright (C) 2004-2007 Laurent Destailleur
+ * Copyright (C) 2004-2008 Laurent Destailleur
* Copyright (C) 2005 Regis Houssin
* Copyright (C) 2007 Franky Van Liedekerke
*
@@ -18,15 +18,13 @@
* 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/contact.class.php
\ingroup societe
\brief Fichier de la classe des contacts
- \version $Revision$
+ \version $Id$
*/
require_once(DOL_DOCUMENT_ROOT ."/commonobject.class.php");
@@ -89,9 +87,10 @@ class Contact extends CommonObject
{
global $conf, $langs;
- // Nettoyage parametres
+ // Clean parameters
$this->name=trim($this->name);
if (! $this->socid) $this->socid = 0;
+ if (! $this->priv) $this->priv = 0;
$sql = "INSERT INTO ".MAIN_DB_PREFIX."socpeople (datec, fk_soc, name, fk_user_creat, priv)";
$sql.= " VALUES (now(),";
@@ -103,7 +102,6 @@ class Contact extends CommonObject
$sql.= ")";
dolibarr_syslog("Contact::create sql=".$sql);
-
$resql=$this->db->query($sql);
if ($resql)
{
@@ -169,7 +167,7 @@ class Contact extends CommonObject
$sql .= ", address='".addslashes($this->address)."'";
$sql .= ", cp='".addslashes($this->cp)."'";
$sql .= ", ville='".addslashes($this->ville)."'";
- $sql .= ", fk_pays='".addslashes($this->fk_pays)."'";
+ $sql .= ", fk_pays=".($this->fk_pays>0?$this->fk_pays:'NULL');
$sql .= ", poste='".addslashes($this->poste)."'";
$sql .= ", fax='".addslashes($this->fax)."'";
$sql .= ", email='".addslashes($this->email)."'";
@@ -186,7 +184,8 @@ class Contact extends CommonObject
$result = $this->db->query($sql);
if (! $result)
{
- $this->error=$this->db->error().' sql='.$sql;
+ $this->error=$this->db->lasterror().' sql='.$sql;
+ dolibarr_syslog("Contact::update Error ".$this->error,LOG_ERR);
return -1;
}
@@ -541,7 +540,7 @@ class Contact extends CommonObject
*/
function delete($notrigger=0)
{
- global $conf, $langs;
+ global $conf, $langs, $user;
$error=0;
diff --git a/htdocs/facture.class.php b/htdocs/facture.class.php
index 4b1153eb20c..8c9d71a6792 100644
--- a/htdocs/facture.class.php
+++ b/htdocs/facture.class.php
@@ -196,8 +196,10 @@ class Facture extends CommonObject
$sql.= ' fk_facture_source, fk_user_author, fk_projet,';
$sql.= ' fk_cond_reglement, fk_mode_reglement, date_lim_reglement, model_pdf)';
$sql.= ' VALUES (';
- $sql.= "'(PROV)', '".$this->type."', '$socid', now(), '$totalht', '".$this->remise_absolue."'";
- $sql.= ",'".$this->remise_percent."', ".$this->db->idate($this->date);
+ $sql.= "'(PROV)', '".$this->type."', '".$socid."', now(), '".$totalht."'";
+ $sql.= ",".($this->remise_absolue>0?$this->remise_absolue:'NULL');
+ $sql.= ",".($this->remise_percent>0?$this->remise_percent:'NULL');
+ $sql.= ",".$this->db->idate($this->date);
$sql.= ",".($this->note?"'".addslashes($this->note)."'":"null");
$sql.= ",".($this->note_public?"'".addslashes($this->note_public)."'":"null");
$sql.= ",".($this->ref_client?"'".addslashes($this->ref_client)."'":"null");
@@ -1487,6 +1489,7 @@ class Facture extends CommonObject
/**
* \brief Supprime une ligne facture de la base
* \param rowid Id de la ligne de facture a supprimer
+ * \param user User object
* \return int <0 if KO, >0 if OK
*/
function deleteline($rowid, $user='')
@@ -2594,7 +2597,7 @@ class FactureLigne
*/
function insert($notrigger=0)
{
- global $langs;
+ global $langs,$user,$conf;
dolibarr_syslog("FactureLigne::Insert rang=".$this->rang, LOG_DEBUG);
diff --git a/htdocs/fichinter/fichinter.class.php b/htdocs/fichinter/fichinter.class.php
index b0b1bf013ca..3b8995b4389 100644
--- a/htdocs/fichinter/fichinter.class.php
+++ b/htdocs/fichinter/fichinter.class.php
@@ -218,6 +218,8 @@ class Fichinter extends CommonObject
*/
function valid($user, $outputdir)
{
+ global $langs, $conf;
+
$sql = "UPDATE ".MAIN_DB_PREFIX."fichinter";
$sql.= " SET fk_statut = 1, date_valid=now(), fk_user_valid=".$user->id;
$sql.= " WHERE rowid = ".$this->id." AND fk_statut = 0";
diff --git a/htdocs/fourn/fournisseur.commande.class.php b/htdocs/fourn/fournisseur.commande.class.php
index 2e2ecf465dd..1a49b9299f7 100644
--- a/htdocs/fourn/fournisseur.commande.class.php
+++ b/htdocs/fourn/fournisseur.commande.class.php
@@ -203,6 +203,8 @@ class CommandeFournisseur extends Commande
*/
function valid($user)
{
+ global $langs,$conf;
+
dolibarr_syslog("CommandeFournisseur.class::Valid");
$result = 0;
if ($user->rights->fournisseur->commande->valider)
@@ -269,6 +271,8 @@ class CommandeFournisseur extends Commande
*/
function Cancel($user)
{
+ global $langs,$conf;
+
//dolibarr_syslog("CommandeFournisseur::Cancel");
$result = 0;
if ($user->rights->fournisseur->commande->annuler)
@@ -460,6 +464,8 @@ class CommandeFournisseur extends Commande
*/
function approve($user)
{
+ global $langs,$conf;
+
dolibarr_syslog("CommandeFournisseur::Approve");
$result = 0;
if ($user->rights->fournisseur->commande->approuver)
@@ -601,6 +607,8 @@ class CommandeFournisseur extends Commande
*/
function create($user)
{
+ global $langs,$conf;
+
dolibarr_syslog("CommandeFournisseur::Create soc id=".$this->socid);
$this->db->begin();
@@ -899,6 +907,8 @@ class CommandeFournisseur extends Commande
*/
function delete()
{
+ global $langs,$conf;
+
$err = 0;
$this->db->begin();
diff --git a/htdocs/includes/triggers/interface_modAgenda_ActionsAuto.class.php b/htdocs/includes/triggers/interface_modAgenda_ActionsAuto.class.php
index aaa4f98aee6..dd5607e7e34 100644
--- a/htdocs/includes/triggers/interface_modAgenda_ActionsAuto.class.php
+++ b/htdocs/includes/triggers/interface_modAgenda_ActionsAuto.class.php
@@ -119,7 +119,7 @@ class InterfaceActionsAuto
if ($action == 'COMPANY_CREATE')
{
dolibarr_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
- $langs->load("companies");
+ $langs->load("other");
$object->actiontypecode='AC_OTH';
$object->actionmsg2=$langs->transnoentities("NewCompanyToDolibarr",$object->nom);
@@ -130,6 +130,7 @@ class InterfaceActionsAuto
$object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login;
$object->sendtoid=0;
+ $object->socid=$object->id;
$object->facid=$object->orderrowid=$object->propalrowid=0;
$ok=1;
}
diff --git a/htdocs/propal.class.php b/htdocs/propal.class.php
index 582bd0cd924..3e66bd8bb2f 100644
--- a/htdocs/propal.class.php
+++ b/htdocs/propal.class.php
@@ -1011,7 +1011,9 @@ class Propal extends CommonObject
*/
function cloture($user, $statut, $note)
{
- $this->statut = $statut;
+ global $langs,$conf;
+
+ $this->statut = $statut;
$this->db->begin();
@@ -1634,13 +1636,13 @@ class Propal extends CommonObject
* \return int l'id du nouvel objet propal en base si ok, <0 si ko
* \see create
*/
- function create_from()
+ function create_from($user)
{
- global $conf;
+ global $conf,$lang;
$this->fin_validite = $this->datep + ($this->duree_validite * 24 * 3600);
- // on v�rifie si la ref n'est pas utilis�e
+ // on verifie si la ref n'est pas utilisee
$soc = new Societe($this->db);
$soc->fetch($this->socid);
$this->verifyNumRef($soc);
diff --git a/htdocs/soc.php b/htdocs/soc.php
index 4bf41cc1e26..73b190f9d05 100644
--- a/htdocs/soc.php
+++ b/htdocs/soc.php
@@ -66,10 +66,12 @@ if ((! $_POST["getcustomercode"] && ! $_POST["getsuppliercode"])
if ($_REQUEST["private"] == 1)
{
+ $soc->particulier = $_REQUEST["private"];
+
$soc->nom = $_POST["nom"].' '.$_POST["prenom"];
$soc->nom_particulier = $_POST["nom"];
$soc->prenom = $_POST["prenom"];
- $soc->particulier = $_REQUEST["private"];
+ $soc->civilite_id = $_POST["civilite_id"];
}
else
{
@@ -145,11 +147,36 @@ if ((! $_POST["getcustomercode"] && ! $_POST["getsuppliercode"])
if ($_POST["action"] == 'add')
{
+ $db->begin();
+
$result = $soc->create($user);
+ if ($result >= 0)
+ {
+ if ($soc->particulier)
+ {
+ dolibarr_syslog("This thirdparty is a personal people",LOG_DEBUG);
+ $contact=new Contact($db);
+
+ $contact->civilite_id = $soc->civilite_id;
+ $contact->name=$soc->name;
+ $contact->firstname=$soc->firstname;
+ $contact->address=$soc->address;
+ $contact->cp=$soc->cp;
+ $contact->ville=$soc->ville;
+ $contact->fk_pays=$soc->fk_pays;
+ $contact->socid=$soc->id; // fk_soc
+ $contact->status=1;
+ $contact->priv=0;
+
+ $result=$contact->create($user);
+ }
+ }
if ($result >= 0)
{
- if ( $soc->client == 1 )
+ $db->commit();
+
+ if ( $soc->client == 1 )
{
Header("Location: comm/fiche.php?socid=".$soc->id);
return;
@@ -171,6 +198,8 @@ if ((! $_POST["getcustomercode"] && ! $_POST["getsuppliercode"])
}
else
{
+ $db->rollback();
+
$langs->load("errors");
$mesg=$langs->trans($soc->error);
$_GET["action"]='create';
@@ -353,6 +382,10 @@ if ($_POST["getcustomercode"] || $_POST["getsuppliercode"] ||
{
print '| '.$langs->trans('FirstName').' | | ';
print ' | ';
+
+ print '| '.$langs->trans("UserTitle").' | ';
+ print $form->select_civilite($contact->civilite_id).' | ';
+ print ' | ';
}
// Client / Prospect
diff --git a/htdocs/societe.class.php b/htdocs/societe.class.php
index 736988ec18e..1415b459b53 100644
--- a/htdocs/societe.class.php
+++ b/htdocs/societe.class.php
@@ -1,6 +1,6 @@
- * Copyright (C) 2004-2007 Laurent Destailleur
+ * Copyright (C) 2004-2008 Laurent Destailleur
* Copyright (C) 2004 Eric Seigne
* Copyright (C) 2003 Brian Fraval
* Copyright (C) 2006 Andre Cianfarani
@@ -41,7 +41,7 @@ class Societe extends CommonObject
var $error;
var $errors=array();
var $table_element = 'societe';
-
+
var $id;
var $nom;
var $nom_particulier;
@@ -303,7 +303,7 @@ class Societe extends CommonObject
*/
function update($id, $user='', $call_trigger=1, $allowmodcodeclient=0, $allowmodcodefournisseur=0)
{
- global $langs;
+ global $langs,$conf;
dolibarr_syslog("Societe::Update id=".$id." call_trigger=".$call_triger." allowmodcodeclient=".$allowmodcodeclient." allowmodcodefournisseur=".$allowmodcodefournisseur);
@@ -703,6 +703,8 @@ class Societe extends CommonObject
*/
function delete($id)
{
+ global $user,$langs,$conf;
+
dolibarr_syslog("Societe::Delete");
$sqr = 0;
diff --git a/htdocs/user.class.php b/htdocs/user.class.php
index 8e59b0c5335..e6d9758d4dc 100644
--- a/htdocs/user.class.php
+++ b/htdocs/user.class.php
@@ -637,7 +637,7 @@ class User extends CommonObject
*/
function delete()
{
- global $conf,$langs;
+ global $user,$conf,$langs;
$this->db->begin();
diff --git a/htdocs/user/fiche.php b/htdocs/user/fiche.php
index 69bc3536ca9..bbd16b3fb82 100644
--- a/htdocs/user/fiche.php
+++ b/htdocs/user/fiche.php
@@ -550,7 +550,7 @@ if (($action == 'create') || ($action == 'adduserldap'))
$nomfichier=$nomclass.".class.php";
//print DOL_DOCUMENT_ROOT."/includes/modules/security/generate/".$nomclass;
require_once(DOL_DOCUMENT_ROOT."/includes/modules/security/generate/".$nomfichier);
- $genhandler=new $nomclass($db,$conf,$lang,$user);
+ $genhandler=new $nomclass($db,$conf,$langs,$user);
$generated_password=$genhandler->getNewGeneratedPassword();
}
}
diff --git a/htdocs/usergroup.class.php b/htdocs/usergroup.class.php
index 2370e7becea..f5d01860a80 100644
--- a/htdocs/usergroup.class.php
+++ b/htdocs/usergroup.class.php
@@ -346,7 +346,7 @@ class UserGroup
*/
function delete()
{
- global $conf,$langs;
+ global $user,$conf,$langs;
$this->db->begin();
@@ -387,7 +387,7 @@ class UserGroup
*/
function create()
{
- global $conf,$langs;
+ global $user,$conf,$langs;
$sql = "INSERT into ".MAIN_DB_PREFIX."usergroup (datec,nom)";
$sql .= " VALUES(now(),'".addslashes($this->nom)."')";
@@ -424,7 +424,7 @@ class UserGroup
*/
function update($notrigger=0)
{
- global $conf, $langs;
+ global $user, $conf, $langs;
$sql = "UPDATE ".MAIN_DB_PREFIX."usergroup SET ";
$sql .= " nom = '".addslashes($this->nom)."',";
|