Skip to content

Commit

Permalink
Merge pull request #4582 from aspangaro/3.9-p10
Browse files Browse the repository at this point in the history
Fixed: 3.9rc Problem of merging Review page init accountancy
  • Loading branch information
eldy committed Feb 8, 2016
2 parents 84f4f2d + eaca582 commit 77531f9
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 56 deletions.
93 changes: 42 additions & 51 deletions htdocs/accountancy/admin/productaccount.php
@@ -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>
Expand All @@ -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';
Expand All @@ -40,7 +41,11 @@
$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');
Expand Down Expand Up @@ -76,8 +81,8 @@
$sortfield = "p.ref";
if (! $sortorder)
$sortorder = "ASC";
// sales or purchase

// Sales or Purchase mode ?
if ($action == 'update') {
if (! empty($btn_changetype)) {
$error = 0;
Expand Down Expand Up @@ -129,9 +134,9 @@

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>';
}
}

Expand All @@ -144,13 +149,6 @@
}
}

// 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
Expand All @@ -176,12 +174,11 @@
$search_desc = '';
}

// debug move header to top
llxHeader('', $langs->trans("Accounts"));

/*
* View
*/

llxHeader('', $langs->trans("Accounts"));

print '<script type="text/javascript">
$(function () {
Expand All @@ -206,7 +203,7 @@

$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 . "))";
Expand Down Expand Up @@ -237,63 +234,59 @@
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";

if (! empty($msg)) {
print $msg;
}

// print '<td align="left"><b>' . $langs->trans("DescProductAccountingAccount") . '</b></td>&nbsp;';
// print_liste_field_titre($langs->trans("RowId"), $_SERVER["PHP_SELF"], "p.rowid", "", $param, '', $sortfield, $sortorder);
print '&nbsp;&nbsp;';

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">&nbsp;</td>';
print '<td align="right" class="liste_titre">';
print '<td class="liste_titre">&nbsp;</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 '&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")) . '">';
Expand Down Expand Up @@ -346,13 +339,12 @@
// 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
Expand All @@ -361,9 +353,8 @@
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;
Expand All @@ -380,7 +371,7 @@
$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);
Expand Down
6 changes: 6 additions & 0 deletions htdocs/core/menus/standard/eldy.lib.php
Expand Up @@ -555,6 +555,12 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu
{
$langs->load("products");
$newmenu->add("/product/admin/product_tools.php?mainmenu=home&amp;leftmenu=modulesadmintools", $langs->trans("ProductVatMassChange"), 1, $user->admin);

if (! empty($conf->accounting->enabled))
{
$langs->load("accountancy");
$newmenu->add("/accountancy/admin/productaccount.php?mainmenu=home&amp;leftmenu=modulesadmintools", $langs->trans("InitAccountancy"), 1, $user->admin);
}
}
}
}
Expand Down
20 changes: 15 additions & 5 deletions htdocs/langs/en_US/accountancy.lang
Expand Up @@ -105,6 +105,7 @@ Code_tiers=Thirdparty
Labelcompte=Label account
Sens=Sens
Codejournal=Journal
NumPiece=Piece number

DelBookKeeping=Delete the records of the general ledger

Expand Down Expand Up @@ -153,6 +154,8 @@ ErrorAccountancyCodeIsAlreadyUse=Error, you cannot delete this accounting accoun
FicheVentilation=Breakdown card
GeneralLedgerIsWritten=Operations are written in the general ledger

MvtNotCorrectlyBalanced=Mouvement not correctly balanced. Credit = %s. Debit = %s

##Export Journal Feature
ExportFormat=Format of Export
Prefixname=Prefix of export File
Expand All @@ -163,8 +166,15 @@ Fieldname=Name of Field
Headername=Name in header
Type=Type of fields
Param=Additionnal parameters
EnabledProduct=In Product
EnabledTiers=In Tiers
EnabledVat=In Vat

MvtNotCorrectlyBalanced=Mouvement not correctly balanced. Credit = %s. Debit = %s
EnabledProduct=In product
EnabledTiers=In third party
EnabledVat=In VAT

## Tools - Init accounting account on product / service
InitAccountancy=Init accountancy
InitAccountancyDesc=This page can be used to initialize an accounting account on products and services that does not have accountancy account defined for sales and purchases. Check before that setup of module accountancy is complete.
Options=Options
OptionModeProductSell=Mode sales
OptionModeProductBuy=Mode purchases
OptionModeProductSellDesc=Show all products with no accounting account defined for sales.
OptionModeProductBuyDesc=Show all products with no accounting account defined for purchases.

0 comments on commit 77531f9

Please sign in to comment.