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"));
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');
296 $object->doc_date = $date_start;
300 $object->code_journal = $journal_code;
301 $object->journal_label = $journal_label;
308 $result =
$object->createStd($user, 0, $mode);
315 $reshook = $hookmanager->executeHooks(
'afterCreateBookkeeping', $parameters, $object, $action);
317 if ($mode !=
'_tmp') {
322 $piece_num = (int)
$object->piece_num;
327 if ($action ==
'setdate' && $permissiontoadd) {
329 $result =
$object->updateByMvt($piece_num,
'doc_date', $db->idate($datedoc), $mode);
333 if ($mode !=
'_tmp') {
340 if ($action ==
'setjournal' && $permissiontoadd) {
341 $result =
$object->updateByMvt($piece_num,
'code_journal', $journal_code, $mode);
342 $result =
$object->updateByMvt($piece_num,
'journal_label', $journal_label, $mode);
346 if ($mode !=
'_tmp') {
353 if ($action ==
'setdocref' && $permissiontoadd) {
354 $refdoc =
GETPOST(
'doc_ref',
'alpha');
355 $result =
$object->updateByMvt($piece_num,
'doc_ref', $refdoc, $mode);
359 if ($mode !=
'_tmp') {
366 if ($action ==
'setref' && $permissiontoadd && $numRefModel ===
'mod_bookkeeping_neon') {
367 $newref =
GETPOST(
'ref',
'alpha');
368 $result =
$object->updateByMvt($piece_num,
'ref', $newref, $mode);
372 if ($mode !=
'_tmp') {
380 if ($action ==
'valid' && $permissiontoadd) {
381 $result =
$object->transformTransaction(0, $piece_num);
385 header(
"Location: " . $backtopage .
"?sortfield=t.piece_num&sortorder=asc" . ($type ?
'&type='.$type :
''));
391 $toselect_str = explode(
',',
GETPOST(
'toselect',
'alphanohtml'));
393 foreach ($toselect_str as $i) {
394 $toselect[] = (int) $i;
397 if ($action ==
'deletebookkeepingwriting' && $confirm ==
"yes" && $permissiontodelete) {
402 $nb_lettering = $lettering->bookkeepingLetteringAll($toselect,
true);
403 if ($nb_lettering < 0) {
412 foreach ($toselect as $toselectid) {
413 $result =
$object->fetch($toselectid);
414 if ($result >= 0 && (!isset(
$object->date_validation) ||
$object->date_validation ===
'')) {
423 } elseif ($result < 0) {
427 } elseif (isset(
$object->date_validation) &&
$object->date_validation !=
'') {
428 setEventMessages($langs->trans(
"ValidatedRecordWhereFound"),
null,
'errors');
441 } elseif ($nbok > 0) {
447 header(
"Location: ".DOL_URL_ROOT.
'/accountancy/bookkeeping/list.php?noreset=1');
454 if ($action ==
'clonebookkeepingwriting' && $confirm ==
"yes" && $permissiontoadd) {
456 $piece_num =
GETPOST(
'piece_num',
'alpha');
457 $journal_code =
GETPOST(
'code_journal',
'alpha');
462 $result =
$object->newClone($piece_num, $journal_code, $clonedate);
470 header(
"Location: " . $_SERVER[
'PHP_SELF'] .
"?piece_num=" . (
$object->getNextNumMvt() - 1));
484$form =
new Form($db);
487$title = $langs->trans(
"CreateMvts");
488$help_url =
'EN:Module_Double_Entry_Accounting|FR:Module_Comptabilité_en_Partie_Double';
490llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-accountancy accountancy-consultation page-card');
493if ($action ==
'delete') {
494 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$id.
'&mode='.$mode, $langs->trans(
'DeleteMvt'), $langs->trans(
'ConfirmDeleteMvt', $langs->transnoentitiesnoconv(
"RegistrationInAccounting")),
'confirm_delete',
'', 0, 1);
499if (!empty($conf->use_javascript_ajax)) {
500 print
"\n" .
'<script type="text/javascript">';
501 print
'$(document).ready(function () {
502 function toggleSubledger() {
503 var isCentral = $("#accountingaccount_number option:selected").data("centralized");
504 console.log("the selected general ledger account is centralised?", isCentral);
506 $("#subledger_account, #subledger_label").prop("disabled", false);
508 $("#subledger_account, #subledger_label").prop("disabled", true);
514 $("#accountingaccount_number").on("change", toggleSubledger);
515 $("#accountingaccount_number").on("select2:select", toggleSubledger);
518 print
' </script>' .
"\n";
521if ($action ==
'create') {
525 $next_num_mvt =
$object->getNextNumMvt(
'_tmp');
527 if (empty($next_num_mvt)) {
531 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" name="create_mvt" method="POST">';
532 if ($optioncss !=
'') {
533 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
535 print
'<input type="hidden" name="token" value="'.newToken().
'">';
536 print
'<input type="hidden" name="action" value="confirm_create">'.
"\n";
537 print
'<input type="hidden" name="next_num_mvt" value="'.$next_num_mvt.
'">'.
"\n";
538 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
539 print
'<input type="hidden" name="type" value="'.$type.
'">';
540 print
'<input type="hidden" name="mode" value="_tmp">'.
"\n";
544 print
'<table class="border centpercent">';
547 print
'<td class="fieldrequired">'.$langs->trans(
"Docdate").
'</td>';
549 print $form->selectDate(
'',
'doc_date', 0, 0, 0,
"create_mvt", 1, 1);
554 print
'<td class="fieldrequired">'.$langs->trans(
"Codejournal").
'</td>';
555 print
'<td>'.$formaccounting->select_journal($journal_code,
'code_journal', 0, 0, 1, 1).
'</td>';
559 print
'<td class="fieldrequired">'.$form->textwithpicto($langs->trans(
"Piece"), $langs->trans(
"PieceDesc")).
'</td>';
560 print
'<td><input type="text" class="minwidth200" name="doc_ref" value="'.GETPOST(
'doc_ref',
'alpha').
'"></td>';
565 print
'<td>'.$form->textwithpicto($langs->trans(
"Ref"), $langs->trans(
"BankTransactionRef")).
'</td>';
567 if ($numRefModel ===
'mod_bookkeeping_neon') {
568 print
'<input type="text" class="minwidth200" name="ref" value="">';
570 print
'<span class="opacitymedium">'.$langs->trans(
"Automatic").
'</span>';
581 $reshookAddLine = $hookmanager->executeHooks(
'bookkeepingAddLine', $parameters, $object, $action);
587 print $form->buttonsSaveCancel(
"Create");
593 $result =
$object->fetchPerMvt($piece_num, $mode);
598 if (!empty(
$object->piece_num)) {
599 $backlink =
'<a href="'.DOL_URL_ROOT.
'/accountancy/bookkeeping/list.php?restore_lastsearch_values=1">'.$langs->trans(
'BackToList').
'</a>';
612 if ($mode ==
'_tmp') {
613 $object->context[
'mode'] = $mode;
614 $object->next_prev_filter =
'1=0';
618 $morehtmlref =
'<div style="clear: both;"></div>';
619 $morehtmlref .=
'<div class="refidno opacitymedium">';
620 $morehtmlref .=
$object->label;
621 $morehtmlref .=
'</div>';
623 dol_banner_tab($object,
'ref', $backlink, 1,
'piece_num',
'piece_num', $morehtmlref);
626 if ($action ==
'clonebookkeepingwriting' && $confirm !=
'yes' && $permissiontoadd) {
627 $piece_num =
GETPOST(
'piece_num',
'alpha');
630 $form =
new Form($db);
631 $input1 = $form->selectDate(
'',
'clonedate', 0, 0, 0,
"", 1, 1);
632 $input2 = $formaccounting->select_journal($journal_code,
'code_journal', 0, 0, 1, 1);
634 $formquestion = array(
637 'name' =>
'clonedate',
638 'label' =>
'<span class="fieldrequired">' . $langs->trans(
"Docdate") .
'</span>',
643 $formquestion[] = array(
'type' =>
'hidden',
'name' =>
'piece_num',
'value' => $piece_num);
646 $formquestion[] = array(
648 'name' =>
'code_journal',
649 'label' =>
'<span class="fieldrequired">' . $langs->trans(
"Codejournal") .
'</span>',
654 print $form->formconfirm(
655 $_SERVER[
"PHP_SELF"],
656 $langs->trans(
"ConfirmMassCloneBookkeepingWriting"),
657 $langs->trans(
"ConfirmMassCloneBookkeepingWritingQuestion", 1),
658 "clonebookkeepingwriting",
665 print
'<div class="fichecenter">';
667 print
'<div class="fichehalfleft">';
669 print
'<div class="underbanner clearboth"></div>';
670 print
'<table class="border tableforfield centpercent">';
681 print
'<tr><td class="titlefieldmiddle">';
682 print
'<table class="nobordernopadding centpercent"><tr><td>';
683 print $langs->trans(
'Ref');
685 if ($action !=
'editref' && empty(
$object->date_validation)) {
686 print
'<td class="right">';
687 if ($permissiontoadd && $numRefModel ===
'mod_bookkeeping_neon') {
688 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>';
692 print
'</tr></table>';
694 if ($action ==
'editref' && empty(
$object->date_validation)) {
695 print
'<form name="setref" action="'.$_SERVER[
"PHP_SELF"].
'?piece_num='.((int)
$object->piece_num).
'" method="POST">';
696 if ($optioncss !=
'') {
697 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
699 print
'<input type="hidden" name="token" value="'.newToken().
'">';
700 print
'<input type="hidden" name="action" value="setref">';
701 print
'<input type="hidden" name="mode" value="'.$mode.
'">';
702 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
703 print
'<input type="hidden" name="type" value="'.$type.
'">';
704 print
'<input type="text" size="20" name="ref" value="'.dol_escape_htmltag(
$object->ref).
'">';
705 print
'<input type="submit" class="button button-edit smallpaddingimp" value="'.$langs->trans(
'Modify').
'">';
715 print
'<table class="nobordernopadding centpercent"><tr><td>';
716 print $form->textwithpicto($langs->trans(
'Piece'), $langs->trans(
'PieceDesc'));
718 if ($action !=
'editdocref') {
719 print
'<td class="right">';
720 if ($permissiontoadd && empty(
$object->date_validation)) {
721 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>';
725 print
'</tr></table>';
727 if ($action ==
'editdocref' && empty(
$object->date_validation)) {
728 print
'<form name="setdocref" action="'.$_SERVER[
"PHP_SELF"].
'?piece_num='.((int)
$object->piece_num).
'" method="POST">';
729 if ($optioncss !=
'') {
730 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
732 print
'<input type="hidden" name="token" value="'.newToken().
'">';
733 print
'<input type="hidden" name="action" value="setdocref">';
734 print
'<input type="hidden" name="mode" value="'.$mode.
'">';
735 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
736 print
'<input type="hidden" name="type" value="'.$type.
'">';
737 print
'<input type="text" size="20" name="doc_ref" value="'.dol_escape_htmltag(
$object->doc_ref).
'">';
738 print
'<input type="submit" class="button button-edit smallpaddingimp" value="'.$langs->trans(
'Modify').
'">';
748 print
'<table class="nobordernopadding centpercent"><tr><td>';
749 print $langs->trans(
'Docdate');
751 if ($action !=
'editdate') {
752 print
'<td class="right">';
753 if ($permissiontoadd && empty(
$object->date_validation)) {
754 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>';
758 print
'</tr></table>';
759 print
'</td><td colspan="3">';
760 if ($action ==
'editdate' && empty(
$object->date_validation)) {
761 print
'<form name="setdate" action="'.$_SERVER[
"PHP_SELF"].
'?piece_num='.((int)
$object->piece_num).
'" method="POST">';
762 if ($optioncss !=
'') {
763 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
765 print
'<input type="hidden" name="token" value="'.newToken().
'">';
766 print
'<input type="hidden" name="action" value="setdate">';
767 print
'<input type="hidden" name="mode" value="'.$mode.
'">';
768 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
769 print
'<input type="hidden" name="type" value="'.$type.
'">';
770 print $form->selectDate(
$object->doc_date ?
$object->doc_date : -1,
'doc_date', 0, 0, 0,
"setdate");
771 print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
'Modify').
'">';
781 print
'<table class="nobordernopadding centpercent"><tr><td>';
782 print $langs->trans(
'Codejournal');
784 if ($action !=
'editjournal') {
785 print
'<td class="right">';
786 if ($permissiontoadd && empty(
$object->date_validation)) {
787 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>';
791 print
'</tr></table>';
793 if ($action ==
'editjournal' && empty(
$object->date_validation)) {
794 print
'<form name="setjournal" action="'.$_SERVER[
"PHP_SELF"].
'?piece_num='.((int)
$object->piece_num).
'" method="POST">';
795 if ($optioncss !=
'') {
796 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
798 print
'<input type="hidden" name="token" value="'.newToken().
'">';
799 print
'<input type="hidden" name="action" value="setjournal">';
800 print
'<input type="hidden" name="mode" value="'.$mode.
'">';
801 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
802 print
'<input type="hidden" name="type" value="'.$type.
'">';
803 print $formaccounting->select_journal(
$object->code_journal,
'code_journal', 0, 0, 0, 1,
'');
804 print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
'Modify').
'">';
817 print
'<div class="fichehalfright">';
819 print
'<div class="underbanner clearboth"></div>';
820 print
'<table class="border tableforfield centpercent">';
823 if (!empty(
$object->doc_type)) {
825 print
'<td class="titlefield">'.$langs->trans(
"Doctype").
'</td>';
826 print
'<td>'.$object->doc_type.
'</td>';
832 print
'<td class="titlefield">'.$langs->trans(
"DateCreation").
'</td>';
841 print
'<td class="titlefield">' . $form->textwithpicto($langs->trans(
'DateDue'), $langs->trans(
"IfTransactionHasDueDate")) .
'</td>';
849 if ($mode !=
"_tmp") {
852 print
'<td class="titlefield">' . $langs->trans(
"DateExport") .
'</td>';
854 print
$object->date_export ?
img_picto($langs->trans(
"TransactionExportDesc"),
'fa-file-export',
'class="pictofixedwidth opacitymedium"').dol_print_date(
$object->date_export,
'dayhour') :
' ';
860 print
'<td class="titlefield">' . $langs->trans(
"DateValidation") .
'</td>';
862 print
$object->date_validation ?
img_picto($langs->trans(
"TransactionBlockedLockedDesc"),
'fa-lock',
'class="pictofixedwidth opacitymedium"').dol_print_date(
$object->date_validation,
'dayhour') :
' ';
867 if (!empty(
$object->import_key)) {
869 print
'<td class="titlefield">' . $langs->trans(
"ImportId") .
'</td>';
922 print
'<div class="clearboth"></div>';
928 $result =
$object->fetchAllPerMvt($piece_num, $mode);
934 $tmptoselect = array();
935 $atleastonevalidated = 0;
936 $atleastoneexported = 0;
937 foreach (
$object->linesmvt as $line) {
938 $tmptoselect[] = $line->id;
939 if (!empty($line->date_validation)) {
940 $atleastonevalidated = 1;
942 if (!empty($line->date_export) || !empty($line->date_validation)) {
943 $atleastoneexported = 1;
947 if ($mode !=
'_tmp' && !$atleastonevalidated) {
948 print
"\n".
'<div class="tabsAction">'.
"\n";
950 $parameters = array();
951 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
952 if (empty($reshook)) {
953 if ($permissiontodelete) {
954 if (!isset($hookmanager->resArray[
'no_button_edit']) || $hookmanager->resArray[
'no_button_edit'] != 1) {
955 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);
958 if ($permissiontoadd) {
959 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);
969 if (empty(
$object->date_validation)) {
970 print
'<form action="' . $_SERVER[
"PHP_SELF"] .
'?piece_num=' . ((int)
$object->piece_num) .
'" method="POST">';
971 if ($optioncss !=
'') {
972 print
'<input type="hidden" name="optioncss" value="' . $optioncss .
'">';
974 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
975 print
'<input type="hidden" name="doc_date" value="' .
$object->doc_date .
'">' .
"\n";
976 print
'<input type="hidden" name="doc_type" value="' .
$object->doc_type .
'">' .
"\n";
977 print
'<input type="hidden" name="doc_ref" value="' .
$object->doc_ref .
'">' .
"\n";
978 print
'<input type="hidden" name="ref" value="' .
$object->ref .
'">' .
"\n";
979 print
'<input type="hidden" name="code_journal" value="' .
$object->code_journal .
'">' .
"\n";
980 print
'<input type="hidden" name="fk_doc" value="' .
$object->fk_doc .
'">' .
"\n";
981 print
'<input type="hidden" name="fk_docdet" value="' .
$object->fk_docdet .
'">' .
"\n";
982 print
'<input type="hidden" name="mode" value="' . $mode .
'">' .
"\n";
983 print
'<input type="hidden" name="backtopage" value="' . $backtopage .
'">';
984 print
'<input type="hidden" name="type" value="' . $type .
'">';
987 if (count(
$object->linesmvt) > 0) {
988 print
'<div class="div-table-responsive-no-min">';
989 print
'<table class="noborder centpercent">';
994 print
'<tr class="liste_titre">';
1001 if (empty(
$object->date_validation)) {
1010 if (!empty(
$object->linesmvt[0]) && empty(
$object->date_validation)) {
1011 $tmpline =
$object->linesmvt[0];
1012 if (!empty($tmpline->numero_compte)) {
1018 foreach (
$object->linesmvt as $line) {
1019 $total_debit += $line->debit;
1020 $total_credit += $line->credit;
1022 if ($action ==
'update' && $line->id == $id && empty(
$object->date_validation)) {
1023 print
'<tr class="oddeven" data-lineid="'.((int) $line->id).
'">';
1024 print
'<!-- td columns in edit mode -->';
1026 print $formaccounting->select_account((GETPOSTISSET(
"accountingaccount_number") ?
GETPOST(
"accountingaccount_number",
"alpha") : $line->numero_compte),
'accountingaccount_number', 1, array(), 1, 1,
'minwidth200 maxwidth500');
1034 print $formaccounting->select_auxaccount((GETPOSTISSET(
"subledger_account") ?
GETPOST(
"subledger_account",
"alpha") : $line->subledger_account),
'subledger_account', 1,
'maxwidth250',
'',
'subledger_label');
1036 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")).
'">';
1039 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")).
'">';
1041 print
'<td><input type="text" class="minwidth200" name="label_operation" value="'.(GETPOSTISSET(
"label_operation") ?
GETPOST(
"label_operation",
"alpha") : $line->label_operation).
'"></td>';
1042 print
'<td class="right"><input type="text" class="right width50" name="debit" value="'.(GETPOSTISSET(
"debit") ?
GETPOST(
"debit",
"alpha") :
price($line->debit)).
'"></td>';
1043 print
'<td class="right"><input type="text" class="right width50" name="credit" value="'.(GETPOSTISSET(
"credit") ?
GETPOST(
"credit",
"alpha") :
price($line->credit)).
'"></td>';
1045 print
'<input type="hidden" name="id" value="'.$line->id.
'">'.
"\n";
1046 print
'<input type="submit" class="button" name="update" value="'.$langs->trans(
"Update").
'">';
1049 } elseif ((empty($line->numero_compte) || (empty($line->debit) && empty($line->credit))) && empty(
$object->date_validation)) {
1050 if (($action ==
"" || $action ==
'add') && $permissiontoadd) {
1051 print
'<tr class="oddeven" data-lineid="'.((int) $line->id).
'">';
1052 print
'<!-- td columns in add mode -->';
1054 print $formaccounting->select_account($action ==
'add' ?
GETPOST(
'accountingaccount_number') :
'',
'accountingaccount_number', 1, array(), 1, 1,
'minwidth200 maxwidth500');
1062 print $formaccounting->select_auxaccount(
'',
'subledger_account', 1,
'maxwidth250',
'',
'subledger_label');
1064 print
'<input type="text" class="maxwidth150" name="subledger_account" value="" placeholder="' .
dol_escape_htmltag($langs->trans(
"SubledgerAccount")) .
'">';
1066 print
'<br><input type="text" class="maxwidth150" name="subledger_label" id="subledger_label" value="" placeholder="' .
dol_escape_htmltag($langs->trans(
"SubledgerAccountLabel")) .
'">';
1068 print
'<td><input type="text" class="minwidth200" name="label_operation" value="' .
dol_escape_htmltag($label_operation) .
'"/></td>';
1069 print
'<td class="right"><input type="text" class="right width50" name="debit" value=""/></td>';
1070 print
'<td class="right"><input type="text" class="right width50" name="credit" value=""/></td>';
1071 print
'<td class="center"><input type="submit" class="button small" name="save" value="' . $langs->trans(
"Add") .
'"></td>';
1075 print
'<tr class="oddeven" data-lineid="'.((int) $line->id).
'">';
1076 print
'<!-- td columns in display mode -->';
1077 $resultfetch = $accountingaccount->fetch(0, $line->numero_compte,
true);
1079 if ($resultfetch > 0) {
1080 print $accountingaccount->getNomUrl(0, 1, 1,
'', 0);
1082 print
dol_escape_htmltag($line->numero_compte).
' <span class="warning">('.$langs->trans(
"AccountRemovedFromCurrentChartOfAccount").
')</span>';
1085 print
'<td>'.length_accounta($line->subledger_account);
1086 if ($line->subledger_label) {
1087 print
' - <span class="opacitymedium">'.dol_escape_htmltag($line->subledger_label).
'</span>';
1090 print
'<td>'.$line->label_operation.
'</td>';
1091 print
'<td class="right nowraponall amount">'.($line->debit != 0 ?
price($line->debit) :
'').
'</td>';
1092 print
'<td class="right nowraponall amount">'.($line->credit != 0 ?
price($line->credit) :
'').
'</td>';
1094 print
'<td class="center nowraponall">';
1095 if ($permissiontoadd) {
1096 if (empty($line->date_export) && empty($line->date_validation)) {
1097 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()) .
'">';
1098 print
img_edit(
'', 0,
'class="marginrightonly"');
1099 print
'</a> ';
1101 print
'<a class="editfielda nohover cursornotallowed reposition disabled" href="#" title="'.dol_escape_htmltag($langs->trans(
"ForbiddenTransactionAlreadyExported")).
'">';
1102 print
img_edit($langs->trans(
"ForbiddenTransactionAlreadyExported"), 0,
'class="marginrightonly"');
1103 print
'</a> ';
1106 if (empty($line->date_validation)) {
1107 $actiontodelete =
'delete';
1108 if ($mode ==
'_tmp' || $action !=
'delmouv') {
1109 $actiontodelete =
'confirm_delete';
1112 print
'<a href="' . $_SERVER[
"PHP_SELF"] .
'?action=' . $actiontodelete .
'&id=' . $line->id .
'&piece_num=' . ((int) $line->piece_num) .
'&mode=' . urlencode((
string) $mode) .
'&token=' . urlencode(
newToken()) .
'">';
1116 print
'<a class="editfielda nohover cursornotallowed disabled" href="#" title="'.dol_escape_htmltag($langs->trans(
"ForbiddenTransactionAlreadyExported")).
'">';
1117 print
img_delete($langs->trans(
"ForbiddenTransactionAlreadyValidated"));
1126 $total_debit =
price2num($total_debit,
'MT');
1127 $total_credit =
price2num($total_credit,
'MT');
1129 if ($total_debit != $total_credit) {
1130 setEventMessages(
null, array($langs->trans(
'MvtNotCorrectlyBalanced', $total_debit, $total_credit)),
'warnings');
1136 if ($mode ==
'_tmp' && $action ==
'' && $permissiontoadd) {
1138 print
'<div class="center">';
1139 if (empty($total_debit) && empty($total_credit)) {
1140 print
'<a class="button disabled cursornotallowed" disabled="disabled" href="#" title="'.dol_escape_htmltag($langs->trans(
"EnterNonEmptyLinesFirst")).
'">'.
dol_escape_htmltag($langs->trans(
"ValidTransaction")).
'</a>';
1141 } elseif ($total_debit == $total_credit) {
1142 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>';
1144 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>';
1148 print
'<a class="button button-cancel" href="'.$backtopage.(!empty($type) ?
'?type=sub' :
'').
'">'.$langs->trans(
"Cancel").
'</a>';
1157 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.
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.