From 94ab340bba53c5e7144d7c00b127fca0dc0f2b61 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 19 Jun 2021 19:12:57 +0200 Subject: [PATCH] Fix css --- htdocs/expensereport/card.php | 1625 +++++++++-------- .../tpl/expensereport_linktofile.tpl.php | 12 +- 2 files changed, 823 insertions(+), 814 deletions(-) diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index 1ac24b56e6b..344c65832db 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -1438,16 +1438,15 @@ if ($action == 'create') { print ''; print ''; -} else { - if ($id > 0 || $ref) { - $result = $object->fetch($id, $ref); +} elseif ($id > 0 || $ref) { + $result = $object->fetch($id, $ref); - $res = $object->fetch_optionals(); + $res = $object->fetch_optionals(); - if ($result > 0) { - if (!in_array($object->fk_user_author, $user->getAllChildIds(1))) { - if (empty($user->rights->expensereport->readall) && empty($user->rights->expensereport->lire_tous) - && (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || empty($user->rights->expensereport->writeall_advance))) { + if ($result > 0) { + if (!in_array($object->fk_user_author, $user->getAllChildIds(1))) { + if (empty($user->rights->expensereport->readall) && empty($user->rights->expensereport->lire_tous) + && (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || empty($user->rights->expensereport->writeall_advance))) { print load_fiche_titre($langs->trans('TripCard'), '', 'trip'); print '
'; @@ -1459,736 +1458,736 @@ if ($action == 'create') { $db->close(); exit; - } + } + } + + $head = expensereport_prepare_head($object); + + if ($action == 'edit' && ($object->status < 3 || $object->status == 99)) { + print "
\n"; + print ''; + print ''; + + print dol_get_fiche_head($head, 'card', $langs->trans("ExpenseReport"), 0, 'trip'); + + if ($object->status == 99) { + print ''; + } else { + print ''; } - $head = expensereport_prepare_head($object); + $linkback = ''.$langs->trans("BackToList").''; - if ($action == 'edit' && ($object->status < 3 || $object->status == 99)) { - print "\n"; - print ''; - print ''; + print ''; - print dol_get_fiche_head($head, 'card', $langs->trans("ExpenseReport"), 0, 'trip'); + print ''; + print ''; + print ''; - if ($object->status == 99) { - print ''; - } else { - print ''; - } + // Ref + print ''; - $linkback = ''.$langs->trans("BackToList").''; - - print '
'.$langs->trans("User").''; + $userfee = new User($db); + if ($object->fk_user_author > 0) { + $userfee->fetch($object->fk_user_author); + print $userfee->getNomUrl(-1); + } + print '
'.$langs->trans("Ref").''; + print $form->showrefnav($object, 'ref', $linkback, 1, 'ref', 'ref', ''); + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + if (!empty($conf->global->EXPENSEREPORT_ASK_PAYMENTMODE_ON_CREATION)) { print ''; - print ''; + print ''; + print ''; + print ''; + } + + if ($object->status < 3) { + print ''; + print ''; // Approbator + print ''; + print ''; + } else { + print ''; + print ''; print ''; + } - // Ref - print ''; + print ''; + print ''; + } - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + // Other attributes + //$cols = 3; + //include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_edit.tpl.php'; - if (!empty($conf->global->EXPENSEREPORT_ASK_PAYMENTMODE_ON_CREATION)) { - print ''; - print ''; - print ''; - print ''; + print '
'.$langs->trans("DateStart").''; + print $form->selectDate($object->date_debut, 'date_debut'); + print '
'.$langs->trans("DateEnd").''; + print $form->selectDate($object->date_fin, 'date_fin'); + print '
'.$langs->trans("User").''.$langs->trans("ModePaiement").''; + $form->select_types_paiements($object->fk_c_paiement, 'fk_c_paiement'); + print '
'.$langs->trans("VALIDATOR").''; + $include_users = $object->fetch_users_approver_expensereport(); + $s = $form->select_dolusers($object->fk_user_validator, "fk_user_validator", 1, "", 0, $include_users); + print $form->textwithpicto($s, $langs->trans("AnyOtherInThisListCanValidate")); + print '
'.$langs->trans("VALIDOR").''; $userfee = new User($db); - if ($object->fk_user_author > 0) { - $userfee->fetch($object->fk_user_author); - print $userfee->getNomUrl(-1); - } + $userfee->fetch($object->fk_user_valid); + print $userfee->getNomUrl(-1); print '
'.$langs->trans("Ref").''; - print $form->showrefnav($object, 'ref', $linkback, 1, 'ref', 'ref', ''); + if ($object->status == 6) { + print '
'.$langs->trans("AUTHORPAIEMENT").''; + $userfee = new User($db); + $userfee->fetch($user->id); + print $userfee->getNomUrl(-1); print '
'.$langs->trans("DateStart").''; - print $form->selectDate($object->date_debut, 'date_debut'); - print '
'.$langs->trans("DateEnd").''; - print $form->selectDate($object->date_fin, 'date_fin'); - print '
'.$langs->trans("ModePaiement").''; - $form->select_types_paiements($object->fk_c_paiement, 'fk_c_paiement'); - print '
'; + + print dol_get_fiche_end(); + + print '
'; + print ''; + print '     '; + print '
'; + + print '
'; + } else { + print dol_get_fiche_head($head, 'card', $langs->trans("ExpenseReport"), -1, 'trip'); + + // Clone confirmation + if ($action == 'clone') { + // Create an array for form + $criteriaforfilter = 'hierarchyme'; + if (!empty($user->rights->expensereport->readall)) { + $criteriaforfilter = ''; } + $formquestion = array( + 'text' => '', + array('type' => 'other', 'name' => 'fk_user_author', 'label' => $langs->trans("SelectTargetUser"), 'value' => $form->select_dolusers((GETPOST('fk_user_author', 'int') > 0 ? GETPOST('fk_user_author', 'int') : $user->id), 'fk_user_author', 0, null, 0, $criteriaforfilter, '', '0', 0, 0, '', 0, '', 'maxwidth150')) + ); + // Paiement incomplet. On demande si motif = escompte ou autre + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneExpenseReport', $object->ref), 'confirm_clone', $formquestion, 'yes', 1); + } - if ($object->status < 3) { - print ''; - print ''.$langs->trans("VALIDATOR").''; // Approbator - print ''; - $include_users = $object->fetch_users_approver_expensereport(); - $s = $form->select_dolusers($object->fk_user_validator, "fk_user_validator", 1, "", 0, $include_users); - print $form->textwithpicto($s, $langs->trans("AnyOtherInThisListCanValidate")); - print ''; - print ''; - } else { - print ''; - print ''.$langs->trans("VALIDOR").''; - print ''; + if ($action == 'save') { + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$id, $langs->trans("SaveTrip"), $langs->trans("ConfirmSaveTrip"), "confirm_validate", "", "", 1); + } + + if ($action == 'save_from_refuse') { + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$id, $langs->trans("SaveTrip"), $langs->trans("ConfirmSaveTrip"), "confirm_save_from_refuse", "", "", 1); + } + + if ($action == 'delete') { + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$id, $langs->trans("DeleteTrip"), $langs->trans("ConfirmDeleteTrip"), "confirm_delete", "", "", 1); + } + + if ($action == 'validate') { + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$id, $langs->trans("ValideTrip"), $langs->trans("ConfirmValideTrip"), "confirm_approve", "", "", 1); + } + + if ($action == 'paid') { + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$id, $langs->trans("PaidTrip"), $langs->trans("ConfirmPaidTrip"), "confirm_paid", "", "", 1); + } + + if ($action == 'cancel') { + $array_input = array('text'=>$langs->trans("ConfirmCancelTrip"), array('type'=>"text", 'label'=>''.$langs->trans("Comment").'', 'name'=>"detail_cancel", 'value'=>"")); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$id, $langs->trans("Cancel"), "", "confirm_cancel", $array_input, "", 1); + } + + if ($action == 'setdraft') { + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$id, $langs->trans("BrouillonnerTrip"), $langs->trans("ConfirmBrouillonnerTrip"), "confirm_setdraft", "", "", 1); + } + + if ($action == 'refuse') { // Deny + $array_input = array('text'=>$langs->trans("ConfirmRefuseTrip"), array('type'=>"text", 'label'=>$langs->trans("Comment"), 'name'=>"detail_refuse", 'value'=>"")); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$id, $langs->trans("Deny"), '', "confirm_refuse", $array_input, "yes", 1); + } + + if ($action == 'delete_line') { + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$id."&rowid=".GETPOST('rowid', 'int'), $langs->trans("DeleteLine"), $langs->trans("ConfirmDeleteLine"), "confirm_delete_line", '', 'yes', 1); + } + + // Print form confirm + print $formconfirm; + + // Expense report card + $linkback = ''.$langs->trans("BackToList").''; + + $morehtmlref = '
'; + /* + // Ref customer + $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, $user->rights->commande->creer, 'string', '', 0, 1); + $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, $user->rights->commande->creer, 'string', '', null, null, '', 1); + // Thirdparty + $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . $soc->getNomUrl(1); + // Project + if (! empty($conf->projet->enabled)) + { + $langs->load("projects"); + $morehtmlref.='
'.$langs->trans('Project') . ' '; + if ($user->rights->commande->creer) + { + if ($action != 'classify') + $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.='
'; + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=''; + $morehtmlref.='
'; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } + } else { + if (! empty($object->fk_project)) { + $proj = new Project($db); + $proj->fetch($object->fk_project); + $morehtmlref.=''; + $morehtmlref.=$proj->ref; + $morehtmlref.=''; + } else { + $morehtmlref.=''; + } + } + }*/ + $morehtmlref .= '
'; + + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); + + print '
'; + print '
'; + print '
'; + + print ''; + + // Author + print ''; + print ''; + print ''; + + // Period + print ''; + print ''; + print ''; + print ''; + if (!empty($conf->global->EXPENSEREPORT_ASK_PAYMENTMODE_ON_CREATION)) { + print ''; + print ''; + print ''; + print ''; + } + + // Validation date + print ''; + print ''; + print ''; + print ''; + + // User to inform for approval + if ($object->status <= ExpenseReport::STATUS_VALIDATED) { // informed + print ''; + print ''; // approver + print ''; - } - - if ($object->status == 6) { - print ''; - print ''; - print ''; - } - - // Other attributes - //$cols = 3; - //include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_edit.tpl.php'; - - print '
'.$langs->trans("User").''; + if ($object->fk_user_author > 0) { + $userauthor = new User($db); + $result = $userauthor->fetch($object->fk_user_author); + if ($result < 0) { + dol_print_error('', $userauthor->error); + } elseif ($result > 0) { + print $userauthor->getNomUrl(-1); + } + } + print '
'.$langs->trans("Period").''; + print get_date_range($object->date_debut, $object->date_fin, 'day', $langs, 0); + print '
'.$langs->trans("ModePaiement").''.$object->fk_c_paiement.'
'.$langs->trans("DATE_SAVE").''.dol_print_date($object->date_valid, 'dayhour', 'tzuser'); + if ($object->status == 2 && $object->hasDelay('toapprove')) { + print ' '.img_warning($langs->trans("Late").' - '.$langs->trans("ToApprove")); + } + if ($object->status == 5 && $object->hasDelay('topay')) { + print ' '.img_warning($langs->trans("Late").' - '.$langs->trans("ToPay")); + } + print '
'.$langs->trans("VALIDATOR").''; + if ($object->fk_user_validator > 0) { $userfee = new User($db); - $userfee->fetch($object->fk_user_valid); - print $userfee->getNomUrl(-1); - print '
'.$langs->trans("AUTHORPAIEMENT").''; - $userfee = new User($db); - $userfee->fetch($user->id); - print $userfee->getNomUrl(-1); - print '
'; - - print dol_get_fiche_end(); - - print '
'; - print ''; - print '     '; - print '
'; - - print ''; - } else { - print dol_get_fiche_head($head, 'card', $langs->trans("ExpenseReport"), -1, 'trip'); - - // Clone confirmation - if ($action == 'clone') { - // Create an array for form - $criteriaforfilter = 'hierarchyme'; - if (!empty($user->rights->expensereport->readall)) { - $criteriaforfilter = ''; - } - $formquestion = array( - 'text' => '', - array('type' => 'other', 'name' => 'fk_user_author', 'label' => $langs->trans("SelectTargetUser"), 'value' => $form->select_dolusers((GETPOST('fk_user_author', 'int') > 0 ? GETPOST('fk_user_author', 'int') : $user->id), 'fk_user_author', 0, null, 0, $criteriaforfilter, '', '0', 0, 0, '', 0, '', 'maxwidth150')) - ); - // Paiement incomplet. On demande si motif = escompte ou autre - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneExpenseReport', $object->ref), 'confirm_clone', $formquestion, 'yes', 1); - } - - if ($action == 'save') { - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$id, $langs->trans("SaveTrip"), $langs->trans("ConfirmSaveTrip"), "confirm_validate", "", "", 1); - } - - if ($action == 'save_from_refuse') { - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$id, $langs->trans("SaveTrip"), $langs->trans("ConfirmSaveTrip"), "confirm_save_from_refuse", "", "", 1); - } - - if ($action == 'delete') { - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$id, $langs->trans("DeleteTrip"), $langs->trans("ConfirmDeleteTrip"), "confirm_delete", "", "", 1); - } - - if ($action == 'validate') { - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$id, $langs->trans("ValideTrip"), $langs->trans("ConfirmValideTrip"), "confirm_approve", "", "", 1); - } - - if ($action == 'paid') { - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$id, $langs->trans("PaidTrip"), $langs->trans("ConfirmPaidTrip"), "confirm_paid", "", "", 1); - } - - if ($action == 'cancel') { - $array_input = array('text'=>$langs->trans("ConfirmCancelTrip"), array('type'=>"text", 'label'=>''.$langs->trans("Comment").'', 'name'=>"detail_cancel", 'value'=>"")); - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$id, $langs->trans("Cancel"), "", "confirm_cancel", $array_input, "", 1); - } - - if ($action == 'setdraft') { - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$id, $langs->trans("BrouillonnerTrip"), $langs->trans("ConfirmBrouillonnerTrip"), "confirm_setdraft", "", "", 1); - } - - if ($action == 'refuse') { // Deny - $array_input = array('text'=>$langs->trans("ConfirmRefuseTrip"), array('type'=>"text", 'label'=>$langs->trans("Comment"), 'name'=>"detail_refuse", 'value'=>"")); - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$id, $langs->trans("Deny"), '', "confirm_refuse", $array_input, "yes", 1); - } - - if ($action == 'delete_line') { - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$id."&rowid=".GETPOST('rowid', 'int'), $langs->trans("DeleteLine"), $langs->trans("ConfirmDeleteLine"), "confirm_delete_line", '', 'yes', 1); - } - - // Print form confirm - print $formconfirm; - - // Expense report card - $linkback = ''.$langs->trans("BackToList").''; - - $morehtmlref = '
'; - /* - // Ref customer - $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, $user->rights->commande->creer, 'string', '', 0, 1); - $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, $user->rights->commande->creer, 'string', '', null, null, '', 1); - // Thirdparty - $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . $soc->getNomUrl(1); - // Project - if (! empty($conf->projet->enabled)) - { - $langs->load("projects"); - $morehtmlref.='
'.$langs->trans('Project') . ' '; - if ($user->rights->commande->creer) - { - if ($action != 'classify') - $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.='
'; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.='
'; - } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); - } - } else { - if (! empty($object->fk_project)) { - $proj = new Project($db); - $proj->fetch($object->fk_project); - $morehtmlref.=''; - $morehtmlref.=$proj->ref; - $morehtmlref.=''; - } else { - $morehtmlref.=''; - } - } - }*/ - $morehtmlref .= '
'; - - dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); - - print '
'; - print '
'; - print '
'; - - print ''; - - // Author - print ''; - print ''; - print ''; - - // Period - print ''; - print ''; - print ''; - print ''; - if (!empty($conf->global->EXPENSEREPORT_ASK_PAYMENTMODE_ON_CREATION)) { - print ''; - print ''; - print ''; - print ''; - } - - // Validation date - print ''; - print ''; - print ''; - print ''; - - // User to inform for approval - if ($object->status <= ExpenseReport::STATUS_VALIDATED) { // informed - print ''; - print ''; // approver - print ''; - } elseif ($object->status == ExpenseReport::STATUS_CANCELED) { - print ''; - print ''; - print ''; - - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - } else { - print ''; - print ''; - print ''; - - print ''; - print ''; - print ''; - print ''; - } - - if ($object->status == 99 || !empty($object->detail_refuse)) { - print ''; - print ''; - print ''; - - print ''; - print ''; - print ''; - print ''; } + print ''; + } elseif ($object->status == ExpenseReport::STATUS_CANCELED) { + print ''; + print ''; + print ''; - if ($object->status == $object::STATUS_CLOSED) { - /* TODO this fields are not yet filled - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + } else { + print ''; + print ''; + print ''; + + print ''; + print ''; + print ''; + print ''; + } + + if ($object->status == 99 || !empty($object->detail_refuse)) { + print ''; + print ''; + print ''; - print ''; - print ''; - print ''; - print ''; - */ } - - // Other attributes - $cols = 2; - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; - - print '
'.$langs->trans("User").''; - if ($object->fk_user_author > 0) { - $userauthor = new User($db); - $result = $userauthor->fetch($object->fk_user_author); - if ($result < 0) { - dol_print_error('', $userauthor->error); - } elseif ($result > 0) { - print $userauthor->getNomUrl(-1); - } - } - print '
'.$langs->trans("Period").''; - print get_date_range($object->date_debut, $object->date_fin, 'day', $langs, 0); - print '
'.$langs->trans("ModePaiement").''.$object->fk_c_paiement.'
'.$langs->trans("DATE_SAVE").''.dol_print_date($object->date_valid, 'dayhour', 'tzuser'); - if ($object->status == 2 && $object->hasDelay('toapprove')) { - print ' '.img_warning($langs->trans("Late").' - '.$langs->trans("ToApprove")); - } - if ($object->status == 5 && $object->hasDelay('topay')) { - print ' '.img_warning($langs->trans("Late").' - '.$langs->trans("ToPay")); - } - print '
'.$langs->trans("VALIDATOR").''; - if ($object->fk_user_validator > 0) { - $userfee = new User($db); - $result = $userfee->fetch($object->fk_user_validator); - if ($result > 0) { - print $userfee->getNomUrl(-1); - } - if (empty($userfee->email) || !isValidEmail($userfee->email)) { - $langs->load("errors"); - print img_warning($langs->trans("ErrorBadEMail", $userfee->email)); - } - } - print '
'.$langs->trans("CANCEL_USER").''; - if ($object->fk_user_cancel > 0) { - $userfee = new User($db); - $result = $userfee->fetch($object->fk_user_cancel); - if ($result > 0) { - print $userfee->getNomUrl(-1); - } - } - print '
'.$langs->trans("MOTIF_CANCEL").''.$object->detail_cancel.'
'.$langs->trans("DATE_CANCEL").''.dol_print_date($object->date_cancel, 'dayhour', 'tzuser').'
'.$langs->trans("ApprovedBy").''; - if ($object->fk_user_approve > 0) { - $userapp = new User($db); - $result = $userapp->fetch($object->fk_user_approve); - if ($result > 0) { - print $userapp->getNomUrl(-1); - } - } - print '
'.$langs->trans("DateApprove").''.dol_print_date($object->date_approve, 'dayhour', 'tzuser').'
'.$langs->trans("REFUSEUR").''; - $userfee = new User($db); - $result = $userfee->fetch($object->fk_user_refuse); + $result = $userfee->fetch($object->fk_user_validator); if ($result > 0) { print $userfee->getNomUrl(-1); } - print '
'.$langs->trans("DATE_REFUS").''.dol_print_date($object->date_refuse, 'dayhour', 'tzuser'); - if ($object->detail_refuse) { - print ' - '.$object->detail_refuse; + if (empty($userfee->email) || !isValidEmail($userfee->email)) { + $langs->load("errors"); + print img_warning($langs->trans("ErrorBadEMail", $userfee->email)); } - print '
'.$langs->trans("CANCEL_USER").''; + if ($object->fk_user_cancel > 0) { + $userfee = new User($db); + $result = $userfee->fetch($object->fk_user_cancel); + if ($result > 0) { + print $userfee->getNomUrl(-1); + } + } + print '
'.$langs->trans("AUTHORPAIEMENT").''; - $userfee=new User($db); - $userfee->fetch($object->fk_user_paid); + print '
'.$langs->trans("MOTIF_CANCEL").''.$object->detail_cancel.'
'.$langs->trans("DATE_CANCEL").''.dol_print_date($object->date_cancel, 'dayhour', 'tzuser').'
'.$langs->trans("ApprovedBy").''; + if ($object->fk_user_approve > 0) { + $userapp = new User($db); + $result = $userapp->fetch($object->fk_user_approve); + if ($result > 0) { + print $userapp->getNomUrl(-1); + } + } + print '
'.$langs->trans("DateApprove").''.dol_print_date($object->date_approve, 'dayhour', 'tzuser').'
'.$langs->trans("REFUSEUR").''; + $userfee = new User($db); + $result = $userfee->fetch($object->fk_user_refuse); + if ($result > 0) { print $userfee->getNomUrl(-1); - print '
'.$langs->trans("DATE_PAIEMENT").''.$object->date_paiement.'
'; - - print '
'; - print '
'; - print '
'; - print '
'; - - print ''; - - // Amount - print ''; - print ''; - print ''; - $rowspan = 5; - if ($object->status <= ExpenseReport::STATUS_VALIDATED) { - $rowspan++; - } elseif ($object->status == ExpenseReport::STATUS_CANCELED) { - $rowspan += 2; - } else { - $rowspan += 2; - } - if ($object->status == ExpenseReport::STATUS_REFUSED || !empty($object->detail_refuse)) { - $rowspan += 2; - } - if ($object->status == ExpenseReport::STATUS_CLOSED) { - $rowspan += 2; - } - print ""; - print ''; + print ''; print ''; - print ''; - print ''; + print ''; + print ''; print ''; + } - print ''; - print ''; - print ''; - print ''; + if ($object->status == $object::STATUS_CLOSED) { + /* TODO this fields are not yet filled + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + */ + } - // List of payments already done - $nbcols = 3; - if (!empty($conf->banque->enabled)) { - $nbrows++; - $nbcols++; + // Other attributes + $cols = 2; + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; + + print '
'.$langs->trans("AmountHT").''.price($object->total_ht, 1, '', 1, - 1, - 1, $conf->currency).'
'.$langs->trans("AmountVAT").''.price($object->total_tva, 1, '', 1, - 1, - 1, $conf->currency).''.$langs->trans("DATE_REFUS").''.dol_print_date($object->date_refuse, 'dayhour', 'tzuser'); + if ($object->detail_refuse) { + print ' - '.$object->detail_refuse; + } + print '
'.$langs->trans("AmountTTC").''.price($object->total_ttc, 1, '', 1, - 1, - 1, $conf->currency).'
'.$langs->trans("AUTHORPAIEMENT").''; + $userfee=new User($db); + $userfee->fetch($object->fk_user_paid); + print $userfee->getNomUrl(-1); + print '
'.$langs->trans("DATE_PAIEMENT").''.$object->date_paiement.'
'; + + print '
'; + print '
'; + print '
'; + print '
'; + + print ''; + + // Amount + print ''; + print ''; + print ''; + $rowspan = 5; + if ($object->status <= ExpenseReport::STATUS_VALIDATED) { + $rowspan++; + } elseif ($object->status == ExpenseReport::STATUS_CANCELED) { + $rowspan += 2; + } else { + $rowspan += 2; + } + if ($object->status == ExpenseReport::STATUS_REFUSED || !empty($object->detail_refuse)) { + $rowspan += 2; + } + if ($object->status == ExpenseReport::STATUS_CLOSED) { + $rowspan += 2; + } + print ""; + print ''; + + print ''; + print ''; + print ''; + print ''; + + print ''; + print ''; + print ''; + print ''; + + // List of payments already done + $nbcols = 3; + if (!empty($conf->banque->enabled)) { + $nbrows++; + $nbcols++; + } + + print '
'.$langs->trans("AmountHT").''.price($object->total_ht, 1, '', 1, - 1, - 1, $conf->currency).'
'.$langs->trans("AmountVAT").''.price($object->total_tva, 1, '', 1, - 1, - 1, $conf->currency).'
'.$langs->trans("AmountTTC").''.price($object->total_ttc, 1, '', 1, - 1, - 1, $conf->currency).'
'; + + print ''; + print ''; + print ''; + print ''; + if (!empty($conf->banque->enabled)) { + print ''; + } + print ''; + print ''; + print ''; + + // Payments already done (from payment on this expensereport) + $sql = "SELECT p.rowid, p.num_payment, p.datep as dp, p.amount, p.fk_bank,"; + $sql .= "c.code as p_code, c.libelle as payment_type,"; + $sql .= "ba.rowid as baid, ba.ref as baref, ba.label, ba.number as banumber, ba.account_number, ba.fk_accountancy_journal"; + $sql .= " FROM ".MAIN_DB_PREFIX."expensereport as e, ".MAIN_DB_PREFIX."payment_expensereport as p"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON p.fk_typepayment = c.id"; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON p.fk_bank = b.rowid'; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank_account as ba ON b.fk_account = ba.rowid'; + $sql .= " WHERE e.rowid = '".$id."'"; + $sql .= " AND p.fk_expensereport = e.rowid"; + $sql .= ' AND e.entity IN ('.getEntity('expensereport').')'; + $sql .= " ORDER BY dp"; + + $resql = $db->query($sql); + if ($resql) { + $num = $db->num_rows($resql); + $i = 0; $totalpaid = 0; + while ($i < $num) { + $objp = $db->fetch_object($resql); + + $paymentexpensereportstatic->id = $objp->rowid; + $paymentexpensereportstatic->datepaye = $db->jdate($objp->dp); + $paymentexpensereportstatic->ref = $objp->rowid; + $paymentexpensereportstatic->num_payment = $objp->num_payment; + $paymentexpensereportstatic->payment_code = $objp->payment_code; + + print ''; + print ''; + print '\n"; + $labeltype = $langs->trans("PaymentType".$objp->p_code) != ("PaymentType".$objp->p_code) ? $langs->trans("PaymentType".$objp->p_code) : $objp->payment_type; + print "\n"; + if (!empty($conf->banque->enabled)) { + $bankaccountstatic->id = $objp->baid; + $bankaccountstatic->ref = $objp->baref; + $bankaccountstatic->label = $objp->baref; + $bankaccountstatic->number = $objp->banumber; + + if (!empty($conf->accounting->enabled)) { + $bankaccountstatic->account_number = $objp->account_number; + + $accountingjournal = new AccountingJournal($db); + $accountingjournal->fetch($objp->fk_accountancy_journal); + $bankaccountstatic->accountancy_journal = $accountingjournal->getNomUrl(0, 1, 1, '', 1); + } + + print ''; + } + print '"; + print ''; + print ""; + $totalpaid += $objp->amount; + $i++; + } + if (!is_null($totalpaid)) { + $totalpaid = price2num($totalpaid); // Round $totalpaid to fix floating problem after addition into loop } - print '
'.$langs->trans('Payments').''.$langs->trans('Date').''.$langs->trans('Type').''.$langs->trans('BankAccount').''.$langs->trans('Amount').' 
'; + print $paymentexpensereportstatic->getNomUrl(1); + print ''.dol_print_date($db->jdate($objp->dp), 'day')."".$labeltype.' '.$objp->num_payment."'; + if ($bankaccountstatic->id) { + print $bankaccountstatic->getNomUrl(1, 'transactions'); + } + print ''.price($objp->amount)."
'; + $remaintopay = price2num($object->total_ttc - $totalpaid); + $resteapayeraffiche = $remaintopay; + + $cssforamountpaymentcomplete = 'amountpaymentcomplete'; + + if ($object->status == ExpenseReport::STATUS_REFUSED) { + $cssforamountpaymentcomplete = 'amountpaymentneutral'; + $resteapayeraffiche = 0; + } elseif ($object->paid == 0) { + $cssforamountpaymentcomplete = 'amountpaymentneutral'; + } + print ''; + print ''; + + print ''; + print ''; + + $db->free($resql); + } else { + dol_print_error($db); + } + print "
'.$langs->trans("AlreadyPaid").':'.price($totalpaid).'
'.$langs->trans("AmountExpected").':'.price($object->total_ttc).'
'.$langs->trans("RemainderToPay").':'.price($resteapayeraffiche).'
"; + + print '
'; + print '
'; + print '
'; + + print '

'; + + print '
'; + + $actiontouse = 'updateline'; + if (($object->status == 0 || $object->status == 99) && $action != 'editline') { + $actiontouse = 'addline'; + } + + print '
'; + print ''; + print ''; + print ''; + print ''; + + print '
'; + print ''; + + if (!empty($object->lines)) { + $i = 0; $total = 0; print ''; - print ''; - print ''; - print ''; - if (!empty($conf->banque->enabled)) { - print ''; + print ''; + //print ''; + print ''; + if (!empty($conf->projet->enabled)) { + print ''; + } + print ''; + if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) { + print ''; + } + print ''; + print ''; + print ''; + print ''; + print ''; + if ($action != 'editline') { + print ''; + print ''; + } + // Picture + print ''; + // Ajout des boutons de modification/suppression + if (($object->status < 2 || $object->status == 99) && $user->rights->expensereport->creer) { + print ''; } - print ''; - print ''; print ''; - // Payments already done (from payment on this expensereport) - $sql = "SELECT p.rowid, p.num_payment, p.datep as dp, p.amount, p.fk_bank,"; - $sql .= "c.code as p_code, c.libelle as payment_type,"; - $sql .= "ba.rowid as baid, ba.ref as baref, ba.label, ba.number as banumber, ba.account_number, ba.fk_accountancy_journal"; - $sql .= " FROM ".MAIN_DB_PREFIX."expensereport as e, ".MAIN_DB_PREFIX."payment_expensereport as p"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON p.fk_typepayment = c.id"; - $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON p.fk_bank = b.rowid'; - $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank_account as ba ON b.fk_account = ba.rowid'; - $sql .= " WHERE e.rowid = '".$id."'"; - $sql .= " AND p.fk_expensereport = e.rowid"; - $sql .= ' AND e.entity IN ('.getEntity('expensereport').')'; - $sql .= " ORDER BY dp"; + foreach ($object->lines as &$line) { + $numline = $i + 1; - $resql = $db->query($sql); - if ($resql) { - $num = $db->num_rows($resql); - $i = 0; $totalpaid = 0; - while ($i < $num) { - $objp = $db->fetch_object($resql); + if ($action != 'editline' || $line->rowid != GETPOST('rowid', 'int')) { + print ''; - $paymentexpensereportstatic->id = $objp->rowid; - $paymentexpensereportstatic->datepaye = $db->jdate($objp->dp); - $paymentexpensereportstatic->ref = $objp->rowid; - $paymentexpensereportstatic->num_payment = $objp->num_payment; - $paymentexpensereportstatic->payment_code = $objp->payment_code; - - print ''; - print ''; - print '\n"; - $labeltype = $langs->trans("PaymentType".$objp->p_code) != ("PaymentType".$objp->p_code) ? $langs->trans("PaymentType".$objp->p_code) : $objp->payment_type; - print "\n"; - if (!empty($conf->banque->enabled)) { - $bankaccountstatic->id = $objp->baid; - $bankaccountstatic->ref = $objp->baref; - $bankaccountstatic->label = $objp->baref; - $bankaccountstatic->number = $objp->banumber; - if (!empty($conf->accounting->enabled)) { - $bankaccountstatic->account_number = $objp->account_number; + // Date + print ''; - $accountingjournal = new AccountingJournal($db); - $accountingjournal->fetch($objp->fk_accountancy_journal); - $bankaccountstatic->accountancy_journal = $accountingjournal->getNomUrl(0, 1, 1, '', 1); - } - - print ''; } - print '"; - print ''; - print ""; - $totalpaid += $objp->amount; - $i++; - } - if (!is_null($totalpaid)) { - $totalpaid = price2num($totalpaid); // Round $totalpaid to fix floating problem after addition into loop - } - $remaintopay = price2num($object->total_ttc - $totalpaid); - $resteapayeraffiche = $remaintopay; + // Type of fee + print ''; - $cssforamountpaymentcomplete = 'amountpaymentcomplete'; - - if ($object->status == ExpenseReport::STATUS_REFUSED) { - $cssforamountpaymentcomplete = 'amountpaymentneutral'; - $resteapayeraffiche = 0; - } elseif ($object->paid == 0) { - $cssforamountpaymentcomplete = 'amountpaymentneutral'; - } - print ''; - print ''; - - print ''; - print ''; - - $db->free($resql); - } else { - dol_print_error($db); - } - print "
'.$langs->trans('Payments').''.$langs->trans('Date').''.$langs->trans('Type').''.$langs->trans('BankAccount').''.$langs->trans('LineNb').''.$langs->trans('Piece').''.$langs->trans('Date').''.$langs->trans('Project').''.$langs->trans('Type').''.$langs->trans('CarCategory').''.$langs->trans('Description').''.$langs->trans('VAT').''.$langs->trans('PriceUHT').''.$langs->trans('PriceUTTC').''.$langs->trans('Qty').''.$langs->trans('AmountHT').''.$langs->trans('AmountTTC').''; + print ''.$langs->trans('Amount').' 
'; - print $paymentexpensereportstatic->getNomUrl(1); + // Num + print ''; + print $numline; print ''.dol_print_date($db->jdate($objp->dp), 'day')."".$labeltype.' '.$objp->num_payment."'.dol_print_date($db->jdate($line->date), 'day').''; - if ($bankaccountstatic->id) { - print $bankaccountstatic->getNomUrl(1, 'transactions'); + // Project + if (!empty($conf->projet->enabled)) { + print ''; + if ($line->fk_project > 0) { + $projecttmp->id = $line->fk_project; + $projecttmp->ref = $line->projet_ref; + $projecttmp->title = $line->projet_title; + print $projecttmp->getNomUrl(1); } print ''.price($objp->amount)."
'; + $labeltype = ($langs->trans(($line->type_fees_code)) == $line->type_fees_code ? $line->type_fees_libelle : $langs->trans($line->type_fees_code)); + print $labeltype; + print '
'.$langs->trans("AlreadyPaid").':'.price($totalpaid).'
'.$langs->trans("AmountExpected").':'.price($object->total_ttc).'
'.$langs->trans("RemainderToPay").':'.price($resteapayeraffiche).'
"; - - print '
'; - print '
'; - print '
'; - - print '

'; - - print '
'; - - $actiontouse = 'updateline'; - if (($object->status == 0 || $object->status == 99) && $action != 'editline') { - $actiontouse = 'addline'; - } - - print ''; - print ''; - print ''; - print ''; - print ''; - - print '
'; - print ''; - - if (!empty($object->lines)) { - $i = 0; $total = 0; - - print ''; - print ''; - //print ''; - print ''; - if (!empty($conf->projet->enabled)) { - print ''; - } - print ''; - if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) { - print ''; - } - print ''; - print ''; - print ''; - print ''; - print ''; - if ($action != 'editline') { - print ''; - print ''; - } - // Picture - print ''; - // Ajout des boutons de modification/suppression - if (($object->status < 2 || $object->status == 99) && $user->rights->expensereport->creer) { - print ''; - } - print ''; - - foreach ($object->lines as &$line) { - $numline = $i + 1; - - if ($action != 'editline' || $line->rowid != GETPOST('rowid', 'int')) { - print ''; - - // Num - print ''; + } - // Date - print ''; + // Comment + print ''; + // VAT rate + print ''; + // Unit price HT + print ''; - // Project - if (!empty($conf->projet->enabled)) { - print ''; - } + print ''; - // Type of fee - print ''; + print ''; - // IK - if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) { - print ''; - } + if ($action != 'editline') { + print ''; + print ''; + } - // Comment - print ''; - // VAT rate - print ''; - // Unit price HT - print ''; + // Column with preview + print ''; - - print ''; - - if ($action != 'editline') { - print ''; - print ''; - } - - // Column with preview - print ''; + + // Ajout des boutons de modification/suppression + if (($object->status < ExpenseReport::STATUS_VALIDATED || $object->status == ExpenseReport::STATUS_REFUSED) && $user->rights->expensereport->creer) { + print ''; - - // Ajout des boutons de modification/suppression - if (($object->status < ExpenseReport::STATUS_VALIDATED || $object->status == ExpenseReport::STATUS_REFUSED) && $user->rights->expensereport->creer) { - print ''; - } - - print ''; } - if ($action == 'editline' && $line->rowid == GETPOST('rowid', 'int')) { - // Add line with link to add new file or attach line to an existing file - $colspan = 10; - if (!empty($conf->projet->enabled)) { - $colspan++; - } - if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) { - $colspan++; - } + print ''; + } - print ''; + if ($action == 'editline' && $line->rowid == GETPOST('rowid', 'int')) { + // Add line with link to add new file or attach line to an existing file + $colspan = 10; + if (!empty($conf->projet->enabled)) { + $colspan++; + } + if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) { + $colspan++; + } - print ''; + print ''; - print ''; + + print ''; + print ''."\n"; + print ''; - $filenamelinked = ''; - if ($line->fk_ecm_files > 0) { - $result = $ecmfilesstatic->fetch($line->fk_ecm_files); - if ($result > 0) { - $filenamelinked = $ecmfilesstatic->filename; - } + $filenamelinked = ''; + if ($line->fk_ecm_files > 0) { + $result = $ecmfilesstatic->fetch($line->fk_ecm_files); + if ($result > 0) { + $filenamelinked = $ecmfilesstatic->filename; } - - $tredited = 'tredited'; - include DOL_DOCUMENT_ROOT.'/expensereport/tpl/expensereport_addfile.tpl.php'; - include DOL_DOCUMENT_ROOT.'/expensereport/tpl/expensereport_linktofile.tpl.php'; - - print ''; - - print ''; - - // Select date - print ''; - - // Select project - if (!empty($conf->projet->enabled)) { - print ''; - } - - // Select type - print ''; - - if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) { - print ''; - } - - // Add comments - print ''; - - // VAT - print ''; - - // Unit price - print ''; - - // Unit price with tax - print ''; - - // Quantity - print ''; - - //print ''; - //print ''; - - // Picture - print ''; - - print ''; - - print ''; } - $i++; - } - } + $tredited = 'tredited'; + include DOL_DOCUMENT_ROOT.'/expensereport/tpl/expensereport_addfile.tpl.php'; + include DOL_DOCUMENT_ROOT.'/expensereport/tpl/expensereport_linktofile.tpl.php'; - // Add a new line - if (($object->status == ExpenseReport::STATUS_DRAFT || $object->status == ExpenseReport::STATUS_REFUSED) - && $action != 'editline' - && $user->rights->expensereport->creer) { + print ''; + + print ''; + + // Select date + print ''; + + // Select project + if (!empty($conf->projet->enabled)) { + print ''; + } + + // Select type + print ''; + + if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) { + print ''; + } + + // Add comments + print ''; + + // VAT + print ''; + + // Unit price + print ''; + + // Unit price with tax + print ''; + + // Quantity + print ''; + + //print ''; + //print ''; + + // Picture + print ''; + + print ''; + + print ''; + } + + $i++; + } + } + + // Add a new line + if (($object->status == ExpenseReport::STATUS_DRAFT || $object->status == ExpenseReport::STATUS_REFUSED) + && $action != 'editline' + && $user->rights->expensereport->creer) { $colspan = 11; - if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) { - $colspan++; - } - if (!empty($conf->projet->enabled)) { - $colspan++; - } - if ($action != 'editline') { - $colspan++; - } + if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) { + $colspan++; + } + if (!empty($conf->projet->enabled)) { + $colspan++; + } + if ($action != 'editline') { + $colspan++; + } $nbFiles = $nbLinks = 0; $arrayoffiles = array(); - if (empty($conf->global->EXPENSEREPORT_DISABLE_ATTACHMENT_ON_LINES)) { - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; - require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; - $upload_dir = $conf->expensereport->dir_output."/".dol_sanitizeFileName($object->ref); - $arrayoffiles = dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png|'.preg_quote(dol_sanitizeFileName($object->ref.'.pdf'), '/').')$'); - $nbFiles = count($arrayoffiles); - $nbLinks = Link::count($db, $object->element, $object->id); - } + if (empty($conf->global->EXPENSEREPORT_DISABLE_ATTACHMENT_ON_LINES)) { + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; + $upload_dir = $conf->expensereport->dir_output."/".dol_sanitizeFileName($object->ref); + $arrayoffiles = dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png|'.preg_quote(dol_sanitizeFileName($object->ref.'.pdf'), '/').')$'); + $nbFiles = count($arrayoffiles); + $nbLinks = Link::count($db, $object->element, $object->id); + } // Add line with link to add new file or attach to an existing file print ''; @@ -2334,11 +2333,11 @@ if ($action == 'create') { print ''.$langs->trans("UploadANewFileNow"); print img_picto($langs->trans("UploadANewFileNow"), 'chevron-down', '', false, 0, 0, '', 'marginleftonly'); print ''; - if (empty($conf->global->EXPENSEREPORT_DISABLE_ATTACHMENT_ON_LINES)) { - print '   -   '.$langs->trans("AttachTheNewLineToTheDocument"); - print img_picto($langs->trans("AttachTheNewLineToTheDocument"), 'chevron-down', '', false, 0, 0, '', 'marginleftonly'); - print ''; - } + if (empty($conf->global->EXPENSEREPORT_DISABLE_ATTACHMENT_ON_LINES)) { + print '   -   '.$langs->trans("AttachTheNewLineToTheDocument"); + print img_picto($langs->trans("AttachTheNewLineToTheDocument"), 'chevron-down', '', false, 0, 0, '', 'marginleftonly'); + print ''; + } print ''."\n"; print ''."\n"; print ''; - include DOL_DOCUMENT_ROOT.'/expensereport/tpl/expensereport_addfile.tpl.php'; include DOL_DOCUMENT_ROOT.'/expensereport/tpl/expensereport_linktofile.tpl.php'; + include DOL_DOCUMENT_ROOT.'/expensereport/tpl/expensereport_addfile.tpl.php'; print ''; print ''; print ''; - if (!empty($conf->projet->enabled)) { - print ''; - } + if (!empty($conf->projet->enabled)) { + print ''; + } print ''; - if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) { - print ''; - } + if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) { + print ''; + } print ''; print ''; print ''; @@ -2415,23 +2414,23 @@ if ($action == 'create') { print ''; // Select project - if (!empty($conf->projet->enabled)) { - print ''; - } + if (!empty($conf->projet->enabled)) { + print ''; + } // Select type print ''; - if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) { - print ''; - } + if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) { + print ''; + } // Add comments print ''; @@ -2465,15 +2464,15 @@ if ($action == 'create') { // Picture print ''; - if ($action != 'editline') { - print ''; - print ''; - } + if ($action != 'editline') { + print ''; + print ''; + } print ''; print ''; - } // Fin si c'est payé/validé + } // Fin si c'est payé/validé print '
'.$langs->trans('LineNb').''.$langs->trans('Piece').''.$langs->trans('Date').''.$langs->trans('Project').''.$langs->trans('Type').''.$langs->trans('CarCategory').''.$langs->trans('Description').''.$langs->trans('VAT').''.$langs->trans('PriceUHT').''.$langs->trans('PriceUTTC').''.$langs->trans('Qty').''.$langs->trans('AmountHT').''.$langs->trans('AmountTTC').''; - print '
'; - print $numline; + // IK + if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) { + print ''; + print dol_getIdFromCode($db, $line->fk_c_exp_tax_cat, 'c_exp_tax_cat', 'rowid', 'label'); print ''.dol_print_date($db->jdate($line->date), 'day').''.dol_nl2br($line->comments).''.vatrate($line->vatrate, true).''; + if (!empty($line->value_unit_ht)) { + print price($line->value_unit_ht); + } else { + $tmpvat = price2num(preg_replace('/\s*\(.*\)/', '', $line->vatrate)); + $pricenettoshow = price2num($line->value_unit / (1 + $tmpvat / 100), 'MU'); + print $pricenettoshow; + } + print ''; - if ($line->fk_project > 0) { - $projecttmp->id = $line->fk_project; - $projecttmp->ref = $line->projet_ref; - $projecttmp->title = $line->projet_title; - print $projecttmp->getNomUrl(1); - } - print ''.price($line->value_unit).''; - $labeltype = ($langs->trans(($line->type_fees_code)) == $line->type_fees_code ? $line->type_fees_libelle : $langs->trans($line->type_fees_code)); - print $labeltype; - print ''.dol_escape_htmltag($line->qty).''; - print dol_getIdFromCode($db, $line->fk_c_exp_tax_cat, 'c_exp_tax_cat', 'rowid', 'label'); - print ''.price($line->total_ht).''.price($line->total_ttc).''.dol_nl2br($line->comments).''.vatrate($line->vatrate, true).''; - if (!empty($line->value_unit_ht)) { - print price($line->value_unit_ht); - } else { - $tmpvat = price2num(preg_replace('/\s*\(.*\)/', '', $line->vatrate)); - $pricenettoshow = price2num($line->value_unit / (1 + $tmpvat / 100), 'MU'); - print $pricenettoshow; - } - print ''; + if ($line->fk_ecm_files > 0) { + $modulepart = 'expensereport'; + $maxheightmini = 32; - print ''.price($line->value_unit).''.dol_escape_htmltag($line->qty).''.price($line->total_ht).''.price($line->total_ttc).''; - if ($line->fk_ecm_files > 0) { - $modulepart = 'expensereport'; - $maxheightmini = 32; - - $result = $ecmfilesstatic->fetch($line->fk_ecm_files); - if ($result > 0) { - $relativepath = preg_replace('/expensereport\//', '', $ecmfilesstatic->filepath); - $fileinfo = pathinfo($ecmfilesstatic->filepath.'/'.$ecmfilesstatic->filename); - if (image_format_supported($fileinfo['basename']) > 0) { - $minifile = getImageFileNameForSize($fileinfo['basename'], '_mini'); // For new thumbs using same ext (in lower case howerver) than original - if (!dol_is_file($conf->expensereport->dir_output.'/'.$relativepath.'/'.$minifile)) { - $minifile = getImageFileNameForSize($fileinfo['basename'], '_mini', '.png'); // For backward compatibility of old thumbs that were created with filename in lower case and with .png extension - } - //print $file['path'].'/'.$minifile.'
'; - $urlforhref = getAdvancedPreviewUrl($modulepart, $relativepath.'/'.$fileinfo['filename'].'.'.strtolower($fileinfo['extension']), 1, '&entity='.(!empty($object->entity) ? $object->entity : $conf->entity)); - if (empty($urlforhref)) { - $urlforhref = DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.(!empty($object->entity) ? $object->entity : $conf->entity).'&file='.urlencode($relativepath.$fileinfo['filename'].'.'.strtolower($fileinfo['extension'])); - print ''; - } else { - print ''; - } - print ''; - print ''; + $result = $ecmfilesstatic->fetch($line->fk_ecm_files); + if ($result > 0) { + $relativepath = preg_replace('/expensereport\//', '', $ecmfilesstatic->filepath); + $fileinfo = pathinfo($ecmfilesstatic->filepath.'/'.$ecmfilesstatic->filename); + if (image_format_supported($fileinfo['basename']) > 0) { + $minifile = getImageFileNameForSize($fileinfo['basename'], '_mini'); // For new thumbs using same ext (in lower case howerver) than original + if (!dol_is_file($conf->expensereport->dir_output.'/'.$relativepath.'/'.$minifile)) { + $minifile = getImageFileNameForSize($fileinfo['basename'], '_mini', '.png'); // For backward compatibility of old thumbs that were created with filename in lower case and with .png extension + } + //print $file['path'].'/'.$minifile.'
'; + $urlforhref = getAdvancedPreviewUrl($modulepart, $relativepath.'/'.$fileinfo['filename'].'.'.strtolower($fileinfo['extension']), 1, '&entity='.(!empty($object->entity) ? $object->entity : $conf->entity)); + if (empty($urlforhref)) { + $urlforhref = DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.(!empty($object->entity) ? $object->entity : $conf->entity).'&file='.urlencode($relativepath.$fileinfo['filename'].'.'.strtolower($fileinfo['extension'])); + print ''; } else { - $modulepart = 'expensereport'; - $thumbshown = 0; - if (preg_match('/\.pdf$/i', $ecmfilesstatic->filename)) { - $filepdf = $conf->expensereport->dir_output.'/'.$relativepath.'/'.$ecmfilesstatic->filename; - $fileimage = $conf->expensereport->dir_output.'/'.$relativepath.'/'.$ecmfilesstatic->filename.'_preview.png'; - $relativepathimage = $relativepath.'/'.$ecmfilesstatic->filename.'_preview.png'; + print ''; + } + print ''; + print ''; + } else { + $modulepart = 'expensereport'; + $thumbshown = 0; + if (preg_match('/\.pdf$/i', $ecmfilesstatic->filename)) { + $filepdf = $conf->expensereport->dir_output.'/'.$relativepath.'/'.$ecmfilesstatic->filename; + $fileimage = $conf->expensereport->dir_output.'/'.$relativepath.'/'.$ecmfilesstatic->filename.'_preview.png'; + $relativepathimage = $relativepath.'/'.$ecmfilesstatic->filename.'_preview.png'; - $pdfexists = file_exists($filepdf); - if ($pdfexists) { - // Conversion du PDF en image png si fichier png non existant - if (!file_exists($fileimage) || (filemtime($fileimage) < filemtime($filepdf))) { - if (empty($conf->global->MAIN_DISABLE_PDF_THUMBS)) { // If you experience trouble with pdf thumb generation and imagick, you can disable here. - include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - $ret = dol_convert_file($filepdf, 'png', $fileimage, '0'); // Convert first page of PDF into a file _preview.png - if ($ret < 0) { - $error++; - } + $pdfexists = file_exists($filepdf); + if ($pdfexists) { + // Conversion du PDF en image png si fichier png non existant + if (!file_exists($fileimage) || (filemtime($fileimage) < filemtime($filepdf))) { + if (empty($conf->global->MAIN_DISABLE_PDF_THUMBS)) { // If you experience trouble with pdf thumb generation and imagick, you can disable here. + include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + $ret = dol_convert_file($filepdf, 'png', $fileimage, '0'); // Convert first page of PDF into a file _preview.png + if ($ret < 0) { + $error++; } } } + } - if ($pdfexists && !$error) { - $heightforphotref = 70; - if (!empty($conf->dol_optimize_smallscreen)) { - $heightforphotref = 60; - } - // If the preview file is found - if (file_exists($fileimage)) { - $thumbshown = 1; - print ''; - } + if ($pdfexists && !$error) { + $heightforphotref = 70; + if (!empty($conf->dol_optimize_smallscreen)) { + $heightforphotref = 60; + } + // If the preview file is found + if (file_exists($fileimage)) { + $thumbshown = 1; + print ''; } } + } - if (!$thumbshown) { - print img_mime($ecmfilesstatic->filename); - } + if (!$thumbshown) { + print img_mime($ecmfilesstatic->filename); } } } + } + print '
'; + + print 'rowid.'">'; + print img_edit(); + print '   '; + print 'rowid.'">'; + print img_delete(); + print ''; + print ''; - - print 'rowid.'">'; - print img_edit(); - print '   '; - print 'rowid.'">'; - print img_delete(); - print ''; - - print '
'; - print $numline; - print '
'; - print ''.$langs->trans("UploadANewFileNow"); - print img_picto($langs->trans("UploadANewFileNow"), 'chevron-down', '', false, 0, 0, '', 'marginleftonly'); + print ''; + print $numline; + print ''; + print ''.$langs->trans("UploadANewFileNow"); + print img_picto($langs->trans("UploadANewFileNow"), 'chevron-down', '', false, 0, 0, '', 'marginleftonly'); + print ''; + if (empty($conf->global->EXPENSEREPORT_DISABLE_ATTACHMENT_ON_LINES)) { + print '   -   '.$langs->trans("AttachTheNewLineToTheDocument"); + print img_picto($langs->trans("AttachTheNewLineToTheDocument"), 'chevron-down', '', false, 0, 0, '', 'marginleftonly'); print ''; - if (empty($conf->global->EXPENSEREPORT_DISABLE_ATTACHMENT_ON_LINES)) { - print '   -   '.$langs->trans("AttachTheNewLineToTheDocument"); - print img_picto($langs->trans("AttachTheNewLineToTheDocument"), 'chevron-down', '', false, 0, 0, '', 'marginleftonly'); - print ''; - } + } - print ''."\n"; - print ''."\n"; - print '
'; - print $form->selectDate($line->date, 'date'); - print ''; - $formproject->select_projects(-1, $line->fk_project, 'fk_project', 0, 0, 1, 1, 0, 0, 0, '', 0, 0, 'maxwidth300'); - print ''; - print $formexpensereport->selectTypeExpenseReport($line->fk_c_type_fees, 'fk_c_type_fees'); - print ''; - $params = array('fk_expense' => $object->id, 'fk_expense_det' => $line->rowid, 'date' => $line->dates); - print $form->selectExpenseCategories($line->fk_c_exp_tax_cat, 'fk_c_exp_tax_cat', 1, array(), 'fk_c_type_fees', $userauthor->default_c_exp_tax_cat, $params); - print ''; - print ''; - print ''; - print $form->load_tva('vatrate', (GETPOSTISSET("vatrate") ? GETPOST("vatrate") : $line->vatrate), $mysoc, '', 0, 0, '', false, 1); - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''.$langs->trans('AmountHT').''.$langs->trans('AmountTTC').''; - //print $line->fk_ecm_files; - print ''; - print ''; - print ''; - print '
'; - print '
'; + print $form->selectDate($line->date, 'date'); + print ''; + $formproject->select_projects(-1, $line->fk_project, 'fk_project', 0, 0, 1, 1, 0, 0, 0, '', 0, 0, 'maxwidth300'); + print ''; + print $formexpensereport->selectTypeExpenseReport($line->fk_c_type_fees, 'fk_c_type_fees'); + print ''; + $params = array('fk_expense' => $object->id, 'fk_expense_det' => $line->rowid, 'date' => $line->dates); + print $form->selectExpenseCategories($line->fk_c_exp_tax_cat, 'fk_c_exp_tax_cat', 1, array(), 'fk_c_type_fees', $userauthor->default_c_exp_tax_cat, $params); + print ''; + print ''; + print ''; + print $form->load_tva('vatrate', (GETPOSTISSET("vatrate") ? GETPOST("vatrate") : $line->vatrate), $mysoc, '', 0, 0, '', false, 1); + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''.$langs->trans('AmountHT').''.$langs->trans('AmountTTC').''; + //print $line->fk_ecm_files; + print ''; + print ''; + print ''; + print '
'; + print '
'.$langs->trans('Date').''.$form->textwithpicto($langs->trans('Project'), $langs->trans("ClosedProjectsAreHidden")).''.$form->textwithpicto($langs->trans('Project'), $langs->trans("ClosedProjectsAreHidden")).''.$langs->trans('Type').''.$langs->trans('CarCategory').''.$langs->trans('CarCategory').''.$langs->trans('Description').''.$langs->trans('VAT').''.$langs->trans('PriceUHT').''; - $formproject->select_projects(-1, $fk_project, 'fk_project', 0, 0, 1, -1, 0, 0, 0, '', 0, 0, 'maxwidth300'); - print ''; + $formproject->select_projects(-1, $fk_project, 'fk_project', 0, 0, 1, -1, 0, 0, 0, '', 0, 0, 'maxwidth300'); + print ''; print $formexpensereport->selectTypeExpenseReport($fk_c_type_fees, 'fk_c_type_fees', 1); print ''; - $params = array('fk_expense' => $object->id); - print $form->selectExpenseCategories('', 'fk_c_exp_tax_cat', 1, array(), 'fk_c_type_fees', $userauthor->default_c_exp_tax_cat, $params, 0); - print ''; + $params = array('fk_expense' => $object->id); + print $form->selectExpenseCategories('', 'fk_c_exp_tax_cat', 1, array(), 'fk_c_type_fees', $userauthor->default_c_exp_tax_cat, $params, 0); + print ''; @@ -2441,9 +2440,9 @@ if ($action == 'create') { // Select VAT print ''; $defaultvat = -1; - if (!empty($conf->global->EXPENSEREPORT_NO_DEFAULT_VAT)) { - $conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS = 'none'; - } + if (!empty($conf->global->EXPENSEREPORT_NO_DEFAULT_VAT)) { + $conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS = 'none'; + } print $form->load_tva('vatrate', ($vatrate != '' ? $vatrate : $defaultvat), $mysoc, '', 0, 0, '', false, 1); print '
'; print '
'; @@ -2501,11 +2500,15 @@ if ($action == 'create') { print ''; print dol_get_fiche_end(); - } - } else { - dol_print_error($db); } + } else { + dol_print_error($db); } +} else { + print 'Record not found'; + + llxFooter(); + exit(1); } /* diff --git a/htdocs/expensereport/tpl/expensereport_linktofile.tpl.php b/htdocs/expensereport/tpl/expensereport_linktofile.tpl.php index 640f4c17b5d..42be03263a8 100644 --- a/htdocs/expensereport/tpl/expensereport_linktofile.tpl.php +++ b/htdocs/expensereport/tpl/expensereport_linktofile.tpl.php @@ -18,6 +18,7 @@ if (empty($conf->global->EXPENSEREPORT_DISABLE_ATTACHMENT_ON_LINES)) { $modulepart = 'expensereport'; $maxheightmini = 48; $relativepath = (!empty($object->ref) ?dol_sanitizeFileName($object->ref) : '').'/'; $filei = 0; + // Loop on each attached file foreach ($arrayoffiles as $file) { $urlforhref = array(); $filei++; @@ -77,7 +78,7 @@ if (empty($conf->global->EXPENSEREPORT_DISABLE_ATTACHMENT_ON_LINES)) { } if (empty($urlforhref) || empty($thumbshown)) { - print ''; + print ''; } else { print ''; } @@ -85,7 +86,12 @@ if (empty($conf->global->EXPENSEREPORT_DISABLE_ATTACHMENT_ON_LINES)) { print $thumbshown ? $thumbshown : img_mime($minifile); - print '
'; + print '
'; + if (empty($urlforhref) || empty($thumbshown)) { + print ''; + } else { + print ''; + } } print '
'; $checked = ''; @@ -106,7 +112,7 @@ if (empty($conf->global->EXPENSEREPORT_DISABLE_ATTACHMENT_ON_LINES)) { if (!empty($filenamelinked) && $filenamelinked == $file['relativename']) { $checked = ' checked'; } - print '
'; + print '
'; print ''; print '
';