Fix: debug of accountancy module

This commit is contained in:
Laurent Destailleur 2014-09-09 09:46:57 +02:00
parent 2fb806bfc2
commit 9e2a0cb671
8 changed files with 201 additions and 196 deletions

View File

@ -16,12 +16,12 @@
*/
/**
* \file htdocs/admin/fiscalyear.php
* \file htdocs/accountancy/admin/fiscalyear.php
* \ingroup fiscal year
* \brief Setup page to configure fiscal year
*/
require '../main.inc.php';
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/fiscalyear.class.php';
@ -55,6 +55,8 @@ $object = new Fiscalyear($db);
* View
*/
$max=100;
$form = new Form($db);
llxHeader('',$title);
@ -68,9 +70,6 @@ $sql.= " FROM ".MAIN_DB_PREFIX."accounting_fiscalyear as f";
$sql.= " WHERE f.entity = ".$conf->entity;
$result = $db->query($sql);
$max=10;
if ($result)
{
$var=false;
@ -85,7 +84,7 @@ if ($result)
print '<td>'.$langs->trans("Label").'</td>';
print '<td>'.$langs->trans("DateStart").'</td>';
print '<td>'.$langs->trans("DateEnd").'</td>';
print '<td>'.$langs->trans("Statut").'</td>';
print '<td align="right">'.$langs->trans("Statut").'</td>';
print '</tr>';
if ($num)
@ -102,7 +101,7 @@ if ($result)
print '<td align="left">'.$obj->label.'</td>';
print '<td align="left">'.dol_print_date($db->jdate($obj->date_start),'day').'</td>';
print '<td align="left">'.dol_print_date($db->jdate($obj->date_end),'day').'</td>';
print '<td>'.$fiscalyearstatic->LibStatut($obj->statut,5).'</td>';
print '<td align="right">'.$fiscalyearstatic->LibStatut($obj->statut,5).'</td>';
print '</tr>';
$var=!$var;
$i++;
@ -115,7 +114,6 @@ if ($result)
}
print '</table>';
print '</form>';
}
else
{

View File

@ -16,11 +16,11 @@
*/
/**
* \file htdocs/admin/fiscalyear_card.php
* \file htdocs/accountancy/admin/fiscalyear_card.php
* \brief Page to show a fiscal year
*/
require '../main.inc.php';
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/fiscalyear.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/fiscalyear.class.php';
@ -51,6 +51,7 @@ $object = new Fiscalyear($db);
$date_start=dol_mktime(0,0,0,GETPOST('fiscalyearmonth','int'),GETPOST('fiscalyearday','int'),GETPOST('fiscalyearyear','int'));
$date_end=dol_mktime(0,0,0,GETPOST('fiscalyearendmonth','int'),GETPOST('fiscalyearendday','int'),GETPOST('fiscalyearendyear','int'));
/*
* Actions
*/
@ -75,8 +76,6 @@ else if ($action == 'add')
{
$error=0;
$db->begin();
$object->date_start = $date_start;
$object->date_end = $date_end;
$object->label = GETPOST('label','alpha');
@ -96,21 +95,27 @@ else if ($action == 'add')
if (! $error)
{
$id = $object->create($user);
$db->begin();
$id = $object->create($user);
if ($id > 0)
{
$db->commit();
header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $id);
exit;
}
else
{
setEventMessage($object->error, 'errors');
{
$db->rollback();
setEventMessage($object->error, 'errors');
$action='create';
}
}
else
{
{
$action='create';
}
}
@ -207,11 +212,11 @@ else if ($id)
{
$head = fiscalyear_prepare_head($object);
dol_fiche_head($head, 'card', $langs->trans("FiscalYearCard"), 0, 'cron');
if ($action == 'edit')
{
print '<form name="update" action="' . $_SERVER["PHP_SELF"] . '" method="POST">' . "\n";
dol_fiche_head($head, 'card', $langs->trans("FiscalYearCard"), 0, 'cron');
print '<form name="update" action="' . $_SERVER["PHP_SELF"] . '" method="POST">' . "\n";
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="update">';
print '<input type="hidden" name="id" value="'.$id.'">';
@ -252,7 +257,7 @@ else if ($id)
print '</form>';
print '</div>';
dol_fiche_end();
}
else
{
@ -265,7 +270,9 @@ else if ($id)
}
print '<table class="border" width="100%">';
dol_fiche_head($head, 'card', $langs->trans("FiscalYearCard"), 0, 'cron');
print '<table class="border" width="100%">';
$linkback = '<a href="'.DOL_URL_ROOT.'/admin/fiscalyear.php">'.$langs->trans("BackToList").'</a>';
@ -300,9 +307,9 @@ else if ($id)
// Statut
print '<tr><td>'.$langs->trans("Status").'</td><td colspan="2">'.$object->getLibStatut(4).'</td></tr>';
print "</table><br>";
print "</table>";
print '</div>';
dol_fiche_end();
/*
* Barre d'actions

View File

@ -16,11 +16,11 @@
*/
/**
* \file htdocs/admin/fiscalyear_card.php
* \file htdocs/accountancy/admin/fiscalyear_card.php
* \brief Page to show info of a fiscal year
*/
require '../main.inc.php';
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/fiscalyear.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';

View File

@ -34,7 +34,7 @@ require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/report.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php');
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
require_once DOL_DOCUMENT_ROOT.'/societe/class/client.class.php';
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php';
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php';

View File

@ -88,7 +88,7 @@ class Fiscalyear
$sql.= ") VALUES (";
$sql.= " '".$this->label."'";
$sql.= ", '".$this->db->idate($this->date_start)."'";
$sql.= ", '".$this->db->idate($this->date_end)."'";
$sql.= ", ".($this->date_end ? "'".$this->db->idate($this->date_end)."'":"null");
$sql.= ", ".$this->statut;
$sql.= ", ".$conf->entity;
$sql.= ", '".$this->db->idate($now)."'";
@ -109,14 +109,14 @@ class Fiscalyear
}
else
{
$this->error=$this->db->error();
$this->error=$this->db->lasterror();
$this->db->rollback();
return $result;
}
}
else
{
$this->error=$this->db->error()." sql=".$sql;
$this->error=$this->db->lasterror()." sql=".$sql;
$this->db->rollback();
return -1;
}
@ -141,12 +141,12 @@ class Fiscalyear
$this->db->begin();
$sql = "UPDATE ".MAIN_DB_PREFIX."accounting_fiscalyear ";
$sql = "UPDATE ".MAIN_DB_PREFIX."accounting_fiscalyear";
$sql .= " SET label = '".$this->label."'";
$sql .= ", date_start = '".$this->db->idate($this->date_start)."'";
$sql .= ", date_end = '".$this->db->idate($this->date_end)."'";
$sql .= ", date_end = ".($this->date_end ? "'".$this->db->idate($this->date_end)."'" : "null");
$sql .= ", statut = '".$this->statut."'";
$sql .= ", datec = " . ($this->datec != '' ? $this->db->idate($this->datec) : 'null');
$sql .= ", datec = " . ($this->datec != '' ? "'".$this->db->idate($this->datec)."'" : 'null');
$sql .= ", fk_user_modif = " . $user->id;
$sql .= " WHERE rowid = ".$this->id;
@ -160,6 +160,7 @@ class Fiscalyear
else
{
$this->error=$this->db->lasterror();
dol_syslog($this->error, LOG_ERR);
$this->db->rollback();
return -1;
}
@ -194,7 +195,7 @@ class Fiscalyear
}
else
{
$this->error=$this->db->error();
$this->error=$this->db->lasterror();
return -1;
}
}
@ -220,7 +221,7 @@ class Fiscalyear
}
else
{
$this->error=$this->db->error();
$this->error=$this->db->lasterror();
$this->db->rollback();
return -1;
}

View File

@ -34,7 +34,7 @@ function fiscalyear_prepare_head($object)
$h = 0;
$head = array();
$head[$h][0] = DOL_URL_ROOT . '/admin/fiscalyear_card.php?id=' . $object->id;
$head[$h][0] = DOL_URL_ROOT . '/accountancy/admin/fiscalyear_card.php?id=' . $object->id;
$head[$h][1] = $langs->trans("Card");
$head[$h][2] = 'card';
$h++;
@ -45,7 +45,7 @@ function fiscalyear_prepare_head($object)
// $this->tabs = array('entity:-tabname); to remove a tab
complete_head_from_modules($conf,$langs,$object,$head,$h,'fiscalyear');
$head[$h][0] = DOL_URL_ROOT . '/admin/fiscalyear_info.php?id=' . $object->id;
$head[$h][0] = DOL_URL_ROOT . '/accountancy/admin/fiscalyear_info.php?id=' . $object->id;
$head[$h][1] = $langs->trans("Info");
$head[$h][2] = 'info';
$h++;

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("/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')))
{
if (empty($leftmenu) || $leftmenu=="setup") $newmenu->add("/admin/translation.php", $langs->trans("Translation"),1);
@ -875,6 +874,8 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu
$newmenu->add("/accountancy/bookkeeping/list.php?leftmenu=bookkeeping",$langs->trans("Bookkeeping"),0,$user->rights->accounting->mouvements->lire, '', $mainmenu, 'bookeeping');
if (empty($leftmenu) || $leftmenu=="bookeeping") $newmenu->add("/accountancy/bookkeeping/listbyyear.php",$langs->trans("ByYear"),1,$user->rights->accounting->mouvements->lire);
if (empty($leftmenu) || $leftmenu=="bookeeping") $newmenu->add("/accountancy/bookkeeping/balancebymonth.php.php",$langs->trans("AccountBalanceByMonth"),1,$user->rights->accounting->mouvements->lire);
$newmenu->add("/accountancy/admin/fiscalyear.php?mainmenu=accountancy", $langs->trans("Fiscalyear"),0,$user->rights->accounting->close, '', $mainmenu, 'fiscalyear');
}
// Rapports

View File

@ -19,7 +19,7 @@
*/
/**
* \file accountingex/core/modules/modAccountingExpert.class.php
* \file accountingex/core/modules/modAccounting.class.php
* \ingroup Accounting Expert
* \brief Module to activate Accounting Expert module
*/
@ -46,7 +46,7 @@ class modAccounting extends DolibarrModules
$this->family = "financial";
// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
$this->name = preg_replace('/^mod/i', '', get_class($this));
$this->description = "Advanced manage of accounting";
$this->description = "Advanced accounting management";
// Possible values for version are: 'development', 'experimental', 'dolibarr' or version
$this->version = 'development';
@ -59,119 +59,109 @@ class modAccounting extends DolibarrModules
// $this->triggers = 1;
// Data directories to create when module is enabled
$this->dirs = array (
'/accountingex/temp'
);
$this->dirs = array('/accounting/temp');
// Config pages
$this->config_page_url = array('index.php@accountancy');
// Dependencies
$this->depends = array ("modFacture","modBanque","modTax"); // List of modules id that must be enabled if this module is enabled
$this->requiredby = array (); // List of modules id to disable if this one is disabled
$this->conflictwith = array ("modComptabilite"); // List of modules are in conflict with this module
$this->phpmin = array (
5,
2
); // Minimum version of PHP required by module
$this->need_dolibarr_version = array (
3,
6
); // Minimum version of Dolibarr required by module
$this->langfiles = array (
"accountancy"
);
$this->depends = array("modFacture","modBanque","modTax"); // List of modules id that must be enabled if this module is enabled
$this->requiredby = array(); // List of modules id to disable if this one is disabled
$this->conflictwith = array("modComptabilite"); // List of modules are in conflict with this module
$this->phpmin = array(5, 2); // Minimum version of PHP required by module
$this->need_dolibarr_version = array(3, 6); // Minimum version of Dolibarr required by module
$this->langfiles = array("accountancy");
// Constants
$this->const = array ();
$this->const[1] = array (
$this->const = array();
$this->const[1] = array(
"MAIN_COMPANY_CODE_ALWAYS_REQUIRED",
"chaine",
"1",
"With this constants on, third party code is always required whatever is numbering module behaviour"
);
$this->const[2] = array (
$this->const[2] = array(
"MAIN_BANK_ACCOUNTANCY_CODE_ALWAYS_REQUIRED",
"chaine",
"1",
"With this constants on, bank account number is always required"
);
$this->const[1] = array (
$this->const[1] = array(
"ACCOUNTING_SEPARATORCSV",
"string",
","
);
$this->const[2] = array (
$this->const[2] = array(
"ACCOUNTING_ACCOUNT_SUSPENSE",
"chaine",
"471"
);
$this->const[3] = array (
$this->const[3] = array(
"ACCOUNTING_SELL_JOURNAL",
"chaine",
"VTE"
);
$this->const[4] = array (
$this->const[4] = array(
"ACCOUNTING_PURCHASE_JOURNAL",
"chaine",
"ACH"
);
$this->const[5] = array (
$this->const[5] = array(
"ACCOUNTING_SOCIAL_JOURNAL",
"chaine",
"SOC"
);
$this->const[6] = array (
$this->const[6] = array(
"ACCOUNTING_CASH_JOURNAL",
"chaine",
"CAI"
);
$this->const[7] = array (
$this->const[7] = array(
"ACCOUNTING_MISCELLANEOUS_JOURNAL",
"chaine",
"OD"
);
$this->const[8] = array (
$this->const[8] = array(
"ACCOUNTING_BANK_JOURNAL",
"chaine",
"BQ"
); // Deprecated Move into llx_bank_account
$this->const[9] = array (
$this->const[9] = array(
"ACCOUNTING_ACCOUNT_TRANSFER_CASH",
"chaine",
"58"
);
$this->const[10] = array (
$this->const[10] = array(
"CHARTOFACCOUNTS",
"chaine",
"2"
);
$this->const[11] = array (
$this->const[11] = array(
"ACCOUNTING_MODELCSV",
"chaine",
"0"
);
$this->const[12] = array (
$this->const[12] = array(
"ACCOUNTING_LENGTH_GACCOUNT",
"chaine",
""
);
$this->const[13] = array (
$this->const[13] = array(
"ACCOUNTING_LENGTH_AACCOUNT",
"chaine",
""
);
$this->const[14] = array (
$this->const[14] = array(
"ACCOUNTING_LIMIT_LIST_VENTILATION",
"chaine",
"50"
);
$this->const[15] = array (
$this->const[15] = array(
"ACCOUNTING_LIST_SORT_VENTILATION_TODO",
"yesno",
"1"
);
$this->const[16] = array (
$this->const[16] = array(
"ACCOUNTING_LIST_SORT_VENTILATION_DONE",
"yesno",
"1"
@ -181,18 +171,18 @@ class modAccounting extends DolibarrModules
$this->tabs = array();
// Css
$this->module_parts = array ();
$this->module_parts = array();
// Boxes
$this->boxes = array ();
$this->boxes = array();
// Permissions
$this->rights_class = 'accounting';
$this->rights = array (); // Permission array used by this module
$this->rights = array(); // Permission array used by this module
$r = 0;
$this->rights[$r][0] = 50401;
$this->rights[$r][0] = 50401; // TODO Goal of this permission compared to others ???
$this->rights[$r][1] = 'Access_accountancy';
$this->rights[$r][2] = 'r';
$this->rights[$r][3] = 0;
@ -240,8 +230,16 @@ class modAccounting extends DolibarrModules
$this->rights[$r][5] = 'lire';
$r++;
$this->rights[$r][0] = 50430;
$this->rights[$r][1] = 'Define and close a fiscal year';
$this->rights[$r][2] = 'r';
$this->rights[$r][3] = 0;
$this->rights[$r][4] = 'fiscalyear';
$this->rights[$r][5] = '';
$r++;
// Main menu entries
$this->menus = array ();
$this->menus = array();
$r = 0;
}