* Copyright (C) 2006 Andre Cianfarani * Copyright (C) 2006-2007 Rodolphe Quiedeville * Copyright (C) 2007 Auguria SARL * Copyright (C) 2005-2009 Regis Houssin * * 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, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /** \file htdocs/admin/produit.php \ingroup produit \brief Page d'administration/configuration du module Produit \version $Id$ */ require("./pre.inc.php"); require_once(DOL_DOCUMENT_ROOT."/lib/admin.lib.php"); require_once(DOL_DOCUMENT_ROOT."/includes/barcode/html.formbarcode.class.php"); $langs->load("admin"); $langs->load("propal"); $langs->load("products"); // Security check if (!$user->admin) accessforbidden(); if ($_POST["action"] == 'nbprod') { dolibarr_set_const($db, "PRODUIT_LIMIT_SIZE", $_POST["value"],'chaine',0,'',$conf->entity); } else if ($_POST["action"] == 'multiprix_num') { dolibarr_set_const($db, "PRODUIT_MULTIPRICES_LIMIT", $_POST["value"],'chaine',0,'',$conf->entity); } if ($_POST["action"] == 'multiprix') { $res=$db->DDLDescTable(MAIN_DB_PREFIX."societe","price_level"); if(! $db->fetch_row($res)) { $field_desc = array('type'=>'TINYINT','value'=>'4','default'=>'1'); if ($_POST["activate_multiprix"]) { // on ajoute le champ price_level dans la table societe if ($db->DDLAddField(MAIN_DB_PREFIX."societe","price_level",$field_desc) < 0) { dol_print_error($db); exit; } } dolibarr_set_const($db, "PRODUIT_MULTIPRICES", $_POST["activate_multiprix"],'chaine',0,'',$conf->entity); dolibarr_set_const($db, "PRODUIT_MULTIPRICES_LIMIT", "6",'chaine',0,'',$conf->entity); } else { dol_syslog("Table definition for ".MAIN_DB_PREFIX."societe already ok"); dolibarr_set_const($db, "PRODUIT_MULTIPRICES", $_POST["activate_multiprix"],'chaine',0,'',$conf->entity); dolibarr_set_const($db, "PRODUIT_MULTIPRICES_LIMIT", "6",'chaine',0,'',$conf->entity); } } else if ($_POST["action"] == 'sousproduits') { $res=$db->DDLDescTable(MAIN_DB_PREFIX."product_association"); if(! $db->fetch_row($res)) { $table = MAIN_DB_PREFIX."product_association"; $fields['fk_product_pere'] = array('type'=>'int','value'=>'11','null'=> 'not null','default'=> '0'); $fields['fk_product_fils'] = array('type'=>'int','value'=>'11','null'=> 'not null','default'=> '0'); $fields['qty'] = array('type'=>'double','default'=> 'null'); $keys['idx_product_association_fk_product_pere'] = "fk_product_pere" ; $keys['idx_product_association_fk_product_fils'] = "fk_product_fils" ; if ($db->DDLCreateTable($table,$fields,"","InnoDB","","",$keys) < 0) { dol_print_error($db); exit; } else { dolibarr_set_const($db, "PRODUIT_SOUSPRODUITS", $_POST["activate_sousproduits"],'chaine',0,'',$conf->entity); } } else { dol_syslog("Table definition already ok"); dolibarr_set_const($db, "PRODUIT_SOUSPRODUITS", $_POST["activate_sousproduits"],'chaine',0,'',$conf->entity); } } else if ($_POST["action"] == 'viewProdDescInForm') { dolibarr_set_const($db, "PRODUIT_DESC_IN_FORM", $_POST["activate_viewProdDescInForm"],'chaine',0,'',$conf->entity); } /* else if ($_POST["action"] == 'confirmDeleteProdLineInForm') { dolibarr_set_const($db, "PRODUIT_CONFIRM_DELETE_LINE", $_POST["activate_confirmDeleteProdLineInForm"],'chaine',0,'',$conf->entity); } */ else if ($_POST["action"] == 'ProductCanvasAbility') { // Create temp directory for smarty if (! empty($dolibarr_smarty_compile)) create_exdir($dolibarr_smarty_compile); if (! empty($dolibarr_smarty_cache)) create_exdir($dolibarr_smarty_cache); dolibarr_set_const($db, "MAIN_NEED_SMARTY", $_POST["ProductCanvasAbility"],'chaine',0,'',$conf->entity); } else if ($_POST["action"] == 'usesearchtoselectproduct') { dolibarr_set_const($db, "PRODUIT_USE_SEARCH_TO_SELECT", $_POST["activate_usesearchtoselectproduct"],'chaine',0,'',$conf->entity); } else if ($_GET["action"] == 'set') { // Create temp directory for smarty if (! empty($dolibarr_smarty_compile)) create_exdir($dolibarr_smarty_compile); if (! empty($dolibarr_smarty_cache)) create_exdir($dolibarr_smarty_cache); $const = "PRODUIT_SPECIAL_".strtoupper($_GET["spe"]); if ($_GET["value"]) dolibarr_set_const($db, $const, $_GET["value"],'chaine',0,'',$conf->entity); else dolibarr_del_const($db, $const,$conf->entity); } else if ($_POST["action"] == 'useecotaxe') { dolibarr_set_const($db, "PRODUIT_USE_ECOTAXE", $_POST["activate_useecotaxe"],'chaine',0,'',$conf->entity); } /* * Affiche page */ $formbarcode=new FormBarCode($db); llxHeader('',$langs->trans("ProductSetup")); $linkback=''.$langs->trans("BackToModuleList").''; print_fiche_titre($langs->trans("ProductSetup"),$linkback,'setup'); $html=new Form($db); $var=true; print ''; print ''; print " \n"; print " \n"; print " \n"; /* * Formulaire parametres divers */ // multiprix activation/desactivation $var=!$var; print ""; print ''; print ""; print ""; print ''; print '"; print ''; print ''; // multiprix nombre de prix a proposer if($conf->global->PRODUIT_MULTIPRICES) { $var=!$var; print ""; print ''; print ""; print ""; print ''; print ""; print ''; print ''; print ''; } // sousproduits activation/desactivation $var=!$var; print ""; print ''; print ""; print ""; print ''; print '"; print ''; print ''; // utilisation formulaire Ajax sur choix produit $var=!$var; print ""; print ''; print ""; print ""; print ''; if (! $conf->use_javascript_ajax) { print '"; } else { print '"; } print ''; print ''; if (empty($conf->global->PRODUIT_USE_SEARCH_TO_SELECT)) { $var=!$var; print ""; print ''; print ""; print ""; print ''; print ""; print ''; print ''; print ''; } // Visualiser description produit dans les formulaires activation/desactivation $var=!$var; print ""; print ''; print ""; print ""; print ''; print '"; print ''; print ''; // Confirmation de suppression d'un ligne produit dans les formulaires activation/desactivation /* $var=!$var; print ""; print ''; print ""; print ""; print ''; print '"; print ''; print ''; */ // Utilisation de l'ecotaxe $var=!$var; print ""; print ''; print ""; print ""; print ''; print '"; print ''; print ''; // Old canvas feature if ($conf->global->PRODUCT_CANVAS_ABILITY) { // Propose utilisation de canvas. // Ces derniers ne sont geres que par le menu default $var = false; print ''; print " \n"; print " \n"; print " \n"; require_once(DOL_DOCUMENT_ROOT . "/product.class.php"); $dir = DOL_DOCUMENT_ROOT . "/product/canvas/"; if ($conf->global->PRODUCT_CANVAS_ABILITY) { if(is_dir($dir) ) { $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(); $var=!$var; print "'; } } closedir($handle); } else { print "\n"; } } print '
".$langs->trans("Parameters")."".$langs->trans("Value")." 
'.$langs->trans("MultiPricesAbility").''; print $html->selectyesno("activate_multiprix",$conf->global->PRODUIT_MULTIPRICES,1); print ''; print ''; print "
'.$langs->trans("MultiPricesNumPrices").'global->PRODUIT_MULTIPRICES_LIMIT."\">
'.$langs->trans("AssociatedProductsAbility").''; print $html->selectyesno("activate_sousproduits",$conf->global->PRODUIT_SOUSPRODUITS,1); print ''; print ''; print "
'.$langs->trans("UseSearchToSelectProduct").''; print $langs->trans("NotAvailableWhenAjaxDisabled"); print "'; print $html->selectyesno("activate_usesearchtoselectproduct",$conf->global->PRODUIT_USE_SEARCH_TO_SELECT,1); print ''; print ''; print "
'.$langs->trans("NumberOfProductShowInSelect").'global->PRODUIT_LIMIT_SIZE."\">
'.$langs->trans("ViewProductDescInFormAbility").''; print $html->selectyesno("activate_viewProdDescInForm",$conf->global->PRODUIT_DESC_IN_FORM,1); print ''; print ''; print "
'.$langs->trans("ConfirmDeleteProductLineAbility").''; print $html->selectyesno("activate_confirmDeleteProdLineInForm",$conf->global->PRODUIT_CONFIRM_DELETE_LINE,1); print ''; print ''; print "
'.$langs->trans("UseEcoTaxeAbility").''; print $html->selectyesno("activate_useecotaxe",$conf->global->PRODUIT_USE_ECOTAXE,1); print ''; print ''; print "
".$langs->trans("ProductSpecial")."".$langs->trans("Value")." 
"; print $module->description; print ''; $const = "PRODUIT_SPECIAL_".strtoupper($parts[1]); if ($conf->global->$const) { print img_tick(); print ''; print ''.$langs->trans("Disable").''; } else { print ' '; print ''.$langs->trans("Activate").''; } print '
ERROR: $dir is not a directory !
'; } $db->close(); llxFooter('$Date$ - $Revision$'); ?>