From 9586bccf27325dc47fa370f1799d4333e88ce097 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 7 Oct 2007 14:49:36 +0000 Subject: [PATCH] =?UTF-8?q?Meilleure=20gestion=20d'erreur=20si=20smarty=20?= =?UTF-8?q?mal=20configur=E9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/conf/conf.php.example | 5 + htdocs/docsoc.php | 3 +- htdocs/main.inc.php | 44 ++- htdocs/master.inc.php | 1 + htdocs/product/canvas/product.livre.class.php | 1 - htdocs/product/fiche.php | 303 +++++++++--------- htdocs/product/pre.inc.php | 149 +++++---- 7 files changed, 262 insertions(+), 244 deletions(-) diff --git a/htdocs/conf/conf.php.example b/htdocs/conf/conf.php.example index 0840c148ac9..a4fad4acf1c 100644 --- a/htdocs/conf/conf.php.example +++ b/htdocs/conf/conf.php.example @@ -132,6 +132,11 @@ $character_set_client="ISO-8859-1"; # Parameters not used yet +# dolibarr_smarty_libs_dir +# Examples: +# $dolibarr_smarty_libs_dir="/var/www/dolibarr/external-libs/smarty/libs/"; +# $dolibarr_smarty_compile="/var/www/dolibarr/documents/temp/smarty_templates"; +# $dolibarr_smarty_cache="/var/www/dolibarr/documents/temp/smarty_cache"; $dolibarr_smarty_libs_dir=""; $dolibarr_smarty_compile=""; $dolibarr_smarty_cache=""; diff --git a/htdocs/docsoc.php b/htdocs/docsoc.php index b1474d2cca4..bc07cc05ac7 100644 --- a/htdocs/docsoc.php +++ b/htdocs/docsoc.php @@ -183,8 +183,9 @@ if ($socid > 0) // Courriers // Les courriers sont des documents speciaux generes par des scripts + // situes dans scripts/courrier. // Voir Rodo - if ($conf->global->SOCIETE_NOLIST_COURRIER) + if ($conf->global->MAIN_MODULE_EDITEUR) { $filearray=array(); $errorlevel=error_reporting(); diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 60ebeb50e25..d1b5df046b1 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -492,6 +492,7 @@ if ($user->admin) $user->rights->user->self->password=1; } + /** * Overwrite configs global par configs perso * ------------------------------------------ @@ -534,22 +535,6 @@ if (isset($user->conf->MAIN_DISABLE_JAVASCRIPT) && $user->conf->MAIN_DISABLE_JAV $conf->use_javascript=! $user->conf->MAIN_DISABLE_JAVASCRIPT; } -// SMARTY -// Definit dans le fichier de conf -// $dolibarr_smarty_libs_dir="/home/www/dolitar/external-libs/smarty/libs/"; -// $dolibarr_smarty_compile="/home/www/dolitar/smarty_templates"; -// $dolibarr_smarty_cache="/home/www/dolitar/smarty_cache"; - -$smarty_libs = $dolibarr_smarty_libs_dir. "Smarty.class.php"; -if (file_exists ($smarty_libs)) -{ - require($smarty_libs); - $smarty = new Smarty(); - $smarty->compile_dir = $dolibarr_smarty_compile; - $smarty->cache_dir = $dolibarr_smarty_cache; - //$smarty->config_dir = '/web/www.domain.com/smarty/configs'; -} - // Defini gestionnaire de menu a utiliser if (! $user->societe_id) // Si utilisateur interne { @@ -564,6 +549,33 @@ else // Si utilisateur externe $conf->left_menu=$conf->global->MAIN_MENUFRONT_BARRELEFT; } + +if ($conf->left_menu != 'default.php') $conf->global->PRODUCT_CANVAS_ABILITY=0; +// Si besoin de smarty +if ($conf->global->PRODUCT_CANVAS_ABILITY) +{ + // SMARTY + // Definit dans le fichier de conf + // $dolibarr_smarty_libs_dir="/home/www/dolibarr/external-libs/smarty/libs/"; + // $dolibarr_smarty_compile="/home/www/dolibarr/documents/temp/smarty_templates"; + // $dolibarr_smarty_cache="/home/www/dolibarr/documents/temp/smarty_cache"; + + $smarty_libs = $dolibarr_smarty_libs_dir. "Smarty.class.php"; + if (file_exists ($smarty_libs)) + { + + require_once($smarty_libs); + $smarty = new Smarty(); + $smarty->compile_dir = $dolibarr_smarty_compile; + $smarty->cache_dir = $dolibarr_smarty_cache; + //$smarty->config_dir = '/web/www.domain.com/smarty/configs'; + } + else + { + dolibarr_print_error('',"Library Smarty ".$smarty_libs." not found. Check parameter dolibarr_smarty_libs_dir in conf file."); + } +} + // Si le login n'a pu etre recupere, on est identifie avec un compte qui n'existe pas. // Tentative de hacking ? if (! $user->login) accessforbidden(); diff --git a/htdocs/master.inc.php b/htdocs/master.inc.php index 99e4b036439..5053d6a2240 100644 --- a/htdocs/master.inc.php +++ b/htdocs/master.inc.php @@ -175,6 +175,7 @@ if (! defined('NOREQUIREUSER')) /* * Chargement objet $conf + * After this, all parameters conf->global->CONSTANTS are loaded */ if (! defined('NOREQUIREDB')) { diff --git a/htdocs/product/canvas/product.livre.class.php b/htdocs/product/canvas/product.livre.class.php index 90e69b2caa3..803ab66d51d 100644 --- a/htdocs/product/canvas/product.livre.class.php +++ b/htdocs/product/canvas/product.livre.class.php @@ -382,7 +382,6 @@ class ProductLivre extends Product */ function assign_smarty_values(&$smarty, $action='') { - if ($action =='edit' or $action == 'create') { $this->GetAvailableFormat(); diff --git a/htdocs/product/fiche.php b/htdocs/product/fiche.php index c7361ce195c..3c4ef44f1d4 100644 --- a/htdocs/product/fiche.php +++ b/htdocs/product/fiche.php @@ -407,168 +407,169 @@ $html = new Form($db); */ if ($_GET["action"] == 'create' && $user->rights->produit->creer) { - if ( !isset($product) ) - { - if ($_GET["canvas"] <> '' && file_exists('canvas/product.'.$_GET["canvas"].'.class.php') ) + if (! isset($product)) { - $class = 'Product'.ucfirst($_GET["canvas"]); - include_once('canvas/product.'.$_GET["canvas"].'.class.php'); - - $product = new $class($db,0,$user); + $filecanvas=DOL_DOCUMENT_ROOT.'/product/canvas/product.'.$_GET["canvas"].'.class.php'; + if ($_GET["canvas"] && file_exists($filecanvas) ) + { + $class = 'Product'.ucfirst($_GET["canvas"]); + include_once($filecanvas); + + $product = new $class($db,0,$user); + } + else + { + $product = new Product($db); + } } - else - { - $product = new Product($db); - } - } - $product->assign_smarty_values($smarty, 'create'); + $product->assign_smarty_values($smarty, 'create'); - if ($_error == 1) - { - $product = $e_product; - } - - llxHeader("","",$langs->trans("CardProduct".$product->type)); - - if ($mesg) print "$mesg\n"; - - if ($_GET["canvas"] == '') - { - print '
'; - print ''; - print ''."\n"; - - if ($_GET["type"]==1) $title=$langs->trans("NewService"); - else $title=$langs->trans("NewProduct"); - print_fiche_titre($title); - - print ''; - print ''; - print ''; - print ''; - if($conf->global->PRODUIT_MULTIPRICES == 1) - { - print ''; - print ''; - for($i=2;$i<=$conf->global->PRODUIT_MULTIPRICES_LIMIT;$i++) - { - print ''; - print ''; - } - } - // PRIX - else - { - print ''; - print ''; - } - - print ''; - - print ''; - - if ($_GET["type"] != 1 && $conf->stock->enabled) + llxHeader("","",$langs->trans("CardProduct".$product->type)); + + if ($mesg) print "$mesg\n"; + + if (! $_GET["canvas"]) { - print ''; + print ''; + print ''; + print ''."\n"; + + if ($_GET["type"]==1) $title=$langs->trans("NewService"); + else $title=$langs->trans("NewProduct"); + print_fiche_titre($title); + + print '
'.$langs->trans("Ref").''; - if ($_error == 1) + if ($_error == 1) { - print $langs->trans("RefAlreadyExists"); + $product = $e_product; } - print '
'.$langs->trans("Label").'
'.$langs->trans("SellingPrice").' 1'; - print $html->select_PriceBaseType($product->price_base_type, "price_base_type"); - print '
'.$langs->trans("SellingPrice").' '.$i.''; - print $html->select_PriceBaseType($product->multiprices_base_type["$i"], "multiprices_base_type_".$i); - print '
'.$langs->trans("SellingPrice").''; - print $html->select_PriceBaseType($product->price_base_type, "price_base_type"); - print '
'.$langs->trans("VATRate").''; - print $html->select_tva("tva_tx",$conf->defaulttx,$mysoc,''); - print '
'.$langs->trans("Status").''; - print ''; - print '
Seuil stock'; - print ''; - print '
'; + print ''; + print ''; + print ''; + + if($conf->global->PRODUIT_MULTIPRICES == 1) + { + print ''; + print ''; + for($i=2;$i<=$conf->global->PRODUIT_MULTIPRICES_LIMIT;$i++) + { + print ''; + print ''; + } + } + // PRIX + else + { + print ''; + print ''; + } + + print ''; + + print ''; + + if ($_GET["type"] != 1 && $conf->stock->enabled) + { + print ''; + } + else + { + print ''; + } + + // Description (utilisé dans facture, propale...) + print '"; + + if ($_GET["type"] == 1) + { + print ''; + } + else + { + // Le poids et le volume ne concerne que les produits et pas les services + print ''; + print ''; + } + + // Note (invisible sur facture, propales...) + print '"; + + print ''; + print '
'.$langs->trans("Ref").''; + if ($_error == 1) + { + print $langs->trans("RefAlreadyExists"); + } + print '
'.$langs->trans("Label").'
'.$langs->trans("SellingPrice").' 1'; + print $html->select_PriceBaseType($product->price_base_type, "price_base_type"); + print '
'.$langs->trans("SellingPrice").' '.$i.''; + print $html->select_PriceBaseType($product->multiprices_base_type["$i"], "multiprices_base_type_".$i); + print '
'.$langs->trans("SellingPrice").''; + print $html->select_PriceBaseType($product->price_base_type, "price_base_type"); + print '
'.$langs->trans("VATRate").''; + print $html->select_tva("tva_tx",$conf->defaulttx,$mysoc,''); + print '
'.$langs->trans("Status").''; + print ''; + print '
Seuil stock'; + print ''; + print '
'.$langs->trans("Description").''; + + if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC) + { + require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php"); + $doleditor=new DolEditor('desc','',160,'dolibarr_notes','',false); + $doleditor->Create(); + } + else + { + print ''; + } + + print "
'.$langs->trans("Duration").'  '; + print ''.$langs->trans("Hour").' '; + print ''.$langs->trans("Day").' '; + print ''.$langs->trans("Week").' '; + print ''.$langs->trans("Month").' '; + print ''.$langs->trans("Year").' '; + print '
'.$langs->trans("Weight").''; + print ''; + print $html->select_measuring_units("weight_units","weight"); + print '
'.$langs->trans("volume").''; + print ''; + print $html->select_measuring_units("volume_units","volume"); + print '
'.$langs->trans("NoteNotVisibleOnBill").''; + if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC) + { + require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php"); + $doleditor=new DolEditor('note','',200,'dolibarr_notes','',false); + $doleditor->Create(); + } + else + { + print ''; + } + print "
'; + print '
'; } - else + else { - print ''; + //RODO + // On assigne les valeurs meme en creation car elles sont definies si + // on revient en erreur + // + $smarty->template_dir = DOL_DOCUMENT_ROOT.'/product/canvas/'.$_GET["canvas"].'/'; + $null = $html->load_tva("tva_tx",$conf->defaulttx,$mysoc,''); + $smarty->assign('tva_taux_value', $html->tva_taux_value); + $smarty->assign('tva_taux_libelle', $html->tva_taux_libelle); + $smarty->display($_GET["canvas"].'-create.tpl'); } - - // Description (utilisé dans facture, propale...) - print ''.$langs->trans("Description").''; - - if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC) - { - require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php"); - $doleditor=new DolEditor('desc','',160,'dolibarr_notes','',false); - $doleditor->Create(); - } - else - { - print ''; - } - - print ""; - - if ($_GET["type"] == 1) - { - print ''.$langs->trans("Duration").'  '; - print ''.$langs->trans("Hour").' '; - print ''.$langs->trans("Day").' '; - print ''.$langs->trans("Week").' '; - print ''.$langs->trans("Month").' '; - print ''.$langs->trans("Year").' '; - print ''; - } - else - { - // Le poids et le volume ne concerne que les produits et pas les services - print ''.$langs->trans("Weight").''; - print ''; - print $html->select_measuring_units("weight_units","weight"); - print ''; - print ''.$langs->trans("volume").''; - print ''; - print $html->select_measuring_units("volume_units","volume"); - print ''; - } - - // Note (invisible sur facture, propales...) - print ''.$langs->trans("NoteNotVisibleOnBill").''; - if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC) - { - require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php"); - $doleditor=new DolEditor('note','',200,'dolibarr_notes','',false); - $doleditor->Create(); - } - else - { - print ''; - } - print ""; - - print ''; - print ''; - print ''; - } - else - { - //RODO - // On assigne les valeurs meme en creation car elles sont definies si - // on revient en erreur - // - $smarty->template_dir = DOL_DOCUMENT_ROOT.'/product/canvas/'.$_GET["canvas"].'/'; - $null = $html->load_tva("tva_tx",$conf->defaulttx,$mysoc,''); - $smarty->assign('tva_taux_value', $html->tva_taux_value); - $smarty->assign('tva_taux_libelle', $html->tva_taux_libelle); - $smarty->display($_GET["canvas"].'-create.tpl'); - } } /** diff --git a/htdocs/product/pre.inc.php b/htdocs/product/pre.inc.php index 684f592d69b..fa712afdb39 100644 --- a/htdocs/product/pre.inc.php +++ b/htdocs/product/pre.inc.php @@ -38,89 +38,88 @@ $user->getrights('facture'); function llxHeader($head = "", $urlp = "", $title="") { - global $user, $conf, $langs; + global $user, $conf, $langs; - $user->getrights("produit"); - - top_menu($head, $title); - - $menu = new Menu(); - - if ($conf->produit->enabled) - { - $menu->add(DOL_URL_ROOT."/product/index.php?type=0", $langs->trans("Products")); - $menu->add_submenu(DOL_URL_ROOT."/product/liste.php?type=0", $langs->trans("List")); - - if ($user->societe_id == 0 && $user->rights->produit->creer) - { - $menu->add_submenu(DOL_URL_ROOT."/product/fiche.php?action=create&type=0", $langs->trans("NewProduct")); - } - } - - // Produit specifique - $dir = DOL_DOCUMENT_ROOT . "/product/canvas/"; + $user->getrights("produit"); - if(is_dir($dir) && $conf->global->PRODUCT_CANVAS_ABILITY==='1' ) - { - if ($handle = opendir($dir)) + top_menu($head, $title); + + $menu = new Menu(); + + if ($conf->produit->enabled) { - while (($file = readdir($handle))!==false) - { - if (substr($file, strlen($file) -10) == '.class.php' && substr($file,0,8) == 'product.') + $menu->add(DOL_URL_ROOT."/product/index.php?type=0", $langs->trans("Products")); + $menu->add_submenu(DOL_URL_ROOT."/product/liste.php?type=0", $langs->trans("List")); + + if ($user->societe_id == 0 && $user->rights->produit->creer) { - $parts = explode('.',$file); - $classname = 'Product'.ucfirst($parts[1]); - require_once($dir.$file); - $module = new $classname(); - - if ($module->active === '1' && $module->menu_add === 1) - { - $module->PersonnalizeMenu($menu); - $langs->load("products_".$module->canvas); - for ($j = 0 ; $j < sizeof($module->menus) ; $j++) - { - $menu->add_submenu($module->menus[$j][0], $langs->trans($module->menus[$j][1])); - } - } + $menu->add_submenu(DOL_URL_ROOT."/product/fiche.php?action=create&type=0", $langs->trans("NewProduct")); } - } - closedir($handle); } - } - $menu->add_submenu(DOL_URL_ROOT."/product/reassort.php?type=0", $langs->trans("Restock")); - - if ($conf->service->enabled) - { - $menu->add(DOL_URL_ROOT."/product/index.php?type=1", $langs->trans("Services")); - $menu->add_submenu(DOL_URL_ROOT."/product/liste.php?type=1", $langs->trans("List")); - if ($user->societe_id == 0 && $user->rights->produit->creer) + // Produit specifique + $dir = DOL_DOCUMENT_ROOT . "/product/canvas/"; + if(is_dir($dir) && $conf->global->PRODUCT_CANVAS_ABILITY) { - $menu->add_submenu(DOL_URL_ROOT."/product/fiche.php?action=create&type=1", $langs->trans("NewService")); + if ($handle = opendir($dir)) + { + while (($file = readdir($handle))!==false) + { + if (substr($file, strlen($file) -10) == '.class.php' && substr($file,0,8) == 'product.') + { + $parts = explode('.',$file); + $classname = 'Product'.ucfirst($parts[1]); + require_once($dir.$file); + $module = new $classname(); + + if ($module->active === '1' && $module->menu_add === 1) + { + $module->PersonnalizeMenu($menu); + $langs->load("products_".$module->canvas); + for ($j = 0 ; $j < sizeof($module->menus) ; $j++) + { + $menu->add_submenu($module->menus[$j][0], $langs->trans($module->menus[$j][1])); + } + } + } + } + closedir($handle); + } } - } - - if ($conf->fournisseur->enabled) { - $langs->load("suppliers"); - $menu->add(DOL_URL_ROOT."/fourn/index.php", $langs->trans("Suppliers")); - } - - $menu->add(DOL_URL_ROOT."/product/stats/", $langs->trans("Statistics")); - if ($conf->propal->enabled) - { - $menu->add_submenu(DOL_URL_ROOT."/product/popuprop.php", $langs->trans("Popularity")); - } - - if ($conf->stock->enabled) - { - $menu->add(DOL_URL_ROOT."/product/stock/", $langs->trans("Stock")); - } - - if ($conf->categorie->enabled) - { - $menu->add(DOL_URL_ROOT."/categories/index.php?type=0", $langs->trans("Categories")); - } - - left_menu($menu->liste); + + $menu->add_submenu(DOL_URL_ROOT."/product/reassort.php?type=0", $langs->trans("Restock")); + + if ($conf->service->enabled) + { + $menu->add(DOL_URL_ROOT."/product/index.php?type=1", $langs->trans("Services")); + $menu->add_submenu(DOL_URL_ROOT."/product/liste.php?type=1", $langs->trans("List")); + if ($user->societe_id == 0 && $user->rights->produit->creer) + { + $menu->add_submenu(DOL_URL_ROOT."/product/fiche.php?action=create&type=1", $langs->trans("NewService")); + } + } + + if ($conf->fournisseur->enabled) { + $langs->load("suppliers"); + $menu->add(DOL_URL_ROOT."/fourn/index.php", $langs->trans("Suppliers")); + } + + $menu->add(DOL_URL_ROOT."/product/stats/", $langs->trans("Statistics")); + if ($conf->propal->enabled) + { + $menu->add_submenu(DOL_URL_ROOT."/product/popuprop.php", $langs->trans("Popularity")); + } + + if ($conf->stock->enabled) + { + $menu->add(DOL_URL_ROOT."/product/stock/", $langs->trans("Stock")); + } + + if ($conf->categorie->enabled) + { + $menu->add(DOL_URL_ROOT."/categories/index.php?type=0", $langs->trans("Categories")); + } + + left_menu($menu->liste); } ?>