Merge pull request #7044 from aspangaro/6.0-fec3

Fix : Accountancy - Debug
This commit is contained in:
Laurent Destailleur
2017-06-20 01:18:45 +02:00
committed by GitHub
5 changed files with 136 additions and 71 deletions

View File

@@ -31,6 +31,7 @@ require '../../main.inc.php';
// Class // Class
require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
$langs->load("compta"); $langs->load("compta");
$langs->load("bills"); $langs->load("bills");

View File

@@ -1,7 +1,7 @@
<?php <?php
/* Copyright (C) 2013-2017 Olivier Geffroy <jeff@jeffinfo.com> /* Copyright (C) 2013-2017 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2017 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.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
@@ -40,16 +40,19 @@ if ($user->societe_id > 0) {
$action = GETPOST('action'); $action = GETPOST('action');
$mode = GETPOST('mode'); $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');
$code_tiers = GETPOST('code_tiers'); $subledger_account = GETPOST('subledger_account');
if ($code_tiers == - 1) { if ($subledger_account == - 1) {
$code_tiers = null; $subledger_account = null;
} }
$label_compte = GETPOST('label_compte'); $label_compte = GETPOST('label_compte');
$label_operation= GETPOST('label_operation'); $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';
@@ -60,23 +63,28 @@ if (! empty($update)) {
} }
$object = new BookKeeping($db); $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, null, $mode);
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->code_tiers = $code_tiers; $book->subledger_account = $subledger_account;
$book->label_compte = $label_compte; $book->label_compte = $label_compte;
$book->label_operation= $label_operation; $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';
@@ -85,6 +93,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, false, $mode);
if ($result < 0) { if ($result < 0) {
setEventMessages($book->error, $book->errors, 'errors'); setEventMessages($book->error, $book->errors, 'errors');
@@ -95,16 +104,20 @@ 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->code_tiers = $code_tiers; $book->subledger_account = $subledger_account;
$book->label_compte = $label_compte; $book->label_compte = $label_compte;
$book->label_operation= $label_operation; $book->label_operation= $label_operation;
$book->debit = $debit; $book->debit = $debit;
@@ -116,14 +129,17 @@ 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, false, $mode);
if ($result < 0) { if ($result < 0) {
setEventMessages($book->error, $book->errors, 'errors'); setEventMessages($book->error, $book->errors, 'errors');
@@ -133,10 +149,13 @@ 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, null, $mode);
$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 {
@@ -147,41 +166,47 @@ else if ($action == "confirm_delete") {
} }
$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 = '';
$book->debit = 0; $book->debit = 0;
$book->credit = 0; $book->credit = 0;
$book->doc_date = $date_start = dol_mktime(0, 0, 0, GETPOST('doc_datemonth'), GETPOST('doc_dateday'), GETPOST('doc_dateyear')); $book->doc_date = $date_start = dol_mktime(0, 0, 0, GETPOST('doc_datemonth'), GETPOST('doc_dateday'), GETPOST('doc_dateyear'));
$book->doc_type = GETPOST('doc_type'); $book->doc_type = GETPOST('doc_type');
$book->piece_num = GETPOST('next_num_mvt'); $book->piece_num = GETPOST('next_num_mvt');
$book->doc_ref = GETPOST('doc_ref'); $book->doc_ref = GETPOST('doc_ref');
$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);
if ($result < 0) { $result = $book->createStd($user,0, $mode);
setEventMessages($book->error, $book->errors, 'errors'); if ($result < 0) {
} else { setEventMessages($book->error, $book->errors, 'errors');
setEventMessages($langs->trans('Saved'), null, 'mesgs'); } else {
$action = 'update'; setEventMessages($langs->trans('Saved'), null, 'mesgs');
$id=$book->id; $action = 'update';
$piece_num = $book->piece_num; $id=$book->id;
} $piece_num = $book->piece_num;
}
} }
} }
if ($action == 'setdate') { if ($action == 'setdate') {
$datedoc = dol_mktime(0, 0, 0, GETPOST('doc_datemonth'), GETPOST('doc_dateday'), GETPOST('doc_dateyear')); $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); $result = $object->updateByMvt($piece_num,'doc_date',$db->idate($datedoc),$mode);
if ($result < 0) { if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} else { } else {
@@ -189,12 +214,13 @@ if ($action == 'setdate') {
$action = ''; $action = '';
} }
} }
if ($action == 'setjournal') { if ($action == 'setjournal') {
$journaldoc = trim(GETPOST('code_journal')); $journaldoc = trim(GETPOST('code_journal'));
if (!empty($journaldoc)) { if (!empty($journaldoc)) {
$journaldoc='\''.$journaldoc.'\''; $journaldoc='\''.$journaldoc.'\'';
} }
$result = $object->upddateByMvt($piece_num,'code_journal',$journaldoc,$mode); $result = $object->updateByMvt($piece_num,'code_journal',$journaldoc,$mode);
if ($result < 0) { if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} else { } else {
@@ -202,12 +228,13 @@ if ($action == 'setjournal') {
$action = ''; $action = '';
} }
} }
if ($action == 'setdocref') { if ($action == 'setdocref') {
$refdoc = trim(GETPOST('doc_ref')); $refdoc = trim(GETPOST('doc_ref'));
if (!empty($refdoc)) { if (!empty($refdoc)) {
$refdoc='\''.$refdoc.'\''; $refdoc='\''.$refdoc.'\'';
} }
$result = $object->upddateByMvt(doc_ref,'code_journal',$refdoc,$mode); $result = $object->updateByMvt(doc_ref,'code_journal',$refdoc,$mode);
if ($result < 0) { if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} else { } else {
@@ -215,6 +242,7 @@ if ($action == 'setdocref') {
$action = ''; $action = '';
} }
} }
if ($action == 'valid') { if ($action == 'valid') {
$result = $object->transformTransaction(0,$piece_num); $result = $object->transformTransaction(0,$piece_num);
if ($result < 0) { if ($result < 0) {
@@ -224,6 +252,7 @@ if ($action == 'valid') {
exit; exit;
} }
} }
/* /*
* View * View
*/ */
@@ -237,47 +266,61 @@ if ($action == 'delete') {
$formconfirm = $html->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $id.'&mode='. $mode, $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('_tmp'); $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"; 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("Codejournal") . '</td>'; print '<td class="fieldrequired">' . $langs->trans("Codejournal") . '</td>';
print '<td>' . $formaccounting->select_journal(GETPOST('code_journal'),'code_journal',0,0,array(),1,1) . '</td>'; print '<td>' . $formaccounting->select_journal(GETPOST('code_journal'),'code_journal',0,0,array(),1,1) . '</td>';
print '</tr>'; print '</tr>';
print '<tr>'; print '<tr>';
print '<td>' . $langs->trans("Docref") . '</td>'; print '<td>' . $langs->trans("Docref") . '</td>';
print '<td><input type="text" size="20" name="doc_ref" value=""/></td>'; print '<td><input type="text" class="minwidth200" 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" size="20" name="doc_type" value=""/></td>'; print '<td><input type="text" class="minwidth200 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);
@@ -286,16 +329,21 @@ if ($action == 'create') {
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="fichehalfleft">';
print '<div class="underbanner clearboth"></div>'; print '<div class="underbanner clearboth"></div>';
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
// account mouvment
// account movement
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 // date
print '<tr class="impair"><td>'; print '<tr class="impair"><td>';
print '<table class="nobordernopadding" width="100%"><tr><td>'; print '<table class="nobordernopadding" width="100%"><tr><td>';
@@ -368,11 +416,14 @@ if ($action == 'create') {
print '<td>' . $book->doc_type . '</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">'; print '<div class="fichehalfright"><div class="ficheaddleft">';
print '<div class="underbanner clearboth"></div>'; print '<div class="underbanner clearboth"></div>';
print '<table class="border tableforfield" width="100%">'; print '<table class="border tableforfield" width="100%">';
//Validate
// Validate
print '<tr class="pair">'; print '<tr class="pair">';
print '<td class="titlefield">' . $langs->trans("Status") . '</td>'; print '<td class="titlefield">' . $langs->trans("Status") . '</td>';
print '<td>'; print '<td>';
@@ -394,17 +445,17 @@ if ($action == 'create') {
if ($book->doc_type == 'customer_invoice') if ($book->doc_type == 'customer_invoice')
{ {
$sqlmid = 'SELECT rowid as ref'; $sqlmid = 'SELECT rowid as ref';
$sqlmid .= " FROM ".MAIN_DB_PREFIX."facture as fac"; $sqlmid .= " FROM ".MAIN_DB_PREFIX."facture as fac";
$sqlmid .= " WHERE fac.rowid=" . $book->fk_doc; $sqlmid .= " WHERE fac.rowid=" . $book->fk_doc;
dol_syslog("accountancy/bookkeeping/card.php::sqlmid=" . $sqlmid, LOG_DEBUG); dol_syslog("accountancy/bookkeeping/card.php::sqlmid=" . $sqlmid, LOG_DEBUG);
$resultmid = $db->query($sqlmid); $resultmid = $db->query($sqlmid);
if ($resultmid) { if ($resultmid) {
$objmid = $db->fetch_object($resultmid); $objmid = $db->fetch_object($resultmid);
$invoicestatic = new Facture($db); $invoicestatic = new Facture($db);
$invoicestatic->fetch($objmid->ref); $invoicestatic->fetch($objmid->ref);
$ref=$langs->trans("Invoice").' '.$invoicestatic->getNomUrl(1); $ref=$langs->trans("Invoice").' '.$invoicestatic->getNomUrl(1);
} }
else dol_print_error($db); else dol_print_error($db);
} }
*/ */
print '<td>' . $ref .'</td>'; print '<td>' . $ref .'</td>';
@@ -413,11 +464,14 @@ if ($action == 'create') {
print '</div></div>'; print '</div></div>';
print '<div style="clear:both"></div>'; print '<div style="clear:both"></div>';
print '<br>'; print '<br>';
$result = $book->fetchAllPerMvt($piece_num, $mode); $result = $book->fetchAllPerMvt($piece_num, $mode);
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";
@@ -426,30 +480,37 @@ if ($action == 'create') {
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"; print '<input type="hidden" name="mode" value="' . $mode . '">' . "\n";
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("Code_tiers")); print_liste_field_titre($langs->trans("Subledger_account"));
print_liste_field_titre($langs->trans("Labelcompte")); print_liste_field_titre($langs->trans("Labelcompte"));
print_liste_field_titre($langs->trans("Labeloperation")); print_liste_field_titre($langs->trans("Labeloperation"));
print_liste_field_titre($langs->trans("Debit"), "", "", "", "", 'align="center"'); print_liste_field_titre($langs->trans("Debit"), "", "", "", "", 'align="center"');
print_liste_field_titre($langs->trans("Credit"), "", "", "", "", 'align="center"'); print_liste_field_titre($langs->trans("Credit"), "", "", "", "", '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; $var = ! $var;
print '<tr' . $bc[$var] . '>'; 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, ''); 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->code_tiers, 'code_tiers', 1); print $formaccounting->select_auxaccount($line->subledger_account, 'subledger_account', 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><input type="text" size="15" name="label_operation" value="' . $line->label_operation. '"/></td>';
@@ -461,34 +522,37 @@ if ($action == 'create') {
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->code_tiers) . '</td>'; print '<td>' . length_accounta($line->subledger_account) . '</td>';
print '<td>' . $line->label_compte . '</td>'; print '<td>' . $line->label_compte . '</td>';
print '<td>' . $line->label_operation. '</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="center">'; print '<td align="center">';
print '<a href="./card.php?action=update&amp;id=' . $line->id . '&amp;piece_num=' . $line->piece_num . '&amp;mode='.$mode.'">'; print '<a href="' . $_SERVER["PHP_SELF"] . '?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 . '&amp;mode='.$mode.'">'; print '<a href="' . $_SERVER["PHP_SELF"] . '?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') {
$var = ! $var; print '<tr class="oddeven">';
print '<tr' . $bc[$var] . '>';
print '<td>'; print '<td>';
print $formaccounting->select_account($account_number, 'account_number', 0, array (), 1, 1, ''); print $formaccounting->select_account($account_number, 'account_number', 0, array (), 1, 1, '');
print '</td>'; print '</td>';
print '<td>'; print '<td>';
print $formaccounting->select_auxaccount($code_tiers, 'code_tiers', 1); print $formaccounting->select_auxaccount($subledger_account, 'subledger_account', 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><input type="text" size="15" name="label_operation" value="' . $line->label_operation. '"/></td>';
@@ -510,6 +574,7 @@ if ($action == 'create') {
print load_fiche_titre($langs->trans("NoRecords")); print load_fiche_titre($langs->trans("NoRecords"));
} }
} }
dol_fiche_end(); dol_fiche_end();
llxFooter(); llxFooter();
$db->close(); $db->close();

View File

@@ -1060,10 +1060,10 @@ class BookKeeping extends CommonObject
* @param string $mode Mode * @param string $mode Mode
* @return number <0 if KO, >0 if OK * @return number <0 if KO, >0 if OK
*/ */
public function upddateByMvt($piece_num='', $field='', $value='', $mode='') { public function updateByMvt($piece_num='', $field='', $value='', $mode='') {
$this->db->begin(); $this->db->begin();
$sql = "UPDATE " . MAIN_DB_PREFIX . $this->table_element.$mode." as ab"; $sql = "UPDATE " . MAIN_DB_PREFIX . $this->table_element . $mode . " as ab";
$sql .= ' SET ab.'.$field.'=' . $value; $sql .= ' SET ab.' . $field . '=' . $value;
$sql .= ' WHERE ab.piece_num=' . $piece_num ; $sql .= ' WHERE ab.piece_num=' . $piece_num ;
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if (! $resql) { if (! $resql) {

View File

@@ -91,7 +91,7 @@ $idpays = $mysoc->country_id;
$sql = "SELECT er.rowid, er.ref, er.date_debut as de,"; $sql = "SELECT er.rowid, er.ref, er.date_debut as de,";
$sql .= " erd.rowid as erdid, erd.comments, erd.total_ttc, erd.tva_tx, erd.total_ht, erd.total_tva, erd.fk_code_ventilation, erd.vat_src_code, "; $sql .= " erd.rowid as erdid, erd.comments, erd.total_ttc, erd.tva_tx, erd.total_ht, erd.total_tva, erd.fk_code_ventilation, erd.vat_src_code, ";
$sql .= " u.rowid as uid, u.firstname, u.lastname, u.accountancy_code as user_accountancy_account,"; $sql .= " u.rowid as uid, u.firstname, u.lastname, u.accountancy_code as user_accountancy_account,";
$sql .= " f.accountancy_code, aa.rowid as fk_compte, aa.account_number as compte, aa.label as label_compte,"; $sql .= " f.accountancy_code, aa.rowid as fk_compte, aa.account_number as compte, aa.label as label_compte";
//$sql .= " ct.accountancy_code_buy as account_tva"; //$sql .= " ct.accountancy_code_buy as account_tva";
$sql .= " FROM " . MAIN_DB_PREFIX . "expensereport_det as erd"; $sql .= " FROM " . MAIN_DB_PREFIX . "expensereport_det as erd";
//$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_tva as ct ON erd.tva_tx = ct.taux AND ct.fk_pays = '" . $idpays . "'"; //$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_tva as ct ON erd.tva_tx = ct.taux AND ct.fk_pays = '" . $idpays . "'";

View File

@@ -152,7 +152,7 @@ if ($result) {
// Define array to display all VAT rates that use this accounting account $compta_tva // Define array to display all VAT rates that use this accounting account $compta_tva
if ((! price2num($obj->tva_tx)) || ! empty($obj->vat_src_code)) if ((! price2num($obj->tva_tx)) || ! empty($obj->vat_src_code))
{ {
$def_tva[$obj->rowid][$compta_tva][vatrate($obj->tva_tx).($obj->vat_src_code?' ('.$obj->vat_src_code.')':'')]=(vatrate($obj->tva_tx).($obj->vat_src_code?' ('.$obj->vat_src_code.')':'')); $def_tva[$obj->rowid][$compta_tva][vatrate($obj->tva_tx).($obj->vat_src_code?' ('.$obj->vat_src_code.')':'')]=(vatrate($obj->tva_tx).($obj->vat_src_code?' ('.$obj->vat_src_code.')':''));
} }
// Situation invoices handling // Situation invoices handling
@@ -591,7 +591,7 @@ if (empty($action) || $action == 'view') {
print "<td>" . $langs->trans("Date") . "</td>"; print "<td>" . $langs->trans("Date") . "</td>";
print "<td>" . $langs->trans("Piece") . ' (' . $langs->trans("InvoiceRef") . ")</td>"; print "<td>" . $langs->trans("Piece") . ' (' . $langs->trans("InvoiceRef") . ")</td>";
print "<td>" . $langs->trans("AccountAccounting") . "</td>"; print "<td>" . $langs->trans("AccountAccounting") . "</td>";
print "<td>" . $langs->trans("Type") . "</td>"; print "<td>" . $langs->trans("Label") . "</td>";
print "<td align='right'>" . $langs->trans("Debit") . "</td>"; print "<td align='right'>" . $langs->trans("Debit") . "</td>";
print "<td align='right'>" . $langs->trans("Credit") . "</td>"; print "<td align='right'>" . $langs->trans("Credit") . "</td>";
print "</tr>\n"; print "</tr>\n";
@@ -617,7 +617,6 @@ if (empty($action) || $action == 'view') {
$companystatic->id = $tabcompany[$key]['id']; $companystatic->id = $tabcompany[$key]['id'];
$companystatic->name = $tabcompany[$key]['name']; $companystatic->name = $tabcompany[$key]['name'];
$companystatic->client = $tabcompany[$key]['code_client']; $companystatic->client = $tabcompany[$key]['code_client'];
$companystatic->client = $tabcompany[$key]['code_client'];
print "<td>"; print "<td>";
$accountoshow = length_accounta($k); $accountoshow = length_accounta($k);
if (empty($accountoshow) || $accountoshow == 'NotDefined') if (empty($accountoshow) || $accountoshow == 'NotDefined')
@@ -675,7 +674,7 @@ if (empty($action) || $action == 'view') {
} }
else print $accountoshow; else print $accountoshow;
print "</td>"; print "</td>";
print "<td>" . $companystatic->getNomUrl(0, 'customer', 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("VAT") . ' '.join(', ',$def_tva[$key][$k]). "</td>"; print "<td>" . $companystatic->getNomUrl(0, 'customer', 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("VAT") . "</td>"; // ' '.join(', ',$def_tva[$key][$k]).
// print "<td>" . $langs->trans("VAT") . "</td>"; // print "<td>" . $langs->trans("VAT") . "</td>";
print "<td align='right'>" . ($mt < 0 ? price(- $mt) : '') . "</td>"; print "<td align='right'>" . ($mt < 0 ? price(- $mt) : '') . "</td>";
print "<td align='right'>" . ($mt >= 0 ? price($mt) : '') . "</td>"; print "<td align='right'>" . ($mt >= 0 ? price($mt) : '') . "</td>";