Category extrafields on categories: edit and view
This commit is contained in:
parent
d9baae3456
commit
e2b47b9919
@ -104,6 +104,8 @@ class Categorie extends CommonObject
|
|||||||
$this->type = $res['type'];
|
$this->type = $res['type'];
|
||||||
$this->entity = $res['entity'];
|
$this->entity = $res['entity'];
|
||||||
|
|
||||||
|
$this->fetch_optionals($this->id,$extralabels);
|
||||||
|
|
||||||
$this->db->free($resql);
|
$this->db->free($resql);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
@ -131,7 +133,7 @@ class Categorie extends CommonObject
|
|||||||
*/
|
*/
|
||||||
function create($user='')
|
function create($user='')
|
||||||
{
|
{
|
||||||
global $conf,$langs;
|
global $conf,$langs,$hookmanager;
|
||||||
$langs->load('categories');
|
$langs->load('categories');
|
||||||
|
|
||||||
$error=0;
|
$error=0;
|
||||||
@ -190,6 +192,24 @@ class Categorie extends CommonObject
|
|||||||
{
|
{
|
||||||
$this->id = $id;
|
$this->id = $id;
|
||||||
|
|
||||||
|
// Actions on extra fields (by external module or standard code)
|
||||||
|
// FIXME le hook fait double emploi avec le trigger !!
|
||||||
|
$hookmanager->initHooks(array('HookModuleNamedao'));
|
||||||
|
$parameters=array('socid'=>$this->id);
|
||||||
|
$reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
|
||||||
|
if (empty($reshook))
|
||||||
|
{
|
||||||
|
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
|
||||||
|
{
|
||||||
|
$result=$this->insertExtraFields();
|
||||||
|
if ($result < 0)
|
||||||
|
{
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if ($reshook < 0) $error++;
|
||||||
|
|
||||||
// Appel des triggers
|
// Appel des triggers
|
||||||
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
|
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
|
||||||
$interface=new Interfaces($this->db);
|
$interface=new Interfaces($this->db);
|
||||||
@ -225,7 +245,7 @@ class Categorie extends CommonObject
|
|||||||
*/
|
*/
|
||||||
function update($user='')
|
function update($user='')
|
||||||
{
|
{
|
||||||
global $conf, $langs;
|
global $conf, $langs,$hookmanager;
|
||||||
|
|
||||||
$error=0;
|
$error=0;
|
||||||
|
|
||||||
@ -258,8 +278,28 @@ class Categorie extends CommonObject
|
|||||||
dol_syslog(get_class($this)."::update sql=".$sql);
|
dol_syslog(get_class($this)."::update sql=".$sql);
|
||||||
if ($this->db->query($sql))
|
if ($this->db->query($sql))
|
||||||
{
|
{
|
||||||
|
|
||||||
|
// Actions on extra fields (by external module or standard code)
|
||||||
|
// FIXME le hook fait double emploi avec le trigger !!
|
||||||
|
$hookmanager->initHooks(array('HookCategorydao'));
|
||||||
|
$parameters=array();
|
||||||
|
$reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
|
||||||
|
if (empty($reshook))
|
||||||
|
{
|
||||||
|
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
|
||||||
|
{
|
||||||
|
$result=$this->insertExtraFields();
|
||||||
|
if ($result < 0)
|
||||||
|
{
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if ($reshook < 0) $error++;
|
||||||
|
|
||||||
$this->db->commit();
|
$this->db->commit();
|
||||||
|
|
||||||
|
|
||||||
// Appel des triggers
|
// Appel des triggers
|
||||||
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
|
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
|
||||||
$interface=new Interfaces($this->db);
|
$interface=new Interfaces($this->db);
|
||||||
|
|||||||
@ -26,6 +26,7 @@
|
|||||||
|
|
||||||
require '../main.inc.php';
|
require '../main.inc.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
|
||||||
|
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
|
||||||
|
|
||||||
$langs->load("categories");
|
$langs->load("categories");
|
||||||
|
|
||||||
@ -50,7 +51,10 @@ if ($id == "")
|
|||||||
// Security check
|
// Security check
|
||||||
$result = restrictedArea($user, 'categorie', $id, '&category');
|
$result = restrictedArea($user, 'categorie', $id, '&category');
|
||||||
|
|
||||||
|
$object = new Categorie($db);
|
||||||
|
|
||||||
|
$extrafields = new ExtraFields($db);
|
||||||
|
$extralabels=$extrafields->fetch_name_optionals_label($object->table_element);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Actions
|
* Actions
|
||||||
@ -85,6 +89,8 @@ if ($action == 'update' && $user->rights->categorie->creer)
|
|||||||
}
|
}
|
||||||
if (empty($categorie->error))
|
if (empty($categorie->error))
|
||||||
{
|
{
|
||||||
|
$ret = $extrafields->setOptionalsFromPost($extralabels,$categorie);
|
||||||
|
|
||||||
if ($categorie->update($user) > 0)
|
if ($categorie->update($user) > 0)
|
||||||
{
|
{
|
||||||
header('Location: '.DOL_URL_ROOT.'/categories/viewcat.php?id='.$categorie->id.'&type='.$type);
|
header('Location: '.DOL_URL_ROOT.'/categories/viewcat.php?id='.$categorie->id.'&type='.$type);
|
||||||
@ -115,7 +121,6 @@ print_fiche_titre($langs->trans("ModifCat"));
|
|||||||
dol_htmloutput_errors($mesg);
|
dol_htmloutput_errors($mesg);
|
||||||
|
|
||||||
|
|
||||||
$object = new Categorie($db);
|
|
||||||
$object->fetch($id);
|
$object->fetch($id);
|
||||||
|
|
||||||
$form = new Form($db);
|
$form = new Form($db);
|
||||||
@ -153,6 +158,12 @@ print '<tr><td>'.$langs->trans("In").'</td><td>';
|
|||||||
print $form->select_all_categories($type,$object->fk_parent,'parent',64,$object->id);
|
print $form->select_all_categories($type,$object->fk_parent,'parent',64,$object->id);
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|
||||||
|
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
|
||||||
|
if (empty($reshook) && ! empty($extrafields->attribute_label))
|
||||||
|
{
|
||||||
|
print $object->showOptionals($extrafields,'edit');
|
||||||
|
}
|
||||||
|
|
||||||
print '</table>';
|
print '</table>';
|
||||||
print '<br>';
|
print '<br>';
|
||||||
|
|
||||||
|
|||||||
@ -27,6 +27,8 @@
|
|||||||
require '../main.inc.php';
|
require '../main.inc.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/categories.lib.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/categories.lib.php';
|
||||||
|
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
|
||||||
|
|
||||||
|
|
||||||
$langs->load("categories");
|
$langs->load("categories");
|
||||||
|
|
||||||
@ -49,6 +51,7 @@ $result = restrictedArea($user, 'categorie', $id, '&category');
|
|||||||
|
|
||||||
$object = new Categorie($db);
|
$object = new Categorie($db);
|
||||||
$result=$object->fetch($id);
|
$result=$object->fetch($id);
|
||||||
|
$object->fetch_optionals($id,$extralabels);
|
||||||
if ($result <= 0)
|
if ($result <= 0)
|
||||||
{
|
{
|
||||||
dol_print_error($db,$object->error);
|
dol_print_error($db,$object->error);
|
||||||
@ -57,6 +60,8 @@ if ($result <= 0)
|
|||||||
|
|
||||||
$type=$object->type;
|
$type=$object->type;
|
||||||
|
|
||||||
|
$extrafields = new ExtraFields($db);
|
||||||
|
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Actions
|
* Actions
|
||||||
@ -166,6 +171,12 @@ print $langs->trans("Description").'</td><td>';
|
|||||||
print nl2br($object->description);
|
print nl2br($object->description);
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|
||||||
|
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
|
||||||
|
if (empty($reshook) && ! empty($extrafields->attribute_label))
|
||||||
|
{
|
||||||
|
print $object->showOptionals($extrafields);
|
||||||
|
}
|
||||||
|
|
||||||
print '</table>';
|
print '</table>';
|
||||||
|
|
||||||
print '</div>';
|
print '</div>';
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user