* Copyright (C) 2004 Eric Seigne * Copyright (C) 2005-2010 Laurent Destailleur * Copyright (C) 2005-2010 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/societe.php * \ingroup company * \brief Third party module setup page * \version $Id$ */ require("../main.inc.php"); require_once(DOL_DOCUMENT_ROOT."/lib/admin.lib.php"); $langs->load("admin"); if (!$user->admin) accessforbidden(); /* * Actions */ if ($_GET["action"] == 'setcodeclient') { if (dolibarr_set_const($db, "SOCIETE_CODECLIENT_ADDON",$_GET["value"],'chaine',0,'',$conf->entity) > 0) { Header("Location: ".$_SERVER["PHP_SELF"]); exit; } else { dol_print_error($db); } } if ($_GET["action"] == 'setcodecompta') { if (dolibarr_set_const($db, "SOCIETE_CODECOMPTA_ADDON",$_GET["value"],'chaine',0,'',$conf->entity) > 0) { Header("Location: ".$_SERVER["PHP_SELF"]); exit; } else { dol_print_error($db); } } if ($_POST["action"] == 'usesearchtoselectcompany') { if (dolibarr_set_const($db, "COMPANY_USE_SEARCH_TO_SELECT", $_POST["activate_usesearchtoselectcompany"],'chaine',0,'',$conf->entity)) { Header("Location: ".$_SERVER["PHP_SELF"]); exit; } else { dol_print_error($db); } } // define constants for models generator that need parameters if ($_POST["action"] == 'setModuleOptions') { $param=$_POST["param1"]; $value=$_POST["value1"]; if ($param) dolibarr_set_const($db,$param,$value,'chaine',0,'',$conf->entity); } // Activate a document generator module if ($_GET["action"] == 'set') { $type='company'; $sql = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity, libelle, description)"; $sql.= " VALUES ('".addslashes($_GET["value"])."','".$type."',".$conf->entity.", "; $sql.= ($_GET["label"]?"'".addslashes($_GET["label"])."'":'null').", "; $sql.= (! empty($_GET["scandir"])?"'".$_GET["scandir"]."'":"null"); $sql.= ")"; if ($db->query($sql)) { } else dol_print_error($db); } // Disable a document generator module if ($_GET["action"] == 'del') { $type='company'; $sql = "DELETE FROM ".MAIN_DB_PREFIX."document_model"; $sql.= " WHERE nom='".addslashes($_GET["value"])."' AND type='".$type."' AND entity=".$conf->entity; if ($db->query($sql)) { } else dol_print_error($db); } // Define default generator if ($_GET["action"] == 'setdoc') { $db->begin(); if (dolibarr_set_const($db, "COMPANY_ADDON_PDF",$_GET["value"],'chaine',0,'',$conf->entity)) { $conf->global->COMPANY_ADDON_PDF = $_GET["value"]; } // On active le modele $type='company'; $sql_del = "DELETE FROM ".MAIN_DB_PREFIX."document_model"; $sql_del.= " WHERE nom = '".$_GET["value"]."'"; $sql_del.= " AND type = '".$type."'"; $sql_del.= " AND entity = ".$conf->entity; $result1=$db->query($sql_del); $sql = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity, libelle, description)"; $sql.= " VALUES ('".$_GET["value"]."', '".$type."', ".$conf->entity.", "; $sql.= ($_GET["label"]?"'".addslashes($_GET["label"])."'":'null').", "; $sql.= (! empty($_GET["scandir"])?"'".$_GET["scandir"]."'":"null"); $sql.= ")"; $result2=$db->query($sql); if ($result1 && $result2) { $db->commit(); } else { $db->rollback(); } } /* * View */ $form=new Form($db); llxHeader('',$langs->trans("CompanySetup"),'EN:Module Third Parties setup|FR:Paramétrage_du_module_Tiers'); $linkback=''.$langs->trans("BackToModuleList").''; print_fiche_titre($langs->trans("CompanySetup"),$linkback,'setup'); print "
"; // Choix du module de gestion des codes clients / fournisseurs print_titre($langs->trans("CompanyCodeChecker")); print "\n"; print "\n"; print ' '; print ' '; print ' '; print ' '; print ' '; print "\n"; clearstatcache(); $dir = "../includes/modules/societe/"; $handle = opendir($dir); if ($handle) { $var = true; // Loop on each module find in opened directory while (($file = readdir($handle))!==false) { if (substr($file, 0, 15) == 'mod_codeclient_' && substr($file, -3) == 'php') { $file = substr($file, 0, strlen($file)-4); require_once(DOL_DOCUMENT_ROOT ."/includes/modules/societe/".$file.".php"); $modCodeTiers = new $file; // Show modules according to features level if ($modCodeTiers->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; if ($modCodeTiers->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; $var = !$var; print "\n \n \n"; print '\n"; if ($conf->global->SOCIETE_CODECLIENT_ADDON == "$file") { print "\n"; } else { print ''; } print ''; print ''; } } closedir($handle); } print '
'.$langs->trans("Name").''.$langs->trans("Description").''.$langs->trans("Example").''.$langs->trans("Status").''.$langs->trans("Infos").'
".$modCodeTiers->nom.""; print $modCodeTiers->info($langs); print "'.$modCodeTiers->getExample($langs)."\n"; print img_picto($langs->trans("Activated"),'on'); print "'; print img_picto($langs->trans("Disabled"),'off'); print ''; $s=$modCodeTiers->getToolTip($langs,$soc,-1); print $form->textwithpicto('',$s,1); print '
'; print "
"; // Choix du module de gestion des codes compta print_titre($langs->trans("AccountCodeManager")); print ''; print ''; print ''; print ''; print ''; print ''; print ''; print "\n"; clearstatcache(); $dir = "../includes/modules/societe/"; $handle = opendir($dir); if ($handle) { $var = true; while (($file = readdir($handle))!==false) { if (substr($file, 0, 15) == 'mod_codecompta_' && substr($file, -3) == 'php') { $file = substr($file, 0, strlen($file)-4); require_once(DOL_DOCUMENT_ROOT ."/includes/modules/societe/".$file.".php"); $modCodeCompta = new $file; $var = !$var; print ''; print ''; print '\n"; if ($conf->global->SOCIETE_CODECOMPTA_ADDON == "$file") { print ''; } else { print ''; } print ''; print "\n"; } } closedir($handle); } print "
'.$langs->trans("Name").''.$langs->trans("Description").''.$langs->trans("Example").''.$langs->trans("Status").' 
'.$modCodeCompta->nom."\n"; print $modCodeCompta->info($langs); print ''.$modCodeCompta->getExample($langs)."'; print img_picto($langs->trans("Activated"),'on'); print ''; print img_picto($langs->trans("Disabled"),'off'); print ' 
\n"; // /* * Modeles de documents */ print '
'; print_titre($langs->trans("ModelModules")); // Defini tableau def de modele invoice $def = array(); $sql = "SELECT nom"; $sql.= " FROM ".MAIN_DB_PREFIX."document_model"; $sql.= " WHERE type = 'company'"; $sql.= " AND entity = ".$conf->entity; $resql=$db->query($sql); if ($resql) { $i = 0; $num_rows=$db->num_rows($resql); while ($i < $num_rows) { $array = $db->fetch_array($resql); array_push($def, $array[0]); $i++; } } else { dol_print_error($db); } print ''; print ''; print ''; print ''; print ''; print ''; print "\n"; clearstatcache(); $var=true; foreach ($conf->file->dol_document_root as $dirroot) { $dir = $dirroot . "/includes/modules/societe/doc"; if (is_dir($dir)) { $handle=opendir($dir); if ($handle) { while (($file = readdir($handle))!==false) { if (preg_match('/\.modules\.php$/i',$file)) { $var = !$var; $name = substr($file, 4, strlen($file) -16); $classname = substr($file, 0, strlen($file) -12); require_once($dir.'/'.$file); $module = new $classname($db); print ''; // Activate / Disable if (in_array($name, $def)) { print ""; } else { if (versioncompare($module->phpmin,versionphparray()) > 0) { print ""; } else { print ""; } } // Info $htmltooltip = ''.$langs->trans("Name").': '.$module->name; $htmltooltip.='
'.$langs->trans("Type").': '.($module->type?$module->type:$langs->trans("Unknown")); if ($modele->type == 'pdf') { $htmltooltip.='
'.$langs->trans("Height").'/'.$langs->trans("Width").': '.$module->page_hauteur.'/'.$module->page_largeur; } $htmltooltip.='

'.$langs->trans("FeaturesSupported").':'; $htmltooltip.='
'.$langs->trans("WatermarkOnDraft").': '.yn($module->option_draft_watermark,1,1); print ''; print ''; print "\n"; } } closedir($handle); } } } print '
'.$langs->trans("Name").''.$langs->trans("Description").''.$langs->trans("Status").''.$langs->trans("Infos").'
'; print $module->name; print "\n"; if (method_exists($module,'info')) print $module->info($langs); else print $module->description; print '\n"; //if ($conf->global->COMPANY_ADDON_PDF != "$name") //{ print 'scandir.'&label='.urlencode($module->name).'">'; print img_picto($langs->trans("Enabled"),'on'); print ''; //} //else //{ // print img_picto($langs->trans("Enabled"),'on'); //} print "\n"; print img_picto(dol_escape_htmltag($langs->trans("ErrorModuleRequirePHPVersion",join('.',$module->phpmin))),'off'); print "\n"; print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"),'off').''; print "'; print $form->textwithpicto('',$htmltooltip,1,0); print ''; if ($modele->type == 'pdf') { print ''.img_object($langs->trans("Preview"),'bill').''; } else { print img_object($langs->trans("PreviewNotAvailable"),'generic'); } print '
'; print '
'; print_titre($langs->trans("Other")); // Autres options $html=new Form($db); $var=true; print ''; print ''; print "\n"; print ''."\n"; print ''."\n"; // Utilisation formulaire Ajax sur choix societe $var=!$var; print ''; print ''; print ''; print ""; print ''; if (! $conf->use_javascript_ajax) { print '"; } else { print '"; } print ''; print ''; print '
".$langs->trans("Parameters")."'.$langs->trans("Value").' 
'.$langs->trans("UseSearchToSelectCompany").''; print $langs->trans("NotAvailableWhenAjaxDisabled"); print "'; print $html->selectyesno("activate_usesearchtoselectcompany",$conf->global->COMPANY_USE_SEARCH_TO_SELECT,1); print ''; print ''; print "
'; $db->close(); llxFooter('$Date$ - $Revision$'); ?>