';
- 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.=' ';
+ } 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 '| '.$langs->trans("User").' | ';
+ print '';
+ 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 ' | ';
+
+ // Period
+ print '';
+ print '| '.$langs->trans("Period").' | ';
+ print '';
+ print get_date_range($object->date_debut, $object->date_fin, 'day', $langs, 0);
+ print ' | ';
+ print ' ';
+ if (!empty($conf->global->EXPENSEREPORT_ASK_PAYMENTMODE_ON_CREATION)) {
+ print '';
+ print '| '.$langs->trans("ModePaiement").' | ';
+ print ''.$object->fk_c_paiement.' | ';
+ print ' ';
+ }
+
+ // Validation date
+ print '';
+ print '| '.$langs->trans("DATE_SAVE").' | ';
+ print ''.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 ' | ';
+ print '';
+
+ // User to inform for approval
+ if ($object->status <= ExpenseReport::STATUS_VALIDATED) { // informed
+ print '';
+ print '| '.$langs->trans("VALIDATOR").' | '; // approver
+ print '';
+ if ($object->fk_user_validator > 0) {
$userfee = new User($db);
- $userfee->fetch($object->fk_user_valid);
- print $userfee->getNomUrl(-1);
- print ' | ';
- }
-
- if ($object->status == 6) {
- print '';
- print '| '.$langs->trans("AUTHORPAIEMENT").' | ';
- print '';
- $userfee = new User($db);
- $userfee->fetch($user->id);
- print $userfee->getNomUrl(-1);
- print ' | ';
- }
-
- // Other attributes
- //$cols = 3;
- //include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_edit.tpl.php';
-
- 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.=' ';
- } 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 '| '.$langs->trans("User").' | ';
- print '';
- 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 ' | ';
-
- // Period
- print '';
- print '| '.$langs->trans("Period").' | ';
- print '';
- print get_date_range($object->date_debut, $object->date_fin, 'day', $langs, 0);
- print ' | ';
- print ' ';
- if (!empty($conf->global->EXPENSEREPORT_ASK_PAYMENTMODE_ON_CREATION)) {
- print '';
- print '| '.$langs->trans("ModePaiement").' | ';
- print ''.$object->fk_c_paiement.' | ';
- print ' ';
- }
-
- // Validation date
- print '';
- print '| '.$langs->trans("DATE_SAVE").' | ';
- print ''.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 ' | ';
- print '';
-
- // User to inform for approval
- if ($object->status <= ExpenseReport::STATUS_VALIDATED) { // informed
- print '';
- print '| '.$langs->trans("VALIDATOR").' | '; // approver
- print '';
- 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 ' | ';
- } elseif ($object->status == ExpenseReport::STATUS_CANCELED) {
- print '';
- print '| '.$langs->trans("CANCEL_USER").' | ';
- print '';
- 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 ' | ';
-
- print '';
- print '| '.$langs->trans("MOTIF_CANCEL").' | ';
- print ''.$object->detail_cancel.' | ';
- print '';
- print '';
- print '| '.$langs->trans("DATE_CANCEL").' | ';
- print ''.dol_print_date($object->date_cancel, 'dayhour', 'tzuser').' | ';
- print '';
- } else {
- print '';
- print '| '.$langs->trans("ApprovedBy").' | ';
- print '';
- 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 ' | ';
-
- print '';
- print '| '.$langs->trans("DateApprove").' | ';
- print ''.dol_print_date($object->date_approve, 'dayhour', 'tzuser').' | ';
- print '';
- }
-
- if ($object->status == 99 || !empty($object->detail_refuse)) {
- print '';
- print '| '.$langs->trans("REFUSEUR").' | ';
- print '';
- $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 ' | ';
-
- print '';
- print '| '.$langs->trans("DATE_REFUS").' | ';
- print ''.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 ' | ';
- print ' ';
}
+ print '';
+ } elseif ($object->status == ExpenseReport::STATUS_CANCELED) {
+ print '';
+ print '| '.$langs->trans("CANCEL_USER").' | ';
+ print '';
+ 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 ' | ';
- if ($object->status == $object::STATUS_CLOSED) {
- /* TODO this fields are not yet filled
- print '';
- print '| '.$langs->trans("AUTHORPAIEMENT").' | ';
- print '';
- $userfee=new User($db);
- $userfee->fetch($object->fk_user_paid);
+ print ' | ';
+ print '| '.$langs->trans("MOTIF_CANCEL").' | ';
+ print ''.$object->detail_cancel.' | ';
+ print '';
+ print '';
+ print '| '.$langs->trans("DATE_CANCEL").' | ';
+ print ''.dol_print_date($object->date_cancel, 'dayhour', 'tzuser').' | ';
+ print '';
+ } else {
+ print '';
+ print '| '.$langs->trans("ApprovedBy").' | ';
+ print '';
+ 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 ' | ';
+
+ print '';
+ print '| '.$langs->trans("DateApprove").' | ';
+ print ''.dol_print_date($object->date_approve, 'dayhour', 'tzuser').' | ';
+ print '';
+ }
+
+ if ($object->status == 99 || !empty($object->detail_refuse)) {
+ print '';
+ print '| '.$langs->trans("REFUSEUR").' | ';
+ print '';
+ $userfee = new User($db);
+ $result = $userfee->fetch($object->fk_user_refuse);
+ if ($result > 0) {
print $userfee->getNomUrl(-1);
- print ' | ';
- print '';
- print '| '.$langs->trans("DATE_PAIEMENT").' | ';
- print ''.$object->date_paiement.' | ';
- print '';
- */
}
-
- // Other attributes
- $cols = 2;
- include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
-
- print ' ';
-
- print ' ';
- print ' ';
- print ' ';
- print ' ';
-
- print ' ';
-
- // Amount
- print '';
- print '| '.$langs->trans("AmountHT").' | ';
- print ''.price($object->total_ht, 1, '', 1, - 1, - 1, $conf->currency).' | ';
- $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 '| '.$langs->trans("AmountVAT").' | ';
- print ''.price($object->total_tva, 1, '', 1, - 1, - 1, $conf->currency).' | ';
+ print ''.$langs->trans("DATE_REFUS").' | ';
+ print ''.dol_print_date($object->date_refuse, 'dayhour', 'tzuser');
+ if ($object->detail_refuse) {
+ print ' - '.$object->detail_refuse;
+ }
+ print ' | ';
print ' ';
+ }
- print '';
- print '| '.$langs->trans("AmountTTC").' | ';
- print ''.price($object->total_ttc, 1, '', 1, - 1, - 1, $conf->currency).' | ';
- print ' ';
+ if ($object->status == $object::STATUS_CLOSED) {
+ /* TODO this fields are not yet filled
+ print '';
+ print '| '.$langs->trans("AUTHORPAIEMENT").' | ';
+ print '';
+ $userfee=new User($db);
+ $userfee->fetch($object->fk_user_paid);
+ print $userfee->getNomUrl(-1);
+ print ' | ';
+ print '';
+ print '| '.$langs->trans("DATE_PAIEMENT").' | ';
+ print ''.$object->date_paiement.' | ';
+ 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 ' ';
+
+ print ' ';
+ print ' ';
+ print ' ';
+ print ' ';
+
+ print ' ';
+
+ // Amount
+ print '';
+ print '| '.$langs->trans("AmountHT").' | ';
+ print ''.price($object->total_ht, 1, '', 1, - 1, - 1, $conf->currency).' | ';
+ $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 '| '.$langs->trans("AmountVAT").' | ';
+ print ''.price($object->total_tva, 1, '', 1, - 1, - 1, $conf->currency).' | ';
+ print ' ';
+
+ print '';
+ print '| '.$langs->trans("AmountTTC").' | ';
+ print ''.price($object->total_ttc, 1, '', 1, - 1, - 1, $conf->currency).' | ';
+ print ' ';
+
+ // List of payments already done
+ $nbcols = 3;
+ if (!empty($conf->banque->enabled)) {
+ $nbrows++;
+ $nbcols++;
+ }
+
+ print '';
+
+ print '';
+ print '| '.$langs->trans('Payments').' | ';
+ print ''.$langs->trans('Date').' | ';
+ print ''.$langs->trans('Type').' | ';
+ if (!empty($conf->banque->enabled)) {
+ print ''.$langs->trans('BankAccount').' | ';
+ }
+ print ''.$langs->trans('Amount').' | ';
+ 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 $paymentexpensereportstatic->getNomUrl(1);
+ print ' | ';
+ print ''.dol_print_date($db->jdate($objp->dp), 'day')." | \n";
+ $labeltype = $langs->trans("PaymentType".$objp->p_code) != ("PaymentType".$objp->p_code) ? $langs->trans("PaymentType".$objp->p_code) : $objp->payment_type;
+ print "".$labeltype.' '.$objp->num_payment." | \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 '';
+ if ($bankaccountstatic->id) {
+ print $bankaccountstatic->getNomUrl(1, 'transactions');
+ }
+ print ' | ';
+ }
+ print ''.price($objp->amount)." | ";
+ print ' | ';
+ print " ";
+ $totalpaid += $objp->amount;
+ $i++;
+ }
+ if (!is_null($totalpaid)) {
+ $totalpaid = price2num($totalpaid); // Round $totalpaid to fix floating problem after addition into loop
}
- print '';
+ $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 '| '.$langs->trans("AlreadyPaid").': | '.price($totalpaid).' | | ';
+ print '| '.$langs->trans("AmountExpected").': | '.price($object->total_ttc).' | | ';
+
+ print '| '.$langs->trans("RemainderToPay").': | ';
+ print ''.price($resteapayeraffiche).' | | ';
+
+ $db->free($resql);
+ } else {
+ dol_print_error($db);
+ }
+ print " ";
+
+ print '';
+ print '';
+ print '';
+
+ print ' ';
+
+ print '';
+
+ $actiontouse = 'updateline';
+ if (($object->status == 0 || $object->status == 99) && $action != 'editline') {
+ $actiontouse = 'addline';
+ }
+
+ 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 ' |