* Copyright (C) 2006 Andre Cianfarani * * 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. * * $Id$ * $Source$ */ /** \file htdocs/admin/produit.php \ingroup produit \brief Page d'administration/configuration du module Produit \version $Revision$ */ require("./pre.inc.php"); $langs->load("admin"); $langs->load("propal"); if (!$user->admin) accessforbidden(); if ($_POST["action"] == 'nbprod') { dolibarr_set_const($db, "PRODUIT_LIMIT_SIZE", $_POST["value"]); Header("Location: produit.php"); exit; } else if ($_POST["action"] == 'multiprix_num') { dolibarr_set_const($db, "PRODUIT_MULTIPRICES_LIMIT", $_POST["value"]); Header("Location: produit.php"); exit; } if ($_GET["action"] == 'activate_multiprix') { $res=$db -> desc_table(MAIN_DB_PREFIX."product_price","price_level"); if(! $db -> fetch_row()) { // on ajoute le champ price_level dans la table product_price $field_desc = array('type'=>'TINYINT','value'=>'4','default'=>'1'); if(! $db -> add_field(MAIN_DB_PREFIX."product_price","price_level",$field_desc,"after date_price")) { dolibarr_print_error($db); print ""; } else { // on ajoute le champ price_level dans la table societe if(! $db -> add_field(MAIN_DB_PREFIX."societe","price_level",$field_desc)) { dolibarr_print_error($db); print ""; } // on crée la table societe_prices else { $table = MAIN_DB_PREFIX."societe_prices"; $fields['rowid'] = array('type'=>'int','value'=>'11','null'=>'not null','extra'=> 'auto_increment'); $fields['fk_soc'] = array('type'=>'int','value'=>'11','null'=>'not null','default'=> '0'); $fields['tms'] = array('type'=>'timestamp','value'=>'14','null'=>'not null'); $fields['datec'] = array('type'=>'datetime','default'=> 'null'); $fields['fk_user_author'] = array('type'=>'int','value'=>'11','default'=> 'null'); $fields['price_level'] = array('type'=>'tinyint','value'=>'4','default'=> '1'); if(! $db -> create_table($table,$fields,"rowid","MyISAM")) { dolibarr_print_error($db); print ""; } else { dolibarr_set_const($db, "PRODUIT_MULTIPRICES", "1"); dolibarr_set_const($db, "PRODUIT_MULTIPRICES_LIMIT", "6"); Header("Location: produit.php"); } } } } else { dolibarr_set_const($db, "PRODUIT_MULTIPRICES", "1"); dolibarr_set_const($db, "PRODUIT_MULTIPRICES_LIMIT", "6"); Header("Location: produit.php"); } exit; } else if ($_GET["action"] == 'disable_multiprix') { //"ALTER TABLE ".MAIN_DB_PREFIX."product_price drop price_level" dolibarr_del_const($db, "PRODUIT_MULTIPRICES"); dolibarr_del_const($db, "PRODUIT_MULTIPRICES_LIMIT"); Header("Location: produit.php"); exit; } else if ($_GET["action"] == 'activate_sousproduits') { $table = MAIN_DB_PREFIX."product_parent_child"; $fields['rowid'] = array('type'=>'int','value'=>'11','null'=>'not null','extra'=> 'auto_increment'); $fields['tms'] = array('type'=>'timestamp','value'=>'14','null'=>'not null'); $fields['datec'] = array('type'=>'datetime','default'=> 'null'); $fields['fk_product_parent'] = array('type'=>'int','value'=>'11','default'=> 'null'); $fields['fk_product_child'] = array('type'=>'int','value'=>'11','default'=> 'null'); if(! $db -> create_table($table,$fields,"rowid","MyISAM")) { dolibarr_print_error($db); print ""; } else { dolibarr_set_const($db, "PRODUIT_SOUSPRODUITS", "1"); Header("Location: produit.php"); } } else if ($_GET["action"] == 'disable_sousproduits') { dolibarr_del_const($db, "PRODUIT_SOUSPRODUITS"); Header("Location: produit.php"); exit; } /* * Affiche page */ llxHeader('',$langs->trans("ProductSetup")); print_titre($langs->trans("ProductSetup")); /* * Formulaire parametres divers */ print '
'; print "
"; print ""; print ""; print ""; print " \n"; print " \n"; print " \n"; print ""; print ''; print ""; print ''; print ''; print '
".$langs->trans("Name")."".$langs->trans("Value")." 
'.$langs->trans("NumberOfProductShowInSelect").'global->PRODUIT_LIMIT_SIZE."\">
'; print '
'; print '
'; // multiprix activation/desactivation print ''; print ''; print ''; print ''; print ''; print "\n"; print ""; print ""; print ""; print ''; print ''; print ""; print ''; print '
'.$langs->trans("Name").' '.$langs->trans("Active").'
'.$langs->trans("MultiPricesAbility").''; if($conf->global->PRODUIT_MULTIPRICES == 1) print img_tick(); print '"; if($conf->global->PRODUIT_MULTIPRICES == 0) print ''.$langs->trans("Activate").''; else if($conf->global->PRODUIT_MULTIPRICES == 1) print ''.$langs->trans("Disable").''; print "
'; print ''; // multiprix nombre de prix a proposer if($conf->global->PRODUIT_MULTIPRICES == 1) { print '
'; print "
"; print ""; print ""; print ""; print ' \n"; print " \n"; print " \n"; print ""; print ''; print ""; print ''; print ''; print '
'.$langs->trans("Name")."".$langs->trans("Value")." 
'.$langs->trans("MultiPricesNumPrices").'global->PRODUIT_MULTIPRICES_LIMIT."\">
'; print '
'; } // sousproduits activation/desactivation print '
'; print ''; print ''; print ''; print ''; print ''; print "\n"; print ""; print ""; print ""; print ''; print ''; print ""; print ''; print '
'.$langs->trans("Name").' '.$langs->trans("Active").'
'.$langs->trans("AssociatedProductsAbility").''; if($conf->global->PRODUIT_SOUSPRODUITS == 1) print img_tick(); print '"; if($conf->global->PRODUIT_SOUSPRODUITS == 0) print ''.$langs->trans("Activate").''; else if($conf->global->PRODUIT_SOUSPRODUITS == 1) print ''.$langs->trans("Disable").''; print "
'; print ''; $db->close(); llxFooter(); ?>