30 require
'../../main.inc.php';
31 require_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
32 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
33 require_once DOL_DOCUMENT_ROOT.
'/core/modules/facture/modules_facture.php';
34 require_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
35 if (!empty($conf->banque->enabled)) require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
38 $langs->loadLangs(array(
'bills',
'banks',
'companies'));
42 $action =
GETPOST(
'action',
'aZ09');
43 $confirm =
GETPOST(
'confirm',
'alpha');
44 $backtopage =
GETPOST(
'backtopage',
'alpha');
49 include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
51 $result =
restrictedArea($user, $object->element, $object->id,
'paiement',
'');
54 if ($user->socid) $socid = $user->socid;
57 if ($socid && $socid != $object->thirdparty->id) {
66 if ($action ==
'setnote' && $user->rights->facture->paiement)
70 $result = $object->update_note(
GETPOST(
'note',
'restricthtml'));
81 if ($action ==
'confirm_delete' && $confirm ==
'yes' && $user->rights->facture->paiement)
85 $result = $object->delete();
92 header(
"Location: ".$backtopage);
95 header(
"Location: list.php");
99 $langs->load(
"errors");
105 if ($action ==
'confirm_validate' && $confirm ==
'yes' && $user->rights->facture->paiement)
109 if ($object->validate($user) > 0)
115 foreach ($factures as $id)
120 $outputlangs = $langs;
121 if (!empty($_REQUEST[
'lang_id']))
124 $outputlangs->setDefaultLang($_REQUEST[
'lang_id']);
126 if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
127 $fac->generateDocument($fac->modelpdf, $outputlangs);
131 header(
'Location: '.
$_SERVER[
'PHP_SELF'].
'?id='.$object->id);
134 $langs->load(
"errors");
140 if ($action ==
'setnum_paiement' && !empty($_POST[
'num_paiement']))
142 $res = $object->update_num($_POST[
'num_paiement']);
145 setEventMessages($langs->trans(
'PaymentNumberUpdateSucceeded'), null,
'mesgs');
147 setEventMessages($langs->trans(
'PaymentNumberUpdateFailed'), null,
'errors');
151 if ($action ==
'setdatep' && !empty($_POST[
'datepday']))
153 $datepaye =
dol_mktime(
GETPOST(
'datephour',
'int'),
GETPOST(
'datepmin',
'int'),
GETPOST(
'datepsec',
'int'),
GETPOST(
'datepmonth',
'int'),
GETPOST(
'datepday',
'int'),
GETPOST(
'datepyear',
'int'));
154 $res = $object->update_date($datepaye);
157 setEventMessages($langs->trans(
'PaymentDateUpdateSucceeded'), null,
'mesgs');
170 $thirdpartystatic =
new Societe($db);
172 $result = $object->fetch($id, $ref);
179 $form =
new Form($db);
181 $head = payment_prepare_head($object);
186 if ($action ==
'delete')
188 print $form->formconfirm(
$_SERVER[
'PHP_SELF'].
'?id='.$object->id, $langs->trans(
"DeletePayment"), $langs->trans(
"ConfirmDeletePayment"),
'confirm_delete',
'', 0, 2);
192 if ($action ==
'valide')
194 $facid = $_GET[
'facid'];
195 print $form->formconfirm(
$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&facid='.$facid, $langs->trans(
"ValidatePayment"), $langs->trans(
"ConfirmValidatePayment"),
'confirm_validate',
'', 0, 2);
198 $linkback =
'<a href="'.DOL_URL_ROOT.
'/compta/paiement/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
203 print '<div class="fichecenter">';
204 print '<div class="underbanner clearboth"></div>';
206 print '<table class="border centpercent">'.
"\n";
209 print '<tr><td class="titlefield">'.$form->editfieldkey(
"Date",
'datep', $object->date, $object, $user->rights->facture->paiement).
'</td><td>';
210 print $form->editfieldval(
"Date",
'datep', $object->date, $object, $user->rights->facture->paiement,
'datehourpicker',
'', null, $langs->trans(
'PaymentDateUpdateSucceeded'));
214 $labeltype = $langs->trans(
"PaymentType".$object->type_code) != (
"PaymentType".$object->type_code) ? $langs->trans(
"PaymentType".$object->type_code) : $object->type_label;
215 print '<tr><td>'.$langs->trans(
'PaymentMode').
'</td><td>'.$labeltype;
216 print $object->num_payment ?
' - '.$object->num_payment :
'';
220 print '<tr><td>'.$langs->trans(
'Amount').
'</td><td>'.
price($object->amount,
'', $langs, 0, -1, -1, $conf->currency).
'</td></tr>';
224 if (!empty($conf->banque->enabled))
228 if ($object->fk_account > 0)
230 $bankline->fetch($object->bank_line);
231 if ($bankline->rappro)
234 $title_button =
dol_escape_htmltag($langs->transnoentitiesnoconv(
"CantRemoveConciliatedPayment"));
238 print '<td>'.$langs->trans(
'BankAccount').
'</td>';
240 $accountstatic =
new Account($db);
241 $accountstatic->fetch($bankline->fk_account);
242 print $accountstatic->getNomUrl(1);
269 if (!empty($conf->banque->enabled))
271 if ($object->fk_account > 0) {
272 if ($object->type_code ==
'CHQ' && $bankline->fk_bordereau > 0) {
275 $bordereau->fetch($bankline->fk_bordereau);
278 print '<td>'.$langs->trans(
'CheckReceipt').
'</td>';
280 print $bordereau->getNomUrl(1);
287 print '<td>'.$langs->trans(
'BankTransactionLine').
'</td>';
289 if ($object->fk_account > 0) {
290 print $bankline->getNomUrl(1, 0,
'showconciliatedandaccounted');
292 $langs->load(
"admin");
293 print '<span class="opacitymedium">'.$langs->trans(
"NoRecordFoundIBankcAccount", $langs->transnoentitiesnoconv(
"Module85Name")).
'</span>';
300 print '<tr><td class="tdtop">'.$form->editfieldkey(
"Comments",
'note', $object->note, $object, $user->rights->facture->paiement).
'</td><td>';
301 print $form->editfieldval(
"Note",
'note', $object->note, $object, $user->rights->facture->paiement,
'textarea:'.ROWS_3.
':90%');
315 $sql =
'SELECT f.rowid as facid, f.ref, f.type, f.total_ttc, f.paye, f.entity, f.fk_statut, pf.amount, s.nom as name, s.rowid as socid';
316 $sql .=
' FROM '.MAIN_DB_PREFIX.
'paiement_facture as pf,'.MAIN_DB_PREFIX.
'facture as f,'.MAIN_DB_PREFIX.
'societe as s';
317 $sql .=
' WHERE pf.fk_facture = f.rowid';
318 $sql .=
' AND f.fk_soc = s.rowid';
319 $sql .=
' AND f.entity IN ('.getEntity(
'invoice').
')';
320 $sql .=
' AND pf.fk_paiement = '.$object->id;
321 $resql = $db->query($sql);
324 $num = $db->num_rows(
$resql);
333 print '<div class="div-table-responsive">';
334 print '<table class="noborder centpercent">';
336 print '<tr class="liste_titre">';
337 print '<td>'.$langs->trans(
'Bill').
'</td>';
338 print '<td>'.$langs->trans(
'Company').
'</td>';
339 if (!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_INVOICE_SHARING_ENABLED))
print '<td>'.$langs->trans(
'Entity').
'</td>';
340 print '<td class="right">'.$langs->trans(
'ExpectedToPay').
'</td>';
341 print '<td class="right">'.$langs->trans(
'PayedByThisPayment').
'</td>';
342 print '<td class="right">'.$langs->trans(
'RemainderToPay').
'</td>';
343 print '<td class="right">'.$langs->trans(
'Status').
'</td>';
350 $objp = $db->fetch_object(
$resql);
352 $thirdpartystatic->fetch($objp->socid);
355 $invoice->fetch($objp->facid);
357 $paiement = $invoice->getSommePaiement();
358 $creditnotes = $invoice->getSumCreditNotesUsed();
359 $deposits = $invoice->getSumDepositsUsed();
360 $alreadypayed =
price2num($paiement + $creditnotes + $deposits,
'MT');
361 $remaintopay =
price2num($invoice->total_ttc - $paiement - $creditnotes - $deposits,
'MT');
363 print '<tr class="oddeven">';
367 print $invoice->getNomUrl(1);
372 print $thirdpartystatic->getNomUrl(1);
376 if (!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_INVOICE_SHARING_ENABLED)) {
378 $mc->getInfo($objp->entity);
383 print '<td class="right">'.price($objp->total_ttc).
'</td>';
386 print '<td class="right">'.price($objp->amount).
'</td>';
389 print '<td class="right">'.price($remaintopay).
'</td>';
392 print '<td class="right">'.$invoice->getLibStatut(5, $alreadypayed).
'</td>';
395 if ($objp->paye == 1)
398 $title_button =
dol_escape_htmltag($langs->transnoentitiesnoconv(
"CantRemovePaymentWithOneInvoicePaid"));
400 $total = $total + $objp->amount;
420 print '<div class="tabsAction">';
422 if (!empty($conf->global->BILL_ADD_PAYMENT_VALIDATION))
424 if ($user->socid == 0 && $object->statut == 0 && $_GET[
'action'] ==
'')
426 if ($user->rights->facture->paiement)
428 print '<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?id='.$id.
'&facid='.$objp->facid.
'&action=valide">'.$langs->trans(
'Valid').
'</a>';
433 if ($user->socid == 0 && $action ==
'')
435 if ($user->rights->facture->paiement)
437 if (!$disable_delete)
439 print '<a class="butActionDelete" href="'.$_SERVER[
'PHP_SELF'].
'?id='.$id.
'&action=delete">'.$langs->trans(
'Delete').
'</a>';
441 print '<a class="butActionRefused classfortooltip" href="#" title="'.$title_button.
'">'.$langs->trans(
'Delete').
'</a>';
if(!function_exists('dol_getprefix')) dol_include_once($relpath, $classname= '')
Make an include_once using default root and alternate root if it fails.
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm= 'auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
Class to manage bank transaction lines.
Class to manage bank accounts.
price($amount, $form=0, $outlangs= '', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code= '')
Function to format a value into an amount for visual output Function used into PDF and HTML pages...
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
Class to manage third parties objects (customers, suppliers, prospects...)
price2num($amount, $rounding= '', $option=0)
Function that return a number with universal decimal format (decimal separator is '...
Class to manage payments of customer invoices.
restrictedArea($user, $features, $objectid=0, $tableandshare= '', $feature2= '', $dbt_keyfield= 'fk_soc', $dbt_select= 'rowid', $isdraft=0)
Check permissions of a user to show a page and an object.
accessforbidden($message= '', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
Class to manage translations.
print $_SERVER["PHP_SELF"]
Edit parameters.
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
print
Draft customers invoices.
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_get_fiche_end($notab=0)
Return tab footer of a card.
Class to manage invoices.
dol_banner_tab($object, $paramid, $morehtml= '', $shownav=1, $fieldid= 'rowid', $fieldref= 'ref', $morehtmlref= '', $moreparam= '', $nodbprefix=0, $morehtmlleft= '', $morehtmlstatus= '', $onlybanner=0, $morehtmlright= '')
Show tab footer of a card.
Class to manage cheque delivery receipts.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $keepmoretags= '', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields...