From 4c72567c6b34b398811fce3f1cf7ed7b73144ca0 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Wed, 8 Jul 2015 07:19:23 +0200 Subject: [PATCH] Update bookkeeping --- htdocs/accountancy/bookkeeping/card.php | 609 ++++++++++++------------ htdocs/accountancy/bookkeeping/list.php | 13 +- htdocs/langs/en_US/accountancy.lang | 1 + 3 files changed, 313 insertions(+), 310 deletions(-) diff --git a/htdocs/accountancy/bookkeeping/card.php b/htdocs/accountancy/bookkeeping/card.php index 3656ae9f929..c1101fb6349 100644 --- a/htdocs/accountancy/bookkeeping/card.php +++ b/htdocs/accountancy/bookkeeping/card.php @@ -1,7 +1,7 @@ - * Copyright (C) 2013-2014 Florian Henry - * Copyright (C) 2013-2015 Alexandre Spangaro +/* Copyright (C) 2013-2014 Olivier Geffroy + * Copyright (C) 2013-2014 Florian Henry + * Copyright (C) 2013-2015 Alexandre Spangaro * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,23 +18,23 @@ */ /** - * \file htdocs/accountancy/bookkeeping/card.php - * \ingroup Accounting Expert - * \brief Page to show account + * \file htdocs/accountancy/bookkeeping/card.php + * \ingroup Accounting Expert + * \brief Page to show account */ require '../../main.inc.php'; - + // Class require_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php'; // Langs -$langs->load("accounting"); +$langs->load("accountancy"); // Security check $id = GETPOST('id', 'int'); if ($user->societe_id > 0) - accessforbidden(); + accessforbidden(); $action = GETPOST('action'); $piece_num = GETPOST("piece_num"); @@ -48,132 +48,132 @@ $debit = price2num(GETPOST('debit')); $credit = price2num(GETPOST('credit')); if ($action == "confirm_update") { - - $error = 0; - - if ((intval($debit) != 0) && (intval($credit) != 0)) { - setEventMessage($langs->trans('ErrorDebitCredit'), 'errors'); - $error ++; - } - - if (empty($error)) { - $book = new BookKeeping($db); - - $result = $book->fetch($id); - if ($result < 0) { - setEventMessage($book->errors, 'errors'); - } else { - $book->numero_compte = $numero_compte; - $book->code_tiers = $code_tiers; - $book->label_compte = $label_compte; - $book->debit = $debit; - $book->credit = $credit; - - if (! empty($debit)) { - $book->montant = $debit; - $book->sens = 'D'; - } - if (! empty($credit)) { - $book->montant = $credit; - $book->sens = 'C'; - } - - $result = $book->update(); - if ($result < 0) { - setEventMessage($book->errors, 'errors'); - } else { - setEventMessage($langs->trans('Saved'), 'mesgs'); - $action = ''; - } - } - } -} + + $error = 0; + + if ((intval($debit) != 0) && (intval($credit) != 0)) { + setEventMessage($langs->trans('ErrorDebitCredit'), 'errors'); + $error ++; + } + + if (empty($error)) { + $book = new BookKeeping($db); + + $result = $book->fetch($id); + if ($result < 0) { + setEventMessage($book->errors, 'errors'); + } else { + $book->numero_compte = $numero_compte; + $book->code_tiers = $code_tiers; + $book->label_compte = $label_compte; + $book->debit = $debit; + $book->credit = $credit; + + if (! empty($debit)) { + $book->montant = $debit; + $book->sens = 'D'; + } + if (! empty($credit)) { + $book->montant = $credit; + $book->sens = 'C'; + } + + $result = $book->update(); + if ($result < 0) { + setEventMessage($book->errors, 'errors'); + } else { + setEventMessage($langs->trans('Saved'), 'mesgs'); + $action = ''; + } + } + } +} else if ($action == "add") { - - $error = 0; - if ((intval($debit) != 0) && (intval($credit) != 0)) { - setEventMessage($langs->trans('ErrorDebitCredit'), 'errors'); - $error ++; - } - - if (empty($error)) { - $book = new BookKeeping($db); - - $book->numero_compte = $numero_compte; - $book->code_tiers = $code_tiers; - $book->label_compte = $label_compte; - $book->debit = $debit; - $book->credit = $credit; - $book->doc_date = GETPOST('doc_date'); - $book->doc_type = GETPOST('doc_type'); - $book->piece_num = $piece_num; - $book->doc_ref = GETPOST('doc_ref'); - $book->code_journal = GETPOST('code_journal'); - $book->fk_doc = GETPOST('fk_doc'); - $book->fk_docdet = GETPOST('fk_docdet'); - - if (! empty($debit)) { - $book->montant = $debit; - $book->sens = 'D'; - } - if (! empty($credit)) { - $book->montant = $credit; - $book->sens = 'C'; - } - - $result = $book->create_std($user); - if ($result < 0) { - setEventMessage($book->errors, 'errors'); - } else { - setEventMessage($langs->trans('Saved'), 'mesgs'); - $action = ''; - } - } -} + $error = 0; + + if ((intval($debit) != 0) && (intval($credit) != 0)) { + setEventMessage($langs->trans('ErrorDebitCredit'), 'errors'); + $error ++; + } + + if (empty($error)) { + $book = new BookKeeping($db); + + $book->numero_compte = $numero_compte; + $book->code_tiers = $code_tiers; + $book->label_compte = $label_compte; + $book->debit = $debit; + $book->credit = $credit; + $book->doc_date = GETPOST('doc_date'); + $book->doc_type = GETPOST('doc_type'); + $book->piece_num = $piece_num; + $book->doc_ref = GETPOST('doc_ref'); + $book->code_journal = GETPOST('code_journal'); + $book->fk_doc = GETPOST('fk_doc'); + $book->fk_docdet = GETPOST('fk_docdet'); + + if (! empty($debit)) { + $book->montant = $debit; + $book->sens = 'D'; + } + if (! empty($credit)) { + $book->montant = $credit; + $book->sens = 'C'; + } + + $result = $book->create_std($user); + if ($result < 0) { + setEventMessage($book->errors, 'errors'); + } else { + setEventMessage($langs->trans('Saved'), 'mesgs'); + $action = ''; + } + } +} else if ($action == "confirm_delete") { - $book = new BookKeeping($db); - - $result = $book->fetch($id); - - $piece_num = $book->piece_num; - - if ($result < 0) { - setEventMessage($book->errors, 'errors'); - } else { - $result = $book->delete($user); - if ($result < 0) { - setEventMessage($book->errors, 'errors'); - } - } - $action = ''; -} + $book = new BookKeeping($db); + + $result = $book->fetch($id); + + $piece_num = $book->piece_num; + + if ($result < 0) { + setEventMessage($book->errors, 'errors'); + } else { + $result = $book->delete($user); + if ($result < 0) { + setEventMessage($book->errors, 'errors'); + } + } + $action = ''; +} else if ($action == "confirm_create") { - $book = new BookKeeping($db); - - $book->label_compte = ''; - $book->debit = 0; - $book->credit = 0; - $book->doc_date = $date_start = dol_mktime(0, 0, 0, GETPOST('doc_datemonth'), GETPOST('doc_dateday'), GETPOST('doc_dateyear')); - $book->doc_type = GETPOST('doc_type'); - $book->piece_num = GETPOST('next_num_mvt'); - $book->doc_ref = GETPOST('doc_ref'); - $book->code_journal = GETPOST('code_journal'); - $book->fk_doc = 0; - $book->fk_docdet = 0; - - $book->montant = 0; - - $result = $book->create_std($user); - if ($result < 0) { - setEventMessage($book->errors, 'errors'); - } else { - setEventMessage($langs->trans('Saved'), 'mesgs'); - $action = ''; - $piece_num = $book->piece_num; - } + $book = new BookKeeping($db); + + $book->label_compte = ''; + $book->debit = 0; + $book->credit = 0; + $book->doc_date = $date_start = dol_mktime(0, 0, 0, GETPOST('doc_datemonth'), GETPOST('doc_dateday'), GETPOST('doc_dateyear')); + $book->doc_type = GETPOST('doc_type'); + $book->piece_num = GETPOST('next_num_mvt'); + $book->doc_ref = GETPOST('doc_ref'); + $book->code_journal = GETPOST('code_journal'); + $book->fk_doc = 0; + $book->fk_docdet = 0; + + $book->montant = 0; + + $result = $book->create_std($user); + if ($result < 0) { + setEventMessage($book->errors, 'errors'); + } else { + setEventMessage($langs->trans('Saved'), 'mesgs'); + $action = ''; + $piece_num = $book->piece_num; + } } llxHeader(); @@ -181,197 +181,194 @@ llxHeader(); $html = new Form($db); /* - * Confirmation to delete the command + * Confirmation to delete the command */ if ($action == 'delete') { - $formconfirm = $html->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $id, $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvt'), 'confirm_delete', '', 0, 1); - print $formconfirm; + $formconfirm = $html->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $id, $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvt'), 'confirm_delete', '', 0, 1); + print $formconfirm; } if ($action == 'create') { - - print_fiche_titre($langs->trans("CreateMvts")); - - $code_journal_array = array ( - $conf->global->ACCOUNTING_SELL_JOURNAL => $conf->global->ACCOUNTING_SELL_JOURNAL, - $conf->global->ACCOUNTING_PURCHASE_JOURNAL => $conf->global->ACCOUNTING_PURCHASE_JOURNAL, - $conf->global->ACCOUNTING_BANK_JOURNAL => $conf->global->ACCOUNTING_BANK_JOURNAL, - $conf->global->ACCOUNTING_SOCIAL_JOURNAL => $conf->global->ACCOUNTING_SOCIAL_JOURNAL - ); - - $book = new BookKeeping($db); - $next_num_mvt = $book->getNextNumMvt(); - - print '
'; - print '' . "\n"; - print '' . "\n"; + print_fiche_titre($langs->trans("CreateMvts")); - dol_fiche_head(); + $code_journal_array = array ( + $conf->global->ACCOUNTING_SELL_JOURNAL => $conf->global->ACCOUNTING_SELL_JOURNAL, + $conf->global->ACCOUNTING_PURCHASE_JOURNAL => $conf->global->ACCOUNTING_PURCHASE_JOURNAL, + $conf->global->ACCOUNTING_SOCIAL_JOURNAL => $conf->global->ACCOUNTING_SOCIAL_JOURNAL, + $conf->global->ACCOUNTING_MISCELLANEOUS_JOURNAL => $conf->global->ACCOUNTING_MISCELLANEOUS_JOURNAL, + $conf->global->ACCOUNTING_EXPENSEREPORT_JOURNAL => $conf->global->ACCOUNTING_EXPENSEREPORT_JOURNAL + ); - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - - print ''; - print ''; - print ''; - - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print '
' . $langs->trans("NumMvts") . '' . $next_num_mvt . '
' . $langs->trans("Docdate") . ''; - print $html->select_date('', 'doc_date', '', '', '', "create_mvt", 1, 1); - print '
' . $langs->trans("Codejournal") . '' . $html->selectarray('code_journal', $code_journal_array) . '
' . $langs->trans("Docref") . '
' . $langs->trans("Doctype") . '
'; + $book = new BookKeeping($db); + $next_num_mvt = $book->getNextNumMvt(); + + print ''; + print '' . "\n"; + print '' . "\n"; + + dol_fiche_head(); + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + print ''; + print ''; + print ''; + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print '
' . $langs->trans("NumMvts") . '' . $next_num_mvt . '
' . $langs->trans("Docdate") . ''; + print $html->select_date('', 'doc_date', '', '', '', "create_mvt", 1, 1); + print '
' . $langs->trans("Codejournal") . '' . $html->selectarray('code_journal', $code_journal_array) . '
' . $langs->trans("Docref") . '
' . $langs->trans("Doctype") . '
'; dol_fiche_end(); - print '
'; + print '
'; print '     '; print '
'; - print ''; -} -else -{ - $book = new BookKeeping($db); - $result = $book->fetch_per_mvt($piece_num); - if ($result < 0) { - setEventMessage($book->errors, 'errors'); - } - if (! empty($book->piece_num)) { - - print_fiche_titre($langs->trans("UpdateMvts")); - - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print '
' . $langs->trans("NumMvts") . '' . $book->piece_num . '
' . $langs->trans("Docdate") . '' . dol_print_date($book->doc_date, 'daytextshort') . '
' . $langs->trans("Codejournal") . '' . $book->code_journal . '
' . $langs->trans("Docref") . '' . $book->doc_ref . '
' . $langs->trans("Doctype") . '' . $book->doc_type . '
'; - - $result = $book->fetch_all_per_mvt($piece_num); - if ($result < 0) { - setEventMessage($book->errors, 'errors'); - } else { - - print_fiche_titre($langs->trans("ListeMvts")); - print ""; - if (count($book->linesmvt) > 0) { - - print ''; - - print_liste_field_titre($langs->trans("Numerocompte")); - print_liste_field_titre($langs->trans("Code_tiers")); - print_liste_field_titre($langs->trans("Labelcompte")); - print_liste_field_titre($langs->trans("Debit")); - print_liste_field_titre($langs->trans("Credit")); - print_liste_field_titre($langs->trans("Amount")); - print_liste_field_titre($langs->trans("Sens")); - print_liste_field_titre(''); + print ''; +} else { + $book = new BookKeeping($db); + $result = $book->fetch_per_mvt($piece_num); + if ($result < 0) { + setEventMessage($book->errors, 'errors'); + } + if (! empty($book->piece_num)) { - print "\n"; - - foreach ( $book->linesmvt as $line ) { - $var = ! $var; - print ""; - - if ($action == 'update' && $line->id == $id) { - - print ''; - print '' . "\n"; - print '' . "\n"; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - } - else { - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - - print ''; - } - print "\n"; - } - - if ($action == "" || $action == 'add') { - $var = ! $var; - print ""; - - print ''; - print '' . "\n"; - print '' . "\n"; - print '' . "\n"; - print '' . "\n"; - print '' . "\n"; - print '' . "\n"; - print '' . "\n"; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - } - print '
' . $line->montant . '' . $line->sens . ''; - print ''; - print ''; - print '' . $line->numero_compte . '' . $line->code_tiers . '' . $line->label_compte . '' . $line->debit . '' . $line->credit . '' . $line->montant . '' . $line->sens . ''; - print ''; - print img_edit(); - print ' '; - print ''; - print img_delete(); - print ''; - - print '
'; - print ''; - } - } - } - else { - print_fiche_titre($langs->trans("NoRecords")); - } + print_fiche_titre($langs->trans("UpdateMvts")); + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print '
' . $langs->trans("NumMvts") . '' . $book->piece_num . '
' . $langs->trans("Docdate") . '' . dol_print_date($book->doc_date, 'daytextshort') . '
' . $langs->trans("Codejournal") . '' . $book->code_journal . '
' . $langs->trans("Docref") . '' . $book->doc_ref . '
' . $langs->trans("Doctype") . '' . $book->doc_type . '
'; + + $result = $book->fetch_all_per_mvt($piece_num); + if ($result < 0) { + setEventMessage($book->errors, 'errors'); + } else { + + print_fiche_titre($langs->trans("ListeMvts")); + print ""; + if (count($book->linesmvt) > 0) { + + print ''; + + print_liste_field_titre($langs->trans("Numerocompte")); + print_liste_field_titre($langs->trans("Code_tiers")); + print_liste_field_titre($langs->trans("Labelcompte")); + print_liste_field_titre($langs->trans("Debit")); + print_liste_field_titre($langs->trans("Credit")); + print_liste_field_titre($langs->trans("Amount")); + print_liste_field_titre($langs->trans("Sens")); + print_liste_field_titre(''); + + print "\n"; + + foreach ( $book->linesmvt as $line ) { + $var = ! $var; + print ""; + + if ($action == 'update' && $line->id == $id) { + + print ''; + print '' . "\n"; + print '' . "\n"; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + } else { + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + print ''; + } + print "\n"; + } + + if ($action == "" || $action == 'add') { + $var = ! $var; + print ""; + + print ''; + print '' . "\n"; + print '' . "\n"; + print '' . "\n"; + print '' . "\n"; + print '' . "\n"; + print '' . "\n"; + print '' . "\n"; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + } + print '
' . $line->montant . '' . $line->sens . ''; + print ''; + print ''; + print '' . $line->numero_compte . '' . $line->code_tiers . '' . $line->label_compte . '' . $line->debit . '' . $line->credit . '' . $line->montant . '' . $line->sens . ''; + print ''; + print img_edit(); + print ' '; + print ''; + print img_delete(); + print ''; + + print '
'; + print ''; + } + } + } + else { + print_fiche_titre($langs->trans("NoRecords")); + } } llxFooter(); diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index 6c06c2ba3d7..cc90b3873db 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -1,7 +1,7 @@ * Copyright (C) 2013-2014 Florian Henry - * Copyright (C) 2013-2014 Alexandre Spangaro + * Copyright (C) 2013-2015 Alexandre Spangaro * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -31,6 +31,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; require_once DOL_DOCUMENT_ROOT.'/accountancy/class/html.formventilation.class.php'; require_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php'; +// Langs +$langs->load("accountancy"); $page = GETPOST("page"); $sortorder = GETPOST("sortorder"); @@ -155,8 +157,6 @@ else { print ''; - print '' . $langs->trans("NewAccountingMvt") . '
'; - print '
'; print ''; print ''; @@ -209,7 +209,7 @@ else { print ""; print '' . $obj->doc_type . ''; - print '' . dol_print_date($db->jdate($obj->doc_date), 'day') . ''; + print '' . dol_print_date($db->jdate($obj->doc_date), 'day') . ''; print '' . $obj->doc_ref . ''; print '' . length_accountg($obj->numero_compte) . ''; print '' . length_accounta($obj->code_tiers) . ''; @@ -224,6 +224,11 @@ else { $i ++; } print ""; + + print ''; + $db->free($resql); } else { dol_print_error($db); diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang index c119a002641..f98e2cf929b 100644 --- a/htdocs/langs/en_US/accountancy.lang +++ b/htdocs/langs/en_US/accountancy.lang @@ -48,6 +48,7 @@ NewAccount=New accounting account Update=Update List=List Create=Create +CreateMvts=Create movement UpdateAccount=Modification of an accounting account UpdateMvts=Modification of a movement WriteBookKeeping=Record accounts in general ledger