diff --git a/build/makepack-dolibarr.pl b/build/makepack-dolibarr.pl index e95503dc9f6..73cc80f5bb1 100644 --- a/build/makepack-dolibarr.pl +++ b/build/makepack-dolibarr.pl @@ -336,11 +336,9 @@ if ($nboftargetok) { $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/phpexcel/license.txt`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/phpexcel/PHPExcel/Shared/PDF`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/phpexcel/PHPExcel/Shared/PCLZip`; - $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/tcpdf/fonts/dejavu-fonts-ttf-2.33`; - $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/tcpdf/fonts/freefont-20100919`; + #$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/tcpdf/fonts/dejavu-fonts-ttf-2.33`; + #$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/tcpdf/fonts/freefont-20100919`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/tcpdf/fonts/utils`; - $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/tcpdf/fonts/free*.ctg.z`; - $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/tcpdf/fonts/free*.z`; $ret=`rm -f $BUILDROOT/$PROJECT/htdocs/includes/tcpdf/LICENSE.TXT`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/jquery/plugins/jstree`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/langs/*/html`; @@ -652,7 +650,6 @@ if ($nboftargetok) { $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/build/rpm`; $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/build/zip`; # We remove embedded libraries or fonts - $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/htdocs/includes/artichow/font`, $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/htdocs/includes/fonts`, $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/htdocs/includes/geoip`; $ret=`rm -fr $BUILDROOT/$PROJECT.tmp/usr/share/$PROJECT/htdocs/includes/odtphp/zip/pclzip`; @@ -767,7 +764,8 @@ if ($nboftargetok) { next; } - if ($target eq 'APS') { + if ($target eq 'APS') + { $NEWDESTI=$DESTI; if (-d $DESTI.'/package_aps') { $NEWDESTI=$DESTI.'/package_aps'; } diff --git a/build/rpm/dolibarr_fedora.spec b/build/rpm/dolibarr_fedora.spec index 1a004cd4b45..4d3daf6b097 100755 --- a/build/rpm/dolibarr_fedora.spec +++ b/build/rpm/dolibarr_fedora.spec @@ -105,6 +105,7 @@ cui hai bisogno ed essere facile da usare. %{__cp} -pr scripts $RPM_BUILD_ROOT%{_datadir}/%{name} %{__rm} -rf $RPM_BUILD_ROOT%{_datadir}/%{name}/htdocs/includes/adodbtime %{__rm} -rf $RPM_BUILD_ROOT%{_datadir}/%{name}/htdocs/includes/nusoap +%{__rm} -rf $RPM_BUILD_ROOT%{_datadir}/%{name}/htdocs/includes/fonts # Lang for i in $RPM_BUILD_ROOT%{_datadir}/%{name}/htdocs/langs/*_* diff --git a/build/rpm/dolibarr_mandriva.spec b/build/rpm/dolibarr_mandriva.spec index 7f6ebb5b594..dded5f3cc0b 100755 --- a/build/rpm/dolibarr_mandriva.spec +++ b/build/rpm/dolibarr_mandriva.spec @@ -102,6 +102,7 @@ cui hai bisogno ed essere facile da usare. %{__cp} -pr build/tgz/* $RPM_BUILD_ROOT%{_datadir}/%{name}/build/tgz %{__cp} -pr htdocs $RPM_BUILD_ROOT%{_datadir}/%{name} %{__cp} -pr scripts $RPM_BUILD_ROOT%{_datadir}/%{name} +%{__rm} -rf $RPM_BUILD_ROOT%{_datadir}/%{name}/htdocs/includes/fonts # Lang for i in $RPM_BUILD_ROOT%{_datadir}/%{name}/htdocs/langs/*_* diff --git a/build/rpm/dolibarr_opensuse.spec b/build/rpm/dolibarr_opensuse.spec index 95d44fe917e..0b2a0c9caf7 100755 --- a/build/rpm/dolibarr_opensuse.spec +++ b/build/rpm/dolibarr_opensuse.spec @@ -101,6 +101,7 @@ cui hai bisogno ed essere facile da usare. %{__cp} -pr build/tgz/* $RPM_BUILD_ROOT%{_datadir}/%{name}/build/tgz %{__cp} -pr htdocs $RPM_BUILD_ROOT%{_datadir}/%{name} %{__cp} -pr scripts $RPM_BUILD_ROOT%{_datadir}/%{name} +%{__rm} -rf $RPM_BUILD_ROOT%{_datadir}/%{name}/htdocs/includes/fonts # Lang for i in $RPM_BUILD_ROOT%{_datadir}/%{name}/htdocs/langs/*_* diff --git a/htdocs/boutique/commande/class/boutiquecommande.class.php b/htdocs/boutique/commande/class/boutiquecommande.class.php index 4b2d41e5221..143a4e3f1ad 100644 --- a/htdocs/boutique/commande/class/boutiquecommande.class.php +++ b/htdocs/boutique/commande/class/boutiquecommande.class.php @@ -41,12 +41,11 @@ class BoutiqueCommande /** * Constructor * - * @param DoliDB $DB Database handler + * @param DoliDB $db Database handler */ - function BoutiqueCommande($DB) + function BoutiqueCommande($db) { - $this->db = $DB; - $this->id = $id; + $this->db = $db; $this->billing_adr = new Address(); $this->delivry_adr = new Address(); @@ -107,7 +106,8 @@ class BoutiqueCommande if ( $result ) { $num = $this->db->num_rows($result); - + + $i=0; while ($i < $num) { $array = $this->db->fetch_array($result); diff --git a/htdocs/boutique/promotion/class/promotion.class.php b/htdocs/boutique/promotion/class/promotion.class.php index d78c54e729f..5ee5a743a3f 100644 --- a/htdocs/boutique/promotion/class/promotion.class.php +++ b/htdocs/boutique/promotion/class/promotion.class.php @@ -41,12 +41,11 @@ class Promotion /** * Constructor * - * @param DoliDB $DB Database handler + * @param DoliDB $db Database handler */ - function Promotion($DB) + function Promotion($db) { - $this->db = $DB; - $this->id = $id; + $this->db = $db; } /** diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index ab58b71972c..2985e4651e0 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -121,15 +121,18 @@ class Categorie /** * Add category into database * - * @return int -1 : erreur SQL - * -2 : nouvel ID inconnu - * -3 : categorie invalide + * @param User $user Object user + * @return int -1 : erreur SQL + * -2 : nouvel ID inconnu + * -3 : categorie invalide */ - function create() + function create($user='') { global $conf,$langs; $langs->load('categories'); + $error=0; + // Clean parameters if (empty($this->visible)) $this->visible=0; $this->parentId = ($this->id_mere) != "" ? intval($this->id_mere) : 0; @@ -201,14 +204,17 @@ class Categorie /** * Update category * - * @return int 1 : OK - * -1 : SQL error - * -2 : invalid category + * @param User $user Object user + * @return int 1 : OK + * -1 : SQL error + * -2 : invalid category */ - function update() + function update($user='') { global $conf, $langs; + $error=0; + // Clean parameters $this->label=trim($this->label); $this->description=trim($this->description); @@ -879,12 +885,12 @@ class Categorie $sql.= " AND c.label='".$this->db->escape($this->label)."'"; } dol_syslog("Categorie::already_exists sql=".$sql); - $res = $this->db->query($sql); - if ($res) + $resql = $this->db->query($sql); + 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 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, diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 6450eab568f..82057f92f64 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -381,7 +381,6 @@ class Propal extends CommonObject $this->line->subprice=$pu_ht; $this->line->rang=$rangtouse; $this->line->info_bits=$info_bits; - $this->line->fk_remise_except=$fk_remise_except; $this->line->total_ht=$total_ht; $this->line->total_tva=$total_tva; $this->line->total_localtax1=$total_localtax1; @@ -1149,6 +1148,7 @@ class Propal extends CommonObject { global $conf,$langs; + $error=0; $now=dol_now(); if ($user->rights->propale->valider) @@ -1477,7 +1477,8 @@ class Propal extends CommonObject global $langs,$conf; $this->statut = $statut; - + $error=0; + $this->db->begin(); $sql = "UPDATE ".MAIN_DB_PREFIX."propal"; @@ -2536,13 +2537,17 @@ class PropaleLigne } /** - * \brief Insert object line propal in database - * \return int <0 if KO, >0 if OK + * Insert object line propal in database + * + * @param int $notrigger 1=no trigger ran + * @return int <0 if KO, >0 if OK */ function insert($notrigger=0) { global $conf,$langs,$user; + $error=0; + dol_syslog("PropaleLigne::insert rang=".$this->rang); // Clean parameters @@ -2599,8 +2604,6 @@ class PropaleLigne $resql=$this->db->query($sql); if ($resql) { - $this->rang=$rangmax; - $this->rowid=$this->db->last_insert_id(MAIN_DB_PREFIX.'propaldet'); if (! $notrigger) { @@ -2632,6 +2635,7 @@ class PropaleLigne { global $conf,$langs,$user; + $error=0; $this->db->begin(); $sql = "DELETE FROM ".MAIN_DB_PREFIX."propaldet WHERE rowid = ".$this->rowid; @@ -2667,6 +2671,8 @@ class PropaleLigne { global $conf,$langs,$user; + $error=0; + // Clean parameters if (empty($this->tva_tx)) $this->tva_tx=0; if (empty($this->localtax1_tx)) $this->localtax1_tx=0; diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 4734a881ed0..2e663f1fe4d 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -99,15 +99,13 @@ class Commande extends CommonObject /** * Constructor * - * @param DoliDB $DB Database handler + * @param DoliDB $db Database handler */ - function Commande($DB) + function Commande($db) { global $langs; $langs->load('orders'); - $this->db = $DB; - $this->socid = $socid; - $this->id = $commandeid; + $this->db = $db; $this->remise = 0; $this->remise_percent = 0; @@ -447,9 +445,10 @@ class Commande extends CommonObject } /** - * Close order - * @param user Objet user that close - * @return int <0 if KO, >0 if OK + * Close order + * + * @param user Objet user that close + * @return int <0 if KO, >0 if OK */ function cloture($user) { @@ -501,13 +500,15 @@ class Commande extends CommonObject } /** - * \brief Cancel an order - * \return int <0 if KO, >0 if OK - * \remarks If stock is decremented on order validation, we must reincrement it + * Cancel an order + * 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; @@ -526,17 +527,20 @@ class Commande extends CommonObject // If stock is decremented on validate order, we must reincrement it if ($conf->stock->enabled && $conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER == 1) { - require_once(DOL_DOCUMENT_ROOT."/product/stock/class/mouvementstock.class.php"); - $langs->load("agenda"); - - if ($this->lines[$i]->fk_product > 0) - { - $mouvP = new MouvementStock($this->db); - // We increment stock of product (and sub-products) - $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)); - if ($result < 0) { $error++; } - } + require_once(DOL_DOCUMENT_ROOT."/product/stock/class/mouvementstock.class.php"); + $langs->load("agenda"); + + $num=count($this->lines); + for ($i = 0; $i < $num; $i++) + { + if ($this->lines[$i]->fk_product > 0) + { + $mouvP = new MouvementStock($this->db); + // 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) @@ -604,7 +608,6 @@ class Commande extends CommonObject dol_syslog("Commande::create ".$this->error, LOG_ERR); return -1; } - if (! $remise) $remise=0; if (! $this->fk_project) $this->fk_project = 0; // $date_commande is deprecated @@ -1299,14 +1302,14 @@ class Commande extends CommonObject } else { - dol_syslog('Commande::Fetch Error rowid='.$rowid.' numrows=0 sql='.$sql); - $this->error='Order with id '.$rowid.' not found sql='.$sql; + dol_syslog('Commande::Fetch Error rowid='.$id.' numrows=0 sql='.$sql); + $this->error='Order with id '.$id.' not found sql='.$sql; return -2; } } 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(); return -1; } @@ -2194,8 +2197,8 @@ class Commande extends CommonObject $qty=price2num($qty); $pu = price2num($pu); $txtva=price2num($txtva); - $txlocaltax1=price2num($txtlocaltax1); - $txlocaltax2=price2num($txtlocaltax2); + $txlocaltax1=price2num($txlocaltax1); + $txlocaltax2=price2num($txlocaltax2); // Calcul du total TTC et de la TVA pour la ligne a partir de // qty, pu, remise_percent et txtva @@ -2287,15 +2290,16 @@ class Commande extends CommonObject /** * 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) { global $conf, $langs; require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"); - $err = 0; + $error = 0; $this->db->begin(); @@ -2305,7 +2309,7 @@ class Commande extends CommonObject if (! $this->db->query($sql) ) { dol_syslog("CustomerOrder::delete error", LOG_ERR); - $err++; + $error++; } // Delete order @@ -2314,7 +2318,7 @@ class Commande extends CommonObject if (! $this->db->query($sql) ) { dol_syslog("CustomerOrder::delete error", LOG_ERR); - $err++; + $error++; } // Delete linked object @@ -2326,7 +2330,7 @@ class Commande extends CommonObject if (! $this->db->query($sql) ) { dol_syslog("CustomerOrder::delete error", LOG_ERR); - $err++; + $error++; } // Delete linked contacts @@ -2334,7 +2338,7 @@ class Commande extends CommonObject if ($res < 0) { dol_syslog("CustomerOrder::delete error", LOG_ERR); - $err++; + $error++; } // On efface le repertoire de pdf provisoire @@ -2365,7 +2369,7 @@ class Commande extends CommonObject } } - if ($err == 0) + if ($error == 0) { // Appel des triggers 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) + * * @param user Objet user * @return int <0 if KO, >0 if OK */ @@ -2935,6 +2940,8 @@ class OrderLine { global $conf, $user, $langs; + $error=0; + $sql = 'DELETE FROM '.MAIN_DB_PREFIX."commandedet WHERE rowid='".$this->rowid."';"; dol_syslog("OrderLine::delete sql=".$sql); @@ -2968,6 +2975,8 @@ class OrderLine { global $langs, $conf, $user; + $error=0; + dol_syslog("OrderLine::insert rang=".$this->rang); // Clean parameters @@ -3065,6 +3074,8 @@ class OrderLine { global $conf,$langs,$user; + $error=0; + // Clean parameters if (empty($this->tva_tx)) $this->tva_tx=0; if (empty($this->localtax1_tx)) $this->localtax1_tx=0; diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index 602da307cc0..b27e00bc39e 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -864,7 +864,6 @@ class Account extends CommonObject { $this->nbtodo++; if ($this->db->jdate($obj->datefin) < ($now - $conf->bank->rappro->warning_delay)) $this->nbtodolate++; - if ($obj->rappro) $foundaccounttoconciliate++; } return $num; } diff --git a/htdocs/compta/dons/class/don.class.php b/htdocs/compta/dons/class/don.class.php index c8e088cc128..f3dc9eee4cf 100644 --- a/htdocs/compta/dons/class/don.class.php +++ b/htdocs/compta/dons/class/don.class.php @@ -182,8 +182,8 @@ class Don extends CommonObject $this->specimen=1; $this->nom = 'Doe'; $this->prenom = 'John'; - $this->socid = $socids[$socid]; - $this->date = time(); + $this->socid = 1; + $this->date = dol_now(); $this->amount = 100; $this->public = 1; $this->societe = 'The Company'; diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index 0ac3b4da79b..c39b3b2e959 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -190,9 +190,10 @@ class FactureRec extends Facture /** - * \brief 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 + * Recupere l'objet facture et ses lignes de factures + * + * @param int $rowid Id de la facture a recuperer + * @return int >0 si ok, <0 si ko */ 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.= ' 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); 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) { @@ -420,7 +423,6 @@ class FactureRec extends Facture $remise_percent=price2num($remise_percent); $qty=price2num($qty); if (! $qty) $qty=1; - if (! $ventil) $ventil=0; if (! $info_bits) $info_bits=0; $pu_ht=price2num($pu_ht); $pu_ttc=price2num($pu_ttc); diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 3986a5d8a78..6b8715bd1a1 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -1395,6 +1395,8 @@ class Facture extends CommonObject { global $conf,$langs; + $error=0; + dol_syslog(get_class($this)."::set_canceled rowid=".$this->id, LOG_DEBUG); $this->db->begin(); @@ -1515,7 +1517,7 @@ class Facture extends CommonObject $result=$facreplaced->set_canceled($user,'replaced',''); if ($result < 0) { - $this->error=$facreplaced->error." sql=".$sql; + $this->error=$facreplaced->error; $this->db->rollback(); return -13; } @@ -3420,6 +3422,8 @@ class FactureLigne { global $langs,$user,$conf; + $error=0; + dol_syslog(get_class($this)."::Insert rang=".$this->rang, LOG_DEBUG); // Clean parameters @@ -3562,12 +3566,16 @@ class FactureLigne /** * 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; + $error=0; + // Clean parameters $this->desc=trim($this->desc); if (empty($this->tva_tx)) $this->tva_tx=0; @@ -3651,6 +3659,8 @@ class FactureLigne { global $conf,$langs,$user; + $error=0; + $this->db->begin(); $sql = "DELETE FROM ".MAIN_DB_PREFIX."facturedet WHERE rowid = ".$this->rowid; diff --git a/htdocs/compta/localtax/class/localtax.class.php b/htdocs/compta/localtax/class/localtax.class.php index 4e0c70f07fa..97683e912b8 100644 --- a/htdocs/compta/localtax/class/localtax.class.php +++ b/htdocs/compta/localtax/class/localtax.class.php @@ -63,6 +63,8 @@ class localtax extends CommonObject { global $conf, $langs; + $error=0; + // Clean parameters $this->amount=trim($this->amount); $this->label=trim($this->label); @@ -128,6 +130,8 @@ class localtax extends CommonObject { global $conf, $langs; + $error=0; + // Clean parameters $this->amount=trim($this->amount); $this->label=trim($this->label); @@ -245,6 +249,8 @@ class localtax extends CommonObject { global $conf, $langs; + $error=0; + $sql = "DELETE FROM ".MAIN_DB_PREFIX."localtax"; $sql.= " WHERE rowid=".$this->id; @@ -493,7 +499,7 @@ class localtax extends CommonObject $acc = new Account($this->db); $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); diff --git a/htdocs/compta/paiement/cheque/class/remisecheque.class.php b/htdocs/compta/paiement/cheque/class/remisecheque.class.php index 0a1fbb8c9f0..f031189d25c 100644 --- a/htdocs/compta/paiement/cheque/class/remisecheque.class.php +++ b/htdocs/compta/paiement/cheque/class/remisecheque.class.php @@ -471,6 +471,7 @@ class RemiseCheque extends CommonObject /** * Build document + * * @param model Model name * @param outputlangs Object langs * @return int <0 if KO, >0 if OK @@ -493,7 +494,7 @@ class RemiseCheque extends CommonObject require_once($dir.$file); $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.= " 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); if ($result > 0) { - $outputlangs->charset_output=$sav_charset_output; + //$outputlangs->charset_output=$sav_charset_output; return 1; } else { - $outputlangs->charset_output=$sav_charset_output; + //$outputlangs->charset_output=$sav_charset_output; dol_syslog("Error"); - dol_print_error($db,$docmodel->error); + dol_print_error($this->db,$docmodel->error); return 0; } } diff --git a/htdocs/compta/prelevement/class/bon-prelevement.class.php b/htdocs/compta/prelevement/class/bon-prelevement.class.php index 8176aa153f9..a7275205caf 100644 --- a/htdocs/compta/prelevement/class/bon-prelevement.class.php +++ b/htdocs/compta/prelevement/class/bon-prelevement.class.php @@ -320,7 +320,7 @@ class BonPrelevement extends CommonObject { global $user,$conf; - $error == 0; + $error = 0; if ($this->db->begin()) { @@ -401,7 +401,7 @@ class BonPrelevement extends CommonObject { global $conf,$langs; - $error == 0; + $error = 0; if ($this->_fetched == 1) { @@ -525,7 +525,8 @@ class BonPrelevement extends CommonObject { global $conf,$langs; - $error == 0; + $error = 0; + dol_syslog("bon-prelevement::set_infotrans Start",LOG_INFO); if ($this->db->begin()) { diff --git a/htdocs/compta/tva/class/tva.class.php b/htdocs/compta/tva/class/tva.class.php index 98b494120a2..8dc51a45b4e 100644 --- a/htdocs/compta/tva/class/tva.class.php +++ b/htdocs/compta/tva/class/tva.class.php @@ -74,8 +74,9 @@ class Tva extends CommonObject { global $conf, $langs; + $error=0; + // Clean parameters - $this->amount=trim($this->amount); $this->label=trim($this->label); $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_modif=trim($this->fk_user_modif); - - // Check parameters // Put here code to add control on parameters values // Insert request $sql = "INSERT INTO ".MAIN_DB_PREFIX."tva("; - $sql.= "tms,"; $sql.= "datep,"; $sql.= "datev,"; @@ -148,8 +146,9 @@ class Tva extends CommonObject { global $conf, $langs; + $error=0; + // Clean parameters - $this->amount=trim($this->amount); $this->label=trim($this->label); $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_modif=trim($this->fk_user_modif); - - // Check parameters // Put here code to add control on parameters values @@ -275,6 +272,8 @@ class Tva extends CommonObject { global $conf, $langs; + $error=0; + $sql = "DELETE FROM ".MAIN_DB_PREFIX."tva"; $sql.= " WHERE rowid=".$this->id; @@ -522,7 +521,7 @@ class Tva extends CommonObject $acc = new Account($this->db); $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); diff --git a/htdocs/conf/conf.php.example b/htdocs/conf/conf.php.example index bfbe4616ec6..f3cd80a6309 100644 --- a/htdocs/conf/conf.php.example +++ b/htdocs/conf/conf.php.example @@ -2,8 +2,9 @@ # Dolibarr example for conf.php file # # Do not edit this file without changing its name. -# This file is used by Dolibarr setup process to create true Dolibarr -# config file called "conf.php". +# This file is an example of empty config file for Dolibarr than can be used to create "conf.php". +# +# Warning: Be sure to not add line feed or spaces after closing php tag. # diff --git a/htdocs/contact/canvas/actions_contactcard_common.class.php b/htdocs/contact/canvas/actions_contactcard_common.class.php index f65a6a500c0..f456f31b5a8 100644 --- a/htdocs/contact/canvas/actions_contactcard_common.class.php +++ b/htdocs/contact/canvas/actions_contactcard_common.class.php @@ -92,10 +92,11 @@ abstract class ActionsContactCardCommon /** * Load data control * - * @param int $id Id of object + * @param string &$action Type of action + * @param int $id Id of object * @return void */ - function doActions(&$action) + function doActions(&$action, $id) { global $conf, $user, $langs; @@ -397,11 +398,7 @@ abstract class ActionsContactCardCommon include_once(DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'); $login=dol_buildlogin($this->object->nom, $this->object->prenom); - $generated_password=''; - if (! $ldap_sid) - { - $generated_password=getRandomPassword(''); - } + $generated_password=getRandomPassword(''); $password=$generated_password; // Create a form array diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index bb0e08de0fe..c37c500828f 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -867,13 +867,13 @@ class Contact extends CommonObject $code=$this->civilite_id; return $langs->trans("Civility".$code)!="Civility".$code ? $langs->trans("Civility".$code) : ''; - if (empty($ret)) + /*if (empty($ret)) { $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', } - return $ret; + return $ret;*/ } diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 9f58f2b2d81..3466e665f06 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -145,6 +145,8 @@ class Contrat extends CommonObject { global $langs,$conf; + $error=0; + $this->db->begin(); $sql = "UPDATE ".MAIN_DB_PREFIX."contratdet SET statut = 4,"; @@ -191,6 +193,8 @@ class Contrat extends CommonObject { global $langs,$conf; + $error=0; + // statut actif : 4 $this->db->begin(); @@ -225,11 +229,12 @@ class Contrat extends CommonObject /** - * \brief Close all lines of a contract - * \param user Object User making action - * \param langs Object Lang - * \param conf Object Conf - * + * Close all lines of a contract + * + * @param user Object User making action + * @param langs Object Lang + * @param conf Object Conf + * @return void */ function cloture($user,$langs='',$conf='') { @@ -268,7 +273,7 @@ class Contrat extends CommonObject } else { - dol_print_error($db,'Error in cloture function'); + dol_print_error($this->db,'Error in cloture function'); $this->db->rollback(); } } @@ -282,6 +287,8 @@ class Contrat extends CommonObject */ function validate($user,$langs,$conf) { + $error=0; + $sql = "UPDATE ".MAIN_DB_PREFIX."contrat SET statut = 1"; $sql .= " WHERE rowid = ".$this->id . " AND statut = 0"; @@ -835,7 +842,6 @@ class Contrat extends CommonObject $remise_percent=price2num($remise_percent); $qty=price2num($qty); if (! $qty) $qty=1; - if (! $ventil) $ventil=0; if (! $info_bits) $info_bits=0; if (! $pu_ht) $pu_ht=0; if (! $pu_ttc) $pu_ttc=0; @@ -883,7 +889,7 @@ class Contrat extends CommonObject $sql.= " price_ht, remise"; // TODO A virer if ($date_start > 0) { $sql.= ",date_ouverture_prevue"; } 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.= " '".$qty."',"; $sql.= " '".$txtva."',"; @@ -1031,6 +1037,8 @@ class Contrat extends CommonObject { global $conf, $langs; + $error=0; + if ($this->statut >= 0) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."contratdet"; @@ -1105,9 +1113,9 @@ class Contrat extends CommonObject $langs->load("contracts"); if ($mode == 0) { - if ($statut == 0) { return $langs->trans("ContractStatusDraft").$text; } - if ($statut == 1) { return $langs->trans("ContractStatusValidated").$text; } - if ($statut == 2) { return $langs->trans("ContractStatusClosed").$text; } + if ($statut == 0) { return $langs->trans("ContractStatusDraft"); } + if ($statut == 1) { return $langs->trans("ContractStatusValidated"); } + if ($statut == 2) { return $langs->trans("ContractStatusClosed"); } } if ($mode == 1) { @@ -1762,6 +1770,8 @@ class ContratLigne { global $conf, $langs; + $error=0; + // Clean parameters $this->fk_contrat=trim($this->fk_contrat); $this->fk_product=trim($this->fk_product); diff --git a/htdocs/core/boxes/box_external_rss.php b/htdocs/core/boxes/box_external_rss.php index 9d4e59358b4..f61df2d8c4c 100644 --- a/htdocs/core/boxes/box_external_rss.php +++ b/htdocs/core/boxes/box_external_rss.php @@ -43,13 +43,15 @@ class box_external_rss extends ModeleBoxes { /** * Constructor + * + * @param DoliDB $db Database handler */ - function box_external_rss($DB,$param) + function box_external_rss($db,$param) { global $langs; $langs->load("boxes"); - $this->db=$DB; + $this->db=$db; $this->param=$param; $this->boxlabel=$langs->trans("BoxLastRssInfos"); @@ -80,7 +82,7 @@ class box_external_rss extends ModeleBoxes { // Get RSS feed $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); // INFO on channel diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php index 32b51c8dd21..6b3337c4625 100644 --- a/htdocs/core/class/CMailFile.class.php +++ b/htdocs/core/class/CMailFile.class.php @@ -500,7 +500,8 @@ class CMailFile if (@is_writeable($dolibarr_main_data_root)) // Avoid fatal error on fopen with open_basedir { - $fp = fopen($dolibarr_main_data_root."/dolibarr_mail.log","w"); + $outputfile=$dolibarr_main_data_root."/dolibarr_mail.log"; + $fp = fopen($outputfile,"w"); if ($conf->global->MAIN_MAIL_SENDMODE == 'mail') { diff --git a/htdocs/core/class/CSMSFile.class.php b/htdocs/core/class/CSMSFile.class.php index 658e09f2db3..4c0771ba7d8 100755 --- a/htdocs/core/class/CSMSFile.class.php +++ b/htdocs/core/class/CSMSFile.class.php @@ -198,7 +198,8 @@ class CSMSFile if (@is_writeable($dolibarr_main_data_root)) // Avoid fatal error on fopen with open_basedir { - $fp = fopen($dolibarr_main_data_root."/dolibarr_sms.log","w"); + $outputfile=$dolibarr_main_data_root."/dolibarr_sms.log"; + $fp = fopen($outputfile,"w"); fputs($fp, $this->message); @@ -218,7 +219,8 @@ class CSMSFile if (@is_writeable($dolibarr_main_data_root)) // Avoid fatal error on fopen with open_basedir { - $fp = fopen($dolibarr_main_data_root."/dolibarr_sms.log","a+"); + $outputfile=$dolibarr_main_data_root."/dolibarr_sms.log"; + $fp = fopen($outputfile,"a+"); fputs($fp, "\nResult id=".$result); diff --git a/htdocs/core/class/antivir.class.php b/htdocs/core/class/antivir.class.php index 8a43c28f8a4..e90c208d32e 100644 --- a/htdocs/core/class/antivir.class.php +++ b/htdocs/core/class/antivir.class.php @@ -68,7 +68,7 @@ class AntiVir $return_var=0; $safemode=ini_get("safe_mode"); // Create a clean fullcommand - dol_syslog("AntiVir::dol_avscan_file Run command=".$fullcommand." with safe_mode ".($safe_mode?"on":"off")); + dol_syslog("AntiVir::dol_avscan_file Run command=".$fullcommand." with safe_mode ".($safemode?"on":"off")); // Run CLI command. If run of Windows, you can get return with echo %ERRORLEVEL% $lastline=exec($fullcommand, $output, $return_var); diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 476d683c68e..9af3ec03256 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -81,6 +81,8 @@ abstract class CommonObject { global $user,$conf,$langs; + $error=0; + dol_syslog(get_class($this)."::add_contact $fk_socpeople, $type_contact, $source"); // Check parameters @@ -200,6 +202,8 @@ abstract class CommonObject { global $user,$langs,$conf; + $error=0; + $sql = "DELETE FROM ".MAIN_DB_PREFIX."element_contact"; $sql.= " WHERE rowid =".$rowid; @@ -348,7 +352,7 @@ abstract class CommonObject $sql.= " AND ec.fk_c_type_contact=tc.rowid"; $sql.= " AND tc.element = '".$this->element."'"; - dol_syslog(get_class($object)."::swapContactStatus sql=".$sql); + dol_syslog(get_class($this)."::swapContactStatus sql=".$sql); $resql=$this->db->query($sql); if ($resql) { @@ -2055,7 +2059,7 @@ abstract class CommonObject // Produit 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->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 { - $discount=new DiscountAbsolute($db); + $discount=new DiscountAbsolute($this->db); $discount->fk_soc = $this->socid; $this->tpl['label'].= $discount->getNomUrl(0,'discount'); } diff --git a/htdocs/core/class/discount.class.php b/htdocs/core/class/discount.class.php index a759be3df03..ff065db2bae 100644 --- a/htdocs/core/class/discount.class.php +++ b/htdocs/core/class/discount.class.php @@ -208,7 +208,7 @@ class DiscountAbsolute } else { - dol_print_error($db); + dol_print_error($this->db); return -1; } } diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index ed5615f79f9..7953349e9a8 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -1036,7 +1036,7 @@ class Form if ($num) { $out.= ''; - if ($show_empty) $out.= ''."\n"; + if ($show_empty) $out.= ''."\n"; while ($i < $num) { diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 2b9e28c07a9..743c75284eb 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -358,7 +358,7 @@ class FormFile $headershown=1; - $form = new Form($db); + $form = new Form($this->db); $buttonlabeltoshow=$buttonlabel; if (empty($buttonlabel)) $buttonlabel=$langs->trans('Generate'); @@ -537,7 +537,7 @@ class FormFile { global $user, $conf, $langs; global $bc; - global $sortfield, $sortorder; + global $sortfield, $sortorder, $maxheightmini; // Show list of existing files if (empty($useinecm)) print_titre($langs->trans("AttachedFiles")); diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index 590282a5358..092dd13f6c1 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -223,7 +223,7 @@ class FormMail if (! empty($_SESSION["listofmimes"])) $listofmimes=explode(';',$_SESSION["listofmimes"]); - $form=new Form($DB); + $form=new Form($this->db); $out.= "\n\n"; if ($this->withform) diff --git a/htdocs/core/class/html.formorder.class.php b/htdocs/core/class/html.formorder.class.php index 147b141c938..68c4a21b688 100644 --- a/htdocs/core/class/html.formorder.class.php +++ b/htdocs/core/class/html.formorder.class.php @@ -47,16 +47,17 @@ class FormOrder /** - * \brief Renvoie la liste des sources de commandes - * \param selected Id de la source pre-selectionnee - * \param htmlname Nom de la liste deroulante - * \param addempty 0=liste sans valeur nulle, 1=ajoute valeur inconnue - * \return array Tableau des sources de commandes + * Renvoie la liste des sources de commandes + * + * @param selected Id de la source pre-selectionnee + * @param htmlname Nom de la liste deroulante + * @param addempty 0=liste sans valeur nulle, 1=ajoute valeur inconnue + * @return array Tableau des sources de commandes */ function selectSourcesCommande($selected='',$htmlname='source_id',$addempty=0) { global $conf,$langs; - print ''; if ($addempty) print ''; // TODO Use a table called llx_c_input_reason diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php index 679485a4a07..3ecc086a548 100644 --- a/htdocs/core/class/html.formother.class.php +++ b/htdocs/core/class/html.formother.class.php @@ -311,7 +311,6 @@ class FormOther $moreforfilter.='>'; $moreforfilter.=$obj_usr->firstname." ".$obj_usr->name." (".$obj_usr->login.')'; $moreforfilter.=''; - $i++; } $this->db->free($resql_usr); } diff --git a/htdocs/core/class/ldap.class.php b/htdocs/core/class/ldap.class.php index a8cf6927cef..1f2483fc91b 100644 --- a/htdocs/core/class/ldap.class.php +++ b/htdocs/core/class/ldap.class.php @@ -633,8 +633,8 @@ class Ldap //Create file $result=create_exdir($conf->ldap->dir_temp); - $file=$conf->ldap->dir_temp.'/ldapinput.in'; - $fp=fopen($file,"w"); + $outputfile=$conf->ldap->dir_temp.'/ldapinput.in'; + $fp=fopen($outputfile,"w"); if ($fp) { fputs($fp, $content); diff --git a/htdocs/core/class/menubase.class.php b/htdocs/core/class/menubase.class.php index 53c05be3bb4..be940844072 100644 --- a/htdocs/core/class/menubase.class.php +++ b/htdocs/core/class/menubase.class.php @@ -395,7 +395,7 @@ class Menubase //print 'name='.$tab[$x][3].' pere='.$pere." ".$tab[$x][6]; $this->newmenu->add((! preg_match("/^(http:\/\/|https:\/\/)/i",$tab[$x][2])) ? $tab[$x][2] : $tab[$x][2], $tab[$x][3], $rang -1, $tab[$x][4], $tab[$x][5], $tab[$x][8]); - $this->recur($tab, $tab[$x][0], $rang +1, $lelfmenu); + $this->recur($tab, $tab[$x][0], $rang +1, $leftmenu); } } } diff --git a/htdocs/core/class/vcard.class.php b/htdocs/core/class/vcard.class.php index d54bf45643b..5b800867298 100755 --- a/htdocs/core/class/vcard.class.php +++ b/htdocs/core/class/vcard.class.php @@ -184,7 +184,7 @@ class vCard $key = "ADR"; if ($type!="") $key.= ";$type"; $key.= ";CHARSET=".$this->encoding; - $this->properties[$key] = encode($name).";".encode($extended).";".encode($street).";".encode($city).";".encode($region).";".encode($zip).";".encode($country); + $this->properties[$key] = ";".encode($extended).";".encode($street).";".encode($city).";".encode($region).";".encode($zip).";".encode($country); if ($this->properties["LABEL;$type;CHARSET=".$this->encoding] == "") { diff --git a/htdocs/core/lib/agenda.lib.php b/htdocs/core/lib/agenda.lib.php index 99e7050c096..0dc0583e481 100644 --- a/htdocs/core/lib/agenda.lib.php +++ b/htdocs/core/lib/agenda.lib.php @@ -374,6 +374,7 @@ function actions_prepare_head($action) /** * Define head array for tabs of agenda setup pages + * * @return Array of head */ function calendars_prepare_head($param) @@ -388,6 +389,8 @@ function calendars_prepare_head($param) $head[$h][2] = 'card'; $h++; + $object=(object) array(); + // Show more tabs from modules // Entries must be declared in modules descriptor with line // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index bad2bc75e70..67e72ed3fc5 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -495,6 +495,8 @@ function dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disable global $conf, $user, $langs, $db; global $object; + $error=0; + $file_name = $dest_file; // If an upload error has been reported if ($uploaderrorcode) @@ -606,8 +608,6 @@ function dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disable dol_syslog("Functions.lib::dol_move_uploaded_file Failed to move ".$src_file." to ".$file_name, LOG_ERR); return -3; // Unknown error } - - return 1; } /** @@ -624,6 +624,8 @@ function dol_delete_file($file,$disableglob=0,$nophperrors=0,$notrigger=0,$objec { global $db, $conf, $user, $langs; + $error=0; + //print "x".$file." ".$disableglob; $ok=true; $file_osencoded=dol_osencode($file); // New filename encoded in OS filesystem encoding charset @@ -1003,8 +1005,6 @@ function dol_convert_file($file,$ext='png') { return -1; } - - return 1; } diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index d34308792ee..2f4793d9df4 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -3977,7 +3977,7 @@ function get_htmloutput_mesg($mesgstring='',$mesgarray='', $style='ok', $keepemb } // If inline message with no format, we add it. - if ((! empty($conf->global->MAIN_DISABLE_JQUERY_JNOTIFY) || $keepembedded) && ! preg_match('/
/i',$out)) + if ((empty($conf->use_javascript_ajax) || ! empty($conf->global->MAIN_DISABLE_JQUERY_JNOTIFY) || $keepembedded) && ! preg_match('/
/i',$out)) { $divstart='
'; $divend='
'; @@ -4007,7 +4007,7 @@ function get_htmloutput_mesg($mesgstring='',$mesgarray='', $style='ok', $keepemb if ($out) { - if (empty($conf->global->MAIN_DISABLE_JQUERY_JNOTIFY) && empty($keepembedded)) + if ($conf->use_javascript_ajax && empty($conf->global->MAIN_DISABLE_JQUERY_JNOTIFY) && empty($keepembedded)) { $return = '