Edit extrafields on customer invoice
This commit is contained in:
parent
7260e139df
commit
3ccb0fb92c
@ -1733,6 +1733,36 @@ if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->facture-
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($action == 'update_extras')
|
||||||
|
{
|
||||||
|
// Get extra fields
|
||||||
|
foreach($_POST as $key => $value)
|
||||||
|
{
|
||||||
|
if (preg_match("/^options_/",$key))
|
||||||
|
{
|
||||||
|
$object->array_options[$key]=$_POST[$key];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Actions on extra fields (by external module or standard code)
|
||||||
|
// FIXME le hook fait double emploi avec le trigger !!
|
||||||
|
$hookmanager->initHooks(array('invoicedao'));
|
||||||
|
$parameters=array('id'=>$object->id);
|
||||||
|
$reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
|
||||||
|
if (empty($reshook))
|
||||||
|
{
|
||||||
|
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
|
||||||
|
{
|
||||||
|
$result=$object->insertExtraFields();
|
||||||
|
if ($result < 0)
|
||||||
|
{
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if ($reshook < 0) $error++;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* View
|
* View
|
||||||
@ -2233,6 +2263,10 @@ else if ($id > 0 || ! empty($ref))
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
$result=$object->fetch($id,$ref);
|
$result=$object->fetch($id,$ref);
|
||||||
|
|
||||||
|
// fetch optionals attributes and labels
|
||||||
|
$extralabels=$extrafields->fetch_name_optionals_label('facture');
|
||||||
|
|
||||||
if ($result > 0)
|
if ($result > 0)
|
||||||
{
|
{
|
||||||
if ($user->societe_id>0 && $user->societe_id!=$object->socid) accessforbidden('',0);
|
if ($user->societe_id>0 && $user->societe_id!=$object->socid) accessforbidden('',0);
|
||||||
@ -3041,21 +3075,58 @@ else if ($id > 0 || ! empty($ref))
|
|||||||
print '</td>';
|
print '</td>';
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Other attributes
|
// Other attributes
|
||||||
$parameters=array('colspan' => ' colspan="3"');
|
$res=$object->fetch_optionals($object->id,$extralabels);
|
||||||
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
|
$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))
|
if (empty($reshook) && ! empty($extrafields->attribute_label))
|
||||||
{
|
{
|
||||||
foreach($extrafields->attribute_label as $key=>$label)
|
|
||||||
{
|
if ($action == 'edit_extras')
|
||||||
$value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$object->array_options["options_".$key]);
|
{
|
||||||
print '<tr><td';
|
print '<form enctype="multipart/form-data" action="'.$_SERVER["PHP_SELF"].'" method="post" name="formsoc">';
|
||||||
if (! empty($extrafields->attribute_required[$key])) print ' class="fieldrequired"';
|
print '<input type="hidden" name="action" value="update_extras">';
|
||||||
print '>'.$label.'</td><td colspan="3">';
|
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||||
print $extrafields->showInputField($key,$value);
|
print '<input type="hidden" name="id" value="'.$object->id.'">';
|
||||||
print '</td></tr>'."\n";
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
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="5">';
|
||||||
|
if ($action == 'edit_extras' && $user->rights->propal->creer)
|
||||||
|
{
|
||||||
|
print $extrafields->showInputField($key,$value);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print $extrafields->showOutputField($key,$value);
|
||||||
|
}
|
||||||
|
|
||||||
|
print '</td></tr>'."\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
if(count($extrafields->attribute_label) > 0) {
|
||||||
|
|
||||||
|
if ($action == 'edit_extras' && $user->rights->propal->creer)
|
||||||
|
{
|
||||||
|
print '<tr><td></td><td colspan="5">';
|
||||||
|
print '<input type="submit" class="button" value="'.$langs->trans('Modify').'">';
|
||||||
|
print '</form>';
|
||||||
|
print '</td></tr>';
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if ($object->statut == 0 && $user->rights->propal->creer)
|
||||||
|
{
|
||||||
|
print '<tr><td></td><td><a href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=edit_extras">'.img_picto('','edit').' '.$langs->trans('Modify').'</a></td></tr>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
print '</table><br>';
|
print '</table><br>';
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user