Fix: use hooks for extrafields
This commit is contained in:
parent
46f8b2536c
commit
cc042a66ea
@ -21,7 +21,7 @@
|
||||
* \file htdocs/core/class/commonobject.class.php
|
||||
* \ingroup core
|
||||
* \brief File of parent class of all other business classes (invoices, contracts, proposals, orders, ...)
|
||||
* \version $Id: commonobject.class.php,v 1.148 2011/07/31 23:45:14 eldy Exp $
|
||||
* \version $Id: commonobject.class.php,v 1.149 2011/08/09 09:13:09 hregis Exp $
|
||||
*/
|
||||
|
||||
|
||||
@ -1987,7 +1987,65 @@ class CommonObject
|
||||
include(DOL_DOCUMENT_ROOT.'/core/tpl/originproductline.tpl.php');
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function showInputFields($object,$post='',$socid=0)
|
||||
{
|
||||
global $conf;
|
||||
|
||||
require_once(DOL_DOCUMENT_ROOT."/core/class/extrafields.class.php");
|
||||
|
||||
$extrafields = new ExtraFields($this->db);
|
||||
|
||||
$elementtype = $object->element;
|
||||
if ($object->element = 'societe') $elementtype = 'company';
|
||||
|
||||
$extralabels=$extrafields->fetch_name_optionals_label($elementtype);
|
||||
|
||||
if ($socid)
|
||||
{
|
||||
$res=$object->fetch_optionals($socid,$extralabels);
|
||||
if ($res < 0) { dol_print_error($db); exit; }
|
||||
}
|
||||
|
||||
foreach($extrafields->attribute_label as $key=>$label)
|
||||
{
|
||||
$value=(isset($post["options_$key"])?$post["options_$key"]:($socid?$object->array_options["options_$key"]:''));
|
||||
print "<tr><td>".$label.'</td><td colspan="3">';
|
||||
print $extrafields->showInputField($key,$value);
|
||||
print '</td></tr>'."\n";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function showOutputFields($object,$socid)
|
||||
{
|
||||
global $conf;
|
||||
|
||||
require_once(DOL_DOCUMENT_ROOT."/core/class/extrafields.class.php");
|
||||
|
||||
$extrafields = new ExtraFields($this->db);
|
||||
|
||||
$elementtype = $object->element;
|
||||
if ($object->element = 'societe') $elementtype = 'company';
|
||||
|
||||
$extralabels=$extrafields->fetch_name_optionals_label($elementtype);
|
||||
|
||||
$res=$object->fetch_optionals($socid,$extralabels);
|
||||
if ($res < 0) { dol_print_error($db); exit; }
|
||||
|
||||
foreach($extrafields->attribute_label as $key=>$label)
|
||||
{
|
||||
$value=$object->array_options["options_$key"];
|
||||
print "<tr><td>".$label.'</td><td colspan="3">';
|
||||
print $extrafields->showOutputField($key,$value);
|
||||
print "</td></tr>\n";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add/Update extra fields
|
||||
* TODO Use also type of field to do manage date fields
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
/**
|
||||
* \defgroup societe Module societe
|
||||
* \brief Module to manage third parties (customers, prospects)
|
||||
* \version $Id: modSociete.class.php,v 1.119 2011/07/31 23:28:10 eldy Exp $
|
||||
* \version $Id: modSociete.class.php,v 1.120 2011/08/09 09:13:09 hregis Exp $
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -106,15 +106,14 @@ class modSociete extends DolibarrModules
|
||||
$this->const[$r][4] = 0;
|
||||
$r++;
|
||||
|
||||
/* Disabled (no hook by default). A module that wants to hook thirdparty or contact actions must add its own constant MAIN_MODULE_MYMODULE_HOOKS=thirdpartycard:contactcard)
|
||||
$this->const[$r][0] = "MAIN_MODULE_SOCIETE_HOOKS";
|
||||
$this->const[$r][1] = "chaine";
|
||||
$this->const[$r][2] = "thirdpartycard:contactcard";
|
||||
$this->const[$r][2] = "extrafields";
|
||||
$this->const[$r][3] = "";
|
||||
$this->const[$r][4] = 0;
|
||||
$this->const[$r][4] = 'current';
|
||||
$this->const[$r][4] = 1;
|
||||
$r++; */
|
||||
$r++;
|
||||
|
||||
// Boxes
|
||||
$this->boxes = array();
|
||||
|
||||
37
htdocs/societe/class/actions_societe.class.php
Normal file
37
htdocs/societe/class/actions_societe.class.php
Normal file
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
/* Copyright (C) 2011 Regis Houssin <regis@dolibarr.fr>
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/societe/class/actions_societe.class.php
|
||||
* \ingroup societe
|
||||
* \brief File for third party class
|
||||
* \version $Id: actions_societe.class.php,v 1.1 2011/08/09 09:13:08 hregis Exp $
|
||||
*/
|
||||
require_once(DOL_DOCUMENT_ROOT."/societe/class/societe.class.php");
|
||||
|
||||
|
||||
/**
|
||||
* \class ActionsSociete
|
||||
* \brief Class to manage third parties objects (customers, suppliers, prospects...)
|
||||
*/
|
||||
class ActionsSociete extends Societe
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
@ -25,7 +25,7 @@
|
||||
* \file htdocs/societe/soc.php
|
||||
* \ingroup societe
|
||||
* \brief Third party card page
|
||||
* \version $Id: soc.php,v 1.126 2011/08/01 00:38:49 eldy Exp $
|
||||
* \version $Id: soc.php,v 1.127 2011/08/09 09:13:09 hregis Exp $
|
||||
*/
|
||||
|
||||
require("../main.inc.php");
|
||||
@ -35,7 +35,7 @@ require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/core/class/html.formadmin.class.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/core/class/html.formcompany.class.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/core/class/html.formfile.class.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/core/class/extrafields.class.php");
|
||||
//require_once(DOL_DOCUMENT_ROOT."/core/class/extrafields.class.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/contact/class/contact.class.php");
|
||||
if ($conf->adherent->enabled) require_once(DOL_DOCUMENT_ROOT."/adherents/class/adherent.class.php");
|
||||
|
||||
@ -52,7 +52,7 @@ $action = GETPOST('action');
|
||||
$confirm = GETPOST('confirm');
|
||||
|
||||
$object = new Societe($db);
|
||||
$extrafields = new ExtraFields($db);
|
||||
//$extrafields = new ExtraFields($db);
|
||||
|
||||
// Security check
|
||||
$socid = GETPOST("socid");
|
||||
@ -78,7 +78,7 @@ else
|
||||
// Instantiate hooks of thirdparty module. Note that conf->hooks_modules contains array array
|
||||
if (is_array($conf->hooks_modules) && !empty($conf->hooks_modules))
|
||||
{
|
||||
$object->callHooks('thirdpartycard');
|
||||
$object->callHooks(array('thirdpartycard','extrafields'));
|
||||
}
|
||||
|
||||
|
||||
@ -502,7 +502,7 @@ if (empty($reshook))
|
||||
*/
|
||||
|
||||
// fetch optionals attributes and labels
|
||||
$extralabels=$extrafields->fetch_name_optionals_label('company');
|
||||
//$extralabels=$extrafields->fetch_name_optionals_label('company');
|
||||
|
||||
$help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
|
||||
llxHeader('',$langs->trans("ThirdParty"),$help_url);
|
||||
@ -1025,6 +1025,7 @@ else
|
||||
}
|
||||
|
||||
// Other attributes
|
||||
/*
|
||||
foreach($extrafields->attribute_label as $key=>$label)
|
||||
{
|
||||
$value=(isset($_POST["options_".$key])?$_POST["options_".$key]:'');
|
||||
@ -1032,6 +1033,25 @@ else
|
||||
print $extrafields->showInputField($key,$value);
|
||||
print '</td></tr>'."\n";
|
||||
}
|
||||
*/
|
||||
|
||||
// Hook for external modules
|
||||
if (! empty($object->hooks))
|
||||
{
|
||||
foreach($object->hooks as $hook)
|
||||
{
|
||||
if (! empty($hook['modules']))
|
||||
{
|
||||
foreach($hook['modules'] as $module)
|
||||
{
|
||||
if (method_exists($module,'showInputFields'))
|
||||
{
|
||||
$module->showInputFields($object,$_POST);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Ajout du logo
|
||||
print '<tr>';
|
||||
@ -1057,11 +1077,11 @@ else
|
||||
|
||||
if ($socid)
|
||||
{
|
||||
$object = new Societe($db);
|
||||
//$object = new Societe($db);
|
||||
$res=$object->fetch($socid);
|
||||
if ($res < 0) { dol_print_error($db,$object->error); exit; }
|
||||
$res=$object->fetch_optionals($socid,$extralabels);
|
||||
if ($res < 0) { dol_print_error($db); exit; }
|
||||
//$res=$object->fetch_optionals($socid,$extralabels);
|
||||
//if ($res < 0) { dol_print_error($db); exit; }
|
||||
|
||||
// Load object modCodeTiers
|
||||
$module=$conf->global->SOCIETE_CODECLIENT_ADDON;
|
||||
@ -1448,6 +1468,7 @@ else
|
||||
}
|
||||
|
||||
// Other attributes
|
||||
/*
|
||||
foreach($extrafields->attribute_label as $key=>$label)
|
||||
{
|
||||
$value=(isset($_POST["options_$key"])?$_POST["options_$key"]:$object->array_options["options_$key"]);
|
||||
@ -1455,6 +1476,25 @@ else
|
||||
print $extrafields->showInputField($key,$value);
|
||||
print "</td></tr>\n";
|
||||
}
|
||||
*/
|
||||
|
||||
// Hook for external modules
|
||||
if (! empty($object->hooks))
|
||||
{
|
||||
foreach($object->hooks as $hook)
|
||||
{
|
||||
if (! empty($hook['modules']))
|
||||
{
|
||||
foreach($hook['modules'] as $module)
|
||||
{
|
||||
if (method_exists($module,'showInputFields'))
|
||||
{
|
||||
$module->showInputFields($object,$_POST,$socid);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Logo
|
||||
print '<tr>';
|
||||
@ -1491,11 +1531,11 @@ else
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
$object = new Societe($db);
|
||||
//$object = new Societe($db);
|
||||
$res=$object->fetch($socid);
|
||||
if ($res < 0) { dol_print_error($db,$object->error); exit; }
|
||||
$res=$object->fetch_optionals($socid,$extralabels);
|
||||
if ($res < 0) { dol_print_error($db); exit; }
|
||||
//$res=$object->fetch_optionals($socid,$extralabels);
|
||||
//if ($res < 0) { dol_print_error($db); exit; }
|
||||
|
||||
|
||||
$head = societe_prepare_head($object);
|
||||
@ -1784,6 +1824,7 @@ else
|
||||
}
|
||||
|
||||
// Other attributes
|
||||
/*
|
||||
foreach($extrafields->attribute_label as $key=>$label)
|
||||
{
|
||||
$value=$object->array_options["options_$key"];
|
||||
@ -1791,6 +1832,25 @@ else
|
||||
print $extrafields->showOutputField($key,$value);
|
||||
print "</td></tr>\n";
|
||||
}
|
||||
*/
|
||||
|
||||
// Hook for external modules
|
||||
if (! empty($object->hooks))
|
||||
{
|
||||
foreach($object->hooks as $hook)
|
||||
{
|
||||
if (! empty($hook['modules']))
|
||||
{
|
||||
foreach($hook['modules'] as $module)
|
||||
{
|
||||
if (method_exists($module,'showOutputFields'))
|
||||
{
|
||||
$module->showOutputFields($object,$socid);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Ban
|
||||
if (empty($conf->global->SOCIETE_DISABLE_BANKACCOUNT))
|
||||
@ -1969,5 +2029,5 @@ else
|
||||
|
||||
$db->close();
|
||||
|
||||
llxFooter('$Date: 2011/08/01 00:38:49 $ - $Revision: 1.126 $');
|
||||
llxFooter('$Date: 2011/08/09 09:13:09 $ - $Revision: 1.127 $');
|
||||
?>
|
||||
Loading…
Reference in New Issue
Block a user