Qual: Mutualized common code. Move module admin pages into admin
directory.
This commit is contained in:
parent
fa63f0fe0c
commit
1df9d13f04
@ -115,6 +115,9 @@ $head = member_admin_prepare_head($adh);
|
||||
dol_fiche_head($head, 'general', $langs->trans("Member"), 0, 'user');
|
||||
|
||||
|
||||
dol_htmloutput_mesg($mesg);
|
||||
|
||||
|
||||
print_fiche_titre($langs->trans("MemberMainOptions"),'','');
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre">';
|
||||
@ -337,12 +340,9 @@ dol_fiche_end();
|
||||
|
||||
$db->close();
|
||||
|
||||
print '<br>';
|
||||
|
||||
llxFooter();
|
||||
|
||||
|
||||
|
||||
function form_constantes($tableau)
|
||||
{
|
||||
global $db,$bc,$langs,$conf,$_Avery_Labels;
|
||||
@ -475,10 +475,4 @@ function form_constantes($tableau)
|
||||
print '</table>';
|
||||
}
|
||||
|
||||
dol_htmloutput_mesg($mesg);
|
||||
|
||||
$db->close();
|
||||
|
||||
llxFooter();
|
||||
|
||||
?>
|
||||
@ -45,119 +45,14 @@ $type2label=array(
|
||||
$action=GETPOST("action");
|
||||
$elementtype='member';
|
||||
|
||||
if (!$user->admin)
|
||||
accessforbidden();
|
||||
if (!$user->admin) accessforbidden();
|
||||
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
|
||||
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"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Suppression attribut
|
||||
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"));
|
||||
}
|
||||
}
|
||||
require(DOL_DOCUMENT_ROOT."/lib/admin_extrafields.inc.php");
|
||||
|
||||
|
||||
|
||||
@ -257,10 +152,12 @@ if ($action == 'create')
|
||||
// Size
|
||||
print '<tr><td class="fieldrequired" required>'.$langs->trans("Size").'</td><td><input type="text" name="size" size="5" value="'.(GETPOST('size')?GETPOST('size'):'255').'"></td></tr>';
|
||||
|
||||
print '<tr><td colspan="2" align="center"><input type="submit" name="button" class="button" value="'.$langs->trans("Save").'"> ';
|
||||
print '<input type="submit" name="button" class="button" value="'.$langs->trans("Cancel").'"></td></tr>';
|
||||
print "</form>\n";
|
||||
print "</table>\n";
|
||||
print '</table>';
|
||||
|
||||
print '<center><br><input type="submit" name="button" class="button" value="'.$langs->trans("Save").'"> ';
|
||||
print '<input type="submit" name="button" class="button" value="'.$langs->trans("Cancel").'"></center>';
|
||||
|
||||
print "</form>\n";
|
||||
}
|
||||
|
||||
/* ************************************************************************** */
|
||||
@ -301,9 +198,12 @@ if ($_GET["attrname"] && $action == 'edit')
|
||||
print '</td></tr>';
|
||||
// Size
|
||||
print '<tr><td class="fieldrequired" required>'.$langs->trans("Size").'</td><td class="valeur"><input type="text" name="size" size="5" value="'.$size.'"></td></tr>';
|
||||
print '<tr><td colspan="2" align="center"><input type="submit" class="button" value="'.$langs->trans("Save").'"> ';
|
||||
print '<input type="submit" name="button" class="button" value="'.$langs->trans("Cancel").'"></td></tr>';
|
||||
|
||||
print '</table>';
|
||||
|
||||
print '<center><br><input type="submit" name="button" class="button" value="'.$langs->trans("Save").'"> ';
|
||||
print '<input type="submit" name="button" class="button" value="'.$langs->trans("Cancel").'"></center>';
|
||||
|
||||
print "</form>";
|
||||
|
||||
}
|
||||
|
||||
@ -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';
|
||||
|
||||
|
||||
131
htdocs/lib/admin_extrafields.inc.php
Normal file
131
htdocs/lib/admin_extrafields.inc.php
Normal file
@ -0,0 +1,131 @@
|
||||
<?php
|
||||
/* Copyright (C) 2011 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
* 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"));
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@ -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)
|
||||
{
|
||||
|
||||
@ -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 ' <td align="center" width="80">'.$langs->trans("Status").'</td>';
|
||||
print ' <td align="center" width="60">'.$langs->trans("Infos").'</td>';
|
||||
print "</tr>\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 "<tr ".$bc[$var].">\n <td width=\"140\">".$modCodeTiers->nom."</td>\n <td>";
|
||||
print $modCodeTiers->info($langs);
|
||||
print "</td>\n";
|
||||
print '<td nowrap="nowrap">'.$modCodeTiers->getExample($langs)."</td>\n";
|
||||
|
||||
$var = !$var;
|
||||
print "<tr ".$bc[$var].">\n <td width=\"140\">".$modCodeTiers->nom."</td>\n <td>";
|
||||
print $modCodeTiers->info($langs);
|
||||
print "</td>\n";
|
||||
print '<td nowrap="nowrap">'.$modCodeTiers->getExample($langs)."</td>\n";
|
||||
if ($conf->global->SOCIETE_CODECLIENT_ADDON == "$file")
|
||||
{
|
||||
print "<td align=\"center\">\n";
|
||||
print img_picto($langs->trans("Activated"),'switch_on');
|
||||
print "</td>\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<td align="center"><a href="'.$_SERVER['PHP_SELF'].'?action=setcodeclient&value='.$file.'">';
|
||||
print img_picto($langs->trans("Disabled"),'switch_off');
|
||||
print '</a></td>';
|
||||
}
|
||||
|
||||
if ($conf->global->SOCIETE_CODECLIENT_ADDON == "$file")
|
||||
{
|
||||
print "<td align=\"center\">\n";
|
||||
print img_picto($langs->trans("Activated"),'switch_on');
|
||||
print "</td>\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<td align="center"><a href="'.$_SERVER['PHP_SELF'].'?action=setcodeclient&value='.$file.'">';
|
||||
print img_picto($langs->trans("Disabled"),'switch_off');
|
||||
print '</a></td>';
|
||||
}
|
||||
print '<td align="center">';
|
||||
$s=$modCodeTiers->getToolTip($langs,null,-1);
|
||||
print $form->textwithpicto('',$s,1);
|
||||
print '</td>';
|
||||
|
||||
print '<td align="center">';
|
||||
$s=$modCodeTiers->getToolTip($langs,null,-1);
|
||||
print $form->textwithpicto('',$s,1);
|
||||
print '</td>';
|
||||
|
||||
print '</tr>';
|
||||
}
|
||||
}
|
||||
closedir($handle);
|
||||
print '</tr>';
|
||||
}
|
||||
}
|
||||
closedir($handle);
|
||||
}
|
||||
}
|
||||
print '</table>';
|
||||
|
||||
@ -299,50 +302,51 @@ print '<td align="center" width="80">'.$langs->trans("Status").'</td>';
|
||||
print '<td align="center" width="60"> </td>';
|
||||
print "</tr>\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;
|
||||
while (($file = readdir($handle))!==false)
|
||||
{
|
||||
if (substr($file, 0, 15) == 'mod_codecompta_' && substr($file, -3) == 'php')
|
||||
{
|
||||
$file = substr($file, 0, dol_strlen($file)-4);
|
||||
$dir = $dirroot . "/includes/modules/societe/";
|
||||
$handle = opendir($dir);
|
||||
if (is_resource($handle))
|
||||
{
|
||||
while (($file = readdir($handle))!==false)
|
||||
{
|
||||
if (substr($file, 0, 15) == 'mod_codecompta_' && substr($file, -3) == 'php')
|
||||
{
|
||||
$file = substr($file, 0, dol_strlen($file)-4);
|
||||
|
||||
require_once(DOL_DOCUMENT_ROOT ."/includes/modules/societe/".$file.".php");
|
||||
dol_include_once("/includes/modules/societe/".$file.".php");
|
||||
|
||||
$modCodeCompta = new $file;
|
||||
$var = !$var;
|
||||
$modCodeCompta = new $file;
|
||||
$var = !$var;
|
||||
|
||||
print '<tr '.$bc[$var].'>';
|
||||
print '<td>'.$modCodeCompta->nom."</td><td>\n";
|
||||
print $modCodeCompta->info($langs);
|
||||
print '</td>';
|
||||
print '<td nowrap="nowrap">'.$modCodeCompta->getExample($langs)."</td>\n";
|
||||
print '<tr '.$bc[$var].'>';
|
||||
print '<td>'.$modCodeCompta->nom."</td><td>\n";
|
||||
print $modCodeCompta->info($langs);
|
||||
print '</td>';
|
||||
print '<td nowrap="nowrap">'.$modCodeCompta->getExample($langs)."</td>\n";
|
||||
|
||||
if ($conf->global->SOCIETE_CODECOMPTA_ADDON == "$file")
|
||||
{
|
||||
print '<td align="center">';
|
||||
print img_picto($langs->trans("Activated"),'switch_on');
|
||||
print '</td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<td align="center"><a href="'.$_SERVER['PHP_SELF'].'?action=setcodecompta&value='.$file.'">';
|
||||
print img_picto($langs->trans("Disabled"),'switch_off');
|
||||
print '</a></td>';
|
||||
}
|
||||
print '<td align="center">';
|
||||
$s=$modCodeCompta->getToolTip($langs,null,-1);
|
||||
print $form->textwithpicto('',$s,1);
|
||||
print '</td>';
|
||||
print "</tr>\n";
|
||||
}
|
||||
}
|
||||
closedir($handle);
|
||||
if ($conf->global->SOCIETE_CODECOMPTA_ADDON == "$file")
|
||||
{
|
||||
print '<td align="center">';
|
||||
print img_picto($langs->trans("Activated"),'switch_on');
|
||||
print '</td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<td align="center"><a href="'.$_SERVER['PHP_SELF'].'?action=setcodecompta&value='.$file.'">';
|
||||
print img_picto($langs->trans("Disabled"),'switch_off');
|
||||
print '</a></td>';
|
||||
}
|
||||
print '<td align="center">';
|
||||
$s=$modCodeCompta->getToolTip($langs,null,-1);
|
||||
print $form->textwithpicto('',$s,1);
|
||||
print '</td>';
|
||||
print "</tr>\n";
|
||||
}
|
||||
}
|
||||
closedir($handle);
|
||||
}
|
||||
}
|
||||
print "</table>\n";
|
||||
|
||||
@ -384,9 +388,6 @@ print '<td align="center" width="80">'.$langs->trans("Status").'</td>';
|
||||
print '<td align="center" width="60">'.$langs->trans("Infos").'</td>';
|
||||
print "</tr>\n";
|
||||
|
||||
clearstatcache();
|
||||
|
||||
|
||||
$var=true;
|
||||
foreach ($conf->file->dol_document_root as $dirroot)
|
||||
{
|
||||
@ -23,7 +23,7 @@
|
||||
* \brief Page to setup extra fields of third party
|
||||
*/
|
||||
|
||||
require("../main.inc.php");
|
||||
require("../../main.inc.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/lib/company.lib.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/core/class/extrafields.class.php");
|
||||
|
||||
@ -45,119 +45,14 @@ $type2label=array(
|
||||
$action=GETPOST("action");
|
||||
$elementtype='company';
|
||||
|
||||
if (!$user->admin)
|
||||
accessforbidden();
|
||||
if (!$user->admin) accessforbidden();
|
||||
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
|
||||
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"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Suppression attribut
|
||||
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"));
|
||||
}
|
||||
}
|
||||
require(DOL_DOCUMENT_ROOT."/lib/admin_extrafields.inc.php");
|
||||
|
||||
|
||||
|
||||
@ -257,10 +152,12 @@ if ($action == 'create')
|
||||
// Size
|
||||
print '<tr><td class="fieldrequired" required>'.$langs->trans("Size").'</td><td><input type="text" name="size" size="5" value="'.(GETPOST('size')?GETPOST('size'):'255').'"></td></tr>';
|
||||
|
||||
print '<tr><td colspan="2" align="center"><input type="submit" name="button" class="button" value="'.$langs->trans("Save").'"> ';
|
||||
print '<input type="submit" name="button" class="button" value="'.$langs->trans("Cancel").'"></td></tr>';
|
||||
print "</form>\n";
|
||||
print "</table>\n";
|
||||
|
||||
print '<center><br><input type="submit" name="button" class="button" value="'.$langs->trans("Save").'"> ';
|
||||
print '<input type="submit" name="button" class="button" value="'.$langs->trans("Cancel").'"></center>';
|
||||
|
||||
print "</form>\n";
|
||||
}
|
||||
|
||||
/* ************************************************************************** */
|
||||
@ -301,9 +198,12 @@ if ($_GET["attrname"] && $action == 'edit')
|
||||
print '</td></tr>';
|
||||
// Size
|
||||
print '<tr><td class="fieldrequired" required>'.$langs->trans("Size").'</td><td class="valeur"><input type="text" name="size" size="5" value="'.$size.'"></td></tr>';
|
||||
print '<tr><td colspan="2" align="center"><input type="submit" class="button" value="'.$langs->trans("Save").'"> ';
|
||||
print '<input type="submit" name="button" class="button" value="'.$langs->trans("Cancel").'"></td></tr>';
|
||||
|
||||
print '</table>';
|
||||
|
||||
print '<center><br><input type="submit" name="button" class="button" value="'.$langs->trans("Save").'"> ';
|
||||
print '<input type="submit" name="button" class="button" value="'.$langs->trans("Cancel").'"></center>';
|
||||
|
||||
print "</form>";
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user