Merge pull request #7030 from aspangaro/6.0-fec3

Fix : Accountancy - Debug and add information in database
This commit is contained in:
Laurent Destailleur 2017-06-19 15:02:30 +02:00 committed by GitHub
commit cffb368bbd
40 changed files with 1105 additions and 625 deletions

View File

@ -8,7 +8,7 @@
* Copyright (C) 2011 Remy Younes <ryounes@gmail.com> * Copyright (C) 2011 Remy Younes <ryounes@gmail.com>
* Copyright (C) 2012-2015 Marcos García <marcosgdf@gmail.com> * Copyright (C) 2012-2015 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2012 Christophe Battarel <christophe.battarel@ltairis.fr> * Copyright (C) 2012 Christophe Battarel <christophe.battarel@ltairis.fr>
* Copyright (C) 2011-2016 Alexandre Spangaro <aspangaro.dolibarr@gmail.com> * Copyright (C) 2011-2016 Alexandre Spangaro <aspangaro@zendsi.com>
* Copyright (C) 2015 Ferran Marcet <fmarcet@2byte.es> * Copyright (C) 2015 Ferran Marcet <fmarcet@2byte.es>
* Copyright (C) 2016 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr> * Copyright (C) 2016 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
* *

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com> /* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2017 Alexandre Spangaro <aspangaro.dolibarr@gmail.com> * Copyright (C) 2013-2017 Alexandre Spangaro <aspangaro@zendsi.com>
* Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro> * Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify

View File

@ -8,7 +8,7 @@
* Copyright (C) 2011 Remy Younes <ryounes@gmail.com> * Copyright (C) 2011 Remy Younes <ryounes@gmail.com>
* Copyright (C) 2012-2015 Marcos García <marcosgdf@gmail.com> * Copyright (C) 2012-2015 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2012 Christophe Battarel <christophe.battarel@ltairis.fr> * Copyright (C) 2012 Christophe Battarel <christophe.battarel@ltairis.fr>
* Copyright (C) 2011-2016 Alexandre Spangaro <aspangaro.dolibarr@gmail.com> * Copyright (C) 2011-2016 Alexandre Spangaro <aspangaro@zendsi.com>
* Copyright (C) 2015 Ferran Marcet <fmarcet@2byte.es> * Copyright (C) 2015 Ferran Marcet <fmarcet@2byte.es>
* Copyright (C) 2016 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr> * Copyright (C) 2016 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
* *

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com> /* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2015 Alexandre Spangaro <aspangaro.dolibarr@gmail.com> * Copyright (C) 2013-2015 Alexandre Spangaro <aspangaro@zendsi.com>
* Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro> * Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2014 Marcos García <marcosgdf@gmail.com> * Copyright (C) 2014 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>

View File

@ -1,5 +1,5 @@
<?php <?php
/* Copyright (C) 2014-2016 Alexandre Spangaro <aspangaro.dolibarr@gmail.com> /* Copyright (C) 2014-2016 Alexandre Spangaro <aspangaro@zendsi.com>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com> /* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2017 Alexandre Spangaro <aspangaro.dolibarr@gmail.com> * Copyright (C) 2013-2017 Alexandre Spangaro <aspangaro@zendsi.com>
* Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro> * Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com> /* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2016 Alexandre Spangaro <aspangaro.dolibarr@gmail.com> * Copyright (C) 2013-2016 Alexandre Spangaro <aspangaro@zendsi.com>
* Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro> * Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2015 Ari Elbaz (elarifr) <github@accedinfo.com> * Copyright (C) 2015 Ari Elbaz (elarifr) <github@accedinfo.com>

View File

@ -1,7 +1,7 @@
<?php <?php
/* Copyright (C) 2016 Olivier Geffroy <jeff@jeffinfo.com> /* Copyright (C) 2016 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2016 Florian Henry <florian.henry@open-concept.pro> * Copyright (C) 2016 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2016 Alexandre Spangaro <aspangaro.dolibarr@gmail.com> * Copyright (C) 2016 Alexandre Spangaro <aspangaro@zendsi.com>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -142,7 +142,6 @@ else {
llxHeader('', $title_page); llxHeader('', $title_page);
// List // List
$nbtotalofrecords = ''; $nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
$nbtotalofrecords = $object->fetchAllBalance($sortorder, $sortfield, 0, 0, $filter); $nbtotalofrecords = $object->fetchAllBalance($sortorder, $sortfield, 0, 0, $filter);
@ -156,13 +155,11 @@ else {
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'; print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
$button = '<input type="submit" name="button_export_csv" class="butAction" value="' . $langs->trans("Export") . '" />'; $button = '<input type="submit" name="button_export_csv" class="butAction" value="' . $langs->trans("Export") . '" />';
print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $options, $sortfield, $sortorder, '', $result, $result, 'title_accountancy', 0, $button); print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $options, $sortfield, $sortorder, '', $result, $result, 'title_accountancy', 0, $button);
$moreforfilter = ''; $moreforfilter = '';
$moreforfilter .= '<div class="divsearchfield">'; $moreforfilter .= '<div class="divsearchfield">';
@ -200,7 +197,7 @@ else {
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print_liste_field_titre($langs->trans("AccountAccounting"), $_SERVER['PHP_SELF'], "t.numero_compte", "", $options, "", $sortfield, $sortorder); print_liste_field_titre($langs->trans("AccountAccounting"), $_SERVER['PHP_SELF'], "t.numero_compte", "", $options, "", $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Label"), $_SERVER['PHP_SELF'], "t.label_compte", "", $options, "", $sortfield, $sortorder); print_liste_field_titre($langs->trans("Label"), $_SERVER['PHP_SELF'], "t.label_operation", "", $options, "", $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Debit"), $_SERVER['PHP_SELF'], "t.debit", "", $options, 'align="right"', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Debit"), $_SERVER['PHP_SELF'], "t.debit", "", $options, 'align="right"', $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Credit"), $_SERVER['PHP_SELF'], "t.credit", "", $options, 'align="right"', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Credit"), $_SERVER['PHP_SELF'], "t.credit", "", $options, 'align="right"', $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Solde"), $_SERVER["PHP_SELF"], "", $options, "", 'align="right"', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Solde"), $_SERVER["PHP_SELF"], "", $options, "", 'align="right"', $sortfield, $sortorder);

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com> /* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2014 Alexandre Spangaro <aspangaro.dolibarr@gmail.com> * Copyright (C) 2013-2014 Alexandre Spangaro <aspangaro@zendsi.com>
* Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro> * Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr> * Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
* *

View File

@ -1,7 +1,7 @@
<?php <?php
/* Copyright (C) 2013-2016 Olivier Geffroy <jeff@jeffinfo.com> /* Copyright (C) 2013-2017 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2016 Florian Henry <florian.henry@open-concept.pro> * Copyright (C) 2013-2017 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2013-2017 Alexandre Spangaro <aspangaro@zendsi.com> * Copyright (C) 2013-2017 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -16,7 +16,6 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
/** /**
* \file htdocs/accountancy/bookkeeping/card.php * \file htdocs/accountancy/bookkeeping/card.php
* \ingroup Advanced accountancy * \ingroup Advanced accountancy
@ -24,38 +23,33 @@
*/ */
require '../../main.inc.php'; require '../../main.inc.php';
// Class
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php'; require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php'; require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php';
require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php';
// Langs
$langs->load("accountancy"); $langs->load("accountancy");
$langs->load("bank");
$langs->load("bills");
$langs->load("trips");
// Security check // Security check
$id = GETPOST('id', 'int'); $id = GETPOST('id', 'int');
if ($user->societe_id > 0) { if ($user->societe_id > 0) {
accessforbidden(); accessforbidden();
} }
$action = GETPOST('action');
$action = GETPOST('action','aZ09'); $mode = GETPOST('mode');
$piece_num = GETPOST("piece_num"); $piece_num = GETPOST("piece_num");
$mesg = ''; $mesg = '';
$account_number = GETPOST('account_number'); $account_number = GETPOST('account_number');
$subledger_account = GETPOST('subledger_account'); $code_tiers = GETPOST('code_tiers');
if ($subledger_account == - 1) { if ($code_tiers == - 1) {
$subledger_account = null; $code_tiers = null;
} }
$label_compte = GETPOST('label_compte'); $label_compte = GETPOST('label_compte');
$label_operation= GETPOST('label_operation');
$debit = price2num(GETPOST('debit')); $debit = price2num(GETPOST('debit'));
$credit = price2num(GETPOST('credit')); $credit = price2num(GETPOST('credit'));
$save = GETPOST('save'); $save = GETPOST('save');
if (! empty($save)) { if (! empty($save)) {
$action = 'add'; $action = 'add';
@ -64,29 +58,25 @@ $update = GETPOST('update');
if (! empty($update)) { if (! empty($update)) {
$action = 'confirm_update'; $action = 'confirm_update';
} }
$object = new BookKeeping($db);
if ($action == "confirm_update") { if ($action == "confirm_update") {
$error = 0; $error = 0;
if ((floatval($debit) != 0.0) && (floatval($credit) != 0.0)) { if ((floatval($debit) != 0.0) && (floatval($credit) != 0.0)) {
setEventMessages($langs->trans('ErrorDebitCredit'), null, 'errors'); setEventMessages($langs->trans('ErrorDebitCredit'), null, 'errors');
$error ++; $error ++;
} }
if (empty($error)) { if (empty($error)) {
$book = new BookKeeping($db); $book = new BookKeeping($db);
$result = $book->fetch($id, null, $mode);
$result = $book->fetch($id);
if ($result < 0) { if ($result < 0) {
setEventMessages($book->error, $book->errors, 'errors'); setEventMessages($book->error, $book->errors, 'errors');
} else { } else {
$book->numero_compte = $account_number; $book->numero_compte = $account_number;
$book->subledger_account = $subledger_account; $book->code_tiers = $code_tiers;
$book->label_compte = $label_compte; $book->label_compte = $label_compte;
$book->label_operation= $label_operation;
$book->debit = $debit; $book->debit = $debit;
$book->credit = $credit; $book->credit = $credit;
if (floatval($debit) != 0.0) { if (floatval($debit) != 0.0) {
$book->montant = $debit; $book->montant = $debit;
$book->sens = 'D'; $book->sens = 'D';
@ -95,8 +85,7 @@ if ($action == "confirm_update") {
$book->montant = $credit; $book->montant = $credit;
$book->sens = 'C'; $book->sens = 'C';
} }
$result = $book->update($user, false, $mode);
$result = $book->update($user);
if ($result < 0) { if ($result < 0) {
setEventMessages($book->error, $book->errors, 'errors'); setEventMessages($book->error, $book->errors, 'errors');
} else { } else {
@ -106,21 +95,18 @@ if ($action == "confirm_update") {
} }
} }
} }
else if ($action == "add") { else if ($action == "add") {
$error = 0; $error = 0;
if ((floatval($debit) != 0.0) && (floatval($credit) != 0.0)) { if ((floatval($debit) != 0.0) && (floatval($credit) != 0.0)) {
setEventMessages($langs->trans('ErrorDebitCredit'), null, 'errors'); setEventMessages($langs->trans('ErrorDebitCredit'), null, 'errors');
$error ++; $error ++;
} }
if (empty($error)) { if (empty($error)) {
$book = new BookKeeping($db); $book = new BookKeeping($db);
$book->numero_compte = $account_number; $book->numero_compte = $account_number;
$book->subledger_account = $subledger_account; $book->code_tiers = $code_tiers;
$book->label_compte = $label_compte; $book->label_compte = $label_compte;
$book->label_operation= $label_operation;
$book->debit = $debit; $book->debit = $debit;
$book->credit = $credit; $book->credit = $credit;
$book->doc_date = GETPOST('doc_date'); $book->doc_date = GETPOST('doc_date');
@ -130,18 +116,15 @@ else if ($action == "add") {
$book->code_journal = GETPOST('code_journal'); $book->code_journal = GETPOST('code_journal');
$book->fk_doc = GETPOST('fk_doc'); $book->fk_doc = GETPOST('fk_doc');
$book->fk_docdet = GETPOST('fk_docdet'); $book->fk_docdet = GETPOST('fk_docdet');
if (floatval($debit) != 0.0) { if (floatval($debit) != 0.0) {
$book->montant = $debit; $book->montant = $debit;
$book->sens = 'D'; $book->sens = 'D';
} }
if (floatval($credit) != 0.0) { if (floatval($credit) != 0.0) {
$book->montant = $credit; $book->montant = $credit;
$book->sens = 'C'; $book->sens = 'C';
} }
$result = $book->createStd($user, false, $mode);
$result = $book->createStd($user);
if ($result < 0) { if ($result < 0) {
setEventMessages($book->error, $book->errors, 'errors'); setEventMessages($book->error, $book->errors, 'errors');
} else { } else {
@ -150,36 +133,28 @@ else if ($action == "add") {
} }
} }
} }
else if ($action == "confirm_delete") { else if ($action == "confirm_delete") {
$book = new BookKeeping($db); $book = new BookKeeping($db);
$result = $book->fetch($id, null, $mode);
$result = $book->fetch($id);
$piece_num = $book->piece_num; $piece_num = $book->piece_num;
if ($result < 0) { if ($result < 0) {
setEventMessages($book->error, $book->errors, 'errors'); setEventMessages($book->error, $book->errors, 'errors');
} else { } else {
$result = $book->delete($user); $result = $book->delete($user, false, $mode);
if ($result < 0) { if ($result < 0) {
setEventMessages($book->error, $book->errors, 'errors'); setEventMessages($book->error, $book->errors, 'errors');
} }
} }
$action = ''; $action = '';
} }
else if ($action == "confirm_create") { else if ($action == "confirm_create") {
$error = 0; $error = 0;
$book = new BookKeeping($db); $book = new BookKeeping($db);
if (! GETPOST('next_num_mvt')) if (! GETPOST('next_num_mvt'))
{ {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("NumPiece")), null, 'errors'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("NumPiece")), null, 'errors');
$error++; $error++;
} }
if (! $error) if (! $error)
{ {
$book->label_compte = ''; $book->label_compte = '';
@ -192,163 +167,258 @@ else if ($action == "confirm_create") {
$book->code_journal = GETPOST('code_journal'); $book->code_journal = GETPOST('code_journal');
$book->fk_doc = 0; $book->fk_doc = 0;
$book->fk_docdet = 0; $book->fk_docdet = 0;
$book->montant = 0; $book->montant = 0;
$result = $book->createStd($user,0, $mode);
$result = $book->createStd($user);
if ($result < 0) { if ($result < 0) {
setEventMessages($book->error, $book->errors, 'errors'); setEventMessages($book->error, $book->errors, 'errors');
} else { } else {
setEventMessages($langs->trans('Saved'), null, 'mesgs'); setEventMessages($langs->trans('Saved'), null, 'mesgs');
$action = ''; $action = 'update';
$id=$book->id;
$piece_num = $book->piece_num; $piece_num = $book->piece_num;
} }
} }
} }
if ($action == 'setdate') {
$datedoc = dol_mktime(0, 0, 0, GETPOST('doc_datemonth'), GETPOST('doc_dateday'), GETPOST('doc_dateyear'));
$result = $object->upddateByMvt($piece_num,'doc_date',$db->idate($datedoc),$mode);
if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors');
} else {
setEventMessages($langs->trans('Saved'), null, 'mesgs');
$action = '';
}
}
if ($action == 'setjournal') {
$journaldoc = trim(GETPOST('code_journal'));
if (!empty($journaldoc)) {
$journaldoc='\''.$journaldoc.'\'';
}
$result = $object->upddateByMvt($piece_num,'code_journal',$journaldoc,$mode);
if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors');
} else {
setEventMessages($langs->trans('Saved'), null, 'mesgs');
$action = '';
}
}
if ($action == 'setdocref') {
$refdoc = trim(GETPOST('doc_ref'));
if (!empty($refdoc)) {
$refdoc='\''.$refdoc.'\'';
}
$result = $object->upddateByMvt(doc_ref,'code_journal',$refdoc,$mode);
if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors');
} else {
setEventMessages($langs->trans('Saved'), null, 'mesgs');
$action = '';
}
}
if ($action == 'valid') {
$result = $object->transformTransaction(0,$piece_num);
if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors');
} else {
header("Location: list.php?sortfield=t.piece_num&sortorder=asc");
exit;
}
}
/* /*
* View * View
*/ */
llxHeader(); llxHeader();
$html = new Form($db); $html = new Form($db);
$formaccountancy = new FormAccounting($db); $formaccounting = new FormAccounting($db);
$accountjournal = new AccountingJournal($db);
/* /*
* Confirmation to delete the command * Confirmation to delete the command
*/ */
if ($action == 'delete') { if ($action == 'delete') {
$formconfirm = $html->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $id, $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvt'), 'confirm_delete', '', 0, 1); $formconfirm = $html->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $id.'&mode='. $mode , $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvt'), 'confirm_delete', '', 0, 1);
print $formconfirm; print $formconfirm;
} }
if ($action == 'create') { if ($action == 'create') {
print load_fiche_titre($langs->trans("CreateMvts")); print load_fiche_titre($langs->trans("CreateMvts"));
$book = new BookKeeping($db); $book = new BookKeeping($db);
$next_num_mvt = $book->getNextNumMvt(); $next_num_mvt = $book->getNextNumMvt('_tmp');
if (empty($next_num_mvt)) if (empty($next_num_mvt))
{ {
dol_print_error('', 'Failed to get next piece number'); dol_print_error('', 'Failed to get next piece number');
} }
print '<form action="' . $_SERVER["PHP_SELF"] . '" name="create_mvt" method="POST">'; print '<form action="' . $_SERVER["PHP_SELF"] . '" name="create_mvt" method="POST">';
print '<input type="hidden" name="action" value="confirm_create">' . "\n"; print '<input type="hidden" name="action" value="confirm_create">' . "\n";
print '<input type="hidden" name="next_num_mvt" value="' . $next_num_mvt . '">' . "\n"; print '<input type="hidden" name="next_num_mvt" value="' . $next_num_mvt . '">' . "\n";
print '<input type="hidden" name="mode" value="_tmp">' . "\n";
dol_fiche_head(); dol_fiche_head();
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
print '<tr>'; print '<tr>';
print '<td class="titlefieldcreate fieldrequired">' . $langs->trans("NumPiece") . '</td>'; print '<td class="titlefieldcreate fieldrequired">' . $langs->trans("NumPiece") . '</td>';
print '<td>' . $next_num_mvt . '</td>'; print '<td>' . $next_num_mvt . '</td>';
print '</tr>'; print '</tr>';
print '<tr>'; print '<tr>';
print '<td class="fieldrequired">' . $langs->trans("Docdate") . '</td>'; print '<td class="fieldrequired">' . $langs->trans("Docdate") . '</td>';
print '<td>'; print '<td>';
print $html->select_date('', 'doc_date', '', '', '', "create_mvt", 1, 1); print $html->select_date('', 'doc_date', '', '', '', "create_mvt", 1, 1);
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
print '<tr>'; print '<tr>';
print '<td class="fieldrequired">'.$langs->trans("AccountancyJournal").'</td>'; print '<td class="fieldrequired">' . $langs->trans("Codejournal") . '</td>';
print '<td>'; print '<td>' . $formaccounting->select_journal(GETPOST('code_journal'),'code_journal',0,0,array(),1,1) . '</td>';
print $formaccountancy->select_journal('', 'code_journal', '', 0, 1, 1, 1, 1); print '</tr>';
print '</td></tr>';
print '<tr>'; print '<tr>';
print '<td>' . $langs->trans("Docref") . '</td>'; print '<td>' . $langs->trans("Docref") . '</td>';
print '<td><input type="text" class="minwidth200" name="doc_ref" value=""/></td>'; print '<td><input type="text" size="20" name="doc_ref" value=""/></td>';
print '</tr>'; print '</tr>';
print '<tr>'; print '<tr>';
print '<td>' . $langs->trans("Doctype") . '</td>'; print '<td>' . $langs->trans("Doctype") . '</td>';
print '<td><input type="text" class="minwidth200" name="doc_type" value=""/></td>'; print '<td><input type="text" size="20" name="doc_type" value=""/></td>';
print '</tr>'; print '</tr>';
print '</table>'; print '</table>';
dol_fiche_end(); dol_fiche_end();
print '<div align="center"><input type="submit" class="button" value="' . $langs->trans("Create") . '">'; print '<div align="center"><input type="submit" class="button" value="' . $langs->trans("Create") . '">';
print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="button" value="' . $langs->trans("Cancel") . '" class="button" onclick="history.go(-1)" />'; print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="button" value="' . $langs->trans("Cancel") . '" class="button" onclick="history.go(-1)" />';
print '</div>'; print '</div>';
print '</form>'; print '</form>';
} else { } else {
$book = new BookKeeping($db); $book = new BookKeeping($db);
$result = $book->fetchPerMvt($piece_num); $result = $book->fetchPerMvt($piece_num, $mode);
if ($result < 0) { if ($result < 0) {
setEventMessages($book->error, $book->errors, 'errors'); setEventMessages($book->error, $book->errors, 'errors');
} }
if (! empty($book->piece_num)) { if (! empty($book->piece_num)) {
print load_fiche_titre($langs->trans("UpdateMvts"), '<a href="list.php">' . $langs->trans('BackToList') . '</a>'); print load_fiche_titre($langs->trans("UpdateMvts"), '<a href="list.php">' . $langs->trans('BackToList') . '</a>');
dol_fiche_head(); dol_fiche_head();
print '<div class="fichehalfleft">';
print '<div class="fichecenter">'; print '<div class="underbanner clearboth"></div>';
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
// account mouvment
print '<tr class="pair">'; print '<tr class="pair">';
print '<td class="titlefield">' . $langs->trans("NumMvts") . '</td>'; print '<td class="titlefield">' . $langs->trans("NumMvts") . '</td>';
print '<td>' . $book->piece_num . '</td>'; print '<td>' . $book->piece_num . '</td>';
print '</tr>'; print '</tr>';
// date
print '<tr class="impair">'; print '<tr class="impair"><td>';
print '<td>' . $langs->trans("Docdate") . '</td>'; print '<table class="nobordernopadding" width="100%"><tr><td>';
print '<td>' . dol_print_date($book->doc_date, 'daytextshort') . '</td>'; print $langs->trans('Docdate');
print '</td>';
if ($action != 'editdate')
print '<a href="'.$_SERVER["PHP_SELF"].'?action=editdate&amp;piece_num='. $book->piece_num .'&amp;mode='. $mode .'">'.img_edit($langs->transnoentitiesnoconv('SetDate'),1).'</a></td>';
print '</tr></table>';
print '</td><td colspan="3">';
if ($action == 'editdate') {
print '<form name="setdate" action="' . $_SERVER["PHP_SELF"] . '?piece_num=' . $book->piece_num . '" method="post">';
print '<input type="hidden" name="token" value="' . $_SESSION ['newtoken'] . '">';
print '<input type="hidden" name="action" value="setdate">';
print '<input type="hidden" name="mode" value="'.$mode.'">';
$form->select_date($book->doc_date ? $book->doc_date : - 1, 'doc_date', '', '', '', "setdate");
print '<input type="submit" class="button" value="' . $langs->trans('Modify') . '">';
print '</form>';
} else {
print $book->doc_date ? dol_print_date($book->doc_date, 'daytext') : '&nbsp;';
}
print '</td>';
print '</tr>'; print '</tr>';
//journal
print '<tr class="pair">'; print '<tr class="pair"><td>';
print '<td>' . $langs->trans("Codejournal") . '</td>'; print '<table class="nobordernopadding" width="100%"><tr><td>';
print '<td>'; print $langs->trans('Codejournal');
$accountingjournal = new AccountingJournal($db); print '</td>';
$accountingjournal->fetch('',$book->code_journal); if ($action != 'editjournal')
print $accountingjournal->getNomUrl(0,1,1,'',1); print '<a href="'.$_SERVER["PHP_SELF"].'?action=editjournal&amp;piece_num='.$book->piece_num.'&amp;mode='. $mode .'">'.img_edit($langs->transnoentitiesnoconv('Edit'),1).'</a></td>';
print '</td></tr>'; print '</tr></table>';
print '</td><td>';
print '<tr class="impair">'; if ($action == 'editjournal') {
print '<td>' . $langs->trans("Docref") . '</td>'; print '<form name="setjournal" action="' . $_SERVER["PHP_SELF"] . '?piece_num=' . $book->piece_num . '" method="post">';
print '<td>' . $book->doc_ref . '</td>'; print '<input type="hidden" name="token" value="' . $_SESSION ['newtoken'] . '">';
print '<input type="hidden" name="action" value="setjournal">';
print '<input type="hidden" name="mode" value="'.$mode.'">';
print $formaccounting->select_journal($book->code_journal,'code_journal',0,0,array(),1,1);
print '<input type="submit" class="button" value="' . $langs->trans('Modify') . '">';
print '</form>';
} else {
print $book->code_journal ;
}
print '</td>';
print '</tr>'; print '</tr>';
//docref
$typelabel = $book->doc_type; print '<tr class="impair"><td>';
if ($typelabel == 'bank') { print '<table class="nobordernopadding" width="100%"><tr><td>';
$typelabel = $langs->trans('Bank'); print $langs->trans('Docref');
} print '</td>';
if ($typelabel == 'customer_invoice') { if ($action != 'editdocref')
$typelabel = $langs->trans('CustomerInvoice'); print '<a href="'.$_SERVER["PHP_SELF"].'?action=editdocref&amp;piece_num='.$book->piece_num.'&amp;mode='. $mode .'">'.img_edit($langs->transnoentitiesnoconv('Edit'),1).'</a></td>';
} print '</tr></table>';
if ($typelabel == 'supplier_invoice') { print '</td><td>';
$typelabel = $langs->trans('SupplierInvoice'); if ($action == 'editdocref') {
} print '<form name="setdocref" action="' . $_SERVER["PHP_SELF"] . '?piece_num=' . $book->piece_num . '" method="post">';
if ($typelabel == 'expense_report') { print '<input type="hidden" name="token" value="' . $_SESSION ['newtoken'] . '">';
$typelabel = $langs->trans('ExpenseReport'); print '<input type="hidden" name="action" value="setdocref">';
print '<input type="hidden" name="mode" value="'.$mode.'">';
print '<input type="text" size="20" name="doc_ref" value="'.$book->doc_ref.'">';
print '<input type="submit" class="button" value="' . $langs->trans('Modify') . '">';
print '</form>';
} else {
print $book->doc_ref ;
} }
print '</td>';
print '</tr>';
//doctype
print '<tr class="pair">'; print '<tr class="pair">';
print '<td>' . $langs->trans("Doctype") . '</td>'; print '<td>' . $langs->trans("Doctype") . '</td>';
print '<td>' . $typelabel . '</td>'; print '<td>' . $book->doc_type . '</td>';
print '</tr>'; print '</tr>';
print '</table>'; print '</table>';
print '</div>'; print '</div>';
print '<div class="fichehalfright"><div class="ficheaddleft">';
dol_fiche_end(); print '<div class="underbanner clearboth"></div>';
print '<table class="border tableforfield" width="100%">';
//Validate
print '<tr class="pair">';
print '<td class="titlefield">' . $langs->trans("Status") . '</td>';
print '<td>';
if (empty($book->validated)) {
print '<a href="' . $_SERVER["PHP_SELF"] . '?piece_num=' . $line->rowid . '&action=enable">';
print img_picto($langs->trans("Disabled"), 'switch_off');
print '</a>';
} else {
print '<a href="' . $_SERVER["PHP_SELF"] . '?piece_num=' . $line->rowid . '&action=disable">';
print img_picto($langs->trans("Activated"), 'switch_on');
print '</a>';
}
print '</td>';
print '</tr>';
// check data
print '<tr class="impair">';
print '<td class="titlefield">' . $langs->trans("Control") . '</td>';
/*
if ($book->doc_type == 'customer_invoice')
{
$sqlmid = 'SELECT rowid as ref';
$sqlmid .= " FROM ".MAIN_DB_PREFIX."facture as fac";
$sqlmid .= " WHERE fac.rowid=" . $book->fk_doc;
dol_syslog("accountancy/bookkeeping/card.php::sqlmid=" . $sqlmid, LOG_DEBUG);
$resultmid = $db->query($sqlmid);
if ($resultmid) {
$objmid = $db->fetch_object($resultmid);
$invoicestatic = new Facture($db);
$invoicestatic->fetch($objmid->ref);
$ref=$langs->trans("Invoice").' '.$invoicestatic->getNomUrl(1);
}
else dol_print_error($db);
}
*/
print '<td>' . $ref .'</td>';
print "</table>\n";
print '</div>';
print '</div></div>';
print '<div style="clear:both"></div>';
print '<br>'; print '<br>';
$result = $book->fetchAllPerMvt($piece_num, $mode);
$result = $book->fetch_all_per_mvt($piece_num);
if ($result < 0) { if ($result < 0) {
setEventMessages($book->error, $book->errors, 'errors'); setEventMessages($book->error, $book->errors, 'errors');
} else { } else {
print load_fiche_titre($langs->trans("ListeMvts"), '', ''); print load_fiche_titre($langs->trans("ListeMvts"), '', '');
print '<form action="' . $_SERVER["PHP_SELF"] . '?piece_num=' . $book->piece_num . '" method="post">'; print '<form action="' . $_SERVER["PHP_SELF"] . '?piece_num=' . $book->piece_num . '" method="post">';
print '<input type="hidden" name="doc_date" value="' . $book->doc_date . '">' . "\n"; print '<input type="hidden" name="doc_date" value="' . $book->doc_date . '">' . "\n";
print '<input type="hidden" name="doc_type" value="' . $book->doc_type . '">' . "\n"; print '<input type="hidden" name="doc_type" value="' . $book->doc_type . '">' . "\n";
@ -356,95 +426,84 @@ if ($action == 'create') {
print '<input type="hidden" name="code_journal" value="' . $book->code_journal . '">' . "\n"; print '<input type="hidden" name="code_journal" value="' . $book->code_journal . '">' . "\n";
print '<input type="hidden" name="fk_doc" value="' . $book->fk_doc . '">' . "\n"; print '<input type="hidden" name="fk_doc" value="' . $book->fk_doc . '">' . "\n";
print '<input type="hidden" name="fk_docdet" value="' . $book->fk_docdet . '">' . "\n"; print '<input type="hidden" name="fk_docdet" value="' . $book->fk_docdet . '">' . "\n";
print '<input type="hidden" name="mode" value="' . $mode . '">' . "\n";
$var=False;
print "<table class=\"noborder\" width=\"100%\">"; print "<table class=\"noborder\" width=\"100%\">";
if (count($book->linesmvt) > 0) { if (count($book->linesmvt) > 0) {
$total_debit = 0; $total_debit = 0;
$total_credit = 0; $total_credit = 0;
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print_liste_field_titre($langs->trans("AccountAccountingShort")); print_liste_field_titre($langs->trans("AccountAccountingShort"));
print_liste_field_titre($langs->trans("subledger_account")); print_liste_field_titre($langs->trans("Code_tiers"));
print_liste_field_titre($langs->trans("Labelcompte")); print_liste_field_titre($langs->trans("Labelcompte"));
print_liste_field_titre($langs->trans("Debit"), "", "", "", "", 'align="right"'); print_liste_field_titre($langs->trans("Labeloperation"));
print_liste_field_titre($langs->trans("Credit"), "", "", "", "", 'align="right"'); print_liste_field_titre($langs->trans("Debit"), "", "", "", "", 'align="center"');
print_liste_field_titre($langs->trans("Amount"), "", "", "", "", 'align="right"'); print_liste_field_titre($langs->trans("Credit"), "", "", "", "", 'align="center"');
print_liste_field_titre($langs->trans("Sens"), "", "", "", "", 'align="center"');
print_liste_field_titre($langs->trans("Action"), "", "", "", "", 'width="60" align="center"'); print_liste_field_titre($langs->trans("Action"), "", "", "", "", 'width="60" align="center"');
print "</tr>\n"; print "</tr>\n";
foreach ( $book->linesmvt as $line ) {
foreach ($book->linesmvt as $line) { $var = ! $var;
print '<tr class="oddeven">'; print '<tr' . $bc[$var] . '>';
$total_debit += $line->debit; $total_debit += $line->debit;
$total_credit += $line->credit; $total_credit += $line->credit;
if ($action == 'update' && $line->id == $id) { if ($action == 'update' && $line->id == $id) {
print '<td>'; print '<td>';
print $formaccounting->select_account($line->numero_compte, 'account_number', 0, array (), 1, 1, 'maxwidth300'); print $formaccounting->select_account($line->numero_compte, 'account_number', 0, array (), 1, 1, '');
print '</td>'; print '</td>';
print '<td>'; print '<td>';
print $formaccounting->select_auxaccount($line->subledger_account, 'subledger_account', 1, 'maxwidth300'); print $formaccounting->select_auxaccount($line->code_tiers, 'code_tiers', 1);
print '</td>'; print '</td>';
print '<td><input type="text" size="15" name="label_compte" value="' . $line->label_compte . '"/></td>'; print '<td><input type="text" size="15" name="label_compte" value="' . $line->label_compte . '"/></td>';
print '<td><input type="text" size="15" name="label_operation" value="' . $line->label_operation. '"/></td>';
print '<td align="right"><input type="text" size="6" name="debit" value="' . price($line->debit) . '"/></td>'; print '<td align="right"><input type="text" size="6" name="debit" value="' . price($line->debit) . '"/></td>';
print '<td align="right"><input type="text" size="6" name="credit" value="' . price($line->credit) . '"/></td>'; print '<td align="right"><input type="text" size="6" name="credit" value="' . price($line->credit) . '"/></td>';
print '<td align="right">' . price($line->montant) . '</td>';
print '<td align="center">' . $line->sens . '</td>';
print '<td>'; print '<td>';
print '<input type="hidden" name="id" value="' . $line->id . '">' . "\n"; print '<input type="hidden" name="id" value="' . $line->id . '">' . "\n";
print '<input type="submit" class="button" name="update" value="' . $langs->trans("Update") . '">'; print '<input type="submit" class="button" name="update" value="' . $langs->trans("Update") . '">';
print '</td>'; print '</td>';
} else { } else {
print '<td>' . length_accountg($line->numero_compte) . '</td>'; print '<td>' . length_accountg($line->numero_compte) . '</td>';
print '<td>' . length_accounta($line->subledger_account) . '</td>'; print '<td>' . length_accounta($line->code_tiers) . '</td>';
print '<td>' . $line->label_compte . '</td>'; print '<td>' . $line->label_compte . '</td>';
print '<td>' . $line->label_operation. '</td>';
print '<td align="right">' . price($line->debit) . '</td>'; print '<td align="right">' . price($line->debit) . '</td>';
print '<td align="right">' . price($line->credit) . '</td>'; print '<td align="right">' . price($line->credit) . '</td>';
print '<td align="right">' . price($line->montant) . '</td>';
print '<td align="center">' . $line->sens . '</td>';
print '<td align="center">'; print '<td align="center">';
print '<a href="./card.php?action=update&amp;id=' . $line->id . '&amp;piece_num=' . $line->piece_num . '">'; print '<a href="./card.php?action=update&amp;id=' . $line->id . '&amp;piece_num=' . $line->piece_num . '&amp;mode='.$mode.'">';
print img_edit(); print img_edit();
print '</a>&nbsp;'; print '</a>&nbsp;';
print '<a href="./card.php?action=delete&amp;id=' . $line->id . '&amp;piece_num=' . $line->piece_num . '">'; print '<a href="./card.php?action=delete&amp;id=' . $line->id . '&amp;piece_num=' . $line->piece_num . '&amp;mode='.$mode.'">';
print img_delete(); print img_delete();
print '</a>'; print '</a>';
print '</td>'; print '</td>';
} }
print "</tr>\n"; print "</tr>\n";
} }
if ($total_debit != $total_credit) if ($total_debit != $total_credit)
{ {
setEventMessages(null, array($langs->trans('MvtNotCorrectlyBalanced', $total_credit, $total_debit)), 'warnings'); setEventMessages(null, array($langs->trans('MvtNotCorrectlyBalanced', $total_credit, $total_debit)), 'warnings');
} }
if ($action == "" || $action == 'add') { if ($action == "" || $action == 'add') {
print '<tr class="oddeven">'; $var = ! $var;
print '<tr' . $bc[$var] . '>';
print '<td>'; print '<td>';
print $formaccounting->select_account($account_number, 'account_number', 0, array (), 1, 1, 'maxwidth300'); print $formaccounting->select_account($account_number, 'account_number', 0, array (), 1, 1, '');
print '</td>'; print '</td>';
print '<td>'; print '<td>';
print $formaccounting->select_auxaccount($subledger_account, 'subledger_account', 1, 'maxwidth300'); print $formaccounting->select_auxaccount($code_tiers, 'code_tiers', 1);
print '</td>'; print '</td>';
print '<td><input type="text" size="15" name="label_compte" value="' . $label_compte . '"/></td>'; print '<td><input type="text" size="15" name="label_compte" value="' . $line->label_compte . '"/></td>';
print '<td align="right"><input type="text" class="right maxwidth50" name="debit" value="' . price($debit) . '"/></td>'; print '<td><input type="text" size="15" name="label_operation" value="' . $line->label_operation. '"/></td>';
print '<td align="right"><input type="text" class="right maxwidth50" name="credit" value="' . price($credit) . '"/></td>'; print '<td align="right"><input type="text" size="6" name="debit" value="' . price($debit) . '"/></td>';
print '<td></td>'; print '<td align="right"><input type="text" size="6" name="credit" value="' . price($credit) . '"/></td>';
print '<td></td>';
print '<td><input type="submit" class="button" name="save" value="' . $langs->trans("Add") . '"></td>'; print '<td><input type="submit" class="button" name="save" value="' . $langs->trans("Add") . '"></td>';
print '</tr>'; print '</tr>';
} }
print '</table>'; print '</table>';
if ($mode=='_tmp' && $total_debit == $total_credit && $action=='') {
print '<div class="tabsAction">';
print '<a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?piece_num=' . $book->piece_num . '&action=valid">'.$langs->trans("ValidTransaction").'</a>';
print "</div>";
}
print '</form>'; print '</form>';
} }
} }
@ -452,6 +511,6 @@ if ($action == 'create') {
print load_fiche_titre($langs->trans("NoRecords")); print load_fiche_titre($langs->trans("NoRecords"));
} }
} }
dol_fiche_end();
llxFooter(); llxFooter();
$db->close(); $db->close();

View File

@ -99,7 +99,7 @@ $formother = new FormOther($db);
$form = new Form($db); $form = new Form($db);
if ($action != 'export_csv' && ! isset($_POST['begin']) && ! isset($_GET['begin']) && ! isset($_POST['formfilteraction'])) { if ($action != 'export_csv' && ! isset($_POST['begin']) && ! isset($_GET['begin']) && ! isset($_POST['formfilteraction']) && empty($page)) {
$search_date_start = dol_mktime(0, 0, 0, 1, 1, dol_print_date(dol_now(), '%Y')); $search_date_start = dol_mktime(0, 0, 0, 1, 1, dol_print_date(dol_now(), '%Y'));
$search_date_end = dol_mktime(0, 0, 0, 12, 31, dol_print_date(dol_now(), '%Y')); $search_date_end = dol_mktime(0, 0, 0, 12, 31, dol_print_date(dol_now(), '%Y'));
} }
@ -183,7 +183,7 @@ if (! empty($search_accountancy_aux_code_end)) {
$param .= '&search_accountancy_aux_code_end=' . $search_accountancy_aux_code_end; $param .= '&search_accountancy_aux_code_end=' . $search_accountancy_aux_code_end;
} }
if (! empty($search_mvt_label)) { if (! empty($search_mvt_label)) {
$filter['t.label_compte'] = $search_mvt_label; $filter['t.label_operation'] = $search_mvt_label;
$param .= '&search_mvt_label=' . $search_mvt_label; $param .= '&search_mvt_label=' . $search_mvt_label;
} }
if (! empty($search_direction)) { if (! empty($search_direction)) {
@ -424,7 +424,7 @@ print_liste_field_titre($langs->trans("Docdate"), $_SERVER['PHP_SELF'], "t.doc_d
print_liste_field_titre($langs->trans("Docref"), $_SERVER['PHP_SELF'], "t.doc_ref", "", $param, "", $sortfield, $sortorder); print_liste_field_titre($langs->trans("Docref"), $_SERVER['PHP_SELF'], "t.doc_ref", "", $param, "", $sortfield, $sortorder);
print_liste_field_titre($langs->trans("AccountAccountingShort"), $_SERVER['PHP_SELF'], "t.numero_compte", "", $param, "", $sortfield, $sortorder); print_liste_field_titre($langs->trans("AccountAccountingShort"), $_SERVER['PHP_SELF'], "t.numero_compte", "", $param, "", $sortfield, $sortorder);
print_liste_field_titre($langs->trans("SubledgerAccount"), $_SERVER['PHP_SELF'], "t.subledger_account", "", $param, "", $sortfield, $sortorder); print_liste_field_titre($langs->trans("SubledgerAccount"), $_SERVER['PHP_SELF'], "t.subledger_account", "", $param, "", $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Label"), $_SERVER['PHP_SELF'], "t.label_compte", "", $param, "", $sortfield, $sortorder); print_liste_field_titre($langs->trans("Label"), $_SERVER['PHP_SELF'], "t.label_operation", "", $param, "", $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Debit"), $_SERVER['PHP_SELF'], "t.debit", "", $param, 'align="right"', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Debit"), $_SERVER['PHP_SELF'], "t.debit", "", $param, 'align="right"', $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Credit"), $_SERVER['PHP_SELF'], "t.credit", "", $param, 'align="right"', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Credit"), $_SERVER['PHP_SELF'], "t.credit", "", $param, 'align="right"', $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Codejournal"), $_SERVER['PHP_SELF'], "t.code_journal", "", $param, 'align="center"', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Codejournal"), $_SERVER['PHP_SELF'], "t.code_journal", "", $param, 'align="center"', $sortfield, $sortorder);
@ -450,7 +450,7 @@ foreach ($object->lines as $line ) {
print '<td class="nowrap">' . $line->doc_ref . '</td>'; print '<td class="nowrap">' . $line->doc_ref . '</td>';
print '<td>' . length_accountg($line->numero_compte) . '</td>'; print '<td>' . length_accountg($line->numero_compte) . '</td>';
print '<td>' . length_accounta($line->subledger_account) . '</td>'; print '<td>' . length_accounta($line->subledger_account) . '</td>';
print '<td>' . $line->label_compte . '</td>'; print '<td>' . $line->label_operation . '</td>';
print '<td align="right">' . ($line->debit ? price($line->debit) : ''). '</td>'; print '<td align="right">' . ($line->debit ? price($line->debit) : ''). '</td>';
print '<td align="right">' . ($line->credit ? price($line->credit) : '') . '</td>'; print '<td align="right">' . ($line->credit ? price($line->credit) : '') . '</td>';

View File

@ -1,9 +1,8 @@
<?php <?php
/* /* Copyright (C) 2016 Neil Orley <neil.orley@oeris.fr>
* Copyright (C) 2016 Neil Orley <neil.orley@oeris.fr> largely based on the great work of : * Copyright (C) 2013-2016 Olivier Geffroy <jeff@jeffinfo.com>
* - Copyright (C) 2013-2016 Olivier Geffroy <jeff@jeffinfo.com> * Copyright (C) 2013-2016 Florian Henry <florian.henry@open-concept.pro>
* - Copyright (C) 2013-2016 Florian Henry <florian.henry@open-concept.pro> * Copyright (C) 2013-2017 Alexandre Spangaro <aspangaro@zendsi.com>
* - Copyright (C) 2013-2016 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -100,11 +99,11 @@ if (!GETPOST("button_removefilter_x") && !GETPOST("button_removefilter")) // Bot
$options .= '&amp;search_accountancy_code_start=' . $search_accountancy_code_start; $options .= '&amp;search_accountancy_code_start=' . $search_accountancy_code_start;
} }
if (! empty($search_label_account)) { if (! empty($search_label_account)) {
$filter['t.label_compte'] = $search_label_account; $filter['t.label_operation'] = $search_label_account;
$options .= '&amp;search_label_account=' . $search_label_account; $options .= '&amp;search_label_account=' . $search_label_account;
} }
if (! empty($search_mvt_label)) { if (! empty($search_mvt_label)) {
$filter['t.label_compte'] = $search_mvt_label; $filter['t.label_operation'] = $search_mvt_label;
$options .= '&amp;search_mvt_label=' . $search_mvt_label; $options .= '&amp;search_mvt_label=' . $search_mvt_label;
} }
if (! empty($search_direction)) { if (! empty($search_direction)) {
@ -312,7 +311,7 @@ foreach ( $object->lines as $line ) {
// Affiche un lien vers la facture client/fournisseur // Affiche un lien vers la facture client/fournisseur
$doc_ref = preg_replace('/\(.*\)/', '', $line->doc_ref); $doc_ref = preg_replace('/\(.*\)/', '', $line->doc_ref);
print strlen(length_accounta($line->subledger_account)) == 0 ? '<td>' . $line->label_compte . '</td>' : '<td>' . $line->label_compte . '<br /><span style="font-size:0.8em">(' . length_accounta($line->subledger_account) . ')</span></td>'; print strlen(length_accounta($line->subledger_account)) == 0 ? '<td>' . $line->label_operation . '</td>' : '<td>' . $line->label_operation . '<br /><span style="font-size:0.8em">(' . length_accounta($line->subledger_account) . ')</span></td>';
print '<td align="right">' . ($line->debit ? price($line->debit) :''). '</td>'; print '<td align="right">' . ($line->debit ? price($line->debit) :''). '</td>';

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2013-2016 Olivier Geffroy <jeff@jeffinfo.com> /* Copyright (C) 2013-2016 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2016 Alexandre Spangaro <aspangaro.dolibarr@gmail.com> * Copyright (C) 2013-2017 Alexandre Spangaro <aspangaro@zendsi.com>
* Copyright (C) 2013-2016 Florian Henry <florian.henry@open-concept.pro> * Copyright (C) 2013-2016 Florian Henry <florian.henry@open-concept.pro>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -61,7 +61,7 @@ $search_subledger_account_end = GETPOST('search_subledger_account_end', 'alpha')
if ($search_subledger_account_end == - 1) { if ($search_subledger_account_end == - 1) {
$search_subledger_account_end = ''; $search_subledger_account_end = '';
} }
$search_label_compte = GETPOST('search_label_compte', 'alpha'); $search_label_operation = GETPOST('search_label_operation', 'alpha');
$search_sens = GETPOST('search_sens', 'alpha'); $search_sens = GETPOST('search_sens', 'alpha');
$search_code_journal = GETPOST('search_code_journal', 'alpha'); $search_code_journal = GETPOST('search_code_journal', 'alpha');
@ -93,7 +93,7 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETP
$search_doc_ref = ""; $search_doc_ref = "";
$search_numero_compte = ""; $search_numero_compte = "";
$search_subledger_account = ""; $search_subledger_account = "";
$search_label_compte = ""; $search_label_operation = "";
$search_sens = ""; $search_sens = "";
$search_code_journal = ""; $search_code_journal = "";
} }
@ -144,9 +144,9 @@ if (! empty($search_subledger_account_end)) {
$filter['t.subledger_account<='] = $search_subledger_account_end; $filter['t.subledger_account<='] = $search_subledger_account_end;
$options .= '&amp;search_subledger_account_end=' . $search_subledger_account_end; $options .= '&amp;search_subledger_account_end=' . $search_subledger_account_end;
} }
if (! empty($search_label_compte)) { if (! empty($search_label_operation)) {
$filter['t.label_compte'] = $search_label_compte; $filter['t.label_operation'] = $search_label_operation;
$options .= '&amp;search_label_compte=' . $search_label_compte; $options .= '&amp;search_label_operation=' . $search_label_operation;
} }
if (! empty($search_sens)) { if (! empty($search_sens)) {
$filter['t.sens'] = $search_sens; $filter['t.sens'] = $search_sens;
@ -207,7 +207,7 @@ print_liste_field_titre($langs->trans("Date"), $_SERVER['PHP_SELF'], "t.doc_date
print_liste_field_titre($langs->trans("Docref"), $_SERVER['PHP_SELF'], "t.doc_ref", "", $options, "", $sortfield, $sortorder); print_liste_field_titre($langs->trans("Docref"), $_SERVER['PHP_SELF'], "t.doc_ref", "", $options, "", $sortfield, $sortorder);
print_liste_field_titre($langs->trans("AccountAccounting"), $_SERVER['PHP_SELF'], "t.numero_compte", "", $options, "", $sortfield, $sortorder); print_liste_field_titre($langs->trans("AccountAccounting"), $_SERVER['PHP_SELF'], "t.numero_compte", "", $options, "", $sortfield, $sortorder);
print_liste_field_titre($langs->trans("ThirdPartyAccount"), $_SERVER['PHP_SELF'], "t.subledger_account", "", $options, "", $sortfield, $sortorder); print_liste_field_titre($langs->trans("ThirdPartyAccount"), $_SERVER['PHP_SELF'], "t.subledger_account", "", $options, "", $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Label"), $_SERVER['PHP_SELF'], "t.label_compte", "", $options, "", $sortfield, $sortorder); print_liste_field_titre($langs->trans("Label"), $_SERVER['PHP_SELF'], "t.label_operation", "", $options, "", $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Debit"), $_SERVER['PHP_SELF'], "t.debit", "", $options, "", $sortfield, $sortorder); print_liste_field_titre($langs->trans("Debit"), $_SERVER['PHP_SELF'], "t.debit", "", $options, "", $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Credit"), $_SERVER['PHP_SELF'], "t.credit", "", $options, 'align="center"', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Credit"), $_SERVER['PHP_SELF'], "t.credit", "", $options, 'align="center"', $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Amount"), $_SERVER['PHP_SELF'], "t.montant", "", $options, 'align="center"', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Amount"), $_SERVER['PHP_SELF'], "t.montant", "", $options, 'align="center"', $sortfield, $sortorder);
@ -242,7 +242,7 @@ print '<input type="text" size=6 class="flat" name="search_subledger_account" va
print '</td>'; print '</td>';
print '<td class="liste_titre">'; print '<td class="liste_titre">';
print '<input type="text" size=6 class="flat" name="search_label_compte" value="' . $search_label_compte . '"/>'; print '<input type="text" size=6 class="flat" name="search_label_operation" value="' . $search_label_operation . '"/>';
print '</td>'; print '</td>';
print '<td class="liste_titre">'; print '<td class="liste_titre">';
@ -279,7 +279,7 @@ foreach ( $object->lines as $line ) {
print '<td>' . $line->doc_ref . '</td>'; print '<td>' . $line->doc_ref . '</td>';
print '<td>' . length_accountg($line->numero_compte) . '</td>'; print '<td>' . length_accountg($line->numero_compte) . '</td>';
print '<td>' . length_accounta($line->subledger_account) . '</td>'; print '<td>' . length_accounta($line->subledger_account) . '</td>';
print '<td>' . $line->label_compte . '</td>'; print '<td>' . $line->label_operation . '</td>';
print '<td align="right">' . price($line->debit) . '</td>'; print '<td align="right">' . price($line->debit) . '</td>';
print '<td align="right">' . price($line->credit) . '</td>'; print '<td align="right">' . price($line->credit) . '</td>';
print '<td align="right">' . price($line->montant) . '</td>'; print '<td align="right">' . price($line->montant) . '</td>';

View File

@ -92,7 +92,7 @@ class AccountancyCategory
public function getCptBK($id) { public function getCptBK($id) {
global $conf; global $conf;
$sql = "SELECT t.numero_compte, t.label_compte, t.doc_ref"; $sql = "SELECT t.numero_compte, t.label_operation, t.doc_ref";
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as t"; $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as t";
$sql .= " WHERE t.numero_compte NOT IN ("; $sql .= " WHERE t.numero_compte NOT IN (";
$sql .= " SELECT t.account_number"; $sql .= " SELECT t.account_number";
@ -104,7 +104,7 @@ class AccountancyCategory
$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version"; $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version";
$sql .= " AND asy.rowid = " . $conf->global->CHARTOFACCOUNTS; $sql .= " AND asy.rowid = " . $conf->global->CHARTOFACCOUNTS;
$sql .= " AND aa.active = 1)"; $sql .= " AND aa.active = 1)";
$sql .= " GROUP BY t.numero_compte, t.label_compte, t.doc_ref"; $sql .= " GROUP BY t.numero_compte, t.label_operation, t.doc_ref";
$sql .= " ORDER BY t.numero_compte"; $sql .= " ORDER BY t.numero_compte";
$this->lines_CptBk = array (); $this->lines_CptBk = array ();

View File

@ -5,7 +5,7 @@
* Copyright (C) 2015 Florian Henry <florian.henry@open-concept.pro> * Copyright (C) 2015 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr> * Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
* Copyright (C) 2016 Pierre-Henry Favre <phf@atm-consulting.fr> * Copyright (C) 2016 Pierre-Henry Favre <phf@atm-consulting.fr>
* Copyright (C) 2016 Alexandre Spangaro <aspangaro.dolibarr@gmail.com> * Copyright (C) 2016-2017 Alexandre Spangaro <aspangaro@zendsi.com>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -198,7 +198,7 @@ class AccountancyExport
print length_accounta($line->subledger_account) . $separator; print length_accounta($line->subledger_account) . $separator;
print $line->sens . $separator; print $line->sens . $separator;
print price($line->montant) . $separator; print price($line->montant) . $separator;
print $line->label_compte . $separator; print $line->label_operation . $separator;
print $line->doc_ref; print $line->doc_ref;
print $this->end_line; print $this->end_line;
} }
@ -220,7 +220,7 @@ class AccountancyExport
print $line->piece_num . $this->separator; print $line->piece_num . $this->separator;
print length_accountg($line->numero_compte) . $this->separator; print length_accountg($line->numero_compte) . $this->separator;
print '' . $this->separator; print '' . $this->separator;
print $line->label_compte . $this->separator; print $line->label_operation . $this->separator;
print $date . $this->separator; print $date . $this->separator;
if ($line->sens=='D') { if ($line->sens=='D') {
print price($line->montant) . $this->separator; print price($line->montant) . $this->separator;
@ -230,7 +230,7 @@ class AccountancyExport
print price($line->montant) . $this->separator; print price($line->montant) . $this->separator;
} }
print $line->doc_ref . $this->separator; print $line->doc_ref . $this->separator;
print $line->label_compte . $this->separator; print $line->label_operation . $this->separator;
print $this->end_line; print $this->end_line;
} }
} }
@ -289,7 +289,7 @@ class AccountancyExport
print price($line->debit) . $this->separator; print price($line->debit) . $this->separator;
print price($line->credit) . $this->separator; print price($line->credit) . $this->separator;
print dol_trunc($line->label_compte, 32) . $this->separator; print dol_trunc($line->label_operation, 32) . $this->separator;
print $this->end_line; print $this->end_line;
} }
} }
@ -320,11 +320,11 @@ class AccountancyExport
$Tab['date_ope'] = dol_print_date($data->doc_date, $conf->global->ACCOUNTING_EXPORT_DATE); $Tab['date_ope'] = dol_print_date($data->doc_date, $conf->global->ACCOUNTING_EXPORT_DATE);
$Tab['num_piece'] = str_pad(self::trunc($data->piece_num, 12), 12); $Tab['num_piece'] = str_pad(self::trunc($data->piece_num, 12), 12);
$Tab['num_compte'] = str_pad(self::trunc($code_compta, 11), 11); $Tab['num_compte'] = str_pad(self::trunc($code_compta, 11), 11);
$Tab['libelle_ecriture'] = str_pad(self::trunc($data->doc_ref . $data->label_compte, 25), 25); $Tab['libelle_ecriture'] = str_pad(self::trunc($data->doc_ref . $data->label_operation, 25), 25);
$Tab['montant'] = str_pad(abs($data->montant), 13, ' ', STR_PAD_LEFT); $Tab['montant'] = str_pad(abs($data->montant), 13, ' ', STR_PAD_LEFT);
$Tab['type_montant'] = str_pad($data->sens, 1); $Tab['type_montant'] = str_pad($data->sens, 1);
$Tab['vide'] = str_repeat(' ', 18); $Tab['vide'] = str_repeat(' ', 18);
$Tab['intitule_compte'] = str_pad(self::trunc($data->label_compte, 34), 34); $Tab['intitule_compte'] = str_pad(self::trunc($data->label_operation, 34), 34);
$Tab['end'] = 'O2003'; $Tab['end'] = 'O2003';
$Tab['end_line'] = $this->end_line; $Tab['end_line'] = $this->end_line;
@ -359,7 +359,7 @@ class AccountancyExport
$Tab['folio'] = '000'; $Tab['folio'] = '000';
$Tab['date_ecriture'] = $date_ecriture; $Tab['date_ecriture'] = $date_ecriture;
$Tab['filler'] = ' '; $Tab['filler'] = ' ';
$Tab['libelle_ecriture'] = str_pad(self::trunc($data->doc_ref . ' ' . $data->label_compte, 20), 20); $Tab['libelle_ecriture'] = str_pad(self::trunc($data->doc_ref . ' ' . $data->label_operation, 20), 20);
$Tab['sens'] = $data->sens; // C or D $Tab['sens'] = $data->sens; // C or D
$Tab['signe_montant'] = '+'; $Tab['signe_montant'] = '+';
$Tab['montant'] = str_pad(abs($data->montant), 12, '0', STR_PAD_LEFT); // TODO manage negative amount $Tab['montant'] = str_pad(abs($data->montant), 12, '0', STR_PAD_LEFT); // TODO manage negative amount
@ -375,7 +375,7 @@ class AccountancyExport
$Tab['devis'] = str_pad($conf->currency, 3); $Tab['devis'] = str_pad($conf->currency, 3);
$Tab['code_journal2'] = str_pad(self::trunc($data->code_journal, 3), 3); $Tab['code_journal2'] = str_pad(self::trunc($data->code_journal, 3), 3);
$Tab['filler3'] = str_repeat(' ', 3); $Tab['filler3'] = str_repeat(' ', 3);
$Tab['libelle_ecriture2'] = str_pad(self::trunc($data->doc_ref . ' ' . $data->label_compte, 32), 32); $Tab['libelle_ecriture2'] = str_pad(self::trunc($data->doc_ref . ' ' . $data->label_operation, 32), 32);
$Tab['num_piece3'] = str_pad(self::trunc($data->piece_num, 10), 10); $Tab['num_piece3'] = str_pad(self::trunc($data->piece_num, 10), 10);
$Tab['filler4'] = str_repeat(' ', 73); $Tab['filler4'] = str_repeat(' ', 73);
@ -406,7 +406,7 @@ class AccountancyExport
print $line->code_journal . $this->separator; print $line->code_journal . $this->separator;
print length_accountg($line->numero_compte) . $this->separator; print length_accountg($line->numero_compte) . $this->separator;
print substr(length_accountg($line->numero_compte),0,2) . $this->separator; print substr(length_accountg($line->numero_compte),0,2) . $this->separator;
print '"'.dol_trunc($line->label_compte,40,'right','UTF-8',1).'"' . $this->separator; print '"'.dol_trunc($line->label_operation,40,'right','UTF-8',1).'"' . $this->separator;
print '"'.dol_trunc($line->piece_num,15,'right','UTF-8',1).'"'.$this->separator; print '"'.dol_trunc($line->piece_num,15,'right','UTF-8',1).'"'.$this->separator;
print price2num($line->montant).$this->separator; print price2num($line->montant).$this->separator;
print $line->sens.$this->separator; print $line->sens.$this->separator;

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com> /* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2014 Alexandre Spangaro <aspangaro.dolibarr@gmail.com> * Copyright (C) 2013-2014 Alexandre Spangaro <aspangaro@zendsi.com>
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro> * Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com> /* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2016 Alexandre Spangaro <aspangaro.dolibarr@gmail.com> * Copyright (C) 2013-2016 Alexandre Spangaro <aspangaro@zendsi.com>
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro> * Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2015 Ari Elbaz (elarifr) <github@accedinfo.com> * Copyright (C) 2015 Ari Elbaz (elarifr) <github@accedinfo.com>

View File

@ -33,10 +33,12 @@ class AccountingJournal extends CommonObject
var $rowid; var $rowid;
var $code; public $code;
var $label; public $label;
var $nature; // 0:various operations, 1:sale, 2:purchase, 3:bank, 9: has-new public $nature; // 0:various operations, 1:sale, 2:purchase, 3:bank, 4:expense-report, 9: has-new
var $active; public $active;
public $lines;
/** /**
* Constructor * Constructor
@ -97,6 +99,74 @@ class AccountingJournal extends CommonObject
return -1; return -1;
} }
/**
* Load object in memory from the database
*
* @param string $sortorder Sort Order
* @param string $sortfield Sort field
* @param int $limit offset limit
* @param int $offset offset limit
* @param array $filter filter array
* @param string $filtermode filter mode (AND or OR)
*
* @return int <0 if KO, >0 if OK
*/
function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') {
$sql = "SELECT rowid, code, label, nature, active";
$sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t';
// Manage filter
$sqlwhere = array();
if (count($filter) > 0) {
foreach ( $filter as $key => $value ) {
if ($key == 't.code' || $key == 't.label' || $key == 't.nature') {
$sqlwhere[] = $key . '\'' . $this->db->escape($value) . '\'';
} elseif ($key == 't.rowid' || $key == 't.active') {
$sqlwhere[] = $key . '=' . $value;
}
}
}
$sql .= ' WHERE 1 = 1';
$sql .= " AND entity IN (" . getEntity('accountancy') . ")";
if (count($sqlwhere) > 0) {
$sql .= ' AND ' . implode(' ' . $filtermode . ' ', $sqlwhere);
}
if (! empty($sortfield)) {
$sql .= $this->db->order($sortfield, $sortorder);
}
if (! empty($limit)) {
$sql .= ' ' . $this->db->plimit($limit + 1, $offset);
}
$this->lines = array();
dol_syslog(get_class($this) . "::fetch sql=" . $sql, LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql) {
$num = $this->db->num_rows($resql);
while ( $obj = $this->db->fetch_object($resql) ) {
$line = new self($this->db);
$line->id = $obj->rowid;
$line->code = $obj->code;
$line->label = $obj->label;
$line->nature = $obj->nature;
$line->active = $obj->active;
$this->lines[] = $line;
}
$this->db->free($resql);
return $num;
} else {
$this->errors[] = 'Error ' . $this->db->lasterror();
dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR);
return - 1;
}
}
/** /**
* Return clicable name (with picto eventually) * Return clicable name (with picto eventually)
* *
@ -187,6 +257,7 @@ class AccountingJournal extends CommonObject
{ {
$prefix=''; $prefix='';
if ($nature == 9) return $langs->trans('AccountingJournalType9'); if ($nature == 9) return $langs->trans('AccountingJournalType9');
if ($nature == 5) return $langs->trans('AccountingJournalType5');
if ($nature == 4) return $langs->trans('AccountingJournalType4'); if ($nature == 4) return $langs->trans('AccountingJournalType4');
if ($nature == 3) return $langs->trans('AccountingJournalType3'); if ($nature == 3) return $langs->trans('AccountingJournalType3');
if ($nature == 2) return $langs->trans('AccountingJournalType2'); if ($nature == 2) return $langs->trans('AccountingJournalType2');
@ -195,6 +266,7 @@ class AccountingJournal extends CommonObject
if ($mode == 1) if ($mode == 1)
{ {
if ($nature == 9) return $langs->trans('AccountingJournalType9'); if ($nature == 9) return $langs->trans('AccountingJournalType9');
if ($nature == 5) return $langs->trans('AccountingJournalType5');
if ($nature == 4) return $langs->trans('AccountingJournalType4'); if ($nature == 4) return $langs->trans('AccountingJournalType4');
if ($nature == 3) return $langs->trans('AccountingJournalType3'); if ($nature == 3) return $langs->trans('AccountingJournalType3');
if ($nature == 2) return $langs->trans('AccountingJournalType2'); if ($nature == 2) return $langs->trans('AccountingJournalType2');

View File

@ -1,7 +1,7 @@
<?php <?php
/* Copyright (C) 2014-2016 Olivier Geffroy <jeff@jeffinfo.com> /* Copyright (C) 2014-2017 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2015-2016 Alexandre Spangaro <aspangaro.dolibarr@gmail.com> * Copyright (C) 2015-2017 Alexandre Spangaro <aspangaro@zendsi.com>
* Copyright (C) 2015-2016 Florian Henry <florian.henry@open-concept.pro> * Copyright (C) 2015-2017 Florian Henry <florian.henry@open-concept.pro>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -80,6 +80,7 @@ class BookKeeping extends CommonObject
public $subledger_label; public $subledger_label;
public $numero_compte; public $numero_compte;
public $label_compte; public $label_compte;
public $label_operation;
public $debit; public $debit;
public $credit; public $credit;
public $montant; public $montant;
@ -90,9 +91,6 @@ class BookKeeping extends CommonObject
public $journal_label; public $journal_label;
public $piece_num; public $piece_num;
/**
*/
/** /**
* Constructor * Constructor
* *
@ -144,6 +142,9 @@ class BookKeeping extends CommonObject
if (isset($this->label_compte)) { if (isset($this->label_compte)) {
$this->label_compte = trim($this->label_compte); $this->label_compte = trim($this->label_compte);
} }
if (isset($this->label_operation)) {
$this->label_operation = trim($this->label_operation);
}
if (isset($this->debit)) { if (isset($this->debit)) {
$this->debit = trim($this->debit); $this->debit = trim($this->debit);
} }
@ -263,6 +264,7 @@ class BookKeeping extends CommonObject
$sql .= ", subledger_label"; $sql .= ", subledger_label";
$sql .= ", numero_compte"; $sql .= ", numero_compte";
$sql .= ", label_compte"; $sql .= ", label_compte";
$sql .= ", label_operation";
$sql .= ", debit"; $sql .= ", debit";
$sql .= ", credit"; $sql .= ", credit";
$sql .= ", montant"; $sql .= ", montant";
@ -284,6 +286,7 @@ class BookKeeping extends CommonObject
$sql .= ",'" . $this->db->escape($this->subledger_label) . "'"; $sql .= ",'" . $this->db->escape($this->subledger_label) . "'";
$sql .= ",'" . $this->db->escape($this->numero_compte) . "'"; $sql .= ",'" . $this->db->escape($this->numero_compte) . "'";
$sql .= ",'" . $this->db->escape($this->label_compte) . "'"; $sql .= ",'" . $this->db->escape($this->label_compte) . "'";
$sql .= ",'" . $this->db->escape($this->label_operation) . "'";
$sql .= "," . $this->debit; $sql .= "," . $this->debit;
$sql .= "," . $this->credit; $sql .= "," . $this->credit;
$sql .= "," . $this->montant; $sql .= "," . $this->montant;
@ -357,9 +360,10 @@ class BookKeeping extends CommonObject
* *
* @param User $user User that creates * @param User $user User that creates
* @param bool $notrigger false=launch triggers after, true=disable triggers * @param bool $notrigger false=launch triggers after, true=disable triggers
* @param string $mode Mode
* @return int <0 if KO, Id of created object if OK * @return int <0 if KO, Id of created object if OK
*/ */
public function createStd(User $user, $notrigger = false) { public function createStd(User $user, $notrigger = false, $mode='') {
dol_syslog(__METHOD__, LOG_DEBUG); dol_syslog(__METHOD__, LOG_DEBUG);
$error = 0; $error = 0;
@ -393,6 +397,9 @@ class BookKeeping extends CommonObject
if (isset($this->label_compte)) { if (isset($this->label_compte)) {
$this->label_compte = trim($this->label_compte); $this->label_compte = trim($this->label_compte);
} }
if (isset($this->label_operation)) {
$this->label_operation = trim($this->label_operation);
}
if (isset($this->debit)) { if (isset($this->debit)) {
$this->debit = trim($this->debit); $this->debit = trim($this->debit);
} }
@ -427,17 +434,18 @@ class BookKeeping extends CommonObject
// Put here code to add control on parameters values // Put here code to add control on parameters values
// Insert request // Insert request
$sql = 'INSERT INTO ' . MAIN_DB_PREFIX . $this->table_element . '('; $sql = 'INSERT INTO ' . MAIN_DB_PREFIX . $this->table_element . $mode.'(';
$sql .= 'doc_date,'; $sql .= 'doc_date,';
$sql .= 'doc_type,'; $sql .= 'doc_type,';
$sql .= 'doc_ref,'; $sql .= 'doc_ref,';
$sql .= 'fk_doc,'; $sql .= 'fk_doc,';
$sql .= 'fk_docdet,'; $sql .= 'fk_docdet,';
$sql .= 'thirdparty,'; $sql .= 'thirdparty_code,';
$sql .= 'subledger_account,'; $sql .= 'subledger_account,';
$sql .= 'subledger_label,'; $sql .= 'subledger_label,';
$sql .= 'numero_compte,'; $sql .= 'numero_compte,';
$sql .= 'label_compte,'; $sql .= 'label_compte,';
$sql .= 'label_operation,';
$sql .= 'debit,'; $sql .= 'debit,';
$sql .= 'credit,'; $sql .= 'credit,';
$sql .= 'montant,'; $sql .= 'montant,';
@ -457,8 +465,9 @@ class BookKeeping extends CommonObject
$sql .= ' ' . (! isset($this->thirdparty_code) ? 'NULL' : "'" . $this->db->escape($this->thirdparty_code) . "'") . ','; $sql .= ' ' . (! isset($this->thirdparty_code) ? 'NULL' : "'" . $this->db->escape($this->thirdparty_code) . "'") . ',';
$sql .= ' ' . (! isset($this->subledger_account) ? 'NULL' : "'" . $this->db->escape($this->subledger_account) . "'") . ','; $sql .= ' ' . (! isset($this->subledger_account) ? 'NULL' : "'" . $this->db->escape($this->subledger_account) . "'") . ',';
$sql .= ' ' . (! isset($this->subledger_label) ? 'NULL' : "'" . $this->db->escape($this->subledger_label) . "'") . ','; $sql .= ' ' . (! isset($this->subledger_label) ? 'NULL' : "'" . $this->db->escape($this->subledger_label) . "'") . ',';
$sql .= ' ' . (! isset($this->numero_compte) ? "NULL" : "'" . $this->db->escape($this->numero_compte) . "'") . ','; $sql .= ' ' . (! isset($this->numero_compte) ? 'NULL' : "'" . $this->db->escape($this->numero_compte) . "'") . ',';
$sql .= ' ' . (! isset($this->label_compte) ? 'NULL' : "'" . $this->db->escape($this->label_compte) . "'") . ','; $sql .= ' ' . (! isset($this->label_compte) ? 'NULL' : "'" . $this->db->escape($this->label_compte) . "'") . ',';
$sql .= ' ' . (! isset($this->label_operation) ? 'NULL' : "'" . $this->db->escape($this->label_operation) . "'") . ',';
$sql .= ' ' . (! isset($this->debit) ? 'NULL' : $this->debit ). ','; $sql .= ' ' . (! isset($this->debit) ? 'NULL' : $this->debit ). ',';
$sql .= ' ' . (! isset($this->credit) ? 'NULL' : $this->credit ). ','; $sql .= ' ' . (! isset($this->credit) ? 'NULL' : $this->credit ). ',';
$sql .= ' ' . (! isset($this->montant) ? 'NULL' : $this->montant ). ','; $sql .= ' ' . (! isset($this->montant) ? 'NULL' : $this->montant ). ',';
@ -511,10 +520,11 @@ class BookKeeping extends CommonObject
* *
* @param int $id Id object * @param int $id Id object
* @param string $ref Ref * @param string $ref Ref
* @param string $mode Mode
* *
* @return int <0 if KO, 0 if not found, >0 if OK * @return int <0 if KO, 0 if not found, >0 if OK
*/ */
public function fetch($id, $ref = null) { public function fetch($id, $ref = null, $mode='') {
global $conf; global $conf;
dol_syslog(__METHOD__, LOG_DEBUG); dol_syslog(__METHOD__, LOG_DEBUG);
@ -531,6 +541,7 @@ class BookKeeping extends CommonObject
$sql .= " t.subledger_label,"; $sql .= " t.subledger_label,";
$sql .= " t.numero_compte,"; $sql .= " t.numero_compte,";
$sql .= " t.label_compte,"; $sql .= " t.label_compte,";
$sql .= " t.label_operation,";
$sql .= " t.debit,"; $sql .= " t.debit,";
$sql .= " t.credit,"; $sql .= " t.credit,";
$sql .= " t.montant,"; $sql .= " t.montant,";
@ -540,7 +551,7 @@ class BookKeeping extends CommonObject
$sql .= " t.code_journal,"; $sql .= " t.code_journal,";
$sql .= " t.journal_label,"; $sql .= " t.journal_label,";
$sql .= " t.piece_num"; $sql .= " t.piece_num";
$sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t'; $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element.$mode. ' as t';
$sql .= ' WHERE 1 = 1'; $sql .= ' WHERE 1 = 1';
$sql .= " AND entity IN (" . getEntity('accountancy') . ")"; $sql .= " AND entity IN (" . getEntity('accountancy') . ")";
if (null !== $ref) { if (null !== $ref) {
@ -567,6 +578,7 @@ class BookKeeping extends CommonObject
$this->subledger_label = $obj->subledger_label; $this->subledger_label = $obj->subledger_label;
$this->numero_compte = $obj->numero_compte; $this->numero_compte = $obj->numero_compte;
$this->label_compte = $obj->label_compte; $this->label_compte = $obj->label_compte;
$this->label_operation = $obj->label_operation;
$this->debit = $obj->debit; $this->debit = $obj->debit;
$this->credit = $obj->credit; $this->credit = $obj->credit;
$this->montant = $obj->montant; $this->montant = $obj->montant;
@ -621,6 +633,7 @@ class BookKeeping extends CommonObject
$sql .= " t.subledger_label,"; $sql .= " t.subledger_label,";
$sql .= " t.numero_compte,"; $sql .= " t.numero_compte,";
$sql .= " t.label_compte,"; $sql .= " t.label_compte,";
$sql .= " t.label_operation,";
$sql .= " t.debit,"; $sql .= " t.debit,";
$sql .= " t.credit,"; $sql .= " t.credit,";
$sql .= " t.montant,"; $sql .= " t.montant,";
@ -644,9 +657,9 @@ class BookKeeping extends CommonObject
$sqlwhere[] = $key . '=' . $value; $sqlwhere[] = $key . '=' . $value;
} elseif ($key == 't.subledger_account' || $key == 't.numero_compte') { } elseif ($key == 't.subledger_account' || $key == 't.numero_compte') {
$sqlwhere[] = $key . ' LIKE \'' . $this->db->escape($value) . '%\''; $sqlwhere[] = $key . ' LIKE \'' . $this->db->escape($value) . '%\'';
} elseif ($key == 't.label_compte') { } elseif ($key == 't.label_operation') {
$sqlwhere[] = $key . ' LIKE \'' . $this->db->escape($value) . '%\''; $sqlwhere[] = $key . ' LIKE \'' . $this->db->escape($value) . '%\'';
}else { } else {
$sqlwhere[] = $key . ' LIKE \'%' . $this->db->escape($value) . '%\''; $sqlwhere[] = $key . ' LIKE \'%' . $this->db->escape($value) . '%\'';
} }
} }
@ -686,6 +699,7 @@ class BookKeeping extends CommonObject
$line->subledger_label = $obj->subledger_label; $line->subledger_label = $obj->subledger_label;
$line->numero_compte = $obj->numero_compte; $line->numero_compte = $obj->numero_compte;
$line->label_compte = $obj->label_compte; $line->label_compte = $obj->label_compte;
$line->label_operation = $obj->label_operation;
$line->debit = $obj->debit; $line->debit = $obj->debit;
$line->credit = $obj->credit; $line->credit = $obj->credit;
$line->montant = $obj->montant; $line->montant = $obj->montant;
@ -709,7 +723,6 @@ class BookKeeping extends CommonObject
} }
} }
/** /**
* Load object in memory from the database * Load object in memory from the database
* *
@ -739,6 +752,7 @@ class BookKeeping extends CommonObject
$sql .= " t.subledger_label,"; $sql .= " t.subledger_label,";
$sql .= " t.numero_compte,"; $sql .= " t.numero_compte,";
$sql .= " t.label_compte,"; $sql .= " t.label_compte,";
$sql .= " t.label_operation,";
$sql .= " t.debit,"; $sql .= " t.debit,";
$sql .= " t.credit,"; $sql .= " t.credit,";
$sql .= " t.montant,"; $sql .= " t.montant,";
@ -801,6 +815,7 @@ class BookKeeping extends CommonObject
$line->subledger_label = $obj->subledger_label; $line->subledger_label = $obj->subledger_label;
$line->numero_compte = $obj->numero_compte; $line->numero_compte = $obj->numero_compte;
$line->label_compte = $obj->label_compte; $line->label_compte = $obj->label_compte;
$line->label_operation = $obj->label_operation;
$line->debit = $obj->debit; $line->debit = $obj->debit;
$line->credit = $obj->credit; $line->credit = $obj->credit;
$line->montant = $obj->montant; $line->montant = $obj->montant;
@ -860,6 +875,8 @@ class BookKeeping extends CommonObject
$sqlwhere[] = $key . '=' . $value; $sqlwhere[] = $key . '=' . $value;
} elseif ($key == 't.subledger_account' || $key == 't.numero_compte') { } elseif ($key == 't.subledger_account' || $key == 't.numero_compte') {
$sqlwhere[] = $key . ' LIKE \'' . $this->db->escape($value) . '%\''; $sqlwhere[] = $key . ' LIKE \'' . $this->db->escape($value) . '%\'';
} elseif ($key == 't.subledger_label') {
$sqlwhere[] = $key . ' LIKE \'' . $this->db->escape($value) . '%\'';
} else { } else {
$sqlwhere[] = $key . ' LIKE \'%' . $this->db->escape($value) . '%\''; $sqlwhere[] = $key . ' LIKE \'%' . $this->db->escape($value) . '%\'';
} }
@ -909,10 +926,11 @@ class BookKeeping extends CommonObject
* *
* @param User $user User that modifies * @param User $user User that modifies
* @param bool $notrigger false=launch triggers after, true=disable triggers * @param bool $notrigger false=launch triggers after, true=disable triggers
* @param string $mode Mode
* *
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
public function update(User $user, $notrigger = false) { public function update(User $user, $notrigger = false, $mode='') {
$error = 0; $error = 0;
dol_syslog(__METHOD__, LOG_DEBUG); dol_syslog(__METHOD__, LOG_DEBUG);
@ -938,13 +956,15 @@ class BookKeeping extends CommonObject
} }
if (isset($this->subledger_label)) { if (isset($this->subledger_label)) {
$this->subledger_label = trim($this->subledger_label); $this->subledger_label = trim($this->subledger_label);
}
if (isset($this->numero_compte)) { if (isset($this->numero_compte)) {
$this->numero_compte = trim($this->numero_compte); $this->numero_compte = trim($this->numero_compte);
} }
if (isset($this->label_compte)) { if (isset($this->label_compte)) {
$this->label_compte = trim($this->label_compte); $this->label_compte = trim($this->label_compte);
} }
if (isset($this->label_operation)) {
$this->label_operation = trim($this->label_operation);
}
if (isset($this->debit)) { if (isset($this->debit)) {
$this->debit = trim($this->debit); $this->debit = trim($this->debit);
} }
@ -977,7 +997,7 @@ class BookKeeping extends CommonObject
// Put here code to add a control on parameters values // Put here code to add a control on parameters values
// Update request // Update request
$sql = 'UPDATE ' . MAIN_DB_PREFIX . $this->table_element . ' SET'; $sql = 'UPDATE ' . MAIN_DB_PREFIX . $this->table_element . $mode.' SET';
$sql .= ' doc_date = ' . (! isset($this->doc_date) || dol_strlen($this->doc_date) != 0 ? "'" . $this->db->idate($this->doc_date) . "'" : 'null') . ','; $sql .= ' doc_date = ' . (! isset($this->doc_date) || dol_strlen($this->doc_date) != 0 ? "'" . $this->db->idate($this->doc_date) . "'" : 'null') . ',';
$sql .= ' doc_type = ' . (isset($this->doc_type) ? "'" . $this->db->escape($this->doc_type) . "'" : "null") . ','; $sql .= ' doc_type = ' . (isset($this->doc_type) ? "'" . $this->db->escape($this->doc_type) . "'" : "null") . ',';
$sql .= ' doc_ref = ' . (isset($this->doc_ref) ? "'" . $this->db->escape($this->doc_ref) . "'" : "null") . ','; $sql .= ' doc_ref = ' . (isset($this->doc_ref) ? "'" . $this->db->escape($this->doc_ref) . "'" : "null") . ',';
@ -988,6 +1008,7 @@ class BookKeeping extends CommonObject
$sql .= ' subledger_label = ' . (isset($this->subledger_label) ? "'" . $this->db->escape($this->subledger_label) . "'" : "null") . ','; $sql .= ' subledger_label = ' . (isset($this->subledger_label) ? "'" . $this->db->escape($this->subledger_label) . "'" : "null") . ',';
$sql .= ' numero_compte = ' . (isset($this->numero_compte) ? "'" . $this->db->escape($this->numero_compte) . "'" : "null") . ','; $sql .= ' numero_compte = ' . (isset($this->numero_compte) ? "'" . $this->db->escape($this->numero_compte) . "'" : "null") . ',';
$sql .= ' label_compte = ' . (isset($this->label_compte) ? "'" . $this->db->escape($this->label_compte) . "'" : "null") . ','; $sql .= ' label_compte = ' . (isset($this->label_compte) ? "'" . $this->db->escape($this->label_compte) . "'" : "null") . ',';
$sql .= ' label_operation = ' . (isset($this->label_operation) ? "'" . $this->db->escape($this->label_operation) . "'" : "null") . ',';
$sql .= ' debit = ' . (isset($this->debit) ? $this->debit : "null") . ','; $sql .= ' debit = ' . (isset($this->debit) ? $this->debit : "null") . ',';
$sql .= ' credit = ' . (isset($this->credit) ? $this->credit : "null") . ','; $sql .= ' credit = ' . (isset($this->credit) ? $this->credit : "null") . ',';
$sql .= ' montant = ' . (isset($this->montant) ? $this->montant : "null") . ','; $sql .= ' montant = ' . (isset($this->montant) ? $this->montant : "null") . ',';
@ -1030,15 +1051,47 @@ class BookKeeping extends CommonObject
} }
} }
/**
* Update movement
*
* @param string $piece_num
* @param string $field
* @param string $value
* @param string $mode
* @return number
*/
public function upddateByMvt($piece_num='', $field='', $value='', $mode='') {
$this->db->begin();
$sql = "UPDATE " . MAIN_DB_PREFIX . $this->table_element.$mode." as ab";
$sql .= ' SET ab.'.$field.'=' . $value;
$sql .= ' WHERE ab.piece_num=' . $piece_num ;
$resql = $this->db->query($sql);
if (! $resql) {
$error ++;
$this->errors[] = 'Error ' . $this->db->lasterror();
dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR);
}
if ($error) {
$this->db->rollback();
return - 1 * $error;
} else {
$this->db->commit();
return 1;
}
}
/** /**
* Delete object in database * Delete object in database
* *
* @param User $user User that deletes * @param User $user User that deletes
* @param bool $notrigger false=launch triggers after, true=disable triggers * @param bool $notrigger false=launch triggers after, true=disable triggers
* @param string $mode Mode
* *
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
public function delete(User $user, $notrigger = false) { public function delete(User $user, $notrigger = false, $mode='') {
dol_syslog(__METHOD__, LOG_DEBUG); dol_syslog(__METHOD__, LOG_DEBUG);
$error = 0; $error = 0;
@ -1058,7 +1111,7 @@ class BookKeeping extends CommonObject
} }
if (! $error) { if (! $error) {
$sql = 'DELETE FROM ' . MAIN_DB_PREFIX . $this->table_element; $sql = 'DELETE FROM ' . MAIN_DB_PREFIX . $this->table_element.$mode;
$sql .= ' WHERE rowid=' . $this->id; $sql .= ' WHERE rowid=' . $this->id;
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
@ -1113,9 +1166,10 @@ class BookKeeping extends CommonObject
* *
* @param string $delyear Year to delete * @param string $delyear Year to delete
* @param string $journal Journal to delete * @param string $journal Journal to delete
* @param string $mode Mode
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
function deleteByYearAndJournal($delyear='', $journal='') { function deleteByYearAndJournal($delyear='', $journal='', $mode='') {
global $conf; global $conf;
if (empty($delyear) && empty($journal)) if (empty($delyear) && empty($journal))
@ -1127,7 +1181,7 @@ class BookKeeping extends CommonObject
// first check if line not yet in bookkeeping // first check if line not yet in bookkeeping
$sql = "DELETE"; $sql = "DELETE";
$sql.= " FROM " . MAIN_DB_PREFIX . $this->table_element; $sql.= " FROM " . MAIN_DB_PREFIX . $this->table_element.$mode;
$sql.= " WHERE 1 = 1"; $sql.= " WHERE 1 = 1";
if (! empty($delyear)) $sql.= " AND YEAR(doc_date) = " . $delyear; // FIXME Must use between if (! empty($delyear)) $sql.= " AND YEAR(doc_date) = " . $delyear; // FIXME Must use between
if (! empty($journal)) $sql.= " AND code_journal = '".$journal."'"; if (! empty($journal)) $sql.= " AND code_journal = '".$journal."'";
@ -1152,16 +1206,17 @@ class BookKeeping extends CommonObject
* Delete bookkepping by piece number * Delete bookkepping by piece number
* *
* @param int $piecenum peicenum to delete * @param int $piecenum peicenum to delete
* @param string $mode Mode
* @return int Result * @return int Result
*/ */
function deleteMvtNum($piecenum) { function deleteMvtNum($piecenum, $mode) {
global $conf; global $conf;
$this->db->begin(); $this->db->begin();
// first check if line not yet in bookkeeping // first check if line not yet in bookkeeping
$sql = "DELETE"; $sql = "DELETE";
$sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element; $sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element. $mode;
$sql .= " WHERE piece_num = " . $piecenum; $sql .= " WHERE piece_num = " . $piecenum;
$sql .= " AND entity IN (" . getEntity('accountancy') . ")"; $sql .= " AND entity IN (" . getEntity('accountancy') . ")";
@ -1245,14 +1300,15 @@ class BookKeeping extends CommonObject
$this->fk_doc = ''; $this->fk_doc = '';
$this->fk_docdet = ''; $this->fk_docdet = '';
$this->thirdparty_code = 'CU001'; $this->thirdparty_code = 'CU001';
$this->subledger_account = '410CU001'; $this->subledger_account = '41100001';
$this->subledger_label = 'My customer company'; $this->subledger_label = 'My customer company';
$this->numero_compte = '410'; $this->numero_compte = '411';
$this->label_compte = ''; $this->label_compte = 'Customer';
$this->label_operation = 'Sales of pea';
$this->debit = 99.9; $this->debit = 99.9;
$this->credit = ''; $this->credit = '';
$this->montant = ''; $this->montant = '';
$this->sens = ''; $this->sens = 'D';
$this->fk_user_author = $user->id; $this->fk_user_author = $user->id;
$this->import_key = ''; $this->import_key = '';
$this->code_journal = 'VT'; $this->code_journal = 'VT';
@ -1264,13 +1320,14 @@ class BookKeeping extends CommonObject
* Load an accounting document into memory from database * Load an accounting document into memory from database
* *
* @param int $piecenum Accounting document to get * @param int $piecenum Accounting document to get
* @param string $mode Mode
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
public function fetchPerMvt($piecenum) { public function fetchPerMvt($piecenum, $mode='') {
global $conf; global $conf;
$sql = "SELECT piece_num,doc_date,code_journal,journal_label,doc_ref,doc_type"; $sql = "SELECT piece_num,doc_date,code_journal,journal_label,doc_ref,doc_type";
$sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element; $sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element.$mode;
$sql .= " WHERE piece_num = " . $piecenum; $sql .= " WHERE piece_num = " . $piecenum;
$sql .= " AND entity IN (" . getEntity('accountancy') . ")"; $sql .= " AND entity IN (" . getEntity('accountancy') . ")";
@ -1297,13 +1354,14 @@ class BookKeeping extends CommonObject
/** /**
* Return next number movement * Return next number movement
* *
* @param string $mode Mode
* @return string Next numero to use * @return string Next numero to use
*/ */
public function getNextNumMvt() public function getNextNumMvt($mode='')
{ {
global $conf; global $conf;
$sql = "SELECT MAX(piece_num)+1 as max FROM " . MAIN_DB_PREFIX . $this->table_element; $sql = "SELECT MAX(piece_num)+1 as max FROM " . MAIN_DB_PREFIX . $this->table_element.$mode;
$sql .= " WHERE entity IN (" . getEntity('accountancy') . ")"; $sql .= " WHERE entity IN (" . getEntity('accountancy') . ")";
dol_syslog(get_class($this) . "getNextNumMvt sql=" . $sql, LOG_DEBUG); dol_syslog(get_class($this) . "getNextNumMvt sql=" . $sql, LOG_DEBUG);
@ -1327,14 +1385,14 @@ class BookKeeping extends CommonObject
* @param int $piecenum id of line to get * @param int $piecenum id of line to get
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
function fetch_all_per_mvt($piecenum) { function fetchAllPerMvt($piecenum, $mode='') {
global $conf; global $conf;
$sql = "SELECT rowid, doc_date, doc_type,"; $sql = "SELECT rowid, doc_date, doc_type,";
$sql .= " doc_ref, fk_doc, fk_docdet, thirdparty_code, subledger_account, subledger_label,"; $sql .= " doc_ref, fk_doc, fk_docdet, thirdparty_code, subledger_account, subledger_label,";
$sql .= " numero_compte, label_compte, debit, credit,"; $sql .= " numero_compte, label_compte, label_operation, debit, credit,";
$sql .= " montant, sens, fk_user_author, import_key, code_journal, journal_label, piece_num"; $sql .= " montant, sens, fk_user_author, import_key, code_journal, journal_label, piece_num";
$sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element; $sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element.$mode;
$sql .= " WHERE piece_num = " . $piecenum; $sql .= " WHERE piece_num = " . $piecenum;
$sql .= " AND entity IN (" . getEntity('accountancy') . ")"; $sql .= " AND entity IN (" . getEntity('accountancy') . ")";
@ -1358,6 +1416,7 @@ class BookKeeping extends CommonObject
$line->subledger_label = $obj->subledger_label; $line->subledger_label = $obj->subledger_label;
$line->numero_compte = $obj->numero_compte; $line->numero_compte = $obj->numero_compte;
$line->label_compte = $obj->label_compte; $line->label_compte = $obj->label_compte;
$line->label_operation = $obj->label_operation;
$line->debit = $obj->debit; $line->debit = $obj->debit;
$line->credit = $obj->credit; $line->credit = $obj->credit;
$line->montant = $obj->montant; $line->montant = $obj->montant;
@ -1388,7 +1447,7 @@ class BookKeeping extends CommonObject
$sql = "SELECT rowid, doc_date, doc_type,"; $sql = "SELECT rowid, doc_date, doc_type,";
$sql .= " doc_ref, fk_doc, fk_docdet, thirdparty_code, subledger_account, subledger_label,"; $sql .= " doc_ref, fk_doc, fk_docdet, thirdparty_code, subledger_account, subledger_label,";
$sql .= " numero_compte, label_compte, debit, credit,"; $sql .= " numero_compte, label_compte, label_operation, debit, credit,";
$sql .= " montant, sens, fk_user_author, import_key, code_journal, piece_num"; $sql .= " montant, sens, fk_user_author, import_key, code_journal, piece_num";
$sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element; $sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element;
$sql .= " WHERE entity IN (" . getEntity('accountancy') . ")"; $sql .= " WHERE entity IN (" . getEntity('accountancy') . ")";
@ -1416,6 +1475,7 @@ class BookKeeping extends CommonObject
$line->subledger_label = $obj->subledger_label; $line->subledger_label = $obj->subledger_label;
$line->numero_compte = $obj->numero_compte; $line->numero_compte = $obj->numero_compte;
$line->label_compte = $obj->label_compte; $line->label_compte = $obj->label_compte;
$line->label_operation = $obj->label_operation;
$line->debit = $obj->debit; $line->debit = $obj->debit;
$line->credit = $obj->credit; $line->credit = $obj->credit;
$line->montant = $obj->montant; $line->montant = $obj->montant;
@ -1435,7 +1495,89 @@ class BookKeeping extends CommonObject
} }
} }
/**
* Transform transaction
*
* @param number $direction if 0 tmp => real, if 1 real => tmp
* @param unknown $piecenum
*/
public function transformTransaction($direction=0,$piece_num='') {
$this->db->begin();
if ($direction==0) {
$next_piecenum=$this->getNextNumMvt();
if ($result < 0) {
$error++;
}
$sql = 'INSERT INTO ' . MAIN_DB_PREFIX . $this->table_element.'(doc_date, doc_type,';
$sql .= ' doc_ref, fk_doc, fk_docdet, thirdparty_code, subledger_account, subledger_label,';
$sql .= ' numero_compte, label_compte, label_operation, debit, credit,';
$sql .= ' montant, sens, fk_user_author, import_key, code_journal, journal_label, piece_num)';
$sql .= 'SELECT doc_date, doc_type,';
$sql .= ' doc_ref, fk_doc, fk_docdet, thirdparty_code, subledger_account, subledger_label,';
$sql .= ' numero_compte, label_compte, label_operation, debit, credit,';
$sql .= ' montant, sens, fk_user_author, import_key, code_journal, journal_label, '.$next_piecenum.'';
$sql .= ' FROM '.MAIN_DB_PREFIX . $this->table_element.'_tmp WHERE piece_num = '.$piece_num;
$resql = $this->db->query($sql);
if (! $resql) {
$error ++;
$this->errors[] = 'Error ' . $this->db->lasterror();
dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR);
}
$sql = 'DELETE FROM '.MAIN_DB_PREFIX . $this->table_element.'_tmp WHERE piece_num = '.$piece_num;
$resql = $this->db->query($sql);
if (! $resql) {
$error ++;
$this->errors[] = 'Error ' . $this->db->lasterror();
dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR);
}
}
if ($direction==1) {
$sql = 'DELETE FROM ' . MAIN_DB_PREFIX . $this->table_element.'_tmp WHERE piece_num = '.$piece_num;
$resql = $this->db->query($sql);
if (! $resql) {
$error ++;
$this->errors[] = 'Error ' . $this->db->lasterror();
dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR);
}
$sql = 'INSERT INTO ' . MAIN_DB_PREFIX . $this->table_element.'_tmp(doc_date, doc_type,';
$sql .= ' doc_ref, fk_doc, fk_docdet, thirdparty_code, subledger_account, subledger_label,';
$sql .= ' numero_compte, label_compte, label_operation, debit, credit,';
$sql .= ' montant, sens, fk_user_author, import_key, code_journal, journal_label, piece_num)';
$sql .= 'SELECT doc_date, doc_type,';
$sql .= ' doc_ref, fk_doc, fk_docdet, thirdparty_code, subledger_account, subledger_label,';
$sql .= ' numero_compte, label_compte, label_operation, debit, credit,';
$sql .= ' montant, sens, fk_user_author, import_key, code_journal, journal_label, piece_num';
$sql .= ' FROM '.MAIN_DB_PREFIX . $this->table_element.' WHERE piece_num = '.$piece_num;
$resql = $this->db->query($sql);
if (! $resql) {
$error ++;
$this->errors[] = 'Error ' . $this->db->lasterror();
dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR);
}
$sql = 'DELETE FROM '.MAIN_DB_PREFIX . $this->table_element.'_tmp WHERE piece_num = '.$piece_num;
$resql = $this->db->query($sql);
if (! $resql) {
$error ++;
$this->errors[] = 'Error ' . $this->db->lasterror();
dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR);
}
}
if (! $error) {
$this->db->commit();
return 1;
} else {
$this->db->rollback();
return - 1;
}
$sql = "DELETE FROM ";
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as ab";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.account_number = ab.numero_compte";
$sql .= " AND aa.active = 1";
$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version";
$sql .= " AND asy.rowid = " . $pcgver;
$sql .= " AND ab.entity IN (" . getEntity('accountancy') . ")";
$sql .= " ORDER BY account_number ASC";
}
/** /**
* Return list of accounts with label by chart of accounts * Return list of accounts with label by chart of accounts
@ -1506,7 +1648,6 @@ class BookKeeping extends CommonObject
return $out; return $out;
} }
/** /**
* Description of a root accounting account * Description of a root accounting account
* *
@ -1547,7 +1688,6 @@ class BookKeeping extends CommonObject
} }
} }
/** /**
* Description of accounting account * Description of accounting account
* *
@ -1586,10 +1726,8 @@ class BookKeeping extends CommonObject
return -1; return -1;
} }
} }
} }
/** /**
* Class BookKeepingLine * Class BookKeepingLine
*/ */
@ -1606,6 +1744,7 @@ class BookKeepingLine
public $subledger_label; public $subledger_label;
public $numero_compte; public $numero_compte;
public $label_compte; public $label_compte;
public $label_operation;
public $debit; public $debit;
public $credit; public $credit;
public $montant; public $montant;

View File

@ -1,7 +1,7 @@
<?php <?php
/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com> /* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro> * Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2013-2017 Alexandre Spangaro <aspangaro.dolibarr@gmail.com> * Copyright (C) 2013-2017 Alexandre Spangaro <aspangaro@zendsi.com>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by

View File

@ -1,7 +1,7 @@
<?php <?php
/* Copyright (C) 2013 Olivier Geffroy <jeff@jeffinfo.com> /* Copyright (C) 2013 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro> * Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2013-2016 Alexandre Spangaro <aspangaro.dolibarr@gmail.com> * Copyright (C) 2013-2016 Alexandre Spangaro <aspangaro@zendsi.com>
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr> * Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
* *

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2013-2016 Olivier Geffroy <jeff@jeffinfo.com> /* Copyright (C) 2013-2016 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2016 Alexandre Spangaro <aspangaro.dolibarr@gmail.com> * Copyright (C) 2013-2016 Alexandre Spangaro <aspangaro@zendsi.com>
* Copyright (C) 2014-2015 Ari Elbaz (elarifr) <github@accedinfo.com> * Copyright (C) 2014-2015 Ari Elbaz (elarifr) <github@accedinfo.com>
* Copyright (C) 2014-2016 Florian Henry <florian.henry@open-concept.pro> * Copyright (C) 2014-2016 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com> /* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2016 Alexandre Spangaro <aspangaro.dolibarr@gmail.com> * Copyright (C) 2013-2016 Alexandre Spangaro <aspangaro@zendsi.com>
* Copyright (C) 2014-2015 Ari Elbaz (elarifr) <github@accedinfo.com> * Copyright (C) 2014-2015 Ari Elbaz (elarifr) <github@accedinfo.com>
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro> * Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>

View File

@ -50,6 +50,7 @@ require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php';
require_once DOL_DOCUMENT_ROOT . '/societe/class/client.class.php'; require_once DOL_DOCUMENT_ROOT . '/societe/class/client.class.php';
require_once DOL_DOCUMENT_ROOT . '/expensereport/class/expensereport.class.php'; require_once DOL_DOCUMENT_ROOT . '/expensereport/class/expensereport.class.php';
require_once DOL_DOCUMENT_ROOT . '/expensereport/class/paymentexpensereport.class.php'; require_once DOL_DOCUMENT_ROOT . '/expensereport/class/paymentexpensereport.class.php';
require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/paymentvarious.class.php';
$langs->load("companies"); $langs->load("companies");
$langs->load("other"); $langs->load("other");
@ -60,6 +61,7 @@ $langs->load('donations');
$langs->load("accountancy"); $langs->load("accountancy");
$langs->load("trips"); $langs->load("trips");
$langs->load("salaries"); $langs->load("salaries");
$langs->load("hrm");
// Multi journal // Multi journal
$id_journal = GETPOST('id_journal', 'int'); $id_journal = GETPOST('id_journal', 'int');
@ -131,6 +133,7 @@ $paymentdonstatic = new PaymentDonation($db);
$paymentvatstatic = new TVA($db); $paymentvatstatic = new TVA($db);
$paymentsalstatic = new PaymentSalary($db); $paymentsalstatic = new PaymentSalary($db);
$paymentexpensereportstatic = new PaymentExpenseReport($db); $paymentexpensereportstatic = new PaymentExpenseReport($db);
$paymentvariousstatic = new PaymentVarious($db);
// Get code of finance journal // Get code of finance journal
$accountingjournalstatic = new AccountingJournal($db); $accountingjournalstatic = new AccountingJournal($db);
@ -208,7 +211,7 @@ if ($result) {
// Now loop on each link of record in bank. // Now loop on each link of record in bank.
foreach ( $links as $key => $val ) { foreach ( $links as $key => $val ) {
if (in_array($links[$key]['type'], array('sc', 'payment_sc', 'payment', 'payment_supplier', 'payment_vat', 'payment_expensereport', 'banktransfert', 'payment_donation', 'payment_salary'))) // So we excluded 'company' here if (in_array($links[$key]['type'], array('sc', 'payment_sc', 'payment', 'payment_supplier', 'payment_vat', 'payment_expensereport', 'banktransfert', 'payment_donation', 'payment_salary', 'payment_various'))) // So we excluded 'company' here
{ {
// We save tabtype for a future use, to remember what kind of payment it is // We save tabtype for a future use, to remember what kind of payment it is
$tabtype[$obj->rowid] = $links[$key]['type']; $tabtype[$obj->rowid] = $links[$key]['type'];
@ -285,6 +288,15 @@ if ($result) {
$paymentexpensereportstatic->fk_expensereport = $links[$key]['url_id']; $paymentexpensereportstatic->fk_expensereport = $links[$key]['url_id'];
$tabpay[$obj->rowid]["lib"] .= ' ' . $paymentexpensereportstatic->getNomUrl(2); $tabpay[$obj->rowid]["lib"] .= ' ' . $paymentexpensereportstatic->getNomUrl(2);
$tabpay[$obj->rowid]["fk_expensereport"] = $paymentexpensereportstatic->id; $tabpay[$obj->rowid]["fk_expensereport"] = $paymentexpensereportstatic->id;
} else if ($links[$key]['type'] == 'payment_various') {
$paymentvariousstatic->id = $links[$key]['url_id'];
$paymentvariousstatic->ref = $links[$key]['url_id'];
$paymentvariousstatic->label = $links[$key]['label'];
$tabpay[$obj->rowid]["lib"] .= ' ' . $paymentvariousstatic->getNomUrl(2);
$tabpay[$obj->rowid]["paymentvariousid"] = $paymentvariousstatic->id;
$paymentvariousstatic->fetch($paymentvariousstatic->id);
$account_various = (! empty($paymentvariousstatic->accountancy_code) ? $paymentvariousstatic->accountancy_code : $langs->trans("CodeNotDef"));
$tabtp[$obj->rowid][$account_various] += $obj->amount;
} else if ($links[$key]['type'] == 'banktransfert') { } else if ($links[$key]['type'] == 'banktransfert') {
$tabpay[$obj->rowid]["lib"] .= ' ' . $langs->trans("BankTransfer"); $tabpay[$obj->rowid]["lib"] .= ' ' . $langs->trans("BankTransfer");
$tabtp[$obj->rowid][$account_transfer] += $obj->amount; $tabtp[$obj->rowid][$account_transfer] += $obj->amount;
@ -353,7 +365,7 @@ if (! $error && $action == 'writebookkeeping') {
$bookkeeping->fk_doc = $key; $bookkeeping->fk_doc = $key;
$bookkeeping->fk_docdet = $val["fk_bank"]; $bookkeeping->fk_docdet = $val["fk_bank"];
$bookkeeping->numero_compte = $k; $bookkeeping->numero_compte = $k;
$bookkeeping->label_compte = $compte->label; $bookkeeping->label_operation = $val["label"];
$bookkeeping->montant = ($mt < 0 ? - $mt : $mt); $bookkeeping->montant = ($mt < 0 ? - $mt : $mt);
$bookkeeping->sens = ($mt >= 0) ? 'D' : 'C'; $bookkeeping->sens = ($mt >= 0) ? 'D' : 'C';
$bookkeeping->debit = ($mt >= 0 ? $mt : 0); $bookkeeping->debit = ($mt >= 0 ? $mt : 0);
@ -412,8 +424,11 @@ if (! $error && $action == 'writebookkeeping') {
$bookkeeping->doc_ref = $langs->trans("Donation") . ' (' . $val["paymentdonationid"] . ')'; // Rowid of donation $bookkeeping->doc_ref = $langs->trans("Donation") . ' (' . $val["paymentdonationid"] . ')'; // Rowid of donation
} else if ($tabtype[$key] == 'payment_salary') { } else if ($tabtype[$key] == 'payment_salary') {
$bookkeeping->subledger_account = ''; $bookkeeping->subledger_account = '';
$bookkeeping->label_compte = $tabuser[$key]['name']; $bookkeeping->label_operation = $tabuser[$key]['name'];
$bookkeeping->doc_ref = $langs->trans("SalaryPayment") . ' (' . $val["paymentsalid"] . ')'; // Ref of salary payment $bookkeeping->doc_ref = $langs->trans("SalaryPayment") . ' (' . $val["paymentsalid"] . ')'; // Ref of salary payment
} else if ($tabtype[$key] == 'payment_various') {
$bookkeeping->subledger_account = '';
$bookkeeping->doc_ref = $langs->trans("VariousPayment") . ' (' . $val["paymentvariousid"] . ')'; // Ref of various payment
} }
$result = $bookkeeping->create($user); $result = $bookkeeping->create($user);
@ -447,7 +462,7 @@ if (! $error && $action == 'writebookkeeping') {
$bookkeeping->doc_type = 'bank'; $bookkeeping->doc_type = 'bank';
$bookkeeping->fk_doc = $key; $bookkeeping->fk_doc = $key;
$bookkeeping->fk_docdet = $val["fk_bank"]; $bookkeeping->fk_docdet = $val["fk_bank"];
$bookkeeping->label_compte = $tabcompany[$key]['name']; $bookkeeping->label_operation = $tabcompany[$key]['name'];
$bookkeeping->montant = ($mt < 0 ? - $mt : $mt); $bookkeeping->montant = ($mt < 0 ? - $mt : $mt);
$bookkeeping->sens = ($mt < 0) ? 'D' : 'C'; $bookkeeping->sens = ($mt < 0) ? 'D' : 'C';
$bookkeeping->debit = ($mt < 0 ? - $mt : 0); $bookkeeping->debit = ($mt < 0 ? - $mt : 0);
@ -473,7 +488,8 @@ if (! $error && $action == 'writebookkeeping') {
$bookkeeping->doc_ref = $objmid->facnumber; $bookkeeping->doc_ref = $objmid->facnumber;
} }
$bookkeeping->subledger_account = $tabcompany[$key]['code_compta']; $bookkeeping->subledger_account = $tabcompany[$key]['code_compta'];
$bookkeeping->numero_compte = $k; $bookkeeping->subledger_label = $tabcompany[$key]['name'];
$bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER;
} else if ($tabtype[$key] == 'payment_supplier') { // If payment is payment of supplier invoice, we get ref of invoice } else if ($tabtype[$key] == 'payment_supplier') { // If payment is payment of supplier invoice, we get ref of invoice
$sqlmid = 'SELECT facf.ref_supplier,facf.ref'; $sqlmid = 'SELECT facf.ref_supplier,facf.ref';
$sqlmid .= " FROM " . MAIN_DB_PREFIX . "facture_fourn facf "; $sqlmid .= " FROM " . MAIN_DB_PREFIX . "facture_fourn facf ";
@ -487,7 +503,23 @@ if (! $error && $action == 'writebookkeeping') {
$bookkeeping->doc_ref = $objmid->ref_supplier . ' (' . $objmid->ref . ')'; $bookkeeping->doc_ref = $objmid->ref_supplier . ' (' . $objmid->ref . ')';
} }
$bookkeeping->subledger_account = $tabcompany[$key]['code_compta']; $bookkeeping->subledger_account = $tabcompany[$key]['code_compta'];
$bookkeeping->numero_compte = $k; $bookkeeping->subledger_label = $tabcompany[$key]['name'];
$bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER;
} else if ($tabtype[$key] == 'payment_expensereport') {
$bookkeeping->subledger_account = $tabuser[$key]['accountancy_code'];
$bookkeeping->subledger_label = $tabuser[$key]['name'];
$bookkeeping->numero_compte = $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT;
$bookkeeping->label_operation = $tabuser[$key]['name'];
$sqlmid = 'SELECT e.ref';
$sqlmid .= " FROM " . MAIN_DB_PREFIX . "expensereport as e";
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "payment_expensereport as payer ON payer.fk_expensereport=e.rowid";
$sqlmid .= " WHERE payer.fk_expensereport=" . $val["fk_expensereport"];
dol_syslog("accountancy/journal/bankjournal.php:: sqlmid=" . $sqlmid, LOG_DEBUG);
$resultmid = $db->query($sqlmid);
if ($resultmid) {
$objmid = $db->fetch_object($resultmid);
$bookkeeping->doc_ref = $objmid->ref; // Ref of expensereport
}
} else if ($tabtype[$key] == 'payment_vat') { } else if ($tabtype[$key] == 'payment_vat') {
$bookkeeping->subledger_account = ''; $bookkeeping->subledger_account = '';
$bookkeeping->numero_compte = $k; $bookkeeping->numero_compte = $k;
@ -499,16 +531,19 @@ if (! $error && $action == 'writebookkeeping') {
} else if ($tabtype[$key] == 'payment_salary') { } else if ($tabtype[$key] == 'payment_salary') {
$bookkeeping->subledger_account = $tabuser[$key]['accountancy_code']; $bookkeeping->subledger_account = $tabuser[$key]['accountancy_code'];
$bookkeeping->numero_compte = $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT; $bookkeeping->numero_compte = $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT;
$bookkeeping->label_compte = $tabuser[$key]['name']; $bookkeeping->label_operation = $tabuser[$key]['name'];
$bookkeeping->doc_ref = $langs->trans("SalaryPayment") . ' (' . $val["paymentsalid"] . ')'; // Rowid of salary payment $bookkeeping->doc_ref = $langs->trans("SalaryPayment") . ' (' . $val["paymentsalid"] . ')'; // Rowid of salary payment
} else if ($tabtype[$key] == 'payment_various') {
$bookkeeping->subledger_account = '';
$bookkeeping->numero_compte = $k;
$bookkeeping->doc_ref = $langs->trans("VariousPayment") . ' (' . $val["paymentvariousid"] . ')'; // Rowid of various payment
} else if ($tabtype[$key] == 'banktransfert') { } else if ($tabtype[$key] == 'banktransfert') {
$bookkeeping->subledger_account = ''; $bookkeeping->subledger_account = '';
$bookkeeping->numero_compte = $k; $bookkeeping->numero_compte = $k;
} else { } else {
// FIXME Should be a temporary account ??? // Temporary account
$bookkeeping->doc_ref = $k; $bookkeeping->doc_ref = $k;
//$bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER; $bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_SUSPENSE;
$bookkeeping->numero_compte = 'CodeNotDef';
} }
$result = $bookkeeping->create($user); $result = $bookkeeping->create($user);
@ -745,6 +780,7 @@ if (empty($action) || $action == 'view') {
$vatstatic = new Tva($db); $vatstatic = new Tva($db);
$donationstatic = new Don($db); $donationstatic = new Don($db);
$salarystatic = new PaymentSalary($db); $salarystatic = new PaymentSalary($db);
$variousstatic = new PaymentVarious($db);
llxHeader('', $langs->trans("FinanceJournal")); llxHeader('', $langs->trans("FinanceJournal"));
@ -913,7 +949,20 @@ if (empty($action) || $action == 'view') {
} }
else dol_print_error($db); else dol_print_error($db);
} }
elseif ($tabtype[$key] == 'payment_various')
{
$sqlmid = 'SELECT v.rowid as id';
$sqlmid .= " FROM " . MAIN_DB_PREFIX . "payment_various as v";
$sqlmid .= " WHERE v.rowid=" . $val["paymentvariousid"];
dol_syslog("accountancy/journal/bankjournal.php::sqlmid=" . $sqlmid, LOG_DEBUG);
$resultmid = $db->query($sqlmid);
if ($resultmid) {
$objmid = $db->fetch_object($resultmid);
$variousstatic->fetch($objmid->id);
$ref=$variousstatic->getNomUrl(1);
}
else dol_print_error($db);
}
/*$invoicestatic->id = $key; /*$invoicestatic->id = $key;
$invoicestatic->ref = $val["ref"]; $invoicestatic->ref = $val["ref"];

View File

@ -148,7 +148,7 @@ if ($result) {
$tabtva[$obj->rowid][$compta_tva] += $obj->total_tva; $tabtva[$obj->rowid][$compta_tva] += $obj->total_tva;
$tabuser[$obj->rowid] = array ( $tabuser[$obj->rowid] = array (
'id' => $obj->uid, 'id' => $obj->uid,
'name' => $obj->firstname.' '.$obj->lastname, 'name' => dolGetFirstLastname($obj->firstname, $obj->lastname),
'user_accountancy_code' => $obj->user_accountancy_account 'user_accountancy_code' => $obj->user_accountancy_account
); );
@ -169,6 +169,7 @@ if ($action == 'writebookkeeping') {
$db->begin(); $db->begin();
// Thirdparty
if (! $errorforline) if (! $errorforline)
{ {
foreach ( $tabttc[$key] as $k => $mt ) { foreach ( $tabttc[$key] as $k => $mt ) {
@ -183,7 +184,7 @@ if ($action == 'writebookkeeping') {
$bookkeeping->fk_docdet = $val["fk_expensereportdet"]; $bookkeeping->fk_docdet = $val["fk_expensereportdet"];
$bookkeeping->subledger_account = $tabuser[$key]['user_accountancy_code']; $bookkeeping->subledger_account = $tabuser[$key]['user_accountancy_code'];
$bookkeeping->subledger_label = $tabuser[$key]['user_accountancy_code']; $bookkeeping->subledger_label = $tabuser[$key]['user_accountancy_code'];
$bookkeeping->label_compte = $tabuser[$key]['name']; $bookkeeping->label_operation = $tabuser[$key]['name'];
$bookkeeping->numero_compte = $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT; $bookkeeping->numero_compte = $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT;
$bookkeeping->montant = $mt; $bookkeeping->montant = $mt;
$bookkeeping->sens = ($mt >= 0) ? 'C' : 'D'; $bookkeeping->sens = ($mt >= 0) ? 'C' : 'D';
@ -212,9 +213,9 @@ if ($action == 'writebookkeeping') {
} }
} }
// Fees
if (! $errorforline) if (! $errorforline)
{ {
// Fees
foreach ( $tabht[$key] as $k => $mt ) { foreach ( $tabht[$key] as $k => $mt ) {
$accountingaccount = new AccountingAccount($db); $accountingaccount = new AccountingAccount($db);
$accountingaccount->fetch(null, $k, true); $accountingaccount->fetch(null, $k, true);
@ -231,7 +232,7 @@ if ($action == 'writebookkeeping') {
$bookkeeping->fk_docdet = $val["fk_expensereportdet"]; $bookkeeping->fk_docdet = $val["fk_expensereportdet"];
$bookkeeping->subledger_account = ''; $bookkeeping->subledger_account = '';
$bookkeeping->subledger_label = ''; $bookkeeping->subledger_label = '';
$bookkeeping->label_compte = $accountingaccount->label; $bookkeeping->label_operation = $accountingaccount->label;
$bookkeeping->numero_compte = $k; $bookkeeping->numero_compte = $k;
$bookkeeping->montant = $mt; $bookkeeping->montant = $mt;
$bookkeeping->sens = ($mt < 0) ? 'C' : 'D'; $bookkeeping->sens = ($mt < 0) ? 'C' : 'D';
@ -261,9 +262,9 @@ if ($action == 'writebookkeeping') {
} }
} }
// VAT
if (! $errorforline) if (! $errorforline)
{ {
// VAT
// var_dump($tabtva); // var_dump($tabtva);
foreach ( $tabtva[$key] as $k => $mt ) { foreach ( $tabtva[$key] as $k => $mt ) {
if ($mt) { if ($mt) {
@ -277,7 +278,7 @@ if ($action == 'writebookkeeping') {
$bookkeeping->fk_docdet = $val["fk_expensereportdet"]; $bookkeeping->fk_docdet = $val["fk_expensereportdet"];
$bookkeeping->subledger_account = ''; $bookkeeping->subledger_account = '';
$bookkeeping->subledger_label = ''; $bookkeeping->subledger_label = '';
$bookkeeping->label_compte = $langs->trans("VAT"). ' '.join(', ',$def_tva[$key][$k]); $bookkeeping->label_operation = $langs->trans("VAT"). ' '.join(', ',$def_tva[$key][$k]);
$bookkeeping->numero_compte = $k; $bookkeeping->numero_compte = $k;
$bookkeeping->montant = $mt; $bookkeeping->montant = $mt;
$bookkeeping->sens = ($mt < 0) ? 'C' : 'D'; $bookkeeping->sens = ($mt < 0) ? 'C' : 'D';

View File

@ -3,7 +3,7 @@
* Copyright (C) 2007-2010 Jean Heimburger <jean@tiaris.info> * Copyright (C) 2007-2010 Jean Heimburger <jean@tiaris.info>
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2012 Regis Houssin <regis@dolibarr.fr> * Copyright (C) 2012 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2013-2015 Alexandre Spangaro <aspangaro@zendsi.com> * Copyright (C) 2013-2017 Alexandre Spangaro <aspangaro@zendsi.com>
* Copyright (C) 2013-2016 Olivier Geffroy <jeff@jeffinfo.com> * Copyright (C) 2013-2016 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2016 Florian Henry <florian.henry@open-concept.pro> * Copyright (C) 2013-2016 Florian Henry <florian.henry@open-concept.pro>
* *
@ -208,10 +208,10 @@ if ($action == 'writebookkeeping') {
$companystatic->code_fournisseur = $tabcompany[$key]['code_fournisseur']; $companystatic->code_fournisseur = $tabcompany[$key]['code_fournisseur'];
$companystatic->client = $tabcompany[$key]['code_client']; $companystatic->client = $tabcompany[$key]['code_client'];
// Thirdparty
if (! $errorforline) if (! $errorforline)
{ {
foreach ( $tabttc[$key] as $k => $mt ) { foreach ( $tabttc[$key] as $k => $mt ) {
// get compte id and label
if ($mt) { if ($mt) {
$bookkeeping = new BookKeeping($db); $bookkeeping = new BookKeeping($db);
$bookkeeping->doc_date = $val["date"]; $bookkeeping->doc_date = $val["date"];
@ -223,7 +223,7 @@ if ($action == 'writebookkeeping') {
$bookkeeping->thirdparty_code = $companystatic->code_fournisseur; $bookkeeping->thirdparty_code = $companystatic->code_fournisseur;
$bookkeeping->subledger_account = $tabcompany[$key]['code_compta_fournisseur']; $bookkeeping->subledger_account = $tabcompany[$key]['code_compta_fournisseur'];
$bookkeeping->subledger_label = ''; // TODO To complete $bookkeeping->subledger_label = ''; // TODO To complete
$bookkeeping->label_compte = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $langs->trans("subledger_account"); $bookkeeping->label_operation = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $langs->trans("subledger_account");
$bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER; $bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER;
$bookkeeping->montant = $mt; $bookkeeping->montant = $mt;
$bookkeeping->sens = ($mt >= 0) ? 'C' : 'D'; $bookkeeping->sens = ($mt >= 0) ? 'C' : 'D';
@ -272,7 +272,7 @@ if ($action == 'writebookkeeping') {
$bookkeeping->thirdparty_code = $companystatic->code_fournisseur; $bookkeeping->thirdparty_code = $companystatic->code_fournisseur;
$bookkeeping->subledger_account = ''; $bookkeeping->subledger_account = '';
$bookkeeping->subledger_label = ''; $bookkeeping->subledger_label = '';
$bookkeeping->label_compte = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $accountingaccount->label; $bookkeeping->label_operation = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $accountingaccount->label;
$bookkeeping->numero_compte = $k; $bookkeeping->numero_compte = $k;
$bookkeeping->montant = $mt; $bookkeeping->montant = $mt;
$bookkeeping->sens = ($mt < 0) ? 'C' : 'D'; $bookkeeping->sens = ($mt < 0) ? 'C' : 'D';
@ -319,7 +319,7 @@ if ($action == 'writebookkeeping') {
$bookkeeping->thirdparty_code = $companystatic->code_fournisseur; $bookkeeping->thirdparty_code = $companystatic->code_fournisseur;
$bookkeeping->subledger_account = ''; $bookkeeping->subledger_account = '';
$bookkeeping->subledger_label = ''; $bookkeeping->subledger_label = '';
$bookkeeping->label_compte = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $langs->trans("VAT"). ' '.join(', ',$def_tva[$key][$k]); $bookkeeping->label_operation = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $langs->trans("VAT"). ' '.join(', ',$def_tva[$key][$k]);
$bookkeeping->numero_compte = $k; $bookkeeping->numero_compte = $k;
$bookkeeping->montant = $mt; $bookkeeping->montant = $mt;
$bookkeeping->sens = ($mt < 0) ? 'C' : 'D'; $bookkeeping->sens = ($mt < 0) ? 'C' : 'D';

View File

@ -239,7 +239,7 @@ if ($action == 'writebookkeeping') {
$bookkeeping->subledger_account = $tabcompany[$key]['code_compta']; $bookkeeping->subledger_account = $tabcompany[$key]['code_compta'];
$bookkeeping->subledger_label = ''; // TODO To complete $bookkeeping->subledger_label = ''; // TODO To complete
$bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER; $bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER;
$bookkeeping->label_compte = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("subledger_account"); $bookkeeping->label_operation = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("subledger_account");
$bookkeeping->montant = $mt; $bookkeeping->montant = $mt;
$bookkeeping->sens = ($mt >= 0) ? 'D' : 'C'; $bookkeeping->sens = ($mt >= 0) ? 'D' : 'C';
$bookkeeping->debit = ($mt >= 0) ? $mt : 0; $bookkeeping->debit = ($mt >= 0) ? $mt : 0;
@ -286,7 +286,7 @@ if ($action == 'writebookkeeping') {
$bookkeeping->subledger_account = ''; $bookkeeping->subledger_account = '';
$bookkeeping->subledger_label = ''; $bookkeeping->subledger_label = '';
$bookkeeping->numero_compte = $k; $bookkeeping->numero_compte = $k;
$bookkeeping->label_compte = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $accountingaccount->label; $bookkeeping->label_operation = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $accountingaccount->label;
$bookkeeping->montant = $mt; $bookkeeping->montant = $mt;
$bookkeeping->sens = ($mt < 0) ? 'D' : 'C'; $bookkeeping->sens = ($mt < 0) ? 'D' : 'C';
$bookkeeping->debit = ($mt < 0) ? $mt : 0; $bookkeeping->debit = ($mt < 0) ? $mt : 0;
@ -332,7 +332,7 @@ if ($action == 'writebookkeeping') {
$bookkeeping->subledger_account = ''; $bookkeeping->subledger_account = '';
$bookkeeping->subledger_label = ''; $bookkeeping->subledger_label = '';
$bookkeeping->numero_compte = $k; $bookkeeping->numero_compte = $k;
$bookkeeping->label_compte = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("VAT").' '.join(', ',$def_tva[$key][$k]); $bookkeeping->label_operation = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("VAT").' '.join(', ',$def_tva[$key][$k]);
$bookkeeping->montant = $mt; $bookkeeping->montant = $mt;
$bookkeeping->sens = ($mt < 0) ? 'D' : 'C'; $bookkeeping->sens = ($mt < 0) ? 'D' : 'C';
$bookkeeping->debit = ($mt < 0) ? $mt : 0; $bookkeeping->debit = ($mt < 0) ? $mt : 0;

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2016 Jamal Elbaz <jamelbaz@gmail.pro> /* Copyright (C) 2016 Jamal Elbaz <jamelbaz@gmail.pro>
* Copyright (C) 2016 Alexandre Spangaro <aspangaro.dolibarr@gmail.com> * Copyright (C) 2016 Alexandre Spangaro <aspangaro@zendsi.com>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by

View File

@ -1,7 +1,7 @@
<?php <?php
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2005 Simon TOSSER <simon@kornog-computing.com> * Copyright (C) 2005 Simon TOSSER <simon@kornog-computing.com>
* Copyright (C) 2013-2017 Alexandre Spangaro <aspangaro.dolibarr@gmail.com> * Copyright (C) 2013-2017 Alexandre Spangaro <aspangaro@zendsi.com>
* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com> * Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro> * Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>

View File

@ -1,7 +1,7 @@
<?php <?php
/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com> /* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro> * Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2013-2015 Alexandre Spangaro <aspangaro.dolibarr@gmail.com> * Copyright (C) 2013-2015 Alexandre Spangaro <aspangaro@zendsi.com>
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2013-2016 Olivier Geffroy <jeff@jeffinfo.com> /* Copyright (C) 2013-2016 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2017 Alexandre Spangaro <aspangaro.dolibarr@gmail.com> * Copyright (C) 2013-2017 Alexandre Spangaro <aspangaro@zendsi.com>
* Copyright (C) 2014-2015 Ari Elbaz (elarifr) <github@accedinfo.com> * Copyright (C) 2014-2015 Ari Elbaz (elarifr) <github@accedinfo.com>
* Copyright (C) 2013-2016 Florian Henry <florian.henry@open-concept.pro> * Copyright (C) 2013-2016 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com> /* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2017 Alexandre Spangaro <aspangaro.dolibarr@gmail.com> * Copyright (C) 2013-2017 Alexandre Spangaro <aspangaro@zendsi.com>
* Copyright (C) 2014-2015 Ari Elbaz (elarifr) <github@accedinfo.com> * Copyright (C) 2014-2015 Ari Elbaz (elarifr) <github@accedinfo.com>
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro> * Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>s * Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>s

View File

@ -1,5 +1,5 @@
<?php <?php
/* Copyright (C) 2015 Alexandre Spangaro <aspangaro.dolibarr@gmail.com> /* Copyright (C) 2015 Alexandre Spangaro <aspangaro@zendsi.com>
* Copyright (C) 2016 Charlie Benke <charlie@patas-monkey.com> * Copyright (C) 2016 Charlie Benke <charlie@patas-monkey.com>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify

View File

@ -17,8 +17,8 @@
/** /**
* \file htdocs/compta/bank/class/paymentvarious.class.php * \file htdocs/compta/bank/class/paymentvarious.class.php
* \ingroup salaries * \ingroup bank
* \brief Class for salaries module payment * \brief Class for various payment
*/ */
// Put here all includes required by your class file // Put here all includes required by your class file
@ -74,7 +74,6 @@ class PaymentVarious extends CommonObject
$error=0; $error=0;
// Clean parameters // Clean parameters
$this->fk_user=trim($this->fk_user);
$this->amount=trim($this->amount); $this->amount=trim($this->amount);
$this->label=trim($this->label); $this->label=trim($this->label);
$this->note=trim($this->note); $this->note=trim($this->note);
@ -85,10 +84,9 @@ class PaymentVarious extends CommonObject
$this->db->begin(); $this->db->begin();
// Update request // Update request
$sql = "UPDATE ".MAIN_DB_PREFIX."payment_salary SET"; $sql = "UPDATE ".MAIN_DB_PREFIX."payment_various SET";
$sql.= " tms=".$this->db->idate($this->tms).","; $sql.= " tms=".$this->db->idate($this->tms).",";
$sql.= " fk_user=".$this->fk_user.",";
$sql.= " datep=".$this->db->idate($this->datep).","; $sql.= " datep=".$this->db->idate($this->datep).",";
$sql.= " datev=".$this->db->idate($this->datev).","; $sql.= " datev=".$this->db->idate($this->datev).",";
$sql.= " sens=".$this->sens.","; $sql.= " sens=".$this->sens.",";
@ -115,7 +113,7 @@ class PaymentVarious extends CommonObject
if (! $notrigger) if (! $notrigger)
{ {
// Call trigger // Call trigger
$result=$this->call_trigger('PAYMENT_SALARY_MODIFY',$user); $result=$this->call_trigger('PAYMENT_VARIOUS_MODIFY',$user);
if ($result < 0) $error++; if ($result < 0) $error++;
// End call triggers // End call triggers
} }
@ -178,7 +176,6 @@ class PaymentVarious extends CommonObject
$this->id = $obj->rowid; $this->id = $obj->rowid;
$this->ref = $obj->rowid; $this->ref = $obj->rowid;
$this->tms = $this->db->jdate($obj->tms); $this->tms = $this->db->jdate($obj->tms);
$this->fk_user = $obj->fk_user;
$this->datep = $this->db->jdate($obj->datep); $this->datep = $this->db->jdate($obj->datep);
$this->datev = $this->db->jdate($obj->datev); $this->datev = $this->db->jdate($obj->datev);
$this->sens = $obj->sens; $this->sens = $obj->sens;
@ -252,12 +249,12 @@ class PaymentVarious extends CommonObject
$this->id=0; $this->id=0;
$this->tms=''; $this->tms='';
$this->fk_user='';
$this->datep=''; $this->datep='';
$this->datev=''; $this->datev='';
$this->sens=''; $this->sens='';
$this->amount=''; $this->amount='';
$this->label=''; $this->label='';
$this->accountancy_code='';
$this->note=''; $this->note='';
$this->fk_bank=''; $this->fk_bank='';
$this->fk_user_author=''; $this->fk_user_author='';

View File

@ -49,7 +49,7 @@ $confirm=GETPOST('confirm','alpha');
$rowid=GETPOST("rowid",'int'); $rowid=GETPOST("rowid",'int');
$orig_account=GETPOST("orig_account"); $orig_account=GETPOST("orig_account");
$backtopage=GETPOST('backtopage'); $backtopage=GETPOST('backtopage');
$cancel=GETPOSt('cancel'); $cancel=GETPOST('cancel');
// Security check // Security check
$fieldvalue = (! empty($id) ? $id : (! empty($ref) ? $ref :'')); $fieldvalue = (! empty($id) ? $id : (! empty($ref) ? $ref :''));

View File

@ -333,8 +333,58 @@ function print_left_auguria_menu($db,$menu_array_before,$menu_array_after,&$tabM
if (! empty($conf->accounting->enabled) && !empty($user->rights->accounting->mouvements->lire) && $mainmenu == 'accountancy') // Entry in accountancy journal for each bank account if (! empty($conf->accounting->enabled) && !empty($user->rights->accounting->mouvements->lire) && $mainmenu == 'accountancy') // Entry in accountancy journal for each bank account
{ {
$newmenu->add('',$langs->trans("Journalization"),0,$user->rights->accounting->comptarapport->lire,'','accountancy','accountancy'); if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy/',$leftmenu)) $newmenu->add('',$langs->trans("Journalization"),0,$user->rights->accounting->comptarapport->lire,'','accountancy','accountancy');
// Multi journal
$sql = "SELECT rowid, code, label, nature";
$sql.= " FROM ".MAIN_DB_PREFIX."accounting_journal";
$sql.= " WHERE entity = ".$conf->entity;
$sql.= " ORDER BY label";
$resql = $db->query($sql);
if ($resql)
{
$numr = $db->num_rows($resql);
$i = 0;
if ($numr > 0)
{
while ($i < $numr)
{
$objp = $db->fetch_object($resql);
$nature='';
// Must match array $sourceList defined into journals_list.php
if ($objp->nature == 2) $nature="sells";
if ($objp->nature == 3) $nature="purchases";
if ($objp->nature == 4) $nature="bank";
if ($objp->nature == 5) $nature="expensereports";
if ($objp->nature == 1) $nature="various";
if ($objp->nature == 9) $nature="hasnew";
// To enable when page exists
if (empty($conf->global->MAIN_FEATURES_LEVEL))
{
if ($nature == 'various' || $nature == 'hasnew') $nature='';
}
if ($nature)
{
if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy/',$leftmenu)) $newmenu->add('/accountancy/journal/'.$nature.'journal.php?mainmenu=accountancy&leftmenu=accountancy_journal&id_journal='.$objp->rowid,dol_trunc($objp->label,25),2,$user->rights->accounting->comptarapport->lire);
}
$i++;
}
}
else
{
// Should not happend. Entries are added
$newmenu->add('',$langs->trans("NoJournalDefined"), 2, $user->rights->accounting->comptarapport->lire);
}
}
else dol_print_error($db);
$db->free($resql);
/*
$sql = "SELECT rowid, label, accountancy_journal"; $sql = "SELECT rowid, label, accountancy_journal";
$sql.= " FROM ".MAIN_DB_PREFIX."bank_account"; $sql.= " FROM ".MAIN_DB_PREFIX."bank_account";
$sql.= " WHERE entity = ".$conf->entity; $sql.= " WHERE entity = ".$conf->entity;
@ -362,6 +412,7 @@ function print_left_auguria_menu($db,$menu_array_before,$menu_array_after,&$tabM
$newmenu->add("/accountancy/journal/sellsjournal.php?leftmenu=journal",$langs->trans("SellsJournal"),1,$user->rights->accounting->comptarapport->lire,'','accountancy','accountancy_journal'); $newmenu->add("/accountancy/journal/sellsjournal.php?leftmenu=journal",$langs->trans("SellsJournal"),1,$user->rights->accounting->comptarapport->lire,'','accountancy','accountancy_journal');
$newmenu->add("/accountancy/journal/purchasesjournal.php?leftmenu=journal",$langs->trans("PurchasesJournal"),1,$user->rights->accounting->comptarapport->lire,'','accountancy','accountancy_journal'); $newmenu->add("/accountancy/journal/purchasesjournal.php?leftmenu=journal",$langs->trans("PurchasesJournal"),1,$user->rights->accounting->comptarapport->lire,'','accountancy','accountancy_journal');
$newmenu->add("/accountancy/journal/expensereportsjournal.php?leftmenu=journal",$langs->trans("ExpenseReportsJournal"),1,$user->rights->accounting->comptarapport->lire,'','accountancy','accountancy_journal'); $newmenu->add("/accountancy/journal/expensereportsjournal.php?leftmenu=journal",$langs->trans("ExpenseReportsJournal"),1,$user->rights->accounting->comptarapport->lire,'','accountancy','accountancy_journal');
*/
} }
if ($conf->ftp->enabled && $mainmenu == 'ftp') // Entry for FTP if ($conf->ftp->enabled && $mainmenu == 'ftp') // Entry for FTP

View File

@ -216,6 +216,46 @@ ALTER TABLE llx_accounting_bookkeeping ADD COLUMN date_lettering datetime AFTER
ALTER TABLE llx_accounting_bookkeeping ADD COLUMN journal_label varchar(255) AFTER code_journal; ALTER TABLE llx_accounting_bookkeeping ADD COLUMN journal_label varchar(255) AFTER code_journal;
ALTER TABLE llx_accounting_bookkeeping ADD COLUMN date_validated datetime AFTER validated; ALTER TABLE llx_accounting_bookkeeping ADD COLUMN date_validated datetime AFTER validated;
CREATE TABLE llx_accounting_bookkeeping_tmp
(
rowid integer NOT NULL AUTO_INCREMENT PRIMARY KEY,
entity integer DEFAULT 1 NOT NULL, -- | multi company id
doc_date date NOT NULL, -- FEC:PieceDate
doc_type varchar(30) NOT NULL, -- FEC:PieceRef | facture_client/reglement_client/facture_fournisseur/reglement_fournisseur
doc_ref varchar(300) NOT NULL, -- | facture_client/reglement_client/... reference number
fk_doc integer NOT NULL, -- | facture_client/reglement_client/... rowid
fk_docdet integer NOT NULL, -- | facture_client/reglement_client/... line rowid
thirdparty_code varchar(32), -- Third party code (customer or supplier) when record is saved (may help debug)
subledger_account varchar(32), -- FEC:CompAuxNum | account number of subledger account
subledger_label varchar(255), -- FEC:CompAuxLib | label of subledger account
numero_compte varchar(32) NOT NULL, -- FEC:CompteNum | account number
label_compte varchar(255) NOT NULL, -- FEC:CompteLib | label of account
label_operation varchar(255), -- FEC:EcritureLib | label of the operation
debit numeric(24,8) NOT NULL, -- FEC:Debit
credit numeric(24,8) NOT NULL, -- FEC:Credit
montant numeric(24,8) NOT NULL, -- FEC:Montant (Not necessary)
sens varchar(1) DEFAULT NULL, -- FEC:Sens (Not necessary)
multicurrency_amount numeric(24,8), -- FEC:Montantdevise
multicurrency_code varchar(255), -- FEC:Idevise
lettering_code varchar(255), -- FEC:EcritureLet
date_lettering datetime, -- FEC:DateLet
fk_user_author integer NOT NULL, -- | user creating
fk_user_modif integer, -- | user making last change
date_creation datetime, -- FEC:EcritureDate | creation date
tms timestamp, -- | date last modification
import_key varchar(14),
code_journal varchar(32) NOT NULL, -- FEC:JournalCode
journal_label varchar(255), -- FEC:JournalLib
piece_num integer NOT NULL, -- FEC:EcritureNum
validated tinyint DEFAULT 0 NOT NULL, -- | 0 line not validated / 1 line validated (No deleting / No modification)
date_validated datetime -- FEC:ValidDate
) ENGINE=innodb;
ALTER TABLE llx_accounting_bookkeeping_tmp ADD INDEX idx_accounting_bookkeeping_doc_date (doc_date);
ALTER TABLE llx_accounting_bookkeeping_tmp ADD INDEX idx_accounting_bookkeeping_fk_docdet (fk_docdet);
ALTER TABLE llx_accounting_bookkeeping_tmp ADD INDEX idx_accounting_bookkeeping_numero_compte (numero_compte);
ALTER TABLE llx_accounting_bookkeeping_tmp ADD INDEX idx_accounting_bookkeeping_code_journal (code_journal);
ALTER TABLE llx_paiementfourn ADD COLUMN model_pdf varchar(255); ALTER TABLE llx_paiementfourn ADD COLUMN model_pdf varchar(255);
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('EXPENSE_REPORT_CREATE','Expense report created','Executed when an expense report is created','expensereport',201); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('EXPENSE_REPORT_CREATE','Expense report created','Executed when an expense report is created','expensereport',201);

View File

@ -0,0 +1,22 @@
-- ============================================================================
-- Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
--
-- 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
-- the Free Software Foundation; either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
--
-- ============================================================================
ALTER TABLE llx_accounting_bookkeeping_tmp ADD INDEX idx_accounting_bookkeeping_doc_date (doc_date);
ALTER TABLE llx_accounting_bookkeeping_tmp ADD INDEX idx_accounting_bookkeeping_fk_docdet (fk_docdet);
ALTER TABLE llx_accounting_bookkeeping_tmp ADD INDEX idx_accounting_bookkeeping_numero_compte (numero_compte);
ALTER TABLE llx_accounting_bookkeeping_tmp ADD INDEX idx_accounting_bookkeeping_code_journal (code_journal);

View File

@ -0,0 +1,53 @@
-- ============================================================================
-- Copyright (C) 2013-2017 Olivier Geffroy <jeff@jeffinfo.com>
-- Copyright (C) 2013-2017 Alexandre Spangaro <aspangaro@zendsi.com>
--
-- 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
-- the Free Software Foundation; either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
--
-- ============================================================================
CREATE TABLE llx_accounting_bookkeeping_tmp
(
rowid integer NOT NULL AUTO_INCREMENT PRIMARY KEY,
entity integer DEFAULT 1 NOT NULL, -- | multi company id
doc_date date NOT NULL, -- FEC:PieceDate
doc_type varchar(30) NOT NULL, -- FEC:PieceRef | facture_client/reglement_client/facture_fournisseur/reglement_fournisseur
doc_ref varchar(300) NOT NULL, -- | facture_client/reglement_client/... reference number
fk_doc integer NOT NULL, -- | facture_client/reglement_client/... rowid
fk_docdet integer NOT NULL, -- | facture_client/reglement_client/... line rowid
thirdparty_code varchar(32), -- Third party code (customer or supplier) when record is saved (may help debug)
subledger_account varchar(32), -- FEC:CompAuxNum | account number of subledger account
subledger_label varchar(255), -- FEC:CompAuxLib | label of subledger account
numero_compte varchar(32) NOT NULL, -- FEC:CompteNum | account number
label_compte varchar(255) NOT NULL, -- FEC:CompteLib | label of account
label_operation varchar(255), -- FEC:EcritureLib | label of the operation
debit numeric(24,8) NOT NULL, -- FEC:Debit
credit numeric(24,8) NOT NULL, -- FEC:Credit
montant numeric(24,8) NOT NULL, -- FEC:Montant (Not necessary)
sens varchar(1) DEFAULT NULL, -- FEC:Sens (Not necessary)
multicurrency_amount numeric(24,8), -- FEC:Montantdevise
multicurrency_code varchar(255), -- FEC:Idevise
lettering_code varchar(255), -- FEC:EcritureLet
date_lettering datetime, -- FEC:DateLet
fk_user_author integer NOT NULL, -- | user creating
fk_user_modif integer, -- | user making last change
date_creation datetime, -- FEC:EcritureDate | creation date
tms timestamp, -- | date last modification
import_key varchar(14),
code_journal varchar(32) NOT NULL, -- FEC:JournalCode
journal_label varchar(255), -- FEC:JournalLib
piece_num integer NOT NULL, -- FEC:EcritureNum
validated tinyint DEFAULT 0 NOT NULL, -- | 0 line not validated / 1 line validated (No deleting / No modification)
date_validated datetime -- FEC:ValidDate
) ENGINE=innodb;

View File

@ -214,6 +214,7 @@ AccountingJournalType1=Various operation
AccountingJournalType2=Sales AccountingJournalType2=Sales
AccountingJournalType3=Purchases AccountingJournalType3=Purchases
AccountingJournalType4=Bank AccountingJournalType4=Bank
AccountingJournalType5=Expenses report
AccountingJournalType9=Has-new AccountingJournalType9=Has-new
ErrorAccountingJournalIsAlreadyUse=This journal is already use ErrorAccountingJournalIsAlreadyUse=This journal is already use