30 require
'../../main.inc.php';
31 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
32 require_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
33 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.class.php';
34 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
35 require_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');
51 $hookmanager->initHooks(array(
'supplierpaymentcard',
'globalcard'));
54 include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
56 $result =
restrictedArea($user, $object->element, $object->id,
'paiementfourn',
'');
60 $socid = $user->socid;
64 if ($socid && $socid != $object->thirdparty->id) {
73 if ($action ==
'setnote' && ($user->rights->fournisseur->facture->creer || $user->rights->supplier_invoice->creer)) {
77 $result = $object->update_note(
GETPOST(
'note',
'restricthtml'));
87 if ($action ==
'confirm_delete' && $confirm ==
'yes' && $user->rights->fournisseur->facture->supprimer) {
91 $result = $object->delete();
94 header(
'Location: '.DOL_URL_ROOT.
'/fourn/paiement/list.php');
102 if ($action ==
'confirm_validate' && $confirm ==
'yes' &&
103 ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && (!empty($user->rights->fournisseur->facture->creer) || !empty($user->rights->supplier_invoice->creer)))
104 || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->fournisseur->supplier_invoice_advance->validate)))
109 if ($object->validate() >= 0) {
111 header(
'Location: '.$_SERVER[
'PHP_SELF'].
'?id='.$object->id);
119 if ($action ==
'setnum_paiement' &&
GETPOST(
'num_paiement')) {
121 $res = $object->update_num(
GETPOST(
'num_paiement'));
123 setEventMessages($langs->trans(
'PaymentNumberUpdateSucceeded'),
null,
'mesgs');
125 setEventMessages($langs->trans(
'PaymentNumberUpdateFailed'),
null,
'errors');
129 if ($action ==
'setdatep' &&
GETPOST(
'datepday')) {
131 $datepaye =
dol_mktime(
GETPOST(
'datephour',
'int'),
GETPOST(
'datepmin',
'int'),
GETPOST(
'datepsec',
'int'),
GETPOST(
'datepmonth',
'int'),
GETPOST(
'datepday',
'int'),
GETPOST(
'datepyear',
'int'));
132 $res = $object->update_date($datepaye);
134 setEventMessages($langs->trans(
'PaymentDateUpdateSucceeded'),
null,
'mesgs');
141 $upload_dir = $conf->fournisseur->payment->dir_output;
143 $permissiontoadd =
true;
144 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
147 $triggersendname =
'PAYMENTRECEIPT_SENTBYMAIL';
149 $autocopy =
'MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO';
150 $trackid =
'pre'.$object->id;
151 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
160 $result = $object->fetch($id);
165 $head = payment_supplier_prepare_head($object);
167 print
dol_get_fiche_head($head,
'payment', $langs->trans(
'SupplierPayment'), -1,
'payment');
173 if ($action ==
'delete') {
174 print
$form->formconfirm($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $langs->trans(
"DeletePayment"), $langs->trans(
"ConfirmDeletePayment"),
'confirm_delete');
180 if ($action ==
'validate') {
181 print
$form->formconfirm($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $langs->trans(
"ValidatePayment"), $langs->trans(
"ConfirmValidatePayment"),
'confirm_validate');
184 $linkback =
'<a href="'.DOL_URL_ROOT.
'/fourn/paiement/list.php'.(!empty($socid) ?
'?socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
189 print
'<div class="fichecenter">';
190 print
'<div class="underbanner clearboth"></div>';
192 print
'<table class="border centpercent">';
200 print
'<tr><td class="titlefield">'.$form->editfieldkey(
"Date",
'datep', $object->date, $object, $object->statut == 0 && ($user->rights->fournisseur->facture->creer || $user->rights->supplier_invoice->creer)).
'</td>';
202 print
$form->editfieldval(
"Date",
'datep', $object->date, $object, $object->statut == 0 && ($user->rights->fournisseur->facture->creer || $user->rights->supplier_invoice->creer),
'datehourpicker',
'',
null, $langs->trans(
'PaymentDateUpdateSucceeded'));
206 $labeltype = $langs->trans(
"PaymentType".$object->type_code) != (
"PaymentType".$object->type_code) ? $langs->trans(
"PaymentType".$object->type_code) : $object->type_label;
207 print
'<tr><td>'.$langs->trans(
'PaymentMode').
'</td>';
208 print
'<td>'.$labeltype;
209 print $object->num_payment ?
' - '.$object->num_payment :
'';
221 print
'<tr><td>'.$langs->trans(
'Amount').
'</td>';
222 print
'<td>'.price($object->amount,
'', $langs, 0, 0, -1, $conf->currency).
'</td></tr>';
224 if (!empty($conf->global->BILL_ADD_PAYMENT_VALIDATION)) {
225 print
'<tr><td>'.$langs->trans(
'Status').
'</td>';
226 print
'<td>'.$object->getLibStatut(4).
'</td></tr>';
232 if ($object->fk_account) {
234 $bankline->fetch($object->bank_line);
235 if ($bankline->rappro) {
237 $title_button =
dol_escape_htmltag($langs->transnoentitiesnoconv(
"CantRemoveConciliatedPayment"));
241 print
'<td>'.$langs->trans(
'BankAccount').
'</td>';
243 $accountstatic =
new Account($db);
244 $accountstatic->fetch($bankline->fk_account);
245 print $accountstatic->getNomUrl(1);
250 print
'<td>'.$langs->trans(
'BankTransactionLine').
'</td>';
252 print $bankline->getNomUrl(1, 0,
'showconciliated');
259 print
'<tr><td>'.$form->editfieldkey(
"Comments",
'note', $object->note, $object, ($user->rights->fournisseur->facture->creer || $user->rights->supplier_invoice->creer)).
'</td>';
261 print
$form->editfieldval(
"Note",
'note', $object->note, $object, ($user->rights->fournisseur->facture->creer || $user->rights->supplier_invoice->creer),
'textarea');
273 $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,';
274 $sql .=
' pf.amount, s.nom as name, s.rowid as socid';
275 $sql .=
' FROM '.MAIN_DB_PREFIX.
'paiementfourn_facturefourn as pf,'.MAIN_DB_PREFIX.
'facture_fourn as f,'.MAIN_DB_PREFIX.
'societe as s';
276 $sql .=
' WHERE pf.fk_facturefourn = f.rowid AND f.fk_soc = s.rowid';
277 $sql .=
' AND pf.fk_paiementfourn = '.((int) $object->id);
278 $resql = $db->query($sql);
280 $num = $db->num_rows(
$resql);
285 print
'<table class="noborder centpercent">';
286 print
'<tr class="liste_titre">';
287 print
'<td>'.$langs->trans(
'Invoice').
'</td>';
288 print
'<td>'.$langs->trans(
'RefSupplier').
'</td>';
289 print
'<td>'.$langs->trans(
'Company').
'</td>';
290 print
'<td class="right">'.$langs->trans(
'ExpectedToPay').
'</td>';
291 print
'<td class="right">'.$langs->trans(
'PayedByThisPayment').
'</td>';
292 print
'<td class="right">'.$langs->trans(
'Status').
'</td>';
299 $objp = $db->fetch_object(
$resql);
301 $facturestatic->id = $objp->facid;
302 $facturestatic->ref = ($objp->ref ? $objp->ref : $objp->rowid);
303 $facturestatic->date = $db->jdate($objp->date);
304 $facturestatic->type = $objp->type;
305 $facturestatic->total_ht = $objp->total_ht;
306 $facturestatic->total_tva = $objp->total_tva;
307 $facturestatic->total_ttc = $objp->total_ttc;
308 $facturestatic->statut = $objp->status;
309 $facturestatic->alreadypaid = -1;
311 print
'<tr class="oddeven">';
314 print $facturestatic->getNomUrl(1);
317 print
'<td>'.$objp->ref_supplier.
"</td>\n";
319 print
'<td><a href="'.DOL_URL_ROOT.
'/fourn/card.php?socid='.$objp->socid.
'">'.
img_object($langs->trans(
'ShowCompany'),
'company').
' '.$objp->name.
'</a></td>';
321 print
'<td class="right">'.price($objp->total_ttc).
'</td>';
323 print
'<td class="right">'.price($objp->amount).
'</td>';
325 print
'<td class="right">'.$facturestatic->LibStatut($objp->paye, $objp->status, 6, 1).
'</td>';
328 if ($objp->paye == 1) {
330 $title_button =
dol_escape_htmltag($langs->transnoentitiesnoconv(
"CantRemovePaymentWithOneInvoicePaid"));
332 $total = $total + $objp->amount;
351 print
'<div class="tabsAction">';
354 if ($user->socid == 0 && $action ==
'') {
355 $usercansend = (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->fournisseur->supplier_invoice_advance->send)));
357 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=presend&mode=init#formmailbeforetitle">'.$langs->trans(
'SendMail').
'</a>';
359 print
'<span class="butActionRefused classfortooltip">'.$langs->trans(
'SendMail').
'</span>';
364 if (!empty($conf->global->BILL_ADD_PAYMENT_VALIDATION)) {
365 if ($user->socid == 0 && $object->statut == 0 && $action ==
'') {
366 if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && (!empty($user->rights->fournisseur->facture->creer) || !empty($user->rights->supplier_invoice->creer)))
367 || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->fournisseur->supplier_invoice_advance->validate))) {
368 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=validate">'.$langs->trans(
'Valid').
'</a>';
374 if ($user->socid == 0 && $action ==
'') {
375 if ($user->rights->fournisseur->facture->supprimer) {
377 print
dolGetButtonAction($langs->trans(
"Delete"),
'',
'delete', $_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=delete&token='.
newToken(),
'delete', 1);
379 print
dolGetButtonAction($title_button, $langs->trans(
"Delete"),
'delete', $_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=delete&token='.
newToken(),
'delete', 0);
386 print
'<div class="fichecenter"><div class="fichehalfleft">';
389 include_once DOL_DOCUMENT_ROOT.
'/core/modules/supplier_payment/modules_supplier_payment.php';
391 if (is_array($modellist)) {
394 $urlsource = $_SERVER[
'PHP_SELF'].
'?id='.$object->id;
395 $genallowed = ($user->rights->fournisseur->facture->lire || $user->rights->supplier_invoice->lire);
396 $delallowed = ($user->rights->fournisseur->facture->creer || $user->rights->supplier_invoice->creer);
397 $modelpdf = (!empty($object->model_pdf) ? $object->model_pdf : (empty($conf->global->SUPPLIER_PAYMENT_ADDON_PDF) ?
'' : $conf->global->SUPPLIER_PAYMENT_ADDON_PDF));
399 print $formfile->showdocuments(
'supplier_payment', $ref, $filedir, $urlsource, $genallowed, $delallowed, $modelpdf, 1, 0, 0, 40, 0,
'',
'',
'', $societe->default_lang);
400 $somethingshown = $formfile->numoffiles;
403 print
'</div><div class="fichehalfright">';
412 print
'</div></div>';
416 $defaulttopic =
'SendPaymentReceipt';
417 $diroutput = $conf->fournisseur->payment->dir_output;
418 $autocopy =
'MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO';
419 $trackid =
'pre'.$object->id;
421 include DOL_DOCUMENT_ROOT.
'/core/tpl/card_presend.tpl.php';
423 $langs->load(
"errors");
424 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.
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
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='')
Show tabs of a record.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields.
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
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.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
isModEnabled($module)
Is Dolibarr module enabled.
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.