NEW Code for extrafields uses the new array $extrafields->attributes

This commit is contained in:
Laurent Destailleur 2019-10-06 14:41:52 +02:00
parent 76dad97cb1
commit 2b66282b61
156 changed files with 622 additions and 649 deletions

View File

@ -68,7 +68,7 @@ $object = new Adherent($db);
$extrafields = new ExtraFields($db);
// fetch optionals attributes and labels
$extralabels=$extrafields->fetch_name_optionals_label($object->table_element);
$extrafields->fetch_name_optionals_label($object->table_element);
// Get object canvas (By default, this is not defined, so standard usage of dolibarr)
$object->getCanvas($id);
@ -320,7 +320,7 @@ if (empty($reshook))
$object->public = GETPOST("public", 'alpha');
// Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost($extralabels, $object);
$ret = $extrafields->setOptionalsFromPost(null, $object);
if ($ret < 0) $error++;
// Check if we need to also synchronize user information
@ -497,7 +497,7 @@ if (empty($reshook))
$object->public = $public;
// Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost($extralabels, $object);
$ret = $extrafields->setOptionalsFromPost(null, $object);
if ($ret < 0) $error++;
// Check parameters
@ -1362,15 +1362,8 @@ else
else print $langs->trans("NoDolibarrAccess");
print '</td></tr>';
// Other attributes
// Other attributes. Fields from hook formObjectOptions and Extrafields.
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php';
//Hooks here
$reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
if (empty($reshook))
{
print $object->showOptionals($extrafields, 'edit');
}
print '</table>';
dol_fiche_end();

View File

@ -48,7 +48,7 @@ $object=new Adherent($db);
$extrafields = new ExtraFields($db);
// Fetch optionals attributes and labels
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
$extrafields->fetch_name_optionals_label($object->table_element);
/*

View File

@ -89,7 +89,7 @@ $hookmanager->initHooks(array('memberlist'));
$extrafields = new ExtraFields($db);
// fetch optionals attributes and labels
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
$extrafields->fetch_name_optionals_label($object->table_element);
$search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_');

View File

@ -68,7 +68,7 @@ $extrafields = new ExtraFields($db);
$adht = new AdherentType($db);
// fetch optionals attributes and labels
$extralabels=$extrafields->fetch_name_optionals_label($object->table_element);
$extrafields->fetch_name_optionals_label($object->table_element);
$errmsg='';
$errmsgs=array();

View File

@ -68,7 +68,7 @@ $hookmanager->initHooks(array('subscriptionlist'));
$extrafields = new ExtraFields($db);
// fetch optionals attributes and labels
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
$extrafields->fetch_name_optionals_label($object->table_element);
$search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_');

View File

@ -73,7 +73,7 @@ $object = new AdherentType($db);
$extrafields = new ExtraFields($db);
// fetch optionals attributes and labels
$extralabels=$extrafields->fetch_name_optionals_label($object->table_element);
$extrafields->fetch_name_optionals_label($object->table_element);
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers
{
@ -113,7 +113,7 @@ if ($action == 'add' && $user->rights->adherent->configurer) {
$object->vote = (int) $vote;
// Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost($extralabels, $object);
$ret = $extrafields->setOptionalsFromPost(null, $object);
if ($ret < 0) $error++;
if (empty($object->label)) {
@ -168,7 +168,7 @@ if ($action == 'update' && $user->rights->adherent->configurer)
$object->vote = (boolean) trim($vote);
// Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost($extralabels, $object);
$ret = $extrafields->setOptionalsFromPost(null, $object);
if ($ret < 0) $error++;
$ret=$object->update($user);

View File

@ -57,7 +57,7 @@ $diroutputmassaction = $conf->emailcollector->dir_output . '/temp/massgeneration
$hookmanager->initHooks(array('emailcollectorcard')); // Note that conf->hooks_modules contains array
// Fetch optionals attributes and labels
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
$extrafields->fetch_name_optionals_label($object->table_element);
$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');

View File

@ -68,7 +68,7 @@ $diroutputmassaction = $conf->emailcollector->dir_output . '/temp/massgeneration
$hookmanager->initHooks(array('emailcollectorlist')); // Note that conf->hooks_modules contains array
// Fetch optionals attributes and labels
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
$extrafields->fetch_name_optionals_label($object->table_element);
$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');

View File

@ -61,7 +61,7 @@ $diroutputmassaction=$conf->admin->dir_output . '/temp/massgeneration/'.$user->i
$hookmanager->initHooks(array('emailsenderprofilelist')); // Note that conf->hooks_modules contains array
// Fetch optionals attributes and labels
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
$extrafields->fetch_name_optionals_label($object->table_element);
$search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_');

View File

@ -45,7 +45,7 @@ $diroutputmassaction=$conf->asset->dir_output . '/temp/massgeneration/'.$user->i
$hookmanager->initHooks(array('assetcard')); // Note that conf->hooks_modules contains array
// Fetch optionals attributes and labels
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
$extrafields->fetch_name_optionals_label($object->table_element);
$search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
@ -64,9 +64,6 @@ if (empty($action) && empty($id) && empty($ref)) $action='view';
//if ($user->societe_id > 0) $socid = $user->societe_id;
//$result = restrictedArea($user, 'asset', $id);
// fetch optionals attributes and labels
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
// Load object
include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once.
@ -207,7 +204,7 @@ if (($id || $ref) && $action == 'edit')
// Part to show record
if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create')))
{
$res = $object->fetch_optionals($object->id, $extralabels);
$res = $object->fetch_optionals($object->id);
$head = asset_prepare_head($object);
dol_fiche_head($head, 'card', $langs->trans("Asset"), -1, 'generic');

View File

@ -62,7 +62,7 @@ $diroutputmassaction=$conf->assets->dir_output . '/temp/massgeneration/'.$user->
$hookmanager->initHooks(array('assetdocument')); // Note that conf->hooks_modules contains array
// Fetch optionals attributes and labels
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
$extrafields->fetch_name_optionals_label($object->table_element);
// Load object
include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals

View File

@ -62,7 +62,7 @@ $diroutputmassaction=$conf->asset->dir_output . '/temp/massgeneration/'.$user->i
$hookmanager->initHooks(array('assetlist')); // Note that conf->hooks_modules contains array
// Fetch optionals attributes and labels
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
$extrafields->fetch_name_optionals_label($object->table_element);
$search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_');

View File

@ -43,7 +43,7 @@ $diroutputmassaction=$conf->asset->dir_output . '/temp/massgeneration/'.$user->i
$hookmanager->initHooks(array('assetnote')); // Note that conf->hooks_modules contains array
// Fetch optionals attributes and labels
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
$extrafields->fetch_name_optionals_label($object->table_element);
// Security check - Protection if external user
//if ($user->societe_id > 0) access_forbidden();

View File

@ -65,7 +65,7 @@ $object = new AssetType($db);
$extrafields = new ExtraFields($db);
// fetch optionals attributes and labels
$extralabels=$extrafields->fetch_name_optionals_label($object->table_element);
$extrafields->fetch_name_optionals_label($object->table_element);
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers
{
@ -102,7 +102,7 @@ if ($action == 'add' && $user->rights->asset->write)
$object->note = trim($comment);
// Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost($extralabels, $object);
$ret = $extrafields->setOptionalsFromPost(null, $object);
if ($ret < 0) $error++;
if (empty($object->label)) {
@ -155,7 +155,7 @@ if ($action == 'update' && $user->rights->asset->write)
$object->note = trim($comment);
// Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost($extralabels, $object);
$ret = $extrafields->setOptionalsFromPost(null, $object);
if ($ret < 0) $error++;
$ret=$object->update($user);

View File

@ -74,7 +74,7 @@ $extrafields = new ExtraFields($db);
$diroutputmassaction=$conf->bom->dir_output . '/temp/massgeneration/'.$user->id;
$hookmanager->initHooks(array('bomagenda','globalcard')); // Note that conf->hooks_modules contains array
// Fetch optionals attributes and labels
$extralabels = $extrafields->fetch_name_optionals_label('bom');
$extrafields->fetch_name_optionals_label($object->table_element);
// Load object
include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals

View File

@ -48,7 +48,7 @@ $extrafields = new ExtraFields($db);
$diroutputmassaction=$conf->bom->dir_output . '/temp/massgeneration/'.$user->id;
$hookmanager->initHooks(array('bomcard', 'globalcard')); // Note that conf->hooks_modules contains array
// Fetch optionals attributes and labels
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
$extrafields->fetch_name_optionals_label($object->table_element);
$search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
// Initialize array of search criterias

View File

@ -63,7 +63,7 @@ $extrafields = new ExtraFields($db);
$diroutputmassaction=$conf->bom->dir_output . '/temp/massgeneration/'.$user->id;
$hookmanager->initHooks(array('bomdocument', 'globalcard')); // Note that conf->hooks_modules contains array
// Fetch optionals attributes and labels
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
$extrafields->fetch_name_optionals_label($object->table_element);
// Load object
include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals

View File

@ -62,7 +62,7 @@ $diroutputmassaction = $conf->bom->dir_output . '/temp/massgeneration/'.$user->i
$hookmanager->initHooks(array('bomlist')); // Note that conf->hooks_modules contains array
// Fetch optionals attributes and labels
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element); // Load $extrafields->attributes['bom']
$extrafields->fetch_name_optionals_label($object->table_element);
$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');

View File

@ -44,7 +44,7 @@ $diroutputmassaction=$conf->bom->dir_output . '/temp/massgeneration/'.$user->id;
$hookmanager->initHooks(array('bomnote','globalcard')); // Note that conf->hooks_modules contains array
// Fetch optionals attributes and labels
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
$extrafields->fetch_name_optionals_label($object->table_element);
// Security check - Protection if external user
//if ($user->societe_id > 0) access_forbidden();

View File

@ -140,7 +140,7 @@ if ($nolinesbefore) {
<?php
if (is_object($objectline)) {
print $objectline->showOptionals($extrafieldsline, 'edit', array('style'=>$bcnd[$var], 'colspan'=>$coldisplay), '', '', empty($conf->global->MAIN_EXTRAFIELDS_IN_ONE_TD)?0:1);
print $objectline->showOptionals($extrafields, 'edit', array('style'=>$bcnd[$var], 'colspan'=>$coldisplay), '', '', empty($conf->global->MAIN_EXTRAFIELDS_IN_ONE_TD)?0:1);
}
?>

View File

@ -138,7 +138,7 @@ $coldisplay=0;
<?php
if (is_object($objectline)) {
print $objectline->showOptionals($extrafieldsline, 'edit', array('style'=>$bcnd[$var], 'colspan'=>$coldisplay), '', '', empty($conf->global->MAIN_EXTRAFIELDS_IN_ONE_TD)?0:1);
print $objectline->showOptionals($extrafields, 'edit', array('style'=>$bcnd[$var], 'colspan'=>$coldisplay), '', '', empty($conf->global->MAIN_EXTRAFIELDS_IN_ONE_TD)?0:1);
}
?>

View File

@ -149,9 +149,9 @@ $objectline = new BOMLine($object->db);
<?php
//Line extrafield
if (!empty($extrafieldsline))
if (!empty($extrafields))
{
print $line->showOptionals($extrafieldsline, 'view', array('style'=>'class="drag drop oddeven"','colspan'=>$coldisplay), '', '', empty($conf->global->MAIN_EXTRAFIELDS_IN_ONE_TD)?0:1);
print $line->showOptionals($extrafields, 'view', array('style'=>'class="drag drop oddeven"','colspan'=>$coldisplay), '', '', empty($conf->global->MAIN_EXTRAFIELDS_IN_ONE_TD)?0:1);
}
?>

View File

@ -68,7 +68,7 @@ if ($catorigin && $type == Categorie::TYPE_PRODUCT) $idCatOrigin = $catorigin;
$object = new Categorie($db);
$extrafields = new ExtraFields($db);
$extralabels=$extrafields->fetch_name_optionals_label($object->table_element);
$extrafields->fetch_name_optionals_label($object->table_element);
// Initialize technical object to manage hooks. Note that conf->hooks_modules contains array array
$hookmanager->initHooks(array('categorycard'));
@ -137,7 +137,7 @@ if ($action == 'add' && $user->rights->categorie->creer)
if ($parent != "-1") $object->fk_parent = $parent;
$ret = $extrafields->setOptionalsFromPost($extralabels, $object);
$ret = $extrafields->setOptionalsFromPost(null, $object);
if ($ret < 0) $error++;
if (! $object->label)

View File

@ -62,7 +62,7 @@ if ($id > 0)
}
$extrafields = new ExtraFields($db);
$extralabels=$extrafields->fetch_name_optionals_label($object->table_element);
$extrafields->fetch_name_optionals_label($object->table_element);
// Initialize technical object to manage hooks. Note that conf->hooks_modules contains array array
$hookmanager->initHooks(array('categorycard'));
@ -102,7 +102,7 @@ if ($action == 'update' && $user->rights->categorie->creer)
}
if (! $error && empty($object->error))
{
$ret = $extrafields->setOptionalsFromPost($extralabels, $object);
$ret = $extrafields->setOptionalsFromPost(null, $object);
if ($ret < 0) $error++;
if (! $error && $object->update($user) > 0)

View File

@ -84,7 +84,7 @@ $type=$object->type;
if (is_numeric($type)) $type=Categorie::$MAP_ID_TO_CODE[$type]; // For backward compatibility
$extrafields = new ExtraFields($db);
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
$extrafields->fetch_name_optionals_label($object->table_element);
// Initialize technical object to manage hooks. Note that conf->hooks_modules contains array array
$hookmanager->initHooks(array('categorycard','globalcard'));

View File

@ -99,7 +99,7 @@ if ($id > 0 && $action!='add') {
}
// fetch optionals attributes and labels
$extralabels=$extrafields->fetch_name_optionals_label($object->table_element);
$extrafields->fetch_name_optionals_label($object->table_element);
//var_dump($_POST);
@ -361,7 +361,7 @@ if (empty($reshook) && $action == 'add')
}
// Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost($extralabels, $object);
$ret = $extrafields->setOptionalsFromPost(null, $object);
if ($ret < 0) $error++;
if (! $error)
@ -526,7 +526,7 @@ if (empty($reshook) && $action == 'update')
}
// Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost($extralabels, $object);
$ret = $extrafields->setOptionalsFromPost(null, $object);
if ($ret < 0) $error++;
if (!$error) {

View File

@ -82,7 +82,7 @@ $hookmanager->initHooks(array('agendalist'));
$extrafields = new ExtraFields($db);
// fetch optionals attributes and labels
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
$extrafields->fetch_name_optionals_label($object->table_element);
$search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
// If not choice done on calendar owner, we filter on user.

View File

@ -80,7 +80,7 @@ $object = new Client($db);
$extrafields = new ExtraFields($db);
// fetch optionals attributes and labels
$extralabels=$extrafields->fetch_name_optionals_label($object->table_element);
$extrafields->fetch_name_optionals_label($object->table_element);
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$hookmanager->initHooks(array('thirdpartycomm','globalcard'));
@ -194,8 +194,7 @@ if (empty($reshook))
$object->oldcopy = dol_clone($object);
// Fill array 'array_options' with data from update form
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
$ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute', 'none'));
$ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute', 'none'));
if ($ret < 0) $error++;
if (! $error)
{

View File

@ -51,7 +51,7 @@ $result=$object->fetch($id);
$extrafields = new ExtraFields($db);
// fetch optionals attributes and labels
$extralabels=$extrafields->fetch_name_optionals_label($object->table_element);
$extrafields->fetch_name_optionals_label($object->table_element);
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$hookmanager->initHooks(array('mailingcard','globalcard'));

View File

@ -544,7 +544,7 @@ class AdvanceTargetingMailing extends CommonObject
public function query_thirdparty($arrayquery)
{
// phpcs:enable
global $langs,$conf;
global $langs,$conf,$extrafields;
$sql = "SELECT";
$sql.= " t.rowid";
@ -617,29 +617,29 @@ class AdvanceTargetingMailing extends CommonObject
//Standard Extrafield feature
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) {
// fetch optionals attributes and labels
dol_include_once('/core/class/extrafields.class.php');
$extrafields = new ExtraFields($this->db);
$extralabels=$extrafields->fetch_name_optionals_label('societe');
foreach($extralabels as $key=>$val) {
$elementtype = Societe::$table_element;
if (($extrafields->attribute_type[$key] == 'varchar') ||
($extrafields->attribute_type[$key] == 'text')) {
$extrafields->fetch_name_optionals_label($elementtype);
foreach($extrafields->attributes[$elementtype]['label'] as $key=>$val) {
if (($extrafields->attributes[$elementtype]['type'][$key] == 'varchar') ||
($extrafields->attributes[$elementtype]['type'][$key] == 'text')) {
if (!empty($arrayquery['options_'.$key])) {
$sqlwhere[]= " (te.".$key." LIKE '".$arrayquery['options_'.$key]."')";
}
} elseif (($extrafields->attribute_type[$key] == 'int') ||
($extrafields->attribute_type[$key] == 'double')) {
} elseif (($extrafields->attributes[$elementtype]['type'][$key] == 'int') ||
($extrafields->attributes[$elementtype]['type'][$key] == 'double')) {
if (!empty($arrayquery['options_'.$key.'_max'])) {
$sqlwhere[]= " (te.".$key." >= ".$arrayquery['options_'.$key.'_max']." AND te.".$key." <= ".$arrayquery['options_'.$key.'_min'].")";
}
} elseif (($extrafields->attribute_type[$key] == 'date') ||
($extrafields->attribute_type[$key] == 'datetime')) {
} elseif (($extrafields->attributes[$elementtype]['type'][$key] == 'date') ||
($extrafields->attributes[$elementtype]['type'][$key] == 'datetime')) {
if (!empty($arrayquery['options_'.$key.'_end_dt'])){
$sqlwhere[]= " (te.".$key." >= '".$this->db->idate($arrayquery['options_'.$key.'_st_dt'])."' AND te.".$key." <= '".$this->db->idate($arrayquery['options_'.$key.'_end_dt'])."')";
}
} elseif ($extrafields->attribute_type[$key] == 'boolean') {
} elseif ($extrafields->attributes[$elementtype]['type'][$key] == 'boolean') {
if ($arrayquery['options_'.$key]!=''){
$sqlwhere[]= " (te.".$key." = ".$arrayquery['options_'.$key].")";
}
@ -757,29 +757,33 @@ class AdvanceTargetingMailing extends CommonObject
//Standard Extrafield feature
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) {
$elementtype = Contact::$table_element;
// fetch optionals attributes and labels
dol_include_once('/core/class/extrafields.class.php');
$extrafields = new ExtraFields($this->db);
$extralabels=$extrafields->fetch_name_optionals_label('socpeople');
$extrafields->fetch_name_optionals_label($elementtype);
foreach($extralabels as $key=>$val) {
$extrafields->fetch_name_optionals_label($elementtype);
if (($extrafields->attribute_type[$key] == 'varchar') ||
($extrafields->attribute_type[$key] == 'text')) {
foreach($extrafields->attributes[$elementtype]['label'] as $key=>$val) {
if (($extrafields->attributes[$elementtype]['type'][$key] == 'varchar') ||
($extrafields->attributes[$elementtype]['type'][$key] == 'text')) {
if (!empty($arrayquery['options_'.$key.'_cnct'])) {
$sqlwhere[]= " (te.".$key." LIKE '".$arrayquery['options_'.$key.'_cnct']."')";
}
} elseif (($extrafields->attribute_type[$key] == 'int') ||
($extrafields->attribute_type[$key] == 'double')) {
} elseif (($extrafields->attributes[$elementtype]['type'][$key] == 'int') ||
($extrafields->attributes[$elementtype]['type'][$key] == 'double')) {
if (!empty($arrayquery['options_'.$key.'_max'.'_cnct'])) {
$sqlwhere[]= " (te.".$key." >= ".$arrayquery['options_'.$key.'_max'.'_cnct']." AND te.".$key." <= ".$arrayquery['options_'.$key.'_min'.'_cnct'].")";
}
} elseif (($extrafields->attribute_type[$key] == 'date') ||
($extrafields->attribute_type[$key] == 'datetime')) {
} elseif (($extrafields->attributes[$elementtype]['type'][$key] == 'date') ||
($extrafields->attributes[$elementtype]['type'][$key] == 'datetime')) {
if (!empty($arrayquery['options_'.$key.'_end_dt'.'_cnct'])){
$sqlwhere[]= " (te.".$key." >= '".$this->db->idate($arrayquery['options_'.$key.'_st_dt'.'_cnct'])."' AND te.".$key." <= '".$this->db->idate($arrayquery['options_'.$key.'_end_dt'.'_cnct'])."')";
}
} elseif ($extrafields->attribute_type[$key] == 'boolean') {
} elseif ($extrafields->attributes[$elementtype]['type'][$key] == 'boolean') {
if ($arrayquery['options_'.$key.'_cnct']!=''){
if ($arrayquery['options_'.$key.'_cnct']==0) {
$sqlwhere[]= " (te.".$key." = ".$arrayquery['options_'.$key.'_cnct']." OR ((te.".$key." IS NULL) AND (te.fk_object IS NOT NULL)))";
@ -857,29 +861,32 @@ class AdvanceTargetingMailing extends CommonObject
//Standard Extrafield feature
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) {
$elementtype = Societe::$table_element;
// fetch optionals attributes and labels
dol_include_once('/core/class/extrafields.class.php');
$extrafields = new ExtraFields($this->db);
$extralabels=$extrafields->fetch_name_optionals_label('societe');
foreach($extralabels as $key=>$val) {
$extrafields->fetch_name_optionals_label($elementtype);
if (($extrafields->attribute_type[$key] == 'varchar') ||
($extrafields->attribute_type[$key] == 'text')) {
foreach($extrafields->attributes[$elementtype]['label'] as $key=>$val) {
if (($extrafields->attributes[$elementtype]['type'][$key] == 'varchar') ||
($extrafields->attributes[$elementtype]['type'][$key] == 'text')) {
if (!empty($arrayquery['options_'.$key])) {
$sqlwhere[]= " (tse.".$key." LIKE '".$arrayquery['options_'.$key]."')";
}
} elseif (($extrafields->attribute_type[$key] == 'int') ||
($extrafields->attribute_type[$key] == 'double')) {
} elseif (($extrafields->attributes[$elementtype]['type'][$key] == 'int') ||
($extrafields->attributes[$elementtype]['type'][$key] == 'double')) {
if (!empty($arrayquery['options_'.$key.'_max'])) {
$sqlwhere[]= " (tse.".$key." >= ".$arrayquery['options_'.$key.'_max']." AND tse.".$key." <= ".$arrayquery['options_'.$key.'_min'].")";
}
} elseif (($extrafields->attribute_type[$key] == 'date') ||
($extrafields->attribute_type[$key] == 'datetime')) {
} elseif (($extrafields->attributes[$elementtype]['type'][$key] == 'date') ||
($extrafields->attributes[$elementtype]['type'][$key] == 'datetime')) {
if (!empty($arrayquery['options_'.$key.'_end_dt'])){
$sqlwhere[]= " (tse.".$key." >= '".$this->db->idate($arrayquery['options_'.$key.'_st_dt'])."' AND tse.".$key." <= '".$this->db->idate($arrayquery['options_'.$key.'_end_dt'])."')";
}
} elseif ($extrafields->attribute_type[$key] == 'boolean') {
} elseif ($extrafields->attributes[$elementtype]['type'][$key] == 'boolean') {
if ($arrayquery['options_'.$key]!=''){
$sqlwhere[]= " (tse.".$key." = ".$arrayquery['options_'.$key].")";
}

View File

@ -53,7 +53,7 @@ $hookmanager->initHooks(array('mailinglist'));
$extrafields = new ExtraFields($db);
// fetch optionals attributes and labels
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
$extrafields->fetch_name_optionals_label($object->table_element);
$search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_');

View File

@ -93,7 +93,7 @@ $object = new Propal($db);
$extrafields = new ExtraFields($db);
// fetch optionals attributes and labels
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
$extrafields->fetch_name_optionals_label($object->table_element);
// Load object
if ($id > 0 || ! empty($ref)) {
@ -410,7 +410,7 @@ if (empty($reshook))
}
// Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost($extralabels, $object);
$ret = $extrafields->setOptionalsFromPost(null, $object);
if ($ret < 0) {
$error ++;
$action = 'create';
@ -841,9 +841,8 @@ if (empty($reshook))
if (empty($remise_percent)) $remise_percent=0;
// Extrafields
$extrafieldsline = new ExtraFields($db);
$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
$array_options = $extrafieldsline->getOptionalsFromPost($object->table_element_line, $predef);
$extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line);
$array_options = $extrafields->getOptionalsFromPost($object->table_element_line, $predef);
// Unset extrafield
if (is_array($extralabelsline)) {
// Get extra fields
@ -1210,9 +1209,8 @@ if (empty($reshook))
$date_end = dol_mktime(GETPOST('date_endhour'), GETPOST('date_endmin'), GETPOST('date_endsec'), GETPOST('date_endmonth'), GETPOST('date_endday'), GETPOST('date_endyear'));
// Extrafields
$extrafieldsline = new ExtraFields($db);
$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
$array_options = $extrafieldsline->getOptionalsFromPost($object->table_element_line);
$extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line);
$array_options = $extrafields->getOptionalsFromPost($object->table_element_line);
// Unset extrafield
if (is_array($extralabelsline)) {
// Get extra fields
@ -1379,8 +1377,7 @@ if (empty($reshook))
$object->oldcopy = dol_clone($object);
// Fill array 'array_options' with data from update form
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
$ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute', 'none'));
$ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute', 'none'));
if ($ret < 0) $error++;
if (! $error)
{

View File

@ -129,7 +129,7 @@ $hookmanager->initHooks(array('propallist'));
$extrafields = new ExtraFields($db);
// fetch optionals attributes and labels
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
$extrafields->fetch_name_optionals_label($object->table_element);
$search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_');

View File

@ -88,7 +88,7 @@ $object = new Commande($db);
$extrafields = new ExtraFields($db);
// fetch optionals attributes and labels
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
$extrafields->fetch_name_optionals_label($object->table_element);
// Load object
include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once
@ -284,7 +284,7 @@ if (empty($reshook))
// Fill array 'array_options' with data from add form
if (! $error)
{
$ret = $extrafields->setOptionalsFromPost($extralabels, $object);
$ret = $extrafields->setOptionalsFromPost(null, $object);
if ($ret < 0) $error++;
}
@ -673,9 +673,8 @@ if (empty($reshook))
$remise_percent = (GETPOST('remise_percent'.$predef) != '' ? GETPOST('remise_percent'.$predef) : 0);
// Extrafields
$extrafieldsline = new ExtraFields($db);
$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
$array_options = $extrafieldsline->getOptionalsFromPost($object->table_element_line, $predef);
$extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line);
$array_options = $extrafields->getOptionalsFromPost($object->table_element_line, $predef);
// Unset extrafield
if (is_array($extralabelsline)) {
// Get extra fields
@ -1037,9 +1036,8 @@ if (empty($reshook))
$buyingprice = price2num(GETPOST('buying_price') != '' ? GETPOST('buying_price') : ''); // If buying_price is '0', we muste keep this value
// Extrafields Lines
$extrafieldsline = new ExtraFields($db);
$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
$array_options = $extrafieldsline->getOptionalsFromPost($object->table_element_line);
$extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line);
$array_options = $extrafields->getOptionalsFromPost($object->table_element_line);
// Unset extrafield POST Data
if (is_array($extralabelsline)) {
foreach ($extralabelsline as $key => $value) {
@ -1297,8 +1295,7 @@ if (empty($reshook))
$object->oldcopy = dol_clone($object);
// Fill array 'array_options' with data from update form
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
$ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute', 'none'));
$ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute', 'none'));
if ($ret < 0) $error++;
if (! $error)

View File

@ -111,7 +111,7 @@ $hookmanager->initHooks(array('orderlist'));
$extrafields = new ExtraFields($db);
// fetch optionals attributes and labels
$extralabels = $extrafields->fetch_name_optionals_label('commande');
$extrafields->fetch_name_optionals_label('commande');
$search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
// List of fields to search into when doing a "search in all"

View File

@ -72,8 +72,10 @@ $date_endy = dol_mktime(23, 59, 59, $_REQUEST["date_end_delymonth"], $_REQUEST["
$extrafields = new ExtraFields($db);
$object=new Facture($db);
// fetch optionals attributes and labels
$extralabels=$extrafields->fetch_name_optionals_label('facture');
$extrafields->fetch_name_optionals_label($object->table_element);
if ($action == 'create')
{
@ -141,7 +143,6 @@ if (($action == 'create' || $action == 'add') && !$error)
$result = restrictedArea($user, 'facture', $id, '', '', 'fk_soc', $fieldid);
$usehm=$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE;
$object=new Facture($db);
// Insert new invoice in database
if ($action == 'add' && $user->rights->facture->creer)
@ -177,7 +178,7 @@ if (($action == 'create' || $action == 'add') && !$error)
$object->remise_absolue = $_POST['remise_absolue'];
$object->remise_percent = $_POST['remise_percent'];
$ret = $extrafields->setOptionalsFromPost($extralabels, $object);
$ret = $extrafields->setOptionalsFromPost(null, $object);
if ($ret < 0) $error++;
if ($_POST['origin'] && $_POST['originid'])

View File

@ -137,7 +137,7 @@ $hookmanager->initHooks(array('banktransactionlist', $contextpage));
$extrafields = new ExtraFields($db);
// fetch optionals attributes and labels
$extralabels = $extrafields->fetch_name_optionals_label('banktransaction');
$extrafields->fetch_name_optionals_label('banktransaction');
$search_array_options=$extrafields->getOptionalsFromPost('banktransaction', '', 'search_');
$arrayfields=array(

View File

@ -57,8 +57,9 @@ $result=restrictedArea($user, 'banque', $id, 'bank_account&bank_account', '', ''
$object = new Account($db);
$extrafields = new ExtraFields($db);
// fetch optionals attributes and labels
$extralabels=$extrafields->fetch_name_optionals_label($object->table_element);
$extrafields->fetch_name_optionals_label($object->table_element);
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$hookmanager->initHooks(array('bankcard','globalcard'));
@ -136,7 +137,7 @@ if ($action == 'add')
}
// Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost($extralabels, $object);
$ret = $extrafields->setOptionalsFromPost(null, $object);
if (! $error)
{
@ -241,7 +242,7 @@ if ($action == 'update')
if (! $error)
{
// Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost($extralabels, $object);
$ret = $extrafields->setOptionalsFromPost(null, $object);
}
if (! $error)
@ -433,7 +434,7 @@ if ($action == 'create')
print $hookmanager->resPrint;
if (empty($reshook))
{
print $object->showOptionals($extrafields, 'edit', $parameters);
print $object->showOptionals($extrafields, 'edit');
}
print '</table>';

View File

@ -73,7 +73,7 @@ $hookmanager->initHooks(array('bankaccountlist'));
$extrafields = new ExtraFields($db);
// fetch optionals attributes and labels
$extralabels = $extrafields->fetch_name_optionals_label('bank_account');
$extrafields->fetch_name_optionals_label('bank_account');
$search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
// List of fields to search into when doing a "search in all"

View File

@ -72,7 +72,7 @@ $object= new CashControl($db);
$extrafields = new ExtraFields($db);
// fetch optionals attributes and labels
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
$extrafields->fetch_name_optionals_label($object->table_element);
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$hookmanager->initHooks(array('cashcontrolcard','globalcard'));

View File

@ -78,8 +78,10 @@ $object=new CashControl($db);
$extrafields = new ExtraFields($db);
$diroutputmassaction=$conf->monmodule->dir_output . '/temp/massgeneration/'.$user->id;
$hookmanager->initHooks(array('cashcontrol')); // Note that conf->hooks_modules contains array
// Fetch optionals attributes and labels
$extralabels = $extrafields->fetch_name_optionals_label('cashcontrol'); // Load $extrafields->attributes['cashcontrol']
$extrafields->fetch_name_optionals_label($object->table_element);
$search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
// Default sort order (if not yet defined by previous GETPOST)

View File

@ -902,8 +902,7 @@ if (empty($reshook))
$error = 0;
$originentity = GETPOST('originentity');
// Fill array 'array_options' with data from add form
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
$ret = $extrafields->setOptionalsFromPost($extralabels, $object);
$ret = $extrafields->setOptionalsFromPost(null, $object);
if ($ret < 0) $error++;
// Replacement invoice
@ -1679,8 +1678,8 @@ if (empty($reshook))
$nextSituationInvoice = new Facture($db);
$nextSituationInvoice->fetch($id);
// create extrafields with data from create form
$extralabels = $extrafields->fetch_name_optionals_label($nextSituationInvoice->table_element);
$ret = $extrafields->setOptionalsFromPost($extralabels, $nextSituationInvoice);
$extrafields->fetch_name_optionals_label($nextSituationInvoice->table_element);
$ret = $extrafields->setOptionalsFromPost(null, $nextSituationInvoice);
if ($ret > 0) {
$nextSituationInvoice->insertExtraFields();
}
@ -1752,9 +1751,8 @@ if (empty($reshook))
$remise_percent = GETPOST('remise_percent' . $predef);
// Extrafields
$extrafieldsline = new ExtraFields($db);
$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
$array_options = $extrafieldsline->getOptionalsFromPost($object->table_element_line, $predef);
$extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line);
$array_options = $extrafields->getOptionalsFromPost($object->table_element_line, $predef);
// Unset extrafield
if (is_array($extralabelsline)) {
// Get extra fields
@ -2075,9 +2073,8 @@ if (empty($reshook))
$buyingprice = price2num(GETPOST('buying_price') != '' ? GETPOST('buying_price') : ''); // If buying_price is '0', we muste keep this value
// Extrafields
$extrafieldsline = new ExtraFields($db);
$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
$array_options = $extrafieldsline->getOptionalsFromPost($object->table_element_line);
$extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line);
$array_options = $extrafields->getOptionalsFromPost($object->table_element_line);
// Unset extrafield
if (is_array($extralabelsline)) {
// Get extra fields
@ -2496,8 +2493,7 @@ if (empty($reshook))
$object->oldcopy = dol_clone($object);
// Fill array 'array_options' with data from add form
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
$ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute', 'none'));
$ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute', 'none'));
if ($ret < 0) $error++;
if (! $error)
@ -2585,7 +2581,7 @@ llxHeader('', $title, $helpurl);
if ($action == 'create')
{
$facturestatic = new Facture($db);
$extralabels = $extrafields->fetch_name_optionals_label($facturestatic->table_element);
$extrafields->fetch_name_optionals_label($facturestatic->table_element);
print load_fiche_titre($langs->trans('NewBill'), '', 'invoicing');
@ -3460,7 +3456,7 @@ elseif ($id > 0 || ! empty($ref))
}
// fetch optionals attributes and labels
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
$extrafields->fetch_name_optionals_label($object->table_element);
if ($user->societe_id > 0 && $user->societe_id != $object->socid)
{

View File

@ -518,14 +518,19 @@ class FactureRec extends CommonInvoice
*/
public function fetch_lines()
{
global $extrafields;
// phpcs:enable
$this->lines=array();
// Retreive all extrafield for line
// fetch optionals attributes and labels
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
$extrafieldsline=new ExtraFields($this->db);
$extrafieldsline=$extrafieldsline->fetch_name_optionals_label('facturedet_rec', true);
if (! is_object($extrafields))
{
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
$extrafields=new ExtraFields($this->db);
}
$extrafields->fetch_name_optionals_label($this->table_element_line, true);
$sql = 'SELECT l.rowid, l.fk_product, l.product_type, l.label as custom_label, l.description, l.product_type, l.price, l.qty, l.vat_src_code, l.tva_tx, ';
$sql.= ' l.localtax1_tx, l.localtax2_tx, l.localtax1_type, l.localtax2_type, l.remise, l.remise_percent, l.subprice,';
@ -599,7 +604,7 @@ class FactureRec extends CommonInvoice
$line->price = $objp->price;
$line->remise = $objp->remise;
$extralabelsline = $line->fetch_optionals($line->id);
$line->fetch_optionals($line->id);
// Multicurrency
$line->fk_multicurrency = $objp->fk_multicurrency;

View File

@ -93,7 +93,8 @@ $hookmanager->initHooks(array('invoicereccard','globalcard'));
$extrafields = new ExtraFields($db);
// fetch optionals attributes and labels
$extralabels = $extrafields->fetch_name_optionals_label('facture_rec');
$extrafields->fetch_name_optionals_label($object->table_element);
$search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
$permissionnote = $user->rights->facture->creer; // Used by the include of actions_setnotes.inc.php
@ -426,8 +427,7 @@ if (empty($reshook))
$object->oldcopy = dol_clone($object);
// Fill array 'array_options' with data from update form
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
$ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute', 'none'));
$ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute', 'none'));
if ($ret < 0) $error++;
if (! $error)
@ -468,9 +468,8 @@ if (empty($reshook))
$remise_percent = GETPOST('remise_percent' . $predef);
// Extrafields
$extrafieldsline = new ExtraFields($db);
$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
$array_options = $extrafieldsline->getOptionalsFromPost($object->table_element_line, $predef);
$extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line);
$array_options = $extrafields->getOptionalsFromPost($object->table_element_line, $predef);
// Unset extrafield
if (is_array($extralabelsline))
{
@ -771,9 +770,8 @@ if (empty($reshook))
$buyingprice = price2num(GETPOST('buying_price') != '' ? GETPOST('buying_price') : ''); // If buying_price is '0', we muste keep this value
// Extrafields
$extrafieldsline = new ExtraFields($db);
$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
$array_options = $extrafieldsline->getOptionalsFromPost($object->table_element_line);
$extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line);
$array_options = $extrafields->getOptionalsFromPost($object->table_element_line);
$objectline = new FactureLigneRec($db);
if ($objectline->fetch(GETPOST('lineid', 'int')))

View File

@ -108,7 +108,8 @@ $hookmanager->initHooks(array('invoicereccard','globalcard'));
$extrafields = new ExtraFields($db);
// fetch optionals attributes and labels
$extralabels = $extrafields->fetch_name_optionals_label('facture_rec');
$extrafields->fetch_name_optionals_label('facture_rec');
$search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
$permissionnote = $user->rights->facture->creer; // Used by the include of actions_setnotes.inc.php

View File

@ -141,7 +141,8 @@ $hookmanager->initHooks(array('invoicelist'));
$extrafields = new ExtraFields($db);
// fetch optionals attributes and labels
$extralabels = $extrafields->fetch_name_optionals_label('facture');
$extrafields->fetch_name_optionals_label('facture');
$search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
// List of fields to search into when doing a "search in all"

View File

@ -59,7 +59,7 @@ $object = new Contact($db);
$extrafields = new ExtraFields($db);
// fetch optionals attributes and labels
$extralabels=$extrafields->fetch_name_optionals_label($object->table_element);
$extrafields->fetch_name_optionals_label($object->table_element);
// Get object canvas (By default, this is not defined, so standard usage of dolibarr)
$object->getCanvas($id);

View File

@ -60,7 +60,7 @@ $object = new Contact($db);
$extrafields = new ExtraFields($db);
// fetch optionals attributes and labels
$extralabels=$extrafields->fetch_name_optionals_label($object->table_element);
$extrafields->fetch_name_optionals_label($object->table_element);
// Get object canvas (By default, this is not defined, so standard usage of dolibarr)
$object->getCanvas($id);
@ -206,7 +206,7 @@ if (empty($reshook))
$object->birthday_alert = GETPOST("birthday_alert", 'alpha');
// Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost($extralabels, $object);
$ret = $extrafields->setOptionalsFromPost(null, $object);
if ($ret < 0)
{
$error++;
@ -373,7 +373,7 @@ if (empty($reshook))
$object->note_private = GETPOST("note_private", 'none');
// Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost($extralabels, $object);
$ret = $extrafields->setOptionalsFromPost(null, $object);
if ($ret < 0) $error++;
if (! $error)

View File

@ -136,7 +136,8 @@ $hookmanager->initHooks(array('contactlist'));
$extrafields = new ExtraFields($db);
// fetch optionals attributes and labels
$extralabels = $extrafields->fetch_name_optionals_label('contact');
$extrafields->fetch_name_optionals_label('contact');
$search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
// List of fields to search into when doing a "search in all"

View File

@ -81,11 +81,10 @@ if ($id > 0 || ! empty($ref) && $action!='add') {
}
// fetch optionals attributes and labels
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
$extrafields->fetch_name_optionals_label($object->table_element);
// fetch optionals attributes lines and labels
$extrafieldsline = new ExtraFields($db);
$extralabelslines=$extrafieldsline->fetch_name_optionals_label($object->table_element_line);
$extralabelslines=$extrafields->fetch_name_optionals_label($object->table_element_line);
$permissionnote=$user->rights->contrat->creer; // Used by the include of actions_setnotes.inc.php
$permissiondellink=$user->rights->contrat->creer; // Used by the include of actions_dellink.inc.php
@ -217,7 +216,7 @@ if (empty($reshook))
}
// Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost($extralabels, $object);
$ret = $extrafields->setOptionalsFromPost(null, $object);
if ($ret < 0) {
$error ++;
$action = 'create';
@ -455,9 +454,8 @@ if (empty($reshook))
}
// Extrafields
$extrafieldsline = new ExtraFields($db);
$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
$array_options = $extrafieldsline->getOptionalsFromPost($object->table_element_line, $predef);
$extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line);
$array_options = $extrafields->getOptionalsFromPost($object->table_element_line, $predef);
// Unset extrafield
if (is_array($extralabelsline)) {
// Get extra fields
@ -736,9 +734,8 @@ if (empty($reshook))
}
// Extrafields
$extrafieldsline = new ExtraFields($db);
$extralabelsline = $extrafieldsline->fetch_name_optionals_label($objectline->table_element);
$array_options = $extrafieldsline->getOptionalsFromPost($object->table_element_line, $predef);
$extralabelsline = $extrafields->fetch_name_optionals_label($objectline->table_element);
$array_options = $extrafields->getOptionalsFromPost($object->table_element_line, $predef);
$objectline->array_options=$array_options;
// TODO verifier price_min si fk_product et multiprix
@ -876,8 +873,7 @@ if (empty($reshook))
$object->oldcopy = dol_clone($object);
// Fill array 'array_options' with data from update form
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
$ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute', 'none'));
$ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute', 'none'));
if ($ret < 0) $error++;
if (! $error) {
@ -1712,7 +1708,7 @@ else
if (is_array($extralabelslines) && count($extralabelslines)>0) {
$line = new ContratLigne($db);
$line->fetch_optionals($objp->rowid);
print $line->showOptionals($extrafieldsline, 'view', array('style'=>'class="oddeven"', 'colspan'=>$colspan), '', '', empty($conf->global->MAIN_EXTRAFIELDS_IN_ONE_TD)?0:1);
print $line->showOptionals($extrafields, 'view', array('style'=>'class="oddeven"', 'colspan'=>$colspan), '', '', empty($conf->global->MAIN_EXTRAFIELDS_IN_ONE_TD)?0:1);
}
}
// Ligne en mode update
@ -1786,7 +1782,7 @@ else
if (is_array($extralabelslines) && count($extralabelslines)>0) {
$line = new ContratLigne($db);
$line->fetch_optionals($objp->rowid);
print $line->showOptionals($extrafieldsline, 'edit', array('style'=>'class="oddeven"', 'colspan'=>$colspan), '', '', empty($conf->global->MAIN_EXTRAFIELDS_IN_ONE_TD)?0:1);
print $line->showOptionals($extrafields, 'edit', array('style'=>'class="oddeven"', 'colspan'=>$colspan), '', '', empty($conf->global->MAIN_EXTRAFIELDS_IN_ONE_TD)?0:1);
}
}

View File

@ -745,8 +745,9 @@ class Contrat extends CommonObject
*/
public function fetch_lines($only_product = 0, $loadalsotranslation = 0)
{
global $langs, $conf;
// phpcs:enable
// phpcs:enable
global $langs, $conf, $extrafields;
$this->nbofserviceswait=0;
$this->nbofservicesopened=0;
$this->nbofservicesexpired=0;
@ -758,10 +759,14 @@ class Contrat extends CommonObject
$now=dol_now();
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
$extrafieldsline=new ExtraFields($this->db);
if (! is_object($extrafields))
{
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
$extrafields=new ExtraFields($this->db);
}
$line = new ContratLigne($this->db);
$extralabelsline=$extrafieldsline->fetch_name_optionals_label($line->table_element, true);
$extrafields->fetch_name_optionals_label($line->table_element, true);
$this->lines=array();
$pos = 0;

View File

@ -100,7 +100,8 @@ $hookmanager->initHooks(array('contractlist'));
$extrafields = new ExtraFields($db);
// fetch optionals attributes and labels
$extralabels = $extrafields->fetch_name_optionals_label('contrat');
$extrafields->fetch_name_optionals_label('contrat');
$search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
// List of fields to search into when doing a "search in all"
$fieldstosearchall = array(

View File

@ -84,7 +84,8 @@ $hookmanager->initHooks(array('contractservicelist'));
$extrafields = new ExtraFields($db);
// fetch optionals attributes and labels
$extralabels = $extrafields->fetch_name_optionals_label('contratdet');
$extrafields->fetch_name_optionals_label('contratdet');
$search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
// Security check

View File

@ -163,7 +163,7 @@ abstract class CommonDocGenerator
/**
* Define array with couple subtitution key => subtitution value
*
* @param Object $object Object
* @param Societe $object Object
* @param Translate $outputlangs Language object for output
* @return array Array of substitution key->code
*/
@ -221,7 +221,7 @@ abstract class CommonDocGenerator
{
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
$extrafields = new ExtraFields($this->db);
$extralabels = $extrafields->fetch_name_optionals_label('societe', true);
$extrafields->fetch_name_optionals_label($object->table_element, true);
$object->fetch_optionals();
foreach($extrafields->attribute_label as $key=>$label)
@ -295,7 +295,7 @@ abstract class CommonDocGenerator
// Retrieve extrafields
require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php';
$extrafields = new ExtraFields($this->db);
$extralabels = $extrafields->fetch_name_optionals_label('socpeople', true);
$extrafields->fetch_name_optionals_label($object->table_element, true);
$object->fetch_optionals();
foreach($extrafields->attribute_label as $key => $label)
@ -517,7 +517,7 @@ abstract class CommonDocGenerator
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
$extrafields = new ExtraFields($this->db);
$extralabels = $extrafields->fetch_name_optionals_label($extrafieldkey, true);
$extrafields->fetch_name_optionals_label($extrafieldkey, true);
$object->fetch_optionals();
$resarray = $this->fill_substitutionarray_with_extrafields($object, $resarray, $extrafields, $array_key, $outputlangs);
@ -592,7 +592,7 @@ abstract class CommonDocGenerator
$array_key="line";
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
$extrafields = new ExtraFields($this->db);
$extralabels = $extrafields->fetch_name_optionals_label($extrafieldkey, true);
$extrafields->fetch_name_optionals_label($extrafieldkey, true);
$line->fetch_optionals();
$resarray = $this->fill_substitutionarray_with_extrafields($line, $resarray, $extrafields, $array_key, $outputlangs);
@ -662,7 +662,7 @@ abstract class CommonDocGenerator
{
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
$extrafields = new ExtraFields($this->db);
$extralabels = $extrafields->fetch_name_optionals_label('expedition', true);
$extrafields->fetch_name_optionals_label('expedition', true);
$object->fetch_optionals();
$array_shipment = $this->fill_substitutionarray_with_extrafields($object, $array_shipment, $extrafields, $array_key, $outputlangs);
@ -712,7 +712,7 @@ abstract class CommonDocGenerator
$array_key = "line";
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
$extrafields = new ExtraFields($this->db);
$extralabels = $extrafields->fetch_name_optionals_label($extrafieldkey, true);
$extrafields->fetch_name_optionals_label($extrafieldkey, true);
$line->fetch_optionals();
$resarray = $this->fill_substitutionarray_with_extrafields($line, $resarray, $extrafields, $array_key, $outputlangs);

View File

@ -3918,13 +3918,16 @@ abstract class CommonObject
*/
public function formAddObjectLine($dateSelector, $seller, $buyer, $defaulttpldir = '/core/tpl')
{
global $conf,$user,$langs,$object,$hookmanager;
global $conf,$user,$langs,$object,$hookmanager,$extrafields;
global $form,$bcnd,$var;
// Line extrafield
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
$extrafieldsline = new ExtraFields($this->db);
$extralabelslines=$extrafieldsline->fetch_name_optionals_label($this->table_element_line);
if (! is_object($extrafields))
{
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
$extrafields = new ExtraFields($this->db);
}
$extrafields->fetch_name_optionals_label($this->table_element_line);
// Output template part (modules that overwrite templates must declare this into descriptor)
// Use global variables + $dateSelector + $seller and $buyer
@ -3970,7 +3973,7 @@ abstract class CommonObject
*/
public function printObjectLines($action, $seller, $buyer, $selected = 0, $dateSelector = 0, $defaulttpldir = '/core/tpl')
{
global $conf, $hookmanager, $langs, $user, $object, $form;
global $conf, $hookmanager, $langs, $user, $object, $form, $extrafields;
// TODO We should not use global var for this
global $inputalsopricewithtax, $usemargins, $disableedit, $disablemove, $disableremove, $outputalsopricetotalwithtax;
@ -3981,11 +3984,14 @@ abstract class CommonObject
$num = count($this->lines);
// Line extrafield
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
$extrafieldsline = new ExtraFields($this->db);
$extralabelslines=$extrafieldsline->fetch_name_optionals_label($this->table_element_line);
if (! is_object($extrafields))
{
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
$extrafields = new ExtraFields($this->db);
}
$extrafields->fetch_name_optionals_label($this->table_element_line);
$parameters = array('num'=>$num,'i'=>$i,'dateSelector'=>$dateSelector,'seller'=>$seller,'buyer'=>$buyer,'selected'=>$selected, 'extrafieldsline'=>$extrafieldsline);
$parameters = array('num'=>$num, 'dateSelector'=>$dateSelector, 'seller'=>$seller, 'buyer'=>$buyer, 'selected'=>$selected, 'table_element_line'=>$this->table_element_line);
$reshook = $hookmanager->executeHooks('printObjectLineTitle', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
if (empty($reshook))
{
@ -4025,18 +4031,18 @@ abstract class CommonObject
{
if (empty($line->fk_parent_line))
{
$parameters = array('line'=>$line,'var'=>$var,'num'=>$num,'i'=>$i,'dateSelector'=>$dateSelector,'seller'=>$seller,'buyer'=>$buyer,'selected'=>$selected, 'extrafieldsline'=>$extrafieldsline);
$parameters = array('line'=>$line,'var'=>$var,'num'=>$num,'i'=>$i,'dateSelector'=>$dateSelector,'seller'=>$seller,'buyer'=>$buyer,'selected'=>$selected, 'table_element_line'=>$line->table_element);
$reshook = $hookmanager->executeHooks('printObjectLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
}
else
{
$parameters = array('line'=>$line,'var'=>$var,'num'=>$num,'i'=>$i,'dateSelector'=>$dateSelector,'seller'=>$seller,'buyer'=>$buyer,'selected'=>$selected, 'extrafieldsline'=>$extrafieldsline, 'fk_parent_line'=>$line->fk_parent_line);
$parameters = array('line'=>$line,'var'=>$var,'num'=>$num,'i'=>$i,'dateSelector'=>$dateSelector,'seller'=>$seller,'buyer'=>$buyer,'selected'=>$selected, 'table_element_line'=>$line->table_element, 'fk_parent_line'=>$line->fk_parent_line);
$reshook = $hookmanager->executeHooks('printObjectSubLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
}
}
if (empty($reshook))
{
$this->printObjectLine($action, $line, $var, $num, $i, $dateSelector, $seller, $buyer, $selected, $extrafieldsline, $defaulttpldir);
$this->printObjectLine($action, $line, $var, $num, $i, $dateSelector, $seller, $buyer, $selected, $extrafields, $defaulttpldir);
}
$i++;
@ -4057,11 +4063,11 @@ abstract class CommonObject
* @param string $seller Object of seller third party
* @param string $buyer Object of buyer third party
* @param int $selected Object line selected
* @param int $extrafieldsline Object of extrafield line attribute
* @param Extrafields $extrafields Object of extrafields
* @param string $defaulttpldir Directory where to find the template
* @return void
*/
public function printObjectLine($action, $line, $var, $num, $i, $dateSelector, $seller, $buyer, $selected = 0, $extrafieldsline = 0, $defaulttpldir = '/core/tpl')
public function printObjectLine($action, $line, $var, $num, $i, $dateSelector, $seller, $buyer, $selected = 0, $extrafields = null, $defaulttpldir = '/core/tpl')
{
global $conf,$langs,$user,$object,$hookmanager;
global $form,$bc,$bcdd;
@ -4897,6 +4903,8 @@ abstract class CommonObject
public function fetch_optionals($rowid = null, $optionsArray = null)
{
// phpcs:enable
global $extrafields;
if (empty($rowid)) $rowid=$this->id;
// To avoid SQL errors. Probably not the better solution though
@ -4909,7 +4917,6 @@ abstract class CommonObject
if (! is_array($optionsArray))
{
// If $extrafields is not a known object, we initialize it. Best practice is to have $extrafields defined into card.php or list.php page.
global $extrafields;
if (! isset($extrafields) || ! is_object($extrafields))
{
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
@ -6591,8 +6598,8 @@ abstract class CommonObject
//$out .= "titlefield";
//if (GETPOST('action', 'none') == 'create') $out.='create';
// BUG #11554 : For public page, use red dot for required fields, instead of bold label
$context = isset($params["context"]) ? $params["context"] : "none";
if ($context=="public") { // Public page : red dot instead of bold ble characters
$tpl_context = isset($params["tpl_context"]) ? $params["tpl_context"] : "none";
if ($tpl_context=="public") { // Public page : red dot instead of fieldrequired characters
$out .= '">';
if (! empty($extrafields->attributes[$this->table_element]['help'][$key])) $out .= $form->textwithpicto($labeltoshow, $extrafields->attributes[$this->table_element]['help'][$key]);
else $out .= $labeltoshow;

View File

@ -825,7 +825,7 @@ class ExtraFields
* Load array this->attributes, or old this->attribute_xxx like attribute_label, attribute_type, ...
*
* @param string $elementtype Type of element ('adherent', 'commande', 'thirdparty', 'facture', 'propal', 'product', ...).
* @param boolean $forceload Force load of extra fields whatever is option MAIN_EXTRAFIELDS_DISABLED. Deprecated. Should not be required.
* @param boolean $forceload Force load of extra fields whatever is status of cache.
* @return array Array of attributes keys+label for all extra fields.
*/
public function fetch_name_optionals_label($elementtype, $forceload = false)
@ -835,14 +835,18 @@ class ExtraFields
if (empty($elementtype)) return array();
if ($elementtype == 'thirdparty') $elementtype='societe';
if ($elementtype == 'contact') $elementtype='socpeople';
if ($elementtype == 'thirdparty') $elementtype='societe';
if ($elementtype == 'contact') $elementtype='socpeople';
if ($elementtype == 'order_supplier') $elementtype='commande_fournisseur';
$array_name_label=array();
// To avoid conflicts with external modules. TODO Remove this.
if (!$forceload && !empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) return $array_name_label;
if (empty($forceload) && !empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) return $array_name_label;
// If already loaded
// TODO Enable this cache test
// if (empty($forceload) && ! empty($this->attributes[$tab->elementtype]['loaded'])) return $array_name_label;
// Set array of label of entity
// TODO Remove completely loading of label. This should be done by presentation.
@ -2007,14 +2011,15 @@ class ExtraFields
/**
* Fill array_options property of object by extrafields value (using for data sent by forms)
*
* @param array $extralabels Deprecated $array of extrafields
* @param array $extralabels Deprecated (old $array of extrafields, now set this to null)
* @param object $object Object
* @param string $onlykey Only following key is filled. When we make update of only one extrafield ($action = 'update_extras'), calling page must must set this to avoid to have other extrafields being reset.
* @param string $onlykey Only the following key is filled. When we make update of only one extrafield ($action = 'update_extras'), calling page must set this to avoid to have other extrafields being reset.
* @return int 1 if array_options set, 0 if no value, -1 if error (field required missing for example)
*/
public function setOptionalsFromPost($extralabels, &$object, $onlykey = '')
{
global $_POST, $langs;
$nofillrequired=0;// For error when required field left blank
$error_field_required = array();

View File

@ -241,7 +241,7 @@ class FormActions
// Ref
print '<td class="nowraponall">'.$ref.'</td>';
// Onwer
print '<td>';
print '<td class="tdoverflowmax150">';
if (! empty($action->userownerid))
{
if (is_object($cacheusers[$action->userownerid]))

View File

@ -145,7 +145,7 @@ class FormTicket
$ticketstat = new Ticket($this->db);
$extrafields = new ExtraFields($this->db);
$extralabels = $extrafields->fetch_name_optionals_label($ticketstat->table_element);
$extrafields->fetch_name_optionals_label($ticketstat->table_element);
print "\n<!-- Begin form TICKET -->\n";

View File

@ -913,7 +913,7 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '')
$contactstatic = new Contact($db);
$extralabels=$extrafields->fetch_name_optionals_label($contactstatic->table_element);
$extrafields->fetch_name_optionals_label($contactstatic->table_element);
$contactstatic->fields=array(
'name' =>array('type'=>'varchar(128)', 'label'=>'Name', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1),

View File

@ -972,11 +972,10 @@ function projectLinesPerAction(&$inc, $parent, $fuser, $lines, &$level, &$projec
* @param array $isavailable Array with data that say if user is available for several days for morning and afternoon
* @param int $oldprojectforbreak Old project id of last project break
* @param array $arrayfields Array of additional column
* @param array $extrafields Array of additional column
* @param array $extralabels Array of additional column
* @param Extrafields $extrafields Object extrafields
* @return array Array with time spent for $fuser for each day of week on tasks in $lines and substasks
*/
function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsrole, &$tasksrole, $mine, $restricteditformytask, $preselectedday, &$isavailable, $oldprojectforbreak = 0, $arrayfields = array(), $extrafields = '', $extralabels = array())
function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsrole, &$tasksrole, $mine, $restricteditformytask, $preselectedday, &$isavailable, $oldprojectforbreak = 0, $arrayfields = array(), $extrafields = null)
{
global $conf, $db, $user, $bc, $langs;
global $form, $formother, $projectstatic, $taskstatic, $thirdpartystatic;
@ -1314,7 +1313,7 @@ function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsr
{
//var_dump('totalforeachday after taskid='.$lines[$i]->id.' and previous one on level '.$level);
//var_dump($totalforeachday);
$ret = projectLinesPerDay($inc, $lines[$i]->id, $fuser, ($parent == 0 ? $lineswithoutlevel0 : $lines), $level, $projectsrole, $tasksrole, $mine, $restricteditformytask, $preselectedday, $isavailable, $oldprojectforbreak, $arrayfields, $extrafields, $extralabels);
$ret = projectLinesPerDay($inc, $lines[$i]->id, $fuser, ($parent == 0 ? $lineswithoutlevel0 : $lines), $level, $projectsrole, $tasksrole, $mine, $restricteditformytask, $preselectedday, $isavailable, $oldprojectforbreak, $arrayfields, $extrafields);
//var_dump('ret with parent='.$lines[$i]->id.' level='.$level);
//var_dump($ret);
foreach($ret as $key => $val)
@ -1352,11 +1351,10 @@ function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsr
* @param array $isavailable Array with data that say if user is available for several days for morning and afternoon
* @param int $oldprojectforbreak Old project id of last project break
* @param array $arrayfields Array of additional column
* @param array $extrafields Array of additional column
* @param array $extralabels Array of additional column
* @param Extrafields $extrafields Object extrafields
* @return array Array with time spent for $fuser for each day of week on tasks in $lines and substasks
*/
function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$level, &$projectsrole, &$tasksrole, $mine, $restricteditformytask, &$isavailable, $oldprojectforbreak = 0, $arrayfields = array(), $extrafields = '', $extralabels = array())
function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$level, &$projectsrole, &$tasksrole, $mine, $restricteditformytask, &$isavailable, $oldprojectforbreak = 0, $arrayfields = array(), $extrafields = null)
{
global $conf, $db, $user, $bc, $langs;
global $form, $formother, $projectstatic, $taskstatic, $thirdpartystatic;
@ -1684,7 +1682,7 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$
{
//var_dump('totalforeachday after taskid='.$lines[$i]->id.' and previous one on level '.$level);
//var_dump($totalforeachday);
$ret = projectLinesPerWeek($inc, $firstdaytoshow, $fuser, $lines[$i]->id, ($parent == 0 ? $lineswithoutlevel0 : $lines), $level, $projectsrole, $tasksrole, $mine, $restricteditformytask, $isavailable, $oldprojectforbreak, $arrayfields, $extrafields, $extralabels);
$ret = projectLinesPerWeek($inc, $firstdaytoshow, $fuser, $lines[$i]->id, ($parent == 0 ? $lineswithoutlevel0 : $lines), $level, $projectsrole, $tasksrole, $mine, $restricteditformytask, $isavailable, $oldprojectforbreak, $arrayfields, $extrafields);
//var_dump('ret with parent='.$lines[$i]->id.' level='.$level);
//var_dump($ret);
foreach($ret as $key => $val)

View File

@ -148,7 +148,7 @@ class doc_generic_project_odt extends ModelePDFProjects
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
$extrafields = new ExtraFields($this->db);
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element, true);
$extrafields->fetch_name_optionals_label($object->table_element, true);
$object->fetch_optionals();
$resarray = $this->fill_substitutionarray_with_extrafields($object, $resarray, $extrafields, $array_key, $outputlangs);
@ -189,8 +189,8 @@ class doc_generic_project_odt extends ModelePDFProjects
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
$extrafields = new ExtraFields($this->db);
$extralabels = $extrafields->fetch_name_optionals_label($task->table_element, true);
$task->fetch_optionals($task->id, $extralabels);
$extrafields->fetch_name_optionals_label($task->table_element, true);
$task->fetch_optionals($task->id);
$resarray = $this->fill_substitutionarray_with_extrafields($task, $resarray, $extrafields, 'task', $outputlangs);
@ -235,7 +235,7 @@ class doc_generic_project_odt extends ModelePDFProjects
// fetch external user extrafields
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
$extrafields=new ExtraFields($this->db);
$extralabels=$extrafields->fetch_name_optionals_label($ct->table_element, true);
$extrafields->fetch_name_optionals_label($ct->table_element, true);
$extrafields_num = $ct->fetch_optionals();
//dol_syslog(get_class($this)."::get_substitutionarray_project_contacts: ===== Number of Extrafields found: ".$extrafields_num, LOG_DEBUG);
foreach($ct->array_options as $efkey => $efval) {

View File

@ -154,7 +154,7 @@ class doc_generic_task_odt extends ModelePDFTask
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
$extrafields = new ExtraFields($this->db);
$extralabels = $extrafields->fetch_name_optionals_label($extrafieldkey, true);
$extrafields->fetch_name_optionals_label($extrafieldkey, true);
$object->fetch_optionals();
$resarray = $this->fill_substitutionarray_with_extrafields($object, $resarray, $extrafields, $array_key, $outputlangs);

View File

@ -245,7 +245,7 @@ class pdf_stdmovement extends ModelePDFMovement
$extrafields = new ExtraFields($db);
// fetch optionals attributes and labels
$extralabels = $extrafields->fetch_name_optionals_label('movement');
$extrafields->fetch_name_optionals_label('movement');
$search_array_options=$extrafields->getOptionalsFromPost('movement', '', 'search_');
$productlot=new ProductLot($db);

View File

@ -261,26 +261,27 @@ print '<script type="text/javascript" language="javascript">
// Standard Extrafield feature
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) {
$elementtype = Societe::$table_element;
// fetch optionals attributes and labels
dol_include_once('/core/class/extrafields.class.php');
$extrafields = new ExtraFields($db);
$extralabels = $extrafields->fetch_name_optionals_label('societe');
foreach ($extralabels as $key => $val) {
$extrafields->fetch_name_optionals_label($elementtype);
foreach ($extrafields->attributes[$elementtype]['label'] as $key => $val) {
if ($key != 'ts_nameextra' && $key != 'ts_payeur') {
print '<tr><td>' . $extrafields->attribute_label[$key];
print '<tr><td>' . $extrafields->attributes[$elementtype]['label'][$key];
if (! empty($array_query['options_' . $key]) || (is_array($array_query['options_' . $key]) && count($array_query['options_' . $key]) > 0)) {
print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing');
}
print '</td><td>';
if (($extrafields->attribute_type[$key] == 'varchar') || ($extrafields->attribute_type[$key] == 'text')) {
if (($extrafields->attributes[$elementtype]['type'][$key] == 'varchar') || ($extrafields->attributes[$elementtype]['type'][$key] == 'text')) {
print '<input type="text" name="options_' . $key . '"/></td><td>' . "\n";
print $form->textwithpicto('', $langs->trans("AdvTgtSearchTextHelp"), 1, 'help');
} elseif (($extrafields->attribute_type[$key] == 'int') || ($extrafields->attribute_type[$key] == 'double')) {
} elseif (($extrafields->attributes[$elementtype]['type'][$key] == 'int') || ($extrafields->attributes[$elementtype]['type'][$key] == 'double')) {
print $langs->trans("AdvTgtMinVal") . '<input type="text" name="options' . $key . '_min"/>';
print $langs->trans("AdvTgtMaxVal") . '<input type="text" name="options' . $key . '_max"/>';
print '</td><td>' . "\n";
print $form->textwithpicto('', $langs->trans("AdvTgtSearchIntHelp"), 1, 'help');
} elseif (($extrafields->attribute_type[$key] == 'date') || ($extrafields->attribute_type[$key] == 'datetime')) {
} elseif (($extrafields->attributes[$elementtype]['type'][$key] == 'date') || ($extrafields->attributes[$elementtype]['type'][$key] == 'datetime')) {
print '<table class="nobordernopadding"><tr>';
print '<td>' . $langs->trans("AdvTgtStartDt") . '</td><td>';
@ -291,7 +292,7 @@ print '<script type="text/javascript" language="javascript">
print '</td><td>' . "\n";
print $form->textwithpicto('', $langs->trans("AdvTgtSearchDtHelp"), 1, 'help');
} elseif (($extrafields->attribute_type[$key] == 'boolean')) {
} elseif (($extrafields->attributes[$elementtype]['type'][$key] == 'boolean')) {
print $form->selectarray(
'options_' . $key,
array (
@ -302,10 +303,10 @@ print '<script type="text/javascript" language="javascript">
$array_query['options_' . $key]
);
print '</td><td>' . "\n";
} elseif (($extrafields->attribute_type[$key] == 'select')) {
} elseif (($extrafields->attributes[$elementtype]['type'][$key] == 'select')) {
print $formadvtargetemaling->advMultiselectarray('options_' . $key, $extrafields->attribute_param[$key]['options'], $array_query['options_' . $key]);
print '</td><td>' . "\n";
} elseif (($extrafields->attribute_type[$key] == 'sellist')) {
} elseif (($extrafields->attributes[$elementtype]['type'][$key] == 'sellist')) {
print $formadvtargetemaling->advMultiselectarraySelllist('options_' . $key, $extrafields->attribute_param[$key]['options'], $array_query['options_' . $key]);
print '</td><td>' . "\n";
} else {
@ -456,31 +457,31 @@ print '<script type="text/javascript" language="javascript">
// Standard Extrafield feature
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) {
$elementype=Contact::$table_element;
// fetch optionals attributes and labels
dol_include_once('/core/class/extrafields.class.php');
$extrafields = new ExtraFields($db);
$extralabels = $extrafields->fetch_name_optionals_label('socpeople');
foreach($extrafields->attribute_type as $key=>&$value) {
$extrafields->fetch_name_optionals_label($elementype);
foreach($extrafields->attributes[$elementtype]['type'] as $key=>&$value) {
if($value == 'radio')$value = 'select';
}
foreach ($extrafields-> as $key => $val) {
foreach ($extralabels as $key => $val) {
print '<tr><td>' . $extrafields->attribute_label[$key];
print '<tr><td>' . $extrafields->attributes[$elementtype]['label'][$key];
if ($array_query['options_' . $key . '_cnct'] != '' || (is_array($array_query['options_' . $key . '_cnct']) && count($array_query['options_' . $key . '_cnct']) > 0)) {
print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing');
}
print '</td><td>';
if (($extrafields->attribute_type[$key] == 'varchar') || ($extrafields->attribute_type[$key] == 'text')) {
if (($extrafields->attributes[$elementtype]['type'][$key] == 'varchar') || ($extrafields->attributes[$elementtype]['type'][$key] == 'text')) {
print '<input type="text" name="options_' . $key . '_cnct"/></td><td>' . "\n";
print $form->textwithpicto('', $langs->trans("AdvTgtSearchTextHelp"), 1, 'help');
} elseif (($extrafields->attribute_type[$key] == 'int') || ($extrafields->attribute_type[$key] == 'double')) {
} elseif (($extrafields->attributes[$elementtype]['type'][$key] == 'int') || ($extrafields->attributes[$elementtype]['type'][$key] == 'double')) {
print $langs->trans("AdvTgtMinVal") . '<input type="text" name="options_' . $key . '_min_cnct"/>';
print $langs->trans("AdvTgtMaxVal") . '<input type="text" name="options_' . $key . '_max_cnct"/>';
print '</td><td>' . "\n";
print $form->textwithpicto('', $langs->trans("AdvTgtSearchIntHelp"), 1, 'help');
} elseif (($extrafields->attribute_type[$key] == 'date') || ($extrafields->attribute_type[$key] == 'datetime')) {
} elseif (($extrafields->attributes[$elementtype]['type'][$key] == 'date') || ($extrafields->attributes[$elementtype]['type'][$key] == 'datetime')) {
print '<table class="nobordernopadding"><tr>';
print '<td>' . $langs->trans("AdvTgtStartDt") . '</td><td>';
@ -491,7 +492,7 @@ print '<script type="text/javascript" language="javascript">
print '</td><td>' . "\n";
print $form->textwithpicto('', $langs->trans("AdvTgtSearchDtHelp"), 1, 'help');
} elseif (($extrafields->attribute_type[$key] == 'boolean')) {
} elseif (($extrafields->attributes[$elementtype]['type'][$key] == 'boolean')) {
print $form->selectarray(
'options_' . $key . '_cnct',
array (
@ -502,10 +503,10 @@ print '<script type="text/javascript" language="javascript">
$array_query['options_' . $key . '_cnct']
);
print '</td><td>' . "\n";
} elseif (($extrafields->attribute_type[$key] == 'select')) {
} elseif (($extrafields->attributes[$elementtype]['type'][$key] == 'select')) {
print $formadvtargetemaling->advMultiselectarray('options_' . $key . '_cnct', $extrafields->attribute_param[$key]['options'], $array_query['options_' . $key . '_cnct']);
print '</td><td>' . "\n";
} elseif (($extrafields->attribute_type[$key] == 'sellist')) {
} elseif (($extrafields->attributes[$elementtype]['type'][$key] == 'sellist')) {
print $formadvtargetemaling->advMultiselectarraySelllist('options_' . $key . '_cnct', $extrafields->attribute_param[$key]['options'], $array_query['options_' . $key . '_cnct']);
print '</td><td>' . "\n";
} else {

View File

@ -41,8 +41,8 @@ $parameters = array();
$reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
if (empty($reshook)) {
$params = isset($tpl_context) ? array('context' => $tpl_context) : array(); // BUG #11554 : Add context in params
print $object->showOptionals($extrafields, 'edit', $params); // BUG #11554 : Add context in params
$params = isset($tpl_context) ? array('tpl_context' => $tpl_context) : array(); // BUG #11554 : Add tpl_context in params
print $object->showOptionals($extrafields, 'edit', $params); // BUG #11554 : Add context in params
}
?>

View File

@ -24,7 +24,7 @@ if (! empty($extrafieldsobjectkey)) // $extrafieldsobject is the $object->table_
$sortonfield = $extrafieldsobjectprefix.$key;
if (! empty($extrafields->attributes[$extrafieldsobjectkey]['computed'][$key])) $sortonfield='';
if ($extrafields->attributes[$extrafieldsobjectkey]['type'][$key] == 'separate') print '<th class="liste_titre thseparator"></th>';
else print getTitleFieldOfList($langs->trans($extralabels[$key]), 0, $_SERVER["PHP_SELF"], $sortonfield, "", $param, ($align?'align="'.$align.'" data-titlekey="'.$key.'"':'data-titlekey="'.$key.'"'), $sortfield, $sortorder)."\n";
else print getTitleFieldOfList($extrafields->attributes[$extrafieldsobjectkey]['label'][$key], 0, $_SERVER["PHP_SELF"], $sortonfield, "", $param, ($align?'align="'.$align.'" data-titlekey="'.$key.'"':'data-titlekey="'.$key.'"'), $sortfield, $sortorder)."\n";
}
}
}

View File

@ -15,7 +15,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* Need to have following variables defined:
* Show extrafields. It also show fields from hook formObjectOptions. Need to have following variables defined:
* $object (invoice, order, ...)
* $action
* $conf
@ -24,6 +24,7 @@
* $parameters
* $cols
*/
// Protection to avoid direct call of template
if (empty($object) || ! is_object($object))
{

View File

@ -259,9 +259,9 @@ $coldisplay=0;
<?php
//Line extrafield
if (!empty($extrafieldsline))
if (!empty($extrafields))
{
print $line->showOptionals($extrafieldsline, 'edit', array('class'=>'tredited', 'colspan'=>$coldisplay), '', '', empty($conf->global->MAIN_EXTRAFIELDS_IN_ONE_TD)?0:1);
print $line->showOptionals($extrafields, 'edit', array('class'=>'tredited', 'colspan'=>$coldisplay), '', '', empty($conf->global->MAIN_EXTRAFIELDS_IN_ONE_TD)?0:1);
}
?>

View File

@ -163,7 +163,7 @@ $domData .= ' data-product_type="'.$line->product_type.'"';
print (! empty($line->description) && $line->description!=$line->product_label)?'<br>'.dol_htmlentitiesbr($line->description):'';
}
}
if ($user->rights->fournisseur->lire && $line->fk_fournprice > 0)
{
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php';
@ -359,7 +359,7 @@ $domData .= ' data-product_type="'.$line->product_type.'"';
<?php
}
if($action == 'selectlines'){ ?>
if ($action == 'selectlines') { ?>
<td class="linecolcheck center"><input type="checkbox" class="linecheckbox" name="line_checkbox[<?php echo $i+1; ?>]" value="<?php echo $line->id; ?>" ></td>
<?php } ?>
@ -367,9 +367,9 @@ $domData .= ' data-product_type="'.$line->product_type.'"';
<?php
//Line extrafield
if (!empty($extrafieldsline))
if (!empty($extrafields))
{
print $line->showOptionals($extrafieldsline, 'view', array('style'=>'class="drag drop oddeven"','colspan'=>$coldisplay), '', '', empty($conf->global->MAIN_EXTRAFIELDS_IN_ONE_TD)?0:1);
print $line->showOptionals($extrafields, 'view', array('style'=>'class="drag drop oddeven"','colspan'=>$coldisplay), '', '', empty($conf->global->MAIN_EXTRAFIELDS_IN_ONE_TD)?0:1);
}
?>

View File

@ -70,7 +70,7 @@ $hookmanager->initHooks(array('cronjoblist'));
$extrafields = new ExtraFields($db);
// fetch optionals attributes and labels
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
$extrafields->fetch_name_optionals_label($object->table_element);
$search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_');

View File

@ -60,7 +60,7 @@ $extrafields = new ExtraFields($db);
$result = restrictedArea($user, 'don', $id);
// fetch optionals attributes and labels
$extralabels=$extrafields->fetch_name_optionals_label($object->table_element);
$extrafields->fetch_name_optionals_label($object->table_element);
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$hookmanager->initHooks(array('doncard','globalcard'));
@ -117,7 +117,7 @@ if ($action == 'update')
$object->modepaymentid = GETPOST('modepayment', 'int');
// Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost($extralabels, $object);
$ret = $extrafields->setOptionalsFromPost(null, $object);
if ($ret < 0) $error++;
if ($object->update($user) > 0)
@ -172,7 +172,7 @@ if ($action == 'add')
$object->modepaymentid = GETPOST('modepayment', 'int');
// Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost($extralabels, $object);
$ret = $extrafields->setOptionalsFromPost(null, $object);
if ($ret < 0) $error++;
$res = $object->create($user);
@ -455,7 +455,7 @@ if ($action == 'create')
print $hookmanager->resPrint;
if (empty($reshook))
{
print $object->showOptionals($extrafields, 'edit', $parameters);
print $object->showOptionals($extrafields, 'edit');
}
print '</tbody>';

View File

@ -88,13 +88,10 @@ $hideref = (GETPOST('hideref', 'int') ? GETPOST('hideref', 'int') : (! empty($
$object = new Expedition($db);
$extrafields = new ExtraFields($db);
$extrafieldsline = new ExtraFields($db);
// fetch optionals attributes and labels
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
// fetch optionals attributes lines and labels
$extralabelslines=$extrafieldsline->fetch_name_optionals_label($object->table_element_line);
$extrafields->fetch_name_optionals_label($object->table_element);
$extrafields->fetch_name_optionals_label($object->table_element_line);
// Load object. Make an object->fetch
@ -165,8 +162,7 @@ if (empty($reshook))
$object->oldcopy = dol_clone($object);
// Fill array 'array_options' with data from update form
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
$ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute', 'none'));
$ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute', 'none'));
if ($ret < 0) $error++;
if (! $error)
@ -306,8 +302,8 @@ if (empty($reshook))
}
// Extrafields
$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
$array_options[$i] = $extrafieldsline->getOptionalsFromPost($extralabelsline, $i);
$extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line);
$array_options[$i] = $extrafields->getOptionalsFromPost($object->table_element_line, $i);
// Unset extrafield
if (is_array($extralabelsline)) {
// Get extra fields
@ -379,7 +375,7 @@ if (empty($reshook))
}
}
// Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost($extralabels, $object);
$ret = $extrafields->setOptionalsFromPost(null, $object);
if ($ret < 0) $error++;
if (! $error)
@ -630,10 +626,10 @@ if (empty($reshook))
if ($lines[$i]->id == $line_id) // we have found line to update
{
$line = new ExpeditionLigne($db);
// Extrafields Lines
$extrafieldsline = new ExtraFields($db);
$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
$line->array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline);
$extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line);
$line->array_options = $extrafields->getOptionalsFromPost($object->table_element_line);
// Unset extrafield POST Data
if (is_array($extralabelsline)) {
foreach ($extralabelsline as $key => $value) {
@ -1576,21 +1572,17 @@ if ($action == 'create')
}
}
//Display lines extrafields
if (is_array($extralabelslines) && count($extralabelslines)>0)
// Line extrafield
if (!empty($extrafields))
{
$colspan=5;
$orderLineExtrafields = new Extrafields($db);
$orderLineExtrafieldLabels = $orderLineExtrafields->fetch_name_optionals_label($object->table_element_line);
$extrafields->fetch_name_optionals_label($object->table_element_line);
$srcLine = new OrderLine($db);
$srcLine->fetch_optionals($line->id); // fetch extrafields also available in orderline
$line = new ExpeditionLigne($db);
//$line->fetch_optionals($line->id);
$line->array_options = array_merge($line->array_options, $srcLine->array_options);
print '<tr class="oddeven">';
print $line->showOptionals($extrafieldsline, 'edit', array('style'=>$bc[$var], 'colspan'=>$colspan), $indiceAsked);
print '</tr>';
print $line->showOptionals($extrafields, 'edit', array('style'=>'class="drag drop oddeven"','colspan'=>$colspan), $indiceAsked, '', empty($conf->global->MAIN_EXTRAFIELDS_IN_ONE_TD)?0:1);
}
}
@ -2456,18 +2448,21 @@ elseif ($id || $ref)
print "</tr>";
// Display lines extrafields
if (is_array($extralabelslines) && count($extralabelslines)>0) {
if (! empty($extrafields)) {
$colspan= empty($conf->productbatch->enabled) ? 5 : 6;
$line = new ExpeditionLigne($db);
$line->fetch_optionals($lines[$i]->id);
$lines[$i]->fetch_optionals($lines[$i]->id);
$extrafields->fetch_name_optionals_label($lines[$i]->table_element);
print '<tr class="oddeven">';
if ($action == 'editline' && $lines[$i]->id == $line_id)
{
print $line->showOptionals($extrafieldsline, 'edit', array('style'=>$bc[$var], 'colspan'=>$colspan), $indiceAsked);
print $lines[$i]->showOptionals($extrafields, 'edit', array('colspan'=>$colspan), $indiceAsked);
}
else
{
print $line->showOptionals($extrafieldsline, 'view', array('style'=>$bc[$var], 'colspan'=>$colspan), $indiceAsked);
print $lines[$i]->showOptionals($extrafields, 'view', array('colspan'=>$colspan), $indiceAsked);
}
print '</tr>';
}

View File

@ -84,7 +84,8 @@ $hookmanager->initHooks(array('shipmentlist'));
$extrafields = new ExtraFields($db);
// fetch optionals attributes and labels
$extralabels = $extrafields->fetch_name_optionals_label('expedition');
$extrafields->fetch_name_optionals_label($object->table_element);
$search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
// List of fields to search into when doing a "search in all"
@ -455,19 +456,7 @@ if ($resql)
if (! empty($arrayfields['l.ref']['checked'])) print_liste_field_titre($arrayfields['l.ref']['label'], $_SERVER["PHP_SELF"], "l.ref", "", $param, '', $sortfield, $sortorder);
if (! empty($arrayfields['l.date_delivery']['checked'])) print_liste_field_titre($arrayfields['l.date_delivery']['label'], $_SERVER["PHP_SELF"], "l.date_delivery", "", $param, '', $sortfield, $sortorder, 'center ');
// Extra fields
if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
{
foreach($extrafields->attribute_label as $key => $val)
{
if (! empty($arrayfields["ef.".$key]['checked']))
{
$align=$extrafields->getAlignFlag($key);
$sortonfield = "ef.".$key;
if (! empty($extrafields->attribute_computed[$key])) $sortonfield='';
print_liste_field_titre($extralabels[$key], $_SERVER["PHP_SELF"], $sortonfield, "", $param, ($align?'align="'.$align.'"':''), $sortfield, $sortorder);
}
}
}
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
// Hook fields
$parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder);
$reshook=$hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook

View File

@ -60,7 +60,7 @@ $object = new Commande($db);
$extrafields = new ExtraFields($db);
// fetch optionals attributes and labels
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
$extrafields->fetch_name_optionals_label($object->table_element);
// Load object
include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once
@ -189,8 +189,7 @@ if (empty($reshook))
$object->oldcopy = dol_clone($object);
// Fill array 'array_options' with data from update form
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
$ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute', 'none'));
$ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute', 'none'));
if ($ret < 0) $error++;
if (! $error)

View File

@ -97,7 +97,7 @@ $object=new ExpenseReport($db);
$extrafields = new ExtraFields($db);
// fetch optionals attributes and labels
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
$extrafields->fetch_name_optionals_label($object->table_element);
// Load object
include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once
@ -238,7 +238,7 @@ if (empty($reshook))
// Fill array 'array_options' with data from add form
if (! $error)
{
$ret = $extrafields->setOptionalsFromPost($extralabels, $object);
$ret = $extrafields->setOptionalsFromPost(null, $object);
if ($ret < 0) $error++;
}
@ -309,8 +309,7 @@ if (empty($reshook))
$object->oldcopy = dol_clone($object);
// Fill array 'array_options' with data from update form
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
$ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute', 'none'));
$ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute', 'none'));
if ($ret < 0) $error++;
if (! $error)

View File

@ -108,7 +108,8 @@ $hookmanager->initHooks(array('expensereportlist'));
$extrafields = new ExtraFields($db);
// fetch optionals attributes and labels
$extralabels = $extrafields->fetch_name_optionals_label('expensereport');
$extrafields->fetch_name_optionals_label('expensereport');
$search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_');

View File

@ -70,6 +70,7 @@ if ($sortfield == "")
$sortfield="f.datec";
$object = new FichinterRec($db);
$extrafields = new ExtraFields($db);
$arrayfields=array(
@ -176,8 +177,8 @@ if ($action == 'add') {
$newinter->note_public=$object->note_public;
// on créer un nouvelle intervention
$extrafields = new ExtraFields($db);
$extralabels = $extrafields->fetch_name_optionals_label($newinter->table_element);
$extrafields->fetch_name_optionals_label($newinter->table_element);
$array_options = $extrafields->getOptionalsFromPost($newinter->table_element);
$newinter->array_options = $array_options;

View File

@ -82,7 +82,8 @@ $hookmanager->initHooks(array('interventioncard','globalcard'));
$object = new Fichinter($db);
$extrafields = new ExtraFields($db);
$extralabels=$extrafields->fetch_name_optionals_label($object->table_element);
$extrafields->fetch_name_optionals_label($object->table_element);
// Load object
if ($id > 0 || ! empty($ref))
@ -258,7 +259,6 @@ if (empty($reshook))
// Extrafields
$extrafields = new ExtraFields($db);
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
$array_options = $extrafields->getOptionalsFromPost($object->table_element);
$object->array_options = $array_options;
@ -361,11 +361,10 @@ if (empty($reshook))
$predef = '';
// Extrafields
$extrafieldsline = new ExtraFields($db);
$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
$array_options = $extrafieldsline->getOptionalsFromPost($object->table_element_line, $predef);
$extrafields->fetch_name_optionals_label($object->table_element_line);
$array_options = $extrafields->getOptionalsFromPost($object->table_element_line, $predef);
$result = $object->addline(
$result = $object->addline(
$user,
$id,
$desc,
@ -397,7 +396,7 @@ if (empty($reshook))
else
{
// Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost($extralabels, $object);
$ret = $extrafields->setOptionalsFromPost(null, $object);
if ($ret < 0) {
$error ++;
$action = 'create';
@ -406,7 +405,6 @@ if (empty($reshook))
if (! $error)
{
// Extrafields
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
$array_options = $extrafields->getOptionalsFromPost($object->table_element);
$object->array_options = $array_options;
@ -506,11 +504,10 @@ if (empty($reshook))
// Extrafields
$extrafieldsline = new ExtraFields($db);
$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
$array_options = $extrafieldsline->getOptionalsFromPost($object->table_element_line);
$extrafields->fetch_name_optionals_label($object->table_element_line);
$array_options = $extrafields->getOptionalsFromPost($object->table_element_line);
$result=$object->addline(
$result=$object->addline(
$user,
$id,
$desc,
@ -618,9 +615,8 @@ if (empty($reshook))
$objectline->duration = $duration;
// Extrafields
$extrafieldsline = new ExtraFields($db);
$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
$array_options = $extrafieldsline->getOptionalsFromPost($object->table_element_line);
$extrafields->fetch_name_optionals_label($object->table_element_line);
$array_options = $extrafields->getOptionalsFromPost($object->table_element_line);
$objectline->array_options = $array_options;
$result = $objectline->update($user);
@ -740,8 +736,7 @@ if (empty($reshook))
$object->oldcopy = dol_clone($object);
// Fill array 'array_options' with data from update form
$extralabels=$extrafields->fetch_name_optionals_label($object->table_element);
$ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute', 'none'));
$ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute', 'none'));
if ($ret < 0) $error++;
if (! $error)
@ -1461,12 +1456,11 @@ elseif ($id > 0 || ! empty($ref))
$line = new FichinterLigne($db);
$line->fetch($objp->rowid);
$extrafieldsline = new ExtraFields($db);
$extralabelslines=$extrafieldsline->fetch_name_optionals_label($line->table_element);
$extrafields->fetch_name_optionals_label($line->table_element);
$line->fetch_optionals();
print $line->showOptionals($extrafieldsline, 'view', array('style'=>$bc[$var], 'colspan'=>5));
print $line->showOptionals($extrafields, 'view', array('colspan'=>5));
}
// Line in update mode
@ -1508,11 +1502,10 @@ elseif ($id > 0 || ! empty($ref))
$line = new FichinterLigne($db);
$line->fetch($objp->rowid);
$extrafieldsline = new ExtraFields($db);
$extralabelslines=$extrafieldsline->fetch_name_optionals_label($line->table_element);
$extrafields->fetch_name_optionals_label($line->table_element);
$line->fetch_optionals();
print $line->showOptionals($extrafieldsline, 'edit', array('style'=>$bc[$var], 'colspan'=>5));
print $line->showOptionals($extrafields, 'edit', array('colspan'=>5));
}
$i++;
@ -1581,10 +1574,9 @@ elseif ($id > 0 || ! empty($ref))
$lineadd = new FichinterLigne($db);
$extrafieldsline = new ExtraFields($db);
$extralabelslines=$extrafieldsline->fetch_name_optionals_label($lineadd->table_element);
$extrafields->fetch_name_optionals_label($lineadd->table_element);
print $lineadd->showOptionals($extrafieldsline, 'edit', array('style'=>$bc[$var], 'colspan'=>5));
print $lineadd->showOptionals($extrafields, 'edit', array('colspan'=>5));
if (! $num) print '</table>';
}

View File

@ -83,10 +83,12 @@ if (! $sortfield)
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$object = new Fichinter($db);
$hookmanager->initHooks(array('interventionlist'));
$extrafields = new ExtraFields($db);
// fetch optionals attributes and labels
$extralabels = $extrafields->fetch_name_optionals_label('fichinter');
$extrafields->fetch_name_optionals_label('fichinter');
$search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
// List of fields to search into when doing a "search in all"

View File

@ -59,7 +59,7 @@ $object = new Fournisseur($db);
$extrafields = new ExtraFields($db);
// fetch optionals attributes and labels
$extralabels=$extrafields->fetch_name_optionals_label($object->table_element);
$extrafields->fetch_name_optionals_label($object->table_element);
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$hookmanager->initHooks(array('suppliercard','globalcard'));
@ -120,8 +120,7 @@ if (empty($reshook))
$object->oldcopy = dol_clone($object);
// Fill array 'array_options' with data from update form
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
$ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute', 'none'));
$ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute', 'none'));
if ($ret < 0) $error++;

View File

@ -91,7 +91,7 @@ $object = new CommandeFournisseur($db);
$extrafields = new ExtraFields($db);
// fetch optionals attributes and labels
$extralabels=$extrafields->fetch_name_optionals_label($object->table_element);
$extrafields->fetch_name_optionals_label($object->table_element);
// Load object
if ($id > 0 || ! empty($ref))
@ -370,9 +370,8 @@ if (empty($reshook))
$price_ht_devise = GETPOST('multicurrency_price_ht');
// Extrafields
$extrafieldsline = new ExtraFields($db);
$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
$array_options = $extrafieldsline->getOptionalsFromPost($object->table_element_line, $predef);
$extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line);
$array_options = $extrafields->getOptionalsFromPost($object->table_element_line, $predef);
// Unset extrafield
if (is_array($extralabelsline)) {
// Get extra fields
@ -678,9 +677,8 @@ if (empty($reshook))
$pu_ht_devise = GETPOST('multicurrency_subprice');
// Extrafields Lines
$extrafieldsline = new ExtraFields($db);
$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
$array_options = $extrafieldsline->getOptionalsFromPost($object->table_element_line);
$extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line);
$array_options = $extrafields->getOptionalsFromPost($object->table_element_line);
// Unset extrafield POST Data
if (is_array($extralabelsline)) {
foreach ($extralabelsline as $key => $value) {
@ -1042,8 +1040,7 @@ if (empty($reshook))
$object->oldcopy = dol_clone($object);
// Fill array 'array_options' with data from add form
$extralabels=$extrafields->fetch_name_optionals_label($object->table_element);
$ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute', 'none'));
$ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute', 'none'));
if ($ret < 0) $error++;
if (! $error)
@ -1100,7 +1097,7 @@ if (empty($reshook))
// Fill array 'array_options' with data from add form
if (! $error)
{
$ret = $extrafields->setOptionalsFromPost($extralabels, $object);
$ret = $extrafields->setOptionalsFromPost(null, $object);
if ($ret < 0) $error++;
}

View File

@ -115,7 +115,8 @@ $hookmanager->initHooks(array('supplierorderlist'));
$extrafields = new ExtraFields($db);
// fetch optionals attributes and labels
$extralabels = $extrafields->fetch_name_optionals_label('commande_fournisseur');
$extrafields->fetch_name_optionals_label('commande_fournisseur');
$search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
// List of fields to search into when doing a "search in all"

View File

@ -73,9 +73,10 @@ $date_endy = dol_mktime(23, 59, 59, $_REQUEST["date_end_delymonth"], $_REQUEST["
$extrafields = new ExtraFields($db);
$object = new FactureFournisseur($db);
// fetch optionals attributes and labels
$extralabels=$extrafields->fetch_name_optionals_label('facture_fourn');
$extrafields->fetch_name_optionals_label($object->table_element);
if ($action == 'create')
{
@ -176,7 +177,7 @@ if (($action == 'create' || $action == 'add') && ! $error) {
if (empty($object->date_echeance))
$object->date_echeance = $object->calculate_date_lim_reglement();
$ret = $extrafields->setOptionalsFromPost($extralabels, $object);
$ret = $extrafields->setOptionalsFromPost(null, $object);
if ($ret < 0) $error++;
if ($_POST['origin'] && $_POST['originid']) {

View File

@ -82,7 +82,7 @@ $object=new FactureFournisseur($db);
$extrafields = new ExtraFields($db);
// fetch optionals attributes and labels
$extralabels=$extrafields->fetch_name_optionals_label($object->table_element);
$extrafields->fetch_name_optionals_label($object->table_element);
// Load object
if ($id > 0 || ! empty($ref))
@ -608,8 +608,7 @@ if (empty($reshook))
$error = 0;
// Fill array 'array_options' with data from add form
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
$ret = $extrafields->setOptionalsFromPost($extralabels, $object);
$ret = $extrafields->setOptionalsFromPost(null, $object);
if ($ret < 0) $error++;
$datefacture=dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']);
@ -1076,9 +1075,8 @@ if (empty($reshook))
$pu_ht_devise = GETPOST('multicurrency_subprice');
// Extrafields Lines
$extrafieldsline = new ExtraFields($db);
$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
$array_options = $extrafieldsline->getOptionalsFromPost($object->table_element_line);
$extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line);
$array_options = $extrafields->getOptionalsFromPost($object->table_element_line);
// Unset extrafield POST Data
if (is_array($extralabelsline)) {
foreach ($extralabelsline as $key => $value) {
@ -1153,9 +1151,8 @@ if (empty($reshook))
$price_ht_devise = GETPOST('multicurrency_price_ht');
// Extrafields
$extrafieldsline = new ExtraFields($db);
$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
$array_options = $extrafieldsline->getOptionalsFromPost($object->table_element_line, $predef);
$extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line);
$array_options = $extrafields->getOptionalsFromPost($object->table_element_line, $predef);
// Unset extrafield
if (is_array($extralabelsline)) {
// Get extra fields
@ -1529,8 +1526,7 @@ if (empty($reshook))
$object->oldcopy = dol_clone($object);
// Fill array 'array_options' with data from add form
$extralabels=$extrafields->fetch_name_optionals_label($object->table_element);
$ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute', 'none'));
$ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute', 'none'));
if ($ret < 0) $error++;
if (! $error)
@ -1633,7 +1629,6 @@ llxHeader('', $title, $helpurl);
if ($action == 'create')
{
$facturestatic = new FactureFournisseur($db);
$extralabels = $extrafields->fetch_name_optionals_label($facturestatic->table_element);
print load_fiche_titre($langs->trans('NewBill'));
@ -2175,9 +2170,6 @@ else
$result=$societe->fetch($object->socid);
if ($result < 0) dol_print_error($db);
// fetch optionals attributes and labels
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
$totalpaye = $object->getSommePaiement();
$totalcreditnotes = $object->getSumCreditNotesUsed();
$totaldeposits = $object->getSumDepositsUsed();

View File

@ -130,7 +130,8 @@ $hookmanager->initHooks(array('supplierinvoicelist'));
$extrafields = new ExtraFields($db);
// fetch optionals attributes and labels
$extralabels = $extrafields->fetch_name_optionals_label('facture_fourn');
$extrafields->fetch_name_optionals_label($object->table_element);
$search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
// List of fields to search into when doing a "search in all"

View File

@ -83,14 +83,16 @@ if ($user->societe_id > 0)
$socid = $user->societe_id;
}
$object = new PaiementFourn($db);
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$hookmanager->initHooks(array('paymentsupplierlist'));
$extrafields = new ExtraFields($db);
// fetch optionals attributes and labels
$extralabels = $extrafields->fetch_name_optionals_label('paymentsupplier');
$search_array_options=$extrafields->getOptionalsFromPost('paymentsupplier', '', 'search_');
$extrafields->fetch_name_optionals_label($object->table_element);
$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
$arrayfields=array();

View File

@ -68,7 +68,7 @@ $object = new Holiday($db);
$extrafields = new ExtraFields($db);
// fetch optionals attributes and labels
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
$extrafields->fetch_name_optionals_label($object->table_element);
if ($id > 0)
{
@ -505,8 +505,7 @@ if (empty($reshook))
$object->oldcopy = dol_clone($object);
// Fill array 'array_options' with data from update form
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
$ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute', 'none'));
$ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute', 'none'));
if ($ret < 0) $error++;
if (! $error)

View File

@ -114,7 +114,8 @@ $extrafields = new ExtraFields($db);
$hookmanager->initHooks(array('holidaylist')); // Note that conf->hooks_modules contains array
// Fetch optionals attributes and labels
$extralabels = $extrafields->fetch_name_optionals_label('holiday');
$extrafields->fetch_name_optionals_label($object->table_element);
$search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
// List of fields to search into when doing a "search in all"

View File

@ -61,13 +61,12 @@ $result=restrictedArea($user, 'expedition', $id, 'livraison', 'livraison');
$object = new Livraison($db);
$extrafields = new ExtraFields($db);
$extrafieldsline = new ExtraFields($db);
// fetch optionals attributes and labels
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
$extrafields->fetch_name_optionals_label($object->table_element);
// fetch optionals attributes lines and labels
$extralabelslines=$extrafieldsline->fetch_name_optionals_label($object->table_element_line);
$extrafields->fetch_name_optionals_label($object->table_element_line);
// Load object. Make an object->fetch
include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once
@ -196,8 +195,7 @@ if ($action == 'update_extras')
$object->oldcopy = dol_clone($object);
// Fill array 'array_options' with data from update form
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
$ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute', 'none'));
$ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute', 'none'));
if ($ret < 0) $error++;
if (! $error)
@ -224,8 +222,8 @@ if ($action == 'update_extras_line')
for ($i = 0; $i < $num; $i++)
{
// Extrafields
$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
$array_options[$i] = $extrafieldsline->getOptionalsFromPost($extralabelsline, $i);
$extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line);
$array_options[$i] = $extrafields->getOptionalsFromPost($extralabelsline, $i);
// Unset extrafield
if (is_array($extralabelsline)) {
// Get extra fields
@ -676,21 +674,20 @@ else
print "</tr>";
// Display lines extrafields
if (is_array($extralabelslines) && count($extralabelslines) > 0) {
if (! empty($extrafields)) {
$colspan = 2;
$mode = ($object->statut == 0) ? 'edit' : 'view';
$line = new LivraisonLigne($db);
$line->fetch_optionals($object->lines[$i]->id);
$object->lines[$i]->fetch_optionals($object->lines[$i]->id);
if ($action == 'create_delivery') {
$srcLine = new ExpeditionLigne($db);
$expeditionLineExtrafields = new Extrafields($db);
$expeditionLineExtrafieldLabels = $expeditionLineExtrafields->fetch_name_optionals_label($srcLine->table_element);
$extrafields->fetch_name_optionals_label($srcLine->table_element);
$srcLine->fetch_optionals($expedition->lines[$i]->id);
$line->array_options = array_merge($line->array_options, $srcLine->array_options);
$object->lines[$i]->array_options = array_merge($object->lines[$i]->array_options, $srcLine->array_options);
}
print '<tr class="oddeven">';
print $line->showOptionals($extrafieldsline, $mode, array('style' => 'class="oddeven"', 'colspan' => $colspan), $i);
print '</tr>';
print $object->lines[$i]->showOptionals($extrafields, $mode, array('style' => 'class="oddeven"', 'colspan' => $colspan), $i);
}
}

View File

@ -87,7 +87,7 @@ $extrafields = new ExtraFields($db);
$diroutputmassaction=$conf->mymodule->dir_output . '/temp/massgeneration/'.$user->id;
$hookmanager->initHooks(array('myobjectagenda','globalcard')); // Note that conf->hooks_modules contains array
// Fetch optionals attributes and labels
$extralabels = $extrafields->fetch_name_optionals_label('myobject');
$extrafields->fetch_name_optionals_label($object->table_element);
// Load object
include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals

View File

@ -80,8 +80,10 @@ $object=new MyObject($db);
$extrafields = new ExtraFields($db);
$diroutputmassaction=$conf->mymodule->dir_output . '/temp/massgeneration/'.$user->id;
$hookmanager->initHooks(array('myobjectcard','globalcard')); // Note that conf->hooks_modules contains array
// Fetch optionals attributes and labels
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
$extrafields->fetch_name_optionals_label($object->table_element);
$search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
// Initialize array of search criterias
@ -209,6 +211,8 @@ if ($action == 'create')
print '</div>';
print '</form>';
//dol_set_focus('input[name="ref"]');
}
// Part to edit record
@ -354,7 +358,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
//$keyforbreak='fieldkeytoswitchonsecondcolumn';
include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_view.tpl.php';
// Other attributes
// Other attributes. Fields from hook formObjectOptions and Extrafields.
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
print '</table>';

View File

@ -76,7 +76,7 @@ $extrafields = new ExtraFields($db);
$diroutputmassaction=$conf->mymodule->dir_output . '/temp/massgeneration/'.$user->id;
$hookmanager->initHooks(array('myobjectdocument','globalcard')); // Note that conf->hooks_modules contains array
// Fetch optionals attributes and labels
$extralabels = $extrafields->fetch_name_optionals_label('myobject');
$extrafields->fetch_name_optionals_label($object->table_element);
// Load object
include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals

View File

@ -100,11 +100,8 @@ $diroutputmassaction = $conf->mymodule->dir_output . '/temp/massgeneration/'.$us
$hookmanager->initHooks(array('myobjectlist')); // Note that conf->hooks_modules contains array
// Fetch optionals attributes and labels
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
// fetch optionals attributes lines and labels
//$extrafieldsline = new ExtraFields($db);
//$extralabelslines=$extrafieldsline->fetch_name_optionals_label($object->table_element_line);
$extrafields->fetch_name_optionals_label($object->table_element);
//$extrafields->fetch_name_optionals_label($object->table_element_line);
$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');

View File

@ -56,7 +56,7 @@ $extrafields = new ExtraFields($db);
$diroutputmassaction=$conf->mymodule->dir_output . '/temp/massgeneration/'.$user->id;
$hookmanager->initHooks(array('myobjectnote','globalcard')); // Note that conf->hooks_modules contains array
// Fetch optionals attributes and labels
$extralabels = $extrafields->fetch_name_optionals_label('myobject');
$extrafields->fetch_name_optionals_label($object->table_element);
// Security check - Protection if external user
//if ($user->societe_id > 0) access_forbidden();

View File

@ -63,7 +63,7 @@ $extrafields = new ExtraFields($db);
$diroutputmassaction = $conf->opensurvey->dir_output . '/temp/massgeneration/'.$user->id;
$hookmanager->initHooks(array('surveylist')); // Note that conf->hooks_modules contains array
// Fetch optionals attributes and labels
$extralabels = $extrafields->fetch_name_optionals_label('survey'); // Load $extrafields->attributes['myobject']
$extrafields->fetch_name_optionals_label($object->table_element);
$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
// Default sort order (if not yet defined by previous GETPOST)

View File

@ -83,7 +83,7 @@ $object->type = $type; // so test later to fill $usercancxxx is correct
$extrafields = new ExtraFields($db);
// fetch optionals attributes and labels
$extralabels=$extrafields->fetch_name_optionals_label($object->table_element);
$extrafields->fetch_name_optionals_label($object->table_element);
if ($id > 0 || ! empty($ref))
{
@ -340,7 +340,7 @@ if (empty($reshook))
}
// Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost($extralabels, $object);
$ret = $extrafields->setOptionalsFromPost(null, $object);
if ($ret < 0) $error++;
if (! $error)
@ -452,7 +452,7 @@ if (empty($reshook))
if ($accountancy_code_buy <= 0) { $object->accountancy_code_buy = ''; } else { $object->accountancy_code_buy = $accountancy_code_buy; }
// Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost($extralabels, $object);
$ret = $extrafields->setOptionalsFromPost(null, $object);
if ($ret < 0) $error++;
if (! $error && $object->check())

View File

@ -155,7 +155,7 @@ class PriceParser
//Retrieve all extrafield for product and add it to values
$extrafields = new ExtraFields($this->db);
$extralabels = $extrafields->fetch_name_optionals_label('product', true);
$extrafields->fetch_name_optionals_label('product', true);
$product->fetch_optionals();
if (is_array($extrafields->attributes[$product->table_element]['label']))
{

View File

@ -32,9 +32,10 @@ $langs->loadLangs(array("stocks","other"));
// Get parameters
$id = GETPOST('id', 'int');
$ref = GETPOST('ref', 'alpha');
$action = GETPOST('action', 'alpha');
$action = GETPOST('action', 'aZ09');
$confirm = GETPOST('confirm', 'alpha');
$cancel = GETPOST('cancel', 'aZ09');
$contextpage= GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'myobjectcard'; // To manage different context of search
$backtopage = GETPOST('backtopage', 'alpha');
if (empty($conf->global->MAIN_USE_ADVANCED_PERMS))
@ -51,9 +52,11 @@ $object=new Inventory($db);
$extrafields = new ExtraFields($db);
$diroutputmassaction=$conf->stock->dir_output . '/temp/massgeneration/'.$user->id;
$hookmanager->initHooks(array('inventorycard')); // Note that conf->hooks_modules contains array
// Fetch optionals attributes and labels
$extralabels = $extrafields->fetch_name_optionals_label('inventory');
$search_array_options=$extrafields->getOptionalsFromPost('inventory', '', 'search_');
$extrafields->fetch_name_optionals_label($object->table_element);
$search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
// Initialize array of search criterias
$search_all=trim(GETPOST("search_all", 'alpha'));
@ -65,17 +68,14 @@ foreach($object->fields as $key => $val)
if (empty($action) && empty($id) && empty($ref)) $action='view';
// Load object
include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once.
// Security check - Protection if external user
//if ($user->societe_id > 0) access_forbidden();
//if ($user->societe_id > 0) $socid = $user->societe_id;
//$result = restrictedArea($user, 'mymodule', $id);
// fetch optionals attributes and labels
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
// Load object
include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once.
if (empty($conf->global->MAIN_USE_ADVANCED_PERMS))
{
$permissiontoadd = $user->rights->stock->creer;
@ -102,9 +102,12 @@ if (empty($reshook))
$backurlforlist = DOL_URL_ROOT.'/product/inventory/list.php';
// Actions cancel, add, update or delete
// Actions cancel, add, update, delete or clone
include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php';
// Actions when linking object each other
include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php';
// Actions when printing a doc from card
include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php';
@ -124,7 +127,7 @@ if (empty($reshook))
$form=new Form($db);
llxHeader('', 'Inventory', '');
llxHeader('', $langs->trans('Inventory'), '');
// Example : Adding jquery code
print '<script type="text/javascript" language="javascript">
@ -154,7 +157,7 @@ if ($action == 'create')
dol_fiche_head(array(), '');
print '<table class="border centpercent">'."\n";
print '<table class="border centpercent tableforfieldcreate">'."\n";
// Common attributes
include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_add.tpl.php';
@ -190,7 +193,7 @@ if (($id || $ref) && $action == 'edit')
dol_fiche_head();
print '<table class="border centpercent">'."\n";
print '<table class="border centpercent tableforfield">'."\n";
// Common attributes
include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_edit.tpl.php';
@ -223,6 +226,18 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
if ($action == 'delete') {
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('DeleteInventory'), $langs->trans('ConfirmDeleteOrder'), 'confirm_delete', '', 0, 1);
}
// Confirmation to delete line
if ($action == 'deleteline')
{
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_deleteline', '', 0, 1);
}
// Clone confirmation
if ($action == 'clone') {
// Create an array for form
$formquestion = array();
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneMyObject', $object->ref), 'confirm_clone', $formquestion, 'yes', 1);
}
// Call Hook formConfirm
$parameters = array('lineid' => $lineid);
@ -236,8 +251,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
// Object card
// ------------------------------------------------------------
$linkback = '<a href="' . DOL_URL_ROOT . '/inventory/inventory_list.php' . (! empty($socid) ? '?socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>';
$linkback = '<a href="' . DOL_URL_ROOT . '/product/inventory/list.php' . (! empty($socid) ? '?socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>';
$morehtmlref='<div class="refidno">';
/*
@ -272,9 +286,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
if (! empty($object->fk_project)) {
$proj = new Project($db);
$proj->fetch($object->fk_project);
$morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">';
$morehtmlref.=$proj->ref;
$morehtmlref.='</a>';
$morehtmlref.=$proj->getNomUrl();
} else {
$morehtmlref.='';
}
@ -295,25 +307,14 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
// Common attributes
include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_view.tpl.php';
// Other attributes
// Other attributes. Fields from hook formObjectOptions and Extrafields.
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
print '</table>';
print '</div>';
/* Second column
print '<div class="fichehalfright">';
print '<div class="ficheaddleft">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border centpercent">';
print '</table>';
print '</div>';*/
print '</div>';
print '</div>';
print '<div class="clearboth"></div><br>';
print '<div class="clearboth"></div>';
dol_fiche_end();

View File

@ -58,7 +58,7 @@ $extrafields = new ExtraFields($db);
$diroutputmassaction=$conf->inventory->dir_output . '/temp/massgeneration/'.$user->id;
$hookmanager->initHooks(array('inventorylist')); // Note that conf->hooks_modules contains array
// Fetch optionals attributes and labels
$extralabels = $extrafields->fetch_name_optionals_label('inventory');
$extrafields->fetch_name_optionals_label($object->table_element);
$search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
// Default sort order (if not yet defined by previous GETPOST)

View File

@ -103,7 +103,7 @@ $extrafields = new ExtraFields($db);
$form=new Form($db);
// fetch optionals attributes and labels
$extralabels = $extrafields->fetch_name_optionals_label('product');
$extrafields->fetch_name_optionals_label('product');
$search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
if (empty($action)) $action='list';

Some files were not shown because too many files have changed in this diff Show More