diff --git a/ChangeLog b/ChangeLog index 5182a84cd33..9f1ae0857a2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -99,6 +99,7 @@ For users: - Fix: [ bug #1506, #1507 ] ECM trigger error problem - Fix: [ bug #1469 ] Triggers CONTACT_MODIFY and CONTACT_DELETE duplicates error message - Fix: [ bug #1537 ] Difference between societe.nom and adherent.societe. +- Fix: [ bug #1535 ] Supplier invoice Extrafields are not shown For users, new experimental module (need to set feature level of instance to experimental to see them): - New: Module Accounting Expert to manage accountancy diff --git a/htdocs/core/tpl/extrafields_view.tpl.php b/htdocs/core/tpl/extrafields_view.tpl.php index d344ef5eb82..ee2a8695f3a 100644 --- a/htdocs/core/tpl/extrafields_view.tpl.php +++ b/htdocs/core/tpl/extrafields_view.tpl.php @@ -1,5 +1,6 @@ + * Copyright (C) 2014 Juanjo Menent * * 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 @@ -48,7 +49,9 @@ if (empty($reshook) && ! empty($extrafields->attribute_label)) print 'attribute_required [$key])) print ' class="fieldrequired"'; print '>' . $label . ''; - if (($object->statut == 0 || $extrafields->attribute_alwayseditable[$key]) && $user->rights->{$object->element}->creer && ($action != 'edit_extras' || GETPOST('attribute') != $key)) + + //TODO Improve element and rights detection + if (($object->statut == 0 || $extrafields->attribute_alwayseditable[$key]) && ($object->element=='order_supplier'?$user->rights->fournisseur>commande:($object->element=='invoice_supplier'?$user->rights->fournisseur>facture:$user->rights->{$object->element}->creer)) && ($action != 'edit_extras' || GETPOST('attribute') != $key)) print ''; print '
' . img_edit().'
'; @@ -58,8 +61,9 @@ if (empty($reshook) && ! empty($extrafields->attribute_label)) 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->{$object->element}->creer && GETPOST('attribute') == $key) + + //TODO Improve element and rights detection + if ($action == 'edit_extras' && ($object->element=='order_supplier'?$user->rights->fournisseur>commande:($object->element=='invoice_supplier'?$user->rights->fournisseur>facture:$user->rights->{$object->element}->creer)) && GETPOST('attribute') == $key) { print '
'; print ''; diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index bd786cfdf4c..ec74b836e1c 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -255,6 +255,16 @@ class FactureFournisseur extends CommonInvoice $result=$this->update_price(); if ($result > 0) { + + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + { + $result=$this->insertExtraFields(); + if ($result < 0) + { + $error++; + } + } + // Call trigger $result=$this->call_trigger('BILL_SUPPLIER_CREATE',$user); if ($result < 0) $error++; diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index b88fd582400..4f1583f6b61 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -300,10 +300,16 @@ elseif ($action == 'add' && $user->rights->fournisseur->facture->creer) $_GET['socid']=$_POST['socid']; $error++; } - + + // Fill array 'array_options' with data from add form + if (! $error) { $db->begin(); + + $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); + $ret = $extrafields->setOptionalsFromPost($extralabels, $object); + if ($ret < 0) $error ++; $tmpproject = GETPOST('projectid', 'int'); @@ -1179,6 +1185,9 @@ llxHeader('','',''); // Mode creation if ($action == 'create') { + $facturestatic = new FactureFournisseur($db); + $extralabels = $extrafields->fetch_name_optionals_label($facturestatic->table_element); + print_fiche_titre($langs->trans('NewBill')); dol_htmloutput_events(); @@ -1419,6 +1428,11 @@ if ($action == 'create') print ''; // print ''; print ''; + + if (empty($reshook) && ! empty($extrafields->attribute_label)) + { + print $object->showOptionals($extrafields, 'edit'); + } if (is_object($objectsrc)) { @@ -1530,6 +1544,9 @@ else $societe = new Fournisseur($db); $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); /* * View card