From 8d5dd719aad2c71f8ffc1433d6c9e20a0903f2c3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 11 Jan 2013 16:11:35 +0100 Subject: [PATCH 01/28] Add svg file --- htdocs/theme/eldy/img/logo_setup.svg | 475 +++++++++++++++++++++++++++ 1 file changed, 475 insertions(+) create mode 100644 htdocs/theme/eldy/img/logo_setup.svg diff --git a/htdocs/theme/eldy/img/logo_setup.svg b/htdocs/theme/eldy/img/logo_setup.svg new file mode 100644 index 00000000000..4db2a11dff1 --- /dev/null +++ b/htdocs/theme/eldy/img/logo_setup.svg @@ -0,0 +1,475 @@ + + + + + + + Ruota dentata grigia 2 + + + + gears + machine + + + + + Open Clip Art Library + + + + + Architetto Francesco Rollandin + + + + + Architetto Francesco Rollandin + + + + image/svg+xml + + + en + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From b9c53fd796a790a3dc7df88864d8e8796d4ed2a8 Mon Sep 17 00:00:00 2001 From: fhenry Date: Sun, 13 Jan 2013 20:50:54 +0100 Subject: [PATCH 02/28] remove dummy line --- htdocs/user/class/user.class.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index ef1bba983a0..6ae0315c143 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -981,7 +981,6 @@ class User extends CommonObject $this->firstname = $member->firstname; $this->email = $member->email; $this->fk_member = $member->id; - if ($member->fk_soc) $sql.= ", fk_societe=".$member->fk_soc; $this->pass = $member->pass; if (empty($login)) $login=strtolower(substr($member->firstname, 0, 4)) . strtolower(substr($member->lastname, 0, 4)); From 0861fbfeb6e9cf696c9ecf2abe09d02597644733 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 13 Jan 2013 23:47:23 +0100 Subject: [PATCH 03/28] Fix: Missing kenya currency --- htdocs/install/mysql/data/llx_c_currencies.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/install/mysql/data/llx_c_currencies.sql b/htdocs/install/mysql/data/llx_c_currencies.sql index fa84275d24f..293c1ea8796 100644 --- a/htdocs/install/mysql/data/llx_c_currencies.sql +++ b/htdocs/install/mysql/data/llx_c_currencies.sql @@ -85,6 +85,7 @@ INSERT INTO llx_c_currencies ( code_iso, unicode, active, label ) VALUES ( 'ILS' INSERT INTO llx_c_currencies ( code_iso, unicode, active, label ) VALUES ( 'JMD', '[74,36]', 1, 'Jamaica Dollar'); INSERT INTO llx_c_currencies ( code_iso, unicode, active, label ) VALUES ( 'JPY', '[165]', 1, 'Japan Yen'); INSERT INTO llx_c_currencies ( code_iso, unicode, active, label ) VALUES ( 'JEP', '[163]', 1, 'Jersey Pound'); +INSERT INTO llx_c_currencies ( code_iso, unicode, active, label ) VALUES ( 'KES', NULL, 1, 'Kenya Shilling'); INSERT INTO llx_c_currencies ( code_iso, unicode, active, label ) VALUES ( 'KZT', '[1083,1074]', 1, 'Kazakhstan Tenge'); INSERT INTO llx_c_currencies ( code_iso, unicode, active, label ) VALUES ( 'KPW', '[8361]', 1, 'Korea (North) Won'); INSERT INTO llx_c_currencies ( code_iso, unicode, active, label ) VALUES ( 'KRW', '[8361]', 1, 'Korea (South) Won'); From cf12815ca9afcba7bb8690ac80ea8ebb57a4402a Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Mon, 14 Jan 2013 09:39:35 +0100 Subject: [PATCH 04/28] Fix: phpunit error --- test/phpunit/AdherentTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/phpunit/AdherentTest.php b/test/phpunit/AdherentTest.php index 493783ae2eb..03be97ecec2 100644 --- a/test/phpunit/AdherentTest.php +++ b/test/phpunit/AdherentTest.php @@ -284,7 +284,7 @@ class AdherentTest extends PHPUnit_Framework_TestCase '%ADDRESS%,%ZIP%,%TOWN%,%COUNTRY%,%EMAIL%,%NAISS%,%PHOTO%,%LOGIN%,%PASSWORD%,%PRENOM%,'. '%NOM%,%SOCIETE%,%ADRESSE%,%CP%,%VILLE%,%PAYS%'; - $expected = DOL_MAIN_URL_ROOT.','.$localobject->id.',,New firstname,New name,New firstname New name,'. + $expected = DOL_MAIN_URL_ROOT.','.$localobject->id.',0,New firstname,New name,New firstname New name,'. 'New company,New address,New zip,New town,Belgium,newemail@newemail.com,'.dol_print_date($localobject->naiss,'day').',,'. 'newlogin,dolibspec,New firstname,New name,New company,New address,New zip,New town,Belgium'; @@ -320,7 +320,7 @@ class AdherentTest extends PHPUnit_Framework_TestCase //We update user object $user->fetch($user->id); print __METHOD__." user id=".$user->id." fk_member=".$user->fk_member."\n"; - + $this->assertEquals($user->fk_member, $localobject->id); //We remove association with user From fb1d99d0dd7605e21bc49c0da18d628b9434662d Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Mon, 14 Jan 2013 11:09:10 +0100 Subject: [PATCH 05/28] Multi-company compatibility with transverse mode for home boxes --- htdocs/core/class/infobox.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/infobox.class.php b/htdocs/core/class/infobox.class.php index 2d3ca1d6ae9..4c089b2ef88 100644 --- a/htdocs/core/class/infobox.class.php +++ b/htdocs/core/class/infobox.class.php @@ -50,7 +50,7 @@ class InfoBox $sql.= " d.rowid as box_id, d.file, d.note, d.tms"; $sql.= " FROM ".MAIN_DB_PREFIX."boxes as b, ".MAIN_DB_PREFIX."boxes_def as d"; $sql.= " WHERE b.box_id = d.rowid"; - $sql.= " AND b.entity = ".$conf->entity; + $sql.= " AND b.entity IN (0,".(! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode)?"1,":"").$conf->entity.")"; if ($zone >= 0) $sql.= " AND b.position = ".$zone; if ($user->id && ! empty($user->conf->$confuserzone)) $sql.= " AND b.fk_user = ".$user->id; else $sql.= " AND b.fk_user = 0"; From 297c10d16b86d336407825ab2f7521e35d971fd3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 14 Jan 2013 11:39:30 +0100 Subject: [PATCH 06/28] Qual: externalise code of merging PDFs into a library. --- htdocs/core/lib/invoice2.lib.php | 262 +++++++++++++++++++++++++ scripts/invoices/rebuild_merge_pdf.php | 208 +------------------- 2 files changed, 272 insertions(+), 198 deletions(-) create mode 100644 htdocs/core/lib/invoice2.lib.php diff --git a/htdocs/core/lib/invoice2.lib.php b/htdocs/core/lib/invoice2.lib.php new file mode 100644 index 00000000000..f2c6bd3599d --- /dev/null +++ b/htdocs/core/lib/invoice2.lib.php @@ -0,0 +1,262 @@ +#!/usr/bin/php + +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +*/ + +/** + * \file htdocs/core/lib/invoice2.lib.php + * \ingroup facture + * \brief Function to rebuild PDF and merge PDF files into one + */ + +require_once(DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'); +require_once(DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'); + + +/** + * Function to build a compiled PDF + * + * @param DoliDB $db Database handler + * @param Translate $langs Object langs + * @param Conf $conf Object conf + * @param string $diroutputpdf Dir to output file + * @param string $newlangid Lang id + * @param array $filter Array with filters + * @param date $dateafterdate Invoice after date + * @param date $datebeforedate Invoice before date + * @param date $paymentdateafter Payment after date + * @param date $paymentdatebefore Payment before date + * @param int $usestdout Add information onto standard output + * @param int $regenerate ''=Use existing PDF files, 'nameofpdf'=Regenerate all PDF files using the template, + * @return int Error code + */ +function rebuild_merge_pdf($db, $langs, $conf, $diroutputpdf, $newlangid, $filter, $dateafterdate, $datebeforedate, $paymentdateafter, $paymentdatebefore, $usestdout, $regenerate=0) +{ + $sql = "SELECT DISTINCT f.rowid, f.facnumber"; + $sql.= " FROM ".MAIN_DB_PREFIX."facture as f"; + $sqlwhere=''; + $sqlorder=''; + if (in_array('all',$filter)) + { + $sqlorder = " ORDER BY f.facnumber ASC"; + } + if (in_array('date',$filter)) + { + if (empty($sqlwhere)) $sqlwhere=' WHERE '; + else $sqlwhere.=" AND"; + $sqlwhere.= " f.fk_statut > 0"; + $sqlwhere.= " AND f.datef >= '".$db->idate($dateafterdate)."'"; + $sqlwhere.= " AND f.datef <= '".$db->idate($datebeforedate)."'"; + $sqlorder = " ORDER BY f.datef ASC"; + } + if (in_array('nopayment',$filter)) + { + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON f.rowid = pf.fk_facture"; + if (empty($sqlwhere)) $sqlwhere=' WHERE '; + else $sqlwhere.=" AND"; + $sqlwhere.= " f.fk_statut > 0"; + $sqlwhere.= " AND pf.fk_paiement IS NULL"; + } + if (in_array('payments',$filter)) + { + $sql.= ", ".MAIN_DB_PREFIX."paiement_facture as pf,"; + $sql.= " ".MAIN_DB_PREFIX."paiement as p"; + if (empty($sqlwhere)) $sqlwhere=' WHERE '; + else $sqlwhere.=" AND"; + $sqlwhere.= " f.fk_statut > 0"; + $sqlwhere.= " AND f.rowid = pf.fk_facture"; + $sqlwhere.= " AND pf.fk_paiement = p.rowid"; + $sqlwhere.= " AND p.datep >= '".$db->idate($paymentdateafter)."'"; + $sqlwhere.= " AND p.datep <= '".$db->idate($paymentdatebefore)."'"; + $sqlorder = " ORDER BY p.datep ASC"; + } + if (in_array('nodeposit',$filter)) + { + if (empty($sqlwhere)) $sqlwhere=' WHERE '; + else $sqlwhere.=" AND"; + $sqlwhere.=' type <> 3'; + } + if (in_array('noreplacement',$filter)) + { + if (empty($sqlwhere)) $sqlwhere=' WHERE '; + else $sqlwhere.=" AND"; + $sqlwhere.=' type <> 1'; + } + if (in_array('nocreditnote',$filter)) + { + if (empty($sqlwhere)) $sqlwhere=' WHERE '; + else $sqlwhere.=" AND"; + $sqlwhere.=' type <> 2'; + } + if ($sqlwhere) $sql.=$sqlwhere; + if ($sqlorder) $sql.=$sqlorder; + + //print $sql; exit; + dol_syslog("scripts/invoices/rebuild_merge.php: sql=".$sql); + + if ($usestdout) print '--- start'."\n"; + + // Start of transaction + //$db->begin(); + + $error = 0; + $result = 0; + $files = array() ; // liste les fichiers + + dol_syslog("scripts/invoices/rebuild_merge.php sql=".$sql); + if ( $resql=$db->query($sql) ) + { + $num = $db->num_rows($resql); + $cpt = 0; + $oldemail = ''; + $message = ''; + $total = ''; + + if ($num) + { + // First loop on each resultset to build PDF + // ----------------------------------------- + + while ($cpt < $num) + { + $obj = $db->fetch_object($resql); + + $fac = new Facture($db); + $result=$fac->fetch($obj->rowid); + if ($result > 0) + { + $outputlangs = $langs; + if (! empty($newlangid)) + { + if ($outputlangs->defaultlang != $newlangid) + { + $outputlangs = new Translate("",$conf); + $outputlangs->setDefaultLang($newlangid); + } + } + $filename=$conf->facture->dir_output.'/'.$fac->ref.'/'.$fac->ref.'.pdf'; + if ($regenerate || ! dol_is_file($filename)) + { + if ($usestdout) print "Build PDF for invoice ".$obj->facnumber." - Lang = ".$outputlangs->defaultlang."\n"; + $result=facture_pdf_create($db, $fac, $regenerate?$regenerate:$fac->modelpdf, $outputlangs); + } + else { + if ($usestdout) print "PDF for invoice ".$obj->facnumber." already exists\n"; + } + + // Add file into files array + $files[] = $filename; + } + + if ($result <= 0) + { + $error++; + if ($usestdout) print "Error: Failed to build PDF for invoice ".$fac->ref."\n"; + else dol_syslog("Failed to build PDF for invoice ".$fac->ref, LOG_ERR); + } + + $cpt++; + } + + + // Define format of output PDF + $formatarray=pdf_getFormat(); + $page_largeur = $formatarray['width']; + $page_hauteur = $formatarray['height']; + $format = array($page_largeur,$page_hauteur); + + if ($usestdout) print "Using output PDF format ".join('x',$format)."\n"; + else dol_syslog("Using output PDF format ".join('x',$format), LOG_ERR); + + + // Now, build a merged files with all files in $files array + //--------------------------------------------------------- + + // Create empty PDF + $pdf=pdf_getInstance($format); + if (class_exists('TCPDF')) + { + $pdf->setPrintHeader(false); + $pdf->setPrintFooter(false); + } + $pdf->SetFont(pdf_getPDFFont($outputlangs)); + + if ($conf->global->MAIN_DISABLE_PDF_COMPRESSION) $pdf->SetCompression(false); + //$pdf->SetCompression(false); + + + //$pdf->Open(); + //$pdf->AddPage(); + //$title=$langs->trans("BillsCustomersUnpaid"); + //if ($option=='late') $title=$langs->trans("BillsCustomersUnpaid"); + //$pdf->MultiCell(100, 3, $title, 0, 'J'); + + // Add all others + foreach($files as $file) + { + if ($usestdout) print "Merge PDF file for invoice ".$file."\n"; + else dol_syslog("Merge PDF file for invoice ".$file); + + // Charge un document PDF depuis un fichier. + $pagecount = $pdf->setSourceFile($file); + for ($i = 1; $i <= $pagecount; $i++) + { + $tplidx = $pdf->importPage($i); + $s = $pdf->getTemplatesize($tplidx); + $pdf->AddPage($s['h'] > $s['w'] ? 'P' : 'L'); + $pdf->useTemplate($tplidx); + } + } + + // Create output dir if not exists + dol_mkdir($diroutputpdf); + + // Save merged file + $filename='mergedpdf'; + + if (! empty($option)) $filename.='_'.$option; + + if ($pagecount) + { + $file=$diroutputpdf.'/'.$filename.'.pdf'; + $pdf->Output($file,'F'); + if (! empty($conf->global->MAIN_UMASK)) + @chmod($file, octdec($conf->global->MAIN_UMASK)); + } + + if ($usestdout) print "Merged PDF has been built in ".$file."\n"; + $result = 1; + } + else + { + if ($usestdout) print "No invoices found for criteria.\n"; + else dol_syslog("No invoices found for criteria"); + $result = 0; + } + } + else + { + dol_print_error($db); + dol_syslog("scripts/invoices/rebuild_merge.php: Error"); + $error++; + } + + if ($error) return -1; + else return $result; +} + +?> \ No newline at end of file diff --git a/scripts/invoices/rebuild_merge_pdf.php b/scripts/invoices/rebuild_merge_pdf.php index c44ed149c03..b38917eb17c 100644 --- a/scripts/invoices/rebuild_merge_pdf.php +++ b/scripts/invoices/rebuild_merge_pdf.php @@ -40,8 +40,7 @@ require_once(DOL_DOCUMENT_ROOT."/cron/functions_cron.lib.php"); require_once(DOL_DOCUMENT_ROOT."/compta/facture/class/facture.class.php"); require_once(DOL_DOCUMENT_ROOT."/core/modules/facture/modules_facture.php"); require_once(DOL_DOCUMENT_ROOT."/core/lib/date.lib.php"); -require_once(DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'); -require_once(DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'); +require_once(DOL_DOCUMENT_ROOT.'/core/lib/invoice2.lib.php'); // Load main language strings @@ -64,10 +63,9 @@ if (! isset($argv[1])) } $diroutputpdf=$conf->facture->dir_output . '/temp'; -$newmodel=''; // To force a new model $newlangid='en_EN'; // To force a new lang id $filter=array(); -$regenerate=''; +$regenerate=''; // Ask regenerate (contains name of model to use) $option=''; foreach ($argv as $key => $value) @@ -179,210 +177,23 @@ if (in_array('payments',$filter) && in_array('nopayment',$filter)) } -// Define SQL and SQL order request to select invoices -$sql = "SELECT DISTINCT f.rowid, f.facnumber"; -$sql.= " FROM ".MAIN_DB_PREFIX."facture as f"; -$sqlwhere=''; -$sqlorder=''; -if (in_array('all',$filter)) -{ - $sqlorder = " ORDER BY f.facnumber ASC"; -} -if (in_array('date',$filter)) -{ - if (empty($sqlwhere)) $sqlwhere=' WHERE '; - else $sqlwhere.=" AND"; - $sqlwhere.= " f.fk_statut > 0"; - $sqlwhere.= " AND f.datef >= '".$db->idate($dateafterdate)."'"; - $sqlwhere.= " AND f.datef <= '".$db->idate($datebeforedate)."'"; - $sqlorder = " ORDER BY f.datef ASC"; -} -if (in_array('nopayment',$filter)) -{ - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON f.rowid = pf.fk_facture"; - if (empty($sqlwhere)) $sqlwhere=' WHERE '; - else $sqlwhere.=" AND"; - $sqlwhere.= " f.fk_statut > 0"; - $sqlwhere.= " AND pf.fk_paiement IS NULL"; -} -if (in_array('payments',$filter)) -{ - $sql.= ", ".MAIN_DB_PREFIX."paiement_facture as pf,"; - $sql.= " ".MAIN_DB_PREFIX."paiement as p"; - if (empty($sqlwhere)) $sqlwhere=' WHERE '; - else $sqlwhere.=" AND"; - $sqlwhere.= " f.fk_statut > 0"; - $sqlwhere.= " AND f.rowid = pf.fk_facture"; - $sqlwhere.= " AND pf.fk_paiement = p.rowid"; - $sqlwhere.= " AND p.datep >= '".$db->idate($paymentdateafter)."'"; - $sqlwhere.= " AND p.datep <= '".$db->idate($paymentdatebefore)."'"; - $sqlorder = " ORDER BY p.datep ASC"; -} -if (in_array('nodeposit',$filter)) -{ - if (empty($sqlwhere)) $sqlwhere=' WHERE '; - else $sqlwhere.=" AND"; - $sqlwhere.=' type <> 3'; -} -if (in_array('noreplacement',$filter)) -{ - if (empty($sqlwhere)) $sqlwhere=' WHERE '; - else $sqlwhere.=" AND"; - $sqlwhere.=' type <> 1'; -} -if (in_array('nocreditnote',$filter)) -{ - if (empty($sqlwhere)) $sqlwhere=' WHERE '; - else $sqlwhere.=" AND"; - $sqlwhere.=' type <> 2'; -} -if ($sqlwhere) $sql.=$sqlwhere; -if ($sqlorder) $sql.=$sqlorder; +// Define SQL and SQL request to select invoices +// Use $filter, $dateafterdate, datebeforedate, $paymentdateafter, $paymentdatebefore +$result=rebuild_merge_pdf($db, $langs, $conf, $diroutputpdf, $newlangid, $filter, $dateafterdate, $datebeforedate, $paymentdateafter, $paymentdatebefore, 1, $regenerate); -//print $sql; exit; -dol_syslog("scripts/invoices/rebuild_merge.php: sql=",$sql); - -print '--- start'."\n"; - -// Start of transaction -//$db->begin(); - -$error = 0; -$files = array() ; // liste les fichiers - -dol_syslog("scripts/invoices/rebuild_merge.php sql=".$sql); -if ( $resql=$db->query($sql) ) -{ - $num = $db->num_rows($resql); - $cpt = 0; - $oldemail = ''; - $message = ''; - $total = ''; - - if ($num) - { - // First loop on each resultset to build PDF - // ----------------------------------------- - - while ($cpt < $num) - { - $obj = $db->fetch_object($resql); - - $fac = new Facture($db); - $result=$fac->fetch($obj->rowid); - if ($result > 0) - { - $outputlangs = $langs; - if (! empty($newlangid)) - { - if ($outputlangs->defaultlang != $newlangid) - { - $outputlangs = new Translate("",$conf); - $outputlangs->setDefaultLang($newlangid); - } - } - $filename=$conf->facture->dir_output.'/'.$fac->ref.'/'.$fac->ref.'.pdf'; - if ($regenerate || ! dol_is_file($filename)) - { - print "Build PDF for invoice ".$obj->facnumber." - Lang = ".$outputlangs->defaultlang."\n"; - $result=facture_pdf_create($db, $fac, $newmodel?$newmodel:$fac->modelpdf, $outputlangs); - } - else { - print "PDF for invoice ".$obj->facnumber." already exists\n"; - } - - // Add file into files array - $files[] = $filename; - } - - if ($result <= 0) - { - print "Error: Failed to build PDF for invoice ".$fac->ref."\n"; - } - - $cpt++; - } - - - // Now, build a merged files with all files in $files array - //--------------------------------------------------------- - - // Create empty PDF - $pdf=pdf_getInstance(); - if (class_exists('TCPDF')) - { - $pdf->setPrintHeader(false); - $pdf->setPrintFooter(false); - } - $pdf->SetFont(pdf_getPDFFont($outputlangs)); - - if ($conf->global->MAIN_DISABLE_PDF_COMPRESSION) $pdf->SetCompression(false); - //$pdf->SetCompression(false); - - - //$pdf->Open(); - //$pdf->AddPage(); - //$title=$langs->trans("BillsCustomersUnpaid"); - //if ($option=='late') $title=$langs->trans("BillsCustomersUnpaid"); - //$pdf->MultiCell(100, 3, $title, 0, 'J'); - - // Add all others - foreach($files as $file) - { - print "Merge PDF file for invoice ".$file."\n"; - - // Charge un document PDF depuis un fichier. - $pagecount = $pdf->setSourceFile($file); - for ($i = 1; $i <= $pagecount; $i++) - { - $tplidx = $pdf->importPage($i); - $s = $pdf->getTemplatesize($tplidx); - $pdf->AddPage($s['h'] > $s['w'] ? 'P' : 'L'); - $pdf->useTemplate($tplidx); - } - } - - // Create output dir if not exists - dol_mkdir($diroutputpdf); - - // Save merged file - $filename='mergedpdf'; - - if (! empty($option)) $filename.='_'.$option; - - if ($pagecount) - { - $file=$diroutputpdf.'/'.$filename.'.pdf'; - $pdf->Output($file,'F'); - if (! empty($conf->global->MAIN_UMASK)) - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } - - print "Merged PDF has been built in ".$file."\n"; - } - else - { - print "No invoices with payments in this range.\n"; - } -} -else -{ - dol_print_error($db); - dol_syslog("scripts/invoices/rebuild_merge.php: Error"); -} // -------------------- END OF YOUR CODE -------------------- -if (! $error) +if ($result >= 0) { - //$db->commit(); + $error=0; print '--- end ok'."\n"; } else { + $error=$result; print '--- end error code='.$error."\n"; - //$db->rollback(); } $db->close(); @@ -390,6 +201,7 @@ $db->close(); return $error; + /** * Show usage of script * @@ -414,7 +226,7 @@ function usage() print "To exclude deposit invoices, use filter=nodeposit\n"; print "To regenerate existing PDF, use regenerate=crabe\n"; print "\n"; - print "Example: ".$script_file." filter=payments 20080101 20081231 lang=fr_FR regenerate=yes\n"; + print "Example: ".$script_file." filter=payments 20080101 20081231 lang=fr_FR regenerate=crabe\n"; print "Example: ".$script_file." filter=all lang=it_IT\n"; print "\n"; print "Note that some filters can be cumulated.\n"; From 6abf682faa6dd79776392d34bda5933ee8856adf Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Mon, 14 Jan 2013 12:01:44 +0100 Subject: [PATCH 07/28] Multi-company compatibility with transverse mode for pdf models --- htdocs/core/lib/functions2.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php index c06e037d6cd..69b02ffbbb4 100644 --- a/htdocs/core/lib/functions2.lib.php +++ b/htdocs/core/lib/functions2.lib.php @@ -1250,7 +1250,7 @@ function getListOfModels($db,$type,$maxfilenamelength=0) $sql = "SELECT nom as id, nom as lib, libelle as label, description as description"; $sql.= " FROM ".MAIN_DB_PREFIX."document_model"; $sql.= " WHERE type = '".$type."'"; - $sql.= " AND entity = ".$conf->entity; + $sql.= " AND entity IN (0,".(! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode)?"1,":"").$conf->entity.")"; $resql = $db->query($sql); if ($resql) From 14dde75c4b7939e196e3ff22d9023f06b3d8cea0 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Mon, 14 Jan 2013 12:17:21 +0100 Subject: [PATCH 08/28] Display bug on FF while closing proposal --- htdocs/theme/bureau2crea/style.css.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/theme/bureau2crea/style.css.php b/htdocs/theme/bureau2crea/style.css.php index 5fc109b4349..5a39902b3cf 100644 --- a/htdocs/theme/bureau2crea/style.css.php +++ b/htdocs/theme/bureau2crea/style.css.php @@ -2155,7 +2155,6 @@ div.tabsAction { table.noborder { margin-bottom: 10px; position: relative; - float: left; border: none; } From b9dc76ebaf525d18d2182bcc005d82685d8e3ac8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 14 Jan 2013 12:27:19 +0100 Subject: [PATCH 09/28] Fix: List of contacts when connected as external user. --- htdocs/core/boxes/box_contacts.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/core/boxes/box_contacts.php b/htdocs/core/boxes/box_contacts.php index 47741be9ec0..4d237051672 100755 --- a/htdocs/core/boxes/box_contacts.php +++ b/htdocs/core/boxes/box_contacts.php @@ -78,12 +78,11 @@ class box_contacts extends ModeleBoxes if (! $user->rights->societe->client->voir && ! $user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE sp.entity IN (".getEntity('societe', 1).")"; if (! $user->rights->societe->client->voir && ! $user->societe_id) $sql.= " AND sp.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - if ($user->societe_id) $sql.= " AND sp.rowid = $user->societe_id"; + if ($user->societe_id) $sql.= " AND sp.fk_soc = $user->societe_id"; $sql.= " ORDER BY sp.tms DESC"; $sql.= $db->plimit($max, 0); $result = $db->query($sql); - if ($result) { $num = $db->num_rows($result); From 49313fff3be9b259ab56e5189724f086193e0462 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 14 Jan 2013 13:06:08 +0100 Subject: [PATCH 10/28] Fix: External user should not see boxes of modules not allowed to external users. --- htdocs/core/boxes/box_comptes.php | 13 +++++++++---- htdocs/core/boxes/box_members.php | 16 +++++++++++----- htdocs/core/boxes/modules_boxes.php | 3 ++- htdocs/core/class/conf.class.php | 2 +- htdocs/core/class/infobox.class.php | 5 +++-- 5 files changed, 26 insertions(+), 13 deletions(-) diff --git a/htdocs/core/boxes/box_comptes.php b/htdocs/core/boxes/box_comptes.php index 64389354605..f2d96ad1e51 100644 --- a/htdocs/core/boxes/box_comptes.php +++ b/htdocs/core/boxes/box_comptes.php @@ -1,6 +1,6 @@ + * Copyright (C) 2005-2013 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * * This program is free software; you can redistribute it and/or modify @@ -38,20 +38,25 @@ class box_comptes extends ModeleBoxes var $db; var $param; - + var $enabled = 1; + var $info_box_head = array(); var $info_box_contents = array(); - + /** * Constructor */ function __construct() { - global $langs; + global $conf, $langs, $user; $langs->load("boxes"); $this->boxlabel=$langs->transnoentitiesnoconv('BoxCurrentAccounts'); + + // disable module for such cases + $listofmodulesforexternal=explode(',',$conf->global->MAIN_MODULES_FOR_EXTERNAL); + if (! in_array('banque',$listofmodulesforexternal) && ! empty($user->societe_id)) $this->enabled=0; // disabled for external users } /** diff --git a/htdocs/core/boxes/box_members.php b/htdocs/core/boxes/box_members.php index 89bce42088e..5c9e3a6f3ab 100755 --- a/htdocs/core/boxes/box_members.php +++ b/htdocs/core/boxes/box_members.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2012 Laurent Destailleur + * Copyright (C) 2004-2013 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * * This program is free software; you can redistribute it and/or modify @@ -19,8 +19,8 @@ /** * \file htdocs/core/boxes/box_members.php - * \ingroup societes - * \brief Module de generation de l'affichage de la box clients + * \ingroup adherent + * \brief Module to show box of members */ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; @@ -38,19 +38,25 @@ class box_members extends ModeleBoxes var $db; var $param; - + var $enabled = 1; + var $info_box_head = array(); var $info_box_contents = array(); + /** * Constructor */ function __construct() { - global $langs; + global $conf, $langs, $user; $langs->load("boxes"); $this->boxlabel=$langs->transnoentitiesnoconv("BoxLastMembers"); + + // disable module for such cases + $listofmodulesforexternal=explode(',',$conf->global->MAIN_MODULES_FOR_EXTERNAL); + if (! in_array('banque',$listofmodulesforexternal) && ! empty($user->societe_id)) $this->enabled=0; // disabled for external users } /** diff --git a/htdocs/core/boxes/modules_boxes.php b/htdocs/core/boxes/modules_boxes.php index 913e3d1627a..e0b2efd7489 100644 --- a/htdocs/core/boxes/modules_boxes.php +++ b/htdocs/core/boxes/modules_boxes.php @@ -32,7 +32,8 @@ class ModeleBoxes // Can't be abtract as it is instanciated to build "empty" var $db; var $error=''; var $max=5; - + var $enabled=1; + var $rowid; var $id; var $position; diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index d131db5e89b..9cf96f14aeb 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -409,7 +409,7 @@ class Conf $this->maxfilesize = (empty($this->global->MAIN_UPLOAD_DOC) ? 0 : $this->global->MAIN_UPLOAD_DOC * 1024); // Define list of limited modules - if (! isset($this->global->MAIN_MODULES_FOR_EXTERNAL)) $this->global->MAIN_MODULES_FOR_EXTERNAL='facture,commande,contact,propal,projet,contrat,societe,ficheinter,expedition,agenda'; // '' means 'all'. Note that contact is added here as it should be a module later. + if (! isset($this->global->MAIN_MODULES_FOR_EXTERNAL)) $this->global->MAIN_MODULES_FOR_EXTERNAL='facture,commande,fournisseur,contact,propal,projet,contrat,societe,ficheinter,expedition,agenda'; // '' means 'all'. Note that contact is added here as it should be a module later. // Timeouts if (empty($this->global->MAIN_USE_CONNECT_TIMEOUT)) $this->global->MAIN_USE_CONNECT_TIMEOUT=10; diff --git a/htdocs/core/class/infobox.class.php b/htdocs/core/class/infobox.class.php index 2d3ca1d6ae9..ce961a5868c 100644 --- a/htdocs/core/class/infobox.class.php +++ b/htdocs/core/class/infobox.class.php @@ -119,15 +119,16 @@ class InfoBox $box->box_id = (! empty($obj->box_id) ? $obj->box_id : ''); $box->note = (! empty($obj->note) ? $obj->note : ''); - $enabled=true; + $enabled=$box->enabled; if (isset($box->depends) && count($box->depends) > 0) { foreach($box->depends as $module) { //print $boxname.'-'.$module.'
'; - if (empty($conf->$module->enabled)) $enabled=false; + if (empty($conf->$module->enabled)) $enabled=0; } } + //print 'xx module='.$module.' enabled='.$enabled; if ($enabled) $boxes[]=$box; } } From 6942700ce7301fcaa25a916d1f669f56887ed8a8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 14 Jan 2013 15:18:15 +0100 Subject: [PATCH 11/28] New: Direct jump to edit page --- htdocs/admin/index.php | 7 ++++--- htdocs/admin/tools/index.php | 5 +++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/htdocs/admin/index.php b/htdocs/admin/index.php index b39273d12e3..a80f16f42d7 100644 --- a/htdocs/admin/index.php +++ b/htdocs/admin/index.php @@ -55,12 +55,13 @@ print $langs->trans("SetupDescription2")."

"; print '
'; //print '
'; -print img_picto('','puce').' '.$langs->trans("SetupDescription3",DOL_URL_ROOT.'/admin/company.php?mainmenu=home'); -if (empty($conf->global->MAIN_INFO_SOCIETE_NOM) || empty($conf->global->MAIN_INFO_SOCIETE_PAYS)) +if (empty($conf->global->MAIN_INFO_SOCIETE_NOM) || empty($conf->global->MAIN_INFO_SOCIETE_PAYS)) $setupcompanynotcomplete=1; +print img_picto('','puce').' '.$langs->trans("SetupDescription3",DOL_URL_ROOT.'/admin/company.php?mainmenu=home'.(empty($setupcompanynotcomplete)?'':'&action=edit')); +if (! empty($setupcompanynotcomplete)) { $langs->load("errors"); $warnpicto=img_warning($langs->trans("WarningMandatorySetupNotComplete")); - print '
'.$warnpicto.' '.$langs->trans("WarningMandatorySetupNotComplete").''; + print '
'.$warnpicto.' '.$langs->trans("WarningMandatorySetupNotComplete").''; } print '
'; print '
'; diff --git a/htdocs/admin/tools/index.php b/htdocs/admin/tools/index.php index e3a9d45c6c1..e8a0205252d 100644 --- a/htdocs/admin/tools/index.php +++ b/htdocs/admin/tools/index.php @@ -49,6 +49,11 @@ print "
"; print info_admin($langs->trans("SystemAreaForAdminOnly")).'
'; +print '

'; + + +// Show logo +print '
'; llxFooter(); $db->close(); From 51098c1227633b66e936f26feef3878bffca5288 Mon Sep 17 00:00:00 2001 From: fhenry Date: Mon, 14 Jan 2013 16:13:09 +0100 Subject: [PATCH 12/28] Add standard extrafield type : - mail - phone - price --- htdocs/core/class/commonobject.class.php | 5 +- htdocs/core/class/extrafields.class.php | 60 ++++++++++++++++--- htdocs/core/tpl/admin_extrafields.tpl.php | 3 + htdocs/core/tpl/admin_extrafields_add.tpl.php | 3 +- .../core/tpl/admin_extrafields_edit.tpl.php | 3 +- htdocs/langs/en_US/admin.lang | 3 + htdocs/langs/fr_FR/admin.lang | 3 + 7 files changed, 70 insertions(+), 10 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 0a5ae5df34c..cddfe13ffad 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -2135,7 +2135,10 @@ abstract class CommonObject $this->array_options[$key] = null; } break; - } + case 'price': + $this->array_options[$key] = price2num($this->array_options[$key]); + break; + } } $this->db->begin(); diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index b387537165b..2aa9f925106 100755 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -53,7 +53,10 @@ class ExtraFields 'double'=>'Float', 'date'=>'Date', 'datetime'=>'DateAndTime', - 'boolean'=>'Boolean' + 'boolean'=>'Boolean', + 'price'=>'ExtrafieldPrice', + 'phone'=>'ExtrafieldPhone', + 'mail'=>'ExtrafieldMail' ); /** @@ -139,6 +142,15 @@ class ExtraFields if ($type=='boolean') { $typedb='int'; $lengthdb='1'; + } elseif($type=='price') { + $typedb='double'; + $lengthdb='24,8'; + } elseif($type=='phone') { + $typedb='varchar'; + $lengthdb='20'; + }elseif($type=='mail') { + $typedb='varchar'; + $lengthdb='128'; } else { $typedb=$type; $lengthdb=$length; @@ -312,9 +324,18 @@ class ExtraFields if (isset($attrname) && $attrname != '' && preg_match("/^\w[a-zA-Z0-9-_]*$/",$attrname)) { - if ($type=='boolean') { + if ($type=='boolean') { $typedb='int'; $lengthdb='1'; + } elseif($type=='price') { + $typedb='double'; + $lengthdb='24,8'; + } elseif($type=='phone') { + $typedb='varchar'; + $lengthdb='20'; + }elseif($type=='mail') { + $typedb='varchar'; + $lengthdb='128'; } else { $typedb=$type; $lengthdb=$length; @@ -533,23 +554,23 @@ class ExtraFields $newsize=$tmp[0]; $out=''; } - else if (in_array($type,array('int','double'))) + elseif (in_array($type,array('int','double'))) { $tmp=explode(',',$size); $newsize=$tmp[0]; $out=''; } - else if ($type == 'varchar') + elseif ($type == 'varchar') { $out=''; } - else if ($type == 'text') + elseif ($type == 'text') { require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; $doleditor=new DolEditor('options_'.$key,$value,'',200,'dolibarr_notes','In',false,false,! empty($conf->fckeditor->enabled) && $conf->global->FCKEDITOR_ENABLE_SOCIETE,5,100); $out=$doleditor->Create(1); } - else if ($type == 'boolean') + elseif ($type == 'boolean') { $checked=''; if (!empty($value)) { @@ -559,6 +580,18 @@ class ExtraFields } $out=''; } + elseif ($type == 'mail') + { + $out=''; + } + elseif ($type == 'phone') + { + $out=''; + } + elseif ($type == 'price') + { + $out=' '.getCurrencySymbol($conf->currency); + } // Add comments if ($type == 'date') $out.=' (YYYY-MM-DD)'; elseif ($type == 'datetime') $out.=' (YYYY-MM-DD HH:MM:SS)'; @@ -575,7 +608,8 @@ class ExtraFields */ function showOutputField($key,$value,$moreparam='') { - + global $conf; + $label=$this->attribute_label[$key]; $type=$this->attribute_type[$key]; $size=$this->attribute_size[$key]; @@ -601,6 +635,18 @@ class ExtraFields $checked=' checked="checked" '; } $value=''; + } + elseif ($type == 'mail') + { + $value=dol_print_email($value); + } + elseif ($type == 'phone') + { + $value=dol_print_phone($value); + } + elseif ($type == 'price') + { + $value=price($value).' '.getCurrencySymbol($conf->currency); } else { diff --git a/htdocs/core/tpl/admin_extrafields.tpl.php b/htdocs/core/tpl/admin_extrafields.tpl.php index f2ce0efa59b..3c5ee8dfaa0 100644 --- a/htdocs/core/tpl/admin_extrafields.tpl.php +++ b/htdocs/core/tpl/admin_extrafields.tpl.php @@ -23,6 +23,8 @@ function init_typeoffields(type) { var size = jQuery("#size"); + var unique = jQuery("#unique"); + var required = jQuery("#required"); if (type == 'date') { size.val('').attr('disabled','disabled'); } else if (type == 'datetime') { size.val('').attr('disabled','disabled'); } else if (type == 'double') { size.val('24,8').removeAttr('disabled'); } @@ -30,6 +32,7 @@ else if (type == 'text') { size.val('2000').removeAttr('disabled'); } else if (type == 'varchar') { size.val('255').removeAttr('disabled'); } else if (type == 'boolean') { size.val('').attr('disabled','disabled'); unique.attr('disabled','disabled');} + else if (type == 'price') { size.val('').attr('disabled','disabled'); unique.attr('disabled','disabled');} else size.val('').attr('disabled','disabled'); } init_typeoffields(); diff --git a/htdocs/core/tpl/admin_extrafields_add.tpl.php b/htdocs/core/tpl/admin_extrafields_add.tpl.php index 3215c235281..e77aac66c63 100644 --- a/htdocs/core/tpl/admin_extrafields_add.tpl.php +++ b/htdocs/core/tpl/admin_extrafields_add.tpl.php @@ -17,7 +17,7 @@ */ ?> - + '; } - $nbboxactivated=count($boxactivated); + $nbboxactivated=count($boxidactivatedforuser); print load_fiche_titre(($nbboxactivated?$langs->trans("OtherInformationsBoxes"):''),$selectboxlist,'','','otherboxes'); if ($nbboxactivated) { + $emptybox=new ModeleBoxes($db); + print ''; print ''; + print ''; print ''; print ''; - print ''; + print ''; print ''; $hasnext=($key < (count($boxactivated)-1)); $hasprevious=($key != 0); diff --git a/htdocs/core/boxes/box_activity.php b/htdocs/core/boxes/box_activity.php index adbc2c7090a..834799878d2 100644 --- a/htdocs/core/boxes/box_activity.php +++ b/htdocs/core/boxes/box_activity.php @@ -55,8 +55,7 @@ class box_activity extends ModeleBoxes $this->boxlabel = $langs->transnoentitiesnoconv("BoxGlobalActivity"); - // Disabled by default because, still has some bug (pgsl support, filters) and slow down seriously Dolibarr - $this->enabled = (! empty($conf->global->MAIN_FEATURES_LEVEL) || ! empty($conf->global->MAIN_BOX_ACTIVITY_ENABLED)); + $this->enabled = 1; // FIXME: Use a cache to save data because this slow down too much main home page. This box slow down too seriously software. // FIXME: Removed number_format (not compatible with all languages) // FIXME: Pb into some status diff --git a/htdocs/core/modules/modSociete.class.php b/htdocs/core/modules/modSociete.class.php index 72c4ea71889..a5c446a02e7 100644 --- a/htdocs/core/modules/modSociete.class.php +++ b/htdocs/core/modules/modSociete.class.php @@ -126,6 +126,7 @@ class modSociete extends DolibarrModules $this->boxes[$r][1] = "box_contacts.php"; $r++; $this->boxes[$r][1] = "box_activity.php"; + $this->boxes[$r][2] = '(WarningUsingThisBoxSlowDown)'; $r++; // Permissions diff --git a/htdocs/langs/en_US/errors.lang b/htdocs/langs/en_US/errors.lang index f034287a880..2c5f634fff6 100644 --- a/htdocs/langs/en_US/errors.lang +++ b/htdocs/langs/en_US/errors.lang @@ -129,4 +129,5 @@ WarningsOnXLines=Warnings on %s source lines WarningNoDocumentModelActivated=No model, for document generation, has been activated. A model will be choosed by default until you check your module setup. WarningLockFileDoesNotExists=Warning, once setup is finished, you must disable install/migrate tools by adding a file install.lock into directory %s. Missing this file is a security hole. WarningUntilDirRemoved=All security warnings (visible by admin users only) will remain active as long as the vulnerability is present (or that constant MAIN_REMOVE_INSTALL_WARNING is added in Setup->Other setup). -WarningCloseAlways=Warning, closing is done even if amount differs between source and target elements. Enable this feature with caution. \ No newline at end of file +WarningCloseAlways=Warning, closing is done even if amount differs between source and target elements. Enable this feature with caution. +WarningUsingThisBoxSlowDown=Warning, using this box slow down seriously all pages showing the box. \ No newline at end of file diff --git a/htdocs/langs/fr_FR/errors.lang b/htdocs/langs/fr_FR/errors.lang index f683af9b736..99112a0db96 100644 --- a/htdocs/langs/fr_FR/errors.lang +++ b/htdocs/langs/fr_FR/errors.lang @@ -130,4 +130,5 @@ WarningsOnXLines=Alertes sur %s lignes sources WarningNoDocumentModelActivated=Aucun modèle, pour la génération de document, n'a été activé. Un modèle sera pris par défaut en attendant la correction de configuration du module. WarningLockFileDoesNotExists=Attention, une fois l'installation terminée, les outils d'installation/migration doivent être désactivés en ajoutant un fichier install.lock dans le répertoire %s. L'absence de ce fichier représente une faille de sécurité. WarningUntilDirRemoved=Les alertes de sécurité sont visibles par les administrateurs uniquement et resteront actives tant que la vulnérabilité sera avérée (ou que la constante MAIN_REMOVE_INSTALL_WARNING aura été définie dans Configuration->Divers) -WarningCloseAlways=Attention, la fermeture se fait même lorsque le montant diffère. N'activez cette fonctionnalité qu'en connaissance de cause. \ No newline at end of file +WarningCloseAlways=Attention, la fermeture se fait même lorsque le montant diffère. N'activez cette fonctionnalité qu'en connaissance de cause. +WarningUsingThisBoxSlowDown=Attention, l'utilisation de cette boite provoque de sérieux ralentissement des pages affichant cette boite. \ No newline at end of file From 7075ae2daaf91c7381a051b8e684681a70373857 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 15 Jan 2013 16:08:16 +0100 Subject: [PATCH 26/28] Fix: Showing warning --- htdocs/admin/boxes.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/htdocs/admin/boxes.php b/htdocs/admin/boxes.php index 262cd4c29d4..4834416ffbb 100644 --- a/htdocs/admin/boxes.php +++ b/htdocs/admin/boxes.php @@ -345,7 +345,14 @@ foreach($boxtoadd as $box) print ''; print ''; print ''; - print ''; + print ''; print ''; // Pour chaque position possible, on affiche un lien d'activation si boite non deja active pour cette position From 1e9cb6b1d4903e21642cc29f0262d457b37885b1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 15 Jan 2013 17:06:53 +0100 Subject: [PATCH 27/28] Qual: A translation file must not be loaded into class constructors, but at output level. --- htdocs/admin/boxes.php | 5 +++-- htdocs/core/boxes/box_actions.php | 13 +------------ htdocs/core/boxes/box_activity.php | 15 ++++----------- htdocs/core/boxes/box_bookmarks.php | 12 +----------- htdocs/core/boxes/box_clients.php | 12 +----------- htdocs/core/boxes/box_commandes.php | 12 +----------- htdocs/core/boxes/box_comptes.php | 11 +++++------ htdocs/core/boxes/box_contacts.php | 12 +----------- htdocs/core/boxes/box_contracts.php | 14 +------------- htdocs/core/boxes/box_external_rss.php | 7 +------ htdocs/core/boxes/box_factures.php | 12 +----------- htdocs/core/boxes/box_factures_fourn.php | 12 +----------- htdocs/core/boxes/box_factures_fourn_imp.php | 13 +------------ htdocs/core/boxes/box_factures_imp.php | 13 +------------ htdocs/core/boxes/box_fournisseurs.php | 12 +----------- htdocs/core/boxes/box_members.php | 9 ++++----- htdocs/core/boxes/box_osc_client.php | 12 +----------- htdocs/core/boxes/box_produits.php | 13 +------------ htdocs/core/boxes/box_produits_alerte_stock.php | 13 +------------ htdocs/core/boxes/box_propales.php | 13 +------------ htdocs/core/boxes/box_prospect.php | 17 +---------------- htdocs/core/boxes/box_services_contracts.php | 14 ++------------ htdocs/core/boxes/box_services_expired.php | 14 +------------- htdocs/core/boxes/box_supplier_orders.php | 13 ++----------- htdocs/core/boxes/modules_boxes.php | 2 +- htdocs/core/class/html.formother.class.php | 3 ++- htdocs/core/class/translate.class.php | 2 +- htdocs/index.php | 2 ++ 28 files changed, 44 insertions(+), 258 deletions(-) diff --git a/htdocs/admin/boxes.php b/htdocs/admin/boxes.php index 4834416ffbb..1522b0977ec 100644 --- a/htdocs/admin/boxes.php +++ b/htdocs/admin/boxes.php @@ -28,6 +28,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/infobox.class.php'; include_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; $langs->load("admin"); +$langs->load("boxes"); if (! $user->admin) accessforbidden(); @@ -344,7 +345,7 @@ foreach($boxtoadd as $box) print '
'; print ''; print '
'; - print ''; + print ''; print ''; - print ''; + print ''; print '
'."\n"; @@ -873,6 +878,7 @@ class FormOther $ii=0; foreach ($boxactivated as $key => $box) { + if ((! empty($user->conf->$confuserzone) && $box->fk_user == 0) || (empty($user->conf->$confuserzone) && $box->fk_user != 0)) continue; if (empty($box->box_order) && $ii < ($nbboxactivated / 2)) $box->box_order='A'.sprintf("%02d",($ii+1)); // When box_order was not yet set to Axx or Bxx and is still 0 if (preg_match('/^A/i',$box->box_order)) // column A { @@ -885,7 +891,6 @@ class FormOther } } - $emptybox=new ModeleBoxes($db); $emptybox->box_id='A'; $emptybox->info_box_head=array(); $emptybox->info_box_contents=array(); @@ -902,7 +907,8 @@ class FormOther $ii=0; foreach ($boxactivated as $key => $box) { - if (empty($box->box_order) && $ii < ($nbboxactivated / 2)) $box->box_order='B'.sprintf("%02d",($ii+1)); // When box_order was not yet set to Axx or Bxx and is still 0 + if ((! empty($user->conf->$confuserzone) && $box->fk_user == 0) || (empty($user->conf->$confuserzone) && $box->fk_user != 0)) continue; + if (empty($box->box_order) && $ii < ($nbboxactivated / 2)) $box->box_order='B'.sprintf("%02d",($ii+1)); // When box_order was not yet set to Axx or Bxx and is still 0 if (preg_match('/^B/i',$box->box_order)) // colonne B { $ii++; @@ -914,7 +920,6 @@ class FormOther } } - $emptybox=new ModeleBoxes($db); $emptybox->box_id='B'; $emptybox->info_box_head=array(); $emptybox->info_box_contents=array(); diff --git a/htdocs/core/class/infobox.class.php b/htdocs/core/class/infobox.class.php index ce961a5868c..b5a0e3ad7d0 100644 --- a/htdocs/core/class/infobox.class.php +++ b/htdocs/core/class/infobox.class.php @@ -33,7 +33,7 @@ class InfoBox * @param DoliDB $db Database handler * @param string $mode 'available' or 'activated' * @param string $zone Name or area (-1 for all, 0 for Homepage, 1 for xxx, ...) - * @param User $user Objet user to filter (used only if $zone >= 0) + * @param User $user Objet user to filter * @param array $excludelist Array of box id (box.box_id = boxes_def.rowid) to exclude * @return array Array of boxes */ @@ -52,7 +52,7 @@ class InfoBox $sql.= " WHERE b.box_id = d.rowid"; $sql.= " AND b.entity = ".$conf->entity; if ($zone >= 0) $sql.= " AND b.position = ".$zone; - if ($user->id && ! empty($user->conf->$confuserzone)) $sql.= " AND b.fk_user = ".$user->id; + if (is_object($user)) $sql.= " AND b.fk_user IN (0,".$user->id.")"; else $sql.= " AND b.fk_user = 0"; $sql.= " ORDER BY b.box_order"; } @@ -71,7 +71,7 @@ class InfoBox } } - dol_syslog(get_class()."::listBoxes get default box list sql=".$sql, LOG_DEBUG); + dol_syslog(get_class()."::listBoxes get default box list for mode=".$mode." userid=".(is_object($user)?$user->id:'')." sql=".$sql, LOG_DEBUG); $resql = $db->query($sql); if ($resql) { @@ -101,13 +101,13 @@ class InfoBox $box=new $boxname($db,$obj->note); // box properties - $box->rowid = (! empty($obj->rowid) ? $obj->rowid : ''); - $box->id = (! empty($obj->box_id) ? $obj->box_id : ''); - $box->position = (! empty($obj->position) ? $obj->position : ''); - $box->box_order = (! empty($obj->box_order) ? $obj->box_order : ''); - $box->fk_user = (! empty($obj->fk_user) ? $obj->fk_user : ''); + $box->rowid = (empty($obj->rowid) ? '' : $obj->rowid); + $box->id = (empty($obj->box_id) ? '' : $obj->box_id); + $box->position = (empty($obj->position) ? '' : $obj->position); + $box->box_order = (empty($obj->box_order) ? '' : $obj->box_order); + $box->fk_user = (empty($obj->fk_user) ? 0 : $obj->fk_user); $box->sourcefile=$relsourcefile; - if ($mode == 'activated' && (! $user->id || empty($user->conf->$confuserzone))) // List of activated box was not yet personalized into database + if ($mode == 'activated' && ! is_object($user)) // List of activated box was not yet personalized into database { if (is_numeric($box->box_order)) { @@ -116,8 +116,8 @@ class InfoBox } } // box_def properties - $box->box_id = (! empty($obj->box_id) ? $obj->box_id : ''); - $box->note = (! empty($obj->note) ? $obj->note : ''); + $box->box_id = (empty($obj->box_id) ? '' : $obj->box_id); + $box->note = (empty($obj->note) ? '' : $obj->note); $enabled=$box->enabled; if (isset($box->depends) && count($box->depends) > 0) @@ -128,6 +128,7 @@ class InfoBox if (empty($conf->$module->enabled)) $enabled=0; } } + //print 'xx module='.$module.' enabled='.$enabled; if ($enabled) $boxes[]=$box; } @@ -138,9 +139,8 @@ class InfoBox else { //dol_print_error($db); - $error=$db->error(); + $error=$db->lasterror(); dol_syslog(get_class()."::listBoxes Error ".$error, LOG_ERR); - return array(); } return $boxes; diff --git a/htdocs/core/class/menubase.class.php b/htdocs/core/class/menubase.class.php index ada707fe11f..24427f6b3c2 100644 --- a/htdocs/core/class/menubase.class.php +++ b/htdocs/core/class/menubase.class.php @@ -434,7 +434,7 @@ class Menubase $this->newmenu = $newmenu; // Load datas from database into $tabMenu, later we will complete this->newmenu with values into $tabMenu - if (count($tabMenu) == 0) + if (count($tabMenu) == 0) // To avoid to read into database a second time { $this->menuLoad($mainmenu, $leftmenu, $type_user, $menu_handler, $tabMenu); } @@ -535,7 +535,7 @@ class Menubase // If type_user == 2, no test required $sql.= " ORDER BY m.position, m.rowid"; - dol_syslog(get_class($this)."::menuLeftCharger sql=".$sql); + dol_syslog(get_class($this)."::menuLoad mymainmenu=".$mymainmenu." myleftmenu=".$myleftmenu." type_user=".$type_user." menu_handler=".$menu_handler." tabMenu size=".count($tabMenu)." sql=".$sql); $resql = $this->db->query($sql); if ($resql) { diff --git a/htdocs/core/menus/standard/auguria_frontoffice.php b/htdocs/core/menus/standard/auguria_frontoffice.php index 7d095d8e6d4..8432a29e9af 100644 --- a/htdocs/core/menus/standard/auguria_frontoffice.php +++ b/htdocs/core/menus/standard/auguria_frontoffice.php @@ -98,6 +98,8 @@ class MenuLeft */ function showmenu() { + global $conf; + require_once DOL_DOCUMENT_ROOT.'/core/menus/standard/auguria.lib.php'; $res=print_left_auguria_menu($this->db,$this->menu_array,$this->menu_array_after); diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index bb47d82fd9b..fed1dc70155 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -444,7 +444,7 @@ function print_eldy_menu($db,$atarget,$type_user) $tabMenu=array(); $menuArbo = new Menubase($db,'eldy','top'); - $newTabMenu = $menuArbo->menuTopCharger('','',$type_user,'eldy',$tabMenu); + $newTabMenu = $menuArbo->menuTopCharger('','',$type_user,'eldy',$tabMenu); // Return tabMenu with only top entries $num = count($newTabMenu); for($i = 0; $i < $num; $i++) diff --git a/htdocs/core/menus/standard/eldy_frontoffice.php b/htdocs/core/menus/standard/eldy_frontoffice.php index 355619e6832..9aec7ac62a4 100644 --- a/htdocs/core/menus/standard/eldy_frontoffice.php +++ b/htdocs/core/menus/standard/eldy_frontoffice.php @@ -96,6 +96,8 @@ class MenuLeft */ function showmenu() { + global $conf; + require_once DOL_DOCUMENT_ROOT.'/core/menus/standard/eldy.lib.php'; $res=print_left_eldy_menu($this->db,$this->menu_array,$this->menu_array_after); From 92723bd6fe438ee4fc10035b400bd456119547c5 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Tue, 15 Jan 2013 11:41:12 +0100 Subject: [PATCH 19/28] Fix: broken features --- htdocs/product/fiche.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/product/fiche.php b/htdocs/product/fiche.php index 783513b67fb..209ba5ff89a 100644 --- a/htdocs/product/fiche.php +++ b/htdocs/product/fiche.php @@ -70,7 +70,6 @@ if (! empty($canvas)) require_once DOL_DOCUMENT_ROOT.'/core/class/canvas.class.php'; $objcanvas = new Canvas($db,$action); $objcanvas->getCanvas('product','card',$canvas); - $objcanvas->assign_values($action, $object->id, $ref); // Set value for templates } // Security check @@ -656,7 +655,8 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) // ----------------------------------------- // When used with CANVAS (more simple) // ----------------------------------------- - $objcanvas->display_canvas($action); // Show template + $objcanvas->assign_values($action, $object->id, $object->ref); // Set value for templates + $objcanvas->display_canvas($action); // Show template } else { From 4cf56eafa5d1141448126858c150160dd48528c5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 15 Jan 2013 12:48:46 +0100 Subject: [PATCH 20/28] Qual: Removed useless param --- htdocs/core/class/menubase.class.php | 4 +--- htdocs/core/menus/smartphone/smartphone.lib.php | 4 ++-- htdocs/core/menus/standard/auguria.lib.php | 4 ++-- htdocs/core/menus/standard/eldy.lib.php | 4 ++-- 4 files changed, 7 insertions(+), 9 deletions(-) diff --git a/htdocs/core/class/menubase.class.php b/htdocs/core/class/menubase.class.php index 24427f6b3c2..b3b37d563de 100644 --- a/htdocs/core/class/menubase.class.php +++ b/htdocs/core/class/menubase.class.php @@ -59,13 +59,11 @@ class Menubase * * @param DoliDB $db Database handler * @param string $menu_handler Menu handler - * @param string $type Type */ - function __construct($db,$menu_handler='',$type='') + function __construct($db,$menu_handler='') { $this->db = $db; $this->menu_handler = $menu_handler; - $this->type = $type; return 1; } diff --git a/htdocs/core/menus/smartphone/smartphone.lib.php b/htdocs/core/menus/smartphone/smartphone.lib.php index 25ac32ef1af..e24688b3bef 100755 --- a/htdocs/core/menus/smartphone/smartphone.lib.php +++ b/htdocs/core/menus/smartphone/smartphone.lib.php @@ -42,8 +42,8 @@ function print_smartphone_menu($db,$atarget,$type_user,$limitmenuto) $tabMenu=array(); - $menutop = new Menubase($db,'smartphone','top'); - $menuleft = new Menubase($db,'smartphone','left'); + $menutop = new Menubase($db,'smartphone'); + $menuleft = new Menubase($db,'smartphone'); $newTabMenu = $menutop->menuTopCharger('', '', $type_user, 'smartphone',$tabMenu); $numTabMenu = count($newTabMenu); diff --git a/htdocs/core/menus/standard/auguria.lib.php b/htdocs/core/menus/standard/auguria.lib.php index cae544c6aa4..0896c8d69ea 100644 --- a/htdocs/core/menus/standard/auguria.lib.php +++ b/htdocs/core/menus/standard/auguria.lib.php @@ -46,7 +46,7 @@ function print_auguria_menu($db,$atarget,$type_user) $listofmodulesforexternal=explode(',',$conf->global->MAIN_MODULES_FOR_EXTERNAL); $tabMenu=array(); - $menuArbo = new Menubase($db,'auguria','top'); + $menuArbo = new Menubase($db,'auguria'); $newTabMenu = $menuArbo->menuTopCharger('', '', $type_user, 'auguria',$tabMenu); print_start_menu_array_auguria(); @@ -259,7 +259,7 @@ function print_left_auguria_menu($db,$menu_array_before,$menu_array_after) require_once DOL_DOCUMENT_ROOT.'/core/class/menubase.class.php'; $tabMenu=array(); - $menuArbo = new Menubase($db,'auguria','left'); + $menuArbo = new Menubase($db,'auguria'); $newmenu = $menuArbo->menuLeftCharger($newmenu,$mainmenu,$leftmenu,($user->societe_id?1:0),'auguria',$tabMenu); //var_dump($newmenu); } diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 5ad1389819b..8260611803b 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -443,7 +443,7 @@ function print_eldy_menu($db,$atarget,$type_user) require_once DOL_DOCUMENT_ROOT.'/core/class/menubase.class.php'; $tabMenu=array(); - $menuArbo = new Menubase($db,'eldy','top'); + $menuArbo = new Menubase($db,'eldy'); $newTabMenu = $menuArbo->menuTopCharger('','',$type_user,'eldy',$tabMenu); // Return tabMenu with only top entries $num = count($newTabMenu); @@ -1362,7 +1362,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after) require_once DOL_DOCUMENT_ROOT.'/core/class/menubase.class.php'; $tabMenu=array(); - $menuArbo = new Menubase($db,'eldy','left'); + $menuArbo = new Menubase($db,'eldy'); $newmenu = $menuArbo->menuLeftCharger($newmenu,$mainmenu,$leftmenu,(empty($user->societe_id)?0:1),'eldy',$tabMenu); } From ec5b4f5fa758e80cd2aa5daeca60672e2111cbfd Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 15 Jan 2013 15:36:04 +0100 Subject: [PATCH 21/28] Fix: Start to fix some bug (pgsql compatibility), try to optimize request. Added FIXME tags. --- htdocs/core/boxes/box_activity.php | 58 ++++++++++++++++++------------ 1 file changed, 35 insertions(+), 23 deletions(-) diff --git a/htdocs/core/boxes/box_activity.php b/htdocs/core/boxes/box_activity.php index 7839f4c30aa..adbc2c7090a 100644 --- a/htdocs/core/boxes/box_activity.php +++ b/htdocs/core/boxes/box_activity.php @@ -1,5 +1,7 @@ +/* Copyright (C) 2012 Charles-François BENKE + * Copyright (C) 2005-2013 Laurent Destailleur + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -31,10 +33,11 @@ class box_activity extends ModeleBoxes var $boximg="object_bill"; var $boxlabel; var $depends = array("facture"); - + var $db; var $param; - + var $enabled = 1; + var $info_box_head = array(); var $info_box_contents = array(); @@ -43,7 +46,7 @@ class box_activity extends ModeleBoxes */ function __construct() { - global $langs; + global $langs,$conf; $langs->load("boxes"); $langs->load("bills"); @@ -51,6 +54,12 @@ class box_activity extends ModeleBoxes $langs->load("orders"); $this->boxlabel = $langs->transnoentitiesnoconv("BoxGlobalActivity"); + + // Disabled by default because, still has some bug (pgsl support, filters) and slow down seriously Dolibarr + $this->enabled = (! empty($conf->global->MAIN_FEATURES_LEVEL) || ! empty($conf->global->MAIN_BOX_ACTIVITY_ENABLED)); + // FIXME: Use a cache to save data because this slow down too much main home page. This box slow down too seriously software. + // FIXME: Removed number_format (not compatible with all languages) + // FIXME: Pb into some status } /** @@ -66,13 +75,7 @@ class box_activity extends ModeleBoxes $totalMnt = 0; $totalnb = 0; - include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; - include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; - include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; - $facturestatic=new Facture($db); - $propalstatic=new Propal($db); - $commandestatic=new Commande($db); $nbofyears=2; if (! empty($conf->global->MAIN_BOX_ACTIVITY_DURATION)) $nbofyears=$conf->global->MAIN_BOX_ACTIVITY_DURATION; @@ -80,12 +83,15 @@ class box_activity extends ModeleBoxes $this->info_box_head = array('text' => $textHead, 'limit'=> dol_strlen($textHead)); // compute the year limit to show - $tmpdate= dol_time_plus_duree(time(), -1*$nbofyears, "y"); + $tmpdate= dol_time_plus_duree(dol_now(), -1*$nbofyears, "y"); // list the summary of the bills if (! empty($conf->facture->enabled) && $user->rights->facture->lire) { - $sql = "SELECT f.paye, f.fk_statut, SUM(f.total_ttc) as Mnttot, COUNT(*) as nb"; + include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; + $facturestatic=new Facture($db); + + $sql = "SELECT f.fk_statut, SUM(f.total_ttc) as Mnttot, COUNT(*) as nb"; $sql.= " FROM (".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f"; if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= ")"; @@ -94,7 +100,7 @@ class box_activity extends ModeleBoxes if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id; $sql.= " AND f.fk_soc = s.rowid"; $sql.= " AND f.datef >= '".$db->idate($tmpdate)."' AND paye=1"; - $sql.= " GROUP BY f.paye, f.fk_statut "; + $sql.= " GROUP BY f.fk_statut"; $sql.= " ORDER BY f.fk_statut DESC"; $result = $db->query($sql); @@ -107,7 +113,7 @@ class box_activity extends ModeleBoxes $this->info_box_contents[$i][0] = array('td' => 'align="left" width="16"', 'logo' => 'bill'); $objp = $db->fetch_object($result); - $this->info_box_contents[$i][1] = array('td' => 'align="left"', 'text' => $langs->trans("Bills")." ".$facturestatic->LibStatut($objp->paye,$objp->fk_statut,0)." ".$objp->annee); + $this->info_box_contents[$i][1] = array('td' => 'align="left"', 'text' => $langs->trans("Bills")." ".$facturestatic->LibStatut(1,$objp->fk_statut,0)." ".$objp->annee); $billurl="viewstatut=2&paye=1&year=".$objp->annee; $this->info_box_contents[$i][2] = array('td' => 'align="right"', @@ -123,19 +129,19 @@ class box_activity extends ModeleBoxes $totalnb += $objp->nb; $totalMnt += $objp->Mnttot; } - $this->info_box_contents[$i][4] = array('td' => 'align="right" width="18"', 'text' => $facturestatic->LibStatut($objp->paye,$objp->fk_statut,3) ); + $this->info_box_contents[$i][4] = array('td' => 'align="right" width="18"', 'text' => $facturestatic->LibStatut(1,$objp->fk_statut,3) ); $i++; } if ($num==0) $this->info_box_contents[$i][0] = array('td' => 'align="center"','text'=>$langs->trans("NoRecordedInvoices")); } else dol_print_error($db); - $sql = "SELECT f.paye, f.fk_statut, SUM(f.total_ttc) as Mnttot, COUNT(*) as nb"; + $sql = "SELECT f.fk_statut, SUM(f.total_ttc) as Mnttot, COUNT(*) as nb"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f"; $sql.= " WHERE f.entity = ".$conf->entity; $sql.= " AND f.fk_soc = s.rowid"; $sql.= " AND paye=0"; - $sql.= " GROUP BY f.paye, f.fk_statut "; + $sql.= " GROUP BY f.fk_statut"; $sql.= " ORDER BY f.fk_statut DESC"; $result = $db->query($sql); @@ -151,7 +157,7 @@ class box_activity extends ModeleBoxes $objp = $db->fetch_object($result); $this->info_box_contents[$i][1] = array('td' => 'align="left"', - 'text' => $langs->trans("Bills")." ".$facturestatic->LibStatut($objp->paye,$objp->fk_statut,0)); + 'text' => $langs->trans("Bills")." ".$facturestatic->LibStatut(0,$objp->fk_statut,0)); $billurl="viewstatut=".$objp->fk_statut."&paye=0"; $this->info_box_contents[$i][2] = array('td' => 'align="right"', @@ -163,7 +169,7 @@ class box_activity extends ModeleBoxes ); $totalMnt += $objp->Mnttot; $this->info_box_contents[$i][4] = array('td' => 'align="right" width="18"', - 'text' => $facturestatic->LibStatut($objp->paye,$objp->fk_statut,3) + 'text' => $facturestatic->LibStatut(0,$objp->fk_statut,3) ); $i++; } @@ -176,7 +182,10 @@ class box_activity extends ModeleBoxes // list the summary of the orders if (! empty($conf->commande->enabled) && $user->rights->commande->lire) { - $sql = "SELECT c.fk_statut,c.facture, sum(c.total_ttc) as Mnttot, count(*) as nb"; + include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; + $commandestatic=new Commande($db); + + $sql = "SELECT c.fk_statut, sum(c.total_ttc) as Mnttot, count(*) as nb"; $sql.= " FROM (".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."commande as c"; if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= ")"; @@ -200,7 +209,7 @@ class box_activity extends ModeleBoxes $objp = $db->fetch_object($result); $this->info_box_contents[$i][1] = array('td' => 'align="left"', - 'text' =>$langs->trans("Orders")." ".$commandestatic->LibStatut($objp->fk_statut,$objp->facture,0) + 'text' =>$langs->trans("Orders")." ".$commandestatic->LibStatut($objp->fk_statut,0,0) ); $this->info_box_contents[$i][2] = array('td' => 'align="right"', @@ -213,7 +222,7 @@ class box_activity extends ModeleBoxes 'text' => dol_trunc(number_format($objp->Mnttot, 0, ',', ' '),40)." ".getCurrencySymbol($conf->currency) ); $totalMnt += $objp->Mnttot; - $this->info_box_contents[$i][4] = array('td' => 'align="right" width="18"', 'text' => $commandestatic->LibStatut($objp->fk_statut,$objp->facture,3)); + $this->info_box_contents[$i][4] = array('td' => 'align="right" width="18"', 'text' => $commandestatic->LibStatut($objp->fk_statut,0,3)); $i++; } @@ -224,7 +233,10 @@ class box_activity extends ModeleBoxes // list the summary of the propals if (! empty($conf->propal->enabled) && $user->rights->propal->lire) { - $sql = "SELECT p.fk_statut, sum(p.total) as Mnttot, count(*) as nb"; + include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; + $propalstatic=new Propal($db); + + $sql = "SELECT p.fk_statut, SUM(p.total) as Mnttot, COUNT(*) as nb"; $sql.= " FROM (".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."propal as p"; if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= ")"; From db1cd6b27f455746cd1ca4158c4dfaba2329f8ff Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 15 Jan 2013 15:42:39 +0100 Subject: [PATCH 22/28] Qual: Merge the 2 class MenuTop and MenuLeft into menu handler file into 1 class MenuManager. This make code simpler and is also a first step to optimize performance of menu loading. --- .../menus/standard/auguria_backoffice.php | 65 ++-- .../menus/standard/auguria_frontoffice.php | 62 +--- .../core/menus/standard/eldy_backoffice.php | 51 +-- .../core/menus/standard/eldy_frontoffice.php | 48 +-- htdocs/core/menus/standard/empty.php | 293 ++++++++---------- htdocs/main.inc.php | 17 +- 6 files changed, 197 insertions(+), 339 deletions(-) diff --git a/htdocs/core/menus/standard/auguria_backoffice.php b/htdocs/core/menus/standard/auguria_backoffice.php index 2d8fba928f3..bad8c3d1507 100644 --- a/htdocs/core/menus/standard/auguria_backoffice.php +++ b/htdocs/core/menus/standard/auguria_backoffice.php @@ -1,7 +1,7 @@ * Copyright (C) 2009 Regis Houssin - * Copyright (C) 2008-2009 Laurent Destailleur + * Copyright (C) 2008-2013 Laurent Destailleur * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -31,78 +31,49 @@ /** * Classe permettant la gestion du menu du haut Auguria */ -class MenuTop +class MenuManager { var $db; var $require_left=array("auguria_backoffice"); // Si doit etre en phase avec un gestionnaire de menu gauche particulier var $type_user=0; // Put 0 for internal users, 1 for external users var $atarget=""; // Valeur du target a utiliser dans les liens + var $menu_array; + var $menu_array_after; - /** + + /** * Constructor * - * @param DoliDb $db Database handler - */ - function __construct($db) - { - $this->db=$db; - } - - - /** - * Show menu - * - * @return void - */ - function showmenu() - { - require_once DOL_DOCUMENT_ROOT.'/core/menus/standard/auguria.lib.php'; - - print_auguria_menu($this->db,$this->atarget,$this->type_user); - } - -} - - -/** - * Classe permettant la gestion du menu du gauche Auguria - */ -class MenuLeft -{ - var $db; - var $menu_array; - var $menu_array_after; - - - /** - * Constructor - * * @param DoliDB $db Database handler * @param array &$menu_array Table of menu entries to show before entries of menu handler * @param array &$menu_array_after Table of menu entries to show after entries of menu handler */ - function __construct($db,&$menu_array,&$menu_array_after) + function __construct($db, &$menu_array, &$menu_array_after) { $this->db=$db; $this->menu_array=$menu_array; $this->menu_array_after=$menu_array_after; } - + /** - * Show menu + * Show menu * - * @return int Number of menu entries shown + * @param string $mode 'top' or 'left' + * @return int Number of menu entries shown */ - function showmenu() + function showmenu($mode) { - require_once DOL_DOCUMENT_ROOT.'/core/menus/standard/auguria.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/core/menus/standard/auguria.lib.php'; - $res=print_left_auguria_menu($this->db,$this->menu_array,$this->menu_array_after); + $res='ErrorBadParameterForMode'; + if ($mode == 'top') $res=print_auguria_menu($this->db,$this->atarget,$this->type_user); + if ($mode == 'left') $res=print_left_auguria_menu($this->db,$this->menu_array,$this->menu_array_after); return $res; - } + } + } ?> diff --git a/htdocs/core/menus/standard/auguria_frontoffice.php b/htdocs/core/menus/standard/auguria_frontoffice.php index 8432a29e9af..73a22696eb0 100644 --- a/htdocs/core/menus/standard/auguria_frontoffice.php +++ b/htdocs/core/menus/standard/auguria_frontoffice.php @@ -1,7 +1,7 @@ * Copyright (C) 2009 Regis Houssin - * Copyright (C) 2008-2009 Laurent Destailleur + * Copyright (C) 2008-2013 Laurent Destailleur * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -31,7 +31,7 @@ /** * Classe permettant la gestion du menu du haut Auguria */ -class MenuTop +class MenuManager { var $db; var $require_left=array("auguria_backoffice"); // Si doit etre en phase avec un gestionnaire de menu gauche particulier @@ -39,43 +39,10 @@ class MenuTop var $atarget=""; // Valeur du target a utiliser dans les liens - /** - * Constructor - * - * @param DoliDb $db Database handler - */ - function __construct($db) - { - $this->db=$db; - } - - - - /** - * Show menu - * - * @return void - */ - function showmenu() - { - require_once DOL_DOCUMENT_ROOT.'/core/menus/standard/auguria.lib.php'; - - print_auguria_menu($this->db,$this->atarget,$this->type_user); - } - -} - - -/** - * Classe permettant la gestion du menu du gauche Auguria - */ -class MenuLeft -{ - var $db; - var $menu_array; - var $menu_array_after; - + var $menu_array; + var $menu_array_after; + /** * Constructor * @@ -83,29 +50,32 @@ class MenuLeft * @param array &$menu_array Table of menu entries to show before entries of menu handler * @param array &$menu_array_after Table of menu entries to show after entries of menu handler */ - function __construct($db,&$menu_array,&$menu_array_after) + function __construct($db, &$menu_array, &$menu_array_after) { $this->db=$db; $this->menu_array=$menu_array; $this->menu_array_after=$menu_array_after; } - + /** * Show menu * - * @return int Number of menu entries shown - */ - function showmenu() - { + * @param string $mode 'top' or 'left' + * @return int Number of menu entries shown + */ + function showmenu($mode) + { global $conf; require_once DOL_DOCUMENT_ROOT.'/core/menus/standard/auguria.lib.php'; - $res=print_left_auguria_menu($this->db,$this->menu_array,$this->menu_array_after); - $conf->global->MAIN_SEARCHFORM_SOCIETE=0; $conf->global->MAIN_SEARCHFORM_CONTACT=0; + + $res='ErrorBadParameterForMode'; + if ($mode == 'top') $res=print_auguria_menu($this->db,$this->atarget,$this->type_user); + if ($mode == 'left') $res=print_left_auguria_menu($this->db,$this->menu_array,$this->menu_array_after); return $res; } diff --git a/htdocs/core/menus/standard/eldy_backoffice.php b/htdocs/core/menus/standard/eldy_backoffice.php index 3baf9cd2ab0..82b3837f66d 100644 --- a/htdocs/core/menus/standard/eldy_backoffice.php +++ b/htdocs/core/menus/standard/eldy_backoffice.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2005-2013 Laurent Destailleur * Copyright (C) 2007-2010 Regis Houssin * * This program is free software; you can redistribute it and/or modify @@ -28,49 +28,15 @@ /** - * Class to manage top menu Eldy (for internal users) + * Classe to manage menu Eldy */ -class MenuTop +class MenuManager { var $db; var $require_left=array("eldy_backoffice"); // Si doit etre en phase avec un gestionnaire de menu gauche particulier var $type_user=0; // Put 0 for internal users, 1 for external users var $atarget=""; // Valeur du target a utiliser dans les liens - - /** - * Constructor - * - * @param DoliDb $db Database handler - */ - function __construct($db) - { - $this->db=$db; - } - - - /** - * Show menu - * - * @return void - */ - function showmenu() - { - require_once DOL_DOCUMENT_ROOT.'/core/menus/standard/eldy.lib.php'; - - print_eldy_menu($this->db,$this->atarget,$this->type_user); - } - -} - - -/** - * \class MenuLeft - * \brief Classe permettant la gestion du menu du gauche Eldy - */ -class MenuLeft -{ - var $db; var $menu_array; var $menu_array_after; @@ -82,7 +48,7 @@ class MenuLeft * @param array &$menu_array Table of menu entries to show before entries of menu handler * @param array &$menu_array_after Table of menu entries to show after entries of menu handler */ - function __construct($db,&$menu_array,&$menu_array_after) + function __construct($db, &$menu_array, &$menu_array_after) { $this->db=$db; $this->menu_array=$menu_array; @@ -93,13 +59,16 @@ class MenuLeft /** * Show menu * - * @return int Number of menu entries shown + * @param string $mode 'top' or 'left' + * @return int Number of menu entries shown */ - function showmenu() + function showmenu($mode) { require_once DOL_DOCUMENT_ROOT.'/core/menus/standard/eldy.lib.php'; - $res=print_left_eldy_menu($this->db,$this->menu_array,$this->menu_array_after); + $res='ErrorBadParameterForMode'; + if ($mode == 'top') $res=print_eldy_menu($this->db,$this->atarget,$this->type_user); + if ($mode == 'left') $res=print_left_eldy_menu($this->db,$this->menu_array,$this->menu_array_after); return $res; } diff --git a/htdocs/core/menus/standard/eldy_frontoffice.php b/htdocs/core/menus/standard/eldy_frontoffice.php index 9aec7ac62a4..ecc1b0c1b94 100644 --- a/htdocs/core/menus/standard/eldy_frontoffice.php +++ b/htdocs/core/menus/standard/eldy_frontoffice.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2005-2013 Laurent Destailleur * Copyright (C) 2007-2009 Regis Houssin * * This program is free software; you can redistribute it and/or modify @@ -28,48 +28,15 @@ /** - * Class to manage top menu Eldy (for external users) + * Class to manage menu Eldy (for external users) */ -class MenuTop +class MenuManager { var $db; var $require_left=array("eldy_frontoffice"); // Si doit etre en phase avec un gestionnaire de menu gauche particulier var $type_user=1; // Put 0 for internal users, 1 for external users var $atarget=""; // Valeur du target a utiliser dans les liens - - /** - * Constructor - * - * @param DoliDb $db Database handler - */ - function __construct($db) - { - $this->db=$db; - } - - - /** - * Show menu - * - * @return void - */ - function showmenu() - { - require_once DOL_DOCUMENT_ROOT.'/core/menus/standard/eldy.lib.php'; - - print_eldy_menu($this->db,$this->atarget,$this->type_user); - } - -} - - -/** - * Classe permettant la gestion du menu du gauche Eldy - */ -class MenuLeft -{ - var $db; var $menu_array; var $menu_array_after; @@ -92,19 +59,22 @@ class MenuLeft /** * Show menu * + * @param string $mode 'top' or 'left' * @return int Number of menu entries shown */ - function showmenu() + function showmenu($mode) { global $conf; require_once DOL_DOCUMENT_ROOT.'/core/menus/standard/eldy.lib.php'; - $res=print_left_eldy_menu($this->db,$this->menu_array,$this->menu_array_after); - $conf->global->MAIN_SEARCHFORM_SOCIETE=0; $conf->global->MAIN_SEARCHFORM_CONTACT=0; + $res='ErrorBadParameterForMode'; + if ($mode == 'top') $res=print_eldy_menu($this->db,$this->atarget,$this->type_user); + if ($mode == 'left') $res=print_left_eldy_menu($this->db,$this->menu_array,$this->menu_array_after); + return $res; } diff --git a/htdocs/core/menus/standard/empty.php b/htdocs/core/menus/standard/empty.php index f67ded5b41f..411b98d52a4 100644 --- a/htdocs/core/menus/standard/empty.php +++ b/htdocs/core/menus/standard/empty.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2006-2013 Laurent Destailleur * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -21,56 +21,156 @@ */ /** - * \class MenuTop - * \brief Class for top empty menu + * Class to manage empty menu */ -class MenuTop +class MenuManager { var $db; - var $require_left=array("empty"); // If this top menu handler must be used with a particular left menu handler + var $require_left=array("empty"); // If this top menu handler must be used with a particular left menu handler var $type_user=0; // Put 0 for internal users, 1 for external users - var $atarget=""; // To store arget to use in menu links + var $atarget=""; // To store arget to use in menu links + + var $menu_array; + var $menu_array_after; - /** - * Constructor + /** + * Constructor * - * @param DoliDB $db Database handler - */ - function __construct($db) - { - $this->db=$db; - } + * @param DoliDB $db Database handler + * @param array &$menu_array Table of menu entries to show before entries of menu handler + * @param array &$menu_array_after Table of menu entries to show after entries of menu handler + */ + function __construct($db, &$menu_array, &$menu_array_after) + { + $this->db=$db; + $this->menu_array=$menu_array; + $this->menu_array_after=$menu_array_after; + } - /** - * Show menu - * - * @return void - */ - function showmenu() - { - global $user,$conf,$langs,$dolibarr_main_db_name; + /** + * Show menu + * + * @param string $mode 'top' or 'left' + * @return void + */ + function showmenu($mode) + { + global $user,$conf,$langs,$dolibarr_main_db_name; - print_start_menu_array_empty(); + if ($mode == 'top') + { + print_start_menu_array_empty(); - $idsel='home'; - $classname='class="tmenu"'; + $idsel='home'; + $classname='class="tmenu"'; - print_start_menu_entry_empty($idsel); - print 'atarget?' target="'.$this->atarget.'"':'').'>'; - print ''; - print ''; - print 'atarget?' target="'.$this->atarget.'"':'').'>'; - print_text_menu_entry_empty($langs->trans("Home")); - print ''; - print_end_menu_entry_empty(); + print_start_menu_entry_empty($idsel); + print 'atarget?' target="'.$this->atarget.'"':'').'>'; + print ''; + print ''; + print 'atarget?' target="'.$this->atarget.'"':'').'>'; + print_text_menu_entry_empty($langs->trans("Home")); + print ''; + print_end_menu_entry_empty(); - print_end_menu_array_empty(); - } + print_end_menu_array_empty(); + } + if ($mode == 'left') + { + $newmenu = new Menu(); + + // Put here left menu entries + // ***** START ***** + + $langs->load("admin"); // Load translation file admin.lang + $newmenu->add("/admin/index.php?leftmenu=setup", $langs->trans("Setup"),0); + $newmenu->add("/admin/company.php", $langs->trans("MenuCompanySetup"),1); + $newmenu->add("/admin/modules.php", $langs->trans("Modules"),1); + $newmenu->add("/admin/menus.php", $langs->trans("Menus"),1); + $newmenu->add("/admin/ihm.php", $langs->trans("GUISetup"),1); + $newmenu->add("/admin/boxes.php", $langs->trans("Boxes"),1); + $newmenu->add("/admin/delais.php",$langs->trans("Alerts"),1); + $newmenu->add("/admin/proxy.php?mainmenu=home", $langs->trans("Security"),1); + $newmenu->add("/admin/limits.php?mainmenu=home", $langs->trans("MenuLimits"),1); + $newmenu->add("/admin/pdf.php?mainmenu=home", $langs->trans("PDF"),1); + $newmenu->add("/admin/mails.php?mainmenu=home", $langs->trans("Emails"),1); + $newmenu->add("/admin/sms.php?mainmenu=home", $langs->trans("SMS"),1); + $newmenu->add("/admin/dict.php?mainmenu=home", $langs->trans("DictionnarySetup"),1); + $newmenu->add("/admin/const.php?mainmenu=home", $langs->trans("OtherSetup"),1); + + // ***** END ***** + + // do not change code after this + + // override menu_array by value array in $newmenu + $this->menu_array=$newmenu->liste; + + $alt=0; + $num=count($this->menu_array); + for ($i = 0; $i < $num; $i++) + { + $alt++; + if (empty($this->menu_array[$i]['level'])) + { + if (($alt%2==0)) + { + print '
'."\n"; + } + else + { + print '
'."\n"; + } + } + + // Place tabulation + $tabstring=''; + $tabul=($this->menu_array[$i]['level'] - 1); + if ($tabul > 0) + { + for ($j=0; $j < $tabul; $j++) + { + $tabstring.='   '; + } + } + + if ($this->menu_array[$i]['level'] == 0) { + if ($this->menu_array[$i]['enabled']) + { + print ''."\n"; + } + else + { + print ''."\n"; + } + print ''."\n"; + } + + if ($this->menu_array[$i]['level'] > 0) { + print ''."\n"; + } + + // If next is a new block or end + if (empty($this->menu_array[$i+1]['level'])) + { + print ''."\n"; + print "
\n"; + } + } + } + } } + /** * Output menu entry * @@ -136,127 +236,4 @@ function print_end_menu_array_empty() print "\n"; } - - -/** - * Class for left empty menu - */ -class MenuLeft -{ - var $db; - var $menu_array; - var $menu_array_after; - - - /** - * Constructor - * - * @param DoliDB $db Database handler - * @param array &$menu_array Table of menu entries to show before entries of menu handler - * @param array &$menu_array_after Table of menu entries to show after entries of menu handler - */ - function __construct($db,&$menu_array,&$menu_array_after) - { - $this->db=$db; - $this->menu_array=$menu_array; - $this->menu_array_after=$menu_array_after; - } - - - /** - * Show menu - * - * @return void - */ - function showmenu() - { - global $user,$conf,$langs,$dolibarr_main_db_name; - $newmenu = new Menu(); - - // Put here left menu entries - // ***** START ***** - - $langs->load("admin"); // Load translation file admin.lang - $newmenu->add("/admin/index.php?leftmenu=setup", $langs->trans("Setup"),0); - $newmenu->add("/admin/company.php", $langs->trans("MenuCompanySetup"),1); - $newmenu->add("/admin/modules.php", $langs->trans("Modules"),1); - $newmenu->add("/admin/menus.php", $langs->trans("Menus"),1); - $newmenu->add("/admin/ihm.php", $langs->trans("GUISetup"),1); - $newmenu->add("/admin/boxes.php", $langs->trans("Boxes"),1); - $newmenu->add("/admin/delais.php",$langs->trans("Alerts"),1); - $newmenu->add("/admin/perms.php", $langs->trans("Security"),1); - $newmenu->add("/admin/mails.php", $langs->trans("EMails"),1); - $newmenu->add("/admin/limits.php", $langs->trans("Limits"),1); - $newmenu->add("/admin/dict.php", $langs->trans("DictionnarySetup"),1); - $newmenu->add("/admin/const.php", $langs->trans("OtherSetup"),1); - - // ***** END ***** - - // do not change code after this - - // override menu_array by value array in $newmenu - $this->menu_array=$newmenu->liste; - - $alt=0; - $num=count($this->menu_array); - for ($i = 0; $i < $num; $i++) - { - $alt++; - if (empty($this->menu_array[$i]['level'])) - { - if (($alt%2==0)) - { - print '
'."\n"; - } - else - { - print '
'."\n"; - } - } - - // Place tabulation - $tabstring=''; - $tabul=($this->menu_array[$i]['level'] - 1); - if ($tabul > 0) - { - for ($j=0; $j < $tabul; $j++) - { - $tabstring.='   '; - } - } - - if ($this->menu_array[$i]['level'] == 0) { - if ($this->menu_array[$i]['enabled']) - { - print ''."\n"; - } - else - { - print ''."\n"; - } - print ''."\n"; - } - - if ($this->menu_array[$i]['level'] > 0) { - print ''."\n"; - } - - // If next is a new block or end - if (empty($this->menu_array[$i+1]['level'])) - { - print ''."\n"; - print "
\n"; - } - } - } - -} - ?> \ No newline at end of file diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 97d5d78f467..6ce1cb50971 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -1271,13 +1271,13 @@ function top_menu($head, $title='', $target='', $disablejs=0, $disablehead=0, $a if (GETPOST('menu')) $top_menu=GETPOST('menu'); // menu=eldy_backoffice.php // Load the top menu manager (only if not already done) - if (! class_exists('MenuTop')) + if (! class_exists('MenuManager')) { $menufound=0; $dirmenus=array_merge(array("/core/menus/"),(array) $conf->modules_parts['menus']); foreach($dirmenus as $dirmenu) { - $menufound=dol_include_once($dirmenu."standard/".$top_menu); + $menufound=dol_include_once($dirmenu."standard/".$top_menu); if ($menufound) break; } if (! $menufound) // If failed to include, we try with standard @@ -1296,9 +1296,10 @@ function top_menu($head, $title='', $target='', $disablejs=0, $disablehead=0, $a print '
'."\n"; // Show menu - $menutop = new MenuTop($db); + $dummy1=array();$dummy2=array(); + $menutop = new MenuManager($db,$dummy1,$dummy2); $menutop->atarget=$target; - $menutop->showmenu(); // This contains a \n + $menutop->showmenu('top'); // This contains a \n print "
\n"; @@ -1483,8 +1484,8 @@ function left_menu($menu_array_before, $helppagename='', $moresearchform='', $me $left_menu=empty($conf->browser->phone)?$conf->top_menu:$conf->smart_menu; if (GETPOST('menu')) $left_menu=GETPOST('menu'); // menu=eldy_backoffice.php - // Load the top menu manager (only if not already done) - if (! class_exists('MenuLeft')) + // Load the menu manager (only if not already done) + if (! class_exists('MenuManager')) { $menufound=0; $dirmenus=array_merge(array("/core/menus/"),(array) $conf->modules_parts['menus']); @@ -1505,8 +1506,8 @@ function left_menu($menu_array_before, $helppagename='', $moresearchform='', $me print '
'."\n"; - $menuleft=new MenuLeft($db,$menu_array_before,$menu_array_after); - $menuleft->showmenu(); // output menu_array and menu found in database + $menuleft=new MenuManager($db,$menu_array_before,$menu_array_after); + $menuleft->showmenu('left'); // output menu_array and menu found in database // Show other forms From e28fefc989b3ddd62279b2ffca79ec0b0102178f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 15 Jan 2013 15:43:37 +0100 Subject: [PATCH 23/28] Fix: Missinf class --- htdocs/user/fiche.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/user/fiche.php b/htdocs/user/fiche.php index 787595e49e8..c603020fd3a 100644 --- a/htdocs/user/fiche.php +++ b/htdocs/user/fiche.php @@ -777,7 +777,7 @@ if (($action == 'create') || ($action == 'adduserldap')) $password=$generated_password; // Mot de passe - print '
'.$langs->trans("Password").'
'.$langs->trans("Password").''; if (! empty($ldap_sid)) { From db923b9814df171c2e46354787cfa73fbb3a7b63 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 15 Jan 2013 15:44:42 +0100 Subject: [PATCH 24/28] Fix: Removed warning --- htdocs/filefunc.inc.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/filefunc.inc.php b/htdocs/filefunc.inc.php index 739a2372430..5cc2435f37e 100755 --- a/htdocs/filefunc.inc.php +++ b/htdocs/filefunc.inc.php @@ -92,9 +92,9 @@ if (! empty($dolibarr_main_prod)) ini_set('display_errors','Off'); // Clean parameters $dolibarr_main_data_root=trim($dolibarr_main_data_root); $dolibarr_main_url_root=trim($dolibarr_main_url_root); -$dolibarr_main_url_root_alt=trim($dolibarr_main_url_root_alt); +$dolibarr_main_url_root_alt=(empty($dolibarr_main_url_root_alt)?'':trim($dolibarr_main_url_root_alt)); $dolibarr_main_document_root=trim($dolibarr_main_document_root); -$dolibarr_main_document_root_alt=trim($dolibarr_main_document_root_alt); +$dolibarr_main_document_root_alt=(empty($dolibarr_main_document_root_alt)?'':trim($dolibarr_main_document_root_alt)); if (empty($dolibarr_main_db_port)) $dolibarr_main_db_port=0; // Pour compatibilite avec anciennes configs, si non defini, on prend 'mysql' if (empty($dolibarr_main_db_type)) $dolibarr_main_db_type='mysql'; // Pour compatibilite avec anciennes configs, si non defini, on prend 'mysql' From 6a51db82e9b9d54bb88060051c79ed718065bdbb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 15 Jan 2013 15:53:35 +0100 Subject: [PATCH 25/28] Qual: We can enable box by default because a warning is output to user. --- htdocs/admin/boxes.php | 11 +++++++++-- htdocs/core/boxes/box_activity.php | 3 +-- htdocs/core/modules/modSociete.class.php | 1 + htdocs/langs/en_US/errors.lang | 3 ++- htdocs/langs/fr_FR/errors.lang | 3 ++- 5 files changed, 15 insertions(+), 6 deletions(-) diff --git a/htdocs/admin/boxes.php b/htdocs/admin/boxes.php index 7e092c56abd..262cd4c29d4 100644 --- a/htdocs/admin/boxes.php +++ b/htdocs/admin/boxes.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2012 Laurent Destailleur + * Copyright (C) 2004-2013 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * * This program is free software; you can redistribute it and/or modify @@ -397,7 +397,14 @@ foreach($boxactivated as $key => $box) print "\n".''."\n"; print '
'.img_object("",$logo).' '.$box->boxlabel.'' . ($box->note?$box->note:' ') . ''; + if ($box->note == '(WarningUsingThisBoxSlowDown)') + { + $langs->load("errors"); + print img_warning('',0).' '.$langs->trans("WarningUsingThisBoxSlowDown"); + } + else print ($box->note?$box->note:' '); + print '' . (isset($pos_name[$box->position])?$pos_name[$box->position]:'') . '
'.img_object("",$logo).' '.$box->boxlabel.'' . ($box->note?$box->note:' ') . ''; + if ($box->note == '(WarningUsingThisBoxSlowDown)') + { + $langs->load("errors"); + print $langs->trans("WarningUsingThisBoxSlowDown"); + } + else print ($box->note?$box->note:' '); + print '' . $box->sourcefile . '
'.img_object("",$logo).' '.$box->boxlabel.''.img_object("",$logo).' '.$langs->transnoentitiesnoconv($box->boxlabel).''; if ($box->note == '(WarningUsingThisBoxSlowDown)') { @@ -403,7 +404,7 @@ foreach($boxactivated as $key => $box) print "\n".''."\n"; print '
'.img_object("",$logo).' '.$box->boxlabel.''.img_object("",$logo).' '.$langs->transnoentitiesnoconv($box->boxlabel).''; if ($box->note == '(WarningUsingThisBoxSlowDown)') { diff --git a/htdocs/core/boxes/box_actions.php b/htdocs/core/boxes/box_actions.php index 1a0709a6962..0a1cc56212c 100644 --- a/htdocs/core/boxes/box_actions.php +++ b/htdocs/core/boxes/box_actions.php @@ -32,7 +32,7 @@ class box_actions extends ModeleBoxes { var $boxcode="lastactions"; var $boximg="object_action"; - var $boxlabel; + var $boxlabel="BoxLastActions"; var $depends = array("agenda"); var $db; @@ -42,17 +42,6 @@ class box_actions extends ModeleBoxes var $info_box_contents = array(); - /** - * Constructor - */ - function __construct() - { - global $langs; - $langs->load("boxes"); - - $this->boxlabel=$langs->transnoentitiesnoconv("BoxLastActions"); - } - /** * Load data for box to show them later * diff --git a/htdocs/core/boxes/box_activity.php b/htdocs/core/boxes/box_activity.php index 834799878d2..41c3f2b9caa 100644 --- a/htdocs/core/boxes/box_activity.php +++ b/htdocs/core/boxes/box_activity.php @@ -31,7 +31,7 @@ class box_activity extends ModeleBoxes { var $boxcode="activity"; var $boximg="object_bill"; - var $boxlabel; + var $boxlabel='BoxGlobalActivity'; var $depends = array("facture"); var $db; @@ -44,17 +44,10 @@ class box_activity extends ModeleBoxes /** * Constructor */ - function __construct() + function __construct($db) { - global $langs,$conf; - - $langs->load("boxes"); - $langs->load("bills"); - $langs->load("projects"); - $langs->load("orders"); - - $this->boxlabel = $langs->transnoentitiesnoconv("BoxGlobalActivity"); - + $this->db = $db; + $this->enabled = 1; // FIXME: Use a cache to save data because this slow down too much main home page. This box slow down too seriously software. // FIXME: Removed number_format (not compatible with all languages) diff --git a/htdocs/core/boxes/box_bookmarks.php b/htdocs/core/boxes/box_bookmarks.php index a341b9d5b76..130bc8661c2 100644 --- a/htdocs/core/boxes/box_bookmarks.php +++ b/htdocs/core/boxes/box_bookmarks.php @@ -29,7 +29,7 @@ class box_bookmarks extends ModeleBoxes { var $boxcode="bookmarks"; var $boximg="object_bookmark"; - var $boxlabel; + var $boxlabel="BoxMyLastBookmarks"; var $depends = array("bookmark"); var $db; @@ -38,16 +38,6 @@ class box_bookmarks extends ModeleBoxes var $info_box_head = array(); var $info_box_contents = array(); - /** - * Constructor - */ - function __construct() - { - global $langs; - $langs->load("boxes"); - - $this->boxlabel=$langs->transnoentitiesnoconv("BoxMyLastBookmarks"); - } /** * Load data for box to show them later diff --git a/htdocs/core/boxes/box_clients.php b/htdocs/core/boxes/box_clients.php index e30523660f3..53ca9f9f8c5 100644 --- a/htdocs/core/boxes/box_clients.php +++ b/htdocs/core/boxes/box_clients.php @@ -33,7 +33,7 @@ class box_clients extends ModeleBoxes { var $boxcode="lastcustomers"; var $boximg="object_company"; - var $boxlabel; + var $boxlabel="BoxLastCustomers"; var $depends = array("societe"); var $db; @@ -42,16 +42,6 @@ class box_clients extends ModeleBoxes var $info_box_head = array(); var $info_box_contents = array(); - /** - * Constructor - */ - function __construct() - { - global $langs; - $langs->load("boxes"); - - $this->boxlabel=$langs->transnoentitiesnoconv("BoxLastCustomers"); - } /** * Load data for box to show them later diff --git a/htdocs/core/boxes/box_commandes.php b/htdocs/core/boxes/box_commandes.php index b0449bdb6b0..c180a8250fa 100644 --- a/htdocs/core/boxes/box_commandes.php +++ b/htdocs/core/boxes/box_commandes.php @@ -33,7 +33,7 @@ class box_commandes extends ModeleBoxes { var $boxcode="lastcustomerorders"; var $boximg="object_order"; - var $boxlabel; + var $boxlabel="BoxLastCustomerOrders"; var $depends = array("commande"); var $db; @@ -42,16 +42,6 @@ class box_commandes extends ModeleBoxes var $info_box_head = array(); var $info_box_contents = array(); - /** - * Constructor - */ - function __construct() - { - global $langs; - $langs->load("boxes"); - - $this->boxlabel=$langs->transnoentitiesnoconv("BoxLastCustomerOrders"); - } /** * Load data for box to show them later diff --git a/htdocs/core/boxes/box_comptes.php b/htdocs/core/boxes/box_comptes.php index f2d96ad1e51..fd3876872a8 100644 --- a/htdocs/core/boxes/box_comptes.php +++ b/htdocs/core/boxes/box_comptes.php @@ -33,7 +33,7 @@ class box_comptes extends ModeleBoxes { var $boxcode="currentaccounts"; var $boximg="object_bill"; - var $boxlabel; + var $boxlabel="BoxCurrentAccounts"; var $depends = array("banque"); // Box active if module banque active var $db; @@ -47,12 +47,11 @@ class box_comptes extends ModeleBoxes /** * Constructor */ - function __construct() + function __construct($db) { - global $conf, $langs, $user; - $langs->load("boxes"); - - $this->boxlabel=$langs->transnoentitiesnoconv('BoxCurrentAccounts'); + global $conf, $user; + + $this->db = $db; // disable module for such cases $listofmodulesforexternal=explode(',',$conf->global->MAIN_MODULES_FOR_EXTERNAL); diff --git a/htdocs/core/boxes/box_contacts.php b/htdocs/core/boxes/box_contacts.php index 4d237051672..cee28d7211a 100755 --- a/htdocs/core/boxes/box_contacts.php +++ b/htdocs/core/boxes/box_contacts.php @@ -34,7 +34,7 @@ class box_contacts extends ModeleBoxes { var $boxcode="lastcontacts"; var $boximg="object_contact"; - var $boxlabel; + var $boxlabel="BoxLastContacts"; var $depends = array("societe"); var $db; @@ -43,16 +43,6 @@ class box_contacts extends ModeleBoxes var $info_box_head = array(); var $info_box_contents = array(); - /** - * Constructor - */ - function __construct() - { - global $langs; - $langs->load("boxes"); - - $this->boxlabel=$langs->transnoentitiesnoconv("BoxLastContacts"); - } /** * Load data into info_box_contents array to show array later. diff --git a/htdocs/core/boxes/box_contracts.php b/htdocs/core/boxes/box_contracts.php index ec8f158dcc6..6eeb34ea17f 100644 --- a/htdocs/core/boxes/box_contracts.php +++ b/htdocs/core/boxes/box_contracts.php @@ -31,7 +31,7 @@ class box_contracts extends ModeleBoxes { var $boxcode="lastcontracts"; var $boximg="object_contract"; - var $boxlabel; + var $boxlabel="BoxLastContracts"; var $depends = array("contrat"); // conf->contrat->enabled var $db; @@ -41,18 +41,6 @@ class box_contracts extends ModeleBoxes var $info_box_contents = array(); - /** - * Constructor - */ - function __construct() - { - global $langs; - - $langs->load("boxes"); - - $this->boxlabel=$langs->transnoentitiesnoconv("BoxLastContracts"); - } - /** * Load data for box to show them later * diff --git a/htdocs/core/boxes/box_external_rss.php b/htdocs/core/boxes/box_external_rss.php index cf10d6e1c5d..cc108d21206 100644 --- a/htdocs/core/boxes/box_external_rss.php +++ b/htdocs/core/boxes/box_external_rss.php @@ -35,7 +35,7 @@ class box_external_rss extends ModeleBoxes { var $boxcode="lastrssinfos"; var $boximg="object_rss"; - var $boxlabel; + var $boxlabel="BoxLastRssInfos"; var $depends = array("externalrss"); var $db; @@ -52,13 +52,8 @@ class box_external_rss extends ModeleBoxes */ function __construct($db,$param) { - global $langs; - $langs->load("boxes"); - $this->db=$db; $this->param=$param; - - $this->boxlabel=$langs->transnoentitiesnoconv("BoxLastRssInfos"); } /** diff --git a/htdocs/core/boxes/box_factures.php b/htdocs/core/boxes/box_factures.php index 729d62ec571..e75f9137b11 100644 --- a/htdocs/core/boxes/box_factures.php +++ b/htdocs/core/boxes/box_factures.php @@ -32,7 +32,7 @@ class box_factures extends ModeleBoxes { var $boxcode="lastcustomerbills"; var $boximg="object_bill"; - var $boxlabel; + var $boxlabel="BoxLastCustomerBills"; var $depends = array("facture"); var $db; @@ -41,16 +41,6 @@ class box_factures extends ModeleBoxes var $info_box_head = array(); var $info_box_contents = array(); - /** - * Constructor - */ - function __construct() - { - global $langs; - $langs->load("boxes"); - - $this->boxlabel=$langs->transnoentitiesnoconv("BoxLastCustomerBills"); - } /** * Load data into info_box_contents array to show array later. diff --git a/htdocs/core/boxes/box_factures_fourn.php b/htdocs/core/boxes/box_factures_fourn.php index 7d8d6e6add9..3e1298dc957 100644 --- a/htdocs/core/boxes/box_factures_fourn.php +++ b/htdocs/core/boxes/box_factures_fourn.php @@ -32,7 +32,7 @@ class box_factures_fourn extends ModeleBoxes { var $boxcode="lastsupplierbills"; var $boximg="object_bill"; - var $boxlabel; + var $boxlabel="BoxLastSupplierBills"; var $depends = array("facture","fournisseur"); var $db; @@ -41,16 +41,6 @@ class box_factures_fourn extends ModeleBoxes var $info_box_head = array(); var $info_box_contents = array(); - /** - * Constructor - */ - function __construct() - { - global $langs; - $langs->load("boxes"); - - $this->boxlabel=$langs->transnoentitiesnoconv("BoxLastSupplierBills"); - } /** * Load data into info_box_contents array to show array later. diff --git a/htdocs/core/boxes/box_factures_fourn_imp.php b/htdocs/core/boxes/box_factures_fourn_imp.php index cb6ffba0d3e..6ab1aa5b74a 100644 --- a/htdocs/core/boxes/box_factures_fourn_imp.php +++ b/htdocs/core/boxes/box_factures_fourn_imp.php @@ -31,7 +31,7 @@ class box_factures_fourn_imp extends ModeleBoxes { var $boxcode="oldestunpaidsupplierbills"; var $boximg="object_bill"; - var $boxlabel; + var $boxlabel="BoxOldestUnpaidSupplierBills"; var $depends = array("facture","fournisseur"); var $db; @@ -41,17 +41,6 @@ class box_factures_fourn_imp extends ModeleBoxes var $info_box_contents = array(); - /** - * Constructor - */ - function __construct() - { - global $langs; - $langs->load("boxes"); - - $this->boxlabel=$langs->transnoentitiesnoconv("BoxOldestUnpaidSupplierBills"); - } - /** * Load data into info_box_contents array to show array later. * diff --git a/htdocs/core/boxes/box_factures_imp.php b/htdocs/core/boxes/box_factures_imp.php index 52033df850a..d909936d71a 100644 --- a/htdocs/core/boxes/box_factures_imp.php +++ b/htdocs/core/boxes/box_factures_imp.php @@ -34,7 +34,7 @@ class box_factures_imp extends ModeleBoxes { var $boxcode="oldestunpaidcustomerbills"; var $boximg="object_bill"; - var $boxlabel; + var $boxlabel="BoxOldestUnpaidCustomerBills"; var $depends = array("facture"); var $db; @@ -44,17 +44,6 @@ class box_factures_imp extends ModeleBoxes var $info_box_contents = array(); - /** - * Constructor - */ - function __construct() - { - global $langs; - $langs->load("boxes"); - - $this->boxlabel=$langs->transnoentitiesnoconv("BoxOldestUnpaidCustomerBills"); - } - /** * Load data into info_box_contents array to show array later. * diff --git a/htdocs/core/boxes/box_fournisseurs.php b/htdocs/core/boxes/box_fournisseurs.php index e54a0b5c214..3e12e08cfb0 100644 --- a/htdocs/core/boxes/box_fournisseurs.php +++ b/htdocs/core/boxes/box_fournisseurs.php @@ -32,7 +32,7 @@ class box_fournisseurs extends ModeleBoxes { var $boxcode="lastsuppliers"; var $boximg="object_company"; - var $boxlabel; + var $boxlabel="BoxLastSuppliers"; var $depends = array("fournisseur"); var $db; @@ -41,16 +41,6 @@ class box_fournisseurs extends ModeleBoxes var $info_box_head = array(); var $info_box_contents = array(); - /** - * Constructor - */ - function __construct() - { - global $langs; - $langs->load("boxes"); - - $this->boxlabel=$langs->transnoentitiesnoconv("BoxLastSuppliers"); - } /** * Load data into info_box_contents array to show array later. diff --git a/htdocs/core/boxes/box_members.php b/htdocs/core/boxes/box_members.php index 5c9e3a6f3ab..4495cd3cbb6 100755 --- a/htdocs/core/boxes/box_members.php +++ b/htdocs/core/boxes/box_members.php @@ -33,7 +33,7 @@ class box_members extends ModeleBoxes { var $boxcode="lastmembers"; var $boximg="object_user"; - var $boxlabel; + var $boxlabel="BoxLastMembers"; var $depends = array("adherent"); var $db; @@ -47,12 +47,11 @@ class box_members extends ModeleBoxes /** * Constructor */ - function __construct() + function __construct($db) { - global $conf, $langs, $user; - $langs->load("boxes"); + global $conf, $user; - $this->boxlabel=$langs->transnoentitiesnoconv("BoxLastMembers"); + $this->db = $db; // disable module for such cases $listofmodulesforexternal=explode(',',$conf->global->MAIN_MODULES_FOR_EXTERNAL); diff --git a/htdocs/core/boxes/box_osc_client.php b/htdocs/core/boxes/box_osc_client.php index aaaf232dfe9..b0eda584d22 100644 --- a/htdocs/core/boxes/box_osc_client.php +++ b/htdocs/core/boxes/box_osc_client.php @@ -32,7 +32,7 @@ class box_osc_clients extends ModeleBoxes { var $boxcode="nbofcustomers"; var $boximg="object_company"; - var $boxlabel; + var $boxlabel="BoxNbOfCustomers"; var $depends = array("boutique"); var $db; @@ -41,16 +41,6 @@ class box_osc_clients extends ModeleBoxes var $info_box_head = array(); var $info_box_contents = array(); - /** - * Constructor - */ - function __construct() - { - global $langs; - $langs->load("boxes"); - - $this->boxlabel=$langs->transnoentitiesnoconv("BoxNbOfCustomers"); - } /** * Load data into info_box_contents array to show array later. diff --git a/htdocs/core/boxes/box_produits.php b/htdocs/core/boxes/box_produits.php index dedca118098..fc4029e686b 100644 --- a/htdocs/core/boxes/box_produits.php +++ b/htdocs/core/boxes/box_produits.php @@ -34,7 +34,7 @@ class box_produits extends ModeleBoxes { var $boxcode="lastproducts"; var $boximg="object_product"; - var $boxlabel; + var $boxlabel="BoxLastProducts"; var $depends = array("produit"); var $db; @@ -44,17 +44,6 @@ class box_produits extends ModeleBoxes var $info_box_contents = array(); - /** - * Constructor - */ - function __construct() - { - global $langs; - $langs->load("boxes"); - - $this->boxlabel=$langs->transnoentitiesnoconv("BoxLastProducts"); - } - /** * Load data into info_box_contents array to show array later. * diff --git a/htdocs/core/boxes/box_produits_alerte_stock.php b/htdocs/core/boxes/box_produits_alerte_stock.php index fe8e86b4df9..48b47d28c57 100644 --- a/htdocs/core/boxes/box_produits_alerte_stock.php +++ b/htdocs/core/boxes/box_produits_alerte_stock.php @@ -35,7 +35,7 @@ class box_produits_alerte_stock extends ModeleBoxes { var $boxcode="productsalertstock"; var $boximg="object_product"; - var $boxlabel; + var $boxlabel="BoxProductsAlertStock"; var $depends = array("produit"); var $db; @@ -45,17 +45,6 @@ class box_produits_alerte_stock extends ModeleBoxes var $info_box_contents = array(); - /** - * Constructor - */ - function __construct() - { - global $langs; - $langs->load("boxes"); - - $this->boxlabel=$langs->transnoentitiesnoconv("BoxProductsAlertStock"); - } - /** * Load data into info_box_contents array to show array later. * diff --git a/htdocs/core/boxes/box_propales.php b/htdocs/core/boxes/box_propales.php index 47b9d6ff71a..752e46625c8 100644 --- a/htdocs/core/boxes/box_propales.php +++ b/htdocs/core/boxes/box_propales.php @@ -33,7 +33,7 @@ class box_propales extends ModeleBoxes { var $boxcode="lastpropals"; var $boximg="object_propal"; - var $boxlabel; + var $boxlabel="BoxLastProposals"; var $depends = array("propal"); // conf->propal->enabled var $db; @@ -43,17 +43,6 @@ class box_propales extends ModeleBoxes var $info_box_contents = array(); - /** - * Constructor - */ - function __construct() - { - global $langs; - $langs->load("boxes"); - - $this->boxlabel=$langs->transnoentitiesnoconv("BoxLastProposals"); - } - /** * Load data into info_box_contents array to show array later. * diff --git a/htdocs/core/boxes/box_prospect.php b/htdocs/core/boxes/box_prospect.php index 3b5356a7285..13a994c26dc 100644 --- a/htdocs/core/boxes/box_prospect.php +++ b/htdocs/core/boxes/box_prospect.php @@ -35,7 +35,7 @@ class box_prospect extends ModeleBoxes { var $boxcode="lastprospects"; var $boximg="object_company"; - var $boxlabel; + var $boxlabel="BoxLastProspects"; var $depends = array("societe"); var $db; @@ -44,21 +44,6 @@ class box_prospect extends ModeleBoxes var $info_box_contents = array(); - /** - * Constructor - * - * @param DoliDB $db Database handler - */ - function __construct($db) - { - global $langs; - $langs->load("boxes"); - - $this->db=$db; - - $this->boxlabel=$langs->transnoentitiesnoconv("BoxLastProspects"); - } - /** * Load data into info_box_contents array to show array later. * diff --git a/htdocs/core/boxes/box_services_contracts.php b/htdocs/core/boxes/box_services_contracts.php index 81b8516bb09..94cf3e5f36b 100644 --- a/htdocs/core/boxes/box_services_contracts.php +++ b/htdocs/core/boxes/box_services_contracts.php @@ -33,7 +33,7 @@ class box_services_contracts extends ModeleBoxes { var $boxcode="lastproductsincontract"; var $boximg="object_product"; - var $boxlabel; + var $boxlabel="BoxLastProductsInContract"; var $depends = array("service","contrat"); var $db; @@ -42,17 +42,7 @@ class box_services_contracts extends ModeleBoxes var $info_box_head = array(); var $info_box_contents = array(); - /** - * Constructor - */ - function __construct() - { - global $langs; - $langs->load("boxes"); - - $this->boxlabel=$langs->transnoentitiesnoconv("BoxLastProductsInContract"); - } - + /** * Load data into info_box_contents array to show array later. * diff --git a/htdocs/core/boxes/box_services_expired.php b/htdocs/core/boxes/box_services_expired.php index 80c3a63c259..e6c6bb7f996 100644 --- a/htdocs/core/boxes/box_services_expired.php +++ b/htdocs/core/boxes/box_services_expired.php @@ -32,7 +32,7 @@ class box_services_expired extends ModeleBoxes var $boxcode="expiredservices"; // id of box var $boximg="object_contract"; - var $boxlabel; + var $boxlabel="BoxOldestExpiredServices"; var $depends = array("contrat"); // conf->propal->enabled var $db; @@ -42,18 +42,6 @@ class box_services_expired extends ModeleBoxes var $info_box_contents = array(); - /** - * Constructor - */ - function __construct() - { - global $langs; - - $langs->load("contracts"); - - $this->boxlabel=$langs->transnoentitiesnoconv("BoxOldestExpiredServices"); - } - /** * Load data for box to show them later * diff --git a/htdocs/core/boxes/box_supplier_orders.php b/htdocs/core/boxes/box_supplier_orders.php index ec7728de32f..c1f68c2ccf1 100644 --- a/htdocs/core/boxes/box_supplier_orders.php +++ b/htdocs/core/boxes/box_supplier_orders.php @@ -33,23 +33,14 @@ class box_supplier_orders extends ModeleBoxes var $boxcode = "latestsupplierorders"; var $boximg = "object_order"; - var $boxlabel; + var $boxlabel="BoxLatestSupplierOrders"; var $depends = array("fournisseur"); + var $db; var $param; var $info_box_head = array(); var $info_box_contents = array(); - /** - * Constructor - */ - function __construct() - { - global $langs; - $langs->load("boxes"); - - $this->boxlabel = $langs->transnoentitiesnoconv("BoxLatestSupplierOrders"); - } /** * Load data into info_box_contents array to show array later. diff --git a/htdocs/core/boxes/modules_boxes.php b/htdocs/core/boxes/modules_boxes.php index 0c6bf08830d..f9a76860f2a 100644 --- a/htdocs/core/boxes/modules_boxes.php +++ b/htdocs/core/boxes/modules_boxes.php @@ -47,7 +47,7 @@ class ModeleBoxes // Can't be abtract as it is instanciated to build "empty" /** * Constructor * - * @param DoliDB $db Database hanlder + * @param DoliDB $db Database handler */ function __construct($db) { diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php index 2a409374f2c..8a2252d7596 100644 --- a/htdocs/core/class/html.formother.class.php +++ b/htdocs/core/class/html.formother.class.php @@ -822,10 +822,11 @@ class FormOther $arrayboxtoactivatelabel=array(); if (! empty($user->conf->$confuserzone)) { + $langs->load("boxes"); foreach($boxactivated as $box) { if (! empty($boxidactivatedforuser[$box->id])) continue; // Already visible for user - $arrayboxtoactivatelabel[$box->id]=$box->boxlabel; // We keep only boxes not shown for user, to show into combo list + $arrayboxtoactivatelabel[$box->id]=$langs->transnoentitiesnoconv($box->boxlabel); // We keep only boxes not shown for user, to show into combo list } $form=new Form($db); diff --git a/htdocs/core/class/translate.class.php b/htdocs/core/class/translate.class.php index 431e2f4461b..2b96fbbd639 100644 --- a/htdocs/core/class/translate.class.php +++ b/htdocs/core/class/translate.class.php @@ -169,7 +169,7 @@ class Translate } if ($this->defaultlang == 'none_NONE') return 0; // Special language code to not translate keys - //dol_syslog("Translate::Load Start domain=".$domain." alt=".$alt." forcelangdir=".$forcelangdir." this->defaultlang=".$this->defaultlang); + dol_syslog("Translate::Load Start domain=".$domain." alt=".$alt." forcelangdir=".$forcelangdir." this->defaultlang=".$this->defaultlang); $newdomain = $domain; $modulename = ''; diff --git a/htdocs/index.php b/htdocs/index.php index d9a1cab868f..0ee561d7127 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -569,6 +569,8 @@ if ($user->admin && empty($conf->global->MAIN_REMOVE_INSTALL_WARNING)) } } +//print 'mem='.memory_get_usage().' - '.memory_get_peak_usage(); + llxFooter(); $db->close(); From 1605e72adba33275a288346588289361c283c154 Mon Sep 17 00:00:00 2001 From: fhenry Date: Tue, 15 Jan 2013 21:43:11 +0100 Subject: [PATCH 28/28] Add update actioncomm webservice method Fix bug on update thridparty webservice method --- htdocs/webservices/server_actioncomm.php | 117 ++++++++++++++++++++++- htdocs/webservices/server_thirdparty.php | 11 +-- 2 files changed, 117 insertions(+), 11 deletions(-) diff --git a/htdocs/webservices/server_actioncomm.php b/htdocs/webservices/server_actioncomm.php index 7014c8d331f..c43aeedddd9 100644 --- a/htdocs/webservices/server_actioncomm.php +++ b/htdocs/webservices/server_actioncomm.php @@ -220,6 +220,20 @@ $server->register( 'WS to create a actioncomm' ); +// Register WSDL +$server->register( + 'updateActionComm', + // Entry values + array('authentication'=>'tns:authentication','actioncomm'=>'tns:actioncomm'), + // Exit values + array('result'=>'tns:result'), + $ns, + $ns.'#updateActionComm', + $styledoc, + $styleuse, + 'WS to update a actioncomm' +); + @@ -473,7 +487,104 @@ function createActionComm($authentication,$actioncomm) return $objectresp; } -// Return the results. -$server->service($HTTP_RAW_POST_DATA); +/** + * Create ActionComm + * + * @param array $authentication Array of authentication information + * @param ActionComm $actioncomm $actioncomm + * @return array Array result + */ +function updateActionComm($authentication,$actioncomm) +{ + global $db,$conf,$langs; -?> + $now=dol_now(); + + dol_syslog("Function: updateActionComm login=".$authentication['login']); + + if ($authentication['entity']) $conf->entity=$authentication['entity']; + + // Init and check authentication + $objectresp=array(); + $errorcode='';$errorlabel=''; + $error=0; + $fuser=check_authentication($authentication,$error,$errorcode,$errorlabel); + // Check parameters + if (empty($actioncomm['id'])) { + $error++; $errorcode='KO'; $errorlabel="Actioncomm id is mandatory."; + } + + if (! $error) + { + $objectfound=false; + + $object=new ActionComm($db); + $result=$object->fetch($actioncomm['id']); + + if (!empty($object->id)) { + + $objectfound=true; + + $object->datep=$actioncomm['datep']; + $object->datef=$actioncomm['datef']; + $object->type_code=$actioncomm['type_code']; + $object->societe->id=$actioncomm['socid']; + $object->fk_project=$actioncomm['projectid']; + $object->note=$actioncomm['note']; + $object->contact->id=$actioncomm['contactid']; + $object->usertodo->id=$actioncomm['usertodo']; + $object->userdone->id=$actioncomm['userdone']; + $object->label=$actioncomm['label']; + $object->percentage=$actioncomm['percentage']; + $object->priority=$actioncomm['priority']; + $object->fulldayevent=$actioncomm['fulldayevent']; + $object->location=$actioncomm['location']; + $object->fk_element=$actioncomm['fk_element']; + $object->elementtype=$actioncomm['elementtype']; + + //Retreive all extrafield for actioncomm + // fetch optionals attributes and labels + $extrafields=new ExtraFields($db); + $extralabels=$extrafields->fetch_name_optionals_label('actioncomm'); + foreach($extrafields->attribute_label as $key=>$label) + { + $key='options_'.$key; + $newobject->array_options[$key]=$actioncomm[$key]; + } + + $db->begin(); + + $result=$object->update($fuser); + if ($result <= 0) { + $error++; + } + } + + if ((! $error) && ($objectfound)) + { + $db->commit(); + $objectresp=array('result'=>array('result_code'=>'OK', 'result_label'=>'')); + } + elseif ($objectfound) + { + $db->rollback(); + $error++; + $errorcode='KO'; + $errorlabel=$object->error; + } else { + $error++; + $errorcode='NOT_FOUND'; + $errorlabel='Actioncomm id='.$actioncomm['id'].' cannot be found'; + } + } + + if ($error) + { + $objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel)); + } + + return $objectresp; +} + +// Return the results. +$server->service($HTTP_RAW_POST_DATA); \ No newline at end of file diff --git a/htdocs/webservices/server_thirdparty.php b/htdocs/webservices/server_thirdparty.php index 40c5bdefd6e..1e3ee7cedca 100755 --- a/htdocs/webservices/server_thirdparty.php +++ b/htdocs/webservices/server_thirdparty.php @@ -506,7 +506,6 @@ function updateThirdParty($authentication,$thirdparty) $error++; $errorcode='KO'; $errorlabel="Thirdparty id is mandatory."; } - if (! $error) { $objectfound=false; @@ -514,9 +513,9 @@ function updateThirdParty($authentication,$thirdparty) include_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; $object=new Societe($db); - $result=$object->fetch($id); + $result=$object->fetch($thirdparty['id']); - if (!empty($thirdparty['id'])) { + if (!empty($object->id)) { $objectfound=true; @@ -680,9 +679,5 @@ function getListOfThirdParties($authentication,$filterthirdparty) return $objectresp; } - - // Return the results. -$server->service($HTTP_RAW_POST_DATA); - -?> +$server->service($HTTP_RAW_POST_DATA); \ No newline at end of file