31require
'../../main.inc.php';
32require_once DOL_DOCUMENT_ROOT.
'/core/lib/accounting.lib.php';
33require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/bookkeeping.class.php';
34require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formaccounting.class.php';
35require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
36require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
37require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/accountingjournal.class.php';
38require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/accountingaccount.class.php';
39require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/lettering.class.php';
50$langs->loadLangs(array(
"accountancy",
"bills",
"compta",
"errors"));
52$action =
GETPOST(
'action',
'aZ09');
53$cancel =
GETPOST(
'cancel',
'alpha');
54$confirm =
GETPOST(
'confirm',
'alpha');
56$type =
GETPOST(
'type',
'alpha');
57$backtopage =
GETPOST(
'backtopage',
'alpha');
58if (empty($backtopage)) {
59 $backtopage = DOL_URL_ROOT .
'/accountancy/bookkeeping/list.php';
62$optioncss =
GETPOST(
'optioncss',
'aZ');
72$accountingaccount_number =
GETPOST(
'accountingaccount_number',
'alphanohtml');
73$accountingaccount->fetch(0, $accountingaccount_number,
true);
74$accountingaccount_label = $accountingaccount->label;
76$journal_code =
GETPOST(
'code_journal',
'alpha');
77$accountingjournal->fetch(0, $journal_code);
78$journal_label = $accountingjournal->label;
80$subledger_account =
GETPOST(
'subledger_account',
'alphanohtml');
81if ($subledger_account == -1) {
82 $subledger_account =
null;
84$subledger_label =
GETPOST(
'subledger_label',
'alphanohtml');
86$label_operation =
GETPOST(
'label_operation',
'alphanohtml');
90$save =
GETPOST(
'save',
'alpha');
94$update =
GETPOST(
'update',
'alpha');
96 $action =
'confirm_update';
100$hookmanager->initHooks(array(
'bookkeepingcard',
'globalcard'));
108if ($user->socid > 0) {
111if (!$user->hasRight(
'accounting',
'mouvements',
'lire')) {
115$permissiontoadd = $user->hasRight(
'accounting',
'mouvements',
'creer');
116$permissiontodelete = $user->hasRight(
'accounting',
'mouvements',
'supprimer');
123$parameters = array();
124$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
128if (empty($reshook)) {
132 header(
"Location: ". $backtopage . (!empty($type) ?
'?type=sub' :
''));
136 if ($action ==
"confirm_update" && $permissiontoadd) {
137 if (((
float) $debit != 0.0) && ((
float) $credit != 0.0)) {
142 if (empty($accountingaccount_number) || $accountingaccount_number ==
'-1') {
144 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
"AccountAccountingShort")),
null,
'errors');
151 $result =
$object->fetch($id,
null, $mode);
156 $object->numero_compte = $accountingaccount_number;
157 $object->subledger_account = $subledger_account;
158 $object->subledger_label = $subledger_label;
159 $object->label_compte = $accountingaccount_label;
160 $object->label_operation = $label_operation;
164 if ((
float) $debit != 0.0) {
169 if ((
float) $credit != 0.0) {
175 $result =
$object->update($user, 0, $mode);
179 if ($mode !=
'_tmp') {
190 } elseif ($action ==
"add" && $permissiontoadd) {
191 if (((
float) $debit != 0.0) && ((
float) $credit != 0.0)) {
196 if (empty($accountingaccount_number) || $accountingaccount_number ==
'-1') {
198 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
"AccountAccountingShort")),
null,
'errors');
201 $subledger_account_str = is_array($subledger_account) ? reset($subledger_account) : (string) $subledger_account;
204 setEventMessages($langs->trans(
"ErrorAccountNotCentralized").
". " . $langs->trans(
"RemoveSubsidiaryAccountOrAdjustTheGeneralAccount"),
null,
'errors');
216 $object->numero_compte = $accountingaccount_number;
217 $object->subledger_account = $subledger_account;
218 $object->subledger_label = $subledger_label;
219 $object->label_compte = $accountingaccount_label;
220 $object->label_operation = $label_operation;
225 $object->piece_num = $piece_num;
228 $object->code_journal = $journal_code;
229 $object->journal_label = $journal_label;
233 if ((
float) $debit != 0.0) {
239 if ((
float) $credit != 0.0) {
245 $result =
$object->createStd($user, 0, $mode);
250 if ($mode !=
'_tmp') {
260 } elseif ($action ==
"confirm_delete" && $permissiontoadd) {
263 $result =
$object->fetch($id,
null, $mode);
264 $piece_num = (int)
$object->piece_num;
269 } elseif ($result > 0) {
270 $result =
$object->delete($user, 0, $mode);
276 } elseif ($action ==
"confirm_create" && $permissiontoadd) {
279 if (!$journal_code || $journal_code ==
'-1') {
280 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
"Journal")),
null,
'errors');
284 if (!
GETPOST(
'doc_ref',
'alpha')) {
285 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Piece")),
null,
'errors');
290 setEventMessages($langs->trans(
"ErrorFieldTooLong", $langs->transnoentitiesnoconv(
"Ref")),
null,
'errors');
301 $object->doc_date = $date_start;
305 $object->code_journal = $journal_code;
306 $object->journal_label = $journal_label;
313 $result =
$object->createStd($user, 0, $mode);
320 $reshook = $hookmanager->executeHooks(
'afterCreateBookkeeping', $parameters, $object, $action);
322 if ($mode !=
'_tmp') {
327 $piece_num = (int)
$object->piece_num;
332 if ($action ==
'setdate' && $permissiontoadd) {
334 $result =
$object->updateByMvt($piece_num,
'doc_date', $db->idate($datedoc), $mode);
338 if ($mode !=
'_tmp') {
345 if ($action ==
'setjournal' && $permissiontoadd) {
346 $result =
$object->updateByMvt($piece_num,
'code_journal', $journal_code, $mode);
347 $result =
$object->updateByMvt($piece_num,
'journal_label', $journal_label, $mode);
351 if ($mode !=
'_tmp') {
358 if ($action ==
'setdocref' && $permissiontoadd) {
359 $refdoc =
GETPOST(
'doc_ref',
'alpha');
360 $result =
$object->updateByMvt($piece_num,
'doc_ref', $refdoc, $mode);
364 if ($mode !=
'_tmp') {
371 if ($action ==
'setref' && $permissiontoadd && $numRefModel ===
'mod_bookkeeping_neon') {
372 $newref =
GETPOST(
'ref',
'alpha');
375 $object->error = $langs->trans(
"ErrorFieldTooLong", $langs->transnoentitiesnoconv(
"Ref"));
378 $result =
$object->updateByMvt($piece_num,
'ref', $newref, $mode);
383 if ($mode !=
'_tmp') {
391 if ($action ==
'valid' && $permissiontoadd) {
392 $result =
$object->transformTransaction(0, $piece_num);
396 header(
"Location: " . $backtopage .
"?sortfield=t.piece_num&sortorder=asc" . ($type ?
'&type='.$type :
''));
402 $toselect_str = explode(
',',
GETPOST(
'toselect',
'alphanohtml'));
404 foreach ($toselect_str as $i) {
405 $toselect[] = (int) $i;
408 if ($action ==
'deletebookkeepingwriting' && $confirm ==
"yes" && $permissiontodelete) {
413 $nb_lettering = $lettering->bookkeepingLetteringAll($toselect,
true);
414 if ($nb_lettering < 0) {
423 foreach ($toselect as $toselectid) {
424 $result =
$object->fetch($toselectid);
425 if ($result >= 0 && (!isset(
$object->date_validation) ||
$object->date_validation ===
'')) {
434 } elseif ($result < 0) {
438 } elseif (isset(
$object->date_validation) &&
$object->date_validation !=
'') {
439 setEventMessages($langs->trans(
"ValidatedRecordWhereFound"),
null,
'errors');
452 } elseif ($nbok > 0) {
458 header(
"Location: ".DOL_URL_ROOT.
'/accountancy/bookkeeping/list.php?noreset=1');
465 if ($action ==
'clonebookkeepingwriting' && $confirm ==
"yes" && $permissiontoadd) {
467 $piece_num =
GETPOST(
'piece_num',
'alpha');
468 $journal_code =
GETPOST(
'code_journal',
'alpha');
473 $result =
$object->newClone($piece_num, $journal_code, $clonedate);
481 header(
"Location: " . $_SERVER[
'PHP_SELF'] .
"?piece_num=" . (
$object->getNextNumMvt() - 1));
495$form =
new Form($db);
498$title = $langs->trans(
"CreateMvts");
499$help_url =
'EN:Module_Double_Entry_Accounting|FR:Module_Comptabilité_en_Partie_Double';
501llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-accountancy accountancy-consultation page-card');
504if ($action ==
'delete') {
505 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$id.
'&mode='.$mode, $langs->trans(
'DeleteMvt'), $langs->trans(
'ConfirmDeleteMvt', $langs->transnoentitiesnoconv(
"RegistrationInAccounting")),
'confirm_delete',
'', 0, 1);
510if (!empty($conf->use_javascript_ajax)) {
511 print
"\n" .
'<script type="text/javascript">';
512 print
'$(document).ready(function () {
513 function toggleSubledger() {
514 var isCentral = $("#accountingaccount_number option:selected").data("centralized");
515 console.log("the selected general ledger account is centralised?", isCentral);
517 $("#subledger_account, #subledger_label").prop("disabled", false);
519 $("#subledger_account, #subledger_label").prop("disabled", true);
525 $("#accountingaccount_number").on("change", toggleSubledger);
526 $("#accountingaccount_number").on("select2:select", toggleSubledger);
529 print
' </script>' .
"\n";
532if ($action ==
'create') {
536 $next_num_mvt =
$object->getNextNumMvt(
'_tmp');
538 if (empty($next_num_mvt)) {
542 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" name="create_mvt" method="POST">';
543 if ($optioncss !=
'') {
544 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
546 print
'<input type="hidden" name="token" value="'.newToken().
'">';
547 print
'<input type="hidden" name="action" value="confirm_create">'.
"\n";
548 print
'<input type="hidden" name="next_num_mvt" value="'.$next_num_mvt.
'">'.
"\n";
549 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
550 print
'<input type="hidden" name="type" value="'.$type.
'">';
551 print
'<input type="hidden" name="mode" value="_tmp">'.
"\n";
555 print
'<table class="border centpercent">';
558 print
'<td class="fieldrequired">'.$langs->trans(
"Docdate").
'</td>';
560 print $form->selectDate(
'',
'doc_date', 0, 0, 0,
"create_mvt", 1, 1);
565 print
'<td class="fieldrequired">'.$langs->trans(
"Codejournal").
'</td>';
566 print
'<td>'.$formaccounting->select_journal($journal_code,
'code_journal', 0, 0, 1, 1).
'</td>';
570 print
'<td class="fieldrequired">'.$form->textwithpicto($langs->trans(
"Piece"), $langs->trans(
"PieceDesc")).
'</td>';
571 print
'<td><input type="text" class="minwidth200" name="doc_ref" value="'.GETPOST(
'doc_ref',
'alpha').
'"></td>';
576 print
'<td>'.$form->textwithpicto($langs->trans(
"Ref"), $langs->trans(
"BankTransactionRef")).
'</td>';
578 if ($numRefModel ===
'mod_bookkeeping_neon') {
579 print
'<input type="text" class="minwidth200" name="ref" maxlength="30" value="">';
581 print
'<span class="opacitymedium">'.$langs->trans(
"Automatic").
'</span>';
592 $reshookAddLine = $hookmanager->executeHooks(
'bookkeepingAddLine', $parameters, $object, $action);
598 print $form->buttonsSaveCancel(
"Create");
604 $result =
$object->fetchPerMvt($piece_num, $mode);
609 if (!empty(
$object->piece_num)) {
610 $backlink =
'<a href="'.DOL_URL_ROOT.
'/accountancy/bookkeeping/list.php?restore_lastsearch_values=1">'.$langs->trans(
'BackToList').
'</a>';
623 if ($mode ==
'_tmp') {
624 $object->context[
'mode'] = $mode;
625 $object->next_prev_filter =
'1=0';
629 $morehtmlref =
'<div style="clear: both;"></div>';
630 $morehtmlref .=
'<div class="refidno opacitymedium">';
631 $morehtmlref .=
$object->label;
632 $morehtmlref .=
'</div>';
634 dol_banner_tab($object,
'ref', $backlink, 1,
'piece_num',
'piece_num', $morehtmlref);
637 if ($action ==
'clonebookkeepingwriting' && $confirm !=
'yes' && $permissiontoadd) {
638 $piece_num =
GETPOST(
'piece_num',
'alpha');
641 $form =
new Form($db);
642 $input1 = $form->selectDate(
'',
'clonedate', 0, 0, 0,
"", 1, 1);
643 $input2 = $formaccounting->select_journal($journal_code,
'code_journal', 0, 0, 1, 1);
645 $formquestion = array(
648 'name' =>
'clonedate',
649 'label' =>
'<span class="fieldrequired">' . $langs->trans(
"Docdate") .
'</span>',
654 $formquestion[] = array(
'type' =>
'hidden',
'name' =>
'piece_num',
'value' => $piece_num);
657 $formquestion[] = array(
659 'name' =>
'code_journal',
660 'label' =>
'<span class="fieldrequired">' . $langs->trans(
"Codejournal") .
'</span>',
665 print $form->formconfirm(
666 $_SERVER[
"PHP_SELF"],
667 $langs->trans(
"ConfirmMassCloneBookkeepingWriting"),
668 $langs->trans(
"ConfirmMassCloneBookkeepingWritingQuestion", 1),
669 "clonebookkeepingwriting",
676 print
'<div class="fichecenter">';
678 print
'<div class="fichehalfleft">';
680 print
'<div class="underbanner clearboth"></div>';
681 print
'<table class="border tableforfield centpercent">';
692 print
'<tr><td class="titlefieldmiddle">';
693 print
'<table class="nobordernopadding centpercent"><tr><td>';
694 print $langs->trans(
'Ref');
696 if ($action !=
'editref' && empty(
$object->date_validation)) {
697 print
'<td class="right">';
698 if ($permissiontoadd && $numRefModel ===
'mod_bookkeeping_neon') {
699 print
'<a class="editfielda reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=editref&token='.
newToken().
'&piece_num='.((int)
$object->piece_num).
'&mode='.urlencode((
string) $mode).
'">'.
img_edit($langs->transnoentitiesnoconv(
'Edit'), 1).
'</a>';
703 print
'</tr></table>';
705 if ($action ==
'editref' && empty(
$object->date_validation)) {
706 print
'<form name="setref" action="'.$_SERVER[
"PHP_SELF"].
'?piece_num='.((int)
$object->piece_num).
'" method="POST">';
707 if ($optioncss !=
'') {
708 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
710 print
'<input type="hidden" name="token" value="'.newToken().
'">';
711 print
'<input type="hidden" name="action" value="setref">';
712 print
'<input type="hidden" name="mode" value="'.$mode.
'">';
713 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
714 print
'<input type="hidden" name="type" value="'.$type.
'">';
715 print
'<input type="text" size="20" name="ref" maxlength="30" value="'.dol_escape_htmltag(
$object->ref).
'">';
716 print
'<input type="submit" class="button button-edit smallpaddingimp" value="'.$langs->trans(
'Modify').
'">';
726 print
'<table class="nobordernopadding centpercent"><tr><td>';
727 print $form->textwithpicto($langs->trans(
'Piece'), $langs->trans(
'PieceDesc'));
729 if ($action !=
'editdocref') {
730 print
'<td class="right">';
731 if ($permissiontoadd && empty(
$object->date_validation)) {
732 print
'<a class="editfielda reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=editdocref&token='.
newToken().
'&piece_num='.((int)
$object->piece_num).
'&mode='.urlencode((
string) $mode).
'">'.
img_edit($langs->transnoentitiesnoconv(
'Edit'), 1).
'</a>';
736 print
'</tr></table>';
738 if ($action ==
'editdocref' && empty(
$object->date_validation)) {
739 print
'<form name="setdocref" action="'.$_SERVER[
"PHP_SELF"].
'?piece_num='.((int)
$object->piece_num).
'" method="POST">';
740 if ($optioncss !=
'') {
741 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
743 print
'<input type="hidden" name="token" value="'.newToken().
'">';
744 print
'<input type="hidden" name="action" value="setdocref">';
745 print
'<input type="hidden" name="mode" value="'.$mode.
'">';
746 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
747 print
'<input type="hidden" name="type" value="'.$type.
'">';
748 print
'<input type="text" size="20" name="doc_ref" value="'.dol_escape_htmltag(
$object->doc_ref).
'">';
749 print
'<input type="submit" class="button button-edit smallpaddingimp" value="'.$langs->trans(
'Modify').
'">';
759 print
'<table class="nobordernopadding centpercent"><tr><td>';
760 print $langs->trans(
'Docdate');
762 if ($action !=
'editdate') {
763 print
'<td class="right">';
764 if ($permissiontoadd && empty(
$object->date_validation)) {
765 print
'<a class="editfielda reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=editdate&token='.
newToken().
'&piece_num='.((int)
$object->piece_num).
'&mode='.urlencode((
string) $mode).
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetDate'), 1).
'</a>';
769 print
'</tr></table>';
770 print
'</td><td colspan="3">';
771 if ($action ==
'editdate' && empty(
$object->date_validation)) {
772 print
'<form name="setdate" action="'.$_SERVER[
"PHP_SELF"].
'?piece_num='.((int)
$object->piece_num).
'" method="POST">';
773 if ($optioncss !=
'') {
774 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
776 print
'<input type="hidden" name="token" value="'.newToken().
'">';
777 print
'<input type="hidden" name="action" value="setdate">';
778 print
'<input type="hidden" name="mode" value="'.$mode.
'">';
779 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
780 print
'<input type="hidden" name="type" value="'.$type.
'">';
781 print $form->selectDate(
$object->doc_date ?
$object->doc_date : -1,
'doc_date', 0, 0, 0,
"setdate");
782 print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
'Modify').
'">';
792 print
'<table class="nobordernopadding centpercent"><tr><td>';
793 print $langs->trans(
'Codejournal');
795 if ($action !=
'editjournal') {
796 print
'<td class="right">';
797 if ($permissiontoadd && empty(
$object->date_validation)) {
798 print
'<a class="editfielda reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=editjournal&token='.
newToken().
'&piece_num='.((int)
$object->piece_num).
'&mode='.urlencode((
string) $mode).
'">'.
img_edit($langs->transnoentitiesnoconv(
'Edit'), 1).
'</a>';
802 print
'</tr></table>';
804 if ($action ==
'editjournal' && empty(
$object->date_validation)) {
805 print
'<form name="setjournal" action="'.$_SERVER[
"PHP_SELF"].
'?piece_num='.((int)
$object->piece_num).
'" method="POST">';
806 if ($optioncss !=
'') {
807 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
809 print
'<input type="hidden" name="token" value="'.newToken().
'">';
810 print
'<input type="hidden" name="action" value="setjournal">';
811 print
'<input type="hidden" name="mode" value="'.$mode.
'">';
812 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
813 print
'<input type="hidden" name="type" value="'.$type.
'">';
814 print $formaccounting->select_journal(
$object->code_journal,
'code_journal', 0, 0, 0, 1,
'');
815 print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
'Modify').
'">';
828 print
'<div class="fichehalfright">';
830 print
'<div class="underbanner clearboth"></div>';
831 print
'<table class="border tableforfield centpercent">';
834 if (!empty(
$object->doc_type)) {
836 print
'<td class="titlefield">'.$langs->trans(
"Doctype").
'</td>';
837 print
'<td>'.$object->doc_type.
'</td>';
843 print
'<td class="titlefield">'.$langs->trans(
"DateCreation").
'</td>';
852 print
'<td class="titlefield">' . $form->textwithpicto($langs->trans(
'DateDue'), $langs->trans(
"IfTransactionHasDueDate")) .
'</td>';
860 if ($mode !=
"_tmp") {
863 print
'<td class="titlefield">' . $langs->trans(
"DateExport") .
'</td>';
865 print
$object->date_export ?
img_picto($langs->trans(
"TransactionExportDesc"),
'fa-file-export',
'class="pictofixedwidth opacitymedium"').dol_print_date(
$object->date_export,
'dayhour') :
' ';
871 print
'<td class="titlefield">' . $langs->trans(
"DateValidation") .
'</td>';
873 print
$object->date_validation ?
img_picto($langs->trans(
"TransactionBlockedLockedDesc"),
'fa-lock',
'class="pictofixedwidth opacitymedium"').dol_print_date(
$object->date_validation,
'dayhour') :
' ';
878 if (!empty(
$object->import_key)) {
880 print
'<td class="titlefield">' . $langs->trans(
"ImportId") .
'</td>';
933 print
'<div class="clearboth"></div>';
939 $result =
$object->fetchAllPerMvt($piece_num, $mode);
945 $tmptoselect = array();
946 $atleastonevalidated = 0;
947 $atleastoneexported = 0;
948 foreach (
$object->linesmvt as $line) {
949 $tmptoselect[] = $line->id;
950 if (!empty($line->date_validation)) {
951 $atleastonevalidated = 1;
953 if (!empty($line->date_export) || !empty($line->date_validation)) {
954 $atleastoneexported = 1;
958 if ($mode !=
'_tmp' && !$atleastonevalidated) {
959 print
"\n".
'<div class="tabsAction">'.
"\n";
961 $parameters = array();
962 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
963 if (empty($reshook)) {
964 if ($permissiontodelete) {
965 if (!isset($hookmanager->resArray[
'no_button_edit']) || $hookmanager->resArray[
'no_button_edit'] != 1) {
966 print
dolGetButtonAction(
'', $langs->trans(
'Delete'),
'delete', DOL_URL_ROOT.
'/accountancy/bookkeeping/card.php?action=deletebookkeepingwriting&confirm=yes&token='.
newToken().
'&piece_num='.((
int)
$object->piece_num).
'&toselect='.implode(
',', $tmptoselect),
'', $permissiontodelete);
969 if ($permissiontoadd) {
970 print
dolGetButtonAction(
'', $langs->trans(
'Clone'),
'clone', DOL_URL_ROOT.
'/accountancy/bookkeeping/card.php?action=clonebookkeepingwriting&token=' .
newToken() .
'&piece_num=' . ((
int)
$object->piece_num) .
'&toselect=' . implode(
',', $tmptoselect),
'action-clone', $permissiontoadd);
980 if (empty(
$object->date_validation)) {
981 print
'<form action="' . $_SERVER[
"PHP_SELF"] .
'?piece_num=' . ((int)
$object->piece_num) .
'" method="POST">';
982 if ($optioncss !=
'') {
983 print
'<input type="hidden" name="optioncss" value="' . $optioncss .
'">';
985 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
986 print
'<input type="hidden" name="doc_date" value="' .
$object->doc_date .
'">' .
"\n";
987 print
'<input type="hidden" name="doc_type" value="' .
$object->doc_type .
'">' .
"\n";
988 print
'<input type="hidden" name="doc_ref" value="' .
$object->doc_ref .
'">' .
"\n";
989 print
'<input type="hidden" name="ref" value="' .
$object->ref .
'">' .
"\n";
990 print
'<input type="hidden" name="code_journal" value="' .
$object->code_journal .
'">' .
"\n";
991 print
'<input type="hidden" name="fk_doc" value="' .
$object->fk_doc .
'">' .
"\n";
992 print
'<input type="hidden" name="fk_docdet" value="' .
$object->fk_docdet .
'">' .
"\n";
993 print
'<input type="hidden" name="mode" value="' . $mode .
'">' .
"\n";
994 print
'<input type="hidden" name="backtopage" value="' . $backtopage .
'">';
995 print
'<input type="hidden" name="type" value="' . $type .
'">';
998 if (count(
$object->linesmvt) > 0) {
999 print
'<div class="div-table-responsive-no-min">';
1000 print
'<table class="noborder centpercent">';
1005 print
'<tr class="liste_titre">';
1012 if (empty(
$object->date_validation)) {
1021 if (!empty(
$object->linesmvt[0]) && empty(
$object->date_validation)) {
1022 $tmpline =
$object->linesmvt[0];
1023 if (!empty($tmpline->numero_compte)) {
1029 foreach (
$object->linesmvt as $line) {
1030 $total_debit += $line->debit;
1031 $total_credit += $line->credit;
1033 if ($action ==
'update' && $line->id == $id && empty(
$object->date_validation)) {
1034 print
'<tr class="oddeven" data-lineid="'.((int) $line->id).
'">';
1035 print
'<!-- td columns in edit mode -->';
1037 print $formaccounting->select_account((GETPOSTISSET(
"accountingaccount_number") ?
GETPOST(
"accountingaccount_number",
"alpha") : $line->numero_compte),
'accountingaccount_number', 1, array(), 1, 1,
'minwidth200 maxwidth500');
1045 print $formaccounting->select_auxaccount((GETPOSTISSET(
"subledger_account") ?
GETPOST(
"subledger_account",
"alpha") : $line->subledger_account),
'subledger_account', 1,
'maxwidth250',
'',
'subledger_label');
1047 print
'<input type="text" class="maxwidth150" name="subledger_account" value="'.(GETPOSTISSET(
"subledger_account") ?
GETPOST(
"subledger_account",
"alpha") : $line->subledger_account).
'" placeholder="'.
dol_escape_htmltag($langs->trans(
"SubledgerAccount")).
'">';
1050 print
'<br><input type="text" class="maxwidth150" name="subledger_label" id="subledger_label" value="'.(GETPOSTISSET(
"subledger_label") ?
GETPOST(
"subledger_label",
"alpha") : $line->subledger_label).
'" placeholder="'.
dol_escape_htmltag($langs->trans(
"SubledgerAccountLabel")).
'">';
1052 print
'<td><input type="text" class="minwidth200" name="label_operation" value="'.(GETPOSTISSET(
"label_operation") ?
GETPOST(
"label_operation",
"alpha") : $line->label_operation).
'"></td>';
1053 print
'<td class="right"><input type="text" class="right width50" name="debit" value="'.(GETPOSTISSET(
"debit") ?
GETPOST(
"debit",
"alpha") :
price($line->debit)).
'"></td>';
1054 print
'<td class="right"><input type="text" class="right width50" name="credit" value="'.(GETPOSTISSET(
"credit") ?
GETPOST(
"credit",
"alpha") :
price($line->credit)).
'"></td>';
1056 print
'<input type="hidden" name="id" value="'.$line->id.
'">'.
"\n";
1057 print
'<input type="submit" class="button" name="update" value="'.$langs->trans(
"Update").
'">';
1060 } elseif ((empty($line->numero_compte) || (empty($line->debit) && empty($line->credit))) && empty(
$object->date_validation)) {
1061 if (($action ==
"" || $action ==
'add') && $permissiontoadd) {
1062 print
'<tr class="oddeven" data-lineid="'.((int) $line->id).
'">';
1063 print
'<!-- td columns in add mode -->';
1065 print $formaccounting->select_account($action ==
'add' ?
GETPOST(
'accountingaccount_number') :
'',
'accountingaccount_number', 1, array(), 1, 1,
'minwidth200 maxwidth500');
1073 print $formaccounting->select_auxaccount(
'',
'subledger_account', 1,
'maxwidth250',
'',
'subledger_label');
1075 print
'<input type="text" class="maxwidth150" name="subledger_account" value="" placeholder="' .
dol_escape_htmltag($langs->trans(
"SubledgerAccount")) .
'">';
1077 print
'<br><input type="text" class="maxwidth150" name="subledger_label" id="subledger_label" value="" placeholder="' .
dol_escape_htmltag($langs->trans(
"SubledgerAccountLabel")) .
'">';
1079 print
'<td><input type="text" class="minwidth200" name="label_operation" value="' .
dol_escape_htmltag($label_operation) .
'"/></td>';
1080 print
'<td class="right"><input type="text" class="right width50" name="debit" value=""/></td>';
1081 print
'<td class="right"><input type="text" class="right width50" name="credit" value=""/></td>';
1082 print
'<td class="center"><input type="submit" class="button small" name="save" value="' . $langs->trans(
"Add") .
'"></td>';
1086 print
'<tr class="oddeven" data-lineid="'.((int) $line->id).
'">';
1087 print
'<!-- td columns in display mode -->';
1088 $resultfetch = $accountingaccount->fetch(0, $line->numero_compte,
true);
1090 if ($resultfetch > 0) {
1091 print $accountingaccount->getNomUrl(0, 1, 1,
'', 0);
1093 print
dol_escape_htmltag($line->numero_compte).
' <span class="warning">('.$langs->trans(
"AccountRemovedFromCurrentChartOfAccount").
')</span>';
1096 print
'<td>'.length_accounta($line->subledger_account);
1097 if ($line->subledger_label) {
1098 print
' - <span class="opacitymedium">'.dol_escape_htmltag($line->subledger_label).
'</span>';
1101 print
'<td>'.$line->label_operation.
'</td>';
1102 print
'<td class="right nowraponall amount">'.($line->debit != 0 ?
price($line->debit) :
'').
'</td>';
1103 print
'<td class="right nowraponall amount">'.($line->credit != 0 ?
price($line->credit) :
'').
'</td>';
1105 print
'<td class="center nowraponall">';
1106 if ($permissiontoadd) {
1107 if (empty($line->date_export) && empty($line->date_validation)) {
1108 print
'<a class="editfielda reposition" href="' . $_SERVER[
"PHP_SELF"] .
'?action=update&id=' . $line->id .
'&piece_num=' . ((int) $line->piece_num) .
'&mode=' . urlencode((
string) $mode) .
'&token=' . urlencode(
newToken()) .
'">';
1109 print
img_edit(
'', 0,
'class="marginrightonly"');
1110 print
'</a> ';
1112 print
'<a class="editfielda nohover cursornotallowed reposition disabled" href="#" title="'.dol_escape_htmltag($langs->trans(
"ForbiddenTransactionAlreadyExported")).
'">';
1113 print
img_edit($langs->trans(
"ForbiddenTransactionAlreadyExported"), 0,
'class="marginrightonly"');
1114 print
'</a> ';
1117 if (empty($line->date_validation)) {
1118 $actiontodelete =
'delete';
1119 if ($mode ==
'_tmp' || $action !=
'delmouv') {
1120 $actiontodelete =
'confirm_delete';
1123 print
'<a href="' . $_SERVER[
"PHP_SELF"] .
'?action=' . $actiontodelete .
'&id=' . $line->id .
'&piece_num=' . ((int) $line->piece_num) .
'&mode=' . urlencode((
string) $mode) .
'&token=' . urlencode(
newToken()) .
'">';
1127 print
'<a class="editfielda nohover cursornotallowed disabled" href="#" title="'.dol_escape_htmltag($langs->trans(
"ForbiddenTransactionAlreadyExported")).
'">';
1128 print
img_delete($langs->trans(
"ForbiddenTransactionAlreadyValidated"));
1137 $total_debit =
price2num($total_debit,
'MT');
1138 $total_credit =
price2num($total_credit,
'MT');
1140 if ($total_debit != $total_credit) {
1141 setEventMessages(
null, array($langs->trans(
'MvtNotCorrectlyBalanced', $total_debit, $total_credit)),
'warnings');
1147 if ($mode ==
'_tmp' && $action ==
'' && $permissiontoadd) {
1149 print
'<div class="center">';
1150 if (empty($total_debit) && empty($total_credit)) {
1151 print
'<a class="button disabled cursornotallowed" disabled="disabled" href="#" title="'.dol_escape_htmltag($langs->trans(
"EnterNonEmptyLinesFirst")).
'">'.
dol_escape_htmltag($langs->trans(
"ValidTransaction")).
'</a>';
1152 } elseif ($total_debit == $total_credit) {
1153 print
'<a class="button" href="'.$_SERVER[
"PHP_SELF"].
'?piece_num='.((int)
$object->piece_num).(!empty($type) ?
'&type=sub' :
'').
'&backtopage='.urlencode($backtopage).
'&action=valid&token='.
newToken().
'">'.$langs->trans(
"ValidTransaction").
'</a>';
1155 print
'<a class="button disabled cursornotallowed" disabled="disabled" href="#" title="'.dol_escape_htmltag($langs->trans(
"MvtNotCorrectlyBalanced", $total_debit, $total_credit)).
'">'.
dol_escape_htmltag($langs->trans(
"ValidTransaction")).
'</a>';
1159 print
'<a class="button button-cancel" href="'.$backtopage.(!empty($type) ?
'?type=sub' :
'').
'">'.$langs->trans(
"Cancel").
'</a>';
1168 print $langs->trans(
"NoRecordFound");
$id
Support class for third parties, contacts, members, users or resources.
if(! $sortfield) if(! $sortorder) $object
accounting_transaction_prepare_head(BookKeeping $object, $mode='', $type='', $backtopage='/accountancy/bookkeeping/listbyaccount.php')
Prepare array with list of tabs for accounting transaction.
checkGeneralAccountAllowsAuxiliary($db, $general_account, $auxiliary_account, $general_account_id=0)
Check if a general accounting account allows the use of an auxiliary account.
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 accounting accounts.
Class to manage accounting journals.
Class to manage Ledger (General Ledger and Subledger)
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...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
print_liste_field_titre($name, $file="", $field="", $begin="", $param="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
img_delete($titlealt='default', $other='class="pictodelete"', $morecss='')
Show delete logo.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
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.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
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.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
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_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
img_edit($titlealt='default', $float=0, $other='')
Show logo edit/modify fiche.
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...
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.