Patch Accounting Expert module

This commit is contained in:
aspangaro 2014-09-03 07:22:59 +02:00
parent e4f51d8f7a
commit 9d08f4c5f5
7 changed files with 66 additions and 69 deletions

View File

@ -22,21 +22,12 @@
* \brief List accounting account
*/
// Dolibarr environment
$res = @include ("../main.inc.php");
if (! $res && file_exists("../main.inc.php"))
$res = @include ("../main.inc.php");
if (! $res && file_exists("../../main.inc.php"))
$res = @include ("../../main.inc.php");
if (! $res && file_exists("../../../main.inc.php"))
$res = @include ("../../../main.inc.php");
if (! $res)
die("Include of main fails");
require '../../main.inc.php';
// Class
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
dol_include_once("/accountancy/class/accountingaccount.class.php");
dol_include_once("/accountancy/class/html.formventilation.class.php");
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php';
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/html.formventilation.class.php';
// Langs
$langs->load("compta");

View File

@ -22,20 +22,12 @@
* \ingroup Accounting Expert
* \brief Card accounting account
*/
$res = @include ("../main.inc.php");
if (! $res && file_exists("../main.inc.php"))
$res = @include ("../main.inc.php");
if (! $res && file_exists("../../main.inc.php"))
$res = @include ("../../main.inc.php");
if (! $res && file_exists("../../../main.inc.php"))
$res = @include ("../../../main.inc.php");
if (! $res)
die("Include of main fails");
require '../../main.inc.php';
// Class
// Class
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
dol_include_once("/accountancy/class/accountingaccount.class.php");
dol_include_once("/accountancy/class/html.formventilation.class.php");
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php';
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/html.formventilation.class.php';
// Langs
$langs->load("bills");
@ -53,7 +45,8 @@ if (!$user->admin)
$accounting = new AccountingAccount($db);
// Action
if ($action == 'add') {
if ($action == 'add')
{
$sql = 'SELECT pcg_version FROM ' . MAIN_DB_PREFIX . 'accounting_system WHERE rowid=' . $conf->global->CHARTOFACCOUNTS;
dol_syslog('accountancy/admin/card.php:: $sql=' . $sql);
@ -82,7 +75,9 @@ if ($action == 'add') {
}
}
Header("Location: account.php");
} elseif ($action == 'edit') {
}
else if ($action == 'edit')
{
if (! GETPOST('cancel', 'alpha')) {
$result = $accounting->fetch($id);
@ -111,8 +106,9 @@ if ($action == 'add') {
header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $id);
exit();
}
} else if ($action == 'delete') {
}
else if ($action == 'delete')
{
$result = $accounting->fetch($id);
if (! empty($accounting->id)) {
@ -137,7 +133,8 @@ llxheader('', $langs->trans('AccountAccounting'));
$form = new Form($db);
$htmlacc = new FormVentilation($db);
if ($action == 'create') {
if ($action == 'create')
{
print_fiche_titre($langs->trans('NewAccount'));
print '<form name="add" action="' . $_SERVER["PHP_SELF"] . '" method="POST">' . "\n";
@ -169,16 +166,19 @@ if ($action == 'create') {
print '<input class="button" type="submit" name="cancel" value="' . $langs->trans("Cancel") . '"></center';
print '</form>';
} else if ($id) {
}
else if ($id)
{
$rowid = $id;
$account = $accounting->fetch($rowid);
if ($account > 0) {
dol_htmloutput_mesg($mesg);
$head = account_prepare_head($accounting);
$head = accounting_prepare_head($accounting);
if ($action == 'update') {
if ($action == 'update')
{
// WYSIWYG Editor
$htmlacc = new FormVentilation($db);
@ -224,7 +224,9 @@ if ($action == 'create') {
print '</form>';
print '</div>';
} else {
}
else
{
$linkback = '<a href="../admin/account.php">' . $langs->trans("BackToChartofaccounts") . '</a>';
dol_fiche_head($head, 'card', $langs->trans('AccountAccounting'), 0, 'billr');
@ -268,8 +270,8 @@ if ($action == 'create') {
print '</div>';
/*
* Barre d'actions
*/
* Barre d'actions
*/
print '<div class="tabsAction">';
@ -287,7 +289,9 @@ if ($action == 'create') {
print '</div>';
}
} else {
}
else
{
dol_print_error($db);
}
}

View File

@ -97,7 +97,7 @@ $form = new Form($db);
print_fiche_titre($langs->trans('ConfigAccountingExpert'));
$head = admin_account_prepare_head(null);
$head = admin_accounting_prepare_head(null);
dol_fiche_head($head, 'export', $langs->trans("Configuration"), 0, 'cron');

View File

@ -26,19 +26,10 @@
* \brief Setup page to configure accounting expert module
*/
// Dolibarr environment
$res = @include ("../main.inc.php");
if (! $res && file_exists("../main.inc.php"))
$res = @include ("../main.inc.php");
if (! $res && file_exists("../../main.inc.php"))
$res = @include ("../../main.inc.php");
if (! $res && file_exists("../../../main.inc.php"))
$res = @include ("../../../main.inc.php");
if (! $res)
die("Include of main fails");
require '../../main.inc.php';
// Class
dol_include_once("/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");
@ -157,7 +148,7 @@ $form = new Form($db);
print_fiche_titre($langs->trans('ConfigAccountingExpert'));
$head = admin_account_prepare_head($accounting);
$head = admin_accounting_prepare_head($accounting);
dol_fiche_head($head, 'general', $langs->trans("Configuration"), 0, 'cron');
@ -264,6 +255,7 @@ foreach ($list as $key)
print '</td></tr>';
}
$var = ! $var;
print "<tr " . $bc[$var] . ">";
print '<td width="80%">' . $langs->trans("ACCOUNTING_LIST_SORT_VENTILATION_TODO") . '</td>';
if (! empty($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_TODO)) {
@ -277,6 +269,7 @@ if (! empty($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_TODO)) {
}
print '</tr>';
$var = ! $var;
print "<tr " . $bc[$var] . ">";
print '<td width="80%">' . $langs->trans("ACCOUNTING_LIST_SORT_VENTILATION_DONE") . '</td>';
if (! empty($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_DONE)) {

View File

@ -91,7 +91,7 @@ $form = new Form($db);
print_fiche_titre($langs->trans('ConfigAccountingExpert'));
$head = admin_account_prepare_head(null);
$head = admin_accounting_prepare_head(null);
dol_fiche_head($head, 'journal', $langs->trans("Configuration"), 0, 'cron');

View File

@ -43,11 +43,12 @@ class AccountingAccount
var $active;
/**
* \brief Constructeur de la classe
* \param DB handler acces base de donnees
* \param id id compte (0 par defaut)
*/
function __construct($db, $rowid = '') {
* Constructor
*
* @param DoliDB $db Database handler
*/
function __construct($db, $rowid = '')
{
$this->db = $db;
if ($rowid != '')
@ -57,7 +58,8 @@ class AccountingAccount
/**
* \brief Load record in memory
*/
function fetch($rowid = null, $account_number = null) {
function fetch($rowid = null, $account_number = null)
{
if ($rowid || $account_number) {
$sql = "SELECT * FROM " . MAIN_DB_PREFIX . "accountingaccount WHERE ";
if ($rowid) {
@ -96,7 +98,8 @@ class AccountingAccount
* \brief insert line in accountingaccount
* \param user utilisateur qui effectue l'insertion
*/
function create($user, $notrigger = 0) {
function create($user, $notrigger = 0)
{
global $conf, $langs;
$error = 0;
@ -195,7 +198,8 @@ class AccountingAccount
* @param User $user update
* @return int if KO, >0 if OK
*/
function update($user) {
function update($user)
{
global $langs;
$this->db->begin();
@ -230,7 +234,8 @@ class AccountingAccount
* @param User $user update
* @return int if KO, >0 if OK
*/
function checkUsage() {
function checkUsage()
{
global $langs;
$sql = "(SELECT fk_code_ventilation FROM " . MAIN_DB_PREFIX . "facturedet";
@ -259,11 +264,12 @@ class AccountingAccount
/**
* Delete object in database
*
* @param User $user that deletes
* @param int $notrigger triggers after, 1=disable triggers
* @return int <0 if KO, >0 if OK
*/
function delete($user, $notrigger = 0) {
* @param User $user User object of making delete
* @param int $notrigger 1=Disable all triggers
* @return int
*/
function delete($user, $notrigger = 0)
{
global $conf, $langs;
$error = 0;
@ -281,7 +287,7 @@ class AccountingAccount
// // Call triggers
// include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
// $interface=new Interfaces($this->db);
// $result=$interface->run_triggers('MYOBJECT_DELETE',$this,$user,$langs,$conf);
// $result=$interface->run_triggers('ACCOUNTANCY_ACOUNT_DELETE',$this,$user,$langs,$conf);
// if ($result < 0) { $error++; $this->errors=$interface->errors; }
// // End call triggers
}
@ -322,7 +328,8 @@ class AccountingAccount
* @param int $id of record
* @return void
*/
function info($id) {
function info($id)
{
$sql = 'SELECT a.rowid, a.datec, a.fk_user_author, a.fk_user_modif, a.tms';
$sql .= ' FROM ' . MAIN_DB_PREFIX . 'accountingaccount as a';
$sql .= ' WHERE a.rowid = ' . $id;
@ -359,7 +366,8 @@ class AccountingAccount
* @param User $user update
* @return int if KO, >0 if OK
*/
function account_desactivate($id) {
function account_desactivate($id)
{
global $langs;
$result = $this->checkUsage();
@ -393,7 +401,8 @@ class AccountingAccount
* @param User $user update
* @return int if KO, >0 if OK
*/
function account_activate($id) {
function account_activate($id)
{
global $langs;
$this->db->begin();

View File

@ -501,7 +501,6 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu
$newmenu->add("/admin/modules.php?mainmenu=home", $langs->trans("Modules").$warnpicto,1);
$newmenu->add("/admin/menus.php?mainmenu=home", $langs->trans("Menus"),1);
$newmenu->add("/admin/ihm.php?mainmenu=home", $langs->trans("GUISetup"),1);
$newmenu->add("/accountancy/admin/account.php?mainmenu=home", $langs->trans("Chartofaccounts"),1);
$newmenu->add("/admin/fiscalyear.php?mainmenu=home", $langs->trans("Fiscalyear"),1);
if (! in_array($langs->defaultlang,array('en_US','en_GB','en_NZ','en_AU','fr_FR','fr_BE','es_ES','ca_ES')))
{
@ -515,6 +514,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu
$newmenu->add("/admin/mails.php?mainmenu=home", $langs->trans("Emails"),1);
$newmenu->add("/admin/sms.php?mainmenu=home", $langs->trans("SMS"),1);
$newmenu->add("/admin/dict.php?mainmenu=home", $langs->trans("Dictionary"),1);
if (! empty($conf->accounting->enabled)) $newmenu->add("/accountancy/admin/account.php?mainmenu=home", $langs->trans("Chartofaccounts"),1);
$newmenu->add("/admin/const.php?mainmenu=home", $langs->trans("OtherSetup"),1);
}