Fix: fix not initialized variables

This commit is contained in:
Laurent Destailleur 2011-12-05 18:36:54 +01:00
parent b0aff1c927
commit ebea7f6c97
22 changed files with 179 additions and 125 deletions

View File

@ -121,11 +121,12 @@ class Categorie
/** /**
* Add category into database * Add category into database
* *
* @return int -1 : erreur SQL * @param User $user Object user
* -2 : nouvel ID inconnu * @return int -1 : erreur SQL
* -3 : categorie invalide * -2 : nouvel ID inconnu
* -3 : categorie invalide
*/ */
function create() function create($user='')
{ {
global $conf,$langs; global $conf,$langs;
$langs->load('categories'); $langs->load('categories');
@ -203,11 +204,12 @@ class Categorie
/** /**
* Update category * Update category
* *
* @return int 1 : OK * @param User $user Object user
* -1 : SQL error * @return int 1 : OK
* -2 : invalid category * -1 : SQL error
* -2 : invalid category
*/ */
function update() function update($user='')
{ {
global $conf, $langs; global $conf, $langs;
@ -883,12 +885,12 @@ class Categorie
$sql.= " AND c.label='".$this->db->escape($this->label)."'"; $sql.= " AND c.label='".$this->db->escape($this->label)."'";
} }
dol_syslog("Categorie::already_exists sql=".$sql); dol_syslog("Categorie::already_exists sql=".$sql);
$res = $this->db->query($sql); $resql = $this->db->query($sql);
if ($res) if ($resql)
{ {
if($this->db->num_rows($resql) > 0) // Checking for empty resql if ($this->db->num_rows($resql) > 0) // Checking for empty resql
{ {
$obj = $this->db->fetch_array($res); $obj = $this->db->fetch_array($resql);
/* If object called create, obj cannot have is id. /* If object called create, obj cannot have is id.
* If object called update, he mustn't have the same label as an other category for this mother. * If object called update, he mustn't have the same label as an other category for this mother.
* So if the result have the same id, update is not for label, and if result have an other one, * So if the result have the same id, update is not for label, and if result have an other one,

View File

@ -381,7 +381,6 @@ class Propal extends CommonObject
$this->line->subprice=$pu_ht; $this->line->subprice=$pu_ht;
$this->line->rang=$rangtouse; $this->line->rang=$rangtouse;
$this->line->info_bits=$info_bits; $this->line->info_bits=$info_bits;
$this->line->fk_remise_except=$fk_remise_except;
$this->line->total_ht=$total_ht; $this->line->total_ht=$total_ht;
$this->line->total_tva=$total_tva; $this->line->total_tva=$total_tva;
$this->line->total_localtax1=$total_localtax1; $this->line->total_localtax1=$total_localtax1;
@ -1149,6 +1148,7 @@ class Propal extends CommonObject
{ {
global $conf,$langs; global $conf,$langs;
$error=0;
$now=dol_now(); $now=dol_now();
if ($user->rights->propale->valider) if ($user->rights->propale->valider)
@ -1477,7 +1477,8 @@ class Propal extends CommonObject
global $langs,$conf; global $langs,$conf;
$this->statut = $statut; $this->statut = $statut;
$error=0;
$this->db->begin(); $this->db->begin();
$sql = "UPDATE ".MAIN_DB_PREFIX."propal"; $sql = "UPDATE ".MAIN_DB_PREFIX."propal";
@ -2536,13 +2537,17 @@ class PropaleLigne
} }
/** /**
* \brief Insert object line propal in database * Insert object line propal in database
* \return int <0 if KO, >0 if OK *
* @param int $notrigger 1=no trigger ran
* @return int <0 if KO, >0 if OK
*/ */
function insert($notrigger=0) function insert($notrigger=0)
{ {
global $conf,$langs,$user; global $conf,$langs,$user;
$error=0;
dol_syslog("PropaleLigne::insert rang=".$this->rang); dol_syslog("PropaleLigne::insert rang=".$this->rang);
// Clean parameters // Clean parameters
@ -2599,8 +2604,6 @@ class PropaleLigne
$resql=$this->db->query($sql); $resql=$this->db->query($sql);
if ($resql) if ($resql)
{ {
$this->rang=$rangmax;
$this->rowid=$this->db->last_insert_id(MAIN_DB_PREFIX.'propaldet'); $this->rowid=$this->db->last_insert_id(MAIN_DB_PREFIX.'propaldet');
if (! $notrigger) if (! $notrigger)
{ {
@ -2632,6 +2635,7 @@ class PropaleLigne
{ {
global $conf,$langs,$user; global $conf,$langs,$user;
$error=0;
$this->db->begin(); $this->db->begin();
$sql = "DELETE FROM ".MAIN_DB_PREFIX."propaldet WHERE rowid = ".$this->rowid; $sql = "DELETE FROM ".MAIN_DB_PREFIX."propaldet WHERE rowid = ".$this->rowid;
@ -2667,6 +2671,8 @@ class PropaleLigne
{ {
global $conf,$langs,$user; global $conf,$langs,$user;
$error=0;
// Clean parameters // Clean parameters
if (empty($this->tva_tx)) $this->tva_tx=0; if (empty($this->tva_tx)) $this->tva_tx=0;
if (empty($this->localtax1_tx)) $this->localtax1_tx=0; if (empty($this->localtax1_tx)) $this->localtax1_tx=0;

View File

@ -99,15 +99,13 @@ class Commande extends CommonObject
/** /**
* Constructor * Constructor
* *
* @param DoliDB $DB Database handler * @param DoliDB $db Database handler
*/ */
function Commande($DB) function Commande($db)
{ {
global $langs; global $langs;
$langs->load('orders'); $langs->load('orders');
$this->db = $DB; $this->db = $db;
$this->socid = $socid;
$this->id = $commandeid;
$this->remise = 0; $this->remise = 0;
$this->remise_percent = 0; $this->remise_percent = 0;
@ -447,9 +445,10 @@ class Commande extends CommonObject
} }
/** /**
* Close order * Close order
* @param user Objet user that close *
* @return int <0 if KO, >0 if OK * @param user Objet user that close
* @return int <0 if KO, >0 if OK
*/ */
function cloture($user) function cloture($user)
{ {
@ -501,13 +500,15 @@ class Commande extends CommonObject
} }
/** /**
* \brief Cancel an order * Cancel an order
* \return int <0 if KO, >0 if OK * If stock is decremented on order validation, we must reincrement it
* \remarks If stock is decremented on order validation, we must reincrement it *
* @param int $idwarehouse Id warehouse to use for stock change.
* @return int <0 if KO, >0 if OK
*/ */
function cancel($user) function cancel($user, $idwarehouse=-1)
{ {
global $conf; global $conf,$langs;
$error=0; $error=0;
@ -526,17 +527,20 @@ class Commande extends CommonObject
// If stock is decremented on validate order, we must reincrement it // If stock is decremented on validate order, we must reincrement it
if ($conf->stock->enabled && $conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER == 1) if ($conf->stock->enabled && $conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER == 1)
{ {
require_once(DOL_DOCUMENT_ROOT."/product/stock/class/mouvementstock.class.php"); require_once(DOL_DOCUMENT_ROOT."/product/stock/class/mouvementstock.class.php");
$langs->load("agenda"); $langs->load("agenda");
if ($this->lines[$i]->fk_product > 0) $num=count($this->lines);
{ for ($i = 0; $i < $num; $i++)
$mouvP = new MouvementStock($this->db); {
// We increment stock of product (and sub-products) if ($this->lines[$i]->fk_product > 0)
$entrepot_id = "1"; //Todo: ajouter possibilite de choisir l'entrepot {
$result=$mouvP->reception($user, $this->lines[$i]->fk_product, $entrepot_id, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("OrderCanceledInDolibarr",$this->ref)); $mouvP = new MouvementStock($this->db);
if ($result < 0) { $error++; } // We increment stock of product (and sub-products)
} $result=$mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("OrderCanceledInDolibarr",$this->ref));
if ($result < 0) { $error++; }
}
}
} }
if (! $error) if (! $error)
@ -604,7 +608,6 @@ class Commande extends CommonObject
dol_syslog("Commande::create ".$this->error, LOG_ERR); dol_syslog("Commande::create ".$this->error, LOG_ERR);
return -1; return -1;
} }
if (! $remise) $remise=0;
if (! $this->fk_project) $this->fk_project = 0; if (! $this->fk_project) $this->fk_project = 0;
// $date_commande is deprecated // $date_commande is deprecated
@ -1299,14 +1302,14 @@ class Commande extends CommonObject
} }
else else
{ {
dol_syslog('Commande::Fetch Error rowid='.$rowid.' numrows=0 sql='.$sql); dol_syslog('Commande::Fetch Error rowid='.$id.' numrows=0 sql='.$sql);
$this->error='Order with id '.$rowid.' not found sql='.$sql; $this->error='Order with id '.$id.' not found sql='.$sql;
return -2; return -2;
} }
} }
else else
{ {
dol_syslog('Commande::Fetch Error rowid='.$rowid.' Erreur dans fetch de la commande'); dol_syslog('Commande::Fetch Error rowid='.$id.' Erreur dans fetch de la commande');
$this->error=$this->db->error(); $this->error=$this->db->error();
return -1; return -1;
} }
@ -2194,8 +2197,8 @@ class Commande extends CommonObject
$qty=price2num($qty); $qty=price2num($qty);
$pu = price2num($pu); $pu = price2num($pu);
$txtva=price2num($txtva); $txtva=price2num($txtva);
$txlocaltax1=price2num($txtlocaltax1); $txlocaltax1=price2num($txlocaltax1);
$txlocaltax2=price2num($txtlocaltax2); $txlocaltax2=price2num($txlocaltax2);
// Calcul du total TTC et de la TVA pour la ligne a partir de // Calcul du total TTC et de la TVA pour la ligne a partir de
// qty, pu, remise_percent et txtva // qty, pu, remise_percent et txtva
@ -2287,15 +2290,16 @@ class Commande extends CommonObject
/** /**
* Delete the customer order * Delete the customer order
* @param user User object *
* @return int <=0 if KO, >0 if OK * @param User $user User object
* @return int <=0 if KO, >0 if OK
*/ */
function delete($user) function delete($user)
{ {
global $conf, $langs; global $conf, $langs;
require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"); require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php");
$err = 0; $error = 0;
$this->db->begin(); $this->db->begin();
@ -2305,7 +2309,7 @@ class Commande extends CommonObject
if (! $this->db->query($sql) ) if (! $this->db->query($sql) )
{ {
dol_syslog("CustomerOrder::delete error", LOG_ERR); dol_syslog("CustomerOrder::delete error", LOG_ERR);
$err++; $error++;
} }
// Delete order // Delete order
@ -2314,7 +2318,7 @@ class Commande extends CommonObject
if (! $this->db->query($sql) ) if (! $this->db->query($sql) )
{ {
dol_syslog("CustomerOrder::delete error", LOG_ERR); dol_syslog("CustomerOrder::delete error", LOG_ERR);
$err++; $error++;
} }
// Delete linked object // Delete linked object
@ -2326,7 +2330,7 @@ class Commande extends CommonObject
if (! $this->db->query($sql) ) if (! $this->db->query($sql) )
{ {
dol_syslog("CustomerOrder::delete error", LOG_ERR); dol_syslog("CustomerOrder::delete error", LOG_ERR);
$err++; $error++;
} }
// Delete linked contacts // Delete linked contacts
@ -2334,7 +2338,7 @@ class Commande extends CommonObject
if ($res < 0) if ($res < 0)
{ {
dol_syslog("CustomerOrder::delete error", LOG_ERR); dol_syslog("CustomerOrder::delete error", LOG_ERR);
$err++; $error++;
} }
// On efface le repertoire de pdf provisoire // On efface le repertoire de pdf provisoire
@ -2365,7 +2369,7 @@ class Commande extends CommonObject
} }
} }
if ($err == 0) if ($error == 0)
{ {
// Appel des triggers // Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"); include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php");
@ -2387,6 +2391,7 @@ class Commande extends CommonObject
/** /**
* Load indicators for dashboard (this->nbtodo and this->nbtodolate) * Load indicators for dashboard (this->nbtodo and this->nbtodolate)
*
* @param user Objet user * @param user Objet user
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
@ -2935,6 +2940,8 @@ class OrderLine
{ {
global $conf, $user, $langs; global $conf, $user, $langs;
$error=0;
$sql = 'DELETE FROM '.MAIN_DB_PREFIX."commandedet WHERE rowid='".$this->rowid."';"; $sql = 'DELETE FROM '.MAIN_DB_PREFIX."commandedet WHERE rowid='".$this->rowid."';";
dol_syslog("OrderLine::delete sql=".$sql); dol_syslog("OrderLine::delete sql=".$sql);
@ -2968,6 +2975,8 @@ class OrderLine
{ {
global $langs, $conf, $user; global $langs, $conf, $user;
$error=0;
dol_syslog("OrderLine::insert rang=".$this->rang); dol_syslog("OrderLine::insert rang=".$this->rang);
// Clean parameters // Clean parameters
@ -3065,6 +3074,8 @@ class OrderLine
{ {
global $conf,$langs,$user; global $conf,$langs,$user;
$error=0;
// Clean parameters // Clean parameters
if (empty($this->tva_tx)) $this->tva_tx=0; if (empty($this->tva_tx)) $this->tva_tx=0;
if (empty($this->localtax1_tx)) $this->localtax1_tx=0; if (empty($this->localtax1_tx)) $this->localtax1_tx=0;

View File

@ -864,7 +864,6 @@ class Account extends CommonObject
{ {
$this->nbtodo++; $this->nbtodo++;
if ($this->db->jdate($obj->datefin) < ($now - $conf->bank->rappro->warning_delay)) $this->nbtodolate++; if ($this->db->jdate($obj->datefin) < ($now - $conf->bank->rappro->warning_delay)) $this->nbtodolate++;
if ($obj->rappro) $foundaccounttoconciliate++;
} }
return $num; return $num;
} }

View File

@ -182,8 +182,8 @@ class Don extends CommonObject
$this->specimen=1; $this->specimen=1;
$this->nom = 'Doe'; $this->nom = 'Doe';
$this->prenom = 'John'; $this->prenom = 'John';
$this->socid = $socids[$socid]; $this->socid = 1;
$this->date = time(); $this->date = dol_now();
$this->amount = 100; $this->amount = 100;
$this->public = 1; $this->public = 1;
$this->societe = 'The Company'; $this->societe = 'The Company';

View File

@ -190,9 +190,10 @@ class FactureRec extends Facture
/** /**
* \brief Recupere l'objet facture et ses lignes de factures * Recupere l'objet facture et ses lignes de factures
* \param rowid id de la facture a recuperer *
* \return int >0 si ok, <0 si ko * @param int $rowid Id de la facture a recuperer
* @return int >0 si ok, <0 si ko
*/ */
function fetch($rowid) function fetch($rowid)
{ {
@ -209,7 +210,7 @@ class FactureRec extends Facture
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON el.fk_target = f.rowid AND el.targettype = 'facture'"; // TODO remplacer par une fonction $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON el.fk_target = f.rowid AND el.targettype = 'facture'"; // TODO remplacer par une fonction
$sql.= ' WHERE f.rowid='.$rowid; $sql.= ' WHERE f.rowid='.$rowid;
dol_syslog("FactureRec::Fetch rowid=".$rowid.", societe_id=".$socid." sql=".$sql, LOG_DEBUG); dol_syslog("FactureRec::Fetch rowid=".$rowid." sql=".$sql, LOG_DEBUG);
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) if ($result)
{ {
@ -404,7 +405,9 @@ class FactureRec extends Facture
/** /**
* \brief Add a line to invoice * Add a line to invoice
*
* @return int <0 if KO, >0 if OK
*/ */
function addline($facid, $desc, $pu_ht, $qty, $txtva, $fk_product=0, $remise_percent=0, $price_base_type='HT', $info_bits=0, $fk_remise_except='', $pu_ttc=0, $type=0, $rang=-1, $special_code=0) function addline($facid, $desc, $pu_ht, $qty, $txtva, $fk_product=0, $remise_percent=0, $price_base_type='HT', $info_bits=0, $fk_remise_except='', $pu_ttc=0, $type=0, $rang=-1, $special_code=0)
{ {
@ -420,7 +423,6 @@ class FactureRec extends Facture
$remise_percent=price2num($remise_percent); $remise_percent=price2num($remise_percent);
$qty=price2num($qty); $qty=price2num($qty);
if (! $qty) $qty=1; if (! $qty) $qty=1;
if (! $ventil) $ventil=0;
if (! $info_bits) $info_bits=0; if (! $info_bits) $info_bits=0;
$pu_ht=price2num($pu_ht); $pu_ht=price2num($pu_ht);
$pu_ttc=price2num($pu_ttc); $pu_ttc=price2num($pu_ttc);

View File

@ -1395,6 +1395,8 @@ class Facture extends CommonObject
{ {
global $conf,$langs; global $conf,$langs;
$error=0;
dol_syslog(get_class($this)."::set_canceled rowid=".$this->id, LOG_DEBUG); dol_syslog(get_class($this)."::set_canceled rowid=".$this->id, LOG_DEBUG);
$this->db->begin(); $this->db->begin();
@ -1515,7 +1517,7 @@ class Facture extends CommonObject
$result=$facreplaced->set_canceled($user,'replaced',''); $result=$facreplaced->set_canceled($user,'replaced','');
if ($result < 0) if ($result < 0)
{ {
$this->error=$facreplaced->error." sql=".$sql; $this->error=$facreplaced->error;
$this->db->rollback(); $this->db->rollback();
return -13; return -13;
} }
@ -3420,6 +3422,8 @@ class FactureLigne
{ {
global $langs,$user,$conf; global $langs,$user,$conf;
$error=0;
dol_syslog(get_class($this)."::Insert rang=".$this->rang, LOG_DEBUG); dol_syslog(get_class($this)."::Insert rang=".$this->rang, LOG_DEBUG);
// Clean parameters // Clean parameters
@ -3562,12 +3566,16 @@ class FactureLigne
/** /**
* Update line into database * Update line into database
* *
* @return int <0 if KO, >0 if OK * @param User $user User object
* @param int $notrigger Disable triggers
* @return int <0 if KO, >0 if OK
*/ */
function update() function update($user='',$notrigger=0)
{ {
global $user,$langs,$conf; global $user,$langs,$conf;
$error=0;
// Clean parameters // Clean parameters
$this->desc=trim($this->desc); $this->desc=trim($this->desc);
if (empty($this->tva_tx)) $this->tva_tx=0; if (empty($this->tva_tx)) $this->tva_tx=0;
@ -3651,6 +3659,8 @@ class FactureLigne
{ {
global $conf,$langs,$user; global $conf,$langs,$user;
$error=0;
$this->db->begin(); $this->db->begin();
$sql = "DELETE FROM ".MAIN_DB_PREFIX."facturedet WHERE rowid = ".$this->rowid; $sql = "DELETE FROM ".MAIN_DB_PREFIX."facturedet WHERE rowid = ".$this->rowid;

View File

@ -63,6 +63,8 @@ class localtax extends CommonObject
{ {
global $conf, $langs; global $conf, $langs;
$error=0;
// Clean parameters // Clean parameters
$this->amount=trim($this->amount); $this->amount=trim($this->amount);
$this->label=trim($this->label); $this->label=trim($this->label);
@ -128,6 +130,8 @@ class localtax extends CommonObject
{ {
global $conf, $langs; global $conf, $langs;
$error=0;
// Clean parameters // Clean parameters
$this->amount=trim($this->amount); $this->amount=trim($this->amount);
$this->label=trim($this->label); $this->label=trim($this->label);
@ -245,6 +249,8 @@ class localtax extends CommonObject
{ {
global $conf, $langs; global $conf, $langs;
$error=0;
$sql = "DELETE FROM ".MAIN_DB_PREFIX."localtax"; $sql = "DELETE FROM ".MAIN_DB_PREFIX."localtax";
$sql.= " WHERE rowid=".$this->id; $sql.= " WHERE rowid=".$this->id;
@ -493,7 +499,7 @@ class localtax extends CommonObject
$acc = new Account($this->db); $acc = new Account($this->db);
$result=$acc->fetch($this->accountid); $result=$acc->fetch($this->accountid);
if ($result <= 0) dol_print_error($db); if ($result <= 0) dol_print_error($this->db);
$bank_line_id = $acc->addline($this->datep, $this->paymenttype, $this->label, -abs($this->amount), '', '', $user); $bank_line_id = $acc->addline($this->datep, $this->paymenttype, $this->label, -abs($this->amount), '', '', $user);

View File

@ -471,6 +471,7 @@ class RemiseCheque extends CommonObject
/** /**
* Build document * Build document
*
* @param model Model name * @param model Model name
* @param outputlangs Object langs * @param outputlangs Object langs
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
@ -493,7 +494,7 @@ class RemiseCheque extends CommonObject
require_once($dir.$file); require_once($dir.$file);
$classname='BordereauCheque'.ucfirst($model); $classname='BordereauCheque'.ucfirst($model);
$docmodel = new $classname($db); $docmodel = new $classname($this->db);
$sql = "SELECT b.banque, b.emetteur, b.amount, b.num_chq"; $sql = "SELECT b.banque, b.emetteur, b.amount, b.num_chq";
$sql.= " FROM ".MAIN_DB_PREFIX."bank as b"; $sql.= " FROM ".MAIN_DB_PREFIX."bank as b";
@ -535,14 +536,14 @@ class RemiseCheque extends CommonObject
$result=$docmodel->write_file($conf->banque->dir_output.'/bordereau', $this->number, $outputlangs); $result=$docmodel->write_file($conf->banque->dir_output.'/bordereau', $this->number, $outputlangs);
if ($result > 0) if ($result > 0)
{ {
$outputlangs->charset_output=$sav_charset_output; //$outputlangs->charset_output=$sav_charset_output;
return 1; return 1;
} }
else else
{ {
$outputlangs->charset_output=$sav_charset_output; //$outputlangs->charset_output=$sav_charset_output;
dol_syslog("Error"); dol_syslog("Error");
dol_print_error($db,$docmodel->error); dol_print_error($this->db,$docmodel->error);
return 0; return 0;
} }
} }

View File

@ -320,7 +320,7 @@ class BonPrelevement extends CommonObject
{ {
global $user,$conf; global $user,$conf;
$error == 0; $error = 0;
if ($this->db->begin()) if ($this->db->begin())
{ {
@ -401,7 +401,7 @@ class BonPrelevement extends CommonObject
{ {
global $conf,$langs; global $conf,$langs;
$error == 0; $error = 0;
if ($this->_fetched == 1) if ($this->_fetched == 1)
{ {
@ -525,7 +525,8 @@ class BonPrelevement extends CommonObject
{ {
global $conf,$langs; global $conf,$langs;
$error == 0; $error = 0;
dol_syslog("bon-prelevement::set_infotrans Start",LOG_INFO); dol_syslog("bon-prelevement::set_infotrans Start",LOG_INFO);
if ($this->db->begin()) if ($this->db->begin())
{ {

View File

@ -74,8 +74,9 @@ class Tva extends CommonObject
{ {
global $conf, $langs; global $conf, $langs;
$error=0;
// Clean parameters // Clean parameters
$this->amount=trim($this->amount); $this->amount=trim($this->amount);
$this->label=trim($this->label); $this->label=trim($this->label);
$this->note=trim($this->note); $this->note=trim($this->note);
@ -83,14 +84,11 @@ class Tva extends CommonObject
$this->fk_user_creat=trim($this->fk_user_creat); $this->fk_user_creat=trim($this->fk_user_creat);
$this->fk_user_modif=trim($this->fk_user_modif); $this->fk_user_modif=trim($this->fk_user_modif);
// Check parameters // Check parameters
// Put here code to add control on parameters values // Put here code to add control on parameters values
// Insert request // Insert request
$sql = "INSERT INTO ".MAIN_DB_PREFIX."tva("; $sql = "INSERT INTO ".MAIN_DB_PREFIX."tva(";
$sql.= "tms,"; $sql.= "tms,";
$sql.= "datep,"; $sql.= "datep,";
$sql.= "datev,"; $sql.= "datev,";
@ -148,8 +146,9 @@ class Tva extends CommonObject
{ {
global $conf, $langs; global $conf, $langs;
$error=0;
// Clean parameters // Clean parameters
$this->amount=trim($this->amount); $this->amount=trim($this->amount);
$this->label=trim($this->label); $this->label=trim($this->label);
$this->note=trim($this->note); $this->note=trim($this->note);
@ -157,8 +156,6 @@ class Tva extends CommonObject
$this->fk_user_creat=trim($this->fk_user_creat); $this->fk_user_creat=trim($this->fk_user_creat);
$this->fk_user_modif=trim($this->fk_user_modif); $this->fk_user_modif=trim($this->fk_user_modif);
// Check parameters // Check parameters
// Put here code to add control on parameters values // Put here code to add control on parameters values
@ -275,6 +272,8 @@ class Tva extends CommonObject
{ {
global $conf, $langs; global $conf, $langs;
$error=0;
$sql = "DELETE FROM ".MAIN_DB_PREFIX."tva"; $sql = "DELETE FROM ".MAIN_DB_PREFIX."tva";
$sql.= " WHERE rowid=".$this->id; $sql.= " WHERE rowid=".$this->id;
@ -522,7 +521,7 @@ class Tva extends CommonObject
$acc = new Account($this->db); $acc = new Account($this->db);
$result=$acc->fetch($this->accountid); $result=$acc->fetch($this->accountid);
if ($result <= 0) dol_print_error($db); if ($result <= 0) dol_print_error($this->db);
$bank_line_id = $acc->addline($this->datep, $this->paymenttype, $this->label, -abs($this->amount), '', '', $user); $bank_line_id = $acc->addline($this->datep, $this->paymenttype, $this->label, -abs($this->amount), '', '', $user);

View File

@ -92,10 +92,11 @@ abstract class ActionsContactCardCommon
/** /**
* Load data control * Load data control
* *
* @param int $id Id of object * @param string &$action Type of action
* @param int $id Id of object
* @return void * @return void
*/ */
function doActions(&$action) function doActions(&$action, $id)
{ {
global $conf, $user, $langs; global $conf, $user, $langs;
@ -397,11 +398,7 @@ abstract class ActionsContactCardCommon
include_once(DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'); include_once(DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php');
$login=dol_buildlogin($this->object->nom, $this->object->prenom); $login=dol_buildlogin($this->object->nom, $this->object->prenom);
$generated_password=''; $generated_password=getRandomPassword('');
if (! $ldap_sid)
{
$generated_password=getRandomPassword('');
}
$password=$generated_password; $password=$generated_password;
// Create a form array // Create a form array

View File

@ -867,13 +867,13 @@ class Contact extends CommonObject
$code=$this->civilite_id; $code=$this->civilite_id;
return $langs->trans("Civility".$code)!="Civility".$code ? $langs->trans("Civility".$code) : ''; return $langs->trans("Civility".$code)!="Civility".$code ? $langs->trans("Civility".$code) : '';
if (empty($ret)) /*if (empty($ret))
{ {
$ret=$code; $ret=$code;
$langs->getLabelFromKey($db,$reg[1],'c_civilite','code','civilite'); $langs->getLabelFromKey($this->db,$reg[1],'c_civilite','code','civilite');
//$ret=dol_getIdFromCode($this->db,$code,'c_civilite', //$ret=dol_getIdFromCode($this->db,$code,'c_civilite',
} }
return $ret; return $ret;*/
} }

View File

@ -145,6 +145,8 @@ class Contrat extends CommonObject
{ {
global $langs,$conf; global $langs,$conf;
$error=0;
$this->db->begin(); $this->db->begin();
$sql = "UPDATE ".MAIN_DB_PREFIX."contratdet SET statut = 4,"; $sql = "UPDATE ".MAIN_DB_PREFIX."contratdet SET statut = 4,";
@ -191,6 +193,8 @@ class Contrat extends CommonObject
{ {
global $langs,$conf; global $langs,$conf;
$error=0;
// statut actif : 4 // statut actif : 4
$this->db->begin(); $this->db->begin();
@ -225,11 +229,12 @@ class Contrat extends CommonObject
/** /**
* \brief Close all lines of a contract * Close all lines of a contract
* \param user Object User making action *
* \param langs Object Lang * @param user Object User making action
* \param conf Object Conf * @param langs Object Lang
* * @param conf Object Conf
* @return void
*/ */
function cloture($user,$langs='',$conf='') function cloture($user,$langs='',$conf='')
{ {
@ -268,7 +273,7 @@ class Contrat extends CommonObject
} }
else else
{ {
dol_print_error($db,'Error in cloture function'); dol_print_error($this->db,'Error in cloture function');
$this->db->rollback(); $this->db->rollback();
} }
} }
@ -282,6 +287,8 @@ class Contrat extends CommonObject
*/ */
function validate($user,$langs,$conf) function validate($user,$langs,$conf)
{ {
$error=0;
$sql = "UPDATE ".MAIN_DB_PREFIX."contrat SET statut = 1"; $sql = "UPDATE ".MAIN_DB_PREFIX."contrat SET statut = 1";
$sql .= " WHERE rowid = ".$this->id . " AND statut = 0"; $sql .= " WHERE rowid = ".$this->id . " AND statut = 0";
@ -835,7 +842,6 @@ class Contrat extends CommonObject
$remise_percent=price2num($remise_percent); $remise_percent=price2num($remise_percent);
$qty=price2num($qty); $qty=price2num($qty);
if (! $qty) $qty=1; if (! $qty) $qty=1;
if (! $ventil) $ventil=0;
if (! $info_bits) $info_bits=0; if (! $info_bits) $info_bits=0;
if (! $pu_ht) $pu_ht=0; if (! $pu_ht) $pu_ht=0;
if (! $pu_ttc) $pu_ttc=0; if (! $pu_ttc) $pu_ttc=0;
@ -883,7 +889,7 @@ class Contrat extends CommonObject
$sql.= " price_ht, remise"; // TODO A virer $sql.= " price_ht, remise"; // TODO A virer
if ($date_start > 0) { $sql.= ",date_ouverture_prevue"; } if ($date_start > 0) { $sql.= ",date_ouverture_prevue"; }
if ($date_end > 0) { $sql.= ",date_fin_validite"; } if ($date_end > 0) { $sql.= ",date_fin_validite"; }
$sql.= ") VALUES ($this->id, '" . $this->db->escape($label) . "','" . $this->db->escape($desc) . "',"; $sql.= ") VALUES ($this->id, '', '" . $this->db->escape($desc) . "',";
$sql.= ($fk_product>0 ? $fk_product : "null").","; $sql.= ($fk_product>0 ? $fk_product : "null").",";
$sql.= " '".$qty."',"; $sql.= " '".$qty."',";
$sql.= " '".$txtva."',"; $sql.= " '".$txtva."',";
@ -1031,6 +1037,8 @@ class Contrat extends CommonObject
{ {
global $conf, $langs; global $conf, $langs;
$error=0;
if ($this->statut >= 0) if ($this->statut >= 0)
{ {
$sql = "DELETE FROM ".MAIN_DB_PREFIX."contratdet"; $sql = "DELETE FROM ".MAIN_DB_PREFIX."contratdet";
@ -1105,9 +1113,9 @@ class Contrat extends CommonObject
$langs->load("contracts"); $langs->load("contracts");
if ($mode == 0) if ($mode == 0)
{ {
if ($statut == 0) { return $langs->trans("ContractStatusDraft").$text; } if ($statut == 0) { return $langs->trans("ContractStatusDraft"); }
if ($statut == 1) { return $langs->trans("ContractStatusValidated").$text; } if ($statut == 1) { return $langs->trans("ContractStatusValidated"); }
if ($statut == 2) { return $langs->trans("ContractStatusClosed").$text; } if ($statut == 2) { return $langs->trans("ContractStatusClosed"); }
} }
if ($mode == 1) if ($mode == 1)
{ {
@ -1762,6 +1770,8 @@ class ContratLigne
{ {
global $conf, $langs; global $conf, $langs;
$error=0;
// Clean parameters // Clean parameters
$this->fk_contrat=trim($this->fk_contrat); $this->fk_contrat=trim($this->fk_contrat);
$this->fk_product=trim($this->fk_product); $this->fk_product=trim($this->fk_product);

View File

@ -43,13 +43,15 @@ class box_external_rss extends ModeleBoxes {
/** /**
* Constructor * Constructor
*
* @param DoliDB $db Database handler
*/ */
function box_external_rss($DB,$param) function box_external_rss($db,$param)
{ {
global $langs; global $langs;
$langs->load("boxes"); $langs->load("boxes");
$this->db=$DB; $this->db=$db;
$this->param=$param; $this->param=$param;
$this->boxlabel=$langs->trans("BoxLastRssInfos"); $this->boxlabel=$langs->trans("BoxLastRssInfos");
@ -80,7 +82,7 @@ class box_external_rss extends ModeleBoxes {
// Get RSS feed // Get RSS feed
$url=@constant("EXTERNAL_RSS_URLRSS_".$site); $url=@constant("EXTERNAL_RSS_URLRSS_".$site);
$rssparser=new RssParser($db); $rssparser=new RssParser($this->db);
$result = $rssparser->parser($url, $this->max, $cachedelay, $conf->externalrss->dir_temp); $result = $rssparser->parser($url, $this->max, $cachedelay, $conf->externalrss->dir_temp);
// INFO on channel // INFO on channel

View File

@ -81,6 +81,8 @@ abstract class CommonObject
{ {
global $user,$conf,$langs; global $user,$conf,$langs;
$error=0;
dol_syslog(get_class($this)."::add_contact $fk_socpeople, $type_contact, $source"); dol_syslog(get_class($this)."::add_contact $fk_socpeople, $type_contact, $source");
// Check parameters // Check parameters
@ -200,6 +202,8 @@ abstract class CommonObject
{ {
global $user,$langs,$conf; global $user,$langs,$conf;
$error=0;
$sql = "DELETE FROM ".MAIN_DB_PREFIX."element_contact"; $sql = "DELETE FROM ".MAIN_DB_PREFIX."element_contact";
$sql.= " WHERE rowid =".$rowid; $sql.= " WHERE rowid =".$rowid;
@ -2055,7 +2059,7 @@ abstract class CommonObject
// Produit // Produit
if ($line->fk_product > 0) if ($line->fk_product > 0)
{ {
$product_static = new Product($db); $product_static = new Product($this->db);
$product_static->type=$line->fk_product_type; $product_static->type=$line->fk_product_type;
$product_static->id=$line->fk_product; $product_static->id=$line->fk_product;
@ -2164,7 +2168,7 @@ abstract class CommonObject
if (($line->info_bits & 2) == 2) // TODO Not sure this is used for source object if (($line->info_bits & 2) == 2) // TODO Not sure this is used for source object
{ {
$discount=new DiscountAbsolute($db); $discount=new DiscountAbsolute($this->db);
$discount->fk_soc = $this->socid; $discount->fk_soc = $this->socid;
$this->tpl['label'].= $discount->getNomUrl(0,'discount'); $this->tpl['label'].= $discount->getNomUrl(0,'discount');
} }

View File

@ -208,7 +208,7 @@ class DiscountAbsolute
} }
else else
{ {
dol_print_error($db); dol_print_error($this->db);
return -1; return -1;
} }
} }

View File

@ -1036,7 +1036,7 @@ class Form
if ($num) if ($num)
{ {
$out.= '<select class="flat" id="'.$htmlname.'" name="'.$htmlname.'"'.($disabled?' disabled="disabled"':'').'>'; $out.= '<select class="flat" id="'.$htmlname.'" name="'.$htmlname.'"'.($disabled?' disabled="disabled"':'').'>';
if ($show_empty) $out.= '<option value="-1"'.($id==-1?' selected="selected"':'').'>&nbsp;</option>'."\n"; if ($show_empty) $out.= '<option value="-1"'.($selected==-1?' selected="selected"':'').'>&nbsp;</option>'."\n";
$userstatic=new User($this->db); $userstatic=new User($this->db);
@ -1364,6 +1364,8 @@ class Form
function select_produits_fournisseurs($socid,$selected='',$htmlname='productid',$filtertype='',$filtre) function select_produits_fournisseurs($socid,$selected='',$htmlname='productid',$filtertype='',$filtre)
{ {
global $langs,$conf; global $langs,$conf;
global $price_level, $status, $finished;
if ($conf->global->PRODUIT_USE_SEARCH_TO_SELECT) if ($conf->global->PRODUIT_USE_SEARCH_TO_SELECT)
{ {
// mode=2 means suppliers products // mode=2 means suppliers products
@ -1521,7 +1523,7 @@ class Form
} }
else else
{ {
dol_print_error($db); dol_print_error($this->db);
} }
} }
@ -1610,7 +1612,7 @@ class Form
} }
else else
{ {
dol_print_error($db); dol_print_error($this->db);
} }
} }
@ -3806,7 +3808,7 @@ class Form
if ($num) if ($num)
{ {
$out.= '<select class="flat" name="'.$htmlname.'"'.($disabled?' disabled="disabled"':'').'>'; $out.= '<select class="flat" name="'.$htmlname.'"'.($disabled?' disabled="disabled"':'').'>';
if ($show_empty) $out.= '<option value="-1"'.($id==-1?' selected="selected"':'').'>&nbsp;</option>'."\n"; if ($show_empty) $out.= '<option value="-1"'.($selected==-1?' selected="selected"':'').'>&nbsp;</option>'."\n";
while ($i < $num) while ($i < $num)
{ {

View File

@ -358,7 +358,7 @@ class FormFile
$headershown=1; $headershown=1;
$form = new Form($db); $form = new Form($this->db);
$buttonlabeltoshow=$buttonlabel; $buttonlabeltoshow=$buttonlabel;
if (empty($buttonlabel)) $buttonlabel=$langs->trans('Generate'); if (empty($buttonlabel)) $buttonlabel=$langs->trans('Generate');
@ -537,7 +537,7 @@ class FormFile
{ {
global $user, $conf, $langs; global $user, $conf, $langs;
global $bc; global $bc;
global $sortfield, $sortorder; global $sortfield, $sortorder, $maxheightmini;
// Show list of existing files // Show list of existing files
if (empty($useinecm)) print_titre($langs->trans("AttachedFiles")); if (empty($useinecm)) print_titre($langs->trans("AttachedFiles"));

View File

@ -223,7 +223,7 @@ class FormMail
if (! empty($_SESSION["listofmimes"])) $listofmimes=explode(';',$_SESSION["listofmimes"]); if (! empty($_SESSION["listofmimes"])) $listofmimes=explode(';',$_SESSION["listofmimes"]);
$form=new Form($DB); $form=new Form($this->db);
$out.= "\n<!-- Debut form mail -->\n"; $out.= "\n<!-- Debut form mail -->\n";
if ($this->withform) if ($this->withform)

View File

@ -357,10 +357,11 @@ class pdf_standard {
/** /**
* \brief Function to build PDF on disk, then output on HTTP strem. * Function to build PDF on disk, then output on HTTP strem.
* \param arrayofmembers Array of members informations *
* \param outputlangs Lang object for output language * @param arrayofmembers Array of members informations
* \return int 1=ok, 0=ko * @param outputlangs Lang object for output language
* @return int 1=ok, 0=ko
*/ */
function write_file($arrayofmembers,$outputlangs) function write_file($arrayofmembers,$outputlangs)
{ {
@ -457,7 +458,7 @@ class pdf_standard {
$filename='tmpcards.pdf'; $filename='tmpcards.pdf';
$type=dol_mimetype($filename); $type=dol_mimetype($filename);
if ($encoding) header('Content-Encoding: '.$encoding); //if ($encoding) header('Content-Encoding: '.$encoding);
if ($type) header('Content-Type: '.$type); if ($type) header('Content-Type: '.$type);
if ($attachment) header('Content-Disposition: attachment; filename="'.$filename.'"'); if ($attachment) header('Content-Disposition: attachment; filename="'.$filename.'"');
else header('Content-Disposition: inline; filename="'.$filename.'"'); else header('Content-Disposition: inline; filename="'.$filename.'"');

View File

@ -75,8 +75,9 @@ class ActionsCardCompany extends ActionsCardCommon
/** /**
* Execute actions * Execute actions
* *
* @param int $socid Id of object (may be empty for creation) * @param string &$action Type of action
* @return int <0 if KO, >0 if OK * @param int $id Id of object
* @return int <0 if KO, >0 if OK
*/ */
function doActions(&$action, $id) function doActions(&$action, $id)
{ {