Merge pull request #793 from jfefe/extrafields
Task #784 : display calendar into data type extrafields / new methods to manage extrafields
This commit is contained in:
commit
cf4603f5af
@ -64,6 +64,9 @@ if (! empty($conf->mailmanspip->enabled))
|
||||
$object = new Adherent($db);
|
||||
$extrafields = new ExtraFields($db);
|
||||
|
||||
// fetch optionals attributes and labels
|
||||
$extralabels=$extrafields->fetch_name_optionals_label('member');
|
||||
|
||||
// Get object canvas (By default, this is not defined, so standard usage of dolibarr)
|
||||
$object->getCanvas($socid);
|
||||
$canvas = $object->canvas?$object->canvas:GETPOST("canvas");
|
||||
@ -282,14 +285,8 @@ if ($action == 'update' && ! $_POST["cancel"] && $user->rights->adherent->creer)
|
||||
$object->statut = $_POST["statut"];
|
||||
$object->public = $_POST["public"];
|
||||
|
||||
// Get extra fields
|
||||
foreach($_POST as $key => $value)
|
||||
{
|
||||
if (preg_match("/^options_/",$key))
|
||||
{
|
||||
$object->array_options[$key]=$_POST[$key];
|
||||
}
|
||||
}
|
||||
// Fill array 'array_options' with data from add form
|
||||
$ret = $extrafields->setOptionalsFromPost($extralabels,$object);
|
||||
|
||||
// Check if we need to also synchronize user information
|
||||
$nosyncuser=0;
|
||||
@ -460,14 +457,8 @@ if ($action == 'add' && $user->rights->adherent->creer)
|
||||
$object->fk_soc = $socid;
|
||||
$object->public = $public;
|
||||
|
||||
// Get extra fields
|
||||
foreach($_POST as $key => $value)
|
||||
{
|
||||
if (preg_match("/^options_/",$key))
|
||||
{
|
||||
$object->array_options[$key]=$_POST[$key];
|
||||
}
|
||||
}
|
||||
// Fill array 'array_options' with data from add form
|
||||
$ret = $extrafields->setOptionalsFromPost($extralabels,$object);
|
||||
|
||||
// Check parameters
|
||||
if (empty($morphy) || $morphy == "-1") {
|
||||
@ -693,9 +684,6 @@ if ($user->rights->adherent->creer && $action == 'confirm_add_spip' && $confirm
|
||||
$form = new Form($db);
|
||||
$formcompany = new FormCompany($db);
|
||||
|
||||
// fetch optionals attributes and labels
|
||||
$extralabels=$extrafields->fetch_name_optionals_label('member');
|
||||
|
||||
$help_url='EN:Module_Foundations|FR:Module_Adhérents|ES:Módulo_Miembros';
|
||||
llxHeader('',$langs->trans("Member"),$help_url);
|
||||
|
||||
@ -894,15 +882,7 @@ else
|
||||
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
|
||||
if (empty($reshook) && ! empty($extrafields->attribute_label))
|
||||
{
|
||||
foreach($extrafields->attribute_label as $key=>$label)
|
||||
{
|
||||
$value=(isset($_POST["options_".$key])?GETPOST('options_'.$key,'alpha'):(isset($object->array_options["options_".$key])?$object->array_options["options_".$key]:''));
|
||||
print '<tr><td';
|
||||
if (! empty($extrafields->attribute_required[$key])) print ' class="fieldrequired"';
|
||||
print '>'.$label.'</td><td>';
|
||||
print $extrafields->showInputField($key,$value);
|
||||
print '</td></tr>'."\n";
|
||||
}
|
||||
print $object->showOptionals($extrafields,'edit');
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1137,15 +1117,7 @@ else
|
||||
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
|
||||
if (empty($reshook) && ! empty($extrafields->attribute_label))
|
||||
{
|
||||
foreach($extrafields->attribute_label as $key=>$label)
|
||||
{
|
||||
$value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$object->array_options["options_".$key]);
|
||||
print '<tr><td';
|
||||
if (! empty($extrafields->attribute_required[$key])) print ' class="fieldrequired"';
|
||||
print '>'.$label.'</td><td>';
|
||||
print $extrafields->showInputField($key,$value);
|
||||
print '</td></tr>'."\n";
|
||||
}
|
||||
print $object->showOptionals($extrafields,'edit');
|
||||
}
|
||||
|
||||
// Third party Dolibarr
|
||||
@ -1467,13 +1439,7 @@ else
|
||||
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
|
||||
if (empty($reshook) && ! empty($extrafields->attribute_label))
|
||||
{
|
||||
foreach($extrafields->attribute_label as $key=>$label)
|
||||
{
|
||||
$value=$object->array_options["options_$key"];
|
||||
print "<tr><td>".$label."</td><td>";
|
||||
print $extrafields->showOutputField($key,$value);
|
||||
print "</td></tr>\n";
|
||||
}
|
||||
print $object->showOptionals($extrafields);
|
||||
}
|
||||
|
||||
// Third party Dolibarr
|
||||
|
||||
@ -56,6 +56,9 @@ $result=restrictedArea($user,'adherent',$rowid,'adherent_type');
|
||||
|
||||
$extrafields = new ExtraFields($db);
|
||||
|
||||
// fetch optionals attributes and labels
|
||||
$extralabels=$extrafields->fetch_name_optionals_label('adherent_type');
|
||||
|
||||
if (GETPOST('button_removefilter'))
|
||||
{
|
||||
$search_lastname="";
|
||||
@ -84,14 +87,8 @@ if ($action == 'add' && $user->rights->adherent->configurer)
|
||||
$adht->mail_valid = trim($_POST["mail_valid"]);
|
||||
$adht->vote = trim($_POST["vote"]);
|
||||
|
||||
// Get extra fields
|
||||
foreach($_POST as $key => $value)
|
||||
{
|
||||
if (preg_match("/^options_/",$key))
|
||||
{
|
||||
$adht->array_options[$key]=GETPOST($key);
|
||||
}
|
||||
}
|
||||
// Fill array 'array_options' with data from add form
|
||||
$ret = $extrafields->setOptionalsFromPost($extralabels,$adht);
|
||||
|
||||
if ($adht->libelle)
|
||||
{
|
||||
@ -127,14 +124,8 @@ if ($action == 'update' && $user->rights->adherent->configurer)
|
||||
$adht->mail_valid = trim($_POST["mail_valid"]);
|
||||
$adht->vote = trim($_POST["vote"]);
|
||||
|
||||
// Get extra fields
|
||||
foreach($_POST as $key => $value)
|
||||
{
|
||||
if (preg_match("/^options_/",$key))
|
||||
{
|
||||
$adht->array_options[$key]=GETPOST($key);
|
||||
}
|
||||
}
|
||||
// Fill array 'array_options' with data from add form
|
||||
$ret = $extrafields->setOptionalsFromPost($extralabels,$adht);
|
||||
|
||||
$adht->update($user->id);
|
||||
|
||||
@ -167,8 +158,6 @@ llxHeader('',$langs->trans("MembersTypeSetup"),'EN:Module_Foundations|FR:Module_
|
||||
|
||||
$form=new Form($db);
|
||||
|
||||
// fetch optionals attributes and labels
|
||||
$extralabels=$extrafields->fetch_name_optionals_label('adherent_type');
|
||||
|
||||
// Liste of members type
|
||||
|
||||
@ -245,6 +234,7 @@ if (! $rowid && $action != 'create' && $action != 'edit')
|
||||
if ($action == 'create')
|
||||
{
|
||||
$form = new Form($db);
|
||||
$adht = new AdherentType($db);
|
||||
|
||||
print_fiche_titre($langs->trans("NewMemberType"));
|
||||
|
||||
@ -278,23 +268,11 @@ if ($action == 'create')
|
||||
// Other attributes
|
||||
$parameters=array();
|
||||
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$act,$action); // Note that $action and $object may have been modified by hook
|
||||
|
||||
print "</table>\n";
|
||||
|
||||
if (empty($reshook) && ! empty($extrafields->attribute_label))
|
||||
{
|
||||
print '<br><br><table class="border" width="100%">';
|
||||
foreach($extrafields->attribute_label as $key=>$label)
|
||||
{
|
||||
$value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$act->array_options["options_".$key]);
|
||||
print '<tr><td';
|
||||
if (! empty($extrafields->attribute_required[$key])) print ' class="fieldrequired"';
|
||||
print ' width="30%">'.$label.'</td><td>';
|
||||
print $extrafields->showInputField($key,$value);
|
||||
print '</td></tr>'."\n";
|
||||
}
|
||||
print '</table><br><br>';
|
||||
print $adht->showOptionals($extrafields,'edit');
|
||||
}
|
||||
print "</table>\n";
|
||||
|
||||
print '<br>';
|
||||
print '<center><input type="submit" name="button" class="button" value="'.$langs->trans("Add").'"> ';
|
||||
@ -356,23 +334,13 @@ if ($rowid > 0)
|
||||
// Other attributes
|
||||
$parameters=array();
|
||||
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$act,$action); // Note that $action and $object may have been modified by hook
|
||||
|
||||
print '</table>';
|
||||
|
||||
//Extra field
|
||||
if (empty($reshook) && ! empty($extrafields->attribute_label))
|
||||
{
|
||||
print '<br><br><table class="border" width="100%">';
|
||||
foreach($extrafields->attribute_label as $key=>$label)
|
||||
{
|
||||
$value=(isset($_POST["options_".$key])?$_POST["options_".$key]:(isset($adht->array_options['options_'.$key])?$adht->array_options['options_'.$key]:''));
|
||||
print '<tr><td width="30%">'.$label.'</td><td>';
|
||||
print $extrafields->showOutputField($key,$value);
|
||||
print "</td></tr>\n";
|
||||
}
|
||||
print '</table><br><br>';
|
||||
// View extrafields
|
||||
print $adht->showOptionals($extrafields);
|
||||
}
|
||||
|
||||
print '</table>';
|
||||
print '</div>';
|
||||
|
||||
/*
|
||||
|
||||
@ -63,6 +63,9 @@ $actioncomm = new ActionComm($db);
|
||||
$contact = new Contact($db);
|
||||
$extrafields = new ExtraFields($db);
|
||||
|
||||
// fetch optionals attributes and labels
|
||||
$extralabels=$extrafields->fetch_name_optionals_label('actioncomm');
|
||||
|
||||
//var_dump($_POST);
|
||||
|
||||
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
|
||||
@ -203,14 +206,8 @@ if ($action == 'add_action')
|
||||
$mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Date")).'</div>';
|
||||
}
|
||||
|
||||
// Get extra fields
|
||||
foreach($_POST as $key => $value)
|
||||
{
|
||||
if (preg_match("/^options_/",$key))
|
||||
{
|
||||
$actioncomm->array_options[$key]=GETPOST($key);
|
||||
}
|
||||
}
|
||||
// Fill array 'array_options' with data from add form
|
||||
$ret = $extrafields->setOptionalsFromPost($extralabels,$actioncomm);
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
@ -343,14 +340,8 @@ if ($action == 'update')
|
||||
}
|
||||
$actioncomm->userdone = $userdone;
|
||||
|
||||
// Get extra fields
|
||||
foreach($_POST as $key => $value)
|
||||
{
|
||||
if (preg_match("/^options_/",$key))
|
||||
{
|
||||
$actioncomm->array_options[$key]=GETPOST($key);
|
||||
}
|
||||
}
|
||||
// Fill array 'array_options' with data from add form
|
||||
$ret = $extrafields->setOptionalsFromPost($extralabels,$actioncomm);
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
@ -395,9 +386,6 @@ llxHeader('',$langs->trans("Agenda"),$help_url);
|
||||
$form = new Form($db);
|
||||
$htmlactions = new FormActions($db);
|
||||
|
||||
// fetch optionals attributes and labels
|
||||
$extralabels=$extrafields->fetch_name_optionals_label('actioncomm');
|
||||
|
||||
if ($action == 'create')
|
||||
{
|
||||
$contact = new Contact($db);
|
||||
@ -603,22 +591,13 @@ if ($action == 'create')
|
||||
$parameters=array();
|
||||
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$actioncomm,$action); // Note that $action and $object may have been modified by hook
|
||||
|
||||
print '</table>';
|
||||
|
||||
if (empty($reshook) && ! empty($extrafields->attribute_label))
|
||||
{
|
||||
print '<br><br><table class="border" width="100%">';
|
||||
foreach($extrafields->attribute_label as $key=>$label)
|
||||
{
|
||||
$value=(isset($_POST["options_".$key])?$_POST["options_".$key]:(isset($actioncomm->array_options["options_".$key])?$actioncomm->array_options["options_".$key]:''));
|
||||
print '<tr><td';
|
||||
if (! empty($extrafields->attribute_required[$key])) print ' class="fieldrequired"';
|
||||
print ' width="30%">'.$label.'</td><td>';
|
||||
print $extrafields->showInputField($key,$value);
|
||||
print '</td></tr>'."\n";
|
||||
}
|
||||
print '</table><br>';
|
||||
print $actioncomm->showOptionals($extrafields,'edit');
|
||||
}
|
||||
|
||||
print '</table>';
|
||||
|
||||
print '<center><br>';
|
||||
print '<input type="submit" class="button" value="'.$langs->trans("Add").'">';
|
||||
@ -838,24 +817,13 @@ if ($id > 0)
|
||||
// Other attributes
|
||||
$parameters=array('colspan' => ' colspan="3"', 'colspanvalue' => '3');
|
||||
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$act,$action); // Note that $action and $object may have been modified by hook
|
||||
|
||||
print '</table>';
|
||||
|
||||
if (empty($reshook) && ! empty($extrafields->attribute_label))
|
||||
{
|
||||
print '<br><br><table class="border" width="100%">';
|
||||
foreach($extrafields->attribute_label as $key=>$label)
|
||||
{
|
||||
$value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$act->array_options["options_".$key]);
|
||||
print '<tr><td';
|
||||
if (! empty($extrafields->attribute_required[$key])) print ' class="fieldrequired"';
|
||||
print ' width="30%">'.$label.'</td><td>';
|
||||
print $extrafields->showInputField($key,$value);
|
||||
print '</td></tr>'."\n";
|
||||
}
|
||||
print '</table><br><br>';
|
||||
print $actioncomm->showOptionals($extrafields,'edit');
|
||||
|
||||
}
|
||||
|
||||
print '</table>';
|
||||
|
||||
print '<center><br><input type="submit" class="button" name="edit" value="'.$langs->trans("Save").'">';
|
||||
print ' <input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
|
||||
|
||||
@ -48,6 +48,9 @@ $result=$object->fetch($id);
|
||||
|
||||
$extrafields = new ExtraFields($db);
|
||||
|
||||
// fetch optionals attributes and labels
|
||||
$extralabels=$extrafields->fetch_name_optionals_label('mailing');
|
||||
|
||||
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
|
||||
$hookmanager->initHooks(array('mailingcard'));
|
||||
|
||||
@ -631,8 +634,6 @@ if (! empty($_POST["cancel"]))
|
||||
* View
|
||||
*/
|
||||
|
||||
// fetch optionals attributes and labels
|
||||
$extralabels=$extrafields->fetch_name_optionals_label('mailing');
|
||||
|
||||
$help_url='EN:Module_EMailing|FR:Module_Mailing|ES:Módulo_Mailing';
|
||||
llxHeader('',$langs->trans("Mailing"),$help_url);
|
||||
@ -661,15 +662,7 @@ if ($action == 'create')
|
||||
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
|
||||
if (empty($reshook) && ! empty($extrafields->attribute_label))
|
||||
{
|
||||
foreach($extrafields->attribute_label as $key=>$label)
|
||||
{
|
||||
$value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$object->array_options["options_".$key]);
|
||||
print '<tr><td';
|
||||
if (! empty($extrafields->attribute_required[$key])) print ' class="fieldrequired"';
|
||||
print '>'.$label.'</td><td colspan="3">';
|
||||
print $extrafields->showInputField($key,$value);
|
||||
print '</td></tr>'."\n";
|
||||
}
|
||||
print $object->showOptionals($extrafields,'edit');
|
||||
}
|
||||
|
||||
print '</table>';
|
||||
@ -823,15 +816,7 @@ else
|
||||
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
|
||||
if (empty($reshook) && ! empty($extrafields->attribute_label))
|
||||
{
|
||||
foreach($extrafields->attribute_label as $key=>$label)
|
||||
{
|
||||
$value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$object->array_options["options_".$key]);
|
||||
print '<tr><td';
|
||||
if (! empty($extrafields->attribute_required[$key])) print ' class="fieldrequired"';
|
||||
print '>'.$label.'</td><td colspan="3">';
|
||||
print $extrafields->showInputField($key,$value);
|
||||
print "</td></tr>\n";
|
||||
}
|
||||
print $object->showOptionals($extrafields);
|
||||
}
|
||||
|
||||
print '</table>';
|
||||
@ -1072,15 +1057,7 @@ else
|
||||
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
|
||||
if (empty($reshook) && ! empty($extrafields->attribute_label))
|
||||
{
|
||||
foreach($extrafields->attribute_label as $key=>$label)
|
||||
{
|
||||
$value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$object->array_options["options_".$key]);
|
||||
print '<tr><td';
|
||||
if (! empty($extrafields->attribute_required[$key])) print ' class="fieldrequired"';
|
||||
print '>'.$label.'</td><td colspan="3">';
|
||||
print $extrafields->showInputField($key,$value);
|
||||
print "</td></tr>\n";
|
||||
}
|
||||
print $object->showOptionals($extrafields,'edit');
|
||||
}
|
||||
|
||||
print '</table>';
|
||||
|
||||
@ -1347,24 +1347,7 @@ if ($action == 'create')
|
||||
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
|
||||
if (empty($reshook) && ! empty($extrafields->attribute_label))
|
||||
{
|
||||
foreach($extrafields->attribute_label as $key=>$label)
|
||||
{
|
||||
$value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$object->array_options["options_".$key]);
|
||||
|
||||
// Show separator only
|
||||
if ($extrafields->attribute_type[$key] == 'separate')
|
||||
{
|
||||
print $extrafields->showSeparator($key);
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<tr><td';
|
||||
if (! empty($extrafields->attribute_required[$key])) print ' class="fieldrequired"';
|
||||
print '>'.$label.'</td><td colspan="3">';
|
||||
print $extrafields->showInputField($key,$value);
|
||||
print '</td></tr>'."\n";
|
||||
}
|
||||
}
|
||||
print $object->showOptionals($extrafields,'edit');
|
||||
}
|
||||
|
||||
print "</table>";
|
||||
@ -1849,7 +1832,7 @@ else
|
||||
print '<input type="hidden" name="id" value="'.$object->id.'">';
|
||||
}
|
||||
|
||||
|
||||
// TODO : use showOptionals($extrafields) function
|
||||
foreach($extrafields->attribute_label as $key=>$label)
|
||||
{
|
||||
$value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$object->array_options["options_".$key]);
|
||||
@ -2279,4 +2262,4 @@ else
|
||||
// End of page
|
||||
llxFooter();
|
||||
$db->close();
|
||||
?>
|
||||
?>
|
||||
|
||||
@ -1564,15 +1564,7 @@ if ($action == 'send' && ! GETPOST('addfile') && ! GETPOST('removedfile') && ! G
|
||||
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
|
||||
if (empty($reshook) && ! empty($extrafields->attribute_label))
|
||||
{
|
||||
foreach($extrafields->attribute_label as $key=>$label)
|
||||
{
|
||||
$value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$object->array_options["options_".$key]);
|
||||
print '<tr><td';
|
||||
if (! empty($extrafields->attribute_required[$key])) print ' class="fieldrequired"';
|
||||
print '>'.$label.'</td><td colspan="3">';
|
||||
print $extrafields->showInputField($key,$value);
|
||||
print '</td></tr>'."\n";
|
||||
}
|
||||
print $object->showOptionals($extrafields,'edit');
|
||||
}
|
||||
|
||||
// Template to use by default
|
||||
@ -2091,15 +2083,7 @@ if ($action == 'send' && ! GETPOST('addfile') && ! GETPOST('removedfile') && ! G
|
||||
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
|
||||
if (empty($reshook) && ! empty($extrafields->attribute_label))
|
||||
{
|
||||
foreach($extrafields->attribute_label as $key=>$label)
|
||||
{
|
||||
$value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$object->array_options["options_".$key]);
|
||||
print '<tr><td';
|
||||
if (! empty($extrafields->attribute_required[$key])) print ' class="fieldrequired"';
|
||||
print '>'.$label.'</td><td colspan="3">';
|
||||
print $extrafields->showInputField($key,$value);
|
||||
print '</td></tr>'."\n";
|
||||
}
|
||||
print $object->showOptionals($extrafields,'edit');
|
||||
}
|
||||
|
||||
// Total HT
|
||||
|
||||
@ -2097,23 +2097,7 @@ if ($action == 'create')
|
||||
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
|
||||
if (empty($reshook) && ! empty($extrafields->attribute_label))
|
||||
{
|
||||
foreach($extrafields->attribute_label as $key=>$label)
|
||||
{
|
||||
$value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$object->array_options["options_".$key]);
|
||||
// Show separator only
|
||||
if ($extrafields->attribute_type[$key] == 'separate')
|
||||
{
|
||||
print $extrafields->showSeparator($key);
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<tr><td';
|
||||
if (! empty($extrafields->attribute_required[$key])) print ' class="fieldrequired"';
|
||||
print '>'.$label.'</td><td colspan="3">';
|
||||
print $extrafields->showInputField($key,$value);
|
||||
print '</td></tr>'."\n";
|
||||
}
|
||||
}
|
||||
print $object->showOptionals($extrafields,'edit');
|
||||
}
|
||||
|
||||
// Modele PDF
|
||||
|
||||
@ -50,6 +50,9 @@ if ($user->societe_id) $socid=$user->societe_id;
|
||||
$object = new Contact($db);
|
||||
$extrafields = new ExtraFields($db);
|
||||
|
||||
// fetch optionals attributes and labels
|
||||
$extralabels=$extrafields->fetch_name_optionals_label('contact');
|
||||
|
||||
// Get object canvas (By default, this is not defined, so standard usage of dolibarr)
|
||||
$object->getCanvas($id);
|
||||
$objcanvas=null;
|
||||
@ -155,14 +158,8 @@ if (empty($reshook))
|
||||
$object->birthday = dol_mktime(0,0,0,$_POST["birthdaymonth"],$_POST["birthdayday"],$_POST["birthdayyear"]);
|
||||
$object->birthday_alert = $_POST["birthday_alert"];
|
||||
|
||||
// Get extra fields
|
||||
foreach($_POST as $key => $value)
|
||||
{
|
||||
if (preg_match("/^options_/",$key))
|
||||
{
|
||||
$object->array_options[$key]=GETPOST($key);
|
||||
}
|
||||
}
|
||||
// Fill array 'array_options' with data from add form
|
||||
$ret = $extrafields->setOptionalsFromPost($extralabels,$object);
|
||||
|
||||
if (! $_POST["lastname"])
|
||||
{
|
||||
@ -252,14 +249,8 @@ if (empty($reshook))
|
||||
$object->priv = $_POST["priv"];
|
||||
$object->note = $_POST["note"];
|
||||
|
||||
// Get extra fields
|
||||
foreach($_POST as $key => $value)
|
||||
{
|
||||
if (preg_match("/^options_/",$key))
|
||||
{
|
||||
$object->array_options[$key]=GETPOST($key);
|
||||
}
|
||||
}
|
||||
// Fill array 'array_options' with data from add form
|
||||
$ret = $extrafields->setOptionalsFromPost($extralabels,$object);
|
||||
|
||||
$result = $object->update($_POST["contactid"], $user);
|
||||
|
||||
@ -283,8 +274,6 @@ if (empty($reshook))
|
||||
* View
|
||||
*/
|
||||
|
||||
// fetch optionals attributes and labels
|
||||
$extralabels=$extrafields->fetch_name_optionals_label('contact');
|
||||
|
||||
$help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
|
||||
llxHeader('',$langs->trans("ContactsAddresses"),$help_url);
|
||||
@ -518,22 +507,7 @@ else
|
||||
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
|
||||
if (empty($reshook) && ! empty($extrafields->attribute_label))
|
||||
{
|
||||
foreach($extrafields->attribute_label as $key=>$label)
|
||||
{
|
||||
$value=(isset($_POST["options_".$key])?$_POST["options_".$key]:(isset($object->array_options["options_".$key])?$object->array_options["options_".$key]:''));
|
||||
if ($extrafields->attribute_type[$key] == 'separate')
|
||||
{
|
||||
print $extrafields->showSeparator($key);
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<tr><td';
|
||||
if (! empty($extrafields->attribute_required[$key])) print ' class="fieldrequired"';
|
||||
print '>'.$label.'</td><td colspan="3">';
|
||||
print $extrafields->showInputField($key,$value);
|
||||
print '</td></tr>'."\n";
|
||||
}
|
||||
}
|
||||
print $object->showOptionals($extrafields,'edit');
|
||||
}
|
||||
|
||||
print "</table><br>";
|
||||
@ -740,22 +714,7 @@ else
|
||||
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
|
||||
if (empty($reshook) && ! empty($extrafields->attribute_label))
|
||||
{
|
||||
foreach($extrafields->attribute_label as $key=>$label)
|
||||
{
|
||||
$value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$object->array_options["options_".$key]);
|
||||
if ($extrafields->attribute_type[$key] == 'separate')
|
||||
{
|
||||
print $extrafields->showSeparator($key);
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<tr><td';
|
||||
if (! empty($extrafields->attribute_required[$key])) print ' class="fieldrequired"';
|
||||
print '>'.$label.'</td><td colspan="3">';
|
||||
print $extrafields->showInputField($key,$value);
|
||||
print "</td></tr>\n";
|
||||
}
|
||||
}
|
||||
print $object->showOptionals($extrafields,'edit');
|
||||
}
|
||||
|
||||
$object->load_ref_elements();
|
||||
@ -959,20 +918,7 @@ else
|
||||
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
|
||||
if (empty($reshook) && ! empty($extrafields->attribute_label))
|
||||
{
|
||||
foreach($extrafields->attribute_label as $key=>$label)
|
||||
{
|
||||
$value=(isset($_POST["options_".$key])?$_POST["options_".$key]:(isset($object->array_options['options_'.$key])?$object->array_options['options_'.$key]:''));
|
||||
if ($extrafields->attribute_type[$key] == 'separate')
|
||||
{
|
||||
print $extrafields->showSeparator($key);
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<tr><td>'.$label.'</td><td colspan="3">';
|
||||
print $extrafields->showOutputField($key,$value);
|
||||
print "</td></tr>\n";
|
||||
}
|
||||
}
|
||||
print $object->showOptionals($extrafields);
|
||||
}
|
||||
|
||||
$object->load_ref_elements();
|
||||
|
||||
@ -2189,6 +2189,76 @@ abstract class CommonObject
|
||||
}
|
||||
else return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to show lines of extrafields with output datas
|
||||
*
|
||||
* @param object $extrafields extrafield Object
|
||||
* @param string $mode Show output (view) or input (edit) for extrafield
|
||||
*
|
||||
* return string
|
||||
*/
|
||||
function showOptionals($extrafields,$mode='view')
|
||||
{
|
||||
global $_POST;
|
||||
|
||||
$out = '';
|
||||
|
||||
if(count($extrafields->attribute_label) > 0)
|
||||
{
|
||||
$out .= "\n";
|
||||
$out .= '<!-- showOptionalsInput --> ';
|
||||
$out .= "\n";
|
||||
|
||||
$e = 0;
|
||||
foreach($extrafields->attribute_label as $key=>$label)
|
||||
{
|
||||
$colspan='3';
|
||||
$value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$this->array_options["options_".$key]);
|
||||
if ($extrafields->attribute_type[$key] == 'separate')
|
||||
{
|
||||
$out .= $extrafields->showSeparator($key);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( !empty($conf->global->MAIN_EXTRAFIELDS_USE_TWO_COLUMS) && ($e % 2) == 0)
|
||||
{
|
||||
$out .= '<tr>';
|
||||
$colspan='0';
|
||||
}
|
||||
else
|
||||
{
|
||||
$out .= '<tr>';
|
||||
}
|
||||
// Convert date into timestamp format
|
||||
if (in_array($extrafields->attribute_type[$key],array('date','datetime')))
|
||||
{
|
||||
$value = isset($_POST["options_".$key])?dol_mktime($_POST["options_".$key."hour"], $_POST["options_".$key."min"], 0, $_POST["options_".$key."month"], $_POST["options_".$key."day"], $_POST["options_".$key."year"]):$this->array_options['options_'.$key];
|
||||
}
|
||||
$out .= '<td>'.$label.'</td>';
|
||||
$out .='<td colspan="'.$colspan.'">';
|
||||
|
||||
switch($mode) {
|
||||
case "view":
|
||||
$out .= $extrafields->showOutputField($key,$value);
|
||||
break;
|
||||
case "edit":
|
||||
$out .= $extrafields->showInputField($key,$value);
|
||||
break;
|
||||
}
|
||||
|
||||
$out .= '</td>'."\n";
|
||||
|
||||
if (! empty($conf->global->MAIN_EXTRAFIELDS_USE_TWO_COLUMS) && (($e % 2) == 1)) $out .= '</tr>';
|
||||
else $out .= '</tr>';
|
||||
$e++;
|
||||
}
|
||||
}
|
||||
$out .= "\n";
|
||||
$out .= '<!-- /showOptionalsInput --> ';
|
||||
}
|
||||
return $out;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@ -624,7 +624,7 @@ class ExtraFields
|
||||
$formstat = new Form($db);
|
||||
|
||||
$showtime = in_array($type,array('datetime')) ? 1 : 0;
|
||||
$out = $formstat->select_date($value, 'options_'.$key, $showtime, $showtime, $required, '', 1, 1, 0, 0, 1);
|
||||
$out = $formstat->select_date($value, 'options_'.$key, $showtime, $showtime, $required, '', 1, 1, 1, 0, 1);
|
||||
//$out='<input type="text" name="options_'.$key.'" size="'.$showsize.'" maxlength="'.$newsize.'" value="'.$value.'"'.($moreparam?$moreparam:'').'>';
|
||||
}
|
||||
elseif (in_array($type,array('int','double')))
|
||||
|
||||
@ -56,6 +56,9 @@ if (! empty($user->societe_id)) $socid=$user->societe_id;
|
||||
$object = new Product($db);
|
||||
$extrafields = new ExtraFields($db);
|
||||
|
||||
// fetch optionals attributes and labels
|
||||
$extralabels=$extrafields->fetch_name_optionals_label('product');
|
||||
|
||||
if ($id > 0 || ! empty($ref))
|
||||
{
|
||||
$object = new Product($db);
|
||||
@ -212,14 +215,8 @@ if (empty($reshook))
|
||||
}
|
||||
}
|
||||
|
||||
// Get extra fields
|
||||
foreach($_POST as $key => $value)
|
||||
{
|
||||
if (preg_match("/^options_/",$key))
|
||||
{
|
||||
$object->array_options[$key]=$_POST[$key];
|
||||
}
|
||||
}
|
||||
// Fill array 'array_options' with data from add form
|
||||
$ret = $extrafields->setOptionalsFromPost($extralabels,$object);
|
||||
|
||||
$id = $object->create($user);
|
||||
|
||||
@ -272,14 +269,8 @@ if (empty($reshook))
|
||||
$object->finished = GETPOST('finished');
|
||||
$object->hidden = GETPOST('hidden')=='yes'?1:0;
|
||||
|
||||
// Get extra fields
|
||||
foreach($_POST as $key => $value)
|
||||
{
|
||||
if (preg_match("/^options_/",$key))
|
||||
{
|
||||
$object->array_options[$key]=$_POST[$key];
|
||||
}
|
||||
}
|
||||
// Fill array 'array_options' with data from add form
|
||||
$ret = $extrafields->setOptionalsFromPost($extralabels,$object);
|
||||
|
||||
if ($object->check())
|
||||
{
|
||||
@ -632,9 +623,6 @@ if (GETPOST("cancel") == $langs->trans("Cancel"))
|
||||
* View
|
||||
*/
|
||||
|
||||
// fetch optionals attributes and labels
|
||||
$extralabels=$extrafields->fetch_name_optionals_label('product');
|
||||
|
||||
$helpurl='';
|
||||
if (GETPOST("type") == '0') $helpurl='EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos';
|
||||
if (GETPOST("type") == '1') $helpurl='EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios';
|
||||
@ -791,16 +779,8 @@ else
|
||||
$parameters=array('colspan' => ' colspan="2"');
|
||||
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
|
||||
if (empty($reshook) && ! empty($extrafields->attribute_label))
|
||||
{
|
||||
foreach($extrafields->attribute_label as $key=>$label)
|
||||
{
|
||||
$value=(GETPOST('options_'.$key)?GETPOST('options_'.$key):$object->array_options["options_".$key]);
|
||||
print '<tr><td';
|
||||
if (! empty($extrafields->attribute_required[$key])) print ' class="fieldrequired"';
|
||||
print '>'.$label.'</td><td colspan="3">';
|
||||
print $extrafields->showInputField($key,$value);
|
||||
print '</td></tr>'."\n";
|
||||
}
|
||||
{
|
||||
print $object->showOptionals($extrafields,'edit');
|
||||
}
|
||||
|
||||
// Note (private, no output on invoices, propales...)
|
||||
@ -999,15 +979,7 @@ else
|
||||
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
|
||||
if (empty($reshook) && ! empty($extrafields->attribute_label))
|
||||
{
|
||||
foreach($extrafields->attribute_label as $key=>$label)
|
||||
{
|
||||
$value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$object->array_options["options_".$key]);
|
||||
print '<tr><td';
|
||||
if (! empty($extrafields->attribute_required[$key])) print ' class="fieldrequired"';
|
||||
print '>'.$label.'</td><td colspan="3">';
|
||||
print $extrafields->showInputField($key,$value);
|
||||
print '</td></tr>'."\n";
|
||||
}
|
||||
print $object->showOptionals($extrafields,'edit');
|
||||
}
|
||||
|
||||
// Note
|
||||
@ -1230,14 +1202,8 @@ else
|
||||
$parameters=array('colspan' => ' colspan="'.(2+(($showphoto||$showbarcode)?1:0)).'"');
|
||||
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
|
||||
if (empty($reshook) && ! empty($extrafields->attribute_label))
|
||||
{
|
||||
foreach($extrafields->attribute_label as $key=>$label)
|
||||
{
|
||||
$value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$object->array_options["options_".$key]);
|
||||
print '<tr><td>'.$label.'</td><td colspan="3">';
|
||||
print $extrafields->showOutputField($key,$value);
|
||||
print '</td></tr>'."\n";
|
||||
}
|
||||
{
|
||||
print $object->showOptionals($extrafields);
|
||||
}
|
||||
|
||||
// Note
|
||||
|
||||
@ -974,40 +974,7 @@ else
|
||||
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
|
||||
if (empty($reshook) && ! empty($extrafields->attribute_label))
|
||||
{
|
||||
$e=0;
|
||||
foreach($extrafields->attribute_label as $key=>$label)
|
||||
{
|
||||
$colspan='3';
|
||||
$value=(isset($_POST["options_".$key])?$_POST["options_".$key]:(isset($object->array_options["options_".$key])?$object->array_options["options_".$key]:''));
|
||||
if ($extrafields->attribute_type[$key] == 'separate')
|
||||
{
|
||||
print $extrafields->showSeparator($key);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (($e % 2) == 0)
|
||||
{
|
||||
print '<tr>';
|
||||
$colspan='0';
|
||||
}
|
||||
print '<td';
|
||||
if (! empty($extrafields->attribute_required[$key])) print ' class="fieldrequired"';
|
||||
print '>'.$label.'</td>';
|
||||
print '<td colspan="'.$colspan.'">';
|
||||
|
||||
// Convert date into timestamp format
|
||||
if (in_array($extrafields->attribute_type[$key],array('date','datetime')))
|
||||
{
|
||||
$value = dol_mktime($_POST["options_".$key."hour"], $_POST["options_".$key."min"], 0, $_POST["options_".$key."month"], $_POST["options_".$key."day"], $_POST["options_".$key."year"]);
|
||||
}
|
||||
|
||||
print $extrafields->showInputField($key,$value);
|
||||
print '</td>';
|
||||
|
||||
if (($e % 2) == 1) print '</tr>'."\n";
|
||||
$e++;
|
||||
}
|
||||
}
|
||||
print $object->showOptionals($extrafields,'edit');
|
||||
}
|
||||
|
||||
// Ajout du logo
|
||||
@ -1416,37 +1383,7 @@ else
|
||||
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
|
||||
if (empty($reshook) && ! empty($extrafields->attribute_label))
|
||||
{
|
||||
$old_pos=0;
|
||||
$e=0;
|
||||
foreach($extrafields->attribute_label as $key=>$label)
|
||||
{
|
||||
$colspan = '3';
|
||||
$value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$object->array_options["options_".$key]);
|
||||
if ($extrafields->attribute_type[$key] == 'separate')
|
||||
{
|
||||
print $extrafields->showSeparator($key);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (($e % 2) == 0)
|
||||
{
|
||||
print '<tr>'."\n";
|
||||
$colspan = '0';
|
||||
}
|
||||
print '<td';
|
||||
if (! empty($extrafields->attribute_required[$key])) print ' class="fieldrequired"';
|
||||
print '>'.$label.'</td>'."\n";
|
||||
print '<td colspan="'.$colspan.'">';
|
||||
print $extrafields->showInputField($key,$value);
|
||||
print "</td>"."\n";
|
||||
|
||||
if (($e % 2) == 1 )
|
||||
{
|
||||
print "</tr>\n";
|
||||
}
|
||||
$e++;
|
||||
}
|
||||
}
|
||||
print $object->showOptionals($extrafields,'edit');
|
||||
}
|
||||
// Logo
|
||||
print '<tr>';
|
||||
@ -1761,31 +1698,7 @@ else
|
||||
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
|
||||
if (empty($reshook) && ! empty($extrafields->attribute_label))
|
||||
{
|
||||
$e=0;
|
||||
foreach($extrafields->attribute_label as $key=>$label)
|
||||
{
|
||||
$colspan='3';
|
||||
$value=(isset($_POST["options_".$key])?$_POST["options_".$key]:(isset($object->array_options['options_'.$key])?$object->array_options['options_'.$key]:''));
|
||||
if ($extrafields->attribute_type[$key] == 'separate')
|
||||
{
|
||||
print $extrafields->showSeparator($key);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (($e % 2) == 0)
|
||||
{
|
||||
print '<tr>';
|
||||
$colspan='0';
|
||||
}
|
||||
print '<td>'.$label.'</td>';
|
||||
print '<td colspan="'.$colspan.'">';
|
||||
print $extrafields->showOutputField($key,$value);
|
||||
print "</td>";
|
||||
|
||||
if (($e % 2) == 1) print '</tr>';
|
||||
$e++;
|
||||
}
|
||||
}
|
||||
print $object->showOptionals($extrafields);
|
||||
}
|
||||
|
||||
// Ban
|
||||
|
||||
@ -187,14 +187,8 @@ if ($action == 'add' && $canadduser)
|
||||
$object->note = GETPOST("note");
|
||||
$object->ldap_sid = GETPOST("ldap_sid");
|
||||
|
||||
// Get extra fields
|
||||
foreach($_POST as $key => $value)
|
||||
{
|
||||
if (preg_match("/^options_/",$key))
|
||||
{
|
||||
$object->array_options[$key]=GETPOST($key);
|
||||
}
|
||||
}
|
||||
// Fill array 'array_options' with data from add form
|
||||
$ret = $extrafields->setOptionalsFromPost($extralabels,$object);
|
||||
|
||||
// If multicompany is off, admin users must all be on entity 0.
|
||||
if (! empty($conf->multicompany->enabled))
|
||||
@ -329,14 +323,8 @@ if ($action == 'update' && ! $_POST["cancel"])
|
||||
$object->openid = GETPOST("openid");
|
||||
$object->fk_user = GETPOST("fk_user")>0?GETPOST("fk_user"):0;
|
||||
|
||||
// Get extra fields
|
||||
foreach($_POST as $key => $value)
|
||||
{
|
||||
if (preg_match("/^options_/",$key))
|
||||
{
|
||||
$object->array_options[$key]=GETPOST($key);
|
||||
}
|
||||
}
|
||||
// Fill array 'array_options' with data from add form
|
||||
$ret = $extrafields->setOptionalsFromPost($extralabels,$object);
|
||||
|
||||
if (! empty($conf->multicompany->enabled))
|
||||
{
|
||||
@ -927,15 +915,7 @@ if (($action == 'create') || ($action == 'adduserldap'))
|
||||
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
|
||||
if (empty($reshook) && ! empty($extrafields->attribute_label))
|
||||
{
|
||||
foreach($extrafields->attribute_label as $key=>$label)
|
||||
{
|
||||
$value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$object->array_options["options_".$key]);
|
||||
print '<tr><td';
|
||||
if (! empty($extrafields->attribute_required[$key])) print ' class="fieldrequired"';
|
||||
print '>'.$label.'</td><td colspan="3">';
|
||||
print $extrafields->showInputField($key,$value);
|
||||
print '</td></tr>'."\n";
|
||||
}
|
||||
print $object->showOptionals($extrafields,'edit');
|
||||
}
|
||||
|
||||
print "</table>\n";
|
||||
@ -1304,15 +1284,7 @@ else
|
||||
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
|
||||
if (empty($reshook) && ! empty($extrafields->attribute_label))
|
||||
{
|
||||
foreach($extrafields->attribute_label as $key=>$label)
|
||||
{
|
||||
$value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$object->array_options["options_".$key]);
|
||||
print '<tr><td';
|
||||
if (! empty($extrafields->attribute_required[$key])) print ' class="fieldrequired"';
|
||||
print '>'.$label.'</td><td colspan="3">';
|
||||
print $extrafields->showOutputField($key,$value);
|
||||
print '</td></tr>'."\n";
|
||||
}
|
||||
print $object->showOptionals($extrafields);
|
||||
}
|
||||
|
||||
print "</table>\n";
|
||||
@ -1921,15 +1893,7 @@ else
|
||||
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
|
||||
if (empty($reshook) && ! empty($extrafields->attribute_label))
|
||||
{
|
||||
foreach($extrafields->attribute_label as $key=>$label)
|
||||
{
|
||||
$value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$object->array_options["options_".$key]);
|
||||
print '<tr><td';
|
||||
if (! empty($extrafields->attribute_required[$key])) print ' class="fieldrequired"';
|
||||
print '>'.$label.'</td><td colspan="3">';
|
||||
print $extrafields->showInputField($key,$value);
|
||||
print '</td></tr>'."\n";
|
||||
}
|
||||
print $object->showOptionals($extrafields,'edit');
|
||||
}
|
||||
|
||||
print '</table>';
|
||||
|
||||
Loading…
Reference in New Issue
Block a user