Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop
This commit is contained in:
commit
409d6df067
@ -23,6 +23,7 @@
|
|||||||
* \ingroup Advanced accountancy
|
* \ingroup Advanced accountancy
|
||||||
* \brief Balance of book keeping
|
* \brief Balance of book keeping
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require '../../main.inc.php';
|
require '../../main.inc.php';
|
||||||
|
|
||||||
// Class
|
// Class
|
||||||
@ -184,7 +185,7 @@ else {
|
|||||||
print_liste_field_titre($langs->trans("Labelcompte"), $_SERVER['PHP_SELF'], "t.label_compte", "", $options, "", $sortfield, $sortorder);
|
print_liste_field_titre($langs->trans("Labelcompte"), $_SERVER['PHP_SELF'], "t.label_compte", "", $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, "", 'width="60" align="center"', $sortfield, $sortorder);
|
print_liste_field_titre($langs->trans("Solde"), $_SERVER["PHP_SELF"], "", $options, "", 'align="right"', $sortfield, $sortorder);
|
||||||
print_liste_field_titre($langs->trans("Action"), $_SERVER["PHP_SELF"], "", $options, "", 'width="60" align="center"', $sortfield, $sortorder);
|
print_liste_field_titre($langs->trans("Action"), $_SERVER["PHP_SELF"], "", $options, "", 'width="60" align="center"', $sortfield, $sortorder);
|
||||||
print "</tr>\n";
|
print "</tr>\n";
|
||||||
|
|
||||||
@ -213,6 +214,9 @@ else {
|
|||||||
|
|
||||||
$total_debit = 0;
|
$total_debit = 0;
|
||||||
$total_credit = 0;
|
$total_credit = 0;
|
||||||
|
$sous_total_debit = 0;
|
||||||
|
$sous_total_credit = 0;
|
||||||
|
$displayed_account = "";
|
||||||
|
|
||||||
foreach ( $object->lines as $line ) {
|
foreach ( $object->lines as $line ) {
|
||||||
$var = ! $var;
|
$var = ! $var;
|
||||||
@ -220,33 +224,59 @@ else {
|
|||||||
$total_debit += $line->debit;
|
$total_debit += $line->debit;
|
||||||
$total_credit += $line->credit;
|
$total_credit += $line->credit;
|
||||||
$description = $object->get_compte_desc($line->numero_compte); // Search description of the account
|
$description = $object->get_compte_desc($line->numero_compte); // Search description of the account
|
||||||
|
$root_account_description = $object->get_compte_racine($line->numero_compte);
|
||||||
if(empty($description)){
|
if(empty($description)){
|
||||||
$link = '<a href="../admin/card.php?action=create&compte=' . length_accountg($line->numero_compte) . '">' . img_edit_add() .'</a>';
|
$link = '<a href="../admin/card.php?action=create&compte=' . length_accountg($line->numero_compte) . '">' . img_edit_add() .'</a>';
|
||||||
}
|
}
|
||||||
print '<tr'. $bc[$var].'>';
|
print '<tr'. $bc[$var].'>';
|
||||||
|
|
||||||
|
|
||||||
|
// Permet d'afficher le compte comptable
|
||||||
|
if ($root_account_description != $displayed_account) {
|
||||||
|
|
||||||
|
// Affiche un Sous-Total par compte comptable
|
||||||
|
if ($displayed_account != "") {
|
||||||
|
print '<tr class="liste_total"><td align="right" colspan="2">'.$langs->trans("SubTotal") . ':</td><td class="nowrap" align="right">'.price($sous_total_debit).'</td><td class="nowrap" align="right">'.price($sous_total_credit).'</td><td class="nowrap" align="right">'.price($sous_total_credit-$sous_total_debit).'</td>';
|
||||||
|
print "<td> </td>\n";
|
||||||
|
print '</tr>';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Affiche le compte comptable en début de ligne
|
||||||
|
print "<tr>";
|
||||||
|
print '<td colspan="6" style="font-weight:bold; border-bottom: 1pt solid black;">'. $root_account_description .'</td>';
|
||||||
|
print '</tr>';
|
||||||
|
|
||||||
|
$displayed_account = $root_account_description;
|
||||||
|
$sous_total_debit = 0;
|
||||||
|
$sous_total_credit = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// $object->get_compte_racine($line->numero_compte);
|
||||||
|
|
||||||
|
|
||||||
print '<td>' . length_accountg($line->numero_compte) . '</td>';
|
print '<td>' . length_accountg($line->numero_compte) . '</td>';
|
||||||
print '<td>' . $description . '</td>';
|
print '<td>' . $description . '</td>';
|
||||||
print '<td align="right">' . number_format($line->debit, 2, ',', ' ') . '</td>';
|
print '<td align="right">' . number_format($line->debit, 2, ',', ' ') . '</td>';
|
||||||
print '<td align="right">' . number_format($line->credit, 2, ',', ' ') . '</td>';
|
print '<td align="right">' . number_format($line->credit, 2, ',', ' ') . '</td>';
|
||||||
print '<td align="right">' . number_format($line->credit - $line->debit, 2, ',', ' ') . '</td>';
|
print '<td align="right">' . number_format($line->credit - $line->debit, 2, ',', ' ') . '</td>';
|
||||||
print '<td align="center">' . $link;
|
print '<td align="center">' . $link;
|
||||||
print '</td>';
|
print '</td>';
|
||||||
print "</tr>\n";
|
print "</tr>\n";
|
||||||
|
|
||||||
|
// Comptabilise le sous-total
|
||||||
|
$sous_total_debit += $line->debit;
|
||||||
|
$sous_total_credit += $line->credit;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
print '<tr class="liste_total">';
|
print '<tr class="liste_total"><td align="right" colspan="2">'.$langs->trans("SubTotal") . ':</td><td class="nowrap" align="right">'.price($sous_total_debit).'</td><td class="nowrap" align="right">'.price($sous_total_credit).'</td><td class="nowrap" align="right">'.price($sous_total_credit-$sous_total_debit).'</td>';
|
||||||
print '<td></td>';
|
print "<td> </td>\n";
|
||||||
print '<td></td>';
|
print '</tr>';
|
||||||
print '<td align="right">';
|
|
||||||
print price($total_debit);
|
print '<tr class="liste_total"><td align="right" colspan="2">'.$langs->trans("AccountBalance") . ':</td><td class="nowrap" align="right">'.price($total_debit).'</td><td class="nowrap" align="right">'.price($total_credit).'</td><td class="nowrap" align="right">'.price($total_credit-$total_debit).'</td>';
|
||||||
print '</td>';
|
print "<td> </td>\n";
|
||||||
print '<td align="right">';
|
print '</tr>';
|
||||||
print price($total_credit);
|
|
||||||
print '</td>';
|
|
||||||
print '<td align="right">' . price($total_credit - $total_debit) . '</td>';
|
|
||||||
print '<td align="right"></td>';
|
|
||||||
print '</tr>';
|
|
||||||
|
|
||||||
print "</table>";
|
print "</table>";
|
||||||
print '</form>';
|
print '</form>';
|
||||||
|
|||||||
@ -258,7 +258,6 @@ if ($action == 'export_csv') {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
$title_page = $langs->trans("Bookkeeping") . ' ' . dol_print_date($search_date_start) . '-' . dol_print_date($search_date_end);
|
$title_page = $langs->trans("Bookkeeping") . ' ' . dol_print_date($search_date_start) . '-' . dol_print_date($search_date_end);
|
||||||
|
|
||||||
llxHeader('', $title_page);
|
llxHeader('', $title_page);
|
||||||
|
|
||||||
// List
|
// List
|
||||||
@ -315,6 +314,7 @@ print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $options, $sortfield
|
|||||||
|
|
||||||
print '<form method="GET" id="searchFormList" action="' . $_SERVER["PHP_SELF"] . '">';
|
print '<form method="GET" id="searchFormList" action="' . $_SERVER["PHP_SELF"] . '">';
|
||||||
print '<div class="tabsAction">' . "\n";
|
print '<div class="tabsAction">' . "\n";
|
||||||
|
print '<div class="inline-block divButAction"><a class="butAction" href="./listbyaccount.php">' . $langs->trans("Bookkeeping") . ' ' . strtolower($langs->trans("By")) . ' ' . strtolower($langs->trans("AccountAccounting")) . '</a></div>';
|
||||||
print '<div class="inline-block divButAction"><input type="submit" name="button_delmvt" class="butAction" value="' . $langs->trans("DelBookKeeping") . '" /></div>';
|
print '<div class="inline-block divButAction"><input type="submit" name="button_delmvt" class="butAction" value="' . $langs->trans("DelBookKeeping") . '" /></div>';
|
||||||
print '<div class="inline-block divButAction"><a class="butAction" href="./card.php?action=create">' . $langs->trans("NewAccountingMvt") . '</a></div>';
|
print '<div class="inline-block divButAction"><a class="butAction" href="./card.php?action=create">' . $langs->trans("NewAccountingMvt") . '</a></div>';
|
||||||
print '<div class="inline-block divButAction"><input type="submit" name="button_export_csv" class="butAction" value="' . $langs->trans("Export") . '" /></div>';
|
print '<div class="inline-block divButAction"><input type="submit" name="button_export_csv" class="butAction" value="' . $langs->trans("Export") . '" /></div>';
|
||||||
|
|||||||
348
htdocs/accountancy/bookkeeping/listbyaccount.php
Normal file
348
htdocs/accountancy/bookkeeping/listbyaccount.php
Normal file
@ -0,0 +1,348 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* 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 Florian Henry <florian.henry@open-concept.pro>
|
||||||
|
* - Copyright (C) 2013-2016 Alexandre Spangaro <aspangaro.dolibarr@gmail.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/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \file htdocs/accountancy/bookkeeping/listbyaccount.php
|
||||||
|
* \ingroup Advanced accountancy
|
||||||
|
* \brief List operation of book keeping ordered by account number
|
||||||
|
*/
|
||||||
|
|
||||||
|
require '../../main.inc.php';
|
||||||
|
|
||||||
|
// Class
|
||||||
|
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
|
||||||
|
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php';
|
||||||
|
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php';
|
||||||
|
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php';
|
||||||
|
|
||||||
|
// Langs
|
||||||
|
$langs->load("accountancy");
|
||||||
|
|
||||||
|
$page = GETPOST("page");
|
||||||
|
$sortorder = GETPOST("sortorder");
|
||||||
|
$sortfield = GETPOST("sortfield");
|
||||||
|
$action = GETPOST('action', 'alpha');
|
||||||
|
$search_date_start = dol_mktime(0, 0, 0, GETPOST('date_startmonth', 'int'), GETPOST('date_startday', 'int'), GETPOST('date_startyear', 'int'));
|
||||||
|
$search_date_end = dol_mktime(0, 0, 0, GETPOST('date_endmonth', 'int'), GETPOST('date_endday', 'int'), GETPOST('date_endyear', 'int'));
|
||||||
|
$search_doc_date = dol_mktime(0, 0, 0, GETPOST('doc_datemonth', 'int'), GETPOST('doc_dateday', 'int'), GETPOST('doc_dateyear', 'int'));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$search_accountancy_code = GETPOST("search_accountancy_code");
|
||||||
|
|
||||||
|
$search_accountancy_code_start = GETPOST('search_accountancy_code_start', 'alpha');
|
||||||
|
if ($search_accountancy_code_start == - 1) {
|
||||||
|
$search_accountancy_code_start = '';
|
||||||
|
}
|
||||||
|
$search_label_account = GETPOST('search_label_account', 'alpha');
|
||||||
|
|
||||||
|
$search_mvt_label = GETPOST('search_mvt_label', 'alpha');
|
||||||
|
$search_direction = GETPOST('search_direction', 'alpha');
|
||||||
|
$search_ledger_code = GETPOST('search_ledger_code', 'alpha');
|
||||||
|
|
||||||
|
$limit = GETPOST('limit') ? GETPOST('limit', 'int') : $conf->liste_limit;
|
||||||
|
if ($page == -1) { $page = 0 ; }
|
||||||
|
$offset = $limit * $page ;
|
||||||
|
$pageprev = $page - 1;
|
||||||
|
$pagenext = $page + 1;
|
||||||
|
|
||||||
|
$object = new BookKeeping($db);
|
||||||
|
|
||||||
|
$formventilation = new FormVentilation($db);
|
||||||
|
$formother = new FormOther($db);
|
||||||
|
$form = new Form($db);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (empty($search_date_start)) {
|
||||||
|
$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'));
|
||||||
|
}
|
||||||
|
if ($sortorder == "")
|
||||||
|
$sortorder = "ASC";
|
||||||
|
if ($sortfield == "")
|
||||||
|
$sortfield = "t.rowid";
|
||||||
|
|
||||||
|
|
||||||
|
$options = '';
|
||||||
|
$filter = array ();
|
||||||
|
|
||||||
|
if (! empty($search_date_start)) {
|
||||||
|
$filter['t.doc_date>='] = $search_date_start;
|
||||||
|
$options .= '&date_startmonth=' . GETPOST('date_startmonth', 'int') . '&date_startday=' . GETPOST('date_startday', 'int') . '&date_startyear=' . GETPOST('date_startyear', 'int');
|
||||||
|
}
|
||||||
|
if (! empty($search_date_end)) {
|
||||||
|
$filter['t.doc_date<='] = $search_date_end;
|
||||||
|
$options .= '&date_endmonth=' . GETPOST('date_endmonth', 'int') . '&date_endday=' . GETPOST('date_endday', 'int') . '&date_endyear=' . GETPOST('date_endyear', 'int');
|
||||||
|
}
|
||||||
|
if (! empty($search_doc_date)) {
|
||||||
|
$filter['t.doc_date'] = $search_doc_date;
|
||||||
|
$options .= '&doc_datemonth=' . GETPOST('doc_datemonth', 'int') . '&doc_dateday=' . GETPOST('doc_dateday', 'int') . '&doc_dateyear=' . GETPOST('doc_dateyear', 'int');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (!GETPOST("button_removefilter_x") && !GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers
|
||||||
|
{
|
||||||
|
if (! empty($search_accountancy_code_start)) {
|
||||||
|
$filter['t.numero_compte'] = $search_accountancy_code_start;
|
||||||
|
$options .= '&search_accountancy_code_start=' . $search_accountancy_code_start;
|
||||||
|
}
|
||||||
|
if (! empty($search_label_account)) {
|
||||||
|
$filter['t.label_compte'] = $search_label_account;
|
||||||
|
$options .= '&search_label_account=' . $search_label_account;
|
||||||
|
}
|
||||||
|
if (! empty($search_mvt_label)) {
|
||||||
|
$filter['t.label_compte'] = $search_mvt_label;
|
||||||
|
$options .= '&search_mvt_label=' . $search_mvt_label;
|
||||||
|
}
|
||||||
|
if (! empty($search_direction)) {
|
||||||
|
$filter['t.sens'] = $search_direction;
|
||||||
|
$options .= '&search_direction=' . $search_direction;
|
||||||
|
}
|
||||||
|
if (! empty($search_ledger_code)) {
|
||||||
|
$filter['t.code_journal'] = $search_ledger_code;
|
||||||
|
$options .= '&search_ledger_code=' . $search_ledger_code;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Action
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers
|
||||||
|
{
|
||||||
|
$search_doc_date = '';
|
||||||
|
$search_accountancy_code = '';
|
||||||
|
$search_accountancy_code_start = '';
|
||||||
|
$search_label_account = '';
|
||||||
|
$search_mvt_label = '';
|
||||||
|
$search_direction = '';
|
||||||
|
$search_ledger_code = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($action == 'delmouvconfirm') {
|
||||||
|
|
||||||
|
$mvt_num = GETPOST('mvt_num', 'int');
|
||||||
|
|
||||||
|
if (! empty($mvt_num)) {
|
||||||
|
$result = $object->deleteMvtNum($mvt_num);
|
||||||
|
if ($result < 0) {
|
||||||
|
setEventMessages($object->error, $object->errors, 'errors');
|
||||||
|
}
|
||||||
|
Header("Location: listbyaccount.php");
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* View
|
||||||
|
*/
|
||||||
|
|
||||||
|
$title_page = $langs->trans("Bookkeeping") . ' ' . strtolower($langs->trans("By")) . ' ' . $langs->trans("AccountAccounting") . ' ' . dol_print_date($search_date_start) . '-' . dol_print_date($search_date_end);
|
||||||
|
|
||||||
|
llxHeader('', $title_page);
|
||||||
|
|
||||||
|
// List
|
||||||
|
|
||||||
|
$nbtotalofrecords = 0;
|
||||||
|
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
|
||||||
|
$nbtotalofrecords = $object->fetchAllByAccount($sortorder, $sortfield, 0, 0, $filter);
|
||||||
|
if ($nbtotalofrecords < 0) {
|
||||||
|
setEventMessages($object->error, $object->errors, 'errors');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$result = $object->fetchAllByAccount($sortorder, $sortfield, $limit, $offset, $filter);
|
||||||
|
if ($result < 0) {
|
||||||
|
setEventMessages($object->error, $object->errors, 'errors');
|
||||||
|
}
|
||||||
|
$nbtotalofrecords = $result;
|
||||||
|
|
||||||
|
if ($action == 'delmouv') {
|
||||||
|
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?mvt_num=' . GETPOST('mvt_num'), $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvt'), 'delmouvconfirm', '', 0, 1);
|
||||||
|
print $formconfirm;
|
||||||
|
}
|
||||||
|
if ($action == 'delbookkeepingyear') {
|
||||||
|
|
||||||
|
$form_question = array ();
|
||||||
|
$delyear = GETPOST('delyear');
|
||||||
|
|
||||||
|
if (empty($delyear)) {
|
||||||
|
$delyear = dol_print_date(dol_now(), '%Y');
|
||||||
|
}
|
||||||
|
$year_array = $formventilation->selectyear_accountancy_bookkepping($delyear, 'delyear', 0, 'array');
|
||||||
|
|
||||||
|
$form_question['delyear'] = array (
|
||||||
|
'name' => 'delyear',
|
||||||
|
'type' => 'select',
|
||||||
|
'label' => $langs->trans('DelYear'),
|
||||||
|
'values' => $year_array,
|
||||||
|
'default' => $delyear
|
||||||
|
);
|
||||||
|
|
||||||
|
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvt'), 'delbookkeepingyearconfirm', $form_question, 0, 1);
|
||||||
|
print $formconfirm;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
print '<form method="GET" id="searchFormList" action="' . $_SERVER["PHP_SELF"] . '">';
|
||||||
|
|
||||||
|
print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $options, $sortfield, $sortorder, '', $result, $nbtotalofrecords,'',0,'','',$limit);
|
||||||
|
|
||||||
|
// Reverse sort order
|
||||||
|
if ( preg_match('/^asc/i', $sortorder) )
|
||||||
|
$sortorder = "asc";
|
||||||
|
else
|
||||||
|
$sortorder = "desc";
|
||||||
|
|
||||||
|
print '<div class="tabsAction">' . "\n";
|
||||||
|
print '<div class="inline-block divButAction"><a class="butAction" href="./card.php?action=create">' . $langs->trans("NewAccountingMvt") . '</a></div>';
|
||||||
|
print '</div>';
|
||||||
|
|
||||||
|
print '<table class="noborder" width="100%">';
|
||||||
|
print '<tr class="liste_titre">';
|
||||||
|
print '<td>' . $langs->trans("AccountAccounting") . '</td>';
|
||||||
|
print_liste_field_titre($langs->trans("Docdate"), $_SERVER['PHP_SELF'], "t.doc_date", "", $options, "", $sortfield, $sortorder);
|
||||||
|
print_liste_field_titre($langs->trans("Docref"), $_SERVER['PHP_SELF'], "t.doc_ref", "", $options, "", $sortfield, $sortorder);
|
||||||
|
print '<td>' . $langs->trans("SuppliersInvoices") . ' / ' . $langs->trans("CustomersInvoices") . '</td>';
|
||||||
|
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("Codejournal"), $_SERVER['PHP_SELF'], "t.code_journal", "", $options, 'align="center"', $sortfield, $sortorder);
|
||||||
|
print_liste_field_titre($langs->trans("Action"), $_SERVER["PHP_SELF"], "", $options, "", 'width="60" align="center"', $sortfield, $sortorder);
|
||||||
|
print "</tr>\n";
|
||||||
|
|
||||||
|
print '<tr class="liste_titre">';
|
||||||
|
print '<form action="' . $_SERVER["PHP_SELF"] . '" method="GET">';
|
||||||
|
print '<td width >' . $object->select_account($search_accountancy_code_start, 'search_accountancy_code_start', 1, array (), 1, 1, '') . '</td>';
|
||||||
|
print '<td class="liste_titre">';
|
||||||
|
print $langs->trans('From') . ': ';
|
||||||
|
print $form->select_date($search_date_start, 'date_start', 0, 0, 1);
|
||||||
|
print '<br>';
|
||||||
|
print $langs->trans('to') . ': ';
|
||||||
|
print $form->select_date($search_date_end, 'date_end', 0, 0, 1);
|
||||||
|
print '</td>';
|
||||||
|
print '<td class="liste_titre"><input type="text" size="7" class="flat" name="search_mvt_label" value="' . $search_mvt_label . '"/></td>';
|
||||||
|
print '<td class="liste_titre"><input type="text" size="7" class="flat" name="search_label_account" value="' . $search_label_account . '"/></td>';
|
||||||
|
print '<td> </td>';
|
||||||
|
print '<td> </td>';
|
||||||
|
print '<td align="right"><input type="text" name="search_ledger_code" size="3" value="' . $search_ledger_code . '"></td>';
|
||||||
|
print '<td align="right" colspan="2" class="liste_titre">';
|
||||||
|
$searchpitco=$form->showFilterAndCheckAddButtons(0);
|
||||||
|
print $searchpitco;
|
||||||
|
print '</td>';
|
||||||
|
|
||||||
|
print '</tr>';
|
||||||
|
|
||||||
|
$var = True;
|
||||||
|
|
||||||
|
$total_debit = 0;
|
||||||
|
$total_credit = 0;
|
||||||
|
$sous_total_debit = 0;
|
||||||
|
$sous_total_credit = 0;
|
||||||
|
$displayed_account_number = "";
|
||||||
|
|
||||||
|
foreach ( $object->lines as $line ) {
|
||||||
|
$var = ! $var;
|
||||||
|
|
||||||
|
$total_debit += $line->debit;
|
||||||
|
$total_credit += $line->credit;
|
||||||
|
|
||||||
|
// Permet d'afficher le compte comptable
|
||||||
|
if (length_accountg($line->numero_compte) != $displayed_account_number) {
|
||||||
|
|
||||||
|
// Affiche un Sous-Total par compte comptable
|
||||||
|
if ($displayed_account_number != "") {
|
||||||
|
print '<tr class="liste_total"><td align="right" colspan="4">'.$langs->trans("SubTotal").':</td><td class="nowrap" align="right">'.price($sous_total_debit).'</td><td class="nowrap" align="right">'.price($sous_total_credit).'</td>';
|
||||||
|
print "<td> </td>\n";
|
||||||
|
print '</tr>';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Affiche le compte comptable en début de ligne
|
||||||
|
print "<tr>";
|
||||||
|
print '<td colspan="7" style="font-weight:bold; border-bottom: 1pt solid black;">'.length_accountg($line->numero_compte) . ' : ' . $object->get_compte_desc($line->numero_compte).'</td>';
|
||||||
|
print '</tr>';
|
||||||
|
|
||||||
|
$displayed_account_number = length_accountg($line->numero_compte);
|
||||||
|
$sous_total_debit = 0;
|
||||||
|
$sous_total_credit = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
print '<tr'. $bc[$var].'>';
|
||||||
|
print '<td> </td>';
|
||||||
|
print '<td align="center">' . dol_print_date($line->doc_date, 'day') . '</td>';
|
||||||
|
print '<td><a href="./card.php?piece_num=' . $line->piece_num . '">' . $line->doc_ref . '</a></td>';
|
||||||
|
|
||||||
|
// Affiche un lien vers la facture client/fournisseur
|
||||||
|
$doc_ref = preg_replace('/\(.*\)/', '', $line->doc_ref);
|
||||||
|
if ($line->doc_type == 'supplier_invoice')
|
||||||
|
print strlen(length_accounta($line->code_tiers)) == 0 ? '<td><a href="/fourn/facture/list.php?search_ref_supplier=' . $doc_ref . '">' . $line->label_compte . '</a></td>' : '<td><a href="/fourn/facture/list.php?search_ref_supplier=' . $doc_ref . '">' . $line->label_compte . '</a><br /><span style="font-size:0.8em">(' . length_accounta($line->code_tiers) . ')</span></td>';
|
||||||
|
elseif ($line->doc_type == 'customer_invoice')
|
||||||
|
print strlen(length_accounta($line->code_tiers)) == 0 ? '<td><a href="/compta/facture/list.php?search_ref=' . $doc_ref . '">' . $line->label_compte . '</a></td>' : '<td><a href="/compta/facture/list.php?search_ref=' . $doc_ref . '">' . $line->label_compte . '</a><br /><span style="font-size:0.8em">(' . length_accounta($line->code_tiers) . ')</span></td>';
|
||||||
|
else
|
||||||
|
print strlen(length_accounta($line->code_tiers)) == 0 ? '<td>' . $line->label_compte . '</td>' : '<td>' . $line->label_compte . '<br /><span style="font-size:0.8em">(' . length_accounta($line->code_tiers) . ')</span></td>';
|
||||||
|
|
||||||
|
|
||||||
|
print '<td align="right">' . price($line->debit) . '</td>';
|
||||||
|
print '<td align="right">' . price($line->credit) . '</td>';
|
||||||
|
print '<td align="center">' . $line->code_journal . '</td>';
|
||||||
|
print '<td align="center">';
|
||||||
|
print '<a href="./card.php?piece_num=' . $line->piece_num . '">' . img_edit() . '</a> ';
|
||||||
|
print '<a href="' . $_SERVER['PHP_SELF'] . '?action=delmouv&mvt_num=' . $line->piece_num . $options . '&page=' . $page . '">' . img_delete() . '</a>';
|
||||||
|
print '</td>';
|
||||||
|
print "</tr>\n";
|
||||||
|
|
||||||
|
// Comptabilise le sous-total
|
||||||
|
$sous_total_debit += $line->debit;
|
||||||
|
$sous_total_credit += $line->credit;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Affiche un Sous-Total du dernier compte comptable affiché
|
||||||
|
print '<tr class="liste_total"><td align="right" colspan="4">'.$langs->trans("SubTotal").':</td><td class="nowrap" align="right">'.price($sous_total_debit).'</td><td class="nowrap" align="right">'.price($sous_total_credit).'</td>';
|
||||||
|
print "<td> </td>\n";
|
||||||
|
print '</tr>';
|
||||||
|
|
||||||
|
|
||||||
|
// Affiche le Total
|
||||||
|
print '<tr class="liste_total">';
|
||||||
|
print '<td align="right" colspan="4">'.$langs->trans("Total").':</td>';
|
||||||
|
print '<td align="right">';
|
||||||
|
print price($total_debit);
|
||||||
|
print '</td>';
|
||||||
|
print '<td align="right">';
|
||||||
|
print price($total_credit);
|
||||||
|
print '</td>';
|
||||||
|
print '<td colspan="2"></td>';
|
||||||
|
print '</tr>';
|
||||||
|
|
||||||
|
print "</table>";
|
||||||
|
print '</form>';
|
||||||
|
|
||||||
|
llxFooter();
|
||||||
|
|
||||||
|
|
||||||
|
$db->close();
|
||||||
@ -109,8 +109,6 @@ class BookKeeping extends CommonObject
|
|||||||
public function create(User $user, $notrigger = false) {
|
public function create(User $user, $notrigger = false) {
|
||||||
dol_syslog(__METHOD__, LOG_DEBUG);
|
dol_syslog(__METHOD__, LOG_DEBUG);
|
||||||
|
|
||||||
global $langs;
|
|
||||||
|
|
||||||
$error = 0;
|
$error = 0;
|
||||||
|
|
||||||
// Clean parameters
|
// Clean parameters
|
||||||
@ -168,11 +166,11 @@ class BookKeeping extends CommonObject
|
|||||||
// first check if line not yet in bookkeeping
|
// first check if line not yet in bookkeeping
|
||||||
$sql = "SELECT count(*) as nb";
|
$sql = "SELECT count(*) as nb";
|
||||||
$sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element;
|
$sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element;
|
||||||
$sql .= " WHERE doc_type = '" . $this->db->escape($this->doc_type) . "'";
|
$sql .= " WHERE doc_type = '" . $this->doc_type . "'";
|
||||||
$sql .= " AND fk_docdet = " . $this->fk_docdet;
|
$sql .= " AND fk_docdet = " . $this->fk_docdet;
|
||||||
$sql .= " AND numero_compte = '" . $this->db->escape($this->numero_compte) . "'";
|
$sql .= " AND numero_compte = '" . $this->numero_compte . "'";
|
||||||
|
|
||||||
dol_syslog(get_class($this) . ":: create ", LOG_DEBUG);
|
dol_syslog(get_class($this) . ":: create sql=" . $sql, LOG_DEBUG);
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
|
|
||||||
if ($resql) {
|
if ($resql) {
|
||||||
@ -204,12 +202,11 @@ class BookKeeping extends CommonObject
|
|||||||
$this->piece_num = $objnum->maxpiecenum;
|
$this->piece_num = $objnum->maxpiecenum;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
dol_syslog(get_class($this) . ":: create this->piece_num=" . $this->piece_num, LOG_DEBUG);
|
||||||
if (empty($this->piece_num)) {
|
if (empty($this->piece_num)) {
|
||||||
$this->piece_num = 1;
|
$this->piece_num = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
dol_syslog(get_class($this) . ":: create this->piece_num=" . $this->piece_num, LOG_DEBUG);
|
|
||||||
|
|
||||||
$now = dol_now();
|
$now = dol_now();
|
||||||
if (empty($this->date_create)) {
|
if (empty($this->date_create)) {
|
||||||
$this->date_create = $now;
|
$this->date_create = $now;
|
||||||
@ -236,26 +233,26 @@ class BookKeeping extends CommonObject
|
|||||||
|
|
||||||
$sql .= ") VALUES (";
|
$sql .= ") VALUES (";
|
||||||
|
|
||||||
$sql .= "'" . $this->db->idate($this->doc_date) . "'";
|
$sql .= "'" . $this->doc_date . "'";
|
||||||
$sql .= ",'" . $this->db->escape($this->doc_type) . "'";
|
$sql .= ",'" . $this->doc_type . "'";
|
||||||
$sql .= ",'" . $this->db->escape($this->doc_ref) . "'";
|
$sql .= ",'" . $this->doc_ref . "'";
|
||||||
$sql .= "," . $this->fk_doc;
|
$sql .= "," . $this->fk_doc;
|
||||||
$sql .= "," . $this->fk_docdet;
|
$sql .= "," . $this->fk_docdet;
|
||||||
$sql .= ",'" . $this->db->escape($this->code_tiers) . "'";
|
$sql .= ",'" . $this->code_tiers . "'";
|
||||||
$sql .= ",'" . $this->db->escape($this->numero_compte) . "'";
|
$sql .= ",'" . $this->numero_compte . "'";
|
||||||
$sql .= ",'" . $this->db->escape($this->label_compte) . "'";
|
$sql .= ",'" . $this->db->escape($this->label_compte) . "'";
|
||||||
$sql .= "," . $this->debit;
|
$sql .= "," . $this->debit;
|
||||||
$sql .= "," . $this->credit;
|
$sql .= "," . $this->credit;
|
||||||
$sql .= "," . $this->montant;
|
$sql .= "," . $this->montant;
|
||||||
$sql .= ",'" . $this->db->escape($this->sens) . "'";
|
$sql .= ",'" . $this->sens . "'";
|
||||||
$sql .= ",'" . $this->fk_user_author . "'";
|
$sql .= ",'" . $this->fk_user_author . "'";
|
||||||
$sql .= ",'" . $this->date_create . "'";
|
$sql .= ",'" . $this->date_create . "'";
|
||||||
$sql .= ",'" . $this->db->escape($this->code_journal) . "'";
|
$sql .= ",'" . $this->code_journal . "'";
|
||||||
$sql .= "," . $this->piece_num;
|
$sql .= "," . $this->piece_num;
|
||||||
|
|
||||||
$sql .= ")";
|
$sql .= ")";
|
||||||
|
|
||||||
dol_syslog(get_class($this) . ":: create", LOG_DEBUG);
|
dol_syslog(get_class($this) . ":: create sql=" . $sql, LOG_DEBUG);
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
if ($resql) {
|
if ($resql) {
|
||||||
$id = $this->db->last_insert_id(MAIN_DB_PREFIX . $this->table_element);
|
$id = $this->db->last_insert_id(MAIN_DB_PREFIX . $this->table_element);
|
||||||
@ -267,25 +264,25 @@ class BookKeeping extends CommonObject
|
|||||||
$result = - 2;
|
$result = - 2;
|
||||||
$error ++;
|
$error ++;
|
||||||
$this->errors[] = 'Error Create Error ' . $result . ' lecture ID';
|
$this->errors[] = 'Error Create Error ' . $result . ' lecture ID';
|
||||||
dol_syslog(__METHOD__ . ' $result='.$result.' ' . implode(',', $this->errors), LOG_ERR);
|
dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$result = - 1;
|
$result = - 1;
|
||||||
$error ++;
|
$error ++;
|
||||||
$this->errors[] = 'Error ' . $this->db->lasterror();
|
$this->errors[] = 'Error ' . $this->db->lasterror();
|
||||||
dol_syslog(__METHOD__ . ' $result='.$result.' ' . implode(',', $this->errors), LOG_ERR);
|
dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$result = - 3;
|
$result = - 3;
|
||||||
$error ++;
|
$error ++;
|
||||||
$this->errors[] = $langs->trans('BookeppingLineAlreayExists');
|
$this->errors[] = 'Error ' . $this->db->lasterror();
|
||||||
dol_syslog(__METHOD__ . ' $result='.$result.' ' . implode(',', $this->errors), LOG_ERR);
|
dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$result = - 5;
|
$result = - 5;
|
||||||
$error ++;
|
$error ++;
|
||||||
$this->errors[] = 'Error ' . $this->db->lasterror();
|
$this->errors[] = 'Error ' . $this->db->lasterror();
|
||||||
dol_syslog(__METHOD__ . ' $result='.$result.' '. implode(',', $this->errors), LOG_ERR);
|
dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! $error) {
|
if (! $error) {
|
||||||
@ -531,6 +528,118 @@ class BookKeeping extends CommonObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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
|
||||||
|
*/
|
||||||
|
public function fetchAllByAccount($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') {
|
||||||
|
dol_syslog(__METHOD__, LOG_DEBUG);
|
||||||
|
|
||||||
|
$sql = 'SELECT';
|
||||||
|
$sql .= ' t.rowid,';
|
||||||
|
|
||||||
|
$sql .= " t.doc_date,";
|
||||||
|
$sql .= " t.doc_type,";
|
||||||
|
$sql .= " t.doc_ref,";
|
||||||
|
$sql .= " t.fk_doc,";
|
||||||
|
$sql .= " t.fk_docdet,";
|
||||||
|
$sql .= " t.code_tiers,";
|
||||||
|
$sql .= " t.numero_compte,";
|
||||||
|
$sql .= " t.label_compte,";
|
||||||
|
$sql .= " t.debit,";
|
||||||
|
$sql .= " t.credit,";
|
||||||
|
$sql .= " t.montant,";
|
||||||
|
$sql .= " t.sens,";
|
||||||
|
$sql .= " t.fk_user_author,";
|
||||||
|
$sql .= " t.import_key,";
|
||||||
|
$sql .= " t.code_journal,";
|
||||||
|
$sql .= " t.piece_num";
|
||||||
|
|
||||||
|
$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.doc_date') {
|
||||||
|
$sqlwhere[] = $key . '=\'' . $this->db->idate($value) . '\'';
|
||||||
|
} elseif ($key == 't.doc_date>=' || $key == 't.doc_date<=') {
|
||||||
|
$sqlwhere[] = $key . '\'' . $this->db->idate($value) . '\'';
|
||||||
|
} elseif ($key == 't.numero_compte>=' || $key == 't.numero_compte<=' || $key == 't.code_tiers>=' || $key == 't.code_tiers<=') {
|
||||||
|
$sqlwhere[] = $key . '\'' . $this->db->escape($value) . '\'';
|
||||||
|
} elseif ($key == 't.fk_doc' || $key == 't.fk_docdet' || $key == 't.piece_num') {
|
||||||
|
$sqlwhere[] = $key . '=' . $value;
|
||||||
|
} elseif ($key == 't.code_tiers' || $key == 't.numero_compte') {
|
||||||
|
$sqlwhere[] = $key . ' LIKE \'' . $this->db->escape($value) . '%\'';
|
||||||
|
} elseif ($key == 't.label_compte') {
|
||||||
|
$sqlwhere[] = $key . ' LIKE \'' . $this->db->escape($value) . '%\'';
|
||||||
|
}else {
|
||||||
|
$sqlwhere[] = $key . ' LIKE \'%' . $this->db->escape($value) . '%\'';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count($sqlwhere) > 0) {
|
||||||
|
$sql .= ' WHERE ' . implode(' ' . $filtermode . ' ', $sqlwhere);
|
||||||
|
}
|
||||||
|
// Affichage par compte comptable
|
||||||
|
$sql .= ' ORDER BY t.numero_compte ASC';
|
||||||
|
if (! empty($sortfield)) {
|
||||||
|
$sql .= ', ' . $sortfield . ' ' .$sortorder;
|
||||||
|
}
|
||||||
|
if (! empty($limit)) {
|
||||||
|
$sql .= ' ' . $this->db->plimit($limit + 1, $offset);
|
||||||
|
}
|
||||||
|
$this->lines = array ();
|
||||||
|
|
||||||
|
$resql = $this->db->query($sql);
|
||||||
|
if ($resql) {
|
||||||
|
$num = $this->db->num_rows($resql);
|
||||||
|
|
||||||
|
while ( $obj = $this->db->fetch_object($resql) ) {
|
||||||
|
$line = new BookKeepingLine();
|
||||||
|
|
||||||
|
$line->id = $obj->rowid;
|
||||||
|
|
||||||
|
$line->doc_date = $this->db->jdate($obj->doc_date);
|
||||||
|
$line->doc_type = $obj->doc_type;
|
||||||
|
$line->doc_ref = $obj->doc_ref;
|
||||||
|
$line->fk_doc = $obj->fk_doc;
|
||||||
|
$line->fk_docdet = $obj->fk_docdet;
|
||||||
|
$line->code_tiers = $obj->code_tiers;
|
||||||
|
$line->numero_compte = $obj->numero_compte;
|
||||||
|
$line->label_compte = $obj->label_compte;
|
||||||
|
$line->debit = $obj->debit;
|
||||||
|
$line->credit = $obj->credit;
|
||||||
|
$line->montant = $obj->montant;
|
||||||
|
$line->sens = $obj->sens;
|
||||||
|
$line->fk_user_author = $obj->fk_user_author;
|
||||||
|
$line->import_key = $obj->import_key;
|
||||||
|
$line->code_journal = $obj->code_journal;
|
||||||
|
$line->piece_num = $obj->piece_num;
|
||||||
|
|
||||||
|
$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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load object in memory from the database
|
* Load object in memory from the database
|
||||||
*
|
*
|
||||||
@ -947,49 +1056,6 @@ class BookKeeping extends CommonObject
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Delete bookkepping by year
|
|
||||||
*
|
|
||||||
* @param string $delyear year to delete
|
|
||||||
* @param string $deljournal journal to delete
|
|
||||||
* @return int Result
|
|
||||||
*/
|
|
||||||
function deleteByYearAndJournal($delyear,$deljournal) {
|
|
||||||
$this->db->begin();
|
|
||||||
|
|
||||||
$sqlwhere=array();
|
|
||||||
|
|
||||||
// first check if line not yet in bookkeeping
|
|
||||||
$sql = "DELETE";
|
|
||||||
$sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element;
|
|
||||||
if (!empty($delyear)) {
|
|
||||||
$sqlwhere[] .= " YEAR(doc_date) = " . $delyear;
|
|
||||||
}
|
|
||||||
if (!empty($deljournal)) {
|
|
||||||
$sqlwhere[] .= " code_journal = '" . $this->db->escape($deljournal)."'";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (count($sqlwhere)>0) {
|
|
||||||
$sql.=" WHERE ".implode(' AND ', $sqlwhere);
|
|
||||||
|
|
||||||
$resql = $this->db->query($sql);
|
|
||||||
|
|
||||||
if (! $resql) {
|
|
||||||
$this->errors[] = "Error " . $this->db->lasterror();
|
|
||||||
foreach ( $this->errors as $errmsg ) {
|
|
||||||
dol_syslog(get_class($this) . "::delete " . $errmsg, LOG_ERR);
|
|
||||||
$this->error .= ($this->error ? ', ' . $errmsg : $errmsg);
|
|
||||||
}
|
|
||||||
$this->db->rollback();
|
|
||||||
return - 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->db->commit();
|
|
||||||
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete bookkepping by piece number
|
* Delete bookkepping by piece number
|
||||||
*
|
*
|
||||||
@ -1248,7 +1314,123 @@ class BookKeeping extends CommonObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return list of accounts with label by chart of accounts
|
||||||
|
*
|
||||||
|
* @param string $selectid Preselected chart of accounts
|
||||||
|
* @param string $htmlname Name of field in html form
|
||||||
|
* @param int $showempty Add an empty field
|
||||||
|
* @param array $event Event options
|
||||||
|
* @param int $select_in $selectid value is a aa.rowid (0 default) or aa.account_number (1)
|
||||||
|
* @param int $select_out set value returned by select 0=rowid (default), 1=account_number
|
||||||
|
* @param int $aabase set accounting_account base class to display empty=all or from 1 to 8 will display only account beginning by this number
|
||||||
|
*
|
||||||
|
* @return string String with HTML select
|
||||||
|
*/
|
||||||
|
function select_account($selectid, $htmlname = 'account', $showempty = 0, $event = array(), $select_in = 0, $select_out = 0, $aabase = '') {
|
||||||
|
global $conf;
|
||||||
|
|
||||||
|
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
|
||||||
|
|
||||||
|
$pcgver = $conf->global->CHARTOFACCOUNTS;
|
||||||
|
|
||||||
|
$sql = "SELECT DISTINCT ab.numero_compte as account_number, aa.label as label, aa.rowid as rowid, aa.fk_pcg_version";
|
||||||
|
$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 .= " ORDER BY account_number ASC";
|
||||||
|
|
||||||
|
dol_syslog(get_class($this) . "::select_account", LOG_DEBUG);
|
||||||
|
$resql = $this->db->query($sql);
|
||||||
|
|
||||||
|
if (!$resql) {
|
||||||
|
$this->error = "Error " . $this->db->lasterror();
|
||||||
|
dol_syslog(get_class($this) . "::select_account " . $this->error, LOG_ERR);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
$out = ajax_combobox($htmlname, $event);
|
||||||
|
|
||||||
|
$options = array();
|
||||||
|
$selected = null;
|
||||||
|
|
||||||
|
while ($obj = $this->db->fetch_object($resql)) {
|
||||||
|
$label = length_accountg($obj->account_number) . ' - ' . $obj->label;
|
||||||
|
$label = dol_trunc($label, $trunclength);
|
||||||
|
|
||||||
|
$select_value_in = $obj->rowid;
|
||||||
|
$select_value_out = $obj->rowid;
|
||||||
|
|
||||||
|
if ($select_in == 1) {
|
||||||
|
$select_value_in = $obj->account_number;
|
||||||
|
}
|
||||||
|
if ($select_out == 1) {
|
||||||
|
$select_value_out = $obj->account_number;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remember guy's we store in database llx_facturedet the rowid of accounting_account and not the account_number
|
||||||
|
// Because same account_number can be share between different accounting_system and do have the same meaning
|
||||||
|
if (($selectid != '') && $selectid == $select_value_in) {
|
||||||
|
$selected = $select_value_out;
|
||||||
|
}
|
||||||
|
|
||||||
|
$options[$select_value_out] = $label;
|
||||||
|
}
|
||||||
|
|
||||||
|
$out .= Form::selectarray($htmlname, $options, $selected, $showempty, 0, 0, '', 0, 0, 0, '', 'maxwidth300');
|
||||||
|
$this->db->free($resql);
|
||||||
|
return $out;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Description of a root accounting account
|
||||||
|
*
|
||||||
|
* @param string $account Accounting account
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function get_compte_racine($account = null)
|
||||||
|
{
|
||||||
|
global $conf;
|
||||||
|
$pcgver = $conf->global->CHARTOFACCOUNTS;
|
||||||
|
|
||||||
|
|
||||||
|
$sql = "SELECT root.account_number, root.label as label";
|
||||||
|
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as aa";
|
||||||
|
$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version";
|
||||||
|
$sql .= " AND asy.rowid = " . $pcgver;
|
||||||
|
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as parent ON aa.account_parent = parent.rowid";
|
||||||
|
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as root ON parent.account_parent = root.rowid";
|
||||||
|
$sql .= " WHERE aa.account_number = '" . $account . "'";
|
||||||
|
$sql .= " AND parent.active = 1";
|
||||||
|
$sql .= " AND root.active = 1";
|
||||||
|
|
||||||
|
|
||||||
|
dol_syslog(get_class($this) . "::select_account sql=" . $sql, LOG_DEBUG);
|
||||||
|
$resql = $this->db->query($sql);
|
||||||
|
if ($resql) {
|
||||||
|
$obj = '';
|
||||||
|
if ($this->db->num_rows($resql)) {
|
||||||
|
$obj = $this->db->fetch_object($resql);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $obj->label;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
$this->error = "Error " . $this->db->lasterror();
|
||||||
|
dol_syslog(__METHOD__ . " " . $this->error, LOG_ERR);
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
* Description of accounting account
|
* Description of accounting account
|
||||||
*
|
*
|
||||||
* @param string $account Accounting account
|
* @param string $account Accounting account
|
||||||
@ -1258,7 +1440,6 @@ class BookKeeping extends CommonObject
|
|||||||
{
|
{
|
||||||
global $conf;
|
global $conf;
|
||||||
$pcgver = $conf->global->CHARTOFACCOUNTS;
|
$pcgver = $conf->global->CHARTOFACCOUNTS;
|
||||||
|
|
||||||
$sql = "SELECT aa.account_number, aa.label, aa.rowid, aa.fk_pcg_version, cat.label as category";
|
$sql = "SELECT aa.account_number, aa.label, aa.rowid, aa.fk_pcg_version, cat.label as category";
|
||||||
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as aa ";
|
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as aa ";
|
||||||
$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";
|
||||||
@ -1266,7 +1447,6 @@ class BookKeeping extends CommonObject
|
|||||||
$sql .= " AND asy.rowid = " . $pcgver;
|
$sql .= " AND asy.rowid = " . $pcgver;
|
||||||
$sql .= " AND aa.active = 1";
|
$sql .= " AND aa.active = 1";
|
||||||
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_accounting_category as cat ON aa.fk_accounting_category = cat.rowid";
|
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_accounting_category as cat ON aa.fk_accounting_category = cat.rowid";
|
||||||
|
|
||||||
dol_syslog(get_class($this) . "::select_account sql=" . $sql, LOG_DEBUG);
|
dol_syslog(get_class($this) . "::select_account sql=" . $sql, LOG_DEBUG);
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
if ($resql) {
|
if ($resql) {
|
||||||
@ -1284,7 +1464,6 @@ class BookKeeping extends CommonObject
|
|||||||
} else {
|
} else {
|
||||||
$this->error = "Error " . $this->db->lasterror();
|
$this->error = "Error " . $this->db->lasterror();
|
||||||
dol_syslog(__METHOD__ . " " . $this->error, LOG_ERR);
|
dol_syslog(__METHOD__ . " " . $this->error, LOG_ERR);
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1971,6 +1971,11 @@ function getElementProperties($element_type)
|
|||||||
$module='resource';
|
$module='resource';
|
||||||
$subelement='dolresource';
|
$subelement='dolresource';
|
||||||
}
|
}
|
||||||
|
if ($element_type == 'propaldet') {
|
||||||
|
$classpath = 'comm/propal/class';
|
||||||
|
$module='propal';
|
||||||
|
$subelement='propaleligne';
|
||||||
|
}
|
||||||
$classfile = strtolower($subelement);
|
$classfile = strtolower($subelement);
|
||||||
$classname = ucfirst($subelement);
|
$classname = ucfirst($subelement);
|
||||||
|
|
||||||
|
|||||||
@ -369,7 +369,7 @@ if (! empty($force_install_message))
|
|||||||
|
|
||||||
<tr class="hidesqlite">
|
<tr class="hidesqlite">
|
||||||
<td valign="top" class="label"><?php echo $langs->trans("Port"); ?></td>
|
<td valign="top" class="label"><?php echo $langs->trans("Port"); ?></td>
|
||||||
<td valign="top" class="label"><input type="text"
|
<td valign="top" class="label"><input type="text" id="db_port"
|
||||||
name="db_port<?php print ($force_install_noedit==2 && $force_install_port)?'_bis':''; ?>"
|
name="db_port<?php print ($force_install_noedit==2 && $force_install_port)?'_bis':''; ?>"
|
||||||
<?php if ($force_install_noedit==2 && $force_install_port) print ' disabled'; ?>
|
<?php if ($force_install_noedit==2 && $force_install_port) print ' disabled'; ?>
|
||||||
value="<?php print (! empty($dolibarr_main_db_port))?$dolibarr_main_db_port:$force_install_port; ?>">
|
value="<?php print (! empty($dolibarr_main_db_port))?$dolibarr_main_db_port:$force_install_port; ?>">
|
||||||
@ -484,9 +484,27 @@ if (! empty($force_install_message))
|
|||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
jQuery(document).ready(function() {
|
jQuery(document).ready(function() {
|
||||||
|
|
||||||
jQuery("#db_type").change(function() {
|
var dbtype = jQuery("#db_type");
|
||||||
if (jQuery("#db_type").val()=='sqlite' || jQuery("#db_type").val()=='sqlite3') { jQuery(".hidesqlite").hide(); }
|
|
||||||
else { jQuery(".hidesqlite").show(); }
|
dbtype.change(function () {
|
||||||
|
if (dbtype.val() == 'sqlite' || dbtype.val() == 'sqlite3') {
|
||||||
|
jQuery(".hidesqlite").hide();
|
||||||
|
} else {
|
||||||
|
jQuery(".hidesqlite").show();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Automatically set default database ports and admin user
|
||||||
|
if (dbtype.val() == 'mysql' || dbtype.val() == 'mysqli') {
|
||||||
|
jQuery("#db_port").val(3306);
|
||||||
|
jQuery("#db_user_root").val('root');
|
||||||
|
} else if (dbtype.val() == 'pgsql') {
|
||||||
|
jQuery("#db_port").val(5432);
|
||||||
|
jQuery("#db_user_root").val('postgres');
|
||||||
|
} else if (dbtype.val() == 'mssql') {
|
||||||
|
jQuery("#db_port").val(1433);
|
||||||
|
jQuery("#db_user_root").val('sa');
|
||||||
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
function init_needroot()
|
function init_needroot()
|
||||||
|
|||||||
@ -95,6 +95,8 @@ if ($user->societe_id > 0) $socid=$user->societe_id;
|
|||||||
$result = restrictedArea($user, 'projet', $projectid, 'projet&project');
|
$result = restrictedArea($user, 'projet', $projectid, 'projet&project');
|
||||||
|
|
||||||
|
|
||||||
|
$hookmanager->initHooks(array('projectOverview'));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* View
|
* View
|
||||||
*/
|
*/
|
||||||
@ -350,6 +352,15 @@ $listofreferent=array(
|
|||||||
'test'=>$conf->projet->enabled && $user->rights->projet->lire && $conf->salaries->enabled && empty($conf->global->PROJECT_HIDE_TASKS)),
|
'test'=>$conf->projet->enabled && $user->rights->projet->lire && $conf->salaries->enabled && empty($conf->global->PROJECT_HIDE_TASKS)),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$parameters=array('listofreferent'=>$listofreferent);
|
||||||
|
$resHook = $hookmanager->executeHooks('completeListOfReferent',$parameters,$object,$action);
|
||||||
|
|
||||||
|
if(!empty($hookmanager->resArray)) {
|
||||||
|
|
||||||
|
$listofreferent = array_merge($listofreferent, $hookmanager->resArray);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
if ($action=="addelement")
|
if ($action=="addelement")
|
||||||
{
|
{
|
||||||
$tablename = GETPOST("tablename");
|
$tablename = GETPOST("tablename");
|
||||||
@ -438,6 +449,7 @@ foreach ($listofreferent as $key => $value)
|
|||||||
$element = new $classname($db);
|
$element = new $classname($db);
|
||||||
|
|
||||||
$elementarray = $object->get_element_list($key, $tablename, $datefieldname, $dates, $datee);
|
$elementarray = $object->get_element_list($key, $tablename, $datefieldname, $dates, $datee);
|
||||||
|
|
||||||
if (count($elementarray)>0 && is_array($elementarray))
|
if (count($elementarray)>0 && is_array($elementarray))
|
||||||
{
|
{
|
||||||
$total_ht = 0;
|
$total_ht = 0;
|
||||||
@ -453,7 +465,7 @@ foreach ($listofreferent as $key => $value)
|
|||||||
$element->fetch($idofelement);
|
$element->fetch($idofelement);
|
||||||
if ($idofelementuser) $elementuser->fetch($idofelementuser);
|
if ($idofelementuser) $elementuser->fetch($idofelementuser);
|
||||||
|
|
||||||
if ($tablename != 'expensereport_det') $element->fetch_thirdparty();
|
if ($tablename != 'expensereport_det' && method_exists($element, 'fetch_thirdparty')) $element->fetch_thirdparty();
|
||||||
|
|
||||||
if ($tablename == 'don') $total_ht_by_line=$element->amount;
|
if ($tablename == 'don') $total_ht_by_line=$element->amount;
|
||||||
elseif ($tablename == 'projet_task')
|
elseif ($tablename == 'projet_task')
|
||||||
@ -679,7 +691,7 @@ foreach ($listofreferent as $key => $value)
|
|||||||
|
|
||||||
if ($tablename != 'expensereport_det')
|
if ($tablename != 'expensereport_det')
|
||||||
{
|
{
|
||||||
$element->fetch_thirdparty();
|
if(method_exists($element, 'fetch_thirdparty')) $element->fetch_thirdparty();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@ -54,7 +54,8 @@ class WebservicesInvoicesTest extends PHPUnit_Framework_TestCase
|
|||||||
protected $savlangs;
|
protected $savlangs;
|
||||||
protected $savdb;
|
protected $savdb;
|
||||||
protected $soapclient;
|
protected $soapclient;
|
||||||
protected $socid;
|
|
||||||
|
private static $socid;
|
||||||
|
|
||||||
protected $ns = 'http://www.dolibarr.org/ns/';
|
protected $ns = 'http://www.dolibarr.org/ns/';
|
||||||
|
|
||||||
@ -72,10 +73,9 @@ class WebservicesInvoicesTest extends PHPUnit_Framework_TestCase
|
|||||||
$this->savuser=$user;
|
$this->savuser=$user;
|
||||||
$this->savlangs=$langs;
|
$this->savlangs=$langs;
|
||||||
$this->savdb=$db;
|
$this->savdb=$db;
|
||||||
$WS_DOL_URL = DOL_MAIN_URL_ROOT.'/webservices/server_invoice.php';
|
|
||||||
|
|
||||||
|
|
||||||
// Set the WebService URL
|
// Set the WebService URL
|
||||||
|
$WS_DOL_URL = DOL_MAIN_URL_ROOT.'/webservices/server_invoice.php';
|
||||||
print __METHOD__." create nusoap_client for URL=".$WS_DOL_URL."\n";
|
print __METHOD__." create nusoap_client for URL=".$WS_DOL_URL."\n";
|
||||||
$this->soapclient = new nusoap_client($WS_DOL_URL);
|
$this->soapclient = new nusoap_client($WS_DOL_URL);
|
||||||
if ($this->soapclient)
|
if ($this->soapclient)
|
||||||
@ -84,7 +84,28 @@ class WebservicesInvoicesTest extends PHPUnit_Framework_TestCase
|
|||||||
$this->soapclient->decodeUTF8(false);
|
$this->soapclient->decodeUTF8(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// create third_parties, needed to test an invoice
|
print __METHOD__." db->type=".$db->type." user->id=".$user->id;
|
||||||
|
//print " - db ".$db->db;
|
||||||
|
print "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function setUpBeforeClass()
|
||||||
|
{
|
||||||
|
global $conf,$user,$langs,$db;
|
||||||
|
|
||||||
|
// create a third_party, needed to create an invoice
|
||||||
|
//
|
||||||
|
// The third party is created in setUpBeforeClass() and not in the
|
||||||
|
// constructor to avoid creating several objects (the constructor is
|
||||||
|
// called for each test).
|
||||||
|
//
|
||||||
|
// The third party must be created before beginning the DB transaction
|
||||||
|
// because there is a foreign key constraint between invoices and third
|
||||||
|
// parties (tables: lx_facture and llx_societe) and with MySQL,
|
||||||
|
// constraints are checked immediately, they are not deferred to
|
||||||
|
// transaction commit. So if the invoice is created in the same
|
||||||
|
// transaction than the third party, the FK constraint fails.
|
||||||
|
// See this post for more detail: http://stackoverflow.com/a/5014744/5187108
|
||||||
$societe=new Societe($db);
|
$societe=new Societe($db);
|
||||||
$societe->ref='';
|
$societe->ref='';
|
||||||
$societe->name='name';
|
$societe->name='name';
|
||||||
@ -98,23 +119,14 @@ class WebservicesInvoicesTest extends PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
$societe->create($user);
|
$societe->create($user);
|
||||||
|
|
||||||
$this->socid = $societe->id;
|
self::$socid = $societe->id;
|
||||||
|
|
||||||
print __METHOD__." societe created id=".$societe->id."\n";
|
print __METHOD__." societe created id=".$societe->id."\n";
|
||||||
|
|
||||||
print __METHOD__." db->type=".$db->type." user->id=".$user->id;
|
|
||||||
//print " - db ".$db->db;
|
|
||||||
print "\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
// Static methods
|
|
||||||
public static function setUpBeforeClass()
|
|
||||||
{
|
|
||||||
global $conf,$user,$langs,$db;
|
|
||||||
$db->begin(); // This is to have all actions inside a transaction even if test launched without suite.
|
$db->begin(); // This is to have all actions inside a transaction even if test launched without suite.
|
||||||
|
|
||||||
print __METHOD__."\n";
|
print __METHOD__."\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function tearDownAfterClass()
|
public static function tearDownAfterClass()
|
||||||
{
|
{
|
||||||
global $conf,$user,$langs,$db;
|
global $conf,$user,$langs,$db;
|
||||||
@ -137,7 +149,6 @@ class WebservicesInvoicesTest extends PHPUnit_Framework_TestCase
|
|||||||
$db=$this->savdb;
|
$db=$this->savdb;
|
||||||
|
|
||||||
print __METHOD__."\n";
|
print __METHOD__."\n";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -166,17 +177,11 @@ class WebservicesInvoicesTest extends PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
$WS_METHOD = 'createInvoice';
|
$WS_METHOD = 'createInvoice';
|
||||||
|
|
||||||
// load societe first
|
|
||||||
/*$societe=new Societe($db);
|
|
||||||
$societe->fetch('', '', 'ref-phpunit');
|
|
||||||
print __METHOD__." societe loaded id=".$societe->id."\n";
|
|
||||||
*/
|
|
||||||
|
|
||||||
$body = array (
|
$body = array (
|
||||||
"id" => NULL,
|
"id" => NULL,
|
||||||
"ref" => NULL,
|
"ref" => NULL,
|
||||||
"ref_ext" => "ref-phpunit-2",
|
"ref_ext" => "ref-phpunit-2",
|
||||||
"thirdparty_id" => $this->socid,
|
"thirdparty_id" => self::$socid,
|
||||||
"fk_user_author" => NULL,
|
"fk_user_author" => NULL,
|
||||||
"fk_user_valid" => NULL,
|
"fk_user_valid" => NULL,
|
||||||
"date" => "2015-04-19 20:16:53",
|
"date" => "2015-04-19 20:16:53",
|
||||||
@ -333,7 +338,7 @@ class WebservicesInvoicesTest extends PHPUnit_Framework_TestCase
|
|||||||
"id" => NULL,
|
"id" => NULL,
|
||||||
"ref" => NULL,
|
"ref" => NULL,
|
||||||
"ref_ext" => "ref-phpunit-2",
|
"ref_ext" => "ref-phpunit-2",
|
||||||
"thirdparty_id" => $this->socid,
|
"thirdparty_id" => self::$socid,
|
||||||
"fk_user_author" => NULL,
|
"fk_user_author" => NULL,
|
||||||
"fk_user_valid" => NULL,
|
"fk_user_valid" => NULL,
|
||||||
"date" => "2015-04-19 20:16:53",
|
"date" => "2015-04-19 20:16:53",
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user