32 require
'../../main.inc.php';
33 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
34 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
35 require_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
38 $langs->loadLangs(array(
'banks',
'categories',
'compta',
'bills',
'other'));
39 if (!empty($conf->adherent->enabled)) $langs->load(
"members");
40 if (!empty($conf->don->enabled)) $langs->load(
"donations");
41 if (!empty($conf->loan->enabled)) $langs->load(
"loan");
42 if (!empty($conf->salaries->enabled)) $langs->load(
"salaries");
47 $action =
GETPOST(
'action',
'aZ09');
48 $confirm =
GETPOST(
'confirm',
'alpha');
49 $rowid =
GETPOST(
"rowid",
'int');
50 $orig_account =
GETPOST(
"orig_account");
51 $backtopage =
GETPOST(
'backtopage',
'alpha');
52 $cancel =
GETPOST(
'cancel',
'alpha');
55 $fieldvalue = (!empty($id) ? $id : (!empty($ref) ? $ref :
''));
56 $fieldtype = (!empty($ref) ?
'ref' :
'rowid');
57 if ($user->socid) $socid = $user->socid;
58 $result =
restrictedArea($user,
'banque', $fieldvalue,
'bank_account',
'',
'', $fieldtype);
59 if (!$user->rights->banque->lire && !$user->rights->banque->consolidate)
accessforbidden();
61 $hookmanager->initHooks(array(
'bankline'));
67 $parameters = array(
'socid' => $socid);
68 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
69 if ($reshook < 0)
setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
74 header(
"Location: ".$backtopage);
80 if ($user->rights->banque->consolidate && $action ==
'donext')
83 $al->dateo_next($_GET[
"rowid"]);
84 } elseif ($user->rights->banque->consolidate && $action ==
'doprev')
87 $al->dateo_previous($_GET[
"rowid"]);
88 } elseif ($user->rights->banque->consolidate && $action ==
'dvnext')
91 $al->datev_next($_GET[
"rowid"]);
92 } elseif ($user->rights->banque->consolidate && $action ==
'dvprev')
95 $al->datev_previous($_GET[
"rowid"]);
98 if ($action ==
'confirm_delete_categ' && $confirm ==
"yes" && $user->rights->banque->modifier)
100 $cat1 =
GETPOST(
"cat1",
'int');
101 if (!empty($rowid) && !empty($cat1)) {
102 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"bank_class WHERE lineid = ".$rowid.
" AND fk_categ = ".$cat1;
103 if (!$db->query($sql))
112 if ($user->rights->banque->modifier && $action ==
"update")
117 $acline->fetch($rowid);
120 $acsource->fetch($id);
123 if (
GETPOST(
'accountid',
'int') > 0 && !$acline->rappro && !$acline->getVentilExportCompta())
125 $actarget->fetch(
GETPOST(
'accountid',
'int'));
127 $actarget->fetch($id);
132 setEventMessages($langs->trans(
"ErrorCashAccountAcceptsOnlyCashMoney"), null,
'errors');
141 $dateop =
dol_mktime(12, 0, 0, $_POST[
"dateomonth"], $_POST[
"dateoday"], $_POST[
"dateoyear"]);
142 $dateval =
dol_mktime(12, 0, 0, $_POST[
"datevmonth"], $_POST[
"datevday"], $_POST[
"datevyear"]);
143 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"bank";
151 if (!$acline->rappro)
154 if (
GETPOSTISSET(
'amount')) $sql .=
" amount= '".$db->escape($amount).
"',";
155 if (
GETPOSTISSET(
'dateomonth')) $sql .=
" dateo = '".$db->idate($dateop).
"',";
156 if (
GETPOSTISSET(
'datevmonth')) $sql .=
" datev = '".$db->idate($dateval).
"',";
158 $sql .=
" fk_account = ".$actarget->id;
159 $sql .=
" WHERE rowid = ".$acline->id;
161 $result = $db->query($sql);
169 $arrayofcategs =
GETPOST(
'custcats',
'array');
170 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"bank_class WHERE lineid = ".$rowid;
171 if (!$db->query($sql))
176 if (count($arrayofcategs))
178 foreach ($arrayofcategs as $val)
180 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"bank_class (lineid, fk_categ) VALUES (".$rowid.
", ".$val.
")";
181 if (!$db->query($sql))
203 if ($user->rights->banque->consolidate && ($action ==
'num_releve' || $action ==
'setreconcile'))
205 $num_rel = trim($_POST[
"num_rel"]);
206 $rappro = $_POST[
'reconciled'] ? 1 : 0;
209 if ($rappro && empty($num_rel))
211 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"AccountStatement")), null,
'errors');
219 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"bank";
220 $sql .=
" SET num_releve=".($num_rel ?
"'".$db->escape($num_rel).
"'" :
"null");
221 if (empty($num_rel)) $sql .=
", rappro = 0";
222 else $sql .=
", rappro = ".$rappro;
223 $sql .=
" WHERE rowid = ".$rowid;
226 $result = $db->query($sql);
244 $form =
new Form($db);
246 llxHeader(
'', $langs->trans(
"BankTransaction"));
249 $cats = $c->containing($rowid, Categorie::TYPE_BANK_LINE);
250 foreach ($cats as $cat) {
251 $arrayselected[] = $cat->id;
254 $head = bankline_prepare_head($rowid);
257 $sql =
"SELECT b.rowid,b.dateo as do,b.datev as dv, b.amount, b.label, b.rappro,";
258 $sql .=
" b.num_releve, b.fk_user_author, b.num_chq, b.fk_type, b.fk_account, b.fk_bordereau as receiptid,";
259 $sql .=
" b.emetteur,b.banque";
260 $sql .=
" FROM ".MAIN_DB_PREFIX.
"bank as b";
261 $sql .=
" WHERE rowid=".$rowid;
262 $sql .=
" ORDER BY dateo ASC";
263 $result = $db->query($sql);
267 if ($db->num_rows($result))
269 $objp = $db->fetch_object($result);
271 $total = $total + $objp->amount;
274 $acct->fetch($objp->fk_account);
275 $account = $acct->id;
278 $bankline->fetch($rowid, $ref);
280 $links = $acct->get_url($rowid);
281 $bankline->load_previous_next_ref(
'',
'rowid');
284 if ($action ==
'delete_categ')
286 print $form->formconfirm(
$_SERVER[
'PHP_SELF'].
"?rowid=".$rowid.
"&cat1=".
GETPOST(
"fk_categ").
"&orig_account=".$orig_account, $langs->trans(
"RemoveFromRubrique"), $langs->trans(
"RemoveFromRubriqueConfirm"),
"confirm_delete_categ",
'',
'yes', 1);
289 print '<form name="update" method="POST" action="'.$_SERVER[
'PHP_SELF'].
'?rowid='.$rowid.
'">';
290 print '<input type="hidden" name="token" value="'.newToken().
'">';
291 print '<input type="hidden" name="action" value="update">';
292 print '<input type="hidden" name="orig_account" value="'.$orig_account.
'">';
293 print '<input type="hidden" name="id" value="'.$acct->id.
'">';
297 $linkback =
'<a href="'.DOL_URL_ROOT.
'/compta/bank/bankentries_list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
302 print '<div class="fichecenter2">';
304 print '<div class="underbanner clearboth"></div>';
305 print '<table class="border centpercent tableforfield">';
310 print '<tr><td class="titlefieldcreate">'.$langs->trans(
"Account").
'</td>';
312 if (!$objp->rappro && !$bankline->getVentilExportCompta())
315 print $form->select_comptes($acct->id,
'accountid', 0,
'', 0,
'', 0,
'', 1);
317 print $acct->getNomUrl(1,
'transactions',
'reflabel');
325 print '<tr><td class="tdtop">'.$langs->trans(
"Links").
'</td>';
327 foreach ($links as $key=>$val)
329 if ($key)
print '<br>';
330 if ($links[$key][
'type'] ==
'payment') {
331 require_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
333 $paymenttmp->fetch($links[$key][
'url_id']);
334 $paymenttmp->ref = $langs->trans(
"Payment").
' '.$paymenttmp->ref;
339 print $paymenttmp->getNomUrl(1);
340 } elseif ($links[$key][
'type'] ==
'payment_supplier') {
341 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/paiementfourn.class.php';
343 $paymenttmp->fetch($links[$key][
'url_id']);
344 $paymenttmp->ref = $langs->trans(
"Payment").
' '.$paymenttmp->ref;
349 print $paymenttmp->getNomUrl(1);
350 } elseif ($links[$key][
'type'] ==
'company') {
352 $societe->fetch($links[$key][
'url_id']);
353 print $societe->getNomUrl(1);
354 } elseif ($links[$key][
'type'] ==
'sc') {
355 print '<a href="'.DOL_URL_ROOT.
'/compta/sociales/card.php?id='.$links[$key][
'url_id'].
'">';
357 print $langs->trans(
"SocialContribution").($links[$key][
'label'] ?
' - '.$links[$key][
'label'] :
'');
359 } elseif ($links[$key][
'type'] ==
'payment_sc') {
360 print '<a href="'.DOL_URL_ROOT.
'/compta/payment_sc/card.php?id='.$links[$key][
'url_id'].
'">';
362 print $langs->trans(
"SocialContributionPayment");
364 } elseif ($links[$key][
'type'] ==
'payment_vat') {
365 print '<a href="'.DOL_URL_ROOT.
'/compta/tva/card.php?id='.$links[$key][
'url_id'].
'">';
367 print $langs->trans(
"VATPayment");
369 } elseif ($links[$key][
'type'] ==
'payment_salary') {
370 print '<a href="'.DOL_URL_ROOT.
'/salaries/card.php?id='.$links[$key][
'url_id'].
'">';
372 print $langs->trans(
"SalaryPayment");
374 } elseif ($links[$key][
'type'] ==
'payment_loan') {
375 print '<a href="'.DOL_URL_ROOT.
'/loan/payment/card.php?id='.$links[$key][
'url_id'].
'">';
377 print $langs->trans(
"PaymentLoan");
379 } elseif ($links[$key][
'type'] ==
'loan') {
380 print '<a href="'.DOL_URL_ROOT.
'/loan/card.php?id='.$links[$key][
'url_id'].
'">';
382 print $langs->trans(
"Loan");
384 } elseif ($links[$key][
'type'] ==
'member') {
385 print '<a href="'.DOL_URL_ROOT.
'/adherents/card.php?rowid='.$links[$key][
'url_id'].
'">';
387 print $links[$key][
'label'];
389 } elseif ($links[$key][
'type'] ==
'payment_donation') {
390 print '<a href="'.DOL_URL_ROOT.
'/don/payment/card.php?id='.$links[$key][
'url_id'].
'">';
392 print $langs->trans(
"DonationPayment");
394 } elseif ($links[$key][
'type'] ==
'banktransfert') {
395 print '<a href="'.DOL_URL_ROOT.
'/compta/bank/line.php?rowid='.$links[$key][
'url_id'].
'">';
397 print $langs->trans(
"TransactionOnTheOtherAccount");
399 } elseif ($links[$key][
'type'] ==
'user') {
400 print '<a href="'.DOL_URL_ROOT.
'/user/card.php?id='.$links[$key][
'url_id'].
'">';
402 print $langs->trans(
"User");
404 } elseif ($links[$key][
'type'] ==
'payment_various') {
405 print '<a href="'.DOL_URL_ROOT.
'/compta/bank/various_payment/card.php?id='.$links[$key][
'url_id'].
'">';
407 print $langs->trans(
"VariousPayment");
410 print '<a href="'.$links[$key][
'url'].$links[$key][
'url_id'].
'">';
412 print $links[$key][
'label'];
423 print "<tr><td>".$langs->trans(
"Type").
" / ".$langs->trans(
"Numero");
424 print ' <em>('.$langs->trans(
"ChequeOrTransferNumber").
')</em>';
426 if ($user->rights->banque->modifier || $user->rights->banque->consolidate)
429 $form->select_types_paiements($objp->fk_type,
"value",
'', 2);
430 print '<input type="text" class="flat" name="num_chq" value="'.(empty($objp->num_chq) ?
'' : $objp->num_chq).
'">';
431 if ($objp->receiptid)
433 include_once DOL_DOCUMENT_ROOT.
'/compta/paiement/cheque/class/remisecheque.class.php';
435 $receipt->fetch($objp->receiptid);
436 print ' '.$langs->trans(
"CheckReceipt").
': '.$receipt->getNomUrl(2);
440 print '<td>'.$objp->fk_type.
' '.$objp->num_chq.
'</td>';
445 print "<tr><td>".$langs->trans(
"CheckTransmitter");
446 print ' <em>('.$langs->trans(
"ChequeMaker").
')</em>';
448 if ($user->rights->banque->modifier || $user->rights->banque->consolidate)
451 print '<input type="text" class="flat minwidth200" name="emetteur" value="'.(empty($objp->emetteur) ?
'' : stripslashes($objp->emetteur)).
'">';
454 print '<td>'.$objp->emetteur.
'</td>';
459 print "<tr><td>".$langs->trans(
"Bank");
460 print ' <em>('.$langs->trans(
"ChequeBank").
')</em>';
462 if ($user->rights->banque->modifier || $user->rights->banque->consolidate)
465 print '<input type="text" class="flat minwidth200" name="banque" value="'.(empty($objp->banque) ?
'' : $objp->banque).
'">';
468 print '<td>'.$objp->banque.
'</td>';
473 print '<tr><td>'.$langs->trans(
"DateOperation").
'</td>';
474 if ($user->rights->banque->modifier || $user->rights->banque->consolidate)
477 print $form->selectDate($db->jdate($objp->do),
'dateo',
'',
'',
'',
'update', 1, 0, $objp->rappro);
481 print '<a href="'.$_SERVER[
'PHP_SELF'].
'?action=doprev&id='.$id.
'&rowid='.$objp->rowid.
'">';
483 print '<a href="'.$_SERVER[
'PHP_SELF'].
'?action=donext&id='.$id.
'&rowid='.$objp->rowid.
'">';
495 print "<tr><td>".$langs->trans(
"DateValue").
"</td>";
496 if ($user->rights->banque->modifier || $user->rights->banque->consolidate)
499 print $form->selectDate($db->jdate($objp->dv),
'datev',
'',
'',
'',
'update', 1, 0, $objp->rappro);
503 print '<a href="'.$_SERVER[
'PHP_SELF'].
'?action=dvprev&id='.$id.
'&rowid='.$objp->rowid.
'">';
505 print '<a href="'.$_SERVER[
'PHP_SELF'].
'?action=dvnext&id='.$id.
'&rowid='.$objp->rowid.
'">';
517 print "<tr><td>".$langs->trans(
"Label").
"</td>";
518 if ($user->rights->banque->modifier || $user->rights->banque->consolidate)
521 print '<input name="label" class="flat minwidth300" '.($objp->rappro ?
' disabled' :
'').
' value="';
522 if (preg_match(
'/^\((.*)\)$/i', $objp->label, $reg))
525 print $langs->trans($reg[1]);
533 if (preg_match(
'/^\((.*)\)$/i', $objp->label, $reg))
536 print $langs->trans($reg[1]);
545 print "<tr><td>".$langs->trans(
"Amount").
"</td>";
546 if ($user->rights->banque->modifier)
549 print '<input name="amount" class="flat maxwidth100" '.($objp->rappro ?
' disabled' :
'').
' value="'.
price($objp->amount).
'"> '.$langs->trans(
"Currency".$acct->currency_code);
559 if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire))
561 $langs->load(
'categories');
564 print '<tr><td class="toptd">'.$form->editfieldkey(
'RubriquesTransactions',
'custcats',
'', $object, 0).
'</td><td>';
565 $cate_arbo = $form->select_all_categories(Categorie::TYPE_BANK_LINE, null,
'parent', null, null, 1);
566 print img_picto(
'',
'category',
'class="paddingright"').$form->multiselectarray(
'custcats', $cate_arbo, $arrayselected, null, null, null, null,
"90%");
577 print '<div class="center"><input type="submit" class="button" value="'.$langs->trans(
"Update").
'"></div><br>';
584 if ($acct->canBeConciliated() > 0)
589 print '<form method="POST" action="'.$_SERVER[
'PHP_SELF'].
'?rowid='.$objp->rowid.
'">';
590 print '<input type="hidden" name="token" value="'.newToken().
'">';
591 print '<input type="hidden" name="action" value="setreconcile">';
592 print '<input type="hidden" name="orig_account" value="'.$orig_account.
'">';
593 print '<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
595 print '<div class="fichecenter">';
597 print '<table class="border centpercent">';
599 print '<tr><td class="titlefield">'.$langs->trans(
"Conciliation").
"</td>";
600 if ($user->rights->banque->consolidate)
605 print $langs->trans(
"AccountStatement").
' <input name="num_rel_bis" class="flat" value="'.$objp->num_releve.
'"'.($objp->rappro ?
' disabled' :
'').
'>';
606 print '<input name="num_rel" type="hidden" value="'.$objp->num_releve.
'">';
608 print $langs->trans(
"AccountStatement").
' <input name="num_rel" class="flat" value="'.$objp->num_releve.
'"'.($objp->rappro ?
' disabled' :
'').
'>';
610 if ($objp->num_releve)
print ' (<a href="'.DOL_URL_ROOT.
'/compta/bank/releve.php?num='.$objp->num_releve.
'&account='.$acct->id.
'">'.$langs->trans(
"AccountStatement").
' '.$objp->num_releve.
')</a>';
613 print '<td>'.$objp->num_releve.
' </td>';
617 print "<tr><td>".$langs->trans(
"BankLineConciliated").
"</td>";
618 if ($user->rights->banque->consolidate)
621 print '<input type="checkbox" name="reconciled" class="flat" '.(GETPOSTISSET(
"reconciled") ? (
GETPOST(
"reconciled") ?
' checked="checked"' :
'') : ($objp->rappro ?
' checked="checked"' :
'')).
'">';
624 print '<td>'.yn($objp->rappro).
'</td>';
631 print '<div class="center">';
633 print '<input type="submit" class="button" value="'.$langs->trans(
"Update").
'">';
637 print '<input type="submit" name="cancel" class="button button-cancel" value="'.$langs->trans(
"Cancel").
'">';
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.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage categories.
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
price2num($amount, $rounding= '', $option=0)
Function that return a number with universal decimal format (decimal separator is '...
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt= '', $morecss= '', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
Class to manage payments of customer invoices.
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 ...
const TYPE_CASH
Cash account.
print $_SERVER["PHP_SELF"]
Edit parameters.
img_edit_add($titlealt= 'default', $other= '')
Show logo +.
img_edit_remove($titlealt= 'default', $other= '')
Show logo -.
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.
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
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.
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.
Class to manage cheque delivery receipts.