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.
'/expensereport/class/expensereport.class.php';
38require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/accountingjournal.class.php';
39require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/accountingaccount.class.php';
40require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/lettering.class.php';
41require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/bookkeepingtemplate.class.php';
42require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/bookkeepingtemplateline.class.php';
53$langs->loadLangs(array(
"accountancy",
"bills",
"compta",
"errors"));
55$action =
GETPOST(
'action',
'aZ09');
56$cancel =
GETPOST(
'cancel',
'alpha');
57$confirm =
GETPOST(
'confirm',
'alpha');
59$type =
GETPOST(
'type',
'alpha');
60$backtopage =
GETPOST(
'backtopage',
'alpha');
61if (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'));
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');
204 $subledger_account_str = is_array($subledger_account) ? reset($subledger_account) : (
string) $subledger_account;
207 setEventMessages($langs->trans(
"ErrorAccountNotCentralized").
". " . $langs->trans(
"RemoveSubsidiaryAccountOrAdjustTheGeneralAccount"),
null,
'errors');
219 $object->numero_compte = $accountingaccount_number;
220 $object->subledger_account = $subledger_account;
221 $object->subledger_label = $subledger_label;
222 $object->label_compte = $accountingaccount_label;
223 $object->label_operation = $label_operation;
228 $object->piece_num = $piece_num;
231 $object->code_journal = $journal_code;
232 $object->journal_label = $journal_label;
236 if ((
float) $debit != 0.0) {
242 if ((
float) $credit != 0.0) {
248 $result =
$object->createStd($user, 0, $mode);
253 if ($mode !=
'_tmp') {
263 } elseif ($action ==
"confirm_delete" && $permissiontoadd) {
266 $result =
$object->fetch($id,
null, $mode);
267 $piece_num = (int)
$object->piece_num;
272 } elseif ($result > 0) {
273 $result =
$object->delete($user, 0, $mode);
279 } elseif ($action ==
"confirm_create" && $permissiontoadd) {
282 if (!$journal_code || $journal_code ==
'-1') {
283 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
"Journal")),
null,
'errors');
287 if (!
GETPOST(
'doc_ref',
'alpha')) {
288 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Piece")),
null,
'errors');
293 setEventMessages($langs->trans(
"ErrorFieldTooLong", $langs->transnoentitiesnoconv(
"Ref")),
null,
'errors');
308 $object->code_journal = $journal_code;
309 $object->journal_label = $journal_label;
316 $result =
$object->createStd($user, 0, $mode);
324 $piece_num =
$object->piece_num;
329 if ($template_id > 0) {
330 require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/bookkeepingtemplate.class.php';
331 require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/bookkeepingtemplateline.class.php';
334 $result_template = $template->fetch($template_id);
336 if ($result_template > 0 && !empty($template->lines)) {
340 foreach ($template->lines as $templateline) {
345 $bookkeeping->doc_type =
GETPOST(
'doctype',
'alpha');
346 $bookkeeping->piece_num = $piece_num;
347 $bookkeeping->doc_ref =
GETPOST(
'docref',
'alpha');
348 $bookkeeping->code_journal = $journal_code;
349 $bookkeeping->journal_label = $journal_label;
350 $bookkeeping->fk_doc = 0;
351 $bookkeeping->fk_docdet = 0;
355 $bookkeeping->numero_compte = $templateline->general_account;
356 $bookkeeping->label_compte = $templateline->general_label;
357 $bookkeeping->subledger_account = $templateline->subledger_account;
358 $bookkeeping->subledger_label = $templateline->subledger_label;
359 $bookkeeping->label_operation = $templateline->operation_label;
360 $bookkeeping->debit = (float) $templateline->debit;
361 $bookkeeping->credit = (float) $templateline->credit;
364 if ((
float) $bookkeeping->debit != 0.0) {
365 $bookkeeping->montant = $bookkeeping->debit;
366 $bookkeeping->amount = $bookkeeping->debit;
367 $bookkeeping->sens =
'D';
369 if ((
float) $bookkeeping->credit != 0.0) {
370 $bookkeeping->montant = $bookkeeping->credit;
371 $bookkeeping->amount = $bookkeeping->credit;
372 $bookkeeping->sens =
'C';
375 $result_line = $bookkeeping->createStd($user, 0,
'_tmp');
377 if ($result_line < 0) {
384 if (!$error_template) {
386 setEventMessages($langs->trans(
'TemplateLinesLoaded', count($template->lines)),
null,
'mesgs');
394 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?piece_num=".$piece_num.
"&mode=_tmp");
400 if ($action ==
'setdate' && $permissiontoadd) {
402 $result =
$object->updateByMvt($piece_num,
'doc_date',
$db->idate($datedoc), $mode);
406 if ($mode !=
'_tmp') {
413 if ($action ==
'setjournal' && $permissiontoadd) {
414 $result =
$object->updateByMvt($piece_num,
'code_journal', $journal_code, $mode);
415 $result =
$object->updateByMvt($piece_num,
'journal_label', $journal_label, $mode);
419 if ($mode !=
'_tmp') {
426 if ($action ==
'setdocref' && $permissiontoadd) {
427 $refdoc =
GETPOST(
'doc_ref',
'alpha');
428 $result =
$object->updateByMvt($piece_num,
'doc_ref', $refdoc, $mode);
432 if ($mode !=
'_tmp') {
439 if ($action ==
'setref' && $permissiontoadd && $numRefModel ===
'mod_bookkeeping_neon') {
440 $newref =
GETPOST(
'ref',
'alpha');
443 $object->error = $langs->trans(
"ErrorFieldTooLong", $langs->transnoentitiesnoconv(
"Ref"));
446 $result =
$object->updateByMvt($piece_num,
'ref', $newref, $mode);
451 if ($mode !=
'_tmp') {
459 if ($action ==
'valid' && $permissiontoadd) {
460 $result =
$object->transformTransaction(0, $piece_num);
465 $piece_num =
$object->piece_num;
467 $linkEntry =
'<a href="'.$_SERVER[
"PHP_SELF"].
'?piece_num='.(int) $piece_num.
'">'.$langs->trans(
'NumMvts').
': '.(int) $piece_num.
'</a>';
468 setEventMessages($langs->trans(
'RecordSaved').
' - '.$linkEntry,
null,
'mesgs',
'', 1);
472 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?piece_num=".(
int) $piece_num);
475 header(
"Location: ".$backtopage.
"?sortfield=t.piece_num&sortorder=asc".($type ?
'&type='.$type :
''));
482 $toselect_str = explode(
',',
GETPOST(
'toselect',
'alphanohtml'));
484 foreach ($toselect_str as $i) {
485 $toselect[] = (int) $i;
488 if ($action ==
'deletebookkeepingwriting' && $confirm ==
"yes" && $permissiontodelete) {
493 $nb_lettering = $lettering->bookkeepingLetteringAll($toselect,
true);
494 if ($nb_lettering < 0) {
503 foreach ($toselect as $toselectid) {
504 $result =
$object->fetch($toselectid);
505 if ($result >= 0 && (!isset(
$object->date_validation) ||
$object->date_validation ===
'')) {
514 } elseif ($result < 0) {
518 } elseif (isset(
$object->date_validation) &&
$object->date_validation !=
'') {
519 setEventMessages($langs->trans(
"ValidatedRecordWhereFound"),
null,
'errors');
532 } elseif ($nbok > 0) {
538 header(
"Location: ".DOL_URL_ROOT.
'/accountancy/bookkeeping/list.php?noreset=1');
545 if ($action ==
'clonebookkeepingwriting' && $confirm ==
"yes" && $permissiontoadd) {
547 $piece_num =
GETPOST(
'piece_num',
'alpha');
548 $journal_code =
GETPOST(
'code_journal',
'alpha');
553 $result =
$object->newClone($piece_num, $journal_code, $clonedate);
561 header(
"Location: " . $_SERVER[
'PHP_SELF'] .
"?piece_num=" . (
$object->getNextNumMvt() - 1));
578$title = $langs->trans(
"CreateMvts");
579$help_url =
'EN:Module_Double_Entry_Accounting|FR:Module_Comptabilité_en_Partie_Double';
581llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-accountancy accountancy-consultation page-card');
584if ($action ==
'delete') {
585 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$id.
'&mode='.$mode, $langs->trans(
'DeleteMvt'), $langs->trans(
'ConfirmDeleteMvt', $langs->transnoentitiesnoconv(
"RegistrationInAccounting")),
'confirm_delete',
'', 0, 1);
590if (!empty(
$conf->use_javascript_ajax)) {
591 print
"\n" .
'<script type="text/javascript">';
592 print
'$(document).ready(function () {
593 function toggleSubledger() {
594 var isCentral = $("#accountingaccount_number option:selected").data("centralized");
595 console.log("the selected general ledger account is centralised?", isCentral);
597 var isAjaxMode = $("#search_subledger_account").length > 0;
598 var $visibleSubledger = isAjaxMode
599 ? $("#search_subledger_account")
600 : $("#subledger_account");
603 $visibleSubledger.prop("disabled", false);
605 $("#subledger_account").prop("disabled", false).trigger("change");
607 $("#subledger_label").prop("disabled", false);
609 $visibleSubledger.prop("disabled", true).val("");
611 $("#subledger_account").val("").prop("disabled", true).trigger("change");
613 $("#subledger_account").val("");
615 $("#subledger_label").val("").prop("disabled", true);
621 $("#accountingaccount_number").on("change", toggleSubledger);
622 $("#accountingaccount_number").on("select2:select", toggleSubledger);
625 print
' </script>' .
"\n";
628if ($action ==
'create') {
632 $next_num_mvt =
$object->getNextNumMvt(
'_tmp');
634 if (empty($next_num_mvt)) {
638 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" name="create_mvt" method="POST">';
639 if ($optioncss !=
'') {
640 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
642 print
'<input type="hidden" name="token" value="'.newToken().
'">';
643 print
'<input type="hidden" name="action" value="confirm_create">'.
"\n";
644 print
'<input type="hidden" name="next_num_mvt" value="'.$next_num_mvt.
'">'.
"\n";
645 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
646 print
'<input type="hidden" name="type" value="'.$type.
'">';
647 print
'<input type="hidden" name="mode" value="_tmp">'.
"\n";
651 print
'<table class="border centpercent">';
654 print
'<td class="fieldrequired">'.$langs->trans(
"Docdate").
'</td>';
656 print $form->selectDate(
'',
'doc_date', 0, 0, 0,
"create_mvt", 1, 1);
661 print
'<td class="fieldrequired">'.$langs->trans(
"Codejournal").
'</td>';
662 print
'<td>'.$formaccounting->select_journal($journal_code,
'code_journal', 0, 0, 1, 1).
'</td>';
666 print
'<td class="fieldrequired">'.$form->textwithpicto($langs->trans(
"Piece"), $langs->trans(
"PieceDesc")).
'</td>';
667 print
'<td><input type="text" class="minwidth200" name="doc_ref" value="'.GETPOST(
'doc_ref',
'alpha').
'"></td>';
672 print
'<td>'.$form->textwithpicto($langs->trans(
"Ref"), $langs->trans(
"BankTransactionRef")).
'</td>';
674 if ($numRefModel ===
'mod_bookkeeping_neon') {
675 print
'<input type="text" class="minwidth200" name="ref" maxlength="30" value="">';
677 print
'<span class="opacitymedium">'.$langs->trans(
"Automatic").
'</span>';
683 print
'<td>'.$langs->trans(
"BookkeepingTemplate").
'</td>';
685 require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/bookkeepingtemplate.class.php';
687 $sql =
"SELECT rowid, code, label";
688 $sql .=
" FROM ".MAIN_DB_PREFIX.
"accounting_transaction_template";
689 $sql .=
" WHERE entity IN (".getEntity(
'accounting').
")";
690 $sql .=
" ORDER BY code ASC";
692 $resql =
$db->query($sql);
693 $templates = array();
696 $num =
$db->num_rows($resql);
699 $obj =
$db->fetch_object($resql);
700 $templates[$obj->rowid] = $obj->code.
' - '.$obj->label;
706 if (count($templates) > 0) {
707 print
'<select class="flat minwidth300" name="template_id" id="template_id">';
708 print
'<option value=""></option>';
709 foreach ($templates as $key => $label) {
714 print
'<span class="opacitymedium">'.$langs->trans(
"NoTemplateAvailable").
'</span>';
720 $reshookAddLine = $hookmanager->executeHooks(
'bookkeepingAddLine', $parameters, $object, $action);
726 print $form->buttonsSaveCancel(
"Create");
732 $result =
$object->fetchPerMvt($piece_num, $mode);
737 if (!empty(
$object->piece_num)) {
738 $backlink =
'<a href="'.DOL_URL_ROOT.
'/accountancy/bookkeeping/list.php?restore_lastsearch_values=1">'.$langs->trans(
'BackToList').
'</a>';
751 if ($mode ==
'_tmp') {
752 $object->context[
'mode'] = $mode;
753 $object->next_prev_filter =
'1=0';
757 $morehtmlref =
'<div style="clear: both;"></div>';
758 $morehtmlref .=
'<div class="refidno opacitymedium">';
759 $morehtmlref .=
$object->label;
760 $morehtmlref .=
'</div>';
762 dol_banner_tab($object,
'ref', $backlink, 1,
'piece_num',
'piece_num', $morehtmlref);
765 if ($action ==
'clonebookkeepingwriting' && $confirm !=
'yes' && $permissiontoadd) {
766 $piece_num =
GETPOST(
'piece_num',
'alpha');
770 $input1 = $form->selectDate(
'',
'clonedate', 0, 0, 0,
"", 1, 1);
771 $input2 = $formaccounting->select_journal($journal_code,
'code_journal', 0, 0, 1, 1);
773 $formquestion = array(
776 'name' =>
'clonedate',
777 'label' =>
'<span class="fieldrequired">' . $langs->trans(
"Docdate") .
'</span>',
782 $formquestion[] = array(
'type' =>
'hidden',
'name' =>
'piece_num',
'value' => $piece_num);
785 $formquestion[] = array(
787 'name' =>
'code_journal',
788 'label' =>
'<span class="fieldrequired">' . $langs->trans(
"Codejournal") .
'</span>',
793 print $form->formconfirm(
794 $_SERVER[
"PHP_SELF"],
795 $langs->trans(
"ConfirmMassCloneBookkeepingWriting"),
796 $langs->trans(
"ConfirmMassCloneBookkeepingWritingQuestion", 1),
797 "clonebookkeepingwriting",
804 print
'<div class="fichecenter">';
806 print
'<div class="fichehalfleft">';
808 print
'<div class="underbanner clearboth"></div>';
809 print
'<table class="border tableforfield centpercent">';
820 print
'<tr><td class="titlefieldmiddle">';
821 print
'<table class="nobordernopadding centpercent"><tr><td>';
822 print $langs->trans(
'Ref');
824 if ($action !=
'editref' && empty(
$object->date_validation)) {
825 print
'<td class="right">';
826 if ($permissiontoadd && $numRefModel ===
'mod_bookkeeping_neon') {
827 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>';
831 print
'</tr></table>';
833 if ($action ==
'editref' && empty(
$object->date_validation)) {
834 print
'<form name="setref" action="'.$_SERVER[
"PHP_SELF"].
'?piece_num='.((int)
$object->piece_num).
'" method="POST">';
835 if ($optioncss !=
'') {
836 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
838 print
'<input type="hidden" name="token" value="'.newToken().
'">';
839 print
'<input type="hidden" name="action" value="setref">';
840 print
'<input type="hidden" name="mode" value="'.$mode.
'">';
841 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
842 print
'<input type="hidden" name="type" value="'.$type.
'">';
843 print
'<input type="text" size="20" name="ref" maxlength="30" value="'.dol_escape_htmltag(
$object->ref).
'">';
844 print
'<input type="submit" class="button button-edit smallpaddingimp" value="'.$langs->trans(
'Modify').
'">';
854 print
'<table class="nobordernopadding centpercent"><tr><td>';
855 print $form->textwithpicto($langs->trans(
'Piece'), $langs->trans(
'PieceDesc'));
857 if ($action !=
'editdocref') {
858 print
'<td class="right">';
859 if ($permissiontoadd && empty(
$object->date_validation)) {
860 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>';
864 print
'</tr></table>';
866 if ($action ==
'editdocref' && empty(
$object->date_validation)) {
867 print
'<form name="setdocref" action="'.$_SERVER[
"PHP_SELF"].
'?piece_num='.((int)
$object->piece_num).
'" method="POST">';
868 if ($optioncss !=
'') {
869 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
871 print
'<input type="hidden" name="token" value="'.newToken().
'">';
872 print
'<input type="hidden" name="action" value="setdocref">';
873 print
'<input type="hidden" name="mode" value="'.$mode.
'">';
874 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
875 print
'<input type="hidden" name="type" value="'.$type.
'">';
876 print
'<input type="text" size="20" name="doc_ref" value="'.dol_escape_htmltag(
$object->doc_ref).
'">';
877 print
'<input type="submit" class="button button-edit smallpaddingimp" value="'.$langs->trans(
'Modify').
'">';
881 if (
$object->doc_type ===
'customer_invoice' && !empty(
$object->fk_doc)) {
883 $result = $invoicestatic->fetch(
$object->fk_doc);
886 $label_element = $invoicestatic->getNomUrl(1);
888 $label_element =
$object->doc_ref;
890 } elseif (
$object->doc_type ===
'supplier_invoice' && !empty(
$object->fk_doc)) {
892 $result = $supplierinvoicestatic->fetch(
$object->fk_doc);
895 $label_element = $supplierinvoicestatic->getNomUrl(1);
897 $label_element =
$object->doc_ref;
899 } elseif (
$object->doc_type ===
'expense_report' && !empty(
$object->fk_doc)) {
901 $result = $expensereportstatic->fetch(
$object->fk_doc);
904 $label_element = $expensereportstatic->getNomUrl(1);
906 $label_element =
$object->doc_ref;
909 $label_element =
$object->doc_ref;
911 print $label_element;
918 print
'<table class="nobordernopadding centpercent"><tr><td>';
919 print $langs->trans(
'Docdate');
921 if ($action !=
'editdate') {
922 print
'<td class="right">';
923 if ($permissiontoadd && empty(
$object->date_validation)) {
924 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>';
928 print
'</tr></table>';
929 print
'</td><td colspan="3">';
930 if ($action ==
'editdate' && empty(
$object->date_validation)) {
931 print
'<form name="setdate" action="'.$_SERVER[
"PHP_SELF"].
'?piece_num='.((int)
$object->piece_num).
'" method="POST">';
932 if ($optioncss !=
'') {
933 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
935 print
'<input type="hidden" name="token" value="'.newToken().
'">';
936 print
'<input type="hidden" name="action" value="setdate">';
937 print
'<input type="hidden" name="mode" value="'.$mode.
'">';
938 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
939 print
'<input type="hidden" name="type" value="'.$type.
'">';
940 print $form->selectDate(
$object->doc_date ?
$object->doc_date : -1,
'doc_date', 0, 0, 0,
"setdate");
941 print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
'Modify').
'">';
951 print
'<table class="nobordernopadding centpercent"><tr><td>';
952 print $langs->trans(
'Codejournal');
954 if ($action !=
'editjournal') {
955 print
'<td class="right">';
956 if ($permissiontoadd && empty(
$object->date_validation)) {
957 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>';
961 print
'</tr></table>';
963 if ($action ==
'editjournal' && empty(
$object->date_validation)) {
964 print
'<form name="setjournal" action="'.$_SERVER[
"PHP_SELF"].
'?piece_num='.((int)
$object->piece_num).
'" method="POST">';
965 if ($optioncss !=
'') {
966 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
968 print
'<input type="hidden" name="token" value="'.newToken().
'">';
969 print
'<input type="hidden" name="action" value="setjournal">';
970 print
'<input type="hidden" name="mode" value="'.$mode.
'">';
971 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
972 print
'<input type="hidden" name="type" value="'.$type.
'">';
973 print $formaccounting->select_journal(
$object->code_journal,
'code_journal', 0, 0, 0, 1,
'');
974 print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
'Modify').
'">';
979 $accountingjournalstatic->fetch(0,
$object->code_journal);
980 $journal = $accountingjournalstatic->code;
981 $journal_label = $accountingjournalstatic->label;
983 print $accountingjournalstatic->getNomUrl(1, 1, 1);
993 print
'<div class="fichehalfright">';
995 print
'<div class="underbanner clearboth"></div>';
996 print
'<table class="border tableforfield centpercent">';
999 if (!empty(
$object->doc_type)) {
1001 print
'<td class="titlefield">'.$langs->trans(
"Doctype").
'</td>';
1002 print
'<td>'.$object->doc_type.
'</td>';
1008 print
'<td class="titlefield">'.$langs->trans(
"DateCreation").
'</td>';
1017 print
'<td class="titlefield">' . $form->textwithpicto($langs->trans(
'DateDue'), $langs->trans(
"IfTransactionHasDueDate")) .
'</td>';
1025 if ($mode !=
"_tmp") {
1028 print
'<td class="titlefield">' . $langs->trans(
"DateExport") .
'</td>';
1030 print
$object->date_export ?
img_picto($langs->trans(
"TransactionExportDesc"),
'fa-file-export',
'class="pictofixedwidth opacitymedium"').dol_print_date(
$object->date_export,
'dayhour') :
' ';
1036 print
'<td class="titlefield">' . $langs->trans(
"DateValidation") .
'</td>';
1038 print
$object->date_validation ?
img_picto($langs->trans(
"TransactionBlockedLockedDesc"),
'fa-lock',
'class="pictofixedwidth opacitymedium"').dol_print_date(
$object->date_validation,
'dayhour') :
' ';
1043 if (!empty(
$object->import_key)) {
1045 print
'<td class="titlefield">' . $langs->trans(
"ImportId") .
'</td>';
1098 print
'<div class="clearboth"></div>';
1104 $result =
$object->fetchAllPerMvt($piece_num, $mode);
1110 $tmptoselect = array();
1111 $atleastonevalidated = 0;
1112 $atleastoneexported = 0;
1113 foreach (
$object->linesmvt as $line) {
1114 $tmptoselect[] = $line->id;
1115 if (!empty($line->date_validation)) {
1116 $atleastonevalidated = 1;
1118 if (!empty($line->date_export) || !empty($line->date_validation)) {
1119 $atleastoneexported = 1;
1123 if ($mode !=
'_tmp' && !$atleastonevalidated) {
1124 print
"\n".
'<div class="tabsAction">'.
"\n";
1126 $parameters = array();
1127 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
1128 if (empty($reshook)) {
1129 if ($permissiontodelete) {
1130 if (!isset($hookmanager->resArray[
'no_button_edit']) || $hookmanager->resArray[
'no_button_edit'] != 1) {
1131 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);
1134 if ($permissiontoadd) {
1135 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);
1145 if (empty(
$object->date_validation)) {
1146 print
'<form action="' . $_SERVER[
"PHP_SELF"] .
'?piece_num=' . ((int)
$object->piece_num) .
'" method="POST">';
1147 if ($optioncss !=
'') {
1148 print
'<input type="hidden" name="optioncss" value="' . $optioncss .
'">';
1150 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
1151 print
'<input type="hidden" name="doc_date" value="' .
$object->doc_date .
'">' .
"\n";
1152 print
'<input type="hidden" name="doc_type" value="' .
$object->doc_type .
'">' .
"\n";
1153 print
'<input type="hidden" name="doc_ref" value="' .
$object->doc_ref .
'">' .
"\n";
1154 print
'<input type="hidden" name="ref" value="' .
$object->ref .
'">' .
"\n";
1155 print
'<input type="hidden" name="code_journal" value="' .
$object->code_journal .
'">' .
"\n";
1156 print
'<input type="hidden" name="fk_doc" value="' .
$object->fk_doc .
'">' .
"\n";
1157 print
'<input type="hidden" name="fk_docdet" value="' .
$object->fk_docdet .
'">' .
"\n";
1158 print
'<input type="hidden" name="mode" value="' . $mode .
'">' .
"\n";
1159 print
'<input type="hidden" name="backtopage" value="' . $backtopage .
'">';
1160 print
'<input type="hidden" name="type" value="' . $type .
'">';
1163 if (count(
$object->linesmvt) > 0) {
1164 print
'<div class="div-table-responsive-no-min">';
1165 print
'<table class="noborder centpercent">';
1170 print
'<tr class="liste_titre">';
1177 if (empty(
$object->date_validation)) {
1186 if (!empty(
$object->linesmvt[0]) && empty(
$object->date_validation)) {
1187 $tmpline =
$object->linesmvt[0];
1188 if (!empty($tmpline->numero_compte)) {
1194 foreach (
$object->linesmvt as $line) {
1195 $total_debit += $line->debit;
1196 $total_credit += $line->credit;
1198 if ($action ==
'update' && $line->id == $id && empty(
$object->date_validation)) {
1199 print
'<tr class="oddeven" data-lineid="'.((int) $line->id).
'">';
1200 print
'<!-- td columns in edit mode -->';
1202 print $formaccounting->select_account((
GETPOSTISSET(
"accountingaccount_number") ?
GETPOST(
"accountingaccount_number",
"alpha") : $line->numero_compte),
'accountingaccount_number', 1, array(), 1, 1,
'minwidth200 maxwidth500');
1205 print $formaccounting->select_auxaccount((
GETPOSTISSET(
"subledger_account") ?
GETPOST(
"subledger_account",
"alpha") : $line->subledger_account),
'subledger_account', 1,
'maxwidth250',
'',
'subledger_label');
1207 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")).
'">';
1209 print
'<td><input type="text" class="minwidth200" name="label_operation" value="'.(GETPOSTISSET(
"label_operation") ?
GETPOST(
"label_operation",
"alpha") : $line->label_operation).
'"></td>';
1210 print
'<td class="right"><input type="text" class="right width50" name="debit" value="'.(GETPOSTISSET(
"debit") ?
GETPOST(
"debit",
"alpha") :
price($line->debit)).
'"></td>';
1211 print
'<td class="right"><input type="text" class="right width50" name="credit" value="'.(GETPOSTISSET(
"credit") ?
GETPOST(
"credit",
"alpha") :
price($line->credit)).
'"></td>';
1213 print
'<input type="hidden" name="id" value="'.$line->id.
'">'.
"\n";
1214 print
'<input type="submit" class="button" name="update" value="'.$langs->trans(
"Update").
'">';
1217 } elseif ((empty($line->numero_compte) || (empty($line->debit) && empty($line->credit))) && empty(
$object->date_validation)) {
1218 if (($action ==
"" || $action ==
'add') && $permissiontoadd) {
1219 print
'<tr class="oddeven" data-lineid="'.((int) $line->id).
'">';
1220 print
'<!-- td columns in add mode -->';
1222 print $formaccounting->select_account($action ==
'add' ?
GETPOST(
'accountingaccount_number') :
'',
'accountingaccount_number', 1, array(), 1, 1,
'minwidth200 maxwidth500');
1225 print $formaccounting->select_auxaccount(
'',
'subledger_account', 1,
'maxwidth250',
'',
'subledger_label');
1226 print
'<br><input type="text" class="maxwidth150" name="subledger_label" id="subledger_label" value="" placeholder="' .
dol_escape_htmltag($langs->trans(
"SubledgerAccountLabel")) .
'">';
1228 print
'<td><input type="text" class="minwidth200" name="label_operation" value="' .
dol_escape_htmltag($label_operation) .
'"/></td>';
1229 print
'<td class="right"><input type="text" class="right width50" name="debit" value=""/></td>';
1230 print
'<td class="right"><input type="text" class="right width50" name="credit" value=""/></td>';
1231 print
'<td class="center"><input type="submit" class="button small" name="save" value="' . $langs->trans(
"Add") .
'"></td>';
1235 print
'<tr class="oddeven" data-lineid="'.((int) $line->id).
'">';
1236 print
'<!-- td columns in display mode -->';
1237 $resultfetch = $accountingaccount->fetch(0, $line->numero_compte,
true);
1239 if ($resultfetch > 0) {
1240 print $accountingaccount->getNomUrl(0, 1, 1,
'', 0);
1242 print
dol_escape_htmltag($line->numero_compte).
' <span class="warning">('.$langs->trans(
"AccountRemovedFromCurrentChartOfAccount").
')</span>';
1245 print
'<td>'.length_accounta($line->subledger_account);
1246 if ($line->subledger_label) {
1247 print
' - <span class="opacitymedium">'.dol_escape_htmltag($line->subledger_label).
'</span>';
1250 print
'<td>'.$line->label_operation.
'</td>';
1251 print
'<td class="right nowraponall amount">'.($line->debit != 0 ?
price($line->debit) :
'').
'</td>';
1252 print
'<td class="right nowraponall amount">'.($line->credit != 0 ?
price($line->credit) :
'').
'</td>';
1254 print
'<td class="center nowraponall">';
1255 if ($permissiontoadd) {
1256 if (empty($line->date_export) && empty($line->date_validation)) {
1257 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()) .
'">';
1258 print
img_edit(
'', 0,
'class="marginrightonly"');
1259 print
'</a> ';
1261 print
'<a class="editfielda nohover cursornotallowed reposition disabled" href="#" title="'.dol_escape_htmltag($langs->trans(
"ForbiddenTransactionAlreadyExported")).
'">';
1262 print
img_edit($langs->trans(
"ForbiddenTransactionAlreadyExported"), 0,
'class="marginrightonly"');
1263 print
'</a> ';
1266 if (empty($line->date_validation)) {
1267 $actiontodelete =
'delete';
1268 if ($mode ==
'_tmp' || $action !=
'delmouv') {
1269 $actiontodelete =
'confirm_delete';
1272 print
'<a href="' . $_SERVER[
"PHP_SELF"] .
'?action=' . $actiontodelete .
'&id=' . $line->id .
'&piece_num=' . ((int) $line->piece_num) .
'&mode=' . urlencode((
string) $mode) .
'&token=' . urlencode(
newToken()) .
'">';
1276 print
'<a class="editfielda nohover cursornotallowed disabled" href="#" title="'.dol_escape_htmltag($langs->trans(
"ForbiddenTransactionAlreadyExported")).
'">';
1277 print
img_delete($langs->trans(
"ForbiddenTransactionAlreadyValidated"));
1286 $total_debit =
price2num($total_debit,
'MT');
1287 $total_credit =
price2num($total_credit,
'MT');
1289 if ($total_debit != $total_credit) {
1290 setEventMessages(
null, array($langs->trans(
'MvtNotCorrectlyBalanced', $total_debit, $total_credit)),
'warnings');
1296 if ($mode ==
'_tmp' && $action ==
'' && $permissiontoadd) {
1298 print
'<div class="center">';
1299 if (empty($total_debit) && empty($total_credit)) {
1300 print
'<a class="button disabled cursornotallowed" disabled="disabled" href="#" title="'.dol_escape_htmltag($langs->trans(
"EnterNonEmptyLinesFirst")).
'">'.
dol_escape_htmltag($langs->trans(
"ValidTransaction")).
'</a>';
1301 } elseif ($total_debit == $total_credit) {
1302 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>';
1304 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>';
1308 print
'<a class="button button-cancel" href="'.$backtopage.(!empty($type) ?
'?type=sub' :
'').
'">'.$langs->trans(
"Cancel").
'</a>';
1317 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)
Class for BookkeepingTemplate.
Class to manage Trips and Expenses.
Class to manage suppliers invoices.
Class to manage invoices.
$date_start
Variables from include:
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.
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'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
dolGetButtonAction($label, $text='', $actionType='default', $url='', $id='', $userRight=1, $params=array())
Function dolGetButtonAction.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
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.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
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...
print $langs trans("Show") . '< td style="' . $timeColor . '" align="center"> s</td > badge status0 badge status4 badge status3 Error badge status8< td align="center">< span class="badge ' . $badge . '"></span ></td >< td align="center">< a href="#" class="button button-small" onclick="openLogModal(this)" data-req="' . dol_escape_htmltag($reqSafe) . '" data-res="' . dol_escape_htmltag($resSafe) . '" data-err="' . dol_escape_htmltag($errSafe) . '">< span class="fa fa-search-plus"></span ></a ></td ></tr >< tr >< td colspan="' . $colspan . '" class="opacitymedium"></td ></tr ></table ></div ></form > logModal none logModal none s a JSON string
buildzip.php
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.