From 14c61e5cb458cefedea9b5f6f904645f748faade Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 5 Dec 2011 09:56:38 +0100 Subject: [PATCH 01/11] Fix: move font --- build/makepack-dolibarr.pl | 10 ++++------ build/rpm/dolibarr_fedora.spec | 1 + build/rpm/dolibarr_mandriva.spec | 1 + build/rpm/dolibarr_opensuse.spec | 1 + 4 files changed, 7 insertions(+), 6 deletions(-) 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/*_* From b0aff1c927fd142d9e13f57be8541cdece5a64e5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 5 Dec 2011 17:13:48 +0100 Subject: [PATCH 02/11] Fix: fix not initialized variables --- .../boutique/commande/class/boutiquecommande.class.php | 10 +++++----- htdocs/boutique/promotion/class/promotion.class.php | 7 +++---- htdocs/categories/class/categorie.class.php | 4 ++++ htdocs/core/class/CMailFile.class.php | 3 ++- htdocs/core/class/CSMSFile.class.php | 6 ++++-- htdocs/core/class/ldap.class.php | 4 ++-- htdocs/core/lib/files.lib.php | 8 ++++---- htdocs/core/lib/functions.lib.php | 3 ++- htdocs/core/lib/functions2.lib.php | 2 +- htdocs/core/lib/pdf.lib.php | 1 + htdocs/core/lib/report.lib.php | 2 +- htdocs/core/lib/sendings.lib.php | 4 +--- 12 files changed, 30 insertions(+), 24 deletions(-) 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..492f3ee15cd 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -130,6 +130,8 @@ class Categorie 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; @@ -209,6 +211,8 @@ class Categorie { global $conf, $langs; + $error=0; + // Clean parameters $this->label=trim($this->label); $this->description=trim($this->description); 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/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/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..9d6da6acf54 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -4417,7 +4417,8 @@ function complete_head_from_modules($conf,$langs,$object,&$head,&$h,$type,$mode= function printCommonFooter($zone='private') { global $conf; - + global $micro_start_time; + if ($zone == 'private') print "\n".''."\n"; else print "\n".''."\n"; diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php index 2e423d2c1a1..8ea11314e07 100644 --- a/htdocs/core/lib/functions2.lib.php +++ b/htdocs/core/lib/functions2.lib.php @@ -936,7 +936,7 @@ function dol_set_user_param($db, $conf, &$user, $tab) foreach ($tab as $key => $value) { // Set new parameters - if ($value && (! $url || in_array($key,array('sortfield','sortorder','begin','page')))) + if ($value) { $sql = "INSERT INTO ".MAIN_DB_PREFIX."user_param(fk_user,entity,param,value)"; $sql.= " VALUES (".$user->id.",".$conf->entity.","; diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 31e90acfe3a..d557c73bf3d 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -806,6 +806,7 @@ function pdf_getlinedesc($object,$i,$outputlangs,$hideref=0,$hidedesc=0,$issuppl if ($object->lines[$i]->date_start || $object->lines[$i]->date_end) { + $format='day'; // Show duration if exists if ($object->lines[$i]->date_start && $object->lines[$i]->date_end) { diff --git a/htdocs/core/lib/report.lib.php b/htdocs/core/lib/report.lib.php index 79c3efb8dfc..02f982bcbb6 100644 --- a/htdocs/core/lib/report.lib.php +++ b/htdocs/core/lib/report.lib.php @@ -36,7 +36,7 @@ */ function report_header($nom,$variante='',$period,$periodlink,$description,$builddate,$exportlink='',$moreparam=array()) { - global $langs; + global $langs, $hselected; print "\n\n\n"; diff --git a/htdocs/core/lib/sendings.lib.php b/htdocs/core/lib/sendings.lib.php index 26eb692c8bd..490fa576ace 100644 --- a/htdocs/core/lib/sendings.lib.php +++ b/htdocs/core/lib/sendings.lib.php @@ -131,8 +131,6 @@ function show_list_sending_receive($origin='commande',$origin_id,$filter='') if ($num) { - if ($somethingshown) print '
'; - if ($filter) print_titre($langs->trans("OtherSendingsForSameOrder")); else print_titre($langs->trans("SendingsAndReceivingForSameOrder")); @@ -191,7 +189,7 @@ function show_list_sending_receive($origin='commande',$origin_id,$filter='') else { print ""; - if ($type==1) $text = img_object($langs->trans('Service'),'service'); + if ($objp->fk_product_type==1) $text = img_object($langs->trans('Service'),'service'); else $text = img_object($langs->trans('Product'),'product'); print $text.' '.nl2br($objp->description); From ebea7f6c971263940f2c2b8747d39a6af1517ee0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 5 Dec 2011 18:36:54 +0100 Subject: [PATCH 03/11] Fix: fix not initialized variables --- htdocs/categories/class/categorie.class.php | 26 +++--- htdocs/comm/propal/class/propal.class.php | 18 ++-- htdocs/commande/class/commande.class.php | 87 +++++++++++-------- htdocs/compta/bank/class/account.class.php | 1 - htdocs/compta/dons/class/don.class.php | 4 +- .../facture/class/facture-rec.class.php | 14 +-- htdocs/compta/facture/class/facture.class.php | 16 +++- .../compta/localtax/class/localtax.class.php | 8 +- .../cheque/class/remisecheque.class.php | 9 +- .../class/bon-prelevement.class.php | 7 +- htdocs/compta/tva/class/tva.class.php | 15 ++-- .../actions_contactcard_common.class.php | 11 +-- htdocs/contact/class/contact.class.php | 6 +- htdocs/contrat/class/contrat.class.php | 32 ++++--- htdocs/core/boxes/box_external_rss.php | 8 +- htdocs/core/class/commonobject.class.php | 8 +- htdocs/core/class/discount.class.php | 2 +- htdocs/core/class/html.form.class.php | 10 ++- htdocs/core/class/html.formfile.class.php | 4 +- htdocs/core/class/html.formmail.class.php | 2 +- .../member/cards/pdf_standard.class.php | 11 +-- .../company/actions_card_company.class.php | 5 +- 22 files changed, 179 insertions(+), 125 deletions(-) diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 492f3ee15cd..2985e4651e0 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -121,11 +121,12 @@ 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'); @@ -203,11 +204,12 @@ 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; @@ -883,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/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/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 476d683c68e..82be4f026e4 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; @@ -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/modules/member/cards/pdf_standard.class.php b/htdocs/core/modules/member/cards/pdf_standard.class.php index b058855a697..85eb6f1f182 100644 --- a/htdocs/core/modules/member/cards/pdf_standard.class.php +++ b/htdocs/core/modules/member/cards/pdf_standard.class.php @@ -357,10 +357,11 @@ class pdf_standard { /** - * \brief Function to build PDF on disk, then output on HTTP strem. - * \param arrayofmembers Array of members informations - * \param outputlangs Lang object for output language - * \return int 1=ok, 0=ko + * Function to build PDF on disk, then output on HTTP strem. + * + * @param arrayofmembers Array of members informations + * @param outputlangs Lang object for output language + * @return int 1=ok, 0=ko */ function write_file($arrayofmembers,$outputlangs) { @@ -457,7 +458,7 @@ class pdf_standard { $filename='tmpcards.pdf'; $type=dol_mimetype($filename); - if ($encoding) header('Content-Encoding: '.$encoding); + //if ($encoding) header('Content-Encoding: '.$encoding); if ($type) header('Content-Type: '.$type); if ($attachment) header('Content-Disposition: attachment; filename="'.$filename.'"'); else header('Content-Disposition: inline; filename="'.$filename.'"'); diff --git a/htdocs/societe/canvas/company/actions_card_company.class.php b/htdocs/societe/canvas/company/actions_card_company.class.php index 1238894b885..5f581d3b69b 100644 --- a/htdocs/societe/canvas/company/actions_card_company.class.php +++ b/htdocs/societe/canvas/company/actions_card_company.class.php @@ -75,8 +75,9 @@ class ActionsCardCompany extends ActionsCardCommon /** * Execute actions * - * @param int $socid Id of object (may be empty for creation) - * @return int <0 if KO, >0 if OK + * @param string &$action Type of action + * @param int $id Id of object + * @return int <0 if KO, >0 if OK */ function doActions(&$action, $id) { From ffaf4e546581e278dce7464ee7c78f297e7f63c3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 5 Dec 2011 19:03:36 +0100 Subject: [PATCH 04/11] Fix: fix not initialized variables --- htdocs/core/class/antivir.class.php | 2 +- htdocs/core/class/commonobject.class.php | 2 +- htdocs/core/class/html.formorder.class.php | 13 +++++++------ htdocs/core/class/html.formother.class.php | 1 - htdocs/core/class/menubase.class.php | 2 +- htdocs/core/class/vcard.class.php | 2 +- htdocs/core/lib/agenda.lib.php | 3 +++ htdocs/core/lib/functions2.lib.php | 2 +- htdocs/core/lib/member.lib.php | 1 + htdocs/core/lib/project.lib.php | 11 +++-------- htdocs/core/login/functions_ldap.php | 4 ++-- htdocs/core/menus/standard/auguria.lib.php | 2 +- htdocs/core/menus/standard/eldy.lib.php | 2 +- .../core/modules/cheque/pdf/pdf_blochet.class.php | 8 ++++---- .../core/modules/commande/mod_commande_saphir.php | 2 +- htdocs/core/modules/commande/modules_commande.php | 2 ++ htdocs/core/modules/contract/mod_contract_magre.php | 2 +- htdocs/core/modules/dons/modules_don.php | 2 +- .../modules/expedition/mod_expedition_ribera.php | 2 +- .../facture/doc/doc_generic_invoice_odt.modules.php | 7 +++---- htdocs/core/modules/facture/mod_facture_mercure.php | 2 +- htdocs/core/modules/facture/modules_facture.php | 2 ++ htdocs/core/modules/fichinter/mod_arctic.php | 2 +- .../core/modules/livraison/mod_livraison_saphir.php | 2 +- .../modules/livraison/pdf/pdf_sirocco.modules.php | 2 +- .../modules/livraison/pdf/pdf_typhon.modules.php | 5 +++-- htdocs/core/modules/mailings/framboise.modules.php | 2 +- .../core/modules/mailings/thirdparties.modules.php | 2 +- htdocs/core/modules/modComptabilite.class.php | 2 ++ htdocs/core/modules/modContrat.class.php | 2 ++ htdocs/core/modules/modMailing.class.php | 2 ++ htdocs/core/modules/modNotification.class.php | 2 ++ htdocs/core/modules/modTax.class.php | 2 ++ htdocs/core/modules/modWorkflow.class.php | 5 ++++- htdocs/projet/tasks.php | 2 ++ 35 files changed, 63 insertions(+), 45 deletions(-) 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 82be4f026e4..9af3ec03256 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -352,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) { 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/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/functions2.lib.php b/htdocs/core/lib/functions2.lib.php index 8ea11314e07..c839d4fe462 100644 --- a/htdocs/core/lib/functions2.lib.php +++ b/htdocs/core/lib/functions2.lib.php @@ -675,7 +675,7 @@ function check_value($mask,$value) $maskrefclient_maskclientcode=$regClientRef[1]; $maskrefclient_maskcounter=$regClientRef[2]; $maskrefclient_maskoffset=0; //default value of maskrefclient_counter offset - $maskrefclient_clientcode=substr($valueforccc,0,dol_strlen($maskrefclient_maskclientcode));//get n first characters of client code to form maskrefclient_clientcode + $maskrefclient_clientcode=substr('',0,dol_strlen($maskrefclient_maskclientcode));//get n first characters of client code to form maskrefclient_clientcode $maskrefclient_clientcode=str_pad($maskrefclient_clientcode,dol_strlen($maskrefclient_maskclientcode),"#",STR_PAD_RIGHT);//padding maskrefclient_clientcode for having exactly n characters in maskrefclient_clientcode $maskrefclient_clientcode=dol_string_nospecial($maskrefclient_clientcode);//sanitize maskrefclient_clientcode for sql insert and sql select like if (dol_strlen($maskrefclient_maskcounter) > 0 && dol_strlen($maskrefclient_maskcounter) < 3) return 'CounterMustHaveMoreThan3Digits'; diff --git a/htdocs/core/lib/member.lib.php b/htdocs/core/lib/member.lib.php index 65822f82972..59f6a150276 100644 --- a/htdocs/core/lib/member.lib.php +++ b/htdocs/core/lib/member.lib.php @@ -23,6 +23,7 @@ /** * Return array head with list of tabs to view object informations + * * @param object Member * @return array head */ diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index f02565209c3..8a56766f46c 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -265,13 +265,10 @@ function select_projects($socid=-1, $selected='', $htmlname='projectid') function PLinesb(&$inc, $parent, $lines, &$level, &$projectsrole, &$tasksrole, $mytask=0) { global $user, $bc, $langs; - global $form; + global $form, $projectstatic, $taskstatic; $lastprojectid=0; - $projectstatic = new Project($db); - $taskstatic = new Task($db); - $var=true; $numlines=count($lines); @@ -380,12 +377,10 @@ function PLinesb(&$inc, $parent, $lines, &$level, &$projectsrole, &$tasksrole, $ function PLines(&$inc, $parent, &$lines, &$level, $var, $showproject, &$taskrole, $projectsListId='') { global $user, $bc, $langs; - + global $projectstatic, $taskstatic; + $lastprojectid=0; - $projectstatic = new Project($db); - $taskstatic = new Task($db); - $projectsArrayId=explode(',',$projectsListId); $numlines=count($lines); diff --git a/htdocs/core/login/functions_ldap.php b/htdocs/core/login/functions_ldap.php index 794187d5ca5..bf216533e17 100644 --- a/htdocs/core/login/functions_ldap.php +++ b/htdocs/core/login/functions_ldap.php @@ -84,9 +84,9 @@ function check_user_password_ldap($usertotest,$passwordtotest,$entitytotest) if ($ldapdebug) { dol_syslog("functions_ldap::check_user_password_ldap Server:".join(',',$ldap->server).", Port:".$ldap->serverPort.", Protocol:".$ldap->ldapProtocolVersion.", Type:".$ldap->serverType); - dol_syslog("functions_ldap::check_user_password_ldap uid/samacountname=".$ldapuserattr.", dn=".$ladpdn.", Admin:".$ldap->searchUser.", Pass:".$ldap->searchPassword); + dol_syslog("functions_ldap::check_user_password_ldap uid/samacountname=".$ldapuserattr.", dn=".$ldapdn.", Admin:".$ldap->searchUser.", Pass:".$ldap->searchPassword); print "DEBUG: Server:".join(',',$ldap->server).", Port:".$ldap->serverPort.", Protocol:".$ldap->ldapProtocolVersion.", Type:".$ldap->serverType."\n"; - print "DEBUG: uid/samacountname=".$ldapuserattr.", dn=".$ladpdn.", Admin:".$ldap->searchUser.", Pass:".$ldap->searchPassword."\n"; + print "DEBUG: uid/samacountname=".$ldapuserattr.", dn=".$ldapdn.", Admin:".$ldap->searchUser.", Pass:".$ldap->searchPassword."\n"; } $resultFetchLdapUser=0; diff --git a/htdocs/core/menus/standard/auguria.lib.php b/htdocs/core/menus/standard/auguria.lib.php index a1a18fb613b..be59ec95da4 100644 --- a/htdocs/core/menus/standard/auguria.lib.php +++ b/htdocs/core/menus/standard/auguria.lib.php @@ -204,7 +204,7 @@ function print_left_auguria_menu($db,$menu_array_before,$menu_array_after) print ''; print ''; print ''; print ''; print ''."\n"; diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index b886c26fca1..493eb821e53 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -601,7 +601,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after) print ''; print ''; print ''; print ''; print ''."\n"; diff --git a/htdocs/core/modules/cheque/pdf/pdf_blochet.class.php b/htdocs/core/modules/cheque/pdf/pdf_blochet.class.php index 1a0ef43a2bc..4672b95dbce 100644 --- a/htdocs/core/modules/cheque/pdf/pdf_blochet.class.php +++ b/htdocs/core/modules/cheque/pdf/pdf_blochet.class.php @@ -167,7 +167,7 @@ class BordereauChequeBlochet extends ModeleChequeReceipts $pdf->Output($_file,'F'); if (! empty($conf->global->MAIN_UMASK)) - @chmod($file, octdec($conf->global->MAIN_UMASK)); + @chmod($_file, octdec($conf->global->MAIN_UMASK)); $outputlangs->charset_output=$sav_charset_output; return 1; // Pas d'erreur @@ -359,7 +359,7 @@ class BordereauChequeBlochet extends ModeleChequeReceipts // On positionne le debut du bas de page selon nbre de lignes de ce bas de page $nbofline=dol_nboflines_bis($line,0,$outputlangs->charset_output); //print 'e'.$line.'t'.dol_nboflines($line);exit; - $posy=$marge_basse + ($nbofline*3) + ($line1?3:0) + ($line2?3:0); + $posy=$marge_basse + ($nbofline*3); if ($line) // Free text { @@ -372,7 +372,7 @@ class BordereauChequeBlochet extends ModeleChequeReceipts $pdf->line($marge_gauche, $page_hauteur-$posy, 200, $page_hauteur-$posy); $posy--; - if ($line1) + /*if ($line1) { $pdf->SetXY($marge_gauche,-$posy); $pdf->MultiCell(200, 2, $line1, 0, 'C', 0); @@ -383,7 +383,7 @@ class BordereauChequeBlochet extends ModeleChequeReceipts $posy-=3; $pdf->SetXY($marge_gauche,-$posy); $pdf->MultiCell(200, 2, $line2, 0, 'C', 0); - } + }*/ // Show page nb only on iso languages (so default Helvetica font) if (pdf_getPDFFont($outputlangs) == 'Helvetica') diff --git a/htdocs/core/modules/commande/mod_commande_saphir.php b/htdocs/core/modules/commande/mod_commande_saphir.php index c4eece7500b..9d26ed47ef1 100644 --- a/htdocs/core/modules/commande/mod_commande_saphir.php +++ b/htdocs/core/modules/commande/mod_commande_saphir.php @@ -48,7 +48,7 @@ class mod_commande_saphir extends ModeleNumRefCommandes $langs->load("bills"); - $form = new Form($db); + $form = new Form($this->db); $texte = $langs->trans('GenericNumRefModelDesc')."
\n"; $texte.= '
'; diff --git a/htdocs/core/modules/commande/modules_commande.php b/htdocs/core/modules/commande/modules_commande.php index b829321b019..732088d9afb 100644 --- a/htdocs/core/modules/commande/modules_commande.php +++ b/htdocs/core/modules/commande/modules_commande.php @@ -155,6 +155,8 @@ function commande_pdf_create($db, $object, $modele, $outputlangs, $hidedetails=0 global $conf,$user,$langs; $langs->load("orders"); + $error=0; + $dir = "/core/modules/commande/"; $srctemplatepath=''; $modelisok=0; diff --git a/htdocs/core/modules/contract/mod_contract_magre.php b/htdocs/core/modules/contract/mod_contract_magre.php index 5c71c303d5f..f963e3d02e5 100755 --- a/htdocs/core/modules/contract/mod_contract_magre.php +++ b/htdocs/core/modules/contract/mod_contract_magre.php @@ -43,7 +43,7 @@ class mod_contract_magre extends ModelNumRefContracts $langs->load("bills"); - $form = new Form($db); + $form = new Form($this->db); $texte = $langs->trans('GenericNumRefModelDesc')."
\n"; $texte.= ''; diff --git a/htdocs/core/modules/dons/modules_don.php b/htdocs/core/modules/dons/modules_don.php index eeb7771e853..df917b1f5d9 100644 --- a/htdocs/core/modules/dons/modules_don.php +++ b/htdocs/core/modules/dons/modules_don.php @@ -177,7 +177,7 @@ function don_create($db, $id, $message, $modele, $outputlangs) // we delete preview files require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"); - dol_delete_preview($object); + dol_delete_preview($obj); return 1; } else diff --git a/htdocs/core/modules/expedition/mod_expedition_ribera.php b/htdocs/core/modules/expedition/mod_expedition_ribera.php index 5363d435c2c..bf832c4042b 100755 --- a/htdocs/core/modules/expedition/mod_expedition_ribera.php +++ b/htdocs/core/modules/expedition/mod_expedition_ribera.php @@ -43,7 +43,7 @@ class mod_expedition_ribera extends ModelNumRefExpedition $langs->load("bills"); - $form = new Form($db); + $form = new Form($this->db); $texte = $langs->trans('GenericNumRefModelDesc')."
\n"; $texte.= ''; diff --git a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php index 5743a724b35..faea0a306c8 100644 --- a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php +++ b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php @@ -166,7 +166,7 @@ class doc_generic_invoice_odt extends ModelePDFFactures $langs->load("companies"); $langs->load("errors"); - $form = new Form($db); + $form = new Form($this->db); $texte = $this->description.".
\n"; $texte.= ''; @@ -266,11 +266,10 @@ class doc_generic_invoice_odt extends ModelePDFFactures { $id = $object; $object = new Facture($this->db); - $object->fetch($id); - + $result=$object->fetch($id); if ($result < 0) { - dol_print_error($db,$object->error); + dol_print_error($this->db,$object->error); return -1; } } diff --git a/htdocs/core/modules/facture/mod_facture_mercure.php b/htdocs/core/modules/facture/mod_facture_mercure.php index c18a185110d..b1ee4c11bf6 100644 --- a/htdocs/core/modules/facture/mod_facture_mercure.php +++ b/htdocs/core/modules/facture/mod_facture_mercure.php @@ -46,7 +46,7 @@ class mod_facture_mercure extends ModeleNumRefFactures $langs->load("bills"); - $form = new Form($db); + $form = new Form($this->db); $texte = $langs->trans('GenericNumRefModelDesc')."
\n"; $texte.= ''; diff --git a/htdocs/core/modules/facture/modules_facture.php b/htdocs/core/modules/facture/modules_facture.php index 386fc2e5feb..27579626d11 100644 --- a/htdocs/core/modules/facture/modules_facture.php +++ b/htdocs/core/modules/facture/modules_facture.php @@ -149,6 +149,8 @@ function facture_pdf_create($db, $object, $message, $modele, $outputlangs, $hide $langs->load("bills"); + $error=0; + // Increase limit for PDF build $err=error_reporting(); error_reporting(0); diff --git a/htdocs/core/modules/fichinter/mod_arctic.php b/htdocs/core/modules/fichinter/mod_arctic.php index 9b8be8762aa..0616a58f070 100644 --- a/htdocs/core/modules/fichinter/mod_arctic.php +++ b/htdocs/core/modules/fichinter/mod_arctic.php @@ -52,7 +52,7 @@ class mod_arctic extends ModeleNumRefFicheinter $langs->load("bills"); - $form = new Form($db); + $form = new Form($this->db); $texte = $langs->trans('GenericNumRefModelDesc')."
\n"; $texte.= ''; diff --git a/htdocs/core/modules/livraison/mod_livraison_saphir.php b/htdocs/core/modules/livraison/mod_livraison_saphir.php index e0bbc8665c9..8ebe1591c68 100644 --- a/htdocs/core/modules/livraison/mod_livraison_saphir.php +++ b/htdocs/core/modules/livraison/mod_livraison_saphir.php @@ -45,7 +45,7 @@ class mod_livraison_saphir extends ModeleNumRefDeliveryOrder $langs->load("bills"); - $form = new Form($db); + $form = new Form($this->db); $texte = $langs->trans('GenericNumRefModelDesc')."
\n"; $texte.= ''; diff --git a/htdocs/core/modules/livraison/pdf/pdf_sirocco.modules.php b/htdocs/core/modules/livraison/pdf/pdf_sirocco.modules.php index fa0f8acaec6..8f0d75ac593 100644 --- a/htdocs/core/modules/livraison/pdf/pdf_sirocco.modules.php +++ b/htdocs/core/modules/livraison/pdf/pdf_sirocco.modules.php @@ -234,7 +234,7 @@ class pdf_sirocco extends ModelePDFDeliveryOrder $tab_height_in_current_page=$tab_height_newpage; } - if (($nexY+$nblineFollowDesc) > ($tab_top_in_current_page+$tab_height_in_current_page) && $i < ($nblignes - 1)) + if (($nexY+$nblineFollowDesc) > ($tab_top_in_current_page+$tab_height_in_current_page) && $i < ($nblines - 1)) { if ($pagenb == 1) { diff --git a/htdocs/core/modules/livraison/pdf/pdf_typhon.modules.php b/htdocs/core/modules/livraison/pdf/pdf_typhon.modules.php index e65a12aad2f..ce32fa45bf9 100644 --- a/htdocs/core/modules/livraison/pdf/pdf_typhon.modules.php +++ b/htdocs/core/modules/livraison/pdf/pdf_typhon.modules.php @@ -298,7 +298,7 @@ class pdf_typhon extends ModelePDFDeliveryOrder $tab_top_in_current_page=$tab_top_newpage; $tab_height_in_current_page=$tab_height_newpage; } - if (($nexY+$nblineFollowDesc) > ($tab_top_in_current_page+$tab_height_in_current_page) && $i < ($nblignes - 1)) + if (($nexY+$nblineFollowDesc) > ($tab_top_in_current_page+$tab_height_in_current_page) && $i < ($nblines - 1)) { if ($pagenb == 1) { @@ -344,7 +344,8 @@ class pdf_typhon extends ModelePDFDeliveryOrder // Check product remaining to be delivered // TODO doit etre modifie //$waitingDelivery = $object->getRemainingDelivered(); - + $waitingDelivery=''; + if (is_array($waitingDelivery) & !empty($waitingDelivery)) { $pdf->AddPage('P', 'A4'); diff --git a/htdocs/core/modules/mailings/framboise.modules.php b/htdocs/core/modules/mailings/framboise.modules.php index 3cc151abdda..6fb61212cc2 100644 --- a/htdocs/core/modules/mailings/framboise.modules.php +++ b/htdocs/core/modules/mailings/framboise.modules.php @@ -202,7 +202,7 @@ class mailing_framboise extends MailingTargets } else { - dol_print_error($db); + dol_print_error($this->db); } $s.=''; diff --git a/htdocs/core/modules/mailings/thirdparties.modules.php b/htdocs/core/modules/mailings/thirdparties.modules.php index 131ee661a18..39bcac186b3 100755 --- a/htdocs/core/modules/mailings/thirdparties.modules.php +++ b/htdocs/core/modules/mailings/thirdparties.modules.php @@ -218,7 +218,7 @@ class mailing_thirdparties extends MailingTargets } else { - dol_print_error($db); + dol_print_error($this->db); } $s.=''; diff --git a/htdocs/core/modules/modComptabilite.class.php b/htdocs/core/modules/modComptabilite.class.php index fd0cb925e1f..6bd9416babe 100644 --- a/htdocs/core/modules/modComptabilite.class.php +++ b/htdocs/core/modules/modComptabilite.class.php @@ -132,6 +132,8 @@ class modComptabilite extends DolibarrModules // Nettoyage avant activation $this->remove(); + $sql = array(); + return $this->_init($sql); } diff --git a/htdocs/core/modules/modContrat.class.php b/htdocs/core/modules/modContrat.class.php index 7ba03b23c9e..323362bc461 100644 --- a/htdocs/core/modules/modContrat.class.php +++ b/htdocs/core/modules/modContrat.class.php @@ -129,6 +129,8 @@ class modContrat extends DolibarrModules // Nettoyage avant activation $this->remove(); + $sql = array(); + return $this->_init($sql); } diff --git a/htdocs/core/modules/modMailing.class.php b/htdocs/core/modules/modMailing.class.php index a6ed37f1f88..b822dd46fee 100644 --- a/htdocs/core/modules/modMailing.class.php +++ b/htdocs/core/modules/modMailing.class.php @@ -111,6 +111,8 @@ class modMailing extends DolibarrModules // Permissions $this->remove(); + $sql = array(); + return $this->_init($sql); } diff --git a/htdocs/core/modules/modNotification.class.php b/htdocs/core/modules/modNotification.class.php index ca430eab2da..1dbb3155ac1 100644 --- a/htdocs/core/modules/modNotification.class.php +++ b/htdocs/core/modules/modNotification.class.php @@ -84,6 +84,8 @@ class modNotification extends DolibarrModules // Permissions $this->remove(); + $sql = array(); + return $this->_init($sql); } diff --git a/htdocs/core/modules/modTax.class.php b/htdocs/core/modules/modTax.class.php index de015e2348c..f1857409197 100644 --- a/htdocs/core/modules/modTax.class.php +++ b/htdocs/core/modules/modTax.class.php @@ -149,6 +149,8 @@ class modTax extends DolibarrModules // Nettoyage avant activation $this->remove(); + $sql = array(); + return $this->_init($sql); } diff --git a/htdocs/core/modules/modWorkflow.class.php b/htdocs/core/modules/modWorkflow.class.php index e4d66941ee0..d9965833c35 100644 --- a/htdocs/core/modules/modWorkflow.class.php +++ b/htdocs/core/modules/modWorkflow.class.php @@ -147,7 +147,10 @@ class modWorkflow extends DolibarrModules */ function init() { - //$result=$this->load_tables(); + // Permissions + $this->remove(); + + $sql = array(); return $this->_init($sql); } diff --git a/htdocs/projet/tasks.php b/htdocs/projet/tasks.php index 8c6f5898a49..d60cd2fab74 100644 --- a/htdocs/projet/tasks.php +++ b/htdocs/projet/tasks.php @@ -132,6 +132,8 @@ if ($_POST["action"] == 'createtask' && $user->rights->projet->creer) $form=new Form($db); $formother=new FormOther($db); +$projectstatic = new Project($db); +$taskstatic = new Task($db); $help_url="EN:Module_Projects|FR:Module_Projets|ES:Módulo_Proyectos"; llxHeader("",$langs->trans("Tasks"),$help_url); From b52fc32853da6407d00593378e89b6a13586e81e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 5 Dec 2011 19:41:38 +0100 Subject: [PATCH 05/11] Fix: fix not initialized variables --- .../member/labels/pdf_standardlabel.class.php | 6 ++-- .../modules/project/mod_project_universal.php | 2 +- .../modules/propale/mod_propale_saphir.php | 2 +- .../core/modules/propale/modules_propale.php | 6 ++-- .../propale/pdf_propale_azur.modules.php | 8 ++--- .../propale/pdf_propale_jaune.modules.php | 8 ++--- .../societe/doc/doc_generic_odt.modules.php | 7 ++-- .../societe/mod_codeclient_elephant.php | 2 +- .../societe/mod_codecompta_aquarium.php | 2 +- .../pdf/pdf_canelle.modules.php | 12 ++++--- .../mod_commande_fournisseur_orchidee.php | 2 +- .../pdf/pdf_muscadet.modules.php | 11 +++--- htdocs/ecm/class/ecmdirectory.class.php | 3 ++ htdocs/expedition/class/expedition.class.php | 10 +++--- htdocs/exports/class/export.class.php | 2 +- htdocs/fichinter/class/fichinter.class.php | 7 ++-- .../class/fournisseur.commande.class.php | 30 +++++++++------- .../fourn/class/fournisseur.facture.class.php | 15 ++++---- htdocs/install/upgrade2.php | 12 ------- htdocs/livraison/class/livraison.class.php | 15 ++++---- htdocs/paypal/lib/paypal.lib.php | 2 ++ .../product/actions_card_product.class.php | 4 +-- htdocs/product/class/product.class.php | 23 +++++++------ htdocs/product/stock/class/entrepot.class.php | 2 +- .../stock/class/mouvementstock.class.php | 2 +- htdocs/projet/class/project.class.php | 10 ++++-- htdocs/projet/class/task.class.php | 5 +++ htdocs/projet/ganttchart.php | 2 +- .../canvas/actions_card_common.class.php | 4 +-- htdocs/societe/class/societe.class.php | 34 ++++--------------- htdocs/user/class/user.class.php | 7 +++- htdocs/user/class/usergroup.class.php | 3 ++ ...ail_unpaid_invoices_to_representatives.php | 1 + test/phpunit/CategorieTest.php | 10 +++--- test/phpunit/SecurityTest.php | 4 +-- 35 files changed, 144 insertions(+), 131 deletions(-) diff --git a/htdocs/core/modules/member/labels/pdf_standardlabel.class.php b/htdocs/core/modules/member/labels/pdf_standardlabel.class.php index 85cba5f324a..583caddfe4d 100644 --- a/htdocs/core/modules/member/labels/pdf_standardlabel.class.php +++ b/htdocs/core/modules/member/labels/pdf_standardlabel.class.php @@ -144,7 +144,9 @@ class pdf_standardlabel { $logo=$conf->mycompany->dir_output.'/logos/'.$mysoc->logo; } } - + // Define photo + $photo=''; + // Print lines if ($this->code == "CARD") { @@ -436,7 +438,7 @@ class pdf_standardlabel { $filename='tmplabels.pdf'; $type=dol_mimetype($filename); - if ($encoding) header('Content-Encoding: '.$encoding); + //if ($encoding) header('Content-Encoding: '.$encoding); if ($type) header('Content-Type: '.$type); if ($attachment) header('Content-Disposition: attachment; filename="'.$filename.'"'); else header('Content-Disposition: inline; filename="'.$filename.'"'); diff --git a/htdocs/core/modules/project/mod_project_universal.php b/htdocs/core/modules/project/mod_project_universal.php index 744360612c6..0aaf3629dee 100644 --- a/htdocs/core/modules/project/mod_project_universal.php +++ b/htdocs/core/modules/project/mod_project_universal.php @@ -47,7 +47,7 @@ class mod_project_universal extends ModeleNumRefProjects $langs->load("projects"); $langs->load("admin"); - $form = new Form($db); + $form = new Form($this->db); $texte = $langs->trans('GenericNumRefModelDesc')."
\n"; $texte.= ''; diff --git a/htdocs/core/modules/propale/mod_propale_saphir.php b/htdocs/core/modules/propale/mod_propale_saphir.php index a44fc23a750..8249fa30604 100644 --- a/htdocs/core/modules/propale/mod_propale_saphir.php +++ b/htdocs/core/modules/propale/mod_propale_saphir.php @@ -48,7 +48,7 @@ class mod_propale_saphir extends ModeleNumRefPropales $langs->load("bills"); - $form = new Form($db); + $form = new Form($this->db); $texte = $langs->trans('GenericNumRefModelDesc')."
\n"; $texte.= ''; diff --git a/htdocs/core/modules/propale/modules_propale.php b/htdocs/core/modules/propale/modules_propale.php index f726b63727e..f04c20feae5 100644 --- a/htdocs/core/modules/propale/modules_propale.php +++ b/htdocs/core/modules/propale/modules_propale.php @@ -128,7 +128,7 @@ abstract class ModeleNumRefPropales /** - * Create a document onto disk accordign to template module. + * Create a document onto disk according to template module. * * @param DoliDB $db Database handler * @param Object $object Object proposal @@ -145,6 +145,8 @@ function propale_pdf_create($db, $object, $modele, $outputlangs, $hidedetails=0, global $conf,$user,$langs; $langs->load("propale"); + $error=0; + $dir = "/core/modules/propale/"; $srctemplatepath=''; $modelisok=0; @@ -181,7 +183,7 @@ function propale_pdf_create($db, $object, $modele, $outputlangs, $hidedetails=0, } // Si model pas encore bon - if (! $modelisok && is_array($liste)) + if (! $modelisok) { $liste=ModelePDFPropales::liste_modeles($db); $modele=key($liste); // Renvoie premiere valeur de cle trouve dans le tableau diff --git a/htdocs/core/modules/propale/pdf_propale_azur.modules.php b/htdocs/core/modules/propale/pdf_propale_azur.modules.php index 2a036aa8f0f..2befc3339cd 100644 --- a/htdocs/core/modules/propale/pdf_propale_azur.modules.php +++ b/htdocs/core/modules/propale/pdf_propale_azur.modules.php @@ -654,9 +654,9 @@ class pdf_propale_azur extends ModelePDFPropales { $index++; $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalLT1".$mysoc->pays_code), $useborder, 'L', 1); + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalLT1".$mysoc->pays_code), 0, 'L', 1); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_localtax1), $useborder, 'R', 1); + $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_localtax1), 0, 'R', 1); } // Total LocalTax2 @@ -664,9 +664,9 @@ class pdf_propale_azur extends ModelePDFPropales { $index++; $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalLT2".$mysoc->pays_code), $useborder, 'L', 1); + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalLT2".$mysoc->pays_code), 0, 'L', 1); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_localtax2), $useborder, 'R', 1); + $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_localtax2), 0, 'R', 1); } } else diff --git a/htdocs/core/modules/propale/pdf_propale_jaune.modules.php b/htdocs/core/modules/propale/pdf_propale_jaune.modules.php index 79c76a4c5c9..aed35de0c83 100644 --- a/htdocs/core/modules/propale/pdf_propale_jaune.modules.php +++ b/htdocs/core/modules/propale/pdf_propale_jaune.modules.php @@ -654,9 +654,9 @@ class pdf_propale_jaune extends ModelePDFPropales { $index++; $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalLT1".$mysoc->pays_code), $useborder, 'L', 1); + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalLT1".$mysoc->pays_code), 0, 'L', 1); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_localtax1), $useborder, 'R', 1); + $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_localtax1), 0, 'R', 1); } // Total LocalTax2 @@ -664,9 +664,9 @@ class pdf_propale_jaune extends ModelePDFPropales { $index++; $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalLT2".$mysoc->pays_code), $useborder, 'L', 1); + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalLT2".$mysoc->pays_code), 0, 'L', 1); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_localtax2), $useborder, 'R', 1); + $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_localtax2), 0, 'R', 1); } } else diff --git a/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php b/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php index 68681e069fc..1831e4cff2c 100644 --- a/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php +++ b/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php @@ -88,7 +88,7 @@ class doc_generic_odt extends ModeleThirdPartyDoc $langs->load("companies"); $langs->load("errors"); - $form = new Form($db); + $form = new Form($this->db); $texte = $this->description.".
\n"; $texte.= ''; @@ -187,11 +187,10 @@ class doc_generic_odt extends ModeleThirdPartyDoc { $id = $object; $object = new Societe($this->db); - $object->fetch($id); - + $result=$object->fetch($id); if ($result < 0) { - dol_print_error($db,$object->error); + dol_print_error($this->db,$object->error); return -1; } } diff --git a/htdocs/core/modules/societe/mod_codeclient_elephant.php b/htdocs/core/modules/societe/mod_codeclient_elephant.php index 59b8196dc11..e3db286e92a 100644 --- a/htdocs/core/modules/societe/mod_codeclient_elephant.php +++ b/htdocs/core/modules/societe/mod_codeclient_elephant.php @@ -72,7 +72,7 @@ class mod_codeclient_elephant extends ModeleThirdPartyCode $langs->load("companies"); - $form = new Form($db); + $form = new Form($this->db); $texte = $langs->trans('GenericNumRefModelDesc')."
\n"; $texte.= ''; diff --git a/htdocs/core/modules/societe/mod_codecompta_aquarium.php b/htdocs/core/modules/societe/mod_codecompta_aquarium.php index e4b94e0b75a..4d3ea14cd45 100644 --- a/htdocs/core/modules/societe/mod_codecompta_aquarium.php +++ b/htdocs/core/modules/societe/mod_codecompta_aquarium.php @@ -61,7 +61,7 @@ class mod_codecompta_aquarium extends ModeleAccountancyCode $langs->load("companies"); - $form = new Form($db); + $form = new Form($this->db); $tooltip=''; $texte = ''; diff --git a/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php b/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php index 26262e3bc96..1cdcc83c2f1 100755 --- a/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php +++ b/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php @@ -355,6 +355,9 @@ class pdf_canelle extends ModelePDFSuppliersInvoices // Affiche zone totaux $posy=$this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs); + $amount_credit_notes_included=0; + $amount_deposits_included=0; + if ($deja_regle || $amount_credit_notes_included || $amount_deposits_included) { $posy=$this->_tableau_versements($pdf, $object, $posy, $outputlangs); @@ -423,6 +426,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices // Affichage des totaux de TVA par taux (conformement a reglementation) $pdf->SetFillColor(248,248,248); + $index=0; foreach( $this->tva as $tvakey => $tvaval ) { if ($tvakey > 0) // On affiche pas taux 0 @@ -461,9 +465,9 @@ class pdf_canelle extends ModelePDFSuppliersInvoices { $index++; $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalLT1".$mysoc->pays_code), $useborder, 'L', 1); + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalLT1".$mysoc->pays_code), 0, 'L', 1); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_localtax1), $useborder, 'R', 1); + $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_localtax1), 0, 'R', 1); } // Total LocalTax2 @@ -471,9 +475,9 @@ class pdf_canelle extends ModelePDFSuppliersInvoices { $index++; $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalLT2".$mysoc->pays_code), $useborder, 'L', 1); + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalLT2".$mysoc->pays_code), 0, 'L', 1); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_localtax2), $useborder, 'R', 1); + $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_localtax2), 0, 'R', 1); } } else diff --git a/htdocs/core/modules/supplier_order/mod_commande_fournisseur_orchidee.php b/htdocs/core/modules/supplier_order/mod_commande_fournisseur_orchidee.php index e65a179f277..ae153661fb3 100644 --- a/htdocs/core/modules/supplier_order/mod_commande_fournisseur_orchidee.php +++ b/htdocs/core/modules/supplier_order/mod_commande_fournisseur_orchidee.php @@ -48,7 +48,7 @@ class mod_commande_fournisseur_orchidee extends ModeleNumRefSuppliersOrders $langs->load("bills"); $langs->load("admin"); - $form = new Form($db); + $form = new Form($this->db); $texte = $langs->trans('GenericNumRefModelDesc')."
\n"; $texte.= ''; diff --git a/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php b/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php index 71b8c244d50..846c3de4c16 100644 --- a/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php +++ b/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php @@ -356,6 +356,8 @@ class pdf_muscadet extends ModelePDFSuppliersOrders // Affiche zone totaux $posy=$this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs); + $amount_credit_notes_included=0; + $amount_deposits_included=0; if ($deja_regle || $amount_credit_notes_included || $amount_deposits_included) { $this->_tableau_versements($pdf, $object, $posy); @@ -426,6 +428,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders // Affichage des totaux de TVA par taux (conformement a reglementation) $pdf->SetFillColor(248,248,248); + $index=0; foreach( $this->tva as $tvakey => $tvaval ) { if ($tvakey > 0) // On affiche pas taux 0 @@ -465,9 +468,9 @@ class pdf_muscadet extends ModelePDFSuppliersOrders { $index++; $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalLT1".$mysoc->pays_code), $useborder, 'L', 1); + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalLT1".$mysoc->pays_code), 0, 'L', 1); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_localtax1), $useborder, 'R', 1); + $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_localtax1), 0, 'R', 1); } // Total LocalTax2 @@ -475,9 +478,9 @@ class pdf_muscadet extends ModelePDFSuppliersOrders { $index++; $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalLT2".$mysoc->pays_code), $useborder, 'L', 1); + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalLT2".$mysoc->pays_code), 0, 'L', 1); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_localtax2), $useborder, 'R', 1); + $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_localtax2), 0, 'R', 1); } } else diff --git a/htdocs/ecm/class/ecmdirectory.class.php b/htdocs/ecm/class/ecmdirectory.class.php index 0c5f8c375f7..2ceac9d7035 100644 --- a/htdocs/ecm/class/ecmdirectory.class.php +++ b/htdocs/ecm/class/ecmdirectory.class.php @@ -70,6 +70,7 @@ class EcmDirectory // extends CommonObject { global $conf, $langs; + $error=0; $now=dol_now(); // Clean parameters @@ -328,6 +329,8 @@ class EcmDirectory // extends CommonObject global $conf, $langs; require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"); + $error=0; + $relativepath=$this->getRelativePath(1); // Ex: dir1/dir2/dir3 dol_syslog("EcmDirectories::delete remove directory ".$relativepath); diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index 76c473ac851..7c956ae3405 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -398,14 +398,14 @@ class Expedition extends CommonObject } else { - dol_syslog('Expedition::Fetch Error rowid='.$rowid.' numrows=0 sql='.$sql); - $this->error='Delivery with id '.$rowid.' not found sql='.$sql; + dol_syslog('Expedition::Fetch Error -2'); + $this->error='Delivery with id '.$id.' not found sql='.$sql; return -2; } } else { - dol_syslog('Expedition::Fetch Error rowid='.$rowid.' Erreur dans fetch de l\'expedition'); + dol_syslog('Expedition::Fetch Error -1'); $this->error=$this->db->error(); return -1; } @@ -768,8 +768,10 @@ class Expedition extends CommonObject function delete() { global $conf, $langs, $user; - require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"); + + $error=0; + $this->db->begin(); $sql = "DELETE FROM ".MAIN_DB_PREFIX."expeditiondet"; diff --git a/htdocs/exports/class/export.class.php b/htdocs/exports/class/export.class.php index c5ddf7eb96e..c1f62634c16 100644 --- a/htdocs/exports/class/export.class.php +++ b/htdocs/exports/class/export.class.php @@ -267,7 +267,7 @@ class Export $file = "export_".$model.".modules.php"; $classname = "Export".$model; require_once($dir.$file); - $objmodel = new $classname($db); + $objmodel = new $classname($this->db); if ($sqlquery) $sql = $sqlquery; else $sql=$this->build_sql($indice,$array_selected); diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index 212c7d84694..b1975181df7 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -309,7 +309,9 @@ class Fichinter extends CommonObject function setValid($user, $outputdir) { global $langs, $conf; - + + $error=0; + if ($this->statut != 1) { $this->db->begin(); @@ -578,6 +580,7 @@ class Fichinter extends CommonObject if (! $this->db->query($sql) ) { dol_syslog("Fichinter::delete error", LOG_ERR); + $this->error=$this->db->lasterror(); $error++; } @@ -589,7 +592,7 @@ class Fichinter extends CommonObject $error++; } - if ($err > 0) + if ($error) { $this->db->rollback(); return -1; diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index d4825c62fd1..1db422884f5 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -706,6 +706,8 @@ class CommandeFournisseur extends Commande { global $conf, $langs; + $error=0; + dol_syslog("CommandeFournisseur::Refuse"); $result = 0; if ($user->rights->fournisseur->commande->approuver) @@ -750,6 +752,8 @@ class CommandeFournisseur extends Commande { global $langs,$conf; + $error=0; + //dol_syslog("CommandeFournisseur::Cancel"); $result = 0; if ($user->rights->fournisseur->commande->commander) @@ -847,7 +851,8 @@ class CommandeFournisseur extends Commande global $langs,$conf; $this->db->begin(); - + + $error=0; $now=dol_now(); /* On positionne en mode brouillon la commande */ @@ -919,6 +924,7 @@ class CommandeFournisseur extends Commande /** * Add order line + * * @param desc Description * @param pu_ht Unit price * @param qty Quantity @@ -934,7 +940,7 @@ class CommandeFournisseur extends Commande * @param type Type of line (0=product, 1=service) * @return int <=0 if KO, >0 if OK */ - function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0, $txlocaltax2=0, $fk_product=0, $fk_prod_fourn_price=0, $fourn_ref='', $remise_percent=0, $price_base_type='HT', $pu_ttc=0, $type=0) + function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0, $txlocaltax2=0, $fk_product=0, $fk_prod_fourn_price=0, $fourn_ref='', $remise_percent=0, $price_base_type='HT', $pu_ttc=0, $type=0, $info_bits=0) { global $langs,$mysoc; @@ -1134,7 +1140,6 @@ class CommandeFournisseur extends Commande $error++; } } - $i++; } if ($error == 0) @@ -1188,13 +1193,14 @@ class CommandeFournisseur extends Commande /** * Delete an order * - * @return int <0 if KO, >0 if OK + * @param User $user Object user + * @return int <0 if KO, >0 if OK */ - function delete() + function delete($user='') { global $langs,$conf; - $err = 0; + $error = 0; $this->db->begin(); @@ -1202,7 +1208,7 @@ class CommandeFournisseur extends Commande dol_syslog("FournisseurCommande::delete sql=".$sql, LOG_DEBUG); if (! $this->db->query($sql) ) { - $err++; + $error++; } $sql = "DELETE FROM ".MAIN_DB_PREFIX."commande_fournisseur WHERE rowid =".$this->id; @@ -1211,15 +1217,15 @@ class CommandeFournisseur extends Commande { if ($this->db->affected_rows($resql) < 1) { - $err++; + $error++; } } else { - $err++; + $error++; } - if ($err == 0) + if ($error == 0) { // Appel des triggers include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"); @@ -1630,10 +1636,10 @@ class CommandeFournisseur extends Commande $sql.= ",localtax1_tx='".price2num($txlocaltax1)."'"; $sql.= ",localtax2_tx='".price2num($txlocaltax2)."'"; $sql.= ",qty='".price2num($qty)."'"; - if ($date_end) { $sql.= ",date_start='$date_end'"; } + /*if ($date_end) { $sql.= ",date_start='$date_end'"; } else { $sql.=',date_start=null'; } if ($date_end) { $sql.= ",date_end='$date_end'"; } - else { $sql.=',date_end=null'; } + else { $sql.=',date_end=null'; }*/ $sql.= ",info_bits='".$info_bits."'"; $sql.= ",total_ht='".price2num($total_ht)."'"; $sql.= ",total_tva='".price2num($total_tva)."'"; diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index c21d73be1a3..43cfa12ca22 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -82,14 +82,11 @@ class FactureFournisseur extends Facture /** * Constructor * - * @param DoliDB $DB Database handler + * @param DoliDB $db Database handler */ - function FactureFournisseur($DB) + function FactureFournisseur($db) { - $this->db = $DB ; - - $this->id = $facid; - $this->socid = $socid; + $this->db = $db; $this->amount = 0; $this->remise = 0; @@ -115,6 +112,7 @@ class FactureFournisseur extends Facture { global $langs,$conf; + $error=0; $now=dol_now(); // Clear parameters @@ -255,6 +253,7 @@ class FactureFournisseur extends Facture function fetch($id='',$ref='') { global $langs; + $sql = "SELECT"; $sql.= " t.rowid,"; $sql.= " t.facnumber,"; @@ -356,8 +355,8 @@ class FactureFournisseur extends Facture } else { - $this->error='Bill with id '.$rowid.' not found sql='.$sql; - dol_syslog(get_class($this).'::Fetch rowid='.$rowid.' numrows=0 sql='.$sql); + $this->error='Bill with id '.$id.' not found sql='.$sql; + dol_syslog(get_class($this).'::Fetch rowid='.$id.' numrows=0 sql='.$sql); return -2; } diff --git a/htdocs/install/upgrade2.php b/htdocs/install/upgrade2.php index 820a8921a6c..de78ffcc49f 100644 --- a/htdocs/install/upgrade2.php +++ b/htdocs/install/upgrade2.php @@ -1354,13 +1354,11 @@ function migrate_price_propal($db,$langs,$conf) else { print "Error id=".$propal->id; - $err++; } } else { print "Error #3"; - $err++; } */ $i++; @@ -1378,7 +1376,6 @@ function migrate_price_propal($db,$langs,$conf) else { print "Error #1 ".$db->error(); - $err++; $db->rollback(); } @@ -1458,13 +1455,11 @@ function migrate_price_contrat($db,$langs,$conf) else { print "Error id=".$propal->id; - $err++; } } else { print "Error #3"; - $err++; } */ $i++; @@ -1482,7 +1477,6 @@ function migrate_price_contrat($db,$langs,$conf) else { print "Error #1 ".$db->error(); - $err++; $db->rollback(); } @@ -1560,13 +1554,11 @@ function migrate_price_commande($db,$langs,$conf) else { print "Error id=".$commande->id; - $err++; } } else { print "Error #3"; - $err++; } */ $i++; @@ -1594,7 +1586,6 @@ function migrate_price_commande($db,$langs,$conf) else { print "Error #1 ".$db->error(); - $err++; $db->rollback(); } @@ -1672,13 +1663,11 @@ function migrate_price_commande_fournisseur($db,$langs,$conf) else { print "Error id=".$commande->id; - $err++; } } else { print "Error #3"; - $err++; } */ $i++; @@ -1706,7 +1695,6 @@ function migrate_price_commande_fournisseur($db,$langs,$conf) else { print "Error #1 ".$db->error(); - $err++; $db->rollback(); } diff --git a/htdocs/livraison/class/livraison.class.php b/htdocs/livraison/class/livraison.class.php index 7f1f32c1741..2bf23fcb2df 100644 --- a/htdocs/livraison/class/livraison.class.php +++ b/htdocs/livraison/class/livraison.class.php @@ -293,7 +293,7 @@ class Livraison extends CommonObject } else { - $this->error='Delivery with id '.$rowid.' not found sql='.$sql; + $this->error='Delivery with id '.$id.' not found sql='.$sql; dol_syslog('Livraison::Fetch Error '.$this->error, LOG_ERR); return -2; } @@ -308,12 +308,13 @@ class Livraison extends CommonObject /** * Validate object and update stock if option enabled - * @param user Object user that validate - * @return int + * + * @param User $user Object user that validate + * @return int */ function valid($user) { - global $conf; + global $conf, $langs; require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"); dol_syslog("livraison.class.php::valid begin"); @@ -375,11 +376,11 @@ class Livraison extends CommonObject if ($resql) { // On efface le repertoire de pdf provisoire - $livraisonref = dol_sanitizeFileName($this->ref); + $numref = dol_sanitizeFileName($this->ref); if ($conf->expedition->dir_output) { - $dir = $conf->livraison->dir_output . "/" . $livraisonref ; - $file = $dir . "/" . $livraisonref . ".pdf"; + $dir = $conf->livraison->dir_output . "/" . $numref ; + $file = $dir . "/" . $numref . ".pdf"; if (file_exists($file)) { if (!dol_delete_file($file)) diff --git a/htdocs/paypal/lib/paypal.lib.php b/htdocs/paypal/lib/paypal.lib.php index fe7d05f877f..0797bbb78d8 100755 --- a/htdocs/paypal/lib/paypal.lib.php +++ b/htdocs/paypal/lib/paypal.lib.php @@ -155,6 +155,8 @@ function paypaladmin_prepare_head() $head[$h][2] = 'paypalaccount'; $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/product/canvas/product/actions_card_product.class.php b/htdocs/product/canvas/product/actions_card_product.class.php index 675285fe2c0..57dd51a10a6 100755 --- a/htdocs/product/canvas/product/actions_card_product.class.php +++ b/htdocs/product/canvas/product/actions_card_product.class.php @@ -303,7 +303,7 @@ class ActionsCardProduct extends Product } else { - dol_print_error($db,$sql); + dol_print_error($this->db,$sql); } } @@ -441,7 +441,7 @@ class ActionsCardProduct extends Product } else { - dol_print_error($db); + dol_print_error($this->db); } } diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 3d200fef7e4..8192b4bb9e6 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -144,14 +144,13 @@ class Product extends CommonObject /** * Constructor * - * @param DoliDB $DB Database handler + * @param DoliDB $db Database handler */ - function Product($DB) + function Product($db) { global $langs; - $this->db = $DB; - $this->id = $id ; + $this->db = $db; $this->status = 0; $this->status_buy = 0; $this->nbphoto = 0; @@ -403,6 +402,8 @@ class Product extends CommonObject { global $langs, $conf; + $error=0; + // Verification parametres if (! $this->libelle) $this->libelle = 'MISSING LABEL'; @@ -881,7 +882,6 @@ class Product extends CommonObject dol_syslog("Product:get_buyprice ".$this->error, LOG_ERR); return -2; } - return $result; } @@ -2555,11 +2555,12 @@ class Product extends CommonObject * @param nbbyrow Nombre vignettes par ligne (si mode vignette) * @param showfilename 1=Show filename * @param showaction 1=Show icon with action links (resize, delete) - * @param maxheight Max height of image when size=1 + * @param maxHeight Max height of image when size=1 + * @param maxWidth Max width of image when size=1 * @return string Html code to show photo. Number of photos shown is saved in this->nbphoto * TODO Move this into html.formproduct.class.php */ - function show_photos($sdir,$size=0,$nbmax=0,$nbbyrow=5,$showfilename=0,$showaction=0,$maxheight=120) + function show_photos($sdir,$size=0,$nbmax=0,$nbbyrow=5,$showfilename=0,$showaction=0,$maxHeight=120,$maxWidth=160) { global $conf,$user,$langs; @@ -2629,17 +2630,17 @@ class Product extends CommonObject $return.= "\n"; $return.= ''; - // Show image (width height=$maxheight) + // Show image (width height=$maxHeight) // Si fichier vignette disponible et image source trop grande, on utilise la vignette, sinon on utilise photo origine $alt=$langs->transnoentitiesnoconv('File').': '.$pdir.$photo; $alt.=' - '.$langs->transnoentitiesnoconv('Size').': '.$imgarray['width'].'x'.$imgarray['height']; - if ($photo_vignette && $imgarray['height'] > $maxheight) { + if ($photo_vignette && $imgarray['height'] > $maxHeight) { $return.= ''; - $return.= ''; + $return.= ''; } else { $return.= ''; - $return.= ''; + $return.= ''; } $return.= ''."\n"; diff --git a/htdocs/product/stock/class/entrepot.class.php b/htdocs/product/stock/class/entrepot.class.php index c516101295b..5eb8a997094 100644 --- a/htdocs/product/stock/class/entrepot.class.php +++ b/htdocs/product/stock/class/entrepot.class.php @@ -258,7 +258,7 @@ class Entrepot extends CommonObject } else { - dol_print_error($db); + dol_print_error($this->db); } $this->pays=$objp->libelle; $this->pays_code=$objp->code; diff --git a/htdocs/product/stock/class/mouvementstock.class.php b/htdocs/product/stock/class/mouvementstock.class.php index d96539e311e..8dd66a154c1 100644 --- a/htdocs/product/stock/class/mouvementstock.class.php +++ b/htdocs/product/stock/class/mouvementstock.class.php @@ -58,7 +58,7 @@ class MouvementStock */ function _create($user, $fk_product, $entrepot_id, $qty, $type, $price=0, $label='') { - global $conf; + global $conf, $langs; $error = 0; dol_syslog("MouvementStock::_create start userid=$user->id, fk_product=$fk_product, warehouse=$entrepot_id, qty=$qty, type=$type, price=$price label=$label"); diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index bd3132a322c..94e75a45637 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -74,7 +74,7 @@ class Project extends CommonObject */ function create($user, $notrigger=0) { - global $conf; + global $conf, $langs; $error = 0; $ret = 0; @@ -170,7 +170,9 @@ class Project extends CommonObject function update($user, $notrigger=0) { global $langs, $conf; - + + $error=0; + // Clean parameters $this->title = trim($this->title); $this->description = trim($this->description); @@ -496,6 +498,8 @@ class Project extends CommonObject { global $langs, $conf; + $error=0; + if ($this->statut != 1) { $this->db->begin(); @@ -553,6 +557,8 @@ class Project extends CommonObject { global $langs, $conf; + $error=0; + if ($this->statut != 2) { $this->db->begin(); diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php index 462edcb1f25..317b9cab694 100644 --- a/htdocs/projet/class/task.class.php +++ b/htdocs/projet/class/task.class.php @@ -381,6 +381,7 @@ class Task extends CommonObject */ function hasChildren() { + $error=0; $ret=0; $sql = "SELECT COUNT(*) as nb"; @@ -664,6 +665,7 @@ class Task extends CommonObject { global $conf,$langs; + $error=0; $ret = 0; // Clean parameters @@ -781,6 +783,9 @@ class Task extends CommonObject */ function updateTimeSpent($user, $notrigger=0) { + global $conf,$langs; + + $error=0; $ret = 0; // Clean parameters diff --git a/htdocs/projet/ganttchart.php b/htdocs/projet/ganttchart.php index 4bd08f83c04..586fbf3518c 100644 --- a/htdocs/projet/ganttchart.php +++ b/htdocs/projet/ganttchart.php @@ -149,7 +149,7 @@ function constructGanttLine($tarr,$task,$project_dependencies,$level=0,$project_ $name=$task['task_name']; for($i=0; $i < $level; $i++) { $name='     '.$name; } // Add line to gantt - $s = "// Add taks id=".$tasks["task_id"]." level = ".$level."\n"; + $s = "// Add taks id=".$task["task_id"]." level = ".$level."\n"; //$s.= "g.AddElementItem(new JSGantt.ElementItem('task',".$task['task_id'].",'".$name."','".$start_date."', '".$end_date."', '".$task['task_color']."', '', ".$task['task_milestone'].", '".$resources."', ".$percent.", ".($task["task_is_group"]>0?1:0).", ".$parent.", 1".($depend?", ".$depend:"")."));"; $s = "g.AddTaskItem(new JSGantt.TaskItem(".$task['task_id'].",'".$name."','".$start_date."', '".$end_date."', '".$task['task_color']."', '".$link."', ".$task['task_milestone'].", '".$resources."', ".$percent.", ".($task["task_is_group"]>0?1:0).", '".$parent."', 1, '".($depend?$depend:"")."'));"; echo $s."\n"; diff --git a/htdocs/societe/canvas/actions_card_common.class.php b/htdocs/societe/canvas/actions_card_common.class.php index accc3365c6f..ff9430a0136 100644 --- a/htdocs/societe/canvas/actions_card_common.class.php +++ b/htdocs/societe/canvas/actions_card_common.class.php @@ -546,7 +546,7 @@ abstract class ActionsCardCommon { $head = societe_prepare_head($this->object); - $this->tpl['showhead']=dol_get_fiche_head($head, 'card', $title, 0, 'company'); + $this->tpl['showhead']=dol_get_fiche_head($head, 'card', '', 0, 'company'); $this->tpl['showend']=dol_get_fiche_end(); $this->tpl['showrefnav'] = $form->showrefnav($this->object,'socid','',($user->societe_id?0:1),'rowid','nom'); @@ -595,7 +595,7 @@ abstract class ActionsCardCommon } else if ($nbofsalesrepresentative > 0) { - $userstatic=new User($db); + $userstatic=new User($this->db); $i=0; foreach($listsalesrepresentatives as $val) { diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 3d1b5ac9f70..f154a18d0cf 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -175,6 +175,8 @@ class Societe extends CommonObject { global $langs,$conf; + $error=0; + // Clean parameters if (empty($this->status)) $this->status=0; $this->name=$this->name?trim($this->name):trim($this->nom); @@ -373,9 +375,10 @@ class Societe extends CommonObject */ function update($id, $user='', $call_trigger=1, $allowmodcodeclient=0, $allowmodcodefournisseur=0, $action='update') { + global $langs,$conf; require_once(DOL_DOCUMENT_ROOT."/core/lib/functions2.lib.php"); - global $langs,$conf; + $error=0; dol_syslog("Societe::Update id=".$id." call_trigger=".$call_trigger." allowmodcodeclient=".$allowmodcodeclient." allowmodcodefournisseur=".$allowmodcodefournisseur); @@ -544,7 +547,7 @@ class Societe extends CommonObject include_once(DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'); $hookmanager=new HookManager($this->db); $hookmanager->callHooks(array('thirdpartydao')); - $parameters=array('socid'=>$socid); + $parameters=array('socid'=>$this->id); $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks if (empty($reshook)) { @@ -2352,34 +2355,9 @@ class Societe extends CommonObject } - /** - * Add a line in log table to save status change. - * - * @param $id_status - */ - function set_status($id_status) - { - $sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_log (datel, fk_soc, fk_statut, fk_user, author, label)"; - $sql.= " VALUES ('".$dateaction."', ".$socid.", ".$id_status.","; - $sql.= "'".$user->id."',"; - $sql.= "'".$this->db->escape($user->login)."',"; - $sql.= "'Change statut from ".$oldstcomm." to ".$stcommid."'"; - $sql.= ")"; - $result = $thi->db->query($sql); - if ($result) - { - $sql = "UPDATE ".MAIN_DB_PREFIX."societe SET fk_stcomm = ".$stcommid." WHERE rowid=".$socid; - $result = $this->db->query($sql); - } - else - { - $errmesg = $this->db->lasterror(); - } - } - - /** * Create a third party into database from a member object + * * @param member Object member * @param socname Name of third party to force * @return int <0 if KO, id of created account if OK diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 173608c820e..c866085e50c 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -654,6 +654,8 @@ class User extends CommonObject { global $user,$conf,$langs; + $error=0; + $this->db->begin(); $this->fetch($this->id); @@ -845,6 +847,8 @@ class User extends CommonObject { global $conf,$user,$langs; + $error=0; + // Positionne parametres $this->admin = 0; $this->nom = $contact->nom; // TODO deprecated @@ -1358,7 +1362,8 @@ class User extends CommonObject function send_password($user, $password='', $changelater=0) { global $conf,$langs; - + global $dolibarr_main_url_root; + require_once DOL_DOCUMENT_ROOT."/core/class/CMailFile.class.php"; $subject = $langs->trans("SubjectNewPassword"); diff --git a/htdocs/user/class/usergroup.class.php b/htdocs/user/class/usergroup.class.php index 0bf7953545e..653a28411c3 100644 --- a/htdocs/user/class/usergroup.class.php +++ b/htdocs/user/class/usergroup.class.php @@ -480,6 +480,8 @@ class UserGroup extends CommonObject { global $user,$conf,$langs; + $error=0; + $this->db->begin(); $sql = "DELETE FROM ".MAIN_DB_PREFIX."usergroup_rights"; @@ -523,6 +525,7 @@ class UserGroup extends CommonObject { global $user, $conf, $langs; + $error=0; $now=dol_now(); $entity=$conf->entity; diff --git a/scripts/invoices/email_unpaid_invoices_to_representatives.php b/scripts/invoices/email_unpaid_invoices_to_representatives.php index 2fe69d8055b..ea7ad071599 100644 --- a/scripts/invoices/email_unpaid_invoices_to_representatives.php +++ b/scripts/invoices/email_unpaid_invoices_to_representatives.php @@ -124,6 +124,7 @@ function envoi_mail($oldemail,$message,$total) $subject = "[Dolibarr] List of unpaid invoices"; $sendto = $oldemail; $from = $conf->global->MAIN_EMAIL_FROM; + $errorsto = $conf->global->MAIN_MAIL_ERRORS_TO; $msgishtml = 0; print "Envoi mail pour $oldemail, total: $total\n"; diff --git a/test/phpunit/CategorieTest.php b/test/phpunit/CategorieTest.php index 190afe1e2fb..52263f47341 100755 --- a/test/phpunit/CategorieTest.php +++ b/test/phpunit/CategorieTest.php @@ -245,12 +245,12 @@ class CategorieTest extends PHPUnit_Framework_TestCase $localobject2->initAsSpecimen(); $retarray=$localobject->liste_photos('/'); - print __METHOD__." retarry size=".count($rearray)."\n"; + print __METHOD__." retarray size=".count($retarray)."\n"; $this->assertTrue(is_array($retarray)); - $ret=$localobject->is_fille($localobject2); - print __METHOD__." retarry size=".count($rearray)."\n"; - $this->assertFalse($ret); + $retarray=$localobject->is_fille($localobject2); + print __METHOD__." retarry size=".count($retarray)."\n"; + $this->assertFalse($retarray); return $localobject->id; } @@ -292,7 +292,7 @@ class CategorieTest extends PHPUnit_Framework_TestCase print __METHOD__." retarray size=".count($retarray)."\n"; $this->assertTrue(is_array($retarray)); - return $result; + return $retarray; } } diff --git a/test/phpunit/SecurityTest.php b/test/phpunit/SecurityTest.php index bf4b5c85775..e961816e612 100755 --- a/test/phpunit/SecurityTest.php +++ b/test/phpunit/SecurityTest.php @@ -187,7 +187,7 @@ class SecurityTest extends PHPUnit_Framework_TestCase print __METHOD__." encodedstring=".$encodedstring." ".base64_encode($stringtotest)."\n"; $this->assertEquals($stringtotest,$decodedstring); - return $result; + return 0; } /** @@ -210,7 +210,7 @@ class SecurityTest extends PHPUnit_Framework_TestCase print __METHOD__." genpass3=".$genpass3."\n"; $this->assertEquals(strlen($genpass3),8); - return $result; + return 0; } } ?> \ No newline at end of file From 37f44dbd75dd244e3240fabb10bcdd1a9620aaf3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 5 Dec 2011 23:04:39 +0100 Subject: [PATCH 06/11] Fix: Avoid duplicate lines --- htdocs/fourn/facture/paiement.php | 43 +++++++++++++++++-------------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/htdocs/fourn/facture/paiement.php b/htdocs/fourn/facture/paiement.php index 04171f596a5..7a87a2478a7 100644 --- a/htdocs/fourn/facture/paiement.php +++ b/htdocs/fourn/facture/paiement.php @@ -34,8 +34,9 @@ $langs->load('companies'); $langs->load('bills'); $langs->load('banks'); -$facid=isset($_GET['facid'])?$_GET['facid']:$_POST['facid']; -$action=isset($_GET['action'])?$_GET['action']:$_POST['action']; +$facid=GETPOST('facid'); +$action=GETPOST('action'); +$socid=GETPOST('socid','int'); $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); @@ -51,7 +52,6 @@ if (! $sortfield) $sortfield="p.rowid"; $amounts = array(); // Security check -$socid=0; if ($user->societe_id > 0) { $socid = $user->societe_id; @@ -159,7 +159,7 @@ if ($action == 'add_paiement') } } if ($invoiceid > 0) $loc = DOL_URL_ROOT.'/fourn/facture/fiche.php?facid='.$invoiceid; - else $loc = DOL_URL_ROOT.'/compta/paiement/fiche.php?id='.$paiement_id; + else $loc = DOL_URL_ROOT.'/fourn/paiement/fiche.php?id='.$paiement_id; Header('Location: '.$loc); exit; } @@ -170,6 +170,7 @@ if ($action == 'add_paiement') } } + /* * View */ @@ -208,7 +209,7 @@ if ($action == 'create' || $action == 'add_paiement') print_fiche_titre($langs->trans('DoPayment')); - if ($mesg) dol_htmloutput_mesg($mesg); + if ($mesg) dol_htmloutput_mesg($mesg); if ($errmsg) dol_htmloutput_errors($errmsg); print ''; @@ -344,7 +345,7 @@ if ($action == 'create' || $action == 'add_paiement') } /* - * Affichage liste + * Show list */ if (! $_GET['action'] && ! $_POST['action']) { @@ -355,16 +356,16 @@ if (! $_GET['action'] && ! $_POST['action']) if (! $sortorder) $sortorder='DESC'; if (! $sortfield) $sortfield='p.datep'; - $sql = 'SELECT p.rowid, p.rowid as pid, p.datep as dp, p.amount as pamount,'; - $sql.= ' f.rowid as facid, f.rowid as ref, f.facnumber, f.amount,'; + $sql = 'SELECT p.rowid as pid, p.datep as dp, p.amount as pamount, p.num_paiement,'; $sql.= ' s.rowid as socid, s.nom,'; - $sql.= ' c.libelle as paiement_type, p.num_paiement,'; - $sql.= ' ba.rowid as bid, ba.label'; - if (!$user->rights->societe->client->voir) $sql .= ", sc.fk_soc, sc.fk_user "; + $sql.= ' c.libelle as paiement_type,'; + $sql.= ' ba.rowid as bid, ba.label,'; + if (!$user->rights->societe->client->voir) $sql .= ' sc.fk_soc, sc.fk_user,'; + $sql.= ' SUM(f.amount)'; $sql.= ' FROM '.MAIN_DB_PREFIX.'paiementfourn AS p'; if (!$user->rights->societe->client->voir) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiementfourn_facturefourn AS pf ON p.rowid=pf.fk_paiementfourn'; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'facture_fourn AS f ON f.rowid=pf.fk_facturefourn '; + $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'facture_fourn AS f ON f.rowid=pf.fk_facturefourn'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement AS c ON p.fk_paiement = c.id'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe AS s ON s.rowid = f.fk_soc'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON p.fk_bank = b.rowid'; @@ -378,26 +379,28 @@ if (! $_GET['action'] && ! $_POST['action']) // Search criteria if ($_REQUEST["search_ref"]) { - $sql .=" AND p.rowid=".$_REQUEST["search_ref"]; + $sql .= ' AND p.rowid='.$db->escape($_REQUEST["search_ref"]); } if ($_REQUEST["search_account"]) { - $sql .=" AND b.fk_account=".$_REQUEST["search_account"]; + $sql .= ' AND b.fk_account='.$db->escape($_REQUEST["search_account"]); } if ($_REQUEST["search_paymenttype"]) { - $sql .=" AND c.code='".$_REQUEST["search_paymenttype"]."'"; + $sql .= " AND c.code='".$db->escape($_REQUEST["search_paymenttype"])."'"; } if ($_REQUEST["search_amount"]) { - $sql .=" AND p.amount=".price2num($_REQUEST["search_amount"]); + $sql .= " AND p.amount=".price2num($_REQUEST["search_amount"]); } if ($_REQUEST["search_company"]) { - $sql .=" AND s.nom LIKE '%".$db->escape($_REQUEST["search_company"])."%'"; + $sql .= " AND s.nom LIKE '%".$db->escape($_REQUEST["search_company"])."%'"; } + $sql.= " GROUP BY p.rowid, p.datep, p.amount, p.num_paiement, s.rowid, s.nom, c.libelle, ba.rowid, ba.label"; + if (!$user->rights->societe->client->voir) $sql .= ", sc.fk_soc, sc.fk_user"; $sql.= $db->order($sortfield,$sortorder); - $sql.= $db->plimit($limit + 1 ,$offset); + $sql.= $db->plimit($limit+1, $offset); $resql = $db->query($sql); if ($resql) @@ -413,8 +416,8 @@ if (! $_GET['action'] && ! $_POST['action']) print_barre_liste($langs->trans('SupplierPayments'), $page, 'paiement.php',$paramlist,$sortfield,$sortorder,'',$num); - if ($mesg) print $mesg; - if ($errmsg) print $errmsg; + if ($mesg) dol_htmloutput_mesg($mesg); + if ($errmsg) dol_htmloutput_errors($errmsg); print ''; print ''; From 9dcfc044a4fe00377771e31fa7a54bcad8e26ed8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 5 Dec 2011 23:05:11 +0100 Subject: [PATCH 07/11] Fix: Miscellaneous bug fixes --- htdocs/core/lib/functions.lib.php | 6 +++--- htdocs/fourn/facture/fiche.php | 2 +- htdocs/fourn/paiement/fiche.php | 14 ++++++++------ 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 756165f77a8..6fa2328550f 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 = '