';
+
print "";
}
diff --git a/htdocs/includes/modules/modSociete.class.php b/htdocs/includes/modules/modSociete.class.php
index f0b4d977d7d..d02511f7cdf 100644
--- a/htdocs/includes/modules/modSociete.class.php
+++ b/htdocs/includes/modules/modSociete.class.php
@@ -59,7 +59,7 @@ class modSociete extends DolibarrModules
$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
$this->special = 0;
- $this->config_page_url = array("societe.php");
+ $this->config_page_url = array("societe.php@societe");
// Name of image file used for this module.
$this->picto='company';
diff --git a/htdocs/lib/admin_extrafields.inc.php b/htdocs/lib/admin_extrafields.inc.php
new file mode 100644
index 00000000000..1854d635b48
--- /dev/null
+++ b/htdocs/lib/admin_extrafields.inc.php
@@ -0,0 +1,131 @@
+
+ *
+ * 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, see .
+ * or see http://www.gnu.org/
+ */
+
+/**
+ * \file htdocs/lib/admin_extrafields.inc.php
+ * \brief Code for actions on extrafields admin pages
+ */
+
+// Add attribute
+if ($action == 'add')
+{
+ if ($_POST["button"] != $langs->trans("Cancel"))
+ {
+ // Check values
+ if (GETPOST('type')=='varchar' && GETPOST('size') > 255)
+ {
+ $error++;
+ $langs->load("errors");
+ $mesg=$langs->trans("ErrorSizeTooLongForVarcharType");
+ $action = 'create';
+ }
+
+ if (! $error)
+ {
+ // Type et taille non encore pris en compte => varchar(255)
+ if (isset($_POST["attrname"]) && preg_match("/^\w[a-zA-Z0-9-_]*$/",$_POST['attrname']))
+ {
+ $result=$extrafields->addExtraField($_POST['attrname'],$_POST['label'],$_POST['type'],$_POST['pos'],$_POST['size'],$elementtype);
+ if ($result > 0)
+ {
+ Header("Location: ".$_SERVER["PHP_SELF"]);
+ exit;
+ }
+ else
+ {
+ $error++;
+ $mesg=$extrafields->error;
+ }
+ }
+ else
+ {
+ $error++;
+ $langs->load("errors");
+ $mesg=$langs->trans("ErrorFieldCanNotContainSpecialCharacters",$langs->transnoentities("AttributeCode"));
+ $action = 'create';
+ }
+ }
+ }
+}
+
+// Rename field
+if ($action == 'update')
+{
+ if ($_POST["button"] != $langs->trans("Cancel"))
+ {
+ // Check values
+ if (GETPOST('type')=='varchar' && GETPOST('size') > 255)
+ {
+ $error++;
+ $langs->load("errors");
+ $mesg=$langs->trans("ErrorSizeTooLongForVarcharType");
+ $action = 'edit';
+ }
+
+ if (! $error)
+ {
+ if (isset($_POST["attrname"]) && preg_match("/^\w[a-zA-Z0-9-_]*$/",$_POST['attrname']))
+ {
+ $result=$extrafields->update($_POST['attrname'],$_POST['type'],$_POST['size'],$elementtype);
+ if ($result > 0)
+ {
+ if (isset($_POST['label']))
+ {
+ $extrafields->update_label($_POST['attrname'],$_POST['label'],$_POST['type'],$_POST['size'],$elementtype);
+ }
+ Header("Location: ".$_SERVER["PHP_SELF"]);
+ exit;
+ }
+ else
+ {
+ $error++;
+ $mesg=$extrafields->error;
+ }
+ }
+ else
+ {
+ $error++;
+ $langs->load("errors");
+ $mesg=$langs->trans("ErrorFieldCanNotContainSpecialCharacters",$langs->transnoentities("AttributeCode"));
+ }
+ }
+ }
+}
+
+// Delete attribute
+if ($action == 'delete')
+{
+ if(isset($_GET["attrname"]) && preg_match("/^\w[a-zA-Z0-9-_]*$/",$_GET["attrname"]))
+ {
+ $result=$extrafields->delete($_GET["attrname"],$elementtype);
+ if ($result >= 0)
+ {
+ Header("Location: ".$_SERVER["PHP_SELF"]);
+ exit;
+ }
+ else $mesg=$extrafields->error;
+ }
+ else
+ {
+ $error++;
+ $langs->load("errors");
+ $mesg=$langs->trans("ErrorFieldCanNotContainSpecialCharacters",$langs->transnoentities("AttributeCode"));
+ }
+}
+
+?>
\ No newline at end of file
diff --git a/htdocs/lib/company.lib.php b/htdocs/lib/company.lib.php
index 6392ebf5bca..043fc603226 100644
--- a/htdocs/lib/company.lib.php
+++ b/htdocs/lib/company.lib.php
@@ -28,8 +28,8 @@
/**
* Return array of tabs to used on pages for third parties cards.
*
- * @param $object Object company shown
- * @return array Array of tabs
+ * @param Object $object Object company shown
+ * @return array Array of tabs
*/
function societe_prepare_head($object)
{
@@ -132,7 +132,7 @@ function societe_prepare_head($object)
/**
* Return array of tabs to used on page
*
- * @param $object
+ * @param Object $object Object for tabs
* @return
*/
function societe_prepare_head2($object)
@@ -173,9 +173,10 @@ function societe_prepare_head2($object)
/**
- * Return array head with list of tabs to view object informations
- * @param object Thirdparty
- * @return array head
+ * Return array head with list of tabs to view object informations.
+ *
+ * @param Object $object Thirdparty
+ * @return array head array with tabs
*/
function societe_admin_prepare_head($object)
{
@@ -184,7 +185,7 @@ function societe_admin_prepare_head($object)
$h = 0;
$head = array();
- $head[$h][0] = DOL_URL_ROOT.'/admin/societe.php';
+ $head[$h][0] = DOL_URL_ROOT.'/societe/admin/societe.php';
$head[$h][1] = $langs->trans("Miscellanous");
$head[$h][2] = 'general';
$h++;
@@ -195,7 +196,7 @@ function societe_admin_prepare_head($object)
// $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
complete_head_from_modules($conf,$langs,$object,$head,$h,'company_admin');
- $head[$h][0] = DOL_URL_ROOT.'/admin/societe_extrafields.php';
+ $head[$h][0] = DOL_URL_ROOT.'/societe/admin/societe_extrafields.php';
$head[$h][1] = $langs->trans("ExtraFields");
$head[$h][2] = 'attributes';
$h++;
@@ -210,16 +211,16 @@ function societe_admin_prepare_head($object)
/**
* Return country label, code or id from an id or a code
*
- * @param id Id or code of country
- * @param withcode '0'=Return label,
- * '1'=Return code + label,
- * '2'=Return code from id,
- * '3'=Return id from code,
- * 'all'=Return array('id'=>,'code'=>,'label'=>)
- * @param dbtouse Database handler (using in global way may fail because of conflicts with some autoload features)
- * @param outputlangs Langs object for output translation
- * @param entconv 0=Return value without entities and not converted to output charset
- * @return string String with country code or translated country name
+ * @param int $id Id or code of country
+ * @param int $withcode '0'=Return label,
+ * '1'=Return code + label,
+ * '2'=Return code from id,
+ * '3'=Return id from code,
+ * 'all'=Return array('id'=>,'code'=>,'label'=>)
+ * @param DoliDB $dbtouse Database handler (using in global way may fail because of conflicts with some autoload features)
+ * @param Translate $outputlangs Langs object for output translation
+ * @param int $entconv 0=Return value without entities and not converted to output charset
+ * @return string String with country code or translated country name
*/
function getCountry($id,$withcode='',$dbtouse=0,$outputlangs='',$entconv=1)
{
@@ -263,13 +264,13 @@ function getCountry($id,$withcode='',$dbtouse=0,$outputlangs='',$entconv=1)
/**
* Return state translated from an id
*
- * @param id id of state (province/departement)
- * @param withcode '0'=Return label,
- * '1'=Return string code + label,
- * '2'=Return code,
- * 'all'=return array('id'=>,'code'=>,'label'=>)
- * @param dbtouse Database handler (using in global way may fail because of conflicts with some autoload features)
- * @return string String with state code or translated state name
+ * @param int $id id of state (province/departement)
+ * @param int $withcode '0'=Return label,
+ * '1'=Return string code + label,
+ * '2'=Return code,
+ * 'all'=return array('id'=>,'code'=>,'label'=>)
+ * @param DoliDB $dbtouse Database handler (using in global way may fail because of conflicts with some autoload features)
+ * @return string String with state code or translated state name
*/
function getState($id,$withcode='',$dbtouse=0)
{
@@ -304,9 +305,9 @@ function getState($id,$withcode='',$dbtouse=0)
/**
* Retourne le nom traduit ou code+nom d'une devise
*
- * @param code_iso Code iso de la devise
- * @param withcode '1'=affiche code + nom
- * @return string Nom traduit de la devise
+ * @param string $code_iso Code iso de la devise
+ * @param int $withcode '1'=affiche code + nom
+ * @return string Nom traduit de la devise
*/
function currency_name($code_iso,$withcode='')
{
@@ -345,8 +346,8 @@ function currency_name($code_iso,$withcode='')
/**
* Retourne le nom traduit de la forme juridique
*
- * @param code Code de la forme juridique
- * @return string Nom traduit du pays
+ * @param string $code Code de la forme juridique
+ * @return string Nom traduit du pays
*/
function getFormeJuridiqueLabel($code)
{
diff --git a/htdocs/admin/societe.php b/htdocs/societe/admin/societe.php
similarity index 82%
rename from htdocs/admin/societe.php
rename to htdocs/societe/admin/societe.php
index 59e6b70bb68..3a8070e3c52 100644
--- a/htdocs/admin/societe.php
+++ b/htdocs/societe/admin/societe.php
@@ -25,17 +25,18 @@
* \brief Third party module setup page
*/
-require("../main.inc.php");
+require("../../main.inc.php");
require_once(DOL_DOCUMENT_ROOT."/lib/admin.lib.php");
require_once(DOL_DOCUMENT_ROOT."/lib/company.lib.php");
$langs->load("admin");
-if (!$user->admin) accessforbidden();
-
$action=GETPOST("action");
$value=GETPOST("value");
+if (!$user->admin) accessforbidden();
+
+
/*
* Actions
@@ -199,6 +200,8 @@ if ($action == 'setprofid')
* View
*/
+clearstatcache();
+
$form=new Form($db);
$help_url='EN:Module Third Parties setup|FR:Paramétrage_du_module_Tiers|ES:Configuración_del_módulo_terceros';
@@ -228,57 +231,57 @@ print '
'.$langs->trans("Status").'
';
print '
'.$langs->trans("Infos").'
';
print "\n";
-clearstatcache();
-
-$dir = "../includes/modules/societe/";
-$handle = opendir($dir);
-if (is_resource($handle))
+$var = true;
+foreach ($conf->file->dol_document_root as $dirroot)
{
- $var = true;
+ $dir = $dirroot . "/includes/modules/societe/";
+ $handle = opendir($dir);
+ if (is_resource($handle))
+ {
+ // 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, dol_strlen($file)-4);
- // 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, dol_strlen($file)-4);
+ dol_include_once("/includes/modules/societe/".$file.".php");
- require_once(DOL_DOCUMENT_ROOT ."/includes/modules/societe/".$file.".php");
+ $modCodeTiers = new $file;
- $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;
- // 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 "