Extrafields for expensereports are visible on cards
This commit is contained in:
parent
cc9230c07f
commit
10c1f02243
@ -262,7 +262,6 @@ if (empty($reshook))
|
|||||||
$object->location_incoterms = GETPOST('location_incoterms', 'alpha');
|
$object->location_incoterms = GETPOST('location_incoterms', 'alpha');
|
||||||
$object->multicurrency_code = GETPOST('multicurrency_code', 'alpha');
|
$object->multicurrency_code = GETPOST('multicurrency_code', 'alpha');
|
||||||
$object->multicurrency_tx = GETPOST('originmulticurrency_tx', 'int');
|
$object->multicurrency_tx = GETPOST('originmulticurrency_tx', 'int');
|
||||||
|
|
||||||
// Fill array 'array_options' with data from add form
|
// Fill array 'array_options' with data from add form
|
||||||
if (! $error)
|
if (! $error)
|
||||||
{
|
{
|
||||||
@ -1212,7 +1211,6 @@ if (empty($reshook))
|
|||||||
if (! $error)
|
if (! $error)
|
||||||
{
|
{
|
||||||
// Actions on extra fields (by external module or standard code)
|
// Actions on extra fields (by external module or standard code)
|
||||||
// TODO le hook fait double emploi avec le trigger !!
|
|
||||||
$hookmanager->initHooks(array('orderdao'));
|
$hookmanager->initHooks(array('orderdao'));
|
||||||
$parameters = array('id' => $object->id);
|
$parameters = array('id' => $object->id);
|
||||||
$reshook = $hookmanager->executeHooks('insertExtraFields', $parameters, $object, $action); // Note that $action and $object may have been modified by
|
$reshook = $hookmanager->executeHooks('insertExtraFields', $parameters, $object, $action); // Note that $action and $object may have been modified by
|
||||||
|
|||||||
@ -38,6 +38,7 @@ require_once DOL_DOCUMENT_ROOT . '/core/modules/expensereport/modules_expenserep
|
|||||||
require_once DOL_DOCUMENT_ROOT . '/expensereport/class/expensereport.class.php';
|
require_once DOL_DOCUMENT_ROOT . '/expensereport/class/expensereport.class.php';
|
||||||
require_once DOL_DOCUMENT_ROOT . '/compta/paiement/class/paiement.class.php';
|
require_once DOL_DOCUMENT_ROOT . '/compta/paiement/class/paiement.class.php';
|
||||||
require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php';
|
require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php';
|
||||||
|
require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php';
|
||||||
|
|
||||||
$langs->load("trips");
|
$langs->load("trips");
|
||||||
$langs->load("bills");
|
$langs->load("bills");
|
||||||
@ -89,11 +90,35 @@ $hidedesc = (GETPOST('hidedesc', 'int') ? GETPOST('hidedesc', 'int') : (! empty(
|
|||||||
$hideref = (GETPOST('hideref', 'int') ? GETPOST('hideref', 'int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0));
|
$hideref = (GETPOST('hideref', 'int') ? GETPOST('hideref', 'int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0));
|
||||||
|
|
||||||
|
|
||||||
|
$object=new ExpenseReport($db);
|
||||||
|
$extrafields = new ExtraFields($db);
|
||||||
|
|
||||||
|
// 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
|
||||||
|
|
||||||
|
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
|
||||||
|
$hookmanager->initHooks(array('expensereportcard','globalcard'));
|
||||||
|
|
||||||
|
$permissionnote = $user->rights->expensereport->creer; // Used by the include of actions_setnotes.inc.php
|
||||||
|
$permissiondellink = $user->rights->expensereport->creer; // Used by the include of actions_dellink.inc.php
|
||||||
|
$permissionedit = $user->rights->expensereport->creer; // Used by the include of actions_lineupdown.inc.php
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Actions
|
* Actions
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
$parameters = array('socid' => $socid);
|
||||||
|
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
|
||||||
|
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||||
|
|
||||||
|
if (empty($reshook))
|
||||||
|
{
|
||||||
if ($cancel)
|
if ($cancel)
|
||||||
{
|
{
|
||||||
$action='';
|
$action='';
|
||||||
@ -108,6 +133,42 @@ if ($cancel)
|
|||||||
$fk_c_type_fees=-1;
|
$fk_c_type_fees=-1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once
|
||||||
|
|
||||||
|
include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, not include_once
|
||||||
|
|
||||||
|
include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php'; // Must be include, not include_once
|
||||||
|
|
||||||
|
// Action clone object
|
||||||
|
if ($action == 'confirm_clone' && $confirm == 'yes' && $user->rights->expensereport->creer)
|
||||||
|
{
|
||||||
|
if (1==0 && ! GETPOST('clone_content') && ! GETPOST('clone_receivers'))
|
||||||
|
{
|
||||||
|
setEventMessages($langs->trans("NoCloneOptionsSpecified"), null, 'errors');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ($object->id > 0)
|
||||||
|
{
|
||||||
|
// Because createFromClone modifies the object, we must clone it so that we can restore it later
|
||||||
|
$orig = clone $object;
|
||||||
|
|
||||||
|
$result=$object->createFromClone($socid);
|
||||||
|
if ($result > 0)
|
||||||
|
{
|
||||||
|
header("Location: ".$_SERVER['PHP_SELF'].'?id='.$result);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
setEventMessages($object->error, $object->errors, 'errors');
|
||||||
|
$object = $orig;
|
||||||
|
$action='';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ($action == 'confirm_delete' && GETPOST("confirm") == "yes" && $id > 0 && $user->rights->expensereport->supprimer)
|
if ($action == 'confirm_delete' && GETPOST("confirm") == "yes" && $id > 0 && $user->rights->expensereport->supprimer)
|
||||||
{
|
{
|
||||||
$object = new ExpenseReport($db);
|
$object = new ExpenseReport($db);
|
||||||
@ -135,6 +196,12 @@ if ($action == 'add' && $user->rights->expensereport->creer)
|
|||||||
$object->fk_user_validator = GETPOST('fk_user_validator','int');
|
$object->fk_user_validator = GETPOST('fk_user_validator','int');
|
||||||
$object->note_public = GETPOST('note_public');
|
$object->note_public = GETPOST('note_public');
|
||||||
$object->note_private = GETPOST('note_private');
|
$object->note_private = GETPOST('note_private');
|
||||||
|
// Fill array 'array_options' with data from add form
|
||||||
|
if (! $error)
|
||||||
|
{
|
||||||
|
$ret = $extrafields->setOptionalsFromPost($extralabels, $object);
|
||||||
|
if ($ret < 0) $error++;
|
||||||
|
}
|
||||||
|
|
||||||
if ($object->periode_existe($user,$object->date_debut,$object->date_fin))
|
if ($object->periode_existe($user,$object->date_debut,$object->date_fin))
|
||||||
{
|
{
|
||||||
@ -194,6 +261,33 @@ if ($action == 'update' && $user->rights->expensereport->creer)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($action == 'update_extras')
|
||||||
|
{
|
||||||
|
// 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'));
|
||||||
|
if ($ret < 0) $error++;
|
||||||
|
|
||||||
|
if (! $error)
|
||||||
|
{
|
||||||
|
// Actions on extra fields (by external module or standard code)
|
||||||
|
$hookmanager->initHooks(array('expensereportdao'));
|
||||||
|
$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)) {
|
||||||
|
$result = $object->insertExtraFields();
|
||||||
|
if ($result < 0) {
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
|
} else if ($reshook < 0)
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($error)
|
||||||
|
$action = 'edit_extras';
|
||||||
|
}
|
||||||
|
|
||||||
if ($action == "confirm_validate" && GETPOST("confirm") == "yes" && $id > 0 && $user->rights->expensereport->creer)
|
if ($action == "confirm_validate" && GETPOST("confirm") == "yes" && $id > 0 && $user->rights->expensereport->creer)
|
||||||
{
|
{
|
||||||
$object = new ExpenseReport($db);
|
$object = new ExpenseReport($db);
|
||||||
@ -1074,11 +1168,13 @@ else if ($action == 'remove_file')
|
|||||||
$action='';
|
$action='';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* View
|
* View
|
||||||
*/
|
*/
|
||||||
|
|
||||||
$title=$langs->trans("ExpenseReport") . " - " . $langs->trans("Card");
|
$title=$langs->trans("ExpenseReport") . " - " . $langs->trans("Card");
|
||||||
$helpurl="EN:Module_Expense_Reports";
|
$helpurl="EN:Module_Expense_Reports";
|
||||||
llxHeader("",$title,$helpurl);
|
llxHeader("",$title,$helpurl);
|
||||||
@ -1155,6 +1251,14 @@ if ($action == 'create')
|
|||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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
|
||||||
|
if (empty($reshook) && ! empty($extrafields->attribute_label)) {
|
||||||
|
print $object->showOptionals($extrafields, 'edit');
|
||||||
|
}
|
||||||
|
|
||||||
print '<tbody>';
|
print '<tbody>';
|
||||||
print '</table>';
|
print '</table>';
|
||||||
|
|
||||||
@ -1171,9 +1275,10 @@ else
|
|||||||
{
|
{
|
||||||
if($id > 0 || $ref)
|
if($id > 0 || $ref)
|
||||||
{
|
{
|
||||||
$object = new ExpenseReport($db);
|
|
||||||
$result = $object->fetch($id, $ref);
|
$result = $object->fetch($id, $ref);
|
||||||
|
|
||||||
|
$res = $object->fetch_optionals($object->id, $extralabels);
|
||||||
|
|
||||||
if ($result > 0)
|
if ($result > 0)
|
||||||
{
|
{
|
||||||
if ($object->fk_user_author != $user->id)
|
if ($object->fk_user_author != $user->id)
|
||||||
@ -1285,6 +1390,10 @@ else
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Other attributes
|
||||||
|
//$cols = 3;
|
||||||
|
//include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_edit.tpl.php';
|
||||||
|
|
||||||
// Public note
|
// Public note
|
||||||
print '<tr>';
|
print '<tr>';
|
||||||
print '<td class="border" valign="top">' . $langs->trans('NotePublic') . '</td>';
|
print '<td class="border" valign="top">' . $langs->trans('NotePublic') . '</td>';
|
||||||
@ -1609,6 +1718,10 @@ else
|
|||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Other attributes
|
||||||
|
$cols = 3;
|
||||||
|
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
|
||||||
|
|
||||||
print '</table>';
|
print '</table>';
|
||||||
|
|
||||||
print '<br>';
|
print '<br>';
|
||||||
@ -2046,6 +2159,7 @@ print '<div style="width:50%">';
|
|||||||
/*
|
/*
|
||||||
* Generate documents
|
* Generate documents
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if($user->rights->expensereport->export && $object->fk_statut>0 && $action != 'edit')
|
if($user->rights->expensereport->export && $object->fk_statut>0 && $action != 'edit')
|
||||||
{
|
{
|
||||||
$filename = dol_sanitizeFileName($object->ref);
|
$filename = dol_sanitizeFileName($object->ref);
|
||||||
@ -2074,10 +2188,12 @@ if ($action != 'create' && $action != 'edit' && ($id || $ref))
|
|||||||
|
|
||||||
// Show links to link elements
|
// Show links to link elements
|
||||||
$linktoelements=array();
|
$linktoelements=array();
|
||||||
if (! empty($conf->global->EXPENSES_LINK_TO_INTERVENTION)) $linktoelements[]='fichinter';
|
if (! empty($conf->global->EXPENSES_LINK_TO_INTERVENTION))
|
||||||
|
{
|
||||||
|
$linktoelements[]='fichinter';
|
||||||
$linktoelem = $form->showLinkToObjectBlock($object, $linktoelements, array('expensereport'));
|
$linktoelem = $form->showLinkToObjectBlock($object, $linktoelements, array('expensereport'));
|
||||||
$somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
|
$somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
llxFooter();
|
llxFooter();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user