Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop
This commit is contained in:
commit
0a2ed1f678
@ -42,6 +42,7 @@ For users:
|
|||||||
- Qual: Implement same rule for return value of all command line scripts (0 when success, <>0 if error).
|
- Qual: Implement same rule for return value of all command line scripts (0 when success, <>0 if error).
|
||||||
- New: [ task #1005 ] Adapting to Spanish legislation bill numbering
|
- New: [ task #1005 ] Adapting to Spanish legislation bill numbering
|
||||||
- New: [ task #1011 ] Now supplier order and invoice deal with payment terms and mode
|
- New: [ task #1011 ] Now supplier order and invoice deal with payment terms and mode
|
||||||
|
- New: [ task #1014 ] Add option to recursivly add parent category
|
||||||
|
|
||||||
|
|
||||||
For translators:
|
For translators:
|
||||||
|
|||||||
121
htdocs/categories/admin/categorie.php
Normal file
121
htdocs/categories/admin/categorie.php
Normal file
@ -0,0 +1,121 @@
|
|||||||
|
<?php
|
||||||
|
/* Copyright (C) 2008-2011 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
|
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
|
||||||
|
*
|
||||||
|
* 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 <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \file htdocs/categories/admin/categorie.php
|
||||||
|
* \ingroup categories
|
||||||
|
* \brief Categorie admin pages
|
||||||
|
*/
|
||||||
|
|
||||||
|
require '../../main.inc.php';
|
||||||
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/categories.lib.php';
|
||||||
|
|
||||||
|
|
||||||
|
if (!$user->admin)
|
||||||
|
accessforbidden();
|
||||||
|
|
||||||
|
$langs->load("cateogries");
|
||||||
|
|
||||||
|
$action=GETPOST("action");
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Actions
|
||||||
|
*/
|
||||||
|
if (preg_match('/set_(.*)/',$action,$reg))
|
||||||
|
{
|
||||||
|
$code=$reg[1];
|
||||||
|
if (dolibarr_set_const($db, $code, 1, 'chaine', 0, '', $conf->entity) > 0)
|
||||||
|
{
|
||||||
|
header("Location: ".$_SERVER["PHP_SELF"]);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
setEventMessage($db->lasterror(),'errors');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (preg_match('/del_(.*)/',$action,$reg))
|
||||||
|
{
|
||||||
|
$code=$reg[1];
|
||||||
|
if (dolibarr_del_const($db, $code, $conf->entity) > 0)
|
||||||
|
{
|
||||||
|
header("Location: ".$_SERVER["PHP_SELF"]);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
setEventMessage($db->lasterror(),'errors');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* View
|
||||||
|
*/
|
||||||
|
|
||||||
|
llxHeader('',$langs->trans("CategoriesSetup"));
|
||||||
|
|
||||||
|
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
|
||||||
|
print_fiche_titre($langs->trans("CategoriesSetup"),'','setup');
|
||||||
|
|
||||||
|
|
||||||
|
$head=categoriesadmin_prepare_head();
|
||||||
|
|
||||||
|
dol_fiche_head($head, 'setup', $langs->trans("Security"));
|
||||||
|
|
||||||
|
|
||||||
|
print '<table class="noborder" width="100%">';
|
||||||
|
print '<tr class="liste_titre">';
|
||||||
|
print '<td>'.$langs->trans("Description").'</td>';
|
||||||
|
print '<td align="center" width="20"> </td>';
|
||||||
|
print '<td align="center" width="100">'.$langs->trans("Value").'</td>'."\n";
|
||||||
|
print '</tr>';
|
||||||
|
|
||||||
|
$var=true;
|
||||||
|
$form = new Form($db);
|
||||||
|
|
||||||
|
// Mail required for members
|
||||||
|
$var=!$var;
|
||||||
|
print '<tr '.$bc[$var].'>';
|
||||||
|
print '<td>'.$langs->trans("CategorieRecursiv").'</td>';
|
||||||
|
print '<td align="center" width="20"> </td>';
|
||||||
|
|
||||||
|
print '<td align="center" width="100">';
|
||||||
|
if ($conf->use_javascript_ajax)
|
||||||
|
{
|
||||||
|
print ajax_constantonoff('CATEGORIE_RECURSIV_ADD');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if($conf->global->CATEGORIE_RECURSIV_ADD == 0)
|
||||||
|
{
|
||||||
|
print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_CATEGORIE_RECURSIV_ADD">'.img_picto($langs->trans("Disabled"),'off').'</a>';
|
||||||
|
}
|
||||||
|
else if($conf->global->CATEGORIE_RECURSIV_ADD == 1)
|
||||||
|
{
|
||||||
|
print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_CATEGORIE_RECURSIV_ADD">'.img_picto($langs->trans("Enabled"),'on').'</a>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
print '</td></tr>';
|
||||||
|
|
||||||
|
print '</table>';
|
||||||
|
|
||||||
|
$db->close();
|
||||||
|
llxFooter();
|
||||||
@ -389,6 +389,8 @@ class Categorie
|
|||||||
*/
|
*/
|
||||||
function add_type($obj,$type)
|
function add_type($obj,$type)
|
||||||
{
|
{
|
||||||
|
global $conf;
|
||||||
|
|
||||||
if ($this->id == -1) return -2;
|
if ($this->id == -1) return -2;
|
||||||
|
|
||||||
if ($type == 'company') $type='societe';
|
if ($type == 'company') $type='societe';
|
||||||
@ -405,6 +407,32 @@ class Categorie
|
|||||||
dol_syslog(get_class($this).'::add_type sql='.$sql);
|
dol_syslog(get_class($this).'::add_type sql='.$sql);
|
||||||
if ($this->db->query($sql))
|
if ($this->db->query($sql))
|
||||||
{
|
{
|
||||||
|
if (!empty($conf->global->CATEGORIE_RECURSIV_ADD)) {
|
||||||
|
$sql = 'SELECT fk_parent FROM '.MAIN_DB_PREFIX.'categorie';
|
||||||
|
$sql.= " WHERE rowid = '".$this->id."'";
|
||||||
|
|
||||||
|
dol_syslog(get_class($this)."::add_type sql=".$sql);
|
||||||
|
$resql=$this->db->query($sql);
|
||||||
|
if ($resql)
|
||||||
|
{
|
||||||
|
if ($this->db->num_rows($resql) > 0)
|
||||||
|
{
|
||||||
|
$objparent = $this->db->fetch_object($resql);
|
||||||
|
|
||||||
|
if (!empty($objparent->fk_parent)) {
|
||||||
|
$cat = new Categorie($this->db);
|
||||||
|
$cat->id=$objparent->fk_parent;
|
||||||
|
$cat->add_type($obj, $type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->error=$this->db->error().' sql='.$sql;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@ -60,4 +60,35 @@ function categories_prepare_head($object,$type)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prepare array with list of tabs
|
||||||
|
*
|
||||||
|
* @return array Array of tabs to show
|
||||||
|
*/
|
||||||
|
function categoriesadmin_prepare_head()
|
||||||
|
{
|
||||||
|
global $langs, $conf, $user;
|
||||||
|
|
||||||
|
$langs->load("categories");
|
||||||
|
|
||||||
|
$h = 0;
|
||||||
|
$head = array();
|
||||||
|
|
||||||
|
$head[$h][0] = DOL_URL_ROOT.'/categories/admin/categorie.php';
|
||||||
|
$head[$h][1] = $langs->trans("Setup");
|
||||||
|
$head[$h][2] = 'setup';
|
||||||
|
$h++;
|
||||||
|
|
||||||
|
// Show more tabs from modules
|
||||||
|
// Entries must be declared in modules descriptor with line
|
||||||
|
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
|
||||||
|
// $this->tabs = array('entity:-tabname); to remove a tab
|
||||||
|
complete_head_from_modules($conf,$langs,$object,$head,$h,'categoriesadmin');
|
||||||
|
|
||||||
|
complete_head_from_modules($conf,$langs,$object,$head,$h,'categoriesadmin','remove');
|
||||||
|
|
||||||
|
return $head;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
@ -68,6 +68,13 @@ class modCategorie extends DolibarrModules
|
|||||||
|
|
||||||
// Constantes
|
// Constantes
|
||||||
$this->const = array();
|
$this->const = array();
|
||||||
|
$r=0;
|
||||||
|
$this->const[$r][0] = "CATEGORIE_RECURSIV_ADD";
|
||||||
|
$this->const[$r][1] = "yesno";
|
||||||
|
$this->const[$r][2] = "0";
|
||||||
|
$this->const[$r][3] = 'Affect parent categories';
|
||||||
|
$this->const[$r][4] = 0;
|
||||||
|
$r++;
|
||||||
|
|
||||||
// Boxes
|
// Boxes
|
||||||
$this->boxes = array();
|
$this->boxes = array();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user