* Copyright (C) 2006 Andre Cianfarani * Copyright (C) 2006-2007 Rodolphe Quiedeville * Copyright (C) 2007 Auguria SARL * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2011-2012 Juanjo Menent * Copyright (C) 2012 Christophe Battarel ** * 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 3 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/product/admin/product.php * \ingroup produit * \brief Setup page of product module */ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formbarcode.class.php'; $langs->load("admin"); $langs->load("products"); // Security check if (! $user->admin || (empty($conf->product->enabled) && empty($conf->service->enabled))) accessforbidden(); $action = GETPOST('action','alpha'); $value = GETPOST('value','alpha'); /* * Actions */ if ($action == 'setcodeproduct') { if (dolibarr_set_const($db, "PRODUCT_CODEPRODUCT_ADDON",$value,'chaine',0,'',$conf->entity) > 0) { header("Location: ".$_SERVER["PHP_SELF"]); exit; } else { dol_print_error($db); } } // Define constants for submodules that contains parameters (forms with param1, param2, ... and value1, value2, ...) if ($action == 'setModuleOptions') { $post_size=count($_POST); $db->begin(); for($i=0;$i < $post_size;$i++) { if (array_key_exists('param'.$i,$_POST)) { $param=GETPOST("param".$i,'alpha'); $value=GETPOST("value".$i,'alpha'); if ($param) $res = dolibarr_set_const($db,$param,$value,'chaine',0,'',$conf->entity); if (! $res > 0) $error++; } } if (! $error) { $db->commit(); $mesg = "".$langs->trans("SetupSaved").""; } else { $db->rollback(); $mesg = "".$langs->trans("Error").""; } } if ($action == 'nbprod') { $res = dolibarr_set_const($db, "PRODUIT_LIMIT_SIZE", $value,'chaine',0,'',$conf->entity); } else if ($action == 'multiprix_num') { $res = dolibarr_set_const($db, "PRODUIT_MULTIPRICES_LIMIT", $value,'chaine',0,'',$conf->entity); } if ($action == 'multiprix') { $multiprix = GETPOST('activate_multiprix','alpha'); $res = dolibarr_set_const($db, "PRODUIT_MULTIPRICES", $multiprix,'chaine',0,'',$conf->entity); $res =dolibarr_set_const($db, "PRODUIT_MULTIPRICES_LIMIT", "5",'chaine',0,'',$conf->entity); } else if ($action == 'sousproduits') { $sousproduits = GETPOST('activate_sousproduits','alpha'); $res = dolibarr_set_const($db, "PRODUIT_SOUSPRODUITS", $sousproduits,'chaine',0,'',$conf->entity); } else if ($action == 'viewProdDescInForm') { $view = GETPOST('activate_viewProdDescInForm','alpha'); $res = dolibarr_set_const($db, "PRODUIT_DESC_IN_FORM", $view,'chaine',0,'',$conf->entity); } else if ($action == 'viewProdTextsInThirdpartyLanguage') { $view = GETPOST('activate_viewProdTextsInThirdpartyLanguage','alpha'); $res = dolibarr_set_const($db, "PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE", $view,'chaine',0,'',$conf->entity); } else if ($action == 'usesearchtoselectproduct') { $usesearch = GETPOST('activate_usesearchtoselectproduct','alpha'); $res = dolibarr_set_const($db, "PRODUIT_USE_SEARCH_TO_SELECT", $usesearch,'chaine',0,'',$conf->entity); } else if ($action == 'set') { $const = "PRODUCT_SPECIAL_".strtoupper(GETPOST('spe','alpha')); if (GETPOST('value','alpha')) $res = dolibarr_set_const($db, $const, $value,'chaine',0,'',$conf->entity); else $res = dolibarr_del_const($db, $const,$conf->entity); } /*else if ($action == 'useecotaxe') { $ecotaxe = GETPOST("activate_useecotaxe"); $res = dolibarr_set_const($db, "PRODUIT_USE_ECOTAXE", $ecotaxe,'chaine',0,'',$conf->entity); }*/ if($action) { if (! $res > 0) $error++; if (! $error) { $mesg = ''.$langs->trans("SetupSaved").''; } else { $mesg = ''.$langs->trans("Error").''; } } /* * View */ $formbarcode=new FormBarCode($db); $title = $langs->trans('ProductServiceSetup'); $tab = $langs->trans("ProductsAndServices"); if (empty($conf->produit->enabled)) { $title = $langs->trans('ServiceSetup'); $tab = $langs->trans('Services'); } else if (empty($conf->service->enabled)) { $title = $langs->trans('ProductSetup'); $tab = $langs->trans('Products'); } llxHeader('',$title); $linkback=''.$langs->trans("BackToModuleList").''; print_fiche_titre($title,$linkback,'setup'); $head = product_admin_prepare_head(); dol_fiche_head($head, 'general', $tab, 0, 'product'); $form=new Form($db); /* * Module to manage product / services code */ $dirproduct=array('/core/modules/product/'); print_titre($langs->trans("ProductCodeChecker")); print ''."\n"; print ''."\n"; print ' '; print ' '; print ' '; print ' '; print ' '; print "\n"; $var = true; foreach ($dirproduct as $dirroot) { $dir = dol_buildpath($dirroot,0); $handle = @opendir($dir); if (is_resource($handle)) { // Loop on each module find in opened directory while (($file = readdir($handle))!==false) { if (substr($file, 0, 16) == 'mod_codeproduct_' && substr($file, -3) == 'php') { $file = substr($file, 0, dol_strlen($file)-4); try { dol_include_once($dirroot.$file.'.php'); } catch(Exception $e) { dol_syslog($e->getMessage(), LOG_ERR); } $modCodeProduct = new $file; // Show modules according to features level if ($modCodeProduct->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; if ($modCodeProduct->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; $var = !$var; print ''."\n"; print ''."\n"; print ''."\n"; print ''."\n"; if (! empty($conf->global->PRODUCT_CODEPRODUCT_ADDON) && $conf->global->PRODUCT_CODEPRODUCT_ADDON == $file) { print '\n"; } else { $disabled = false; if (! empty($conf->multicompany->enabled) && (is_object($mc) && ! empty($mc->sharings['referent']) && $mc->sharings['referent'] == $conf->entity) ? false : true); print ''; } print ''; print ''; } } closedir($handle); } } print '
'.$langs->trans("Name").''.$langs->trans("Description").''.$langs->trans("Example").''.$langs->trans("Status").''.$langs->trans("ShortInfo").'
'.$modCodeProduct->nom.''.$modCodeProduct->info($langs).''.$modCodeProduct->getExample($langs).''."\n"; print img_picto($langs->trans("Activated"),'switch_on'); print "'; if (! $disabled) print ''; print img_picto($langs->trans("Disabled"),'switch_off'); if (! $disabled) print ''; print ''; $s=$modCodeProduct->getToolTip($langs,null,-1); print $form->textwithpicto('',$s,1); print '
'; /* * Other conf */ print "
"; print_titre($langs->trans("ProductOtherConf")); $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 (! empty($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 (empty($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 ''; // View product description in thirdparty language if (! empty($conf->global->MAIN_MULTILANGS)) { $var=!$var; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; } if (! empty($conf->global->PRODUCT_CANVAS_ABILITY)) { // Add canvas feature $dir = DOL_DOCUMENT_ROOT . "/product/canvas/"; $var = false; print ''; print ''."\n"; print ''."\n"; print ''."\n"; if (is_dir($dir)) { require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; $handle=opendir($dir); if (is_resource($handle)) { while (($file = readdir($handle))!==false) { if (file_exists($dir.$file.'/product.'.$file.'.class.php')) { $classfile = $dir.$file.'/product.'.$file.'.class.php'; $classname = 'Product'.ucfirst($file); require_once $classfile; $object = new $classname(); $module = $object->module; if ($conf->$module->enabled) { $var=!$var; print "'; } } } closedir($handle); } } else { print "\n"; } print '
'.$langs->trans("Parameters").''.$langs->trans("Value").' 
'.$langs->trans("MultiPricesAbility").''; print $form->selectyesno("activate_multiprix",$conf->global->PRODUIT_MULTIPRICES,1); print ''; print ''; print '
'.$langs->trans("MultiPricesNumPrices").'
'.$langs->trans("AssociatedProductsAbility").''; print $form->selectyesno("activate_sousproduits",$conf->global->PRODUIT_SOUSPRODUITS,1); print ''; print ''; print '
'.$langs->trans("UseSearchToSelectProduct").''; print $langs->trans("NotAvailableWhenAjaxDisabled"); print ''; $arrval=array('0'=>$langs->trans("No"), '1'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch",1).')', '2'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch",2).')', '3'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch",3).')', ); print $form->selectarray("activate_usesearchtoselectproduct",$arrval,$conf->global->PRODUIT_USE_SEARCH_TO_SELECT); print ''; print ''; print '
'.$langs->trans("NumberOfProductShowInSelect").'
'.$langs->trans("ViewProductDescInFormAbility").''; print $form->selectyesno("activate_viewProdDescInForm",$conf->global->PRODUIT_DESC_IN_FORM,1); print ''; print ''; print '
'.$langs->trans("ViewProductDescInThirdpartyLanguageAbility").''; print $form->selectyesno("activate_viewProdTextsInThirdpartyLanguage", (! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)?$conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE:0), 1); print ''; print ''; print '
'.$langs->trans("ProductSpecial").''.$langs->trans("Value").' 
"; print $object->description; print ''; $const = "PRODUCT_SPECIAL_".strtoupper($file); if ($conf->global->$const) { print img_picto($langs->trans("Active"),'tick'); print ''; print ''.$langs->trans("Disable").''; } else { print ' '; print ''.$langs->trans("Activate").''; } print '
ERROR: $dir is not a directory !
'; } dol_htmloutput_mesg($mesg); llxFooter(); $db->close(); ?>