diff --git a/htdocs/admin/boxes.php b/htdocs/admin/boxes.php index b5fd35fe3ad..1522b0977ec 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 @@ -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(); @@ -211,8 +212,6 @@ if ($action == 'switch') */ $form=new Form($db); -$emptyuser=new User($db); -//$infobox=new InfoBox($db); llxHeader('',$langs->trans("Boxes")); @@ -316,7 +315,7 @@ if ($resql) // Available boxes -$boxtoadd=InfoBox::listBoxes($db,'available',-1,$emptyuser,$actives); +$boxtoadd=InfoBox::listBoxes($db,'available',-1,null,$actives); print "
\n"; print_titre($langs->trans("BoxesAvailable")); @@ -346,8 +345,15 @@ foreach($boxtoadd as $box) print '
'; print ''; print ''; - print ''.img_object("",$logo).' '.$box->boxlabel.''; - print '' . ($box->note?$box->note:' ') . ''; + print ''.img_object("",$logo).' '.$langs->transnoentitiesnoconv($box->boxlabel).''; + print ''; + if ($box->note == '(WarningUsingThisBoxSlowDown)') + { + $langs->load("errors"); + print $langs->trans("WarningUsingThisBoxSlowDown"); + } + else print ($box->note?$box->note:' '); + print ''; print '' . $box->sourcefile . ''; // Pour chaque position possible, on affiche un lien d'activation si boite non deja active pour cette position @@ -366,7 +372,7 @@ print ''; // Activated boxes -$boxactivated=InfoBox::listBoxes($db,'activated',-1,$emptyuser); +$boxactivated=InfoBox::listBoxes($db,'activated',-1,null); print "
\n\n"; print_titre($langs->trans("BoxesActivated")); @@ -398,8 +404,15 @@ foreach($boxactivated as $key => $box) print "\n".''."\n"; print ''; - print ''.img_object("",$logo).' '.$box->boxlabel.''; - print '' . ($box->note?$box->note:' ') . ''; + print ''.img_object("",$logo).' '.$langs->transnoentitiesnoconv($box->boxlabel).''; + print ''; + if ($box->note == '(WarningUsingThisBoxSlowDown)') + { + $langs->load("errors"); + print img_warning('',0).' '.$langs->trans("WarningUsingThisBoxSlowDown"); + } + else print ($box->note?$box->note:' '); + print ''; print '' . (isset($pos_name[$box->position])?$pos_name[$box->position]:'') . ''; $hasnext=($key < (count($boxactivated)-1)); $hasprevious=($key != 0); 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/syslog.php b/htdocs/admin/syslog.php index b0699f99aa5..941f1728c03 100644 --- a/htdocs/admin/syslog.php +++ b/htdocs/admin/syslog.php @@ -37,7 +37,7 @@ $action = GETPOST("action"); $syslogModules = array(); $activeModules = array(); -if (defined('SYSLOG_HANDLERS')) $activeModules = json_decode(SYSLOG_HANDLERS); +if (defined('SYSLOG_HANDLERS')) $activeModules = json_decode(constant('SYSLOG_HANDLERS')); $dir = dol_buildpath('/core/modules/syslog/'); 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(); 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 7839f4c30aa..41c3f2b9caa 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 @@ -29,28 +31,27 @@ class box_activity extends ModeleBoxes { var $boxcode="activity"; var $boximg="object_bill"; - var $boxlabel; + var $boxlabel='BoxGlobalActivity'; var $depends = array("facture"); - + var $db; var $param; - + var $enabled = 1; + var $info_box_head = array(); var $info_box_contents = array(); /** * Constructor */ - function __construct() + function __construct($db) { - global $langs; - - $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) + // FIXME: Pb into some status } /** @@ -66,13 +67,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 +75,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 +92,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 +105,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 +121,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 +149,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 +161,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 +174,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 +201,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 +214,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 +225,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.= ")"; 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 2d87db14a50..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 @@ -83,8 +73,8 @@ class box_clients extends ModeleBoxes $sql.= " ORDER BY s.tms DESC"; $sql.= $db->plimit($max, 0); + dol_syslog(get_class($this)."::loadBox sql=".$sql,LOG_DEBUG); $result = $db->query($sql); - if ($result) { $num = $db->num_rows($result); 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 64389354605..fd3876872a8 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 @@ -33,25 +33,29 @@ 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; var $param; - + var $enabled = 1; + var $info_box_head = array(); var $info_box_contents = array(); - + /** * Constructor */ - function __construct() + function __construct($db) { - global $langs; - $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); + if (! in_array('banque',$listofmodulesforexternal) && ! empty($user->societe_id)) $this->enabled=0; // disabled for external users } /** diff --git a/htdocs/core/boxes/box_contacts.php b/htdocs/core/boxes/box_contacts.php index 47741be9ec0..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. @@ -78,12 +68,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); 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 89bce42088e..4495cd3cbb6 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'; @@ -33,24 +33,29 @@ class box_members extends ModeleBoxes { var $boxcode="lastmembers"; var $boximg="object_user"; - var $boxlabel; + var $boxlabel="BoxLastMembers"; var $depends = array("adherent"); var $db; var $param; - + var $enabled = 1; + var $info_box_head = array(); var $info_box_contents = array(); + /** * Constructor */ - function __construct() + function __construct($db) { - global $langs; - $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); + if (! in_array('banque',$listofmodulesforexternal) && ! empty($user->societe_id)) $this->enabled=0; // disabled for external users } /** 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 12724d0bd33..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. * @@ -88,7 +73,7 @@ class box_prospect extends ModeleBoxes $sql.= " ORDER BY s.tms DESC"; $sql.= $db->plimit($max, 0); - dol_syslog("box_prospect::loadBox sql=".$sql,LOG_DEBUG); + dol_syslog(get_class($this)."::loadBox sql=".$sql,LOG_DEBUG); $resql = $db->query($sql); if ($resql) { 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 913e3d1627a..f9a76860f2a 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; @@ -46,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) { @@ -122,7 +123,7 @@ class ModeleBoxes // Can't be abtract as it is instanciated to build "empty" $bcx[1] = 'class="box_impair"'; $var = false; - dol_syslog(get_Class($this)); + dol_syslog(get_class($this).'::showBox'); // Define nbcol and nblines of the box to show $nbcol=0; diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index 62b0b582595..7ebdea10f01 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -147,7 +147,7 @@ class Conf $value=$objp->value; if ($key) { - if (! defined("$key")) define("$key", $value); // In some cases, the constant might be already forced (Example: SYSLOG_FILE_ON and SYSLOG_FILE during install) + if (! defined("$key")) define("$key", $value); // In some cases, the constant might be already forced (Example: SYSLOG_HANDLERS during install) $this->global->$key=$value; if ($value && preg_match('/^MAIN_MODULE_/',$key)) @@ -397,7 +397,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/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 2aa9f925106..e051aab618c 100755 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -467,16 +467,17 @@ class ExtraFields * Load array this->attribute_label * * @param string $elementtype Type of element + * @param boolean $forcecheck override test of MAIN_EXTRAFIELDS_DISABLED * @return array Array of attributes for all extra fields */ - function fetch_name_optionals_label($elementtype='member') + function fetch_name_optionals_label($elementtype='member',$forcecheck=false) { global $conf; $array_name_label=array(); // For avoid conflicts with external modules - if (! empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) + if (!empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && !$forcecheck) return $array_name_label; $sql = "SELECT rowid,name,label,type,size,elementtype,fieldunique,fieldrequired"; diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php index 55fd08ab493..8a2252d7596 100644 --- a/htdocs/core/class/html.formother.class.php +++ b/htdocs/core/class/html.formother.class.php @@ -808,24 +808,28 @@ class FormOther include_once DOL_DOCUMENT_ROOT.'/core/class/infobox.class.php'; - //$infobox=new InfoBox($db); - $boxactivated=InfoBox::listBoxes($db,'activated',$areacode,$user); - $arrayboxactivatedid=array(); - foreach($boxactivated as $box) $arrayboxactivatedid[$box->id]=$box->id; - - $selectboxlist=''; - if (! empty($conf->use_javascript_ajax)) + $confuserzone='MAIN_BOXES_'.$areacode; + + $boxactivated=InfoBox::listBoxes($db,'activated',$areacode,(empty($user->conf->$confuserzone)?null:$user)); // Search boxes of user (or everybody if user has no specific setup) + + $boxidactivatedforuser=array(); + foreach($boxactivated as $box) { - $emptyuser=new User($db); - $boxavailable=InfoBox::listBoxes($db,'activated',$areacode,$emptyuser,$arrayboxactivatedid); // Get list of box available for empty user (minus already activated for user) - - $arrayboxtoactivatelabel=array(); - foreach($boxavailable as $box) - { - $arrayboxtoactivatelabel[$box->id]=$box->boxlabel; - } - $form=new Form($db); + if (empty($user->conf->$confuserzone) || $box->fk_user == $user->id) $boxidactivatedforuser[$box->id]=$box->id; // We keep only boxes to show for user + } + + $selectboxlist=''; + $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]=$langs->transnoentitiesnoconv($box->boxlabel); // We keep only boxes not shown for user, to show into combo list + } + $form=new Form($db); $selectboxlist=$form->selectarray('boxcombo', $arrayboxtoactivatelabel,'',1); } @@ -852,12 +856,14 @@ class FormOther '; } - $nbboxactivated=count($boxactivated); + $nbboxactivated=count($boxidactivatedforuser); print load_fiche_titre(($nbboxactivated?$langs->trans("OtherInformationsBoxes"):''),$selectboxlist,'','','otherboxes'); if ($nbboxactivated) { + $emptybox=new ModeleBoxes($db); + print ''; print '
'."\n"; @@ -873,6 +879,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 +892,6 @@ class FormOther } } - $emptybox=new ModeleBoxes($db); $emptybox->box_id='A'; $emptybox->info_box_head=array(); $emptybox->info_box_contents=array(); @@ -902,7 +908,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 +921,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 4c089b2ef88..e24a893baf4 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 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; + 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,18 +116,20 @@ 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=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; } } @@ -137,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..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; } @@ -434,7 +432,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 +533,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/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/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 576d9845776..53126eb70a1 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -473,8 +473,8 @@ function dol_strtoupper($utf8_string) /** * Write log message into outputs. Possible outputs can be: - * A file if SYSLOG_FILE_ON defined: file name is then defined by SYSLOG_FILE - * Syslog if SYSLOG_SYSLOG_ON defined: facility is then defined by SYSLOG_FACILITY + * SYSLOG_HANDLERS = ["mod_syslog_file"] file name is then defined by SYSLOG_FILE + * SYSLOG_HANDLERS = ["mod_syslog_syslog"] facility is then defined by SYSLOG_FACILITY * Warning, syslog functions are bugged on Windows, generating memory protection faults. To solve * this, use logging to files instead of syslog (see setup of module). * Note: If SYSLOG_FILE_NO_ERROR defined, we never output any error message when writing to log fails. 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/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 7d095d8e6d4..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,27 +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.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 51e61dfb6c9..8260611803b 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -443,8 +443,8 @@ 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'); - $newTabMenu = $menuArbo->menuTopCharger('','',$type_user,'eldy',$tabMenu); + $menuArbo = new Menubase($db,'eldy'); + $newTabMenu = $menuArbo->menuTopCharger('','',$type_user,'eldy',$tabMenu); // Return tabMenu with only top entries $num = count($newTabMenu); for($i = 0; $i < $num; $i++) @@ -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); } 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 355619e6832..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,17 +59,22 @@ class MenuLeft /** * Show menu * + * @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'; + global $conf; - $res=print_left_eldy_menu($this->db,$this->menu_array,$this->menu_array_after); + require_once DOL_DOCUMENT_ROOT.'/core/menus/standard/eldy.lib.php'; $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/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/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' 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(); diff --git a/htdocs/install/inc.php b/htdocs/install/inc.php index 799ce4e2e98..e65c6a35b40 100644 --- a/htdocs/install/inc.php +++ b/htdocs/install/inc.php @@ -303,7 +303,7 @@ function conf($dolibarr_main_document_root) // Force usage of log file for install and upgrades $conf->syslog->enabled=1; $conf->global->SYSLOG_LEVEL=constant('LOG_DEBUG'); - if (! defined('SYSLOG_FILE_ON')) define('SYSLOG_FILE_ON',1); + if (! defined('SYSLOG_HANDLERS')) define('SYSLOG_HANDLERS','["mod_syslog_file"]'); if (! defined('SYSLOG_FILE')) // To avoid warning on systems with constant already defined { if (@is_writable('/tmp')) define('SYSLOG_FILE','/tmp/dolibarr_install.log'); 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'); diff --git a/htdocs/install/mysql/data/llx_const.sql b/htdocs/install/mysql/data/llx_const.sql index 973152f119c..d9fdc2ba8da 100644 --- a/htdocs/install/mysql/data/llx_const.sql +++ b/htdocs/install/mysql/data/llx_const.sql @@ -35,7 +35,7 @@ insert into llx_const (name, value, type, note, visible, entity) values ('MAIN_N insert into llx_const (name, value, type, note, visible, entity) values ('MAIN_FEATURES_LEVEL','0','chaine','Level of features to show (0=stable only, 1=stable+experimental, 2=stable+experimental+development',1,0); -- Hidden and common to all entities -insert into llx_const (name, value, type, note, visible, entity) values ('SYSLOG_FILE_ON','1','chaine','Log to file Directory where to write log file',0,0); +insert into llx_const (name, value, type, note, visible, entity) values ('SYSLOG_HANDLERS','["mod_syslog_file"]','chaine','Which logger to use',0,0); insert into llx_const (name, value, type, note, visible, entity) values ('SYSLOG_FILE','DOL_DATA_ROOT/dolibarr.log','chaine','Directory where to write log file',0,0); insert into llx_const (name, value, type, note, visible, entity) values ('SYSLOG_LEVEL','7','chaine','Level of debug info to show',0,0); 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 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 diff --git a/htdocs/product/fiche.php b/htdocs/product/fiche.php index 1bd270b93ce..209ba5ff89a 100644 --- a/htdocs/product/fiche.php +++ b/htdocs/product/fiche.php @@ -56,9 +56,14 @@ if (! empty($user->societe_id)) $socid=$user->societe_id; $object = new Product($db); $extrafields = new ExtraFields($db); +if ($id > 0 || ! empty($ref)) +{ + $object = new Product($db); + $object->fetch($id, $ref); +} + // Get object canvas (By default, this is not defined, so standard usage of dolibarr) -$object->getCanvas($id,$ref); -$canvas = $object->canvas?$object->canvas:GETPOST("canvas"); +$canvas = !empty($object->canvas)?$object->canvas:GETPOST("canvas"); $objcanvas=''; if (! empty($canvas)) { @@ -92,7 +97,6 @@ if (empty($reshook)) // Type if ($action == 'setfk_product_type' && $user->rights->produit->creer) { - $object->fetch($id); $result = $object->setValueFrom('fk_product_type', GETPOST('fk_product_type')); header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); exit; @@ -101,7 +105,6 @@ if (empty($reshook)) // Barcode type if ($action == 'setfk_barcode_type' && $user->rights->barcode->creer) { - $object->fetch($id); $result = $object->setValueFrom('fk_barcode_type', GETPOST('fk_barcode_type')); header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); exit; @@ -110,7 +113,6 @@ if (empty($reshook)) // Barcode value if ($action == 'setbarcode' && $user->rights->barcode->creer) { - $object->fetch($id); //Todo: ajout verification de la validite du code barre en fonction du type $result = $object->setValueFrom('barcode', GETPOST('barcode')); header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); @@ -119,23 +121,17 @@ if (empty($reshook)) if ($action == 'setaccountancy_code_buy') { - $object->fetch($id,$ref); $result = $object->setValueFrom('accountancy_code_buy', GETPOST('accountancy_code_buy')); if ($result < 0) - { - $mesg=join(',',$object->errors); - } + setEventMessage(join(',',$object->errors), 'errors'); $action=""; } if ($action == 'setaccountancy_code_sell') { - $object->fetch($id,$ref); $result = $object->setValueFrom('accountancy_code_sell', GETPOST('accountancy_code_sell')); if ($result < 0) - { - $mesg=join(',',$object->errors); - } + setEventMessage(join(',',$object->errors), 'errors'); $action=""; } @@ -146,13 +142,13 @@ if (empty($reshook)) if (! GETPOST('libelle')) { - $mesg='
'.$langs->trans('ErrorFieldRequired',$langs->transnoentities('Label')).'
'; + setEventMessage($langs->trans('ErrorFieldRequired',$langs->transnoentities('Label')), 'errors'); $action = "create"; $error++; } if (empty($ref)) { - $mesg='
'.$langs->trans('ErrorFieldRequired',$langs->transnoentities('Ref')).'
'; + setEventMessage($langs->trans('ErrorFieldRequired',$langs->transnoentities('Ref')), 'errors'); $action = "create"; $error++; } @@ -162,10 +158,16 @@ if (empty($reshook)) $object->ref = $ref; $object->libelle = GETPOST('libelle'); $object->price_base_type = GETPOST('price_base_type'); - if ($object->price_base_type == 'TTC') $object->price_ttc = GETPOST('price'); - else $object->price = GETPOST('price'); - if ($object->price_base_type == 'TTC') $object->price_min_ttc = GETPOST('price_min'); - else $object->price_min = GETPOST('price_min'); + + if ($object->price_base_type == 'TTC') + $object->price_ttc = GETPOST('price'); + else + $object->price = GETPOST('price'); + if ($object->price_base_type == 'TTC') + $object->price_min_ttc = GETPOST('price_min'); + else + $object->price_min = GETPOST('price_min'); + $object->tva_tx = str_replace('*','',GETPOST('tva_tx')); $object->tva_npr = preg_match('/\*/',GETPOST('tva_tx'))?1:0; @@ -230,7 +232,7 @@ if (empty($reshook)) } else { - $mesg='
'.$langs->trans($object->error).'
'; + setEventMessage($langs->trans($object->error), 'errors'); $action = "create"; } } @@ -245,7 +247,7 @@ if (empty($reshook)) } else { - if ($object->fetch($id,$ref)) + if ($object->id > 0) { $object->oldcopy=dol_clone($object); @@ -289,14 +291,14 @@ if (empty($reshook)) } else { + setEventMessage($langs->trans($object->error), 'errors'); $action = 'edit'; - $mesg = $object->error; } } else { + setEventMessage($langs->trans("ErrorProductBadRefOrLabel"), 'errors'); $action = 'edit'; - $mesg = $langs->trans("ErrorProductBadRefOrLabel"); } } @@ -309,14 +311,14 @@ if (empty($reshook)) { if (! GETPOST('clone_content') && ! GETPOST('clone_prices') ) { - $mesg='
'.$langs->trans("NoCloneOptionsSpecified").'
'; + setEventMessage($langs->trans("NoCloneOptionsSpecified"), 'errors'); } else { $db->begin(); $originalId = $id; - if ($object->fetch($id,$ref) > 0) + if ($object->id > 0) { $object->ref = GETPOST('clone_ref'); $object->status = 0; @@ -351,12 +353,13 @@ if (empty($reshook)) $mesg='
'.$langs->trans("ErrorProductAlreadyExists",$object->ref); $mesg.=' '.$langs->trans("ShowCardHere").'.'; $mesg.='
'; + setEventMessage($mesg, 'errors'); //dol_print_error($object->db); } else { $db->rollback(); - $mesg=$object->error; + setEventMessage($langs->trans($object->error), 'errors'); dol_print_error($db,$object->error); } } @@ -374,10 +377,7 @@ if (empty($reshook)) if ($action == 'confirm_delete' && $confirm != 'yes') { $action=''; } if ($action == 'confirm_delete' && $confirm == 'yes') { - $object = new Product($db); - $object->fetch($id,$ref); - - if ( ($object->type == 0 && $user->rights->produit->supprimer) || ($object->type == 1 && $user->rights->service->supprimer) ) + if (($object->type == 0 && $user->rights->produit->supprimer) || ($object->type == 1 && $user->rights->service->supprimer)) { $result = $object->delete($object->id); } @@ -389,7 +389,7 @@ if (empty($reshook)) } else { - $mesg=$object->error; + setEventMessage($langs->trans($object->error), 'errors'); $reload = 0; $action=''; } @@ -397,7 +397,7 @@ if (empty($reshook)) // Add product into proposal - if ($action == 'addinpropal') + if ($object->id > 0 && $action == 'addinpropal') { $propal = new Propal($db); $result=$propal->fetch(GETPOST('propalid')); @@ -415,35 +415,27 @@ if (empty($reshook)) exit; } - $prod = new Product($db); - $result=$prod->fetch($id,$ref); - if ($result <= 0) - { - dol_print_error($db,$prod->error); - exit; - } + $desc = $object->description; - $desc = $prod->description; - - $tva_tx = get_default_tva($mysoc, $soc, $prod->id); + $tva_tx = get_default_tva($mysoc, $soc, $object->id); $localtax1_tx= get_localtax($tva_tx, 1, $soc); $localtax2_tx= get_localtax($tva_tx, 2, $soc); - $pu_ht = $prod->price; - $pu_ttc = $prod->price_ttc; - $price_base_type = $prod->price_base_type; + $pu_ht = $object->price; + $pu_ttc = $object->price_ttc; + $price_base_type = $object->price_base_type; // If multiprice if ($conf->global->PRODUIT_MULTIPRICES && $soc->price_level) { - $pu_ht = $prod->multiprices[$soc->price_level]; - $pu_ttc = $prod->multiprices_ttc[$soc->price_level]; - $price_base_type = $prod->multiprices_base_type[$soc->price_level]; + $pu_ht = $object->multiprices[$soc->price_level]; + $pu_ttc = $object->multiprices_ttc[$soc->price_level]; + $price_base_type = $object->multiprices_base_type[$soc->price_level]; } // On reevalue prix selon taux tva car taux tva transaction peut etre different // de ceux du produit par defaut (par exemple si pays different entre vendeur et acheteur). - if ($tva_tx != $prod->tva_tx) + if ($tva_tx != $object->tva_tx) { if ($price_base_type != 'HT') { @@ -463,7 +455,7 @@ if (empty($reshook)) $tva_tx, $localtax1_tx, // localtax1 $localtax2_tx, // localtax2 - $prod->id, + $object->id, GETPOST('remise_percent'), $price_base_type, $pu_ttc @@ -474,11 +466,11 @@ if (empty($reshook)) return; } - $mesg = $langs->trans("ErrorUnknown").": $result"; + setEventMessage($langs->trans("ErrorUnknown").": $result", 'errors'); } // Add product into order - if ($action == 'addincommande') + if ($object->id > 0 && $action == 'addincommande') { $commande = new Commande($db); $result=$commande->fetch(GETPOST('commandeid')); @@ -496,36 +488,28 @@ if (empty($reshook)) exit; } - $prod = new Product($db); - $result=$prod->fetch($id,$ref); - if ($result <= 0) - { - dol_print_error($db,$prod->error); - exit; - } + $desc = $object->description; - $desc = $prod->description; - - $tva_tx = get_default_tva($mysoc, $soc, $prod->id); + $tva_tx = get_default_tva($mysoc, $soc, $object->id); $localtax1_tx= get_localtax($tva_tx, 1, $soc); $localtax2_tx= get_localtax($tva_tx, 2, $soc); - $pu_ht = $prod->price; - $pu_ttc = $prod->price_ttc; - $price_base_type = $prod->price_base_type; + $pu_ht = $object->price; + $pu_ttc = $object->price_ttc; + $price_base_type = $object->price_base_type; // If multiprice if ($conf->global->PRODUIT_MULTIPRICES && $soc->price_level) { - $pu_ht = $prod->multiprices[$soc->price_level]; - $pu_ttc = $prod->multiprices_ttc[$soc->price_level]; - $price_base_type = $prod->multiprices_base_type[$soc->price_level]; + $pu_ht = $object->multiprices[$soc->price_level]; + $pu_ttc = $object->multiprices_ttc[$soc->price_level]; + $price_base_type = $object->multiprices_base_type[$soc->price_level]; } // On reevalue prix selon taux tva car taux tva transaction peut etre different // de ceux du produit par defaut (par exemple si pays different entre vendeur et acheteur). - if ($tva_tx != $prod->tva_tx) + if ($tva_tx != $object->tva_tx) { if ($price_base_type != 'HT') { @@ -545,7 +529,7 @@ if (empty($reshook)) $tva_tx, $localtax1_tx, // localtax1 $localtax2_tx, // localtax2 - $prod->id, + $object->id, GETPOST('remise_percent'), '', '', @@ -561,7 +545,7 @@ if (empty($reshook)) } // Add product into invoice - if ($action == 'addinfacture' && $user->rights->facture->creer) + if ($object->id > 0 && $action == 'addinfacture' && $user->rights->facture->creer) { $facture = New Facture($db); $result=$facture->fetch(GETPOST('factureid')); @@ -579,35 +563,27 @@ if (empty($reshook)) exit; } - $prod = new Product($db); - $result = $prod->fetch($id,$ref); - if ($result <= 0) - { - dol_print_error($db,$prod->error); - exit; - } + $desc = $object->description; - $desc = $prod->description; - - $tva_tx = get_default_tva($mysoc, $soc, $prod->id); + $tva_tx = get_default_tva($mysoc, $soc, $object->id); $localtax1_tx= get_localtax($tva_tx, 1, $soc); $localtax2_tx= get_localtax($tva_tx, 2, $soc); - $pu_ht = $prod->price; - $pu_ttc = $prod->price_ttc; - $price_base_type = $prod->price_base_type; + $pu_ht = $object->price; + $pu_ttc = $object->price_ttc; + $price_base_type = $object->price_base_type; // If multiprice if ($conf->global->PRODUIT_MULTIPRICES && $soc->price_level) { - $pu_ht = $prod->multiprices[$soc->price_level]; - $pu_ttc = $prod->multiprices_ttc[$soc->price_level]; - $price_base_type = $prod->multiprices_base_type[$soc->price_level]; + $pu_ht = $object->multiprices[$soc->price_level]; + $pu_ttc = $object->multiprices_ttc[$soc->price_level]; + $price_base_type = $object->multiprices_base_type[$soc->price_level]; } // On reevalue prix selon taux tva car taux tva transaction peut etre different // de ceux du produit par defaut (par exemple si pays different entre vendeur et acheteur). - if ($tva_tx != $prod->tva_tx) + if ($tva_tx != $object->tva_tx) { if ($price_base_type != 'HT') { @@ -627,7 +603,7 @@ if (empty($reshook)) $tva_tx, $localtax1_tx, $localtax2_tx, - $prod->id, + $object->id, GETPOST('remise_percent'), '', '', @@ -649,7 +625,7 @@ if (empty($reshook)) if (GETPOST("cancel") == $langs->trans("Cancel")) { $action = ''; - header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); + header("Location: ".$_SERVER["PHP_SELF"]."?id=".$object->id); exit; } @@ -677,15 +653,10 @@ $formproduct = new FormProduct($db); if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { // ----------------------------------------- - // When used with CANVAS + // When used with CANVAS (more simple) // ----------------------------------------- - if (empty($object->error) && ($id || $ref)) - { - $object = new Product($db); - $object->fetch($id, $ref); - } - $objcanvas->assign_values($action, $object->id, $ref); // Set value for templates - $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 { @@ -717,8 +688,6 @@ else else $title=$langs->trans("NewProduct"); print_fiche_titre($title); - dol_htmloutput_mesg($mesg); - print ''; print ''; $tmpcode=''; @@ -887,10 +856,8 @@ else * Product card */ - else if ($id || $ref) + else if ($object->id > 0) { - $res=$object->fetch($id,$ref); - if ($res < 0) { dol_print_error($db,$object->error); exit; } $res=$object->fetch_optionals($object->id,$extralabels); // Fiche en mode edition @@ -903,8 +870,6 @@ else if ($object->isservice()) $type = $langs->trans('Service'); print_fiche_titre($langs->trans('Modify').' '.$type.' : '.$object->ref, ""); - dol_htmloutput_errors($mesg); - // Main official, simple, and not duplicated code print ''."\n"; print ''; @@ -1066,8 +1031,6 @@ else // Fiche en mode visu else { - dol_htmloutput_mesg($mesg); - $head=product_prepare_head($object, $user); $titre=$langs->trans("CardProduct".$object->type); $picto=($object->type==1?'service':'product'); 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 ''; + print ''; print '
'.$langs->trans("Password").'
'.$langs->trans("Password").''; if (! empty($ldap_sid)) {