2
0
forked from Wavyzz/dolibarr

Fix: Several bugs

This commit is contained in:
Laurent Destailleur
2008-04-09 23:07:13 +00:00
parent 6b9918663b
commit c55e279b11
16 changed files with 101 additions and 47 deletions

View File

@@ -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<63><72>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
}

View File

@@ -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();

View File

@@ -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 '<tr><td>'.$langs->trans("Password").'*</td><td>';

View File

@@ -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
{

View File

@@ -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."';";

View File

@@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2002-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
* Copyright (C) 2004-2007 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2007 Franky Van Liedekerke <franky.van.liedekerker@telenet.be>
*
@@ -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;

View File

@@ -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);

View File

@@ -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";

View File

@@ -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();

View File

@@ -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;
}

View File

@@ -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<EFBFBD>rifie si la ref n'est pas utilis<EFBFBD>e
// on verifie si la ref n'est pas utilisee
$soc = new Societe($this->db);
$soc->fetch($this->socid);
$this->verifyNumRef($soc);

View File

@@ -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 '<tr><td>'.$langs->trans('FirstName').'</td><td><input type="text" size="30" name="prenom" value="'.$soc->firstname.'"></td>';
print '<td colspan=2>&nbsp;</td></tr>';
print '<tr><td>'.$langs->trans("UserTitle").'</td><td>';
print $form->select_civilite($contact->civilite_id).'</td>';
print '<td colspan=2>&nbsp;</td></tr>';
}
// Client / Prospect

View File

@@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2002-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2007 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2003 Brian Fraval <brian@fraval.org>
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
@@ -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;

View File

@@ -637,7 +637,7 @@ class User extends CommonObject
*/
function delete()
{
global $conf,$langs;
global $user,$conf,$langs;
$this->db->begin();

View File

@@ -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();
}
}

View File

@@ -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)."',";