|
|
|
|
@ -1,6 +1,6 @@
|
|
|
|
|
<?PHP
|
|
|
|
|
<?php
|
|
|
|
|
/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
|
|
|
|
|
* Copyright (C) 2013-2014 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
|
|
|
|
|
* Copyright (C) 2013-2016 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
|
|
|
|
|
* Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro>
|
|
|
|
|
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
|
|
|
|
|
* Copyright (C) 2015 Ari Elbaz (elarifr) <github@accedinfo.com>
|
|
|
|
|
@ -20,13 +20,14 @@
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* \file htdocs/accountancy/admin/productaccount.php
|
|
|
|
|
* \file htdocs/accountancy/admin/productaccount.php
|
|
|
|
|
* \ingroup Accounting Expert
|
|
|
|
|
* \brief Onglet de gestion de parametrages des ventilations
|
|
|
|
|
* \brief To define accounting account on product / service
|
|
|
|
|
*/
|
|
|
|
|
require '../../main.inc.php';
|
|
|
|
|
|
|
|
|
|
// Class
|
|
|
|
|
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
|
|
|
|
|
require_once DOL_DOCUMENT_ROOT . '/core/lib/report.lib.php';
|
|
|
|
|
require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php';
|
|
|
|
|
require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
|
|
|
|
|
@ -40,7 +41,11 @@ $langs->load("compta");
|
|
|
|
|
$langs->load("main");
|
|
|
|
|
$langs->load("accountancy");
|
|
|
|
|
|
|
|
|
|
// search & action GETPOST
|
|
|
|
|
// Security check
|
|
|
|
|
if (!$user->admin) accessforbidden();
|
|
|
|
|
if (empty($conf->accounting->enabled)) accessforbidden();
|
|
|
|
|
|
|
|
|
|
// Search & action GETPOST
|
|
|
|
|
$action = GETPOST('action');
|
|
|
|
|
$codeventil_buy = GETPOST('codeventil_buy', 'array');
|
|
|
|
|
$codeventil_sell = GETPOST('codeventil_sell', 'array');
|
|
|
|
|
@ -76,8 +81,8 @@ if (! $sortfield)
|
|
|
|
|
$sortfield = "p.ref";
|
|
|
|
|
if (! $sortorder)
|
|
|
|
|
$sortorder = "ASC";
|
|
|
|
|
|
|
|
|
|
// sales or purchase
|
|
|
|
|
|
|
|
|
|
// Sales or Purchase mode ?
|
|
|
|
|
if ($action == 'update') {
|
|
|
|
|
if (! empty($btn_changetype)) {
|
|
|
|
|
$error = 0;
|
|
|
|
|
@ -129,9 +134,9 @@ if ($action == 'update') {
|
|
|
|
|
|
|
|
|
|
dol_syslog("/accountancy/admin/productaccount.php sql=" . $sql, LOG_DEBUG);
|
|
|
|
|
if ($db->query($sql)) {
|
|
|
|
|
$msg .= '<div><font color="green">' . $langs->trans("Product") . ' ' . $productid . ' ' . $langs->trans("VentilatedinAccount") . ' : ' . $monCompte . '</font></div>';
|
|
|
|
|
$msg .= '<div><font color="green">' . $langs->trans("Product") . ' ' . $productid . ' ' . $langs->trans("VentilatedinAccount") . ' : ' . length_accountg($accounting->account_number) . '</font></div>';
|
|
|
|
|
} else {
|
|
|
|
|
$msg .= '<div><font color="red">' . $langs->trans("ErrorDB") . ' : ' . $langs->trans("Product") . ' ' . $productid . ' ' . $langs->trans("NotVentilatedinAccount") . ' : ' . $accounting->account_number . '<br/> <pre>' . $sql . '</pre></font></div>';
|
|
|
|
|
$msg .= '<div><font color="red">' . $langs->trans("ErrorDB") . ' : ' . $langs->trans("Product") . ' ' . $productid . ' ' . $langs->trans("NotVentilatedinAccount") . ' : ' . length_accountg($accounting->account_number) . '<br/> <pre>' . $sql . '</pre></font></div>';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -144,13 +149,6 @@ if ($action == 'update') {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Security check
|
|
|
|
|
if ($user->societe_id > 0)
|
|
|
|
|
accessforbidden();
|
|
|
|
|
// TODO after adding menu
|
|
|
|
|
// if (! $user->rights->accounting->ventilation->dispatch)
|
|
|
|
|
// accessforbidden();
|
|
|
|
|
|
|
|
|
|
$form = new FormVentilation($db);
|
|
|
|
|
|
|
|
|
|
// Defaut AccountingAccount RowId Product / Service
|
|
|
|
|
@ -176,12 +174,11 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both
|
|
|
|
|
$search_desc = '';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// debug move header to top
|
|
|
|
|
llxHeader('', $langs->trans("Accounts"));
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* View
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
llxHeader('', $langs->trans("Accounts"));
|
|
|
|
|
|
|
|
|
|
print '<script type="text/javascript">
|
|
|
|
|
$(function () {
|
|
|
|
|
@ -206,7 +203,7 @@ $sql .= " WHERE (";
|
|
|
|
|
|
|
|
|
|
$pcgver = $conf->global->CHARTOFACCOUNTS;
|
|
|
|
|
|
|
|
|
|
IF ($accounting_product_mode == 'ACCOUNTANCY_BUY' ? ' checked' : '') {
|
|
|
|
|
if ($accounting_product_mode == 'ACCOUNTANCY_BUY' ? ' checked' : '') {
|
|
|
|
|
$sql .= " p.accountancy_code_buy ='' OR p.accountancy_code_buy IS NULL";
|
|
|
|
|
$sql .= " OR (p.accountancy_code_buy IS NOT NULL AND p.accountancy_code_buy != '' AND p.accountancy_code_buy NOT IN
|
|
|
|
|
(SELECT aa.account_number FROM " . MAIN_DB_PREFIX . "accounting_account as aa , " . MAIN_DB_PREFIX . "accounting_system as asy WHERE fk_pcg_version = asy.pcg_version AND asy.rowid = " . $pcgver . "))";
|
|
|
|
|
@ -237,29 +234,29 @@ $result = $db->query($sql);
|
|
|
|
|
if ($result) {
|
|
|
|
|
$num_lines = $db->num_rows($result);
|
|
|
|
|
$i = 0;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* View
|
|
|
|
|
*/
|
|
|
|
|
print_barre_liste($langs->trans("ProductAccountingAccountSelect"), $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, '', $num_lines);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
print load_fiche_titre($langs->trans("InitAccountancy"),'','title_setup');
|
|
|
|
|
print '<br>';
|
|
|
|
|
print $langs->trans("InitAccountancyDesc").'<br>';
|
|
|
|
|
print '<br>';
|
|
|
|
|
|
|
|
|
|
print '<form action="' . $_SERVER["PHP_SELF"] . '" method="post">';
|
|
|
|
|
print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
|
|
|
|
|
print '<input type="hidden" name="action" value="update">';
|
|
|
|
|
|
|
|
|
|
print '<table class="noborder" width="100%">';
|
|
|
|
|
print '<tr class="liste_titre">';
|
|
|
|
|
print '<td>' . $langs->trans('OptionMode') . '</td><td>' . $langs->trans('Description') . '</td>';
|
|
|
|
|
print '<td>' . $langs->trans('Options') . '</td><td>' . $langs->trans('Description') . '</td>';
|
|
|
|
|
print "</tr>\n";
|
|
|
|
|
print '<tr ' . $bc[false] . '><td width="200"><input type="radio" name="accounting_product_mode" value="ACCOUNTANCY_SELL"' . ($accounting_product_mode != 'ACCOUNTANCY_BUY' ? ' checked' : '') . '> ' . $langs->trans('Accountancy_code_sell') . '</td>';
|
|
|
|
|
print '<td colspan="2">' . nl2br($langs->trans('OptionModeProductSell'));
|
|
|
|
|
print '<tr ' . $bc[false] . '><td width="25%"><input type="radio" name="accounting_product_mode" value="ACCOUNTANCY_SELL"' . ($accounting_product_mode != 'ACCOUNTANCY_BUY' ? ' checked' : '') . '> ' . $langs->trans('OptionModeProductSell') . '</td>';
|
|
|
|
|
print '<td colspan="2">' . nl2br($langs->trans('OptionModeProductSellDesc'));
|
|
|
|
|
print "</td></tr>\n";
|
|
|
|
|
print '<tr ' . $bc[true] . '><td width="200"><input type="radio" name="accounting_product_mode" value="ACCOUNTANCY_BUY"' . ($accounting_product_mode == 'ACCOUNTANCY_BUY' ? ' checked' : '') . '> ' . $langs->trans('Accountancy_code_buy') . '</td>';
|
|
|
|
|
print '<td colspan="2">' . nl2br($langs->trans('OptionModeProductBuy')) . "</td></tr>\n";
|
|
|
|
|
print '<tr ' . $bc[true] . '><td><input type="radio" name="accounting_product_mode" value="ACCOUNTANCY_BUY"' . ($accounting_product_mode == 'ACCOUNTANCY_BUY' ? ' checked' : '') . '> ' . $langs->trans('OptionModeProductBuy') . '</td>';
|
|
|
|
|
print '<td colspan="2">' . nl2br($langs->trans('OptionModeProductBuyDesc')) . "</td></tr>\n";
|
|
|
|
|
|
|
|
|
|
print "</table>\n";
|
|
|
|
|
|
|
|
|
|
print '<br /><div style="text-align:center"><input type="submit" class="button" value="' . $langs->trans('Modify') . '" name="changetype"></div>';
|
|
|
|
|
print '<br /><div align="right"><input type="submit" class="button" value="' . $langs->trans('Modify') . '" name="changetype"></div>';
|
|
|
|
|
|
|
|
|
|
print "<br>\n";
|
|
|
|
|
|
|
|
|
|
@ -267,33 +264,29 @@ if ($result) {
|
|
|
|
|
print $msg;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// print '<td align="left"><b>' . $langs->trans("DescProductAccountingAccount") . '</b></td> ';
|
|
|
|
|
// print_liste_field_titre($langs->trans("RowId"), $_SERVER["PHP_SELF"], "p.rowid", "", $param, '', $sortfield, $sortorder);
|
|
|
|
|
print ' ';
|
|
|
|
|
|
|
|
|
|
print '<table class="noborder" width="100%">';
|
|
|
|
|
print '<tr class="liste_titre">';
|
|
|
|
|
print_liste_field_titre($langs->trans("Ref"), $_SERVER["PHP_SELF"], "p.ref", "", $param, '', $sortfield, $sortorder);
|
|
|
|
|
print_liste_field_titre($langs->trans("Label"), $_SERVER["PHP_SELF"], "p.label", "", $param, '', $sortfield, $sortorder);
|
|
|
|
|
print_liste_field_titre($langs->trans("Description"), $_SERVER["PHP_SELF"], "l.description", "", $param, '', $sortfield, $sortorder);
|
|
|
|
|
/*
|
|
|
|
|
if ($accounting_product_mode == 'ACCOUNTANCY_BUY') {
|
|
|
|
|
print '<th align="left">' . $langs->trans("Accountancy_code_buy") . '</td>';
|
|
|
|
|
print '<th align="left">' . $langs->trans("Accountancy_code_buy_suggest") . '</td>';
|
|
|
|
|
} else {
|
|
|
|
|
print '<th align="left">' . $langs->trans("Accountancy_code_sell") . '</td>';
|
|
|
|
|
print '<th align="left">' . $langs->trans("Accountancy_code_sell_suggest") . '</td>';
|
|
|
|
|
}
|
|
|
|
|
// 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>');
|
|
|
|
|
*/
|
|
|
|
|
print_liste_field_titre($langs->trans("AccountAccounting"));
|
|
|
|
|
print_liste_field_titre($langs->trans("Modify") . '<br><label id="select-all">' . $langs->trans('All') . '</label> / <label id="unselect-all">' . $langs->trans('None') . '</label>','','','','','align="center"');
|
|
|
|
|
print '</tr>';
|
|
|
|
|
|
|
|
|
|
print '<tr class="liste_titre">';
|
|
|
|
|
print '<td class="liste_titre"><input type="text" class="flat" size="20" name="search_ref" value="' . $search_ref . '"></td>';
|
|
|
|
|
print '<td class="liste_titre"><input type="text" class="flat" size="10" 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="30" name="search_desc" value="' . $search_desc . '"></td>';
|
|
|
|
|
|
|
|
|
|
print '<td class="liste_titre" colspan="2"> </td>';
|
|
|
|
|
print '<td align="right" class="liste_titre">';
|
|
|
|
|
print '<td class="liste_titre"> </td>';
|
|
|
|
|
print '<td align="center" class="liste_titre">';
|
|
|
|
|
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 ' ';
|
|
|
|
|
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")) . '">';
|
|
|
|
|
@ -346,13 +339,12 @@ if ($result) {
|
|
|
|
|
// TODO ADJUST DESCRIPTION SIZE
|
|
|
|
|
// print '<td align="left">' . $obj->description . '</td>';
|
|
|
|
|
// TODO: we shoul set a user defined value to adjust user square / wide screen size
|
|
|
|
|
$trunclengh = defined('ACCOUNTING_LENGTH_DESCRIPTION') ? ACCOUNTING_LENGTH_DESCRIPTION : 32;
|
|
|
|
|
$trunclengh = defined('ACCOUNTING_LENGTH_DESCRIPTION') ? ACCOUNTING_LENGTH_DESCRIPTION : 64;
|
|
|
|
|
print '<td style="' . $code_sell_p_l_differ . '">' . nl2br(dol_trunc($obj->description, $trunclengh)) . '</td>';
|
|
|
|
|
|
|
|
|
|
// acountingaccount buy
|
|
|
|
|
|
|
|
|
|
// Accounting account
|
|
|
|
|
if ($accounting_product_mode == 'ACCOUNTANCY_BUY') {
|
|
|
|
|
print '<td align="left">' . $obj->accountancy_code_buy . '</td>';
|
|
|
|
|
// print '<td align="left">' . $obj->accountancy_code_buy . '</td>';
|
|
|
|
|
// TODO: replace by select
|
|
|
|
|
// print '<td align="left">' . $compta_prodbuy . '</td>';
|
|
|
|
|
// TODO: we shoul set a user defined value to adjust user square / wide screen size
|
|
|
|
|
@ -361,9 +353,8 @@ if ($result) {
|
|
|
|
|
print $form->select_account($compta_prodbuy_id, 'codeventil_' . $product_static->id, 1);
|
|
|
|
|
print '</td>';
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
// acountingaccount sel
|
|
|
|
|
print '<td align="left">' . $obj->accountancy_code_sell . '</td>';
|
|
|
|
|
// Accounting account sell
|
|
|
|
|
// print '<td align="left">' . $obj->accountancy_code_sell . '</td>';
|
|
|
|
|
// TODO: replace by select
|
|
|
|
|
// TODO: we shoul set a user defined value to adjust user square / wide screen size
|
|
|
|
|
// $trunclenghform = defined('ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT') ? ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT : 50;
|
|
|
|
|
@ -380,7 +371,7 @@ if ($result) {
|
|
|
|
|
$i ++;
|
|
|
|
|
}
|
|
|
|
|
print '</table>';
|
|
|
|
|
print '<br><div align="center"><input type="submit" class="butAction" name="changeaccount" value="' . $langs->trans("Change_Account") . '"></div>';
|
|
|
|
|
print '<br><div align="right"><input type="submit" class="butAction" name="changeaccount" value="' . $langs->trans("Validate") . '"></div>';
|
|
|
|
|
print '</form>';
|
|
|
|
|
|
|
|
|
|
$db->free($result);
|
|
|
|
|
|