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');
54$confirm =
GETPOST(
'confirm',
'alpha');
56$type =
GETPOST(
'type',
'alpha');
57$backtopage =
GETPOST(
'backtopage',
'alpha');
58if (empty($backtopage)) {
62 $backtopage = DOL_URL_ROOT.
'/accountancy/bookkeeping/list.php';
65$optioncss =
GETPOST(
'optioncss',
'aZ');
75$accountingaccount_number =
GETPOST(
'accountingaccount_number',
'alphanohtml');
76$accountingaccount->fetch(0, $accountingaccount_number,
true);
77$accountingaccount_label = $accountingaccount->label;
79$journal_code =
GETPOST(
'code_journal',
'alpha');
80$accountingjournal->fetch(0, $journal_code);
81$journal_label = $accountingjournal->label;
83$subledger_account =
GETPOST(
'subledger_account',
'alphanohtml');
84if ($subledger_account == -1) {
85 $subledger_account =
null;
87$subledger_label =
GETPOST(
'subledger_label',
'alphanohtml');
89$label_operation =
GETPOST(
'label_operation',
'alphanohtml');
93$save =
GETPOST(
'save',
'alpha');
97$update =
GETPOST(
'update',
'alpha');
99 $action =
'confirm_update';
103$hookmanager->initHooks(array(
'bookkeepingcard',
'globalcard'));
108if (!isModEnabled(
'accounting')) {
111if ($user->socid > 0) {
114if (!$user->hasRight(
'accounting',
'mouvements',
'lire')) {
118$permissiontoadd = $user->hasRight(
'accounting',
'mouvements',
'creer');
119$permissiontodelete = $user->hasRight(
'accounting',
'mouvements',
'supprimer');
126$parameters = array();
127$reshook = $hookmanager->executeHooks(
'doActions', $parameters,
$object, $action);
131if (empty($reshook)) {
135 header(
"Location: ". $backtopage . (!empty($type) ?
'?type=sub' :
''));
139 if ($action ==
"confirm_update" && $permissiontoadd) {
140 if (((
float) $debit != 0.0) && ((
float) $credit != 0.0)) {
145 if (empty($accountingaccount_number) || $accountingaccount_number ==
'-1') {
147 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
"AccountAccountingShort")),
null,
'errors');
154 $result =
$object->fetch($id,
null, $mode);
159 $object->numero_compte = $accountingaccount_number;
160 $object->subledger_account = $subledger_account;
161 $object->subledger_label = $subledger_label;
162 $object->label_compte = $accountingaccount_label;
163 $object->label_operation = $label_operation;
167 if ((
float) $debit != 0.0) {
172 if ((
float) $credit != 0.0) {
178 $result =
$object->update($user, 0, $mode);
182 if ($mode !=
'_tmp') {
193 } elseif ($action ==
"add" && $permissiontoadd) {
194 if (((
float) $debit != 0.0) && ((
float) $credit != 0.0)) {
199 if (empty($accountingaccount_number) || $accountingaccount_number ==
'-1') {
201 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
"AccountAccountingShort")),
null,
'errors');
214 $object->numero_compte = $accountingaccount_number;
215 $object->subledger_account = $subledger_account;
216 $object->subledger_label = $subledger_label;
217 $object->label_compte = $accountingaccount_label;
218 $object->label_operation = $label_operation;
223 $object->piece_num = $piece_num;
226 $object->code_journal = $journal_code;
227 $object->journal_label = $journal_label;
231 if ((
float) $debit != 0.0) {
237 if ((
float) $credit != 0.0) {
243 $result =
$object->createStd($user, 0, $mode);
248 if ($mode !=
'_tmp') {
258 } elseif ($action ==
"confirm_delete" && $permissiontoadd) {
261 $result =
$object->fetch($id,
null, $mode);
262 $piece_num = (int)
$object->piece_num;
267 } elseif ($result > 0) {
268 $result =
$object->delete($user, 0, $mode);
274 } elseif ($action ==
"confirm_create" && $permissiontoadd) {
277 if (!$journal_code || $journal_code ==
'-1') {
278 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
"Journal")),
null,
'errors');
282 if (!
GETPOST(
'doc_ref',
'alpha')) {
283 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Piece")),
null,
'errors');
294 $object->doc_date = $date_start;
298 $object->code_journal = $journal_code;
299 $object->journal_label = $journal_label;
306 $result =
$object->createStd($user, 0, $mode);
313 $reshook = $hookmanager->executeHooks(
'afterCreateBookkeeping', $parameters,
$object, $action);
315 if ($mode !=
'_tmp') {
320 $piece_num = (int)
$object->piece_num;
325 if ($action ==
'setdate' && $permissiontoadd) {
327 $result =
$object->updateByMvt($piece_num,
'doc_date', $db->idate($datedoc), $mode);
331 if ($mode !=
'_tmp') {
338 if ($action ==
'setjournal' && $permissiontoadd) {
339 $result =
$object->updateByMvt($piece_num,
'code_journal', $journal_code, $mode);
340 $result =
$object->updateByMvt($piece_num,
'journal_label', $journal_label, $mode);
344 if ($mode !=
'_tmp') {
351 if ($action ==
'setdocref' && $permissiontoadd) {
352 $refdoc =
GETPOST(
'doc_ref',
'alpha');
353 $result =
$object->updateByMvt($piece_num,
'doc_ref', $refdoc, $mode);
357 if ($mode !=
'_tmp') {
364 if ($action ==
'setref' && $permissiontoadd && $numRefModel ===
'mod_bookkeeping_neon') {
365 $newref =
GETPOST(
'ref',
'alpha');
366 $result =
$object->updateByMvt($piece_num,
'ref', $newref, $mode);
370 if ($mode !=
'_tmp') {
378 if ($action ==
'valid' && $permissiontoadd) {
379 $result =
$object->transformTransaction(0, $piece_num);
383 header(
"Location: " . $backtopage .
"?sortfield=t.piece_num&sortorder=asc" . ($type ?
'&type='.$type :
''));
389 $toselect_str = explode(
',',
GETPOST(
'toselect',
'alphanohtml'));
391 foreach ($toselect_str as $i) {
392 $toselect[] = (int) $i;
395 if ($action ==
'deletebookkeepingwriting' && $confirm ==
"yes" && $permissiontodelete) {
400 $nb_lettering = $lettering->bookkeepingLetteringAll($toselect,
true);
401 if ($nb_lettering < 0) {
410 foreach ($toselect as $toselectid) {
411 $result =
$object->fetch($toselectid);
412 if ($result >= 0 && (!isset(
$object->date_validation) ||
$object->date_validation ===
'')) {
421 } elseif ($result < 0) {
425 } elseif (isset(
$object->date_validation) &&
$object->date_validation !=
'') {
426 setEventMessages($langs->trans(
"ValidatedRecordWhereFound"),
null,
'errors');
439 } elseif ($nbok > 0) {
445 header(
"Location: ".DOL_URL_ROOT.
'/accountancy/bookkeeping/list.php?noreset=1');
452 if ($action ==
'clonebookkeepingwriting' && $confirm ==
"yes" && $permissiontoadd) {
454 $piece_num =
GETPOST(
'piece_num',
'alpha');
455 $journal_code =
GETPOST(
'code_journal',
'alpha');
460 $result =
$object->newClone($piece_num, $journal_code, $clonedate);
468 header(
"Location: " . $_SERVER[
'PHP_SELF'] .
"?piece_num=" . (
$object->getNextNumMvt() - 1));
482$form =
new Form($db);
485$title = $langs->trans(
"CreateMvts");
486$help_url =
'EN:Module_Double_Entry_Accounting|FR:Module_Comptabilité_en_Partie_Double';
488llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-accountancy accountancy-consultation page-card');
491if ($action ==
'delete') {
492 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$id.
'&mode='.$mode, $langs->trans(
'DeleteMvt'), $langs->trans(
'ConfirmDeleteMvt', $langs->transnoentitiesnoconv(
"RegistrationInAccounting")),
'confirm_delete',
'', 0, 1);
496if ($action ==
'create') {
500 $next_num_mvt =
$object->getNextNumMvt(
'_tmp');
502 if (empty($next_num_mvt)) {
506 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" name="create_mvt" method="POST">';
507 if ($optioncss !=
'') {
508 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
510 print
'<input type="hidden" name="token" value="'.newToken().
'">';
511 print
'<input type="hidden" name="action" value="confirm_create">'.
"\n";
512 print
'<input type="hidden" name="next_num_mvt" value="'.$next_num_mvt.
'">'.
"\n";
513 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
514 print
'<input type="hidden" name="type" value="'.$type.
'">';
515 print
'<input type="hidden" name="mode" value="_tmp">'.
"\n";
519 print
'<table class="border centpercent">';
522 print
'<td class="fieldrequired">'.$langs->trans(
"Docdate").
'</td>';
524 print $form->selectDate(
'',
'doc_date', 0, 0, 0,
"create_mvt", 1, 1);
529 print
'<td class="fieldrequired">'.$langs->trans(
"Codejournal").
'</td>';
530 print
'<td>'.$formaccounting->select_journal($journal_code,
'code_journal', 0, 0, 1, 1).
'</td>';
534 print
'<td class="fieldrequired">'.$form->textwithpicto($langs->trans(
"Piece"), $langs->trans(
"PieceDesc")).
'</td>';
535 print
'<td><input type="text" class="minwidth200" name="doc_ref" value="'.GETPOST(
'doc_ref',
'alpha').
'"></td>';
540 print
'<td>'.$form->textwithpicto($langs->trans(
"Ref"), $langs->trans(
"BankTransactionRef")).
'</td>';
542 if ($numRefModel ===
'mod_bookkeeping_neon') {
543 print
'<input type="text" class="minwidth200" name="ref" value="">';
545 print
'<span class="opacitymedium">'.$langs->trans(
"Automatic").
'</span>';
556 $reshookAddLine = $hookmanager->executeHooks(
'bookkeepingAddLine', $parameters,
$object, $action);
562 print $form->buttonsSaveCancel(
"Create");
568 $result =
$object->fetchPerMvt($piece_num, $mode);
573 if (!empty(
$object->piece_num)) {
574 $backlink =
'<a href="'.DOL_URL_ROOT.
'/accountancy/bookkeeping/list.php?restore_lastsearch_values=1">'.$langs->trans(
'BackToList').
'</a>';
582 if ($action ==
'clonebookkeepingwriting' && $confirm !=
'yes' && $permissiontoadd) {
583 $piece_num =
GETPOST(
'piece_num',
'alpha');
586 $form =
new Form($db);
587 $input1 = $form->selectDate(
'',
'clonedate', 0, 0, 0,
"", 1, 1);
588 $input2 = $formaccounting->select_journal($journal_code,
'code_journal', 0, 0, 1, 1);
590 $formquestion = array(
593 'name' =>
'clonedate',
594 'label' =>
'<span class="fieldrequired">' . $langs->trans(
"Docdate") .
'</span>',
599 $formquestion[] = array(
'type' =>
'hidden',
'name' =>
'piece_num',
'value' => $piece_num);
602 $formquestion[] = array(
604 'name' =>
'code_journal',
605 'label' =>
'<span class="fieldrequired">' . $langs->trans(
"Codejournal") .
'</span>',
610 print $form->formconfirm(
611 $_SERVER[
"PHP_SELF"],
612 $langs->trans(
"ConfirmMassCloneBookkeepingWriting"),
613 $langs->trans(
"ConfirmMassCloneBookkeepingWritingQuestion", 1),
614 "clonebookkeepingwriting",
622 $head[$h][0] = DOL_URL_ROOT.
"/accountancy/bookkeeping/card.php".
'?piece_num='.((int)
$object->piece_num).($mode ?
'&mode='.$mode :
'').($type ?
'&type='.$type :
'').
'&backtopage='.urlencode($backtopage);
623 $head[$h][1] = $langs->trans(
"Transaction");
624 $head[$h][2] =
'transaction';
630 if ($mode ==
'_tmp') {
631 $object->context[
'mode'] = $mode;
632 $object->next_prev_filter =
'1=0';
636 $morehtmlref =
'<div style="clear: both;"></div>';
637 $morehtmlref .=
'<div class="refidno opacitymedium">';
638 $morehtmlref .=
$object->label;
639 $morehtmlref .=
'</div>';
641 dol_banner_tab(
$object,
'ref', $backlink, 1,
'piece_num',
'piece_num', $morehtmlref);
643 print
'<div class="fichecenter">';
645 print
'<div class="fichehalfleft">';
647 print
'<div class="underbanner clearboth"></div>';
648 print
'<table class="border tableforfield centpercent">';
659 print
'<tr><td class="titlefieldmiddle">';
660 print
'<table class="nobordernopadding centpercent"><tr><td>';
661 print $langs->trans(
'Ref');
663 if ($action !=
'editref') {
664 print
'<td class="right">';
665 if ($permissiontoadd && $numRefModel ===
'mod_bookkeeping_neon') {
666 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>';
670 print
'</tr></table>';
672 if ($action ==
'editref') {
673 print
'<form name="setref" action="'.$_SERVER[
"PHP_SELF"].
'?piece_num='.((int)
$object->piece_num).
'" method="POST">';
674 if ($optioncss !=
'') {
675 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
677 print
'<input type="hidden" name="token" value="'.newToken().
'">';
678 print
'<input type="hidden" name="action" value="setref">';
679 print
'<input type="hidden" name="mode" value="'.$mode.
'">';
680 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
681 print
'<input type="hidden" name="type" value="'.$type.
'">';
682 print
'<input type="text" size="20" name="ref" value="'.dol_escape_htmltag(
$object->ref).
'">';
683 print
'<input type="submit" class="button button-edit smallpaddingimp" value="'.$langs->trans(
'Modify').
'">';
693 print
'<table class="nobordernopadding centpercent"><tr><td>';
694 print $form->textwithpicto($langs->trans(
'Piece'), $langs->trans(
'PieceDesc'));
696 if ($action !=
'editdocref') {
697 print
'<td class="right">';
698 if ($permissiontoadd) {
699 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>';
703 print
'</tr></table>';
705 if ($action ==
'editdocref') {
706 print
'<form name="setdocref" 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="setdocref">';
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="doc_ref" value="'.dol_escape_htmltag(
$object->doc_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 $langs->trans(
'Docdate');
729 if ($action !=
'editdate') {
730 print
'<td class="right">';
731 if ($permissiontoadd) {
732 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>';
736 print
'</tr></table>';
737 print
'</td><td colspan="3">';
738 if ($action ==
'editdate') {
739 print
'<form name="setdate" 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="setdate">';
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 $form->selectDate(
$object->doc_date ?
$object->doc_date : -1,
'doc_date', 0, 0, 0,
"setdate");
749 print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
'Modify').
'">';
759 print
'<table class="nobordernopadding centpercent"><tr><td>';
760 print $langs->trans(
'Codejournal');
762 if ($action !=
'editjournal') {
763 print
'<td class="right">';
764 if ($permissiontoadd) {
765 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>';
769 print
'</tr></table>';
771 if ($action ==
'editjournal') {
772 print
'<form name="setjournal" 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="setjournal">';
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 $formaccounting->select_journal(
$object->code_journal,
'code_journal', 0, 0, 0, 1,
'');
782 print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
'Modify').
'">';
795 print
'<div class="fichehalfright">';
797 print
'<div class="underbanner clearboth"></div>';
798 print
'<table class="border tableforfield centpercent">';
801 if (!empty(
$object->doc_type)) {
803 print
'<td class="titlefield">'.$langs->trans(
"Doctype").
'</td>';
804 print
'<td>'.$object->doc_type.
'</td>';
810 print
'<td class="titlefield">'.$langs->trans(
"DateCreation").
'</td>';
819 print
'<td class="titlefield">' . $form->textwithpicto($langs->trans(
'DateDue'), $langs->trans(
"IfTransactionHasDueDate")) .
'</td>';
827 if ($mode !=
"_tmp") {
830 print
'<td class="titlefield">' . $langs->trans(
"DateExport") .
'</td>';
838 print
'<td class="titlefield">' . $langs->trans(
"DateValidation") .
'</td>';
845 if (!empty(
$object->import_key)) {
847 print
'<td class="titlefield">' . $langs->trans(
"ImportId") .
'</td>';
900 print
'<div class="clearboth"></div>';
906 $result =
$object->fetchAllPerMvt($piece_num, $mode);
912 $tmptoselect = array();
913 $atleastonevalidated = 0;
914 $atleastoneexported = 0;
915 foreach (
$object->linesmvt as $line) {
916 $tmptoselect[] = $line->id;
917 if (!empty($line->date_validation)) {
918 $atleastonevalidated = 1;
920 if (!empty($line->date_export) || !empty($line->date_validation)) {
921 $atleastoneexported = 1;
925 if ($mode !=
'_tmp' && !$atleastonevalidated) {
926 print
"\n".
'<div class="tabsAction">'.
"\n";
928 $parameters = array();
929 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters,
$object, $action);
930 if (empty($reshook)) {
931 if ($permissiontodelete) {
932 if (!isset($hookmanager->resArray[
'no_button_edit']) || $hookmanager->resArray[
'no_button_edit'] != 1) {
933 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);
936 if ($permissiontoadd) {
937 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);
947 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?piece_num='.((int)
$object->piece_num).
'" method="POST">';
948 if ($optioncss !=
'') {
949 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
951 print
'<input type="hidden" name="token" value="'.newToken().
'">';
952 print
'<input type="hidden" name="doc_date" value="'.$object->doc_date.
'">'.
"\n";
953 print
'<input type="hidden" name="doc_type" value="'.$object->doc_type.
'">'.
"\n";
954 print
'<input type="hidden" name="doc_ref" value="'.$object->doc_ref.
'">'.
"\n";
955 print
'<input type="hidden" name="ref" value="'.$object->ref.
'">'.
"\n";
956 print
'<input type="hidden" name="code_journal" value="'.$object->code_journal.
'">'.
"\n";
957 print
'<input type="hidden" name="fk_doc" value="'.$object->fk_doc.
'">'.
"\n";
958 print
'<input type="hidden" name="fk_docdet" value="'.$object->fk_docdet.
'">'.
"\n";
959 print
'<input type="hidden" name="mode" value="'.$mode.
'">'.
"\n";
960 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
961 print
'<input type="hidden" name="type" value="'.$type.
'">';
963 if (count(
$object->linesmvt) > 0) {
964 print
'<div class="div-table-responsive-no-min">';
965 print
'<table class="noborder centpercent">';
970 print
'<tr class="liste_titre">';
977 if (empty(
$object->date_validation)) {
986 if (!empty(
$object->linesmvt[0])) {
987 $tmpline =
$object->linesmvt[0];
988 if (!empty($tmpline->numero_compte)) {
994 foreach (
$object->linesmvt as $line) {
995 $total_debit += $line->debit;
996 $total_credit += $line->credit;
998 if ($action ==
'update' && $line->id == $id) {
999 print
'<tr class="oddeven" data-lineid="'.((int) $line->id).
'">';
1000 print
'<!-- td columns in edit mode -->';
1002 print $formaccounting->select_account((GETPOSTISSET(
"accountingaccount_number") ?
GETPOST(
"accountingaccount_number",
"alpha") : $line->numero_compte),
'accountingaccount_number', 1, array(), 1, 1,
'minwidth200 maxwidth500');
1010 print $formaccounting->select_auxaccount((GETPOSTISSET(
"subledger_account") ?
GETPOST(
"subledger_account",
"alpha") : $line->subledger_account),
'subledger_account', 1,
'maxwidth250',
'',
'subledger_label');
1012 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")).
'">';
1015 print
'<br><input type="text" class="maxwidth150" name="subledger_label" value="'.(GETPOSTISSET(
"subledger_label") ?
GETPOST(
"subledger_label",
"alpha") : $line->subledger_label).
'" placeholder="'.
dol_escape_htmltag($langs->trans(
"SubledgerAccountLabel")).
'">';
1017 print
'<td><input type="text" class="minwidth200" name="label_operation" value="'.(GETPOSTISSET(
"label_operation") ?
GETPOST(
"label_operation",
"alpha") : $line->label_operation).
'"></td>';
1018 print
'<td class="right"><input type="text" class="right width50" name="debit" value="'.(GETPOSTISSET(
"debit") ?
GETPOST(
"debit",
"alpha") :
price($line->debit)).
'"></td>';
1019 print
'<td class="right"><input type="text" class="right width50" name="credit" value="'.(GETPOSTISSET(
"credit") ?
GETPOST(
"credit",
"alpha") :
price($line->credit)).
'"></td>';
1021 print
'<input type="hidden" name="id" value="'.$line->id.
'">'.
"\n";
1022 print
'<input type="submit" class="button" name="update" value="'.$langs->trans(
"Update").
'">';
1025 } elseif (empty($line->numero_compte) || (empty($line->debit) && empty($line->credit))) {
1026 if (($action ==
"" || $action ==
'add') && $permissiontoadd) {
1027 print
'<tr class="oddeven" data-lineid="'.((int) $line->id).
'">';
1028 print
'<!-- td columns in add mode -->';
1030 print $formaccounting->select_account($action ==
'add' ?
GETPOST(
'accountingaccount_number') :
'',
'accountingaccount_number', 1, array(), 1, 1,
'minwidth200 maxwidth500');
1038 print $formaccounting->select_auxaccount(
'',
'subledger_account', 1,
'maxwidth250',
'',
'subledger_label');
1040 print
'<input type="text" class="maxwidth150" name="subledger_account" value="" placeholder="' .
dol_escape_htmltag($langs->trans(
"SubledgerAccount")) .
'">';
1042 print
'<br><input type="text" class="maxwidth150" name="subledger_label" value="" placeholder="' .
dol_escape_htmltag($langs->trans(
"SubledgerAccountLabel")) .
'">';
1044 print
'<td><input type="text" class="minwidth200" name="label_operation" value="' .
dol_escape_htmltag($label_operation) .
'"/></td>';
1045 print
'<td class="right"><input type="text" class="right width50" name="debit" value=""/></td>';
1046 print
'<td class="right"><input type="text" class="right width50" name="credit" value=""/></td>';
1047 print
'<td class="center"><input type="submit" class="button small" name="save" value="' . $langs->trans(
"Add") .
'"></td>';
1051 print
'<tr class="oddeven" data-lineid="'.((int) $line->id).
'">';
1052 print
'<!-- td columns in display mode -->';
1053 $resultfetch = $accountingaccount->fetch(0, $line->numero_compte,
true);
1055 if ($resultfetch > 0) {
1056 print $accountingaccount->getNomUrl(0, 1, 1,
'', 0);
1058 print
dol_escape_htmltag($line->numero_compte).
' <span class="warning">('.$langs->trans(
"AccountRemovedFromCurrentChartOfAccount").
')</span>';
1061 print
'<td>'.length_accounta($line->subledger_account);
1062 if ($line->subledger_label) {
1063 print
' - <span class="opacitymedium">'.dol_escape_htmltag($line->subledger_label).
'</span>';
1066 print
'<td>'.$line->label_operation.
'</td>';
1067 print
'<td class="right nowraponall amount">'.($line->debit != 0 ?
price($line->debit) :
'').
'</td>';
1068 print
'<td class="right nowraponall amount">'.($line->credit != 0 ?
price($line->credit) :
'').
'</td>';
1070 print
'<td class="center nowraponall">';
1071 if ($permissiontoadd) {
1072 if (empty($line->date_export) && empty($line->date_validation)) {
1073 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()) .
'">';
1074 print
img_edit(
'', 0,
'class="marginrightonly"');
1075 print
'</a> ';
1077 print
'<a class="editfielda nohover cursornotallowed reposition disabled" href="#" title="'.dol_escape_htmltag($langs->trans(
"ForbiddenTransactionAlreadyExported")).
'">';
1078 print
img_edit($langs->trans(
"ForbiddenTransactionAlreadyExported"), 0,
'class="marginrightonly"');
1079 print
'</a> ';
1082 if (empty($line->date_validation)) {
1083 $actiontodelete =
'delete';
1084 if ($mode ==
'_tmp' || $action !=
'delmouv') {
1085 $actiontodelete =
'confirm_delete';
1088 print
'<a href="' . $_SERVER[
"PHP_SELF"] .
'?action=' . $actiontodelete .
'&id=' . $line->id .
'&piece_num=' . ((int) $line->piece_num) .
'&mode=' . urlencode((
string) $mode) .
'&token=' . urlencode(
newToken()) .
'">';
1092 print
'<a class="editfielda nohover cursornotallowed disabled" href="#" title="'.dol_escape_htmltag($langs->trans(
"ForbiddenTransactionAlreadyExported")).
'">';
1093 print
img_delete($langs->trans(
"ForbiddenTransactionAlreadyValidated"));
1102 $total_debit =
price2num($total_debit,
'MT');
1103 $total_credit =
price2num($total_credit,
'MT');
1105 if ($total_debit != $total_credit) {
1106 setEventMessages(
null, array($langs->trans(
'MvtNotCorrectlyBalanced', $total_debit, $total_credit)),
'warnings');
1112 if ($mode ==
'_tmp' && $action ==
'' && $permissiontoadd) {
1114 print
'<div class="center">';
1115 if (empty($total_debit) && empty($total_credit)) {
1116 print
'<a class="button disabled cursornotallowed" disabled="disabled" href="#" title="'.dol_escape_htmltag($langs->trans(
"EnterNonEmptyLinesFirst")).
'">'.
dol_escape_htmltag($langs->trans(
"ValidTransaction")).
'</a>';
1117 } elseif ($total_debit == $total_credit) {
1118 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>';
1120 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>';
1124 print
'<a class="button button-cancel" href="'.$backtopage.(!empty($type) ?
'?type=sub' :
'').
'">'.$langs->trans(
"Cancel").
'</a>';
1133 print $langs->trans(
"NoRecordFound");
$id
Support class for third parties, contacts, members, users or resources.
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Class to manage 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...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
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_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.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
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_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
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.