28 require
'../../main.inc.php';
29 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
30 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/paiementfourn.class.php';
31 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.class.php';
32 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
33 require_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
35 $langs->loadLangs(array(
'bills',
'banks',
'companies',
'suppliers'));
38 $action =
GETPOST(
'action',
'alpha');
39 $confirm =
GETPOST(
'confirm',
'alpha');
44 include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
46 $result =
restrictedArea($user, $object->element, $object->id,
'paiementfourn',
'');
49 if ($user->socid) $socid = $user->socid;
52 if ($socid && $socid != $object->thirdparty->id) {
61 if ($action ==
'setnote' && $user->rights->fournisseur->facture->creer)
66 $result = $object->update_note(
GETPOST(
'note',
'restricthtml'));
77 if ($action ==
'confirm_delete' && $confirm ==
'yes' && $user->rights->fournisseur->facture->supprimer)
82 $result = $object->delete();
86 header(
'Location: '.DOL_URL_ROOT.
'/fourn/paiement/list.php');
94 if ($action ==
'confirm_validate' && $confirm ==
'yes' &&
95 ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->fournisseur->facture->creer))
96 || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->fournisseur->supplier_invoice_advance->validate)))
102 if ($object->validate() >= 0)
105 header(
'Location: '.
$_SERVER[
'PHP_SELF'].
'?id='.$object->id);
113 if ($action ==
'setnum_paiement' && !empty($_POST[
'num_paiement']))
116 $res = $object->update_num($_POST[
'num_paiement']);
119 setEventMessages($langs->trans(
'PaymentNumberUpdateSucceeded'), null,
'mesgs');
121 setEventMessages($langs->trans(
'PaymentNumberUpdateFailed'), null,
'errors');
125 if ($action ==
'setdatep' && !empty($_POST[
'datepday']))
128 $datepaye =
dol_mktime(
GETPOST(
'datephour',
'int'),
GETPOST(
'datepmin',
'int'),
GETPOST(
'datepsec',
'int'),
GETPOST(
'datepmonth',
'int'),
GETPOST(
'datepday',
'int'),
GETPOST(
'datepyear',
'int'));
129 $res = $object->update_date($datepaye);
132 setEventMessages($langs->trans(
'PaymentDateUpdateSucceeded'), null,
'mesgs');
139 $upload_dir = $conf->fournisseur->payment->dir_output;
141 $permissiontoadd =
true;
142 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
151 $result = $object->fetch($id);
153 $form =
new Form($db);
156 $head = payment_supplier_prepare_head($object);
165 if ($action ==
'delete')
167 print $form->formconfirm(
$_SERVER[
'PHP_SELF'].
'?id='.$object->id, $langs->trans(
"DeletePayment"), $langs->trans(
"ConfirmDeletePayment"),
'confirm_delete');
173 if ($action ==
'validate')
175 print $form->formconfirm(
$_SERVER[
'PHP_SELF'].
'?id='.$object->id, $langs->trans(
"ValidatePayment"), $langs->trans(
"ConfirmValidatePayment"),
'confirm_validate');
178 $linkback =
'<a href="'.DOL_URL_ROOT.
'/fourn/paiement/list.php'.(!empty($socid) ?
'?socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
183 print '<div class="fichecenter">';
184 print '<div class="underbanner clearboth"></div>';
186 print '<table class="border centpercent">';
194 print '<tr><td class="titlefield">'.$form->editfieldkey(
"Date",
'datep', $object->date, $object, $object->statut == 0 && $user->rights->fournisseur->facture->creer).
'</td>';
196 print $form->editfieldval(
"Date",
'datep', $object->date, $object, $object->statut == 0 && $user->rights->fournisseur->facture->creer,
'datehourpicker',
'', null, $langs->trans(
'PaymentDateUpdateSucceeded'));
200 $labeltype = $langs->trans(
"PaymentType".$object->type_code) != (
"PaymentType".$object->type_code) ? $langs->trans(
"PaymentType".$object->type_code) : $object->type_label;
201 print '<tr><td>'.$langs->trans(
'PaymentMode').
'</td>';
202 print '<td>'.$labeltype;
203 print $object->num_payment ?
' - '.$object->num_payment :
'';
215 print '<tr><td>'.$langs->trans(
'Amount').
'</td>';
216 print '<td>'.price($object->amount,
'', $langs, 0, 0, -1, $conf->currency).
'</td></tr>';
218 if (!empty($conf->global->BILL_ADD_PAYMENT_VALIDATION))
220 print '<tr><td>'.$langs->trans(
'Status').
'</td>';
221 print '<td>'.$object->getLibStatut(4).
'</td></tr>';
226 if (!empty($conf->banque->enabled))
228 if ($object->fk_account)
231 $bankline->fetch($object->bank_line);
232 if ($bankline->rappro)
235 $title_button =
dol_escape_htmltag($langs->transnoentitiesnoconv(
"CantRemoveConciliatedPayment"));
239 print '<td>'.$langs->trans(
'BankAccount').
'</td>';
241 $accountstatic =
new Account($db);
242 $accountstatic->fetch($bankline->fk_account);
243 print $accountstatic->getNomUrl(1);
248 print '<td>'.$langs->trans(
'BankTransactionLine').
'</td>';
250 print $bankline->getNomUrl(1, 0,
'showconciliated');
257 print '<tr><td>'.$form->editfieldkey(
"Comments",
'note', $object->note, $object, $user->rights->fournisseur->facture->creer).
'</td>';
259 print $form->editfieldval(
"Note",
'note', $object->note, $object, $user->rights->fournisseur->facture->creer,
'textarea');
271 $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,';
272 $sql .=
' pf.amount, s.nom as name, s.rowid as socid';
273 $sql .=
' FROM '.MAIN_DB_PREFIX.
'paiementfourn_facturefourn as pf,'.MAIN_DB_PREFIX.
'facture_fourn as f,'.MAIN_DB_PREFIX.
'societe as s';
274 $sql .=
' WHERE pf.fk_facturefourn = f.rowid AND f.fk_soc = s.rowid';
275 $sql .=
' AND pf.fk_paiementfourn = '.$object->id;
276 $resql = $db->query($sql);
279 $num = $db->num_rows(
$resql);
284 print '<table class="noborder centpercent">';
285 print '<tr class="liste_titre">';
286 print '<td>'.$langs->trans(
'Invoice').
'</td>';
287 print '<td>'.$langs->trans(
'RefSupplier').
'</td>';
288 print '<td>'.$langs->trans(
'Company').
'</td>';
289 print '<td class="right">'.$langs->trans(
'ExpectedToPay').
'</td>';
290 print '<td class="right">'.$langs->trans(
'PayedByThisPayment').
'</td>';
291 print '<td class="right">'.$langs->trans(
'Status').
'</td>';
300 $objp = $db->fetch_object(
$resql);
302 $facturestatic->id = $objp->facid;
303 $facturestatic->ref = ($objp->ref ? $objp->ref : $objp->rowid);
304 $facturestatic->date = $db->jdate($objp->date);
305 $facturestatic->type = $objp->type;
306 $facturestatic->total_ht = $objp->total_ht;
307 $facturestatic->total_tva = $objp->total_tva;
308 $facturestatic->total_ttc = $objp->total_ttc;
309 $facturestatic->statut = $objp->status;
310 $facturestatic->alreadypaid = -1;
312 print '<tr class="oddeven">';
315 print $facturestatic->getNomUrl(1);
318 print '<td>'.$objp->ref_supplier.
"</td>\n";
320 print '<td><a href="'.DOL_URL_ROOT.
'/fourn/card.php?socid='.$objp->socid.
'">'.
img_object($langs->trans(
'ShowCompany'),
'company').
' '.$objp->name.
'</a></td>';
322 print '<td class="right">'.price($objp->total_ttc).
'</td>';
324 print '<td class="right">'.price($objp->amount).
'</td>';
326 print '<td class="right">'.$facturestatic->LibStatut($objp->paye, $objp->status, 6, 1).
'</td>';
329 if ($objp->paye == 1)
332 $title_button =
dol_escape_htmltag($langs->transnoentitiesnoconv(
"CantRemovePaymentWithOneInvoicePaid"));
334 $total = $total + $objp->amount;
353 print '<div class="tabsAction">';
354 if (!empty($conf->global->BILL_ADD_PAYMENT_VALIDATION))
356 if ($user->socid == 0 && $object->statut == 0 && $action ==
'')
358 if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->fournisseur->facture->creer))
359 || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->fournisseur->supplier_invoice_advance->validate)))
361 print '<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=validate">'.$langs->trans(
'Valid').
'</a>';
365 if ($user->socid == 0 && $action ==
'')
367 if ($user->rights->fournisseur->facture->supprimer)
371 print '<a class="butActionDelete" href="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=delete&token='.
newToken().
'">'.$langs->trans(
'Delete').
'</a>';
373 print '<a class="butActionRefused classfortooltip" href="#" title="'.$title_button.
'">'.$langs->trans(
'Delete').
'</a>';
380 print '<div class="fichecenter"><div class="fichehalfleft">';
384 include_once DOL_DOCUMENT_ROOT.
'/core/modules/supplier_payment/modules_supplier_payment.php';
386 if (is_array($modellist))
390 $urlsource =
$_SERVER[
'PHP_SELF'].
'?id='.$object->id;
391 $genallowed = $user->rights->fournisseur->facture->lire;
392 $delallowed = $user->rights->fournisseur->facture->creer;
393 $modelpdf = (!empty($object->model_pdf) ? $object->model_pdf : (empty($conf->global->SUPPLIER_PAYMENT_ADDON_PDF) ?
'' : $conf->global->SUPPLIER_PAYMENT_ADDON_PDF));
395 print $formfile->showdocuments(
'supplier_payment', $ref, $filedir, $urlsource, $genallowed, $delallowed, $modelpdf, 1, 0, 0, 40, 0,
'',
'',
'', $societe->default_lang);
396 $somethingshown = $formfile->numoffiles;
399 print '</div><div class="fichehalfright"><div class="ficheaddleft">';
408 print '</div></div></div>';
410 $langs->load(
"errors");
411 print $langs->trans(
"ErrorRecordNotFound");
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...
static liste_modeles($db, $maxfilenamelength=0)
Return list of active generation models.
Class to manage bank transaction lines.
Class to manage suppliers invoices.
Class to manage bank accounts.
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
img_object($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
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 ...
dol_sanitizeFileName($str, $newstr= '_', $unaccent=1)
Clean a string to use it as a file name.
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...
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
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 payments for supplier invoices.
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...