Commit 6907670946c257824d420f827dd8e5547f1d2789

Authored by Darkjeff
2 parents c1d3732b e170a7ce
Exists in 3.5 and in 1 other branch 3.6

Merge pull request #93 from FHenry/3.5

Big Code Review and factoring
Showing 41 changed files with 5263 additions and 7246 deletions   Show diff stats
ChangeLog
... ... @@ -8,6 +8,7 @@ New: Add cash journal
8 8 New: Possibility of defining the separator in the export csv
9 9 New: Possibility of defining the length of account
10 10 Add: CSV Export Model - CEGID Expert
  11 +New: Review all code
11 12  
12 13 ***** ChangeLog for 3.4.x compared to none *****
13 14 First release of this module
14 15 \ No newline at end of file
... ...
README.txt
... ... @@ -2,6 +2,7 @@
2 2 * Accounting Expert MODULE
3 3 * by Olivier Geffroy (Jeffinfo)
4 4 * And Alexandre Spangaro
  5 +* And Florian Henry
5 6 *
6 7 * Version 3.5 alpha - Revision 1.0.0
7 8 * for Dolibarr >= 3.5.x
... ...
accountingex/admin/about.php
1 1 <?php
2 2 /* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
3 3 * Copyright (C) 2013-2014 Alexandre Spangaro <alexandre.spangaro@gmail.com>
  4 + * Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro>
4 5 *
5 6 * This program is free software; you can redistribute it and/or modify
6 7 * it under the terms of the GNU General Public License as published by
... ... @@ -18,30 +19,36 @@
18 19 */
19 20  
20 21 /**
21   - \file accountingex/admin/about.php
22   - \ingroup Accounting Expert
23   - \brief Page administration du module
24   -*/
  22 + * \file accountingex/admin/about.php
  23 + * \ingroup Accounting Expert
  24 + * \brief Page administration du module
  25 + */
25 26  
26 27 // Dolibarr environment
27   -$res=@include("../main.inc.php");
28   -if (! $res && file_exists("../main.inc.php")) $res=@include("../main.inc.php");
29   -if (! $res && file_exists("../../main.inc.php")) $res=@include("../../main.inc.php");
30   -if (! $res && file_exists("../../../main.inc.php")) $res=@include("../../../main.inc.php");
31   -if (! $res) die("Include of main fails");
32   -
33   -// Class
  28 +$res = @include ("../main.inc.php");
  29 +if (! $res && file_exists("../main.inc.php"))
  30 + $res = @include ("../main.inc.php");
  31 +if (! $res && file_exists("../../main.inc.php"))
  32 + $res = @include ("../../main.inc.php");
  33 +if (! $res && file_exists("../../../main.inc.php"))
  34 + $res = @include ("../../../main.inc.php");
  35 +if (! $res)
  36 + die("Include of main fails");
  37 +
  38 + // Class
34 39 dol_include_once("/core/lib/admin.lib.php");
35 40 dol_include_once("/accountingex/core/lib/account.lib.php");
36 41  
37 42 $langs->load('main');
38 43 $langs->load('accountingex@accountingex');
39 44  
40   -// Securité accès client
41   -if ($user->societe_id > 0) accessforbidden();
42   -if (!$user->rights->accountingex->admin) accessforbidden();
43   -
44   -/*
  45 +// Security check
  46 +if ($user->societe_id > 0)
  47 + accessforbidden();
  48 +if (! $user->rights->accountingex->admin)
  49 + accessforbidden();
  50 +
  51 + /*
45 52 * View
46 53 */
47 54  
... ... @@ -50,12 +57,12 @@ llxHeader();
50 57 print_fiche_titre($langs->trans('ConfigAccountingExpert'));
51 58  
52 59 $head = admin_account_prepare_head(null);
53   -
54   -dol_fiche_head($head,'about',$langs->trans("Configuration"),0,'cron');
  60 +
  61 +dol_fiche_head($head, 'about', $langs->trans("Configuration"), 0, 'cron');
55 62  
56 63 print '<table class="noborder" width="100%">';
57 64  
58   -print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("Authors").'</td>';
  65 +print '<tr class="liste_titre"><td colspan="2">' . $langs->trans("Authors") . '</td>';
59 66 print '</tr>';
60 67  
61 68 // Alexandre Spangaro
... ... @@ -76,10 +83,15 @@ print &#39;&lt;a target=&quot;_blank&quot; href=&quot;http://twiter.com/elarifr&quot;&gt;&lt;img src=&quot;../img/twee
76 83 print '<a target="_blank" href="https://plus.google.com/109875408706351786851"><img src="../img/google+.png" width="20"></a>';
77 84 print '</td></tr>';
78 85  
79   -
80   -dol_htmloutput_mesg($mesg);
  86 +//Florian HENRY - Open-concept.pro
  87 +print '<tr><td><img src="http://demo.open-concept.pro/prestashop/img/logo.jpg"></td>';
  88 +print '<td><b>Florian Henry</b>&nbsp;-&nbsp;Intégrateur/développeur Solution Open-Source';
  89 +print '<br>Florian HENRY - Open-Concept.pro <BR> florian.henry@open-concept.pro <BR> +33 6 03 76 48 07';
  90 +print '<br><a target="_blank" href="http://www.open-concept.pro">http://www.open-concept.pro</a>';
  91 +print '<br><br><a target="_blank" href="http://twitter.com/_open_concept_"><img src="../img/tweet.png" width="20"></a>';
  92 +print '</td></tr>';
81 93  
82   -$db->close();
  94 +dol_htmloutput_mesg($mesg);
83 95  
84 96 llxFooter();
85   -?>
86 97 \ No newline at end of file
  98 +$db->close();
87 99 \ No newline at end of file
... ...
accountingex/admin/account.php
1 1 <?php
2   -/* Copyright (C) 2002-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3   - * Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
4   - * Copyright (C) 2013-2014 Alexandre Spangaro <alexandre.spangaro@gmail.com>
  2 +/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
  3 + * Copyright (C) 2013-2014 Alexandre Spangaro <alexandre.spangaro@gmail.com>
5 4 *
6 5 * This program is free software; you can redistribute it and/or modify
7 6 * it under the terms of the GNU General Public License as published by
... ... @@ -18,75 +17,84 @@
18 17 */
19 18  
20 19 /**
21   - * \file accountingex/admin/account.php
22   - * \ingroup Accounting Expert
23   - * \brief List accounting account
  20 + * \file accountingex/admin/account.php
  21 + * \ingroup Accounting Expert
  22 + * \brief List accounting account
24 23 */
25 24  
26 25 // Dolibarr environment
27   -$res=@include("../main.inc.php");
28   -if (! $res && file_exists("../main.inc.php")) $res=@include("../main.inc.php");
29   -if (! $res && file_exists("../../main.inc.php")) $res=@include("../../main.inc.php");
30   -if (! $res && file_exists("../../../main.inc.php")) $res=@include("../../../main.inc.php");
31   -if (! $res) die("Include of main fails");
  26 +$res = @include ("../main.inc.php");
  27 +if (! $res && file_exists("../main.inc.php"))
  28 + $res = @include ("../main.inc.php");
  29 +if (! $res && file_exists("../../main.inc.php"))
  30 + $res = @include ("../../main.inc.php");
  31 +if (! $res && file_exists("../../../main.inc.php"))
  32 + $res = @include ("../../../main.inc.php");
  33 +if (! $res)
  34 + die("Include of main fails");
32 35  
33   -// Class
  36 + // Class
34 37 dol_include_once("/accountingex/core/lib/account.lib.php");
35 38 dol_include_once("/accountingex/class/accountingaccount.class.php");
36 39 dol_include_once("/accountingex/class/html.formventilation.class.php");
37 40  
38 41 // Langs
39   -$langs->load ("compta");
40   -$langs->load ("accountingex@accountingex");
  42 +$langs->load("compta");
  43 +$langs->load("accountingex@accountingex");
41 44  
42 45 $mesg = '';
43 46 $action = GETPOST('action');
44   -$id = GETPOST ( 'id', 'int' );
45   -$rowid = GETPOST ( 'rowid', 'int' );
  47 +$id = GETPOST('id', 'int');
  48 +$rowid = GETPOST('rowid', 'int');
46 49  
47 50 // Security check
48   -if ($user->societe_id > 0) accessforbidden();
49   -if (!$user->rights->accountingex->admin) accessforbidden();
  51 +if ($user->societe_id > 0)
  52 + accessforbidden();
  53 +if (! $user->rights->accountingex->admin)
  54 + accessforbidden();
50 55  
51   -$sortfield = GETPOST("sortfield",'alpha');
52   -$sortorder = GETPOST("sortorder",'alpha');
  56 +$sortfield = GETPOST("sortfield", 'alpha');
  57 +$sortorder = GETPOST("sortorder", 'alpha');
53 58 $limit = $conf->liste_limit;
54   -$page = GETPOST("page",'int');
55   -if ($page == -1) { $page = 0; }
  59 +$page = GETPOST("page", 'int');
  60 +if ($page == - 1) {
  61 + $page = 0;
  62 +}
56 63 $offset = $conf->liste_limit * $page;
57 64 $pageprev = $page - 1;
58 65 $pagenext = $page + 1;
59   -if (! $sortfield) $sortfield = "aa.account_number";
60   -if (! $sortorder) $sortorder = "ASC";
  66 +if (! $sortfield)
  67 + $sortfield = "aa.account_number";
  68 +if (! $sortorder)
  69 + $sortorder = "ASC";
61 70  
62 71 if ($action == 'delete') {
63   - $formconfirm = $html->formconfirm ( $_SERVER ["PHP_SELF"] . '?id=' . $id, $langs->trans ( 'DeleteAccount' ), $langs->trans ( 'ConfirmDeleteAccount' ), 'confirm_delete', '', 0, 1 );
  72 + $formconfirm = $html->formconfirm($_SERVER ["PHP_SELF"] . '?id=' . $id, $langs->trans('DeleteAccount'), $langs->trans('ConfirmDeleteAccount'), 'confirm_delete', '', 0, 1);
64 73 print $formconfirm;
65 74 }
66 75  
67 76 $accounting = new AccountingAccount($db);
68   -
  77 +
69 78 if ($action == 'disable') {
70   - $accounting = $accounting->fetch ( $id );
71   - if (!empty($accounting->id)) {
72   - $result = $accounting->account_desactivate ( $user );
  79 + $accounting = $accounting->fetch($id);
  80 + if (! empty($accounting->id)) {
  81 + $result = $accounting->account_desactivate($user);
73 82 }
74 83  
75 84 $action = 'update';
76 85 if ($result < 0) {
77   - setEventMessage ( $accounting->error, 'errors' );
  86 + setEventMessage($accounting->error, 'errors');
78 87 }
79   -}
80   -else if ($action == 'enable') {
  88 +} else if ($action == 'enable') {
81 89  
82   - $accounting = $accounting->fetch ( $id );
83   -
84   - if (!empty($accounting->id)) {
85   - $result = $accounting->account_activate ( $user );
  90 + $accounting = $accounting->fetch($id);
  91 +
  92 + if (! empty($accounting->id)) {
  93 + $result = $accounting->account_activate($user);
86 94 }
87 95 $action = 'update';
88 96 if ($result < 0) {
89   - setEventMessage ( $accounting->error, 'errors' );
  97 + setEventMessage($accounting->error, 'errors');
90 98 }
91 99 }
92 100  
... ... @@ -100,116 +108,113 @@ $pcgver = $conf-&gt;global-&gt;CHARTOFACCOUNTS;
100 108  
101 109 $sql = "SELECT aa.rowid, aa.fk_pcg_version, aa.pcg_type, aa.pcg_subtype, aa.account_number, aa.account_parent , aa.label, aa.active ";
102 110 $sql .= " FROM " . MAIN_DB_PREFIX . "accountingaccount as aa, " . MAIN_DB_PREFIX . "accounting_system as asy";
103   -$sql .= " WHERE aa.fk_pcg_version = asy.pcg_version";
104   -$sql .= " AND asy.rowid = ".$pcgver;
  111 +$sql .= " WHERE aa.fk_pcg_version = asy.pcg_version";
  112 +$sql .= " AND asy.rowid = " . $pcgver;
105 113  
106   -if (strlen ( trim ( $_GET ["search_account"] ) )) {
  114 +if (strlen(trim($_GET ["search_account"]))) {
107 115 $sql .= " AND aa.account_number like '%" . $_GET ["search_account"] . "%'";
108 116 }
109   -if (strlen ( trim ( $_GET ["search_label"] ) )) {
  117 +if (strlen(trim($_GET ["search_label"]))) {
110 118 $sql .= " AND aa.label like '%" . $_GET ["search_label"] . "%'";
111 119 }
112   -if (strlen ( trim ( $_GET ["search_accountparent"] ) )) {
  120 +if (strlen(trim($_GET ["search_accountparent"]))) {
113 121 $sql .= " AND aa.account_parent like '%" . $_GET ["search_accountparent"] . "%'";
114 122 }
115   -if (strlen ( trim ( $_GET ["search_pcgtype"] ) )) {
  123 +if (strlen(trim($_GET ["search_pcgtype"]))) {
116 124 $sql .= " AND aa.pcg_type like '%" . $_GET ["search_pcgtype"] . "%'";
117 125 }
118   -if (strlen ( trim ( $_GET ["search_pcgsubtype"] ) )) {
  126 +if (strlen(trim($_GET ["search_pcgsubtype"]))) {
119 127 $sql .= " AND aa.pcg_subtype like '%" . $_GET ["search_pcgsubtype"] . "%'";
120 128 }
121   -$sql .= $db->order($sortfield,$sortorder);
  129 +
  130 +$sql .= $db->order($sortfield, $sortorder);
122 131 $sql .= $db->plimit($limit + 1, $offset);
123 132  
124   -dol_syslog('accountingex/admin/account.php:: $sql='.$sql);
  133 +dol_syslog('accountingex/admin/account.php:: $sql=' . $sql);
125 134 $result = $db->query($sql);
126 135  
127   -if ($result)
128   -{
  136 +if ($result) {
129 137 $num = $db->num_rows($result);
130   -
131   - print_barre_liste ($langs->trans('ListAccounts'), $page, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '',$num);
132   -
133   - $i = 0;
  138 +
  139 + print_barre_liste($langs->trans('ListAccounts'), $page, $_SERVER ["PHP_SELF"], '', $sortfield, $sortorder, '', $num);
  140 +
  141 + $i = 0;
134 142  
135 143 print '<form method="GET" action="' . $_SERVER ["PHP_SELF"] . '">';
136   -
  144 +
137 145 print '<br/>';
138   -
139   - print '<a class="butAction" href="./fiche.php?action=create">' . $langs->trans ( "Addanaccount" ) . '</a>';
140   - print '<a class="butAction" href="./importaccounts.php">' . $langs->trans ( "ImportAccount" ) . '</a>';
  146 +
  147 + print '<a class="butAction" href="./fiche.php?action=create">' . $langs->trans("Addanaccount") . '</a>';
  148 + print '<a class="butAction" href="./importaccounts.php">' . $langs->trans("ImportAccount") . '</a>';
141 149 print '<br/><br/>';
142 150  
143 151 print '<table class="noborder" width="100%">';
144 152 print '<tr class="liste_titre">';
145   - print_liste_field_titre($langs->trans("AccountNumber"), "account.php", "aa.account_number", "", $param, "", $sortfield, $sortorder );
146   - print_liste_field_titre($langs->trans("Label"), "account.php", "aa.label", "", $param, "", $sortfield, $sortorder );
147   - print_liste_field_titre($langs->trans("Accountparent"), "account.php", "aa.account_parent", "", $param, "", $sortfield, $sortorder );
148   - print_liste_field_titre($langs->trans("Pcgtype"), "account.php", "aa.pcg_type", "", $param, "", $sortfield, $sortorder );
149   - print_liste_field_titre($langs->trans("Pcgsubtype"), "account.php", "aa.pcg_subtype", "", $param, "", $sortfield, $sortorder );
150   - print_liste_field_titre($langs->trans("Active"), "account.php", "aa.active", "", $param, "", $sortfield, $sortorder );
151   - print_liste_field_titre( "&nbsp;" );
  153 + print_liste_field_titre($langs->trans("AccountNumber"), "account.php", "aa.account_number", "", $param, "", $sortfield, $sortorder);
  154 + print_liste_field_titre($langs->trans("Label"), "account.php", "aa.label", "", $param, "", $sortfield, $sortorder);
  155 + print_liste_field_titre($langs->trans("Accountparent"), "account.php", "aa.account_parent", "", $param, "", $sortfield, $sortorder);
  156 + print_liste_field_titre($langs->trans("Pcgtype"), "account.php", "aa.pcg_type", "", $param, "", $sortfield, $sortorder);
  157 + print_liste_field_titre($langs->trans("Pcgsubtype"), "account.php", "aa.pcg_subtype", "", $param, "", $sortfield, $sortorder);
  158 + print_liste_field_titre($langs->trans("Active"), "account.php", "aa.active", "", $param, "", $sortfield, $sortorder);
  159 + print_liste_field_titre("&nbsp;");
152 160 print '</tr>';
153 161  
154 162 print '<tr class="liste_titre">';
155   - print '<td class="liste_titre"><input type="text" class="flat" size="15" name="search_account" value="' . GETPOST ( "search_account" ) . '"></td>';
156   - print '<td class="liste_titre"><input type="text" class="flat" size="15" name="search_label" value="' . GETPOST ( "search_label" ) . '"></td>';
157   - print '<td class="liste_titre"><input type="text" class="flat" size="15" name="search_accountparent" value="' . GETPOST ( "search_accountparent" ) . '"></td>';
158   - print '<td class="liste_titre"><input type="text" class="flat" size="15" name="search_pcgtype" value="' . GETPOST ( "search_pcgtype" ) . '"></td>';
159   - print '<td class="liste_titre"><input type="text" class="flat" size="15" name="search_pcgsubtype" value="' . GETPOST ( "search_pcgsubtype" ) . '"></td>';
  163 + print '<td class="liste_titre"><input type="text" class="flat" size="15" name="search_account" value="' . GETPOST("search_account") . '"></td>';
  164 + print '<td class="liste_titre"><input type="text" class="flat" size="15" name="search_label" value="' . GETPOST("search_label") . '"></td>';
  165 + print '<td class="liste_titre"><input type="text" class="flat" size="15" name="search_accountparent" value="' . GETPOST("search_accountparent") . '"></td>';
  166 + print '<td class="liste_titre"><input type="text" class="flat" size="15" name="search_pcgtype" value="' . GETPOST("search_pcgtype") . '"></td>';
  167 + print '<td class="liste_titre"><input type="text" class="flat" size="15" name="search_pcgsubtype" value="' . GETPOST("search_pcgsubtype") . '"></td>';
160 168 print '<td class="liste_titre">&nbsp;</td>';
161 169 print '<td class="liste_titre" align="right">';
162   - print '<input type="image" class="liste_titre" src="' . DOL_URL_ROOT . '/theme/' . $conf->theme . '/img/search.png" name="button_search" value="' . dol_escape_htmltag ( $langs->trans ( "Search" ) ) . '" title="' . dol_escape_htmltag ( $langs->trans ( "Search" ) ) . '">';
  170 + print '<input type="image" class="liste_titre" src="' . DOL_URL_ROOT . '/theme/' . $conf->theme . '/img/search.png" name="button_search" value="' . dol_escape_htmltag($langs->trans("Search")) . '" title="' . dol_escape_htmltag($langs->trans("Search")) . '">';
163 171 print '</td>';
164 172 print '</tr>';
165 173  
166 174 $var = True;
167   - while ($i < min($num,$limit))
168   - {
169   - $obj = $db->fetch_object($resql);
170   -
171   - $var=!$var;
172   - print '<tr '.$bc[$var].'>';
173   - print '<td><a href="./fiche.php?id=' . $obj->rowid . '">' . $obj->account_number . '</td>';
  175 +
  176 + while ( $i < min($num, $limit) ) {
  177 + $obj = $db->fetch_object($resql);
  178 +
  179 + $var = ! $var;
  180 + print '<tr ' . $bc [$var] . '>';
  181 + print '<td><a href="./fiche.php?id=' . $obj->rowid . '">' . $obj->account_number . '</td>';
174 182 print '<td>' . $obj->label . '</td>';
175 183 print '<td>' . $obj->account_parent . '</td>';
176 184 print '<td>' . $obj->pcg_type . '</td>';
177 185 print '<td>' . $obj->pcg_subtype . '</td>';
178 186 print '<td>';
179   - if (empty ( $obj->active )) {
180   - print '<a href="' . $_SERVER ["PHP_SELF"] . '?id=' . $obj->rowid . '&action=enable">';
181   - print img_picto ( $langs->trans ( "Disabled" ), 'switch_off' );
182   - print '</a>';
  187 + if (empty($obj->active)) {
  188 + print '<a href="' . $_SERVER ["PHP_SELF"] . '?id=' . $obj->rowid . '&action=enable">';
  189 + print img_picto($langs->trans("Disabled"), 'switch_off');
  190 + print '</a>';
183 191 } else {
184   - print '<a href="' . $_SERVER ["PHP_SELF"] . '?id=' . $obj->rowid . '&action=disable">';
185   - print img_picto ( $langs->trans ( "Activated" ), 'switch_on' );
186   - print '</a>';
  192 + print '<a href="' . $_SERVER ["PHP_SELF"] . '?id=' . $obj->rowid . '&action=disable">';
  193 + print img_picto($langs->trans("Activated"), 'switch_on');
  194 + print '</a>';
187 195 }
188 196 print '</td>';
189 197  
190 198 print '<td>';
191 199 if ($user->rights->accountingex->admin) {
192 200 print '<a href="./fiche.php?action=update&id=' . $obj->rowid . '">';
193   - print img_edit ();
  201 + print img_edit();
194 202 print '</a>&nbsp;';
195 203 print '<a href="./fiche.php?action=delete&id=' . $obj->rowid . '">';
196   - print img_delete ();
  204 + print img_delete();
197 205 print '</a>';
198 206 }
199 207 print '</td>' . "\n";
200 208  
201 209 print "</tr>\n";
202   - $i ++;
  210 + $i ++;
203 211 }
204 212  
205 213 print "</table>";
206 214 print '</form>';
207   -}
208   -else
209   -{
210   - dol_print_error($db);
  215 +} else {
  216 + dol_print_error($db);
211 217 }
212   -$db->close();
213 218  
214 219 llxFooter();
215   -?>
  220 +$db->close();
216 221 \ No newline at end of file
... ...
accountingex/admin/export.php
1 1 <?php
2   -/* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3   - * Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net>
4   - * Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
  2 +/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
5 3 * Copyright (C) 2013-2014 Alexandre Spangaro <alexandre.spangaro@gmail.com>
  4 + * Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro>
6 5 *
7 6 * This program is free software; you can redistribute it and/or modify
8 7 * it under the terms of the GNU General Public License as published by
... ... @@ -20,19 +19,23 @@
20 19 */
21 20  
22 21 /**
23   - \file htdocs/accountingex/admin/export.php
24   - \ingroup Accounting Expert
25   - \brief Page administration du module
26   -*/
  22 + * \file htdocs/accountingex/admin/export.php
  23 + * \ingroup Accounting Expert
  24 + * \brief Setup page to configure accounting expert module
  25 + */
27 26  
28 27 // Dolibarr environment
29   -$res=@include("../main.inc.php");
30   -if (! $res && file_exists("../main.inc.php")) $res=@include("../main.inc.php");
31   -if (! $res && file_exists("../../main.inc.php")) $res=@include("../../main.inc.php");
32   -if (! $res && file_exists("../../../main.inc.php")) $res=@include("../../../main.inc.php");
33   -if (! $res) die("Include of main fails");
34   -
35   -// Class
  28 +$res = @include ("../main.inc.php");
  29 +if (! $res && file_exists("../main.inc.php"))
  30 + $res = @include ("../main.inc.php");
  31 +if (! $res && file_exists("../../main.inc.php"))
  32 + $res = @include ("../../main.inc.php");
  33 +if (! $res && file_exists("../../../main.inc.php"))
  34 + $res = @include ("../../../main.inc.php");
  35 +if (! $res)
  36 + die("Include of main fails");
  37 +
  38 + // Class
36 39 dol_include_once("/core/lib/admin.lib.php");
37 40 dol_include_once("/accountingex/core/lib/account.lib.php");
38 41  
... ... @@ -41,61 +44,50 @@ $langs-&gt;load(&quot;bills&quot;);
41 44 $langs->load('admin');
42 45 $langs->load('accountingex@accountingex');
43 46  
44   -// Securite accès client
45   -if ($user->societe_id > 0) accessforbidden();
46   -if (!$user->rights->accountingex->admin) accessforbidden();
  47 +// Security check
  48 +if ($user->societe_id > 0)
  49 + accessforbidden();
  50 +if (! $user->rights->accountingex->admin)
  51 + accessforbidden();
  52 +
  53 +$action = GETPOST('action', 'alpha');
47 54  
48   -$action=GETPOST('action','alpha');
  55 +// Other parameters ACCOUNTINGEX_*
  56 +$list = array (
  57 + 'ACCOUNTINGEX_MODELCSV',
  58 + 'ACCOUNTINGEX_SEPARATORCSV'
  59 +);
49 60  
50 61 /*
51   - * Affichage page
52   - *
  62 + * Actions
53 63 */
54   -if ($action == 'setmodelcsv')
55   -{
56   - $modelcsv = GETPOST('modelcsv','int');
57   -
58   - $res = dolibarr_set_const($db, 'ACCOUNTINGEX_MODELCSV', $modelcsv,'chaine',0,'',$conf->entity);
59   -
60   - if (! $res > 0) $error++;
61   -
62   - if (! $error)
63   - {
64   - $mesg = "<font class=\"ok\">".$langs->trans("SetupSaved")."</font>";
65   - }
66   - else
67   - {
68   - $mesg = "<font class=\"error\">".$langs->trans("Error")."</font>";
69   - }
70   -}
71   -
72   -if ($action == 'delete')
73   -{
74   - if (! dolibarr_del_const($db, $_GET['constname'],$conf->entity));
75   - {
76   - print $db->error();
  64 +if ($action == 'update') {
  65 + $error = 0;
  66 +
  67 + $modelcsv = GETPOST('modelcsv', 'int');
  68 +
  69 + if (in_array($modelcsv, $modelcsv)) {
  70 +
  71 + if (! dolibarr_set_const($db, 'ACCOUNTINGEX_MODELCSV', $modelcsv, 'chaine', 0, '', $conf->entity)) {
  72 + $error ++;
  73 + }
  74 + } else {
  75 + $error ++;
  76 + }
  77 +
  78 + foreach ( $list as $constname ) {
  79 + $constvalue = GETPOST($constname, 'alpha');
  80 +
  81 + if (! dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) {
  82 + $error ++;
  83 + }
  84 + }
  85 +
  86 + if (! $error) {
  87 + setEventMessage($langs->trans("SetupSaved"));
  88 + } else {
  89 + setEventMessage($langs->trans("Error"), 'errors');
77 90 }
78   -}
79   -
80   -if ($action == 'update' || $action == 'add')
81   -{
82   - $constname = GETPOST('constname','alpha');
83   - $constvalue = GETPOST('constvalue','alpha');
84   - $consttype = GETPOST('consttype','alpha');
85   - $constnote = GETPOST('constnote','alpha');
86   -
87   - $res = dolibarr_set_const($db, $constname, $constvalue, $consttype, 0, $constnote, $conf->entity);
88   -
89   - if (! $res > 0) $error++;
90   -
91   - if (! $error)
92   - {
93   - $mesg = "<font class=\"ok\">".$langs->trans("SetupSaved")."</font>";
94   - }
95   - else
96   - {
97   - $mesg = "<font class=\"error\">".$langs->trans("Error")."</font>";
98   - }
99 91 }
100 92  
101 93 /*
... ... @@ -104,54 +96,44 @@ if ($action == &#39;update&#39; || $action == &#39;add&#39;)
104 96  
105 97 llxHeader();
106 98  
107   -$form=new Form($db);
  99 +$form = new Form($db);
108 100  
109 101 print_fiche_titre($langs->trans('ConfigAccountingExpert'));
110 102  
111 103 $head = admin_account_prepare_head(null);
112   -
113   -dol_fiche_head($head,'export',$langs->trans("Configuration"),0,'cron' );
114 104  
115   -print '<table class="noborder" width="100%">';
  105 +dol_fiche_head($head, 'export', $langs->trans("Configuration"), 0, 'cron');
116 106  
117   -/*
118   - * Select Export Model CSV
119   - *
120   - */
121   -print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
122   -print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'" />';
123   -print '<input type="hidden" name="action" value="setmodelcsv">';
  107 +print '<form action="' . $_SERVER ["PHP_SELF"] . '" method="post">';
  108 +print '<input type="hidden" name="token" value="' . $_SESSION ['newtoken'] . '">';
  109 +print '<input type="hidden" name="action" value="update">';
124 110  
125 111 print '<table class="noborder" width="100%">';
126   -$var=True;
  112 +$var = True;
127 113  
128 114 print '<tr class="liste_titre">';
129   -print '<td>';
130   -
131   -print $langs->trans("Modelcsv").'</td>';
132   -print '<td align="right"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>';
133   -print "</tr>\n";
134   -$var=!$var;
135   -print '<tr '.$bc[$var].'>';
136   -print "<td>".$langs->trans("Selectmodelcsv")."</td>";
  115 +print '<td colspan="2">' . $langs->trans("Modelcsv") . '</td>';
  116 +print '</tr>';
  117 +
  118 +$var = ! $var;
  119 +
  120 +print '<tr ' . $bc [$var] . '>';
  121 +print "<td>" . $langs->trans("Selectmodelcsv") . "</td>";
137 122 print "<td>";
138 123 print '<select class="flat" name="modelcsv" id="modelcsv">';
139 124 print '<option value="0"';
140   - if($conf->global->ACCOUNTINGEX_MODELCSV == 0)
141   - {
142   - print ' selected="selected"';
143   - }
144   -print '>'.$langs->trans("Modelcsv_normal").'</option>';
  125 +if ($conf->global->ACCOUNTINGEX_MODELCSV == 0) {
  126 + print ' selected="selected"';
  127 +}
  128 +print '>' . $langs->trans("Modelcsv_normal") . '</option>';
145 129 print '<option value="1"';
146   - if($conf->global->ACCOUNTINGEX_MODELCSV == 1)
147   - {
148   - print ' selected="selected"';
149   - }
150   -print '>'.$langs->trans("Modelcsv_CEGID").'</option>';
  130 +if ($conf->global->ACCOUNTINGEX_MODELCSV == 1) {
  131 + print ' selected="selected"';
  132 +}
  133 +print '>' . $langs->trans("Modelcsv_CEGID") . '</option>';
151 134 print "</select>";
152 135 print "</td></tr>";
153 136 print "</table>";
154   -print "</form>";
155 137  
156 138 print "<br>\n";
157 139  
... ... @@ -159,55 +141,37 @@ print &quot;&lt;br&gt;\n&quot;;
159 141 * Params
160 142 *
161 143 */
162   -$list=array('ACCOUNTINGEX_SEPARATORCSV');
  144 +$list = array (
  145 + 'ACCOUNTINGEX_SEPARATORCSV'
  146 +);
163 147  
164   -$num=count($list);
165   -if ($num)
166   -{
  148 +$num = count($list);
  149 +if ($num) {
167 150 print '<table class="noborder" width="100%">';
168 151 print '<tr class="liste_titre">';
169   - print '<td colspan="3">'.$langs->trans('OtherOptions').'</td>';
  152 + print '<td colspan="3">' . $langs->trans('OtherOptions') . '</td>';
170 153 print "</tr>\n";
171 154 }
172 155  
173   -foreach ($list as $key)
174   -{
175   - $var=!$var;
176   -
177   - print '<form action="index.php" method="POST">';
178   - print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  156 +foreach ( $list as $key ) {
  157 + $var = ! $var;
179 158  
180   - print '<input type="hidden" name="action" value="update">';
181   - print '<input type="hidden" name="consttype" value="string">';
182   - print '<input type="hidden" name="constname" value="'.$key.'">';
  159 + print '<tr ' . $bc [$var] . ' class="value">';
183 160  
184   - print '<tr '.$bc[$var].' class="value">';
185   -
186 161 // Param
187   - $libelle = $langs->trans($key);
188   - print '<td>'.$libelle;
189   - //print ' ('.$key.')';
190   - print "</td>\n";
191   -
  162 + $label = $langs->trans($key);
  163 + print '<td>' . $label . '</td>';
  164 +
192 165 // Value
193 166 print '<td>';
194   - print '<input type="text" size="20" name="constvalue" value="'.$conf->global->$key.'">';
195   - print '</td><td>';
196   - print '<input type="submit" class="button" value="'.$langs->trans('Modify').'" name="button"> &nbsp; ';
197   - print "</td></tr>\n";
198   - print '</form>';
199   -
200   - $i++;
201   -}
202   -
203   -if ($num)
204   -{
205   - print "</table>\n";
  167 + print '<input type="text" size="20" name="' . $key . '" value="' . $conf->global->$key . '">';
  168 + print '</td></tr>';
206 169 }
207 170  
208   -dol_htmloutput_mesg($mesg);
  171 +print '</form>';
  172 +print "</table>\n";
209 173  
210   -$db->close();
  174 +print '<br /><div style="text-align:center"><input type="submit" class="button" value="' . $langs->trans('Modify') . '" name="button"></div>';
211 175  
212 176 llxFooter();
213   -?>
214 177 \ No newline at end of file
  178 +$db->close();
215 179 \ No newline at end of file
... ...
accountingex/admin/fiche.php
1 1 <?PHP
2   -/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3   - * Copyright (C) 2005-2006 Laurent Destailleur <eldy@users.sourceforge.net>
4   - * Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
5   - * Copyright (C) 2013-2014 Alexandre Spangaro <alexandre.spangaro@gmail.com>
  2 +/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
  3 + * Copyright (C) 2013-2014 Alexandre Spangaro <alexandre.spangaro@gmail.com>
  4 + * Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro>
6 5 *
7 6 * This program is free software; you can redistribute it and/or modify
8 7 * it under the terms of the GNU General Public License as published by
... ... @@ -19,56 +18,60 @@
19 18 */
20 19  
21 20 /**
22   - * \file accountingex/admin/fiche.php
23   - * \ingroup Accounting Expert
24   - * \brief Page fiche de compte
  21 + * \file accountingex/admin/fiche.php
  22 + * \ingroup Accounting Expert
  23 + * \brief Page fiche de compte
25 24 */
26   -
27   -$res=@include("../main.inc.php");
28   -if (! $res && file_exists("../main.inc.php")) $res=@include("../main.inc.php");
29   -if (! $res && file_exists("../../main.inc.php")) $res=@include("../../main.inc.php");
30   -if (! $res && file_exists("../../../main.inc.php")) $res=@include("../../../main.inc.php");
31   -if (! $res) die("Include of main fails");
  25 +$res = @include ("../main.inc.php");
  26 +if (! $res && file_exists("../main.inc.php"))
  27 + $res = @include ("../main.inc.php");
  28 +if (! $res && file_exists("../../main.inc.php"))
  29 + $res = @include ("../../main.inc.php");
  30 +if (! $res && file_exists("../../../main.inc.php"))
  31 + $res = @include ("../../../main.inc.php");
  32 +if (! $res)
  33 + die("Include of main fails");
32 34  
33   -// Class
  35 + // Class
34 36 dol_include_once("/accountingex/core/lib/account.lib.php");
35 37 dol_include_once("/accountingex/class/accountingaccount.class.php");
36 38 dol_include_once("/accountingex/class/html.formventilation.class.php");
37 39  
38 40 // Langs
39   -$langs->load ("bills");
40   -$langs->load ("accountingex@accountingex");
  41 +$langs->load("bills");
  42 +$langs->load("accountingex@accountingex");
41 43  
42 44 $mesg = '';
43   -$action = GETPOST ( 'action' );
44   -$id = GETPOST ( 'id', 'int' );
45   -$rowid = GETPOST ( 'rowid', 'int' );
  45 +$action = GETPOST('action');
  46 +$id = GETPOST('id', 'int');
  47 +$rowid = GETPOST('rowid', 'int');
46 48  
47 49 // Security check
48   -if ($user->societe_id > 0) accessforbidden();
49   -if (!$user->rights->accountingex->admin) accessforbidden();
50   -$accounting = new AccountingAccount ( $db );
  50 +if ($user->societe_id > 0)
  51 + accessforbidden();
  52 +if (! $user->rights->accountingex->admin)
  53 + accessforbidden();
  54 +$accounting = new AccountingAccount($db);
51 55  
52 56 // action
53 57 if ($action == 'add') {
54   -
55   - $sql = 'SELECT pcg_version FROM ' . MAIN_DB_PREFIX . 'accounting_system WHERE rowid=' . $conf->global->CHARTOFACCOUNTS;
  58 + $sql = 'SELECT pcg_version FROM ' . MAIN_DB_PREFIX . 'accounting_system WHERE rowid=' . $conf->global->CHARTOFACCOUNTS;
  59 +
  60 + dol_syslog('accountingex/admin/fiche.php:: $sql=' . $sql);
  61 + $result = $db->query($sql);
  62 + $obj = $db->fetch_object($result);
56 63  
57   - dol_syslog('accountingex/admin/fiche.php:: $sql='.$sql);
58   - $result = $db->query ( $sql );
59   - $obj = $db->fetch_object ( $result );
60   -
61 64 $accounting->fk_pcg_version = $obj->pcg_version;
62 65 $accounting->pcg_type = GETPOST('pcg_type');
63 66 $accounting->pcg_subtype = GETPOST('pcg_subtype');
64 67 $accounting->account_number = GETPOST('account_number', 'int');
65 68 $accounting->account_parent = GETPOST('account_parent', 'int');
66   - $accounting->label = GETPOST('label', 'alpha' );
  69 + $accounting->label = GETPOST('label', 'alpha');
67 70 $accounting->active = 1;
68 71  
69   - $res = $accounting->create ( $user );
  72 + $res = $accounting->create($user);
70 73  
71   - if ($res == 0) {
  74 + if ($res == 0) {
72 75 } else {
73 76 if ($res == - 3) {
74 77 $_error = 1;
... ... @@ -79,52 +82,50 @@ if ($action == &#39;add&#39;) {
79 82 $action = "create";
80 83 }
81 84 }
82   - Header ( "Location: account.php" );
83   -} // Update record
84   -else if ($action == 'edit') {
85   - if (! GETPOST ( 'cancel', 'alpha' )) {
86   - $result = $accounting->fetch ( $id );
87   -
88   - $sql = 'SELECT pcg_version FROM ' . MAIN_DB_PREFIX . 'accounting_system WHERE rowid=' . $conf->global->CHARTOFACCOUNTS;
89   -
90   - dol_syslog('accountingex/admin/fiche.php:: $sql='.$sql);
91   - $result2 = $db->query ( $sql );
92   - $obj = $db->fetch_object ( $result2 );
93   -
94   - $accounting->fk_pcg_version = $obj->pcg_version;
95   - $accounting->pcg_type = GETPOST('pcg_type');
96   - $accounting->pcg_subtype = GETPOST('pcg_subtype');
97   - $accounting->account_number = GETPOST('account_number', 'int');
98   - $accounting->account_parent = GETPOST('account_parent', 'int');
99   - $accounting->label = GETPOST('label', 'alpha' );
100   -
101   - $result = $accounting->update ( $user );
102   -
103   - if ($result > 0) {
104   - header ( "Location: " . $_SERVER ["PHP_SELF"] . "?id=" . $id );
105   - exit ();
106   - } else {
107   - $mesg = $object->error;
108   - }
109   - } else {
110   - header ( "Location: " . $_SERVER ["PHP_SELF"] . "?id=" . $id );
111   - exit ();
  85 + Header("Location: account.php");
  86 +} elseif ($action == 'edit') {
  87 + if (! GETPOST('cancel', 'alpha')) {
  88 + $result = $accounting->fetch($id);
  89 +
  90 + $sql = 'SELECT pcg_version FROM ' . MAIN_DB_PREFIX . 'accounting_system WHERE rowid=' . $conf->global->CHARTOFACCOUNTS;
  91 +
  92 + dol_syslog('accountingex/admin/fiche.php:: $sql=' . $sql);
  93 + $result2 = $db->query($sql);
  94 + $obj = $db->fetch_object($result2);
  95 +
  96 + $accounting->fk_pcg_version = $obj->pcg_version;
  97 + $accounting->pcg_type = GETPOST('pcg_type');
  98 + $accounting->pcg_subtype = GETPOST('pcg_subtype');
  99 + $accounting->account_number = GETPOST('account_number', 'int');
  100 + $accounting->account_parent = GETPOST('account_parent', 'int');
  101 + $accounting->label = GETPOST('label', 'alpha');
  102 +
  103 + $result = $accounting->update($user);
  104 +
  105 + if ($result > 0) {
  106 + header("Location: " . $_SERVER ["PHP_SELF"] . "?id=" . $id);
  107 + exit();
  108 + } else {
  109 + $mesg = $object->error;
  110 + }
  111 + } else {
  112 + header("Location: " . $_SERVER ["PHP_SELF"] . "?id=" . $id);
  113 + exit();
112 114 }
113 115 } else if ($action == 'delete') {
114 116  
115   - $result = $accounting->fetch ( $id );
116   -
117   - if (!empty($accounting->id)) {
118   - $result = $accounting->delete ( $user );
  117 + $result = $accounting->fetch($id);
  118 +
  119 + if (! empty($accounting->id)) {
  120 + $result = $accounting->delete($user);
119 121  
120   - if ($result>0) {
121   - Header ( "Location: account.php" );
  122 + if ($result > 0) {
  123 + Header("Location: account.php");
122 124 }
123   -
124 125 }
125 126  
126 127 if ($result < 0) {
127   - setEventMessage ( $accounting->error, 'errors' );
  128 + setEventMessage($accounting->error, 'errors');
128 129 }
129 130 }
130 131  
... ... @@ -132,13 +133,12 @@ else if ($action == &#39;edit&#39;) {
132 133 * View
133 134 *
134 135 */
135   -llxheader('',$langs->trans('AccountAccounting'));
  136 +llxheader('', $langs->trans('AccountAccounting'));
136 137  
137   -$form = new Form ( $db );
138   -$htmlacc = new FormVentilation ( $db );
  138 +$form = new Form($db);
  139 +$htmlacc = new FormVentilation($db);
139 140  
140 141 if ($action == 'create') {
141   -
142 142 print_fiche_titre($langs->trans('NewAccount'));
143 143  
144 144 print '<form name="add" action="' . $_SERVER ["PHP_SELF"] . '" method="POST">' . "\n";
... ... @@ -147,54 +147,51 @@ if ($action == &#39;create&#39;) {
147 147  
148 148 print '<table class="border" width="100%">';
149 149  
150   - print '<tr><td width="25%">' . $langs->trans ( "AccountNumber" ) . '</td>';
  150 + print '<tr><td width="25%">' . $langs->trans("AccountNumber") . '</td>';
151 151 print '<td><input name="account_number" size="30" value="' . $accounting->account_number . '"</td></tr>';
152   - print '<tr><td>' . $langs->trans ( "Label" ) . '</td>';
  152 + print '<tr><td>' . $langs->trans("Label") . '</td>';
153 153 print '<td><input name="label" size="70" value="' . $accounting->label . '"</td></tr>';
154   - print '<tr><td>' . $langs->trans ( "Accountparent" ) . '</td>';
  154 + print '<tr><td>' . $langs->trans("Accountparent") . '</td>';
155 155 print '<td>';
156 156 print $htmlacc->select_account($accounting->account_parent, 'account_parent');
157 157 print '</td></tr>';
158   - print '<tr><td>' . $langs->trans ( "Pcgtype" ) . '</td>';
  158 + print '<tr><td>' . $langs->trans("Pcgtype") . '</td>';
159 159 print '<td>';
160   - print $htmlacc->select_pcgtype ( $accounting->pcg_type, 'pcg_type' );
  160 + print $htmlacc->select_pcgtype($accounting->pcg_type, 'pcg_type');
161 161 print '</td></tr>';
162   - print '<tr><td>' . $langs->trans ( "Pcgsubtype" ) . '</td>';
  162 + print '<tr><td>' . $langs->trans("Pcgsubtype") . '</td>';
163 163 print '<td>';
164   - print $htmlacc->select_pcgsubtype ( $accounting->pcg_subtype, 'pcg_subtype' );
  164 + print $htmlacc->select_pcgsubtype($accounting->pcg_subtype, 'pcg_subtype');
165 165 print '</td></tr>';
166 166  
167 167 print '</table>';
168 168  
169   - print '<br><center><input class="button" type="submit" value="' . $langs->trans ( "Save" ) . '"> &nbsp; &nbsp; ';
170   - print '<input class="button" type="submit" name="cancel" value="' . $langs->trans ( "Cancel" ) . '"></center';
  169 + print '<br><center><input class="button" type="submit" value="' . $langs->trans("Save") . '"> &nbsp; &nbsp; ';
  170 + print '<input class="button" type="submit" name="cancel" value="' . $langs->trans("Cancel") . '"></center';
171 171  
172 172 print '</form>';
173   -}
174   -else if ($id)
175   -{
  173 +} else if ($id) {
176 174 $rowid = $id;
177   - $account = $accounting->fetch ( $rowid );
  175 + $account = $accounting->fetch($rowid);
178 176  
179 177 if ($account > 0) {
180   - dol_htmloutput_mesg ( $mesg );
  178 + dol_htmloutput_mesg($mesg);
  179 +
  180 + $head = account_prepare_head($accounting);
181 181  
182   - $head = account_prepare_head($accounting);
183   -
184   - if ($action == 'update')
185