Qual : refactoring extrafields display on objects into a single tpl file
This commit is contained in:
parent
68179c8794
commit
ee4b807a5d
@ -2008,67 +2008,9 @@ if ($action == 'create')
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
// Other attributes (TODO Move this into an include)
|
||||
$res = $object->fetch_optionals($object->id, $extralabels);
|
||||
$parameters = array('colspan' => ' colspan="3"');
|
||||
$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)
|
||||
{
|
||||
if ($action == 'edit_extras')
|
||||
{
|
||||
$value = (isset($_POST ["options_" . $key]) ? $_POST ["options_" . $key] : $object->array_options ["options_" . $key]);
|
||||
}
|
||||
else
|
||||
{
|
||||
$value = $object->array_options ["options_" . $key];
|
||||
}
|
||||
if ($extrafields->attribute_type [$key] == 'separate')
|
||||
{
|
||||
print $extrafields->showSeparator($key);
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<tr><td>';
|
||||
print '<table width="100%" class="nobordernopadding"><tr><td';
|
||||
if (! empty($extrafields->attribute_required [$key])) print ' class="fieldrequired"';
|
||||
print '>' . $label . '</td>';
|
||||
if (($object->statut == 0 || $extrafields->attribute_alwayseditable[$key]) && $user->rights->propal->creer && ($action != 'edit_extras' || GETPOST('attribute') != $key))
|
||||
print '<td align="right"><a href="' . $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&action=edit_extras&attribute=' . $key . '">' . img_edit().'</a></td>';
|
||||
|
||||
print '</tr></table>';
|
||||
print '<td colspan="5">';
|
||||
|
||||
// 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"]) : $db->jdate($object->array_options ['options_' . $key]);
|
||||
}
|
||||
|
||||
if ($action == 'edit_extras' && $user->rights->propal->creer && GETPOST('attribute') == $key)
|
||||
{
|
||||
print '<form enctype="multipart/form-data" action="' . $_SERVER["PHP_SELF"] . '" method="post" name="formsoc">';
|
||||
print '<input type="hidden" name="action" value="update_extras">';
|
||||
print '<input type="hidden" name="attribute" value="' . $key . '">';
|
||||
print '<input type="hidden" name="token" value="' . $_SESSION ['newtoken'] . '">';
|
||||
print '<input type="hidden" name="id" value="' . $object->id . '">';
|
||||
|
||||
print $extrafields->showInputField($key, $value);
|
||||
|
||||
print '<input type="submit" class="button" value="' . $langs->trans('Modify') . '">';
|
||||
|
||||
print '</form>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print $extrafields->showOutputField($key, $value);
|
||||
}
|
||||
print '</td></tr>' . "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
// Other attributes
|
||||
$cols = 3;
|
||||
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
|
||||
|
||||
// Amount HT
|
||||
print '<tr><td height="10" width="25%">' . $langs->trans('AmountHT') . '</td>';
|
||||
|
||||
@ -2130,67 +2130,9 @@ if ($action == 'create' && $user->rights->commande->creer) {
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
// Other attributes (TODO Move this into an include)
|
||||
$parameters = array('colspan' => ' colspan="3"');
|
||||
$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)
|
||||
{
|
||||
if ($action == 'edit_extras')
|
||||
{
|
||||
$value = (isset($_POST["options_".$key])?$_POST["options_".$key]:$object->array_options["options_".$key]);
|
||||
}
|
||||
else
|
||||
{
|
||||
$value = $object->array_options["options_" . $key];
|
||||
}
|
||||
|
||||
if ($extrafields->attribute_type[$key] == 'separate')
|
||||
{
|
||||
print $extrafields->showSeparator($key);
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<tr><td>';
|
||||
print '<table width="100%" class="nobordernopadding"><tr><td';
|
||||
if (! empty($extrafields->attribute_required [$key])) print ' class="fieldrequired"';
|
||||
print '>' . $label . '</td>';
|
||||
if (($object->statut == 0 || $extrafields->attribute_alwayseditable[$key]) && $user->rights->propal->creer && ($action != 'edit_extras' || GETPOST('attribute') != $key))
|
||||
print '<td align="right"><a href="' . $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&action=edit_extras&attribute=' . $key . '">' . img_edit().'</a></td>';
|
||||
|
||||
print '</tr></table>';
|
||||
print '<td colspan="5">';
|
||||
|
||||
// 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"]) : $db->jdate($object->array_options ['options_' . $key]);
|
||||
}
|
||||
|
||||
if ($action == 'edit_extras' && $user->rights->commande->creer && GETPOST('attribute') == $key)
|
||||
{
|
||||
print '<form enctype="multipart/form-data" action="' . $_SERVER["PHP_SELF"] . '" method="post" name="formsoc">';
|
||||
print '<input type="hidden" name="action" value="update_extras">';
|
||||
print '<input type="hidden" name="attribute" value="' . $key . '">';
|
||||
print '<input type="hidden" name="token" value="' . $_SESSION ['newtoken'] . '">';
|
||||
print '<input type="hidden" name="id" value="' . $object->id . '">';
|
||||
|
||||
print $extrafields->showInputField($key, $value);
|
||||
|
||||
print '<input type="submit" class="button" value="' . $langs->trans('Modify') . '">';
|
||||
print '</form>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print $extrafields->showOutputField($key, $value);
|
||||
if ($object->statut == 0 && $user->rights->commande->creer)
|
||||
print '<a href="' . $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&action=edit_extras&attribute=' . $key . '">' . img_picto('', 'edit') . ' ' . $langs->trans('Modify') . '</a>';
|
||||
}
|
||||
print '</td></tr>' . "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
// Other attributes
|
||||
$cols = 3;
|
||||
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
|
||||
|
||||
$rowspan = 4;
|
||||
if ($mysoc->localtax1_assuj == "1" || $object->total_localtax1 != 0)
|
||||
|
||||
@ -3324,58 +3324,9 @@ if ($action == 'create')
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
// Other attributes (TODO Move this into an include)
|
||||
$res = $object->fetch_optionals($object->id, $extralabels);
|
||||
$parameters = array('colspan' => ' colspan="5"', "cols" => 5);
|
||||
$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)
|
||||
{
|
||||
if ($action == 'edit_extras') {
|
||||
$value = (isset($_POST["options_" . $key]) ? $_POST["options_" . $key] : $object->array_options ["options_" . $key]);
|
||||
} else {
|
||||
$value = $object->array_options ["options_" . $key];
|
||||
}
|
||||
if ($extrafields->attribute_type [$key] == 'separate') {
|
||||
print $extrafields->showSeparator($key);
|
||||
} else {
|
||||
print '<tr><td>';
|
||||
print '<table width="100%" class="nobordernopadding"><tr><td';
|
||||
if (! empty($extrafields->attribute_required [$key])) print ' class="fieldrequired"';
|
||||
print '>' . $label . '</td>';
|
||||
if (($object->statut == 0 || $extrafields->attribute_alwayseditable[$key]) && $user->rights->propal->creer && ($action != 'edit_extras' || GETPOST('attribute') != $key))
|
||||
print '<td align="right"><a href="' . $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&action=edit_extras&attribute=' . $key . '">' . img_edit().'</a></td>';
|
||||
|
||||
print '</tr></table>';
|
||||
print '<td colspan="5">';
|
||||
|
||||
// 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"]) : $db->jdate($object->array_options ['options_' . $key]);
|
||||
}
|
||||
|
||||
if ($action == 'edit_extras' && $user->rights->facture->creer && GETPOST('attribute') == $key) {
|
||||
print '<form enctype="multipart/form-data" action="' . $_SERVER["PHP_SELF"] . '" method="post" name="formsoc">';
|
||||
print '<input type="hidden" name="action" value="update_extras">';
|
||||
print '<input type="hidden" name="attribute" value="' . $key . '">';
|
||||
print '<input type="hidden" name="token" value="' . $_SESSION ['newtoken'] . '">';
|
||||
print '<input type="hidden" name="id" value="' . $object->id . '">';
|
||||
|
||||
print $extrafields->showInputField($key, $value);
|
||||
|
||||
print '<input type="submit" class="button" value="' . $langs->trans('Modify') . '">';
|
||||
print '</form>';
|
||||
} else {
|
||||
print $extrafields->showOutputField($key, $value);
|
||||
if ($object->statut == 0 && $user->rights->facture->creer)
|
||||
print '<a href="' . $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&action=edit_extras&attribute=' . $key . '">' . img_picto('', 'edit') . ' ' . $langs->trans('Modify') . '</a>';
|
||||
}
|
||||
print '</td></tr>' . "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
// Other attributes
|
||||
$cols = 5;
|
||||
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
|
||||
|
||||
print '</table><br>';
|
||||
|
||||
|
||||
@ -1189,52 +1189,8 @@ else
|
||||
}
|
||||
|
||||
// Other attributes
|
||||
$parameters=array('colspan' => ' colspan="3"');
|
||||
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
|
||||
|
||||
$res = $object->fetch_optionals($object->id, $extralabels);
|
||||
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]);
|
||||
} else {
|
||||
$value = $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="5">';
|
||||
// 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"]) : $db->jdate($object->array_options ['options_' . $key]);
|
||||
}
|
||||
|
||||
if ($action == 'edit_extras' && $user->rights->commande->creer && GETPOST('attribute') == $key) {
|
||||
print '<form enctype="multipart/form-data" action="' . $_SERVER["PHP_SELF"] . '" method="post" name="formcontract">';
|
||||
print '<input type="hidden" name="action" value="update_extras">';
|
||||
print '<input type="hidden" name="attribute" value="' . $key . '">';
|
||||
print '<input type="hidden" name="token" value="' . $_SESSION ['newtoken'] . '">';
|
||||
print '<input type="hidden" name="id" value="' . $object->id . '">';
|
||||
|
||||
print $extrafields->showInputField($key, $value);
|
||||
|
||||
print '<input type="submit" class="button" value="' . $langs->trans('Modify') . '">';
|
||||
print '</form>';
|
||||
} else {
|
||||
print $extrafields->showOutputField($key, $value);
|
||||
if ($object->statut == 0 && $user->rights->commande->creer)
|
||||
print '<a href="' . $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&action=edit_extras&attribute=' . $key . '">' . img_picto('', 'edit') . ' ' . $langs->trans('Modify') . '</a>';
|
||||
}
|
||||
print '</td></tr>' . "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
$cols = 3;
|
||||
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
|
||||
|
||||
print "</table>";
|
||||
|
||||
|
||||
83
htdocs/core/tpl/extrafields_view.tpl.php
Normal file
83
htdocs/core/tpl/extrafields_view.tpl.php
Normal file
@ -0,0 +1,83 @@
|
||||
<?php
|
||||
/* Copyright (C) 2014 Maxime Kohlhaas <support@atm-consulting.fr>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Need to have following variables defined:
|
||||
* $object (invoice, order, ...)
|
||||
* $conf
|
||||
* $langs
|
||||
*
|
||||
* $cols
|
||||
*/
|
||||
|
||||
//$res = $object->fetch_optionals($object->id, $extralabels);
|
||||
$parameters = array('colspan' => ' colspan="'.$cols.'"', 'cols' => $cols, 'socid' => $object->fk_soc);
|
||||
$reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action);
|
||||
|
||||
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]);
|
||||
}
|
||||
else
|
||||
{
|
||||
$value = $object->array_options ["options_" . $key];
|
||||
}
|
||||
if ($extrafields->attribute_type [$key] == 'separate')
|
||||
{
|
||||
print $extrafields->showSeparator($key);
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<tr><td>';
|
||||
print '<table width="100%" class="nobordernopadding"><tr><td';
|
||||
if (! empty($extrafields->attribute_required [$key])) print ' class="fieldrequired"';
|
||||
print '>' . $label . '</td>';
|
||||
if (($object->statut == 0 || $extrafields->attribute_alwayseditable[$key]) && $user->rights->propal->creer && ($action != 'edit_extras' || GETPOST('attribute') != $key))
|
||||
print '<td align="right"><a href="' . $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&action=edit_extras&attribute=' . $key . '">' . img_edit().'</a></td>';
|
||||
|
||||
print '</tr></table>';
|
||||
print '<td colspan="5">';
|
||||
|
||||
// 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"]) : $db->jdate($object->array_options ['options_' . $key]);
|
||||
}
|
||||
|
||||
if ($action == 'edit_extras' && $user->rights->propal->creer && GETPOST('attribute') == $key)
|
||||
{
|
||||
print '<form enctype="multipart/form-data" action="' . $_SERVER["PHP_SELF"] . '" method="post" name="formsoc">';
|
||||
print '<input type="hidden" name="action" value="update_extras">';
|
||||
print '<input type="hidden" name="attribute" value="' . $key . '">';
|
||||
print '<input type="hidden" name="token" value="' . $_SESSION ['newtoken'] . '">';
|
||||
print '<input type="hidden" name="id" value="' . $object->id . '">';
|
||||
|
||||
print $extrafields->showInputField($key, $value);
|
||||
|
||||
print '<input type="submit" class="button" value="' . $langs->trans('Modify') . '">';
|
||||
|
||||
print '</form>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print $extrafields->showOutputField($key, $value);
|
||||
}
|
||||
print '</td></tr>' . "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1330,49 +1330,9 @@ else if ($id > 0 || ! empty($ref))
|
||||
// Statut
|
||||
print '<tr><td>'.$langs->trans("Status").'</td><td colspan="3">'.$object->getLibStatut(4).'</td></tr>';
|
||||
|
||||
// Other attributes (TODO Move this into an include)
|
||||
$parameters=array('colspan' => ' colspan="3"');
|
||||
$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)
|
||||
{
|
||||
if ($action == 'edit_extras') {
|
||||
$value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$object->array_options["options_".$key]);
|
||||
} else {
|
||||
$value=$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">';
|
||||
// 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"]):$db->jdate($object->array_options['options_'.$key]);
|
||||
}
|
||||
if ($action == 'edit_extras' && $user->rights->ficheinter->creer && GETPOST('attribute') == $key)
|
||||
{
|
||||
print '<input type="hidden" name="attribute" value="'.$key.'">';
|
||||
|
||||
print $extrafields->showInputField($key,$value);
|
||||
|
||||
print ' <input type="submit" class="button" value="'.$langs->trans('Modify').'">';
|
||||
}
|
||||
else
|
||||
{
|
||||
print $extrafields->showOutputField($key,$value);
|
||||
if (($object->statut == 0 || $object->statut == 1) && $user->rights->ficheinter->creer) print ' <a href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=edit_extras&attribute='.$key.'">'.img_picto('','edit').' '.$langs->trans('Modify').'</a>';
|
||||
}
|
||||
print '</td></tr>'."\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
// Other attributes
|
||||
$cols = 3;
|
||||
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
|
||||
|
||||
print "</table>";
|
||||
|
||||
|
||||
@ -413,6 +413,15 @@ class FactureFournisseur extends CommonInvoice
|
||||
|
||||
$this->socid = $obj->socid;
|
||||
$this->socnom = $obj->socnom;
|
||||
|
||||
// Retreive all extrafield
|
||||
// fetch optionals attributes and labels
|
||||
require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php');
|
||||
$extrafields=new ExtraFields($this->db);
|
||||
$extralabels=$extrafields->fetch_name_optionals_label($this->table_element,true);
|
||||
$this->fetch_optionals($this->id,$extralabels);
|
||||
|
||||
if ($this->statut == 0) $this->brouillon = 1;
|
||||
|
||||
$result=$this->fetch_lines();
|
||||
if ($result < 0)
|
||||
|
||||
@ -1484,78 +1484,9 @@ elseif (! empty($object->id))
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
// Other attributes (TODO Move this into an include)
|
||||
$parameters=array('socid'=>$socid, 'colspan' => ' colspan="3"');
|
||||
$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)
|
||||
{
|
||||
if ($action == 'edit_extras')
|
||||
{
|
||||
$value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$object->array_options["options_".$key]);
|
||||
}
|
||||
else
|
||||
{
|
||||
$value=$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="5">';
|
||||
// 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"]):$db->jdate($object->array_options['options_'.$key]);
|
||||
}
|
||||
|
||||
if ($action == 'edit_extras' && $user->rights->commande->creer && GETPOST('attribute') == $key)
|
||||
{
|
||||
print '<form enctype="multipart/form-data" action="' . $_SERVER["PHP_SELF"] . '" method="post" name="formsoc">';
|
||||
print '<input type="hidden" name="action" value="update_extras">';
|
||||
print '<input type="hidden" name="attribute" value="' . $key . '">';
|
||||
print '<input type="hidden" name="token" value="' . $_SESSION ['newtoken'] . '">';
|
||||
print '<input type="hidden" name="id" value="' . $object->id . '">';
|
||||
|
||||
print $extrafields->showInputField($key, $value);
|
||||
|
||||
print '<input type="submit" class="button" value="' . $langs->trans('Modify') . '">';
|
||||
print '</form>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print $extrafields->showOutputField($key, $value);
|
||||
if ($object->statut == 0 && $user->rights->commande->creer)
|
||||
print '<a href="' . $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&action=edit_extras&attribute=' . $key . '">' . img_picto('', 'edit') . ' ' . $langs->trans('Modify') . '</a>';
|
||||
}
|
||||
print '</td></tr>'."\n";
|
||||
}
|
||||
}
|
||||
|
||||
if(count($extrafields->attribute_label) > 0)
|
||||
{
|
||||
if ($action == 'edit_extras' && $user->rights->fournisseur->commande->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->fournisseur->commande->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>';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Other attributes
|
||||
$cols = 3;
|
||||
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
|
||||
|
||||
// Ligne de 3 colonnes
|
||||
print '<tr><td>'.$langs->trans("AmountHT").'</td>';
|
||||
|
||||
@ -72,6 +72,10 @@ $result = restrictedArea($user, 'fournisseur', $id, 'facture_fourn', 'facture');
|
||||
$hookmanager->initHooks(array('invoicesuppliercard','globalcard'));
|
||||
|
||||
$object=new FactureFournisseur($db);
|
||||
$extrafields = new ExtraFields($db);
|
||||
|
||||
// fetch optionals attributes and labels
|
||||
$extralabels=$extrafields->fetch_name_optionals_label($object->table_element);
|
||||
|
||||
// Load object
|
||||
if ($id > 0 || ! empty($ref))
|
||||
@ -1054,6 +1058,45 @@ elseif ($action == 'remove_file')
|
||||
}
|
||||
}
|
||||
|
||||
elseif ($action == 'update_extras')
|
||||
{
|
||||
// Fill array 'array_options' with data from add form
|
||||
$extralabels=$extrafields->fetch_name_optionals_label($object->table_element);
|
||||
$ret = $extrafields->setOptionalsFromPost($extralabels,$object);
|
||||
|
||||
if($ret < 0) $error++;
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
// Actions on extra fields (by external module or standard code)
|
||||
// FIXME le hook fait double emploi avec le trigger !!
|
||||
$hookmanager->initHooks(array('supplierorderdao'));
|
||||
$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++;
|
||||
}
|
||||
else
|
||||
{
|
||||
$action = 'edit_extras';
|
||||
}
|
||||
}
|
||||
|
||||
if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->fournisseur->facture->creer)
|
||||
{
|
||||
if ($action == 'addcontact')
|
||||
@ -1884,9 +1927,9 @@ else
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
// Other options
|
||||
$parameters=array('colspan' => ' colspan="4"');
|
||||
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
|
||||
// Other attributes
|
||||
$cols = 4;
|
||||
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
|
||||
|
||||
print '</table>';
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user