* * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ /** * \file htdocs/expensereport/payment/card.php * \ingroup Expense Report * \brief Tab payment of an expense report */ // Load Dolibarr environment require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; require_once DOL_DOCUMENT_ROOT.'/expensereport/class/paymentexpensereport.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/modules/expensereport/modules_expensereport.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/expensereport.lib.php'; if (isModEnabled("banque")) { require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; } // Load translation files required by the page $langs->loadLangs(array('bills', 'banks', 'companies', 'trips')); $id = GETPOST('rowid') ?GETPOST('rowid', 'int') : GETPOST('id', 'int'); $action = GETPOST('action', 'aZ09'); $confirm = GETPOST('confirm'); // Security check if ($user->socid) { $socid = $user->socid; } // TODO Add rule to restrict access payment //$result = restrictedArea($user, 'facture', $id,''); $object = new PaymentExpenseReport($db); if ($id > 0) { $result = $object->fetch($id); if (!$result) { dol_print_error($db, 'Failed to get payment id '.$id); } } /* * Actions */ // Delete payment if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->expensereport->supprimer) { $db->begin(); $result = $object->delete($user); if ($result > 0) { $db->commit(); header("Location: ".DOL_URL_ROOT."/expensereport/index.php"); exit; } else { setEventMessages($object->error, $object->errors, 'errors'); $db->rollback(); } } /* * View */ llxHeader('', $langs->trans("ExpenseReportPayment")); $form = new Form($db); $head = payment_expensereport_prepare_head($object); print dol_get_fiche_head($head, 'payment', $langs->trans("ExpenseReportPayment"), -1, 'payment'); /* * Confirm deleting of the payment */ if ($action == 'delete') { print $form->formconfirm('card.php?id='.$object->id, $langs->trans("DeletePayment"), $langs->trans("ConfirmDeletePayment"), 'confirm_delete', '', 0, 2); } $linkback = ''; // $linkback = '' . $langs->trans("BackToList") . ''; dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', ''); print '
'; print '
'; print ''."\n"; // Date payment print ''; // Mode print ''; // Number print ''; // Amount print ''; // Note public print ''; $disable_delete = 0; // Bank account if (isModEnabled("banque")) { if ($object->bank_account) { $bankline = new AccountLine($db); $bankline->fetch($object->bank_line); if ($bankline->rappro) { $disable_delete = 1; $title_button = dol_escape_htmltag($langs->transnoentitiesnoconv("CantRemoveConciliatedPayment")); } print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; } } print '
'.$langs->trans('Date').''.dol_print_date($object->datep, 'day').'
'.$langs->trans('PaymentMode').''.$langs->trans("PaymentType".$object->type_code).'
'.$langs->trans('Numero').''.$object->num_payment.'
'.$langs->trans('Amount').''.price($object->amount, 0, $outputlangs, 1, -1, -1, $conf->currency).'
'.$langs->trans('Note').''.nl2br($object->note_public).'
'.$langs->trans('BankTransactionLine').''; print $bankline->getNomUrl(1, 0, 'showconciliated'); print '
'.$langs->trans('BankAccount').''; $accountstatic = new Account($db); $accountstatic->fetch($bankline->fk_account); print $accountstatic->getNomUrl(1); print '
'; print '
'; print dol_get_fiche_end(); /* * List of expense report paid */ $sql = 'SELECT er.rowid as eid, er.paid, er.total_ttc, per.amount'; $sql .= ' FROM '.MAIN_DB_PREFIX.'payment_expensereport as per,'.MAIN_DB_PREFIX.'expensereport as er'; $sql .= ' WHERE per.fk_expensereport = er.rowid'; $sql .= ' AND er.entity IN ('.getEntity('expensereport').')'; $sql .= ' AND per.rowid = '.((int) $id); dol_syslog("expensereport/payment/card.php", LOG_DEBUG); $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); $i = 0; $total = 0; print '
'; print '
'; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print "\n"; if ($num > 0) { while ($i < $num) { $objp = $db->fetch_object($resql); print ''; $expensereport = new ExpenseReport($db); $expensereport->fetch($objp->eid); // Expense report print '\n"; // Expected to pay print ''; // Amount paid print ''; // Remain to pay print ''; // Status print ''; print "\n"; if ($objp->paid == 1) { // If at least one invoice is paid, disable delete $disable_delete = 2; $title_button = $langs->trans("CantRemovePaymentWithOneInvoicePaid"); } $total = $total + $objp->amount; $i++; } } print "
'.$langs->trans('ExpenseReport').''.$langs->trans('ExpectedToPay').''.$langs->trans('PayedByThisPayment').''.$langs->trans('RemainderToPay').''.$langs->trans('Status').'
'; print $expensereport->getNomUrl(1); print "'.price($objp->total_ttc).''.price($objp->amount).''.price($objp->total_ttc - $objp->amount).''.$expensereport->getLibStatut(4).'
\n"; print '
'; $db->free($resql); } else { dol_print_error($db); } /* * Actions buttons */ print '
'; // Delete if ($action == '') { if ($user->rights->expensereport->supprimer) { if (!$disable_delete) { print dolGetButtonAction($langs->trans("Delete"), '', 'delete', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken(), 'delete', 1); } else { print dolGetButtonAction($title_button, $langs->trans("Delete"), 'delete', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken(), 'delete', 0); } } } print '
'; // End of page llxFooter(); $db->close();