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/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/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 b387537165b..e051aab618c 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; @@ -446,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"; @@ -533,23 +555,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 +581,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 +609,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 +636,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/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 2d3ca1d6ae9..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 */ @@ -50,9 +50,9 @@ 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; + 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/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) 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/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/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 @@ */ ?> - +