33require
'../../main.inc.php';
41require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
42require_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
43require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.class.php';
44require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
45require_once DOL_DOCUMENT_ROOT.
'/fourn/class/paiementfourn.class.php';
48$langs->loadLangs(array(
'banks',
'bills',
'companies',
'suppliers'));
53$action =
GETPOST(
'action',
'alpha');
54$confirm =
GETPOST(
'confirm',
'alpha');
62$hookmanager->initHooks(array(
'supplierpaymentcard',
'globalcard'));
65include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
70if ($user->isExternalUser()) {
71 $socid = $user->isExternalUser();
75if ($socid && $socid !=
$object->thirdparty->id) {
79$permissiontoadd = ($user->hasRight(
"fournisseur",
"facture",
"creer") || $user->hasRight(
"supplier_invoice",
"write"));
80$permissiontovalidate = ((!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && ($user->hasRight(
"fournisseur",
"facture",
"creer") || $user->hasRight(
"supplier_invoice",
"write"))) || (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
"fournisseur",
"supplier_invoice_advance",
"validate")));
81$permissiontodelete = ($user->hasRight(
"fournisseur",
"facture",
"supprimer") || $user->hasRight(
"supplier_invoice",
"delete"));
88if ($action ==
'setnote' && $permissiontoadd) {
102if ($action ==
'confirm_delete' && $confirm ==
'yes' && $permissiontodelete) {
107 $result =
$object->delete($user);
110 header(
'Location: '.DOL_URL_ROOT.
'/fourn/paiement/list.php');
118if ($action ==
'confirm_validate' && $confirm ==
'yes' && $permissiontovalidate) {
122 if (
$object->validate() >= 0) {
124 header(
'Location: '.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id);
132if ($action ==
'setnum_paiement' &&
GETPOST(
'num_paiement') && $permissiontoadd) {
136 setEventMessages($langs->trans(
'PaymentNumberUpdateSucceeded'),
null,
'mesgs');
138 setEventMessages($langs->trans(
'PaymentNumberUpdateFailed'),
null,
'errors');
142if ($action ==
'setdatep' &&
GETPOST(
'datepday') && $permissiontoadd) {
145 $res =
$object->update_date($datepaye);
147 setEventMessages($langs->trans(
'PaymentDateUpdateSucceeded'),
null,
'mesgs');
149 setEventMessages($langs->trans(
'PaymentDateUpdateFailed'),
null,
'errors');
154$upload_dir =
$conf->fournisseur->payment->dir_output;
155include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
158$triggersendname =
'PAYMENTRECEIPT_SENTBYMAIL';
160$autocopy =
'MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO';
161$trackid =
'pre'.$object->id;
162include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
173$form =
new Form($db);
176$head = payment_supplier_prepare_head($object);
180print
dol_get_fiche_head($head,
'payment', $langs->trans(
'SupplierPayment'), -1,
'payment', 0,
'',
'', 0,
'', ($result > 0 ? 1 : 0));
186 if ($action ==
'delete') {
187 print $form->formconfirm($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, $langs->trans(
"DeletePayment"), $langs->trans(
"ConfirmDeletePayment"),
'confirm_delete');
193 if ($action ==
'validate') {
194 print $form->formconfirm($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, $langs->trans(
"ValidatePayment"), $langs->trans(
"ConfirmValidatePayment"),
'confirm_validate');
197 $linkback =
'<a href="'.DOL_URL_ROOT.
'/fourn/paiement/list.php'.(!empty($socid) ?
'?socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
201 dol_banner_tab($object,
'id', $linkback, 1,
'rowid',
'ref', $morehtmlref);
203 print
'<div class="fichecenter">';
204 print
'<div class="underbanner clearboth"></div>';
206 print
'<table class="border centpercent">';
214 print
'<tr><td class="titlefield">'.$form->editfieldkey(
"Date",
'datep',
$object->date, $object, (
int) (
$object->statut == 0 && ($user->hasRight(
"fournisseur",
"facture",
"creer") || $user->hasRight(
"supplier_invoice",
"creer")))).
'</td>';
216 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'));
220 $labeltype = $langs->trans(
"PaymentType".
$object->type_code) !=
"PaymentType".$object->type_code ? $langs->trans(
"PaymentType".
$object->type_code) :
$object->type_label;
221 print
'<tr><td>'.$langs->trans(
'PaymentMode').
'</td>';
222 print
'<td>'.$labeltype;
223 print
$object->num_payment ?
' - '.$object->num_payment :
'';
227 print
'<tr><td>'.$form->editfieldkey(
"Numero",
'num_paiement',
$object->num_payment, $object,
$object->statut == 0 && $user->hasRight(
"fournisseur",
"facture",
"creer")).
'</td>';
229 print $form->editfieldval(
"Numero",
'num_paiement',
$object->num_payment, $object,
$object->statut == 0 && $user->hasRight(
"fournisseur",
"facture",
"creer"),
'string',
'',
null, $langs->trans(
'PaymentNumberUpdateSucceeded'));
241 print
'<tr><td>'.$langs->trans(
'Amount').
'</td>';
242 print
'<td><span class="amount">'.price(
$object->amount, 0, $langs, 0, 0, -1,
$conf->currency).
'</span></td></tr>';
246 print
'<tr><td>'.$langs->trans(
'Status').
'</td>';
247 print
'<td>'.$object->getLibStatut(4).
'</td></tr>';
256 $bankline->fetch(
$object->bank_line);
257 if ($bankline->rappro) {
259 $title_button =
dol_escape_htmltag($langs->transnoentitiesnoconv(
"CantRemoveConciliatedPayment"));
263 print
'<td>'.$langs->trans(
'BankAccount').
'</td>';
265 $accountstatic =
new Account($db);
266 $accountstatic->fetch($bankline->fk_account);
267 print $accountstatic->getNomUrl(1);
272 print
'<td>'.$langs->trans(
'BankTransactionLine').
'</td>';
274 print $bankline->getNomUrl(1, 0,
'showconciliatedandaccounted');
281 print
'<tr><td>'.$form->editfieldkey(
"Comments",
'note',
$object->note_private, $object, (
int) ($user->hasRight(
"fournisseur",
"facture",
"creer") || $user->hasRight(
"supplier_invoice",
"creer"))).
'</td>';
283 print $form->editfieldval(
"Note",
'note',
$object->note_private, $object, ($user->hasRight(
"fournisseur",
"facture",
"creer") || $user->hasRight(
"supplier_invoice",
"creer")),
'textarea');
297 $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,';
298 $sql .=
' pf.amount, s.nom as name, s.rowid as socid';
299 $sql .=
' FROM '.MAIN_DB_PREFIX.
'paiementfourn_facturefourn as pf,'.MAIN_DB_PREFIX.
'facture_fourn as f,'.MAIN_DB_PREFIX.
'societe as s';
300 $sql .=
' WHERE pf.fk_facturefourn = f.rowid AND f.fk_soc = s.rowid';
301 $sql .=
' AND pf.fk_paiementfourn = '.((int)
$object->id);
302 $resql = $db->query($sql);
304 $num = $db->num_rows($resql);
309 print
'<table class="noborder centpercent">';
310 print
'<tr class="liste_titre">';
311 print
'<td>'.$langs->trans(
'Invoice').
'</td>';
312 print
'<td>'.$langs->trans(
'RefSupplier').
'</td>';
313 print
'<td>'.$langs->trans(
'Company').
'</td>';
314 print
'<td class="right">'.$langs->trans(
'ExpectedToPay').
'</td>';
315 print
'<td class="right">'.$langs->trans(
'PayedByThisPayment').
'</td>';
316 print
'<td class="right">'.$langs->trans(
'Status').
'</td>';
323 $objp = $db->fetch_object($resql);
325 $facturestatic->id = $objp->facid;
326 $facturestatic->ref = ($objp->ref ? $objp->ref : $objp->rowid);
327 $facturestatic->date = $db->jdate($objp->date);
328 $facturestatic->type = $objp->type;
329 $facturestatic->total_ht = $objp->total_ht;
330 $facturestatic->total_tva = $objp->total_tva;
331 $facturestatic->total_ttc = $objp->total_ttc;
332 $facturestatic->statut = $objp->status;
333 $facturestatic->status = $objp->status;
334 $facturestatic->alreadypaid = -1;
336 print
'<tr class="oddeven">';
339 print $facturestatic->getNomUrl(1);
342 print
'<td>'.$objp->ref_supplier.
"</td>\n";
344 print
'<td><a href="'.DOL_URL_ROOT.
'/fourn/card.php?socid='.$objp->socid.
'">'.img_object($langs->trans(
'ShowCompany'),
'company').
' '.$objp->name.
'</a></td>';
346 print
'<td class="right">'.price($objp->total_ttc).
'</td>';
348 print
'<td class="right">'.price($objp->amount).
'</td>';
350 print
'<td class="right">'.$facturestatic->LibStatut($objp->paye, $objp->status, 6, 1).
'</td>';
353 if ($objp->paye == 1) {
355 $title_button =
dol_escape_htmltag($langs->transnoentitiesnoconv(
"CantRemovePaymentWithOneInvoicePaid"));
357 $total += $objp->amount;
366 dol_print_error($db);
376 print
'<div class="tabsAction">';
379 if ($user->socid == 0 && $action !=
'presend') {
380 $usercansend = (!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') || (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
"fournisseur",
"supplier_invoice_advance",
"send")));
382 print dolGetButtonAction(
'', $langs->trans(
'SendMail'),
'email',
dolBuildUrl($_SERVER[
"PHP_SELF"], [
'id' =>
$object->id,
'action' =>
'presend',
'mode' =>
'init'],
true).
'#formmailbeforetitle',
'');
384 print dolGetButtonAction(
'', $langs->trans(
'SendMail'),
'email',
'#',
'',
false);
390 if ($user->socid == 0 &&
$object->statut == 0 && $action ==
'') {
391 if ((!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && ($user->hasRight(
"fournisseur",
"facture",
"creer") || $user->hasRight(
"supplier_invoice",
"creer")))
392 || (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
"fournisseur",
"supplier_invoice_advance",
"validate"))) {
393 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=validate&token='.
newToken().
'">'.$langs->trans(
'Valid').
'</a>';
399 if ($user->socid == 0 && $action !=
'presend') {
400 if ($user->hasRight(
'fournisseur',
'facture',
'supprimer')) {
402 print dolGetButtonAction($langs->trans(
"Delete"), $langs->trans(
"Delete"),
'delete', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=delete&token='.
newToken(),
'delete', 1, array(
'attr' => array(
'class' =>
'reposition'))).
"\n";
404 print dolGetButtonAction($title_button, $langs->trans(
"Delete"),
'delete', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=delete&token='.
newToken(),
'delete', 0);
411 if (
GETPOST(
'modelselected')) {
415 if ($action !=
'presend') {
416 print
'<div class="fichecenter"><div class="fichehalfleft">';
419 include_once DOL_DOCUMENT_ROOT.
'/core/modules/supplier_payment/modules_supplier_payment.php';
421 if (is_array($modellist)) {
424 $urlsource = $_SERVER[
'PHP_SELF'].
'?id='.
$object->id;
425 $genallowed = ($user->hasRight(
"fournisseur",
"facture",
"lire") || $user->hasRight(
"supplier_invoice",
"lire"));
426 $delallowed = ($user->hasRight(
"fournisseur",
"facture",
"creer") || $user->hasRight(
"supplier_invoice",
"creer"));
428 if (empty($modelpdf) && !empty($modellist)) {
429 $tmpkeys = array_keys($modellist);
430 $modelpdf = (string) $tmpkeys[0];
432 if (empty($modelpdf)) {
433 $modelpdf =
'standard_supplierpayment';
436 print $formfile->showdocuments(
'supplier_payment', $ref, $filedir, $urlsource, (
int) $genallowed, (int) $delallowed, $modelpdf, 1, 0, 0, 40, 0,
'',
'',
'',
$object->thirdparty->default_lang);
437 $somethingshown = $formfile->numoffiles;
440 print
'</div><div class="fichehalfright">';
449 print
'</div></div>';
453 if ($action ==
'presend' && empty(
$object->model_pdf)) {
455 if (!empty($defaultpdfmodel)) {
456 $object->model_pdf = $defaultpdfmodel;
458 include_once DOL_DOCUMENT_ROOT.
'/core/modules/supplier_payment/modules_supplier_payment.php';
460 if (!empty($modellist)) {
461 $tmpkeys = array_keys($modellist);
462 $object->model_pdf = (string) $tmpkeys[0];
465 if (empty(
$object->model_pdf)) {
466 $object->model_pdf =
'standard_supplierpayment';
471 $modelmail =
'supplier_payment_send';
472 $defaulttopic =
'SendPaymentReceipt';
473 $diroutput =
$conf->fournisseur->payment->dir_output;
474 $autocopy =
'MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO';
475 $trackid =
'pre'.$object->id;
477 include DOL_DOCUMENT_ROOT.
'/core/tpl/card_presend.tpl.php';
$id
Support class for third parties, contacts, members, users or resources.
if(! $sortfield) if(! $sortorder) $object
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
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 modules.
Class to manage payments for supplier invoices.
recordNotFound($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Displays an error page when a record is not found.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
dolBuildUrl($url, $params=[], $addtoken=false, $anchor='')
Return path of url.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_clone($srcobject, $native=2)
Create a clone of instance of object (new instance with same value for each properties) With native =...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $nodie=0, $mode='')
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.