30require
'../../main.inc.php';
31require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
32require_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
33require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.class.php';
34require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
35require_once DOL_DOCUMENT_ROOT.
'/fourn/class/paiementfourn.class.php';
39$langs->loadLangs(array(
'banks',
'bills',
'companies',
'suppliers'));
44$action =
GETPOST(
'action',
'alpha');
45$confirm =
GETPOST(
'confirm',
'alpha');
53$hookmanager->initHooks(array(
'supplierpaymentcard',
'globalcard'));
56include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
58$result =
restrictedArea($user, $object->element, $object->id,
'paiementfourn',
'');
62 $socid = $user->socid;
66if ($socid && $socid != $object->thirdparty->id) {
75if ($action ==
'setnote' && ($user->hasRight(
"fournisseur",
"facture",
"creer") || $user->hasRight(
"supplier_invoice",
"creer"))) {
79 $result = $object->update_note(
GETPOST(
'note',
'restricthtml'));
89if ($action ==
'confirm_delete' && $confirm ==
'yes' && $user->hasRight(
"fournisseur",
"facture",
"supprimer")) {
93 $result = $object->delete();
96 header(
'Location: '.DOL_URL_ROOT.
'/fourn/paiement/list.php');
104if ($action ==
'confirm_validate' && $confirm ==
'yes' &&
105 ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ($user->hasRight(
"fournisseur",
"facture",
"creer") || $user->hasRight(
"supplier_invoice",
"creer")))
106 || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->hasRight(
"fournisseur",
"supplier_invoice_advance",
"validate")))
111 if ($object->validate() >= 0) {
113 header(
'Location: '.$_SERVER[
'PHP_SELF'].
'?id='.$object->id);
121if ($action ==
'setnum_paiement' &&
GETPOST(
'num_paiement')) {
123 $res = $object->update_num(
GETPOST(
'num_paiement'));
125 setEventMessages($langs->trans(
'PaymentNumberUpdateSucceeded'),
null,
'mesgs');
127 setEventMessages($langs->trans(
'PaymentNumberUpdateFailed'),
null,
'errors');
131if ($action ==
'setdatep' &&
GETPOST(
'datepday')) {
133 $datepaye =
dol_mktime(
GETPOST(
'datephour',
'int'),
GETPOST(
'datepmin',
'int'),
GETPOST(
'datepsec',
'int'),
GETPOST(
'datepmonth',
'int'),
GETPOST(
'datepday',
'int'),
GETPOST(
'datepyear',
'int'));
134 $res = $object->update_date($datepaye);
136 setEventMessages($langs->trans(
'PaymentDateUpdateSucceeded'),
null,
'mesgs');
143$upload_dir = $conf->fournisseur->payment->dir_output;
145$permissiontoadd =
true;
146include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
149$triggersendname =
'PAYMENTRECEIPT_SENTBYMAIL';
151$autocopy =
'MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO';
152$trackid =
'pre'.$object->id;
153include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
162$result = $object->fetch($id);
164$form =
new Form($db);
167$head = payment_supplier_prepare_head($object);
169print
dol_get_fiche_head($head,
'payment', $langs->trans(
'SupplierPayment'), -1,
'payment');
175 if ($action ==
'delete') {
176 print $form->formconfirm($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $langs->trans(
"DeletePayment"), $langs->trans(
"ConfirmDeletePayment"),
'confirm_delete');
182 if ($action ==
'validate') {
183 print $form->formconfirm($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $langs->trans(
"ValidatePayment"), $langs->trans(
"ConfirmValidatePayment"),
'confirm_validate');
186 $linkback =
'<a href="'.DOL_URL_ROOT.
'/fourn/paiement/list.php'.(!empty($socid) ?
'?socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
191 print
'<div class="fichecenter">';
192 print
'<div class="underbanner clearboth"></div>';
194 print
'<table class="border centpercent">';
202 print
'<tr><td class="titlefield">'.$form->editfieldkey(
"Date",
'datep', $object->date, $object, $object->statut == 0 && ($user->hasRight(
"fournisseur",
"facture",
"creer") || $user->hasRight(
"supplier_invoice",
"creer"))).
'</td>';
204 print $form->editfieldval(
"Date",
'datep', $object->date, $object, $object->statut == 0 && ($user->hasRight(
"fournisseur",
"facture",
"creer") || $user->hasRight(
"supplier_invoice",
"creer")),
'datehourpicker',
'',
null, $langs->trans(
'PaymentDateUpdateSucceeded'));
208 $labeltype = $langs->trans(
"PaymentType".$object->type_code) != (
"PaymentType".$object->type_code) ? $langs->trans(
"PaymentType".$object->type_code) : $object->type_label;
209 print
'<tr><td>'.$langs->trans(
'PaymentMode').
'</td>';
210 print
'<td>'.$labeltype;
211 print $object->num_payment ?
' - '.$object->num_payment :
'';
223 print
'<tr><td>'.$langs->trans(
'Amount').
'</td>';
224 print
'<td><span class="amount">'.price($object->amount,
'', $langs, 0, 0, -1, $conf->currency).
'</span></td></tr>';
227 if (!empty($conf->global->BILL_ADD_PAYMENT_VALIDATION)) {
228 print
'<tr><td>'.$langs->trans(
'Status').
'</td>';
229 print
'<td>'.$object->getLibStatut(4).
'</td></tr>';
234 if (isModEnabled(
"banque")) {
235 if ($object->fk_account) {
237 $bankline->fetch($object->bank_line);
238 if ($bankline->rappro) {
240 $title_button =
dol_escape_htmltag($langs->transnoentitiesnoconv(
"CantRemoveConciliatedPayment"));
244 print
'<td>'.$langs->trans(
'BankAccount').
'</td>';
246 $accountstatic =
new Account($db);
247 $accountstatic->fetch($bankline->fk_account);
248 print $accountstatic->getNomUrl(1);
253 print
'<td>'.$langs->trans(
'BankTransactionLine').
'</td>';
255 print $bankline->getNomUrl(1, 0,
'showconciliated');
262 print
'<tr><td>'.$form->editfieldkey(
"Comments",
'note', $object->note_private, $object, ($user->hasRight(
"fournisseur",
"facture",
"creer") || $user->hasRight(
"supplier_invoice",
"creer"))).
'</td>';
264 print $form->editfieldval(
"Note",
'note', $object->note_private, $object, ($user->hasRight(
"fournisseur",
"facture",
"creer") || $user->hasRight(
"supplier_invoice",
"creer")),
'textarea');
276 $sql =
'SELECT f.rowid, f.rowid as facid, f.ref, f.ref_supplier, f.type, f.paye, f.total_ht, f.total_tva, f.total_ttc, f.datef as date, f.fk_statut as status,';
277 $sql .=
' pf.amount, s.nom as name, s.rowid as socid';
278 $sql .=
' FROM '.MAIN_DB_PREFIX.
'paiementfourn_facturefourn as pf,'.MAIN_DB_PREFIX.
'facture_fourn as f,'.MAIN_DB_PREFIX.
'societe as s';
279 $sql .=
' WHERE pf.fk_facturefourn = f.rowid AND f.fk_soc = s.rowid';
280 $sql .=
' AND pf.fk_paiementfourn = '.((int) $object->id);
281 $resql = $db->query($sql);
283 $num = $db->num_rows($resql);
288 print
'<table class="noborder centpercent">';
289 print
'<tr class="liste_titre">';
290 print
'<td>'.$langs->trans(
'Invoice').
'</td>';
291 print
'<td>'.$langs->trans(
'RefSupplier').
'</td>';
292 print
'<td>'.$langs->trans(
'Company').
'</td>';
293 print
'<td class="right">'.$langs->trans(
'ExpectedToPay').
'</td>';
294 print
'<td class="right">'.$langs->trans(
'PayedByThisPayment').
'</td>';
295 print
'<td class="right">'.$langs->trans(
'Status').
'</td>';
302 $objp = $db->fetch_object($resql);
304 $facturestatic->id = $objp->facid;
305 $facturestatic->ref = ($objp->ref ? $objp->ref : $objp->rowid);
306 $facturestatic->date = $db->jdate($objp->date);
307 $facturestatic->type = $objp->type;
308 $facturestatic->total_ht = $objp->total_ht;
309 $facturestatic->total_tva = $objp->total_tva;
310 $facturestatic->total_ttc = $objp->total_ttc;
311 $facturestatic->statut = $objp->status;
312 $facturestatic->alreadypaid = -1;
314 print
'<tr class="oddeven">';
317 print $facturestatic->getNomUrl(1);
320 print
'<td>'.$objp->ref_supplier.
"</td>\n";
322 print
'<td><a href="'.DOL_URL_ROOT.
'/fourn/card.php?socid='.$objp->socid.
'">'.
img_object($langs->trans(
'ShowCompany'),
'company').
' '.$objp->name.
'</a></td>';
324 print
'<td class="right">'.price($objp->total_ttc).
'</td>';
326 print
'<td class="right">'.price($objp->amount).
'</td>';
328 print
'<td class="right">'.$facturestatic->LibStatut($objp->paye, $objp->status, 6, 1).
'</td>';
331 if ($objp->paye == 1) {
333 $title_button =
dol_escape_htmltag($langs->transnoentitiesnoconv(
"CantRemovePaymentWithOneInvoicePaid"));
335 $total = $total + $objp->amount;
354 print
'<div class="tabsAction">';
357 if ($user->socid == 0 && $action !=
'presend') {
358 $usercansend = (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->hasRight(
"fournisseur",
"supplier_invoice_advance",
"send")));
360 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=presend&mode=init#formmailbeforetitle">'.$langs->trans(
'SendMail').
'</a>';
362 print
'<span class="butActionRefused classfortooltip">'.$langs->trans(
'SendMail').
'</span>';
367 if (!empty($conf->global->BILL_ADD_PAYMENT_VALIDATION)) {
368 if ($user->socid == 0 && $object->statut == 0 && $action ==
'') {
369 if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ($user->hasRight(
"fournisseur",
"facture",
"creer") || $user->hasRight(
"supplier_invoice",
"creer")))
370 || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->hasRight(
"fournisseur",
"supplier_invoice_advance",
"validate"))) {
371 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=validate">'.$langs->trans(
'Valid').
'</a>';
377 if ($user->socid == 0 && $action !=
'presend') {
378 if ($user->hasRight(
'fournisseur',
'facture',
'supprimer')) {
380 print
dolGetButtonAction($langs->trans(
"Delete"),
'',
'delete', $_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=delete&token='.newToken(),
'delete', 1);
382 print
dolGetButtonAction($title_button, $langs->trans(
"Delete"),
'delete', $_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=delete&token='.newToken(),
'delete', 0);
388 if ($action !=
'presend') {
389 print
'<div class="fichecenter"><div class="fichehalfleft">';
392 include_once DOL_DOCUMENT_ROOT.
'/core/modules/supplier_payment/modules_supplier_payment.php';
394 if (is_array($modellist)) {
397 $urlsource = $_SERVER[
'PHP_SELF'].
'?id='.$object->id;
398 $genallowed = ($user->hasRight(
"fournisseur",
"facture",
"lire") || $user->hasRight(
"supplier_invoice",
"lire"));
399 $delallowed = ($user->hasRight(
"fournisseur",
"facture",
"creer") || $user->hasRight(
"supplier_invoice",
"creer"));
400 $modelpdf = (!empty($object->model_pdf) ? $object->model_pdf : (empty($conf->global->SUPPLIER_PAYMENT_ADDON_PDF) ?
'' : $conf->global->SUPPLIER_PAYMENT_ADDON_PDF));
402 print $formfile->showdocuments(
'supplier_payment', $ref, $filedir, $urlsource, $genallowed, $delallowed, $modelpdf, 1, 0, 0, 40, 0,
'',
'',
'', $object->thirdparty->default_lang);
403 $somethingshown = $formfile->numoffiles;
406 print
'</div><div class="fichehalfright">';
415 print
'</div></div>';
420 $defaulttopic =
'SendPaymentReceipt';
421 $diroutput = $conf->fournisseur->payment->dir_output;
422 $autocopy =
'MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO';
423 $trackid =
'pre'.$object->id;
425 include DOL_DOCUMENT_ROOT.
'/core/tpl/card_presend.tpl.php';
427 $langs->load(
"errors");
428 print $langs->trans(
"ErrorRecordNotFound");
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Class to manage bank accounts.
Class to manage bank transaction lines.
Class to manage suppliers invoices.
static liste_modeles($db, $maxfilenamelength=0)
Return list of active generation models.
Class to manage payments for supplier 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.
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...
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dolGetButtonAction($label, $text='', $actionType='default', $url='', $id='', $userRight=1, $params=array())
Function dolGetButtonAction.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=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.