Skip to content
Snippets Groups Projects
Commit 4ea00fe1 authored by Laurent Destailleur's avatar Laurent Destailleur
Browse files

Merge pull request #4725 from aspangaro/3.9-p15

Fix: 3.9rc2 Show accountancy account ventilated instead of the rowid of the account
parents e7511dd2 8536841a
No related branches found
No related tags found
No related merge requests found
<?php
/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2016 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
* Copyright (C) 2014-2015 Ari Elbaz (elarifr) <github@accedinfo.com>
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2016 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
* Copyright (C) 2014-2015 Ari Elbaz (elarifr) <github@accedinfo.com>
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
*
* 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
......@@ -20,9 +20,9 @@
*/
/**
* \file htdocs/accountancy/customer/list.php
* \ingroup Accountancy
* \brief Ventilation page from customers invoices
* \file htdocs/accountancy/customer/list.php
* \ingroup Advanced accountancy
* \brief Ventilation page from customers invoices
*/
require '../../main.inc.php';
......@@ -31,6 +31,7 @@ require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php';
require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
// Langs
$langs->load("compta");
......@@ -123,36 +124,38 @@ print '<script type="text/javascript">
});
});
});
</script>';
</script>';
/*
* Action
*/
if ($action == 'ventil' && ! empty($btn_ventil)) {
print '<div><font color="red">' . $langs->trans("Processing") . '...</font></div>';
if (! empty($codeventil) && ! empty($mesCasesCochees)) {
print '<div><font color="red">' . count($mesCasesCochees) . ' ' . $langs->trans("SelectedLines") . '</font></div>';
$mesCodesVentilChoisis = $codeventil;
$cpt = 0;
foreach ( $mesCasesCochees as $maLigneCochee ) {
$maLigneCourante = explode("_", $maLigneCochee);
$monId = $maLigneCourante[0];
$monNumLigne = $maLigneCourante[1];
$monCompte = $mesCodesVentilChoisis[$monNumLigne];
$sql = " UPDATE " . MAIN_DB_PREFIX . "facturedet";
$sql .= " SET fk_code_ventilation = " . $monCompte;
$sql .= " WHERE rowid = " . $monId;
$accountventilated = new AccountingAccount($db);
$accountventilated->fetch($monCompte, '');
dol_syslog("/accountancy/customer/list.php sql=" . $sql, LOG_DEBUG);
if ($db->query($sql)) {
print '<div><font color="green">' . $langs->trans("Lineofinvoice") . ' ' . $monId . ' ' . $langs->trans("VentilatedinAccount") . ' : ' . $monCompte . '</font></div>';
print '<div><font color="green">' . $langs->trans("Lineofinvoice") . ' ' . $monId . ' - ' . $langs->trans("VentilatedinAccount") . ' : ' . length_accountg($accountventilated->account_number) . '</font></div>';
} else {
print '<div><font color="red">' . $langs->trans("ErrorDB") . ' : ' . $langs->trans("Lineofinvoice") . ' ' . $monId . ' ' . $langs->trans("NotVentilatedinAccount") . ' : ' . $monCompte . '<br/> <pre>' . $sql . '</pre></font></div>';
print '<div><font color="red">' . $langs->trans("ErrorDB") . ' : ' . $langs->trans("Lineofinvoice") . ' ' . $monId . ' - ' . $langs->trans("NotVentilatedinAccount") . ' : ' . length_accountg($accountventilated->account_number) . '<br/> <pre>' . $sql . '</pre></font></div>';
}
$cpt ++;
}
} else {
......@@ -164,7 +167,6 @@ if ($action == 'ventil' && ! empty($btn_ventil)) {
/*
* Customer Invoice lines
*/
if (! empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)) {
$limit = $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION;
} else if ($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION <= 0) {
......@@ -224,16 +226,13 @@ $result = $db->query($sql);
if ($result) {
$num_lines = $db->num_rows($result);
$i = 0;
print_barre_liste($langs->trans("InvoiceLines"), $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, '', $num_lines);
print '<br><b>' . $langs->trans("DescVentilTodoCustomer") . '</b></br>';
print_liste_field_titre($langs->trans("Date"), $_SERVER["PHP_SELF"], "f.datef", "", $param, '', $sortfield, $sortorder);
print '&nbsp;&nbsp;';
print_liste_field_titre($langs->trans("RowId"), $_SERVER["PHP_SELF"], "l.rowid", "", $param, '', $sortfield, $sortorder);
print '<form action="' . $_SERVER["PHP_SELF"] . '" method="post">' . "\n";
print '<input type="hidden" name="action" value="ventil">';
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print_liste_field_titre($langs->trans("Invoice"), $_SERVER["PHP_SELF"], "f.facnumber", "", $param, '', $sortfield, $sortorder);
......@@ -247,40 +246,39 @@ if ($result) {
print_liste_field_titre('');
print_liste_field_titre($langs->trans("Ventilate") . '<br><label id="select-all">' . $langs->trans('All') . '</label>/<label id="unselect-all">' . $langs->trans('None') . '</label>', '', '', '', '', 'align="center"');
print '</tr>';
// We add search filter
print '<tr class="liste_titre">';
print '<td class="liste_titre"><input type="text" class="flat" size="10" name="search_invoice" value="' . $search_invoice . '"></td>';
print '<td class="liste_titre"><input type="text" class="flat" size="15" name="search_ref" value="' . $search_ref . '"></td>';
print '<td class="liste_titre"><input type="text" class="flat" size="20" name="search_label" value="' . $search_label . '"></td>';
print '<td class="liste_titre"><input type="text" class="flat" size="20" name="search_desc" value="' . $search_desc . '"></td>';
print '<td class="liste_titre" align="right"><input type="text" class="flat" size="10" name="search_amount" value="' . $search_amount . '"></td>';
print '<td class="liste_titre" align="center"><input type="text" class="flat" size="5" name="search_vat" value="' . $search_vat . '">%</td>';
print '<td class="liste_titre" align="center"><input type="text" class="flat" size="3" name="search_vat" value="' . $search_vat . '">%</td>';
print '<td align="right" class="liste_titre" colspan="4">';
print '<input type="image" class="liste_titre" src="' . img_picto($langs->trans("Search"), 'search.png', '', '', 1) . '" name="button_search" value="' . dol_escape_htmltag($langs->trans("Search")) . '" title="' . dol_escape_htmltag($langs->trans("Search")) . '">';
print '&nbsp;';
print '<input type="image" class="liste_titre" src="' . img_picto($langs->trans("Search"), 'searchclear.png', '', '', 1) . '" name="button_removefilter" value="' . dol_escape_htmltag($langs->trans("RemoveFilter")) . '" title="' . dol_escape_htmltag($langs->trans("RemoveFilter")) . '">';
print '</td>';
print '</tr>';
$facture_static = new Facture($db);
$product_static = new Product($db);
$form = new Form($db);
$var = true;
while ( $i < min($num_lines, $limit) ) {
$objp = $db->fetch_object($result);
$var = ! $var;
$objp->code_sell_l = '';
$objp->code_sell_p = '';
$objp->aarowid_suggest = '';
$code_sell_p_l_differ = '';
$code_sell_p_notset = '';
$objp->aarowid_suggest = $objp->aarowid;
if (! empty($objp->code_sell)) {
$objp->code_sell_p = $objp->code_sell;
} else {
......@@ -304,9 +302,9 @@ if ($result) {
}
if ($objp->code_sell_l != $objp->code_sell_p)
$code_sell_p_l_differ = 'color:red';
print "<tr $bc[$var]>";
// Ref Invoice
$facture_static->ref = $objp->facnumber;
$facture_static->id = $objp->facid;
......@@ -316,14 +314,14 @@ if ($result) {
$product_static->id = $objp->product_id;
$product_static->type = $objp->type;
print '<td>';
if ($product_static->id)
print $product_static->getNomUrl(1);
else
print '&nbsp;';
print '</td>';
print '<td style="' . $code_sell_p_l_differ . '">' . dol_trunc($objp->product_label, 24) . '</td>';
$trunclength = defined('ACCOUNTING_LENGTH_DESCRIPTION') ? ACCOUNTING_LENGTH_DESCRIPTION : 32;
print '<td style="' . $code_sell_p_l_differ . '">' . nl2br(dol_trunc($objp->description, $trunclength)) . '</td>';
......@@ -339,10 +337,10 @@ if ($result) {
if ($objp->code_sell_l == $objp->code_sell_p) {
print $objp->code_sell_l;
} else {
print $langs->trans("Purchase") . ' = ' . $objp->code_sell_l . '<br />' . $langs->trans("Sell") . ' = ' . $objp->code_sell_p;
print $langs->trans("Buy") . ' = ' . $objp->code_sell_l . '<br />' . $langs->trans("Sell") . ' = ' . $objp->code_sell_p;
}
print '</td>';
print '<td align="center">';
print $formventilation->select_account($objp->aarowid_suggest, 'codeventil[]', 1);
print '</td>';
......@@ -353,7 +351,7 @@ if ($result) {
print '</tr>';
$i ++;
}
print '</table>';
print '<br><div align="center"><input type="submit" class="butAction" value="' . $langs->trans("Ventilate") . '" name="ventil"></div>';
print '</form>';
......
......@@ -20,9 +20,9 @@
*/
/**
* \file htdocs/accountancy/supplier/list.php
* \ingroup Accountancy
* \brief Ventilation page from suppliers invoices
* \file htdocs/accountancy/supplier/list.php
* \ingroup Advanced accountancy
* \brief Ventilation page from suppliers invoices
*/
require '../../main.inc.php';
......@@ -31,6 +31,7 @@ require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php';
require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.product.class.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/html.formventilation.class.php';
require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
// Langs
$langs->load("compta");
......@@ -128,36 +129,39 @@ print '<script type="text/javascript">
});
});
});
</script>';
</script>';
/*
* Action
*/
if ($action == 'ventil' && ! empty($btn_ventil)) {
print '<div><font color="red">' . $langs->trans("Processing") . '...</font></div>';
if ($_POST['codeventil'] && $_POST["mesCasesCochees"]) {
print '<div><font color="red">' . count($_POST["mesCasesCochees"]) . ' ' . $langs->trans("SelectedLines") . '</font></div>';
$mesCodesVentilChoisis = $codeventil;
$cpt = 0;
foreach ( $mesCasesCochees as $maLigneCochee ) {
// print '<div><font color="red">id selectionnee : '.$monChoix."</font></div>";
$maLigneCourante = explode("_", $maLigneCochee);
$monId = $maLigneCourante[0];
$monNumLigne = $maLigneCourante[1];
$monCompte = $mesCodesVentilChoisis[$monNumLigne];
$sql = " UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det";
$sql .= " SET fk_code_ventilation = " . $monCompte;
$sql .= " WHERE rowid = " . $monId;
$accountventilated = new AccountingAccount($db);
$accountventilated->fetch($monCompte, '');
dol_syslog('accountancy/supplier/list.php:: sql=' . $sql, LOG_DEBUG);
if ($db->query($sql)) {
print '<div><font color="green">' . $langs->trans("Lineofinvoice") . ' ' . $monId . ' ' . $langs->trans("VentilatedinAccount") . ' : ' . $monCompte . '</font></div>';
print '<div><font color="green">' . $langs->trans("Lineofinvoice") . ' ' . $monId . ' - ' . $langs->trans("VentilatedinAccount") . ' : ' . length_accountg($accountventilated->account_number) . '</font></div>';
} else {
print '<div><font color="red">' . $langs->trans("ErrorDB") . ' : ' . $langs->trans("Lineofinvoice") . ' ' . $monId . ' ' . $langs->trans("NotVentilatedinAccount") . ' : ' . $monCompte . '<br/> <pre>' . $sql . '</pre></font></div>';
print '<div><font color="red">' . $langs->trans("ErrorDB") . ' : ' . $langs->trans("Lineofinvoice") . ' ' . $monId . ' - ' . $langs->trans("NotVentilatedinAccount") . ' : ' . length_accountg($accountventilated->account_number) . '<br/> <pre>' . $sql . '</pre></font></div>';
}
$cpt ++;
}
} else {
......@@ -169,7 +173,6 @@ if ($action == 'ventil' && ! empty($btn_ventil)) {
/*
* Supplier Invoice Lines
*/
if (! empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)) {
$limit = $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION;
} else if ($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION <= 0) {
......@@ -226,15 +229,15 @@ $result = $db->query($sql);
if ($result) {
$num_lines = $db->num_rows($result);
$i = 0;
// TODO : print_barre_liste always use $conf->liste_limit and do not care about custom limit in list...
print_barre_liste($langs->trans("InvoiceLines"), $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, '', $num_lines);
print '<br><b>' . $langs->trans("DescVentilTodoCustomer") . '</b></br>';
print '<form action="' . $_SERVER["PHP_SELF"] . '" method="post">' . "\n";
print '<input type="hidden" name="action" value="ventil">';
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print_liste_field_titre($langs->trans("Invoice"), $_SERVER["PHP_SELF"], "f.ref", "", $param, '', $sortfield, $sortorder);
......@@ -248,14 +251,14 @@ if ($result) {
print_liste_field_titre('');
print_liste_field_titre($langs->trans("Ventilate") . '<br><label id="select-all">' . $langs->trans('All') . '</label>/<label id="unselect-all">' . $langs->trans('None') . '</label>', '', '', '', '', 'align="center"');
print "</tr>\n";
print '<tr class="liste_titre">';
print '<td class="liste_titre"><input type="text" class="flat" size="10" name="search_invoice" value="' . $search_invoice . '"></td>';
print '<td class="liste_titre"><input type="text" class="flat" size="15" name="search_ref" value="' . $search_ref . '"></td>';
print '<td class="liste_titre"><input type="text" class="flat" size="20" name="search_label" value="' . $search_label . '"></td>';
print '<td class="liste_titre"><input type="text" class="flat" size="20" name="search_desc" value="' . $search_desc . '"></td>';
print '<td class="liste_titre" align="right"><input type="text" class="flat" size="10" name="search_amount" value="' . $search_amount . '"></td>';
print '<td class="liste_titre" align="center"><input type="text" class="flat" size="5" name="search_vat" value="' . $search_vat . '">%</td>';
print '<td class="liste_titre" align="center"><input type="text" class="flat" size="3" name="search_vat" value="' . $search_vat . '">%</td>';
print '<td class="liste_titre" align="center">&nbsp;</td>';
print '<td class="liste_titre">&nbsp;</td>';
print '<td align="right" colspan="2" class="liste_titre">';
......@@ -264,16 +267,16 @@ if ($result) {
print '<input type="image" class="liste_titre" src="' . img_picto($langs->trans("Search"), 'searchclear.png', '', '', 1) . '" name="button_removefilter" value="' . dol_escape_htmltag($langs->trans("RemoveFilter")) . '" title="' . dol_escape_htmltag($langs->trans("RemoveFilter")) . '">';
print '</td>';
print '</tr>';
$facturefourn_static = new FactureFournisseur($db);
$productfourn_static = new ProductFournisseur($db);
$form = new Form($db);
$var = True;
while ( $i < min($num_lines, $limit) ) {
$objp = $db->fetch_object($result);
$var = ! $var;
// product_type: 0 = service ? 1 = product
// if product does not exist we use the value of product_type provided in facturedet to define if this is a product or service
// issue : if we change product_type value in product DB it should differ from the value stored in facturedet DB !
......@@ -281,9 +284,9 @@ if ($result) {
$objp->code_buy_p = '';
$objp->aarowid_suggest = '';
$code_buy_p_l_differ = '';
$code_buy_p_notset = '';
$objp->aarowid_suggest = $objp->aarowid;
if (! empty($objp->code_buy)) {
$objp->code_buy_p = $objp->code_buy;
......@@ -297,7 +300,7 @@ if ($result) {
$objp->code_buy_p = (! empty($conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT : $langs->trans("CodeNotDef"));
}
}
if ($objp->type_l == 1) {
$objp->code_buy_l = (! empty($conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT : $langs->trans("CodeNotDef"));
if ($objp->aarowid == '')
......@@ -307,17 +310,17 @@ if ($result) {
if ($objp->aarowid == '')
$objp->aarowid_suggest = $aarowid_p;
}
if ($objp->code_buy_l != $objp->code_buy_p)
$code_buy_p_l_differ = 'color:red';
print "<tr $bc[$var]>";
// Ref Invoice
$facturefourn_static->ref = $objp->ref;
$facturefourn_static->id = $objp->facid;
print '<td>' . $facturefourn_static->getNomUrl(1) . '</td>';
// Ref Supplier Invoice
$productfourn_static->ref = $objp->product_ref;
$productfourn_static->id = $objp->product_id;
......@@ -328,23 +331,23 @@ if ($result) {
else
print '&nbsp;';
print '</td>';
print '<td style="' . $code_buy_p_l_differ . '">' . dol_trunc($objp->product_label, 24) . '</td>';
// TODO: we should set a user defined value to adjust user square / wide screen size
$trunclength = defined('ACCOUNTING_LENGTH_DESCRIPTION') ? ACCOUNTING_LENGTH_DESCRIPTION : 32;
print '<td style="' . $code_buy_p_l_differ . '">' . nl2br(dol_trunc($objp->description, $trunclength)) . '</td>';
print '<td align="right">';
print price($objp->price);
print '</td>';
if ($objp->vat_tx_l != $objp->vat_tx_p)
$code_vat_differ = 'font-weight:bold; text-decoration:blink; color:red';
print '<td style="' . $code_vat_differ . '" align="center">';
print price($objp->tva_tx_line);
print '</td>';
print '<td align="center" style="' . $code_buy_p_notset . '">';
// if not same kind of product_type stored in product & facturedt we display both account and let user choose
if ($objp->code_buy_l == $objp->code_buy_p) {
......@@ -353,7 +356,7 @@ if ($result) {
print 'lines=' . $objp->code_buy_l . '<br />product=' . $objp->code_buy_p;
}
print '</td>';
// Colonne choix du compte
print '<td align="center">';
print $formventilation->select_account($objp->aarowid_suggest, 'codeventil[]', 1);
......@@ -363,11 +366,11 @@ if ($result) {
print '<td align="center">';
print '<input type="checkbox" name="mesCasesCochees[]" value="' . $objp->rowid . "_" . $i . '"' . ($objp->aarowid ? "checked" : "") . '/>';
print '</td>';
print "</tr>";
$i ++;
}
print '</table>';
print '<br><div align="center"><input type="submit" class="butAction" value="' . $langs->trans("Ventilate") . '" name="ventil" ></div>';
print '</form>';
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment