Commit 3d5bdea35c477c1398be59803e58446629567e78

Authored by Florian HENRY
1 parent 3f6c1205
Exists in 3.5 and in 1 other branch 3.6

reset

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>
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
... ... @@ -77,16 +76,6 @@ print &#39;&lt;a target=&quot;_blank&quot; href=&quot;http://twiter.com/elarifr&quot;&gt;&lt;img src=&quot;../img/twee
77 76 print '<a target="_blank" href="https://plus.google.com/109875408706351786851"><img src="../img/google+.png" width="20"></a>';
78 77 print '</td></tr>';
79 78  
80   -//Florian HENRY - Open-concept.pro
81   -print '<tr><td><img src="http://demo.open-concept.pro/prestashop/img/logo.jpg"></td>';
82   -print '<td><b>Florian Henry</b>&nbsp;-&nbsp;Intégrateur/développeur Solution Open-Source';
83   -print '<br>Florian HENRY - Open-Concept.pro <BR> florian.henry@open-concept.pro <BR> +33 6 03 76 48 07';
84   -print '<br><a target="_blank" href="http://www.open-concept.pro">http://www.open-concept.pro</a>';
85   -print '<br><br><a target="_blank" href="http://twitter.com/_open_concept_"><img src="../img/tweet.png" width="20"></a>';
86   -print '</td></tr>';
87   -
88   -print '<tr><td>&nbsp;</td></tr>';
89   -
90 79  
91 80 dol_htmloutput_mesg($mesg);
92 81  
... ...
accountingex/admin/export.php
... ... @@ -20,23 +20,19 @@
20 20 */
21 21  
22 22 /**
23   - * \file htdocs/accountingex/admin/export.php
24   - * \ingroup Accounting Expert
25   - * \brief Page administration du module
26   - */
  23 + \file htdocs/accountingex/admin/export.php
  24 + \ingroup Accounting Expert
  25 + \brief Page administration du module
  26 +*/
27 27  
28 28 // Dolibarr environment
29   -$res = @include ("../main.inc.php");
30   -if (! $res && file_exists("../main.inc.php"))
31   - $res = @include ("../main.inc.php");
32   -if (! $res && file_exists("../../main.inc.php"))
33   - $res = @include ("../../main.inc.php");
34   -if (! $res && file_exists("../../../main.inc.php"))
35   - $res = @include ("../../../main.inc.php");
36   -if (! $res)
37   - die("Include of main fails");
38   -
39   - // Class
  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
40 36 dol_include_once("/core/lib/admin.lib.php");
41 37 dol_include_once("/accountingex/core/lib/account.lib.php");
42 38  
... ... @@ -46,56 +42,60 @@ $langs-&gt;load(&#39;admin&#39;);
46 42 $langs->load('accountingex@accountingex');
47 43  
48 44 // Securite accès client
49   -if ($user->societe_id > 0)
50   - accessforbidden();
51   -if (! $user->rights->accountingex->admin)
52   - accessforbidden();
  45 +if ($user->societe_id > 0) accessforbidden();
  46 +if (!$user->rights->accountingex->admin) accessforbidden();
53 47  
54   -$action = GETPOST('action', 'alpha');
  48 +$action=GETPOST('action','alpha');
55 49  
56 50 /*
57 51 * Affichage page
58 52 *
59 53 */
60   -if ($action == 'setmodelcsv') {
61   - $modelcsv = GETPOST('modelcsv', 'int');
62   -
63   - $res = dolibarr_set_const($db, 'ACCOUNTINGEX_MODELCSV', $modelcsv, 'chaine', 0, '', $conf->entity);
64   -
65   - if (! $res > 0)
66   - $error ++;
67   -
68   - if (! $error) {
69   - $mesg = "<font class=\"ok\">" . $langs->trans("SetupSaved") . "</font>";
70   - } else {
71   - $mesg = "<font class=\"error\">" . $langs->trans("Error") . "</font>";
72   - }
  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 + }
73 70 }
74 71  
75   -if ($action == 'delete') {
76   - if (! dolibarr_del_const($db, $_GET ['constname'], $conf->entity))
77   - ;
  72 +if ($action == 'delete')
  73 +{
  74 + if (! dolibarr_del_const($db, $_GET['constname'],$conf->entity));
78 75 {
79 76 print $db->error();
80 77 }
81 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');
82 86  
83   -if ($action == 'update' || $action == 'add') {
84   - $constname = GETPOST('constname', 'alpha');
85   - $constvalue = GETPOST('constvalue', 'alpha');
86   - $consttype = GETPOST('consttype', 'alpha');
87   - $constnote = GETPOST('constnote', 'alpha');
88   -
89 87 $res = dolibarr_set_const($db, $constname, $constvalue, $consttype, 0, $constnote, $conf->entity);
90   -
91   - if (! $res > 0)
92   - $error ++;
93   -
94   - if (! $error) {
95   - $mesg = "<font class=\"ok\">" . $langs->trans("SetupSaved") . "</font>";
96   - } else {
97   - $mesg = "<font class=\"error\">" . $langs->trans("Error") . "</font>";
98   - }
  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 99 }
100 100  
101 101 /*
... ... @@ -104,13 +104,13 @@ if ($action == &#39;update&#39; || $action == &#39;add&#39;) {
104 104  
105 105 llxHeader();
106 106  
107   -$form = new Form($db);
  107 +$form=new Form($db);
108 108  
109 109 print_fiche_titre($langs->trans('ConfigAccountingExpert'));
110 110  
111 111 $head = admin_account_prepare_head(null);
112   -
113   -dol_fiche_head($head, 'export', $langs->trans("Configuration"), 0, 'cron');
  112 +
  113 +dol_fiche_head($head,'export',$langs->trans("Configuration"),0,'cron' );
114 114  
115 115 print '<table class="noborder" width="100%">';
116 116  
... ... @@ -118,34 +118,36 @@ print &#39;&lt;table class=&quot;noborder&quot; width=&quot;100%&quot;&gt;&#39;;
118 118 * Select Export Model CSV
119 119 *
120 120 */
121   -print '<form action="' . $_SERVER ["PHP_SELF"] . '" method="POST">';
122   -print '<input type="hidden" name="token" value="' . $_SESSION ['newtoken'] . '" />';
  121 +print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
  122 +print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'" />';
123 123 print '<input type="hidden" name="action" value="setmodelcsv">';
124 124  
125 125 print '<table class="noborder" width="100%">';
126   -$var = True;
  126 +$var=True;
127 127  
128 128 print '<tr class="liste_titre">';
129 129 print '<td>';
130 130  
131   -print $langs->trans("Modelcsv") . '</td>';
132   -print '<td align="right"><input type="submit" class="button" value="' . $langs->trans("Modify") . '"></td>';
  131 +print $langs->trans("Modelcsv").'</td>';
  132 +print '<td align="right"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>';
133 133 print "</tr>\n";
134   -$var = ! $var;
135   -print '<tr ' . $bc [$var] . '>';
136   -print "<td>" . $langs->trans("Selectmodelcsv") . "</td>";
  134 +$var=!$var;
  135 +print '<tr '.$bc[$var].'>';
  136 +print "<td>".$langs->trans("Selectmodelcsv")."</td>";
137 137 print "<td>";
138 138 print '<select class="flat" name="modelcsv" id="modelcsv">';
139 139 print '<option value="0"';
140   -if ($conf->global->ACCOUNTINGEX_MODELCSV == 0) {
141   - print ' selected="selected"';
142   -}
143   -print '>' . $langs->trans("Modelcsv_normal") . '</option>';
  140 + if($conf->global->ACCOUNTINGEX_MODELCSV == 0)
  141 + {
  142 + print ' selected="selected"';
  143 + }
  144 +print '>'.$langs->trans("Modelcsv_normal").'</option>';
144 145 print '<option value="1"';
145   -if ($conf->global->ACCOUNTINGEX_MODELCSV == 1) {
146   - print ' selected="selected"';
147   -}
148   -print '>' . $langs->trans("Modelcsv_CEGID") . '</option>';
  146 + if($conf->global->ACCOUNTINGEX_MODELCSV == 1)
  147 + {
  148 + print ' selected="selected"';
  149 + }
  150 +print '>'.$langs->trans("Modelcsv_CEGID").'</option>';
149 151 print "</select>";
150 152 print "</td></tr>";
151 153 print "</table>";
... ... @@ -157,48 +159,49 @@ print &quot;&lt;br&gt;\n&quot;;
157 159 * Params
158 160 *
159 161 */
160   -$list = array (
161   - 'ACCOUNTINGEX_SEPARATORCSV'
162   -);
  162 +$list=array('ACCOUNTINGEX_SEPARATORCSV');
163 163  
164   -$num = count($list);
165   -if ($num) {
  164 +$num=count($list);
  165 +if ($num)
  166 +{
166 167 print '<table class="noborder" width="100%">';
167 168 print '<tr class="liste_titre">';
168   - print '<td colspan="3">' . $langs->trans('OtherOptions') . '</td>';
  169 + print '<td colspan="3">'.$langs->trans('OtherOptions').'</td>';
169 170 print "</tr>\n";
170 171 }
171 172  
172   -foreach ( $list as $key ) {
173   - $var = ! $var;
174   -
  173 +foreach ($list as $key)
  174 +{
  175 + $var=!$var;
  176 +
175 177 print '<form action="index.php" method="POST">';
176   - print '<input type="hidden" name="token" value="' . $_SESSION ['newtoken'] . '">';
  178 + print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
177 179  
178 180 print '<input type="hidden" name="action" value="update">';
179 181 print '<input type="hidden" name="consttype" value="string">';
180   - print '<input type="hidden" name="constname" value="' . $key . '">';
181   -
182   - print '<tr ' . $bc [$var] . ' class="value">';
  182 + print '<input type="hidden" name="constname" value="'.$key.'">';
183 183  
  184 + print '<tr '.$bc[$var].' class="value">';
  185 +
184 186 // Param
185   - $libelle = $langs->trans($key);
186   - print '<td>' . $libelle;
187   - // print ' ('.$key.')';
  187 + $libelle = $langs->trans($key);
  188 + print '<td>'.$libelle;
  189 + //print ' ('.$key.')';
188 190 print "</td>\n";
189   -
  191 +
190 192 // Value
191 193 print '<td>';
192   - print '<input type="text" size="20" name="constvalue" value="' . $conf->global->$key . '">';
  194 + print '<input type="text" size="20" name="constvalue" value="'.$conf->global->$key.'">';
193 195 print '</td><td>';
194   - print '<input type="submit" class="button" value="' . $langs->trans('Modify') . '" name="button"> &nbsp; ';
  196 + print '<input type="submit" class="button" value="'.$langs->trans('Modify').'" name="button"> &nbsp; ';
195 197 print "</td></tr>\n";
196 198 print '</form>';
197 199  
198   - $i ++;
  200 + $i++;
199 201 }
200 202  
201   -if ($num) {
  203 +if ($num)
  204 +{
202 205 print "</table>\n";
203 206 }
204 207  
... ...
accountingex/admin/fiche.php
... ... @@ -19,141 +19,112 @@
19 19 */
20 20  
21 21 /**
22   - * \file accountingex/admin/fiche.php
23   - * \ingroup Accounting Expert
24   - * \brief Page fiche de compte
  22 + * \file accountingex/admin/fiche.php
  23 + * \ingroup Accounting Expert
  24 + * \brief Page fiche de compte
25 25 */
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");
  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");
35 32  
36   - // Class
  33 +// Class
37 34 dol_include_once("/accountingex/core/lib/account.lib.php");
38 35 dol_include_once("/accountingex/class/accountingaccount.class.php");
39 36 dol_include_once("/accountingex/class/html.formventilation.class.php");
40 37  
41 38 // Langs
42   -$langs->load("bills");
43   -$langs->load("accountingex@accountingex");
  39 +$langs->load ("bills");
  40 +$langs->load ("accountingex@accountingex");
44 41  
45 42 $mesg = '';
46   -$action = GETPOST('action');
47   -$id = GETPOST('id', 'int');
48   -$rowid = GETPOST('rowid', 'int');
  43 +$action = GETPOST ( 'action' );
  44 +$id = GETPOST ( 'id', 'int' );
  45 +$rowid = GETPOST ( 'rowid', 'int' );
49 46  
50 47 // Security check
51   -if ($user->societe_id > 0)
52   - accessforbidden();
53   -if (! $user->rights->accountingex->admin)
54   - accessforbidden();
55   -$accounting = new AccountingAccount($db);
  48 +if ($user->societe_id > 0) accessforbidden();
  49 +if (!$user->rights->accountingex->admin) accessforbidden();
  50 +$accounting = new AccountingAccount ( $db );
56 51  
57 52 // action
58 53 if ($action == 'add') {
59   - if (GETPOST('cancel') != '')
60   - Header("Location: account.php");
61   - else {
62   - $sql = 'SELECT pcg_version FROM ' . MAIN_DB_PREFIX . 'accounting_system WHERE rowid=' . $conf->global->CHARTOFACCOUNTS;
63   -
64   - dol_syslog('accountingex/admin/fiche.php:: $sql=' . $sql);
65   - $result = $db->query($sql);
66   - $obj = $db->fetch_object($result);
67   -
68   - $accounting->fk_pcg_version = $obj->pcg_version;
69   - $accounting->pcg_type = GETPOST('pcg_type');
70   - $accounting->pcg_subtype = GETPOST('pcg_subtype');
71   - $accounting->account_number = GETPOST('account_number', 'int');
72   - $accounting->account_parent = GETPOST('account_parent', 'int');
73   - $accounting->label = GETPOST('label', 'alpha');
74   - $accounting->active = 1;
75   -
76   - $res = $accounting->create($user);
77   -
78   - if ($res == 0) {
79   - } else {
80   - if ($res == - 3) {
81   - $_error = 1;
82   - $action = "create";
83   - }
84   - if ($res == - 4) {
85   - $_error = 2;
86   - $action = "create";
87   - }
88   - }
89   - Header("Location: account.php");
90   - }
91   -} // Update record
92   -else if ($action == 'edit') {
93   - if (! GETPOST('cancel', 'alpha')) {
94   - $result = $accounting->fetch($id);
95   -
96   - $sql = 'SELECT pcg_version FROM ' . MAIN_DB_PREFIX . 'accounting_system WHERE rowid=' . $conf->global->CHARTOFACCOUNTS;
97   -
98   - dol_syslog('accountingex/admin/fiche.php:: $sql=' . $sql);
99   - $result2 = $db->query($sql);
100   - $obj = $db->fetch_object($result2);
101   -
102   - $accounting->fk_pcg_version = $obj->pcg_version;
103   - $accounting->pcg_type = GETPOST('pcg_type');
104   - $accounting->pcg_subtype = GETPOST('pcg_subtype');
105   - $accounting->account_number = GETPOST('account_number', 'int');
106   - $accounting->account_parent = GETPOST('account_parent', 'int');
107   - $accounting->label = GETPOST('label', 'alpha');
108   -
109   - $result = $accounting->update($user);
110   -
111   - if ($result > 0) {
112   - header("Location: " . $_SERVER ["PHP_SELF"] . "?id=" . $id);
113   - exit();
114   - } else {
115   - $mesg = $object->error;
116   - }
117   - } else {
118   - header("Location: " . $_SERVER ["PHP_SELF"] . "?id=" . $id);
119   - exit();
120   - }
121   -} else if ($action == 'disable') {
122   -
123   - $result = $accounting->fetch($id);
124   - if (! empty($accounting->id)) {
125   - $result = $accounting->account_desactivate($user);
126   - }
  54 +
  55 + $sql = 'SELECT pcg_version FROM ' . MAIN_DB_PREFIX . 'accounting_system WHERE rowid=' . $conf->global->CHARTOFACCOUNTS;
127 56  
128   - $action = 'update';
129   - if ($result < 0) {
130   - setEventMessage($accounting->error, 'errors');
131   - }
132   -} else if ($action == 'enable') {
  57 + dol_syslog('accountingex/admin/fiche.php:: $sql='.$sql);
  58 + $result = $db->query ( $sql );
  59 + $obj = $db->fetch_object ( $result );
  60 +
  61 + $accounting->fk_pcg_version = $obj->pcg_version;
  62 + $accounting->pcg_type = GETPOST('pcg_type');
  63 + $accounting->pcg_subtype = GETPOST('pcg_subtype');
  64 + $accounting->account_number = GETPOST('account_number', 'int');
  65 + $accounting->account_parent = GETPOST('account_parent', 'int');
  66 + $accounting->label = GETPOST('label', 'alpha' );
  67 + $accounting->active = 1;
133 68  
134   - $result = $accounting->fetch($id);
  69 + $res = $accounting->create ( $user );
135 70  
136   - if (! empty($accounting->id)) {
137   - $result = $accounting->account_activate($user);
  71 + if ($res == 0) {
  72 + } else {
  73 + if ($res == - 3) {
  74 + $_error = 1;
  75 + $action = "create";
  76 + }
  77 + if ($res == - 4) {
  78 + $_error = 2;
  79 + $action = "create";
  80 + }
138 81 }
139   - $action = 'update';
140   - if ($result < 0) {
141   - setEventMessage($accounting->error, 'errors');
  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 ();
142 112 }
143 113 } else if ($action == 'delete') {
144 114  
145   - $result = $accounting->fetch($id);
146   -
147   - if (! empty($accounting->id)) {
148   - $result = $accounting->delete($user);
  115 + $result = $accounting->fetch ( $id );
  116 +
  117 + if (!empty($accounting->id)) {
  118 + $result = $accounting->delete ( $user );
149 119  
150   - if ($result > 0) {
151   - Header("Location: account.php");
  120 + if ($result>0) {
  121 + Header ( "Location: account.php" );
152 122 }
  123 +
153 124 }
154 125  
155 126 if ($result < 0) {
156   - setEventMessage($accounting->error, 'errors');
  127 + setEventMessage ( $accounting->error, 'errors' );
157 128 }
158 129 }
159 130  
... ... @@ -161,12 +132,10 @@ else if ($action == &#39;edit&#39;) {
161 132 * View
162 133 *
163 134 */
164   -llxheader('', $langs->trans('AccountAccounting'));
165   -
166   -$form = new Form($db);
167   -$htmlacc = new FormVentilation($db);
  135 +llxheader('',$langs->trans('AccountAccounting'));
168 136  
169   -$linkback = '<a href="' . DOL_URL_ROOT . '/accountingex/admin/account.php">' . $langs->trans("BackToChartofaccounts") . '</a>';
  137 +$form = new Form ( $db );
  138 +$htmlacc = new FormVentilation ( $db );
170 139  
171 140 if ($action == 'create') {
172 141  
... ... @@ -178,51 +147,54 @@ if ($action == &#39;create&#39;) {
178 147  
179 148 print '<table class="border" width="100%">';
180 149  
181   - print '<tr><td width="25%">' . $langs->trans("AccountNumber") . '</td>';
  150 + print '<tr><td width="25%">' . $langs->trans ( "AccountNumber" ) . '</td>';
182 151 print '<td><input name="account_number" size="30" value="' . $accounting->account_number . '"</td></tr>';
183   - print '<tr><td>' . $langs->trans("Label") . '</td>';
  152 + print '<tr><td>' . $langs->trans ( "Label" ) . '</td>';
184 153 print '<td><input name="label" size="70" value="' . $accounting->label . '"</td></tr>';
185   - print '<tr><td>' . $langs->trans("Accountparent") . '</td>';
  154 + print '<tr><td>' . $langs->trans ( "Accountparent" ) . '</td>';
186 155 print '<td>';
187 156 print $htmlacc->select_account($accounting->account_parent, 'account_parent');
188 157 print '</td></tr>';
189   - print '<tr><td>' . $langs->trans("Pcgtype") . '</td>';
  158 + print '<tr><td>' . $langs->trans ( "Pcgtype" ) . '</td>';
190 159 print '<td>';
191   - print $htmlacc->select_pcgtype($accounting->pcg_type, 'pcg_type');
  160 + print $htmlacc->select_pcgtype ( $accounting->pcg_type, 'pcg_type' );
192 161 print '</td></tr>';
193   - print '<tr><td>' . $langs->trans("Pcgsubtype") . '</td>';
  162 + print '<tr><td>' . $langs->trans ( "Pcgsubtype" ) . '</td>';
194 163 print '<td>';
195   - print $htmlacc->select_pcgsubtype($accounting->pcg_subtype, 'pcg_subtype');
  164 + print $htmlacc->select_pcgsubtype ( $accounting->pcg_subtype, 'pcg_subtype' );
196 165 print '</td></tr>';
197 166  
198 167 print '</table>';
199 168  
200   - print '<br><center><input class="button" type="submit" value="' . $langs->trans("Save") . '"> &nbsp; &nbsp; ';
201   - 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';
202 171  
203 172 print '</form>';
204   -} else if ($id) {
  173 +}
  174 +else if ($id)
  175 +{
205 176 $rowid = $id;
206   - $account = $accounting->fetch($rowid);
  177 + $account = $accounting->fetch ( $rowid );
207 178  
208 179 if ($account > 0) {
209   - dol_htmloutput_mesg($mesg);
  180 + dol_htmloutput_mesg ( $mesg );
210 181  
211   - $head = account_prepare_head($accounting);
212   -
213   - if ($action == 'update') {
  182 + $head = account_prepare_head($accounting);
  183 +
  184 + if ($action == 'update')
  185 + {
214 186 // WYSIWYG Editor
215   - $htmlacc = new FormVentilation($db);
  187 + $htmlacc = new FormVentilation ( $db );
216 188  
217 189 require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php';
218 190  
219   - $soc = new Societe($db);
  191 + $soc = new Societe ( $db );
220 192 if ($object->socid) {
221   - $soc->fetch($object->socid);
  193 + $soc->fetch ( $object->socid );
222 194 }
223 195  
224   - dol_fiche_head($head, 'card', $langs->trans('AccountAccounting'), 0, 'billr');
225   -
  196 + dol_fiche_head($head,'card',$langs->trans('AccountAccounting'),0,'billr');
  197 +
226 198 print '<form name="update" action="' . $_SERVER ["PHP_SELF"] . '" method="POST">' . "\n";
227 199 print '<input type="hidden" name="token" value="' . $_SESSION ['newtoken'] . '">';
228 200 print '<input type="hidden" name="action" value="edit">';
... ... @@ -230,67 +202,72 @@ if ($action == &#39;create&#39;) {
230 202  
231 203 print '<table class="border" width="100%">';
232 204  
233   - print '<tr><td width="25%">' . $langs->trans("AccountNumber") . '</td>';
  205 + print '<tr><td width="25%">' . $langs->trans ( "AccountNumber" ) . '</td>';
234 206 print '<td><input name="account_number" size="30" value="' . $accounting->account_number . '"</td></tr>';
235   - print '<tr><td>' . $langs->trans("Label") . '</td>';
  207 + print '<tr><td>' . $langs->trans ( "Label" ) . '</td>';
236 208 print '<td><input name="label" size="70" value="' . $accounting->label . '"</td></tr>';
237   - print '<tr><td>' . $langs->trans("Accountparent") . '</td>';
  209 + print '<tr><td>' . $langs->trans ( "Accountparent" ) . '</td>';
238 210 print '<td>';
239 211 print $htmlacc->select_account($accounting->account_parent, 'account_parent');
240 212 print '</td></tr>';
241   - print '<tr><td>' . $langs->trans("Pcgtype") . '</td>';
  213 + print '<tr><td>' . $langs->trans ( "Pcgtype" ) . '</td>';
242 214 print '<td>';
243   - print $htmlacc->select_pcgtype($accounting->pcg_type, 'pcg_type');
  215 + print $htmlacc->select_pcgtype ( $accounting->pcg_type, 'pcg_type' );
244 216 print '</td></tr>';
245   - print '<tr><td>' . $langs->trans("Pcgsubtype") . '</td>';
  217 + print '<tr><td>' . $langs->trans ( "Pcgsubtype" ) . '</td>';
246 218 print '<td>';
247   - print $htmlacc->select_pcgsubtype($accounting->pcg_subtype, 'pcg_subtype');
  219 + print $htmlacc->select_pcgsubtype ( $accounting->pcg_subtype, 'pcg_subtype' );
248 220 print '</td></tr>';
249   -
  221 +
250 222 print '</table>';
251 223  
252   - print '<br><center><input type="submit" class="button" value="' . $langs->trans("Save") . '"> &nbsp; ';
253   - print '<input type="submit" name="cancel" class="button" value="' . $langs->trans("Cancel") . '">';
  224 + print '<br><center><input type="submit" class="button" value="' . $langs->trans ( "Save" ) . '"> &nbsp; ';
  225 + print '<input type="submit" name="cancel" class="button" value="' . $langs->trans ( "Cancel" ) . '">';
254 226 print '</center>';
255 227  
256 228 print '</form>';
257 229  
258 230 print '</div>';
259   - } else {
260   - $linkback = '<a href="../admin/account.php">' . $langs->trans("BackToChartofaccounts") . '</a>';
261   -
262   - dol_fiche_head($head, 'card', $langs->trans('AccountAccounting'), 0, 'billr');
263   -
  231 + }
  232 + else
  233 + {
  234 + $linkback='<a href="../admin/account.php">'.$langs->trans("BackToChartofaccounts").'</a>';
  235 +
  236 + dol_fiche_head($head,'card',$langs->trans('AccountAccounting'),0,'billr');
  237 +
264 238 print '<table class="border" width="100%">';
265 239  
266   - // Account number
267   - print '<tr><td width="25%">' . $langs->trans("AccountNumber") . '</td>';
268   - print '<td>' . $accounting->account_number . '</td>';
269   - print '<td align="right" width="25%">' . $linkback . '</td></tr>';
270   -
271   - print '<tr><td>' . $langs->trans("Label") . '</td>';
272   - print '<td colspan="2">' . $accounting->label . '</td></tr>';
273   -
274   - $accp = new AccountingAccount($db);
  240 + // Account number
  241 + print '<tr><td width="25%">'.$langs->trans("AccountNumber").'</td>';
  242 + print '<td>'.$accounting->account_number.'</td>';
  243 + print '<td align="right" width="25%">'.$linkback.'</td></tr>';
  244 +
  245 + print '<tr><td>'.$langs->trans("Label").'</td>';
  246 + print '<td colspan="2">'.$accounting->label.'</td></tr>';
  247 +
  248 + $accp = new AccountingAccount($db);
275 249 if ($accounting->account_parent) {
276   - $accp->fetch('', $accounting->account_parent);
  250 + $accp->fetch('',$accounting->account_parent);
277 251 }
278   - print '<tr><td>' . $langs->trans("Accountparent") . '</td>';
279   - print '<td colspan="2">' . $accp->account_number . ' - ' . $accp->label . '</td></tr>';
  252 + print '<tr><td>'.$langs->trans("Accountparent").'</td>';
  253 + print '<td colspan="2">'.$accp->account_number.' - '.$accp->label.'</td></tr>';
280 254  
281   - print '<tr><td>' . $langs->trans("Pcgtype") . '</td>';
282   - print '<td colspan="2">' . $accounting->pcg_type . '</td></tr>';
  255 + print '<tr><td>'.$langs->trans("Pcgtype").'</td>';
  256 + print '<td colspan="2">'.$accounting->pcg_type.'</td></tr>';
283 257  
284   - print '<tr><td>' . $langs->trans("Pcgsubtype") . '</td>';
285   - print '<td colspan="2">' . $accounting->pcg_subtype . '</td></tr>';
  258 + print '<tr><td>'.$langs->trans("Pcgsubtype").'</td>';
  259 + print '<td colspan="2">'.$accounting->pcg_subtype.'</td></tr>';
286 260  
287   - print '<tr><td>' . $langs->trans("Active") . '</td>';
  261 + print '<tr><td>'.$langs->trans("Active" ).'</td>';
288 262 print '<td colspan="2">';
289 263  
290   - if (empty($accounting->active)) {
291   - print img_picto($langs->trans("Disabled"), 'switch_off');
292   - } else {
293   - print img_picto($langs->trans("Activated"), 'switch_on');
  264 + if (empty ( $accounting->active ))
  265 + {
  266 + print img_picto ( $langs->trans ( "Disabled" ), 'switch_off' );
  267 + }
  268 + else
  269 + {
  270 + print img_picto ( $langs->trans ( "Activated" ), 'switch_on' );
294 271 }
295 272  
296 273 print '</td></tr>';
... ... @@ -305,26 +282,32 @@ if ($action == &#39;create&#39;) {
305 282  
306 283 print '<div class="tabsAction">';
307 284  
308   - if ($user->rights->accountingex->admin) {
309   - print '<a class="butAction" href="' . $_SERVER ["PHP_SELF"] . '?action=update&id=' . $id . '">' . $langs->trans('Modify') . '</a>';
310   - } else {
311   - print '<a class="butActionRefused" href="#" title="' . dol_escape_htmltag($langs->trans("NotAllowed")) . '">' . $langs->trans('Modify') . '</a>';
  285 + if ($user->rights->accountingex->admin)
  286 + {
  287 + print '<a class="butAction" href="' . $_SERVER ["PHP_SELF"] . '?action=update&id=' . $id . '">' . $langs->trans ( 'Modify' ) . '</a>';
  288 + }
  289 + else
  290 + {
  291 + print '<a class="butActionRefused" href="#" title="' . dol_escape_htmltag ( $langs->trans ( "NotAllowed" ) ) . '">' . $langs->trans ( 'Modify' ) . '</a>';
312 292 }
313 293  
314   - if ($user->rights->accountingex->admin) {
315   - print '<a class="butActionDelete" href="' . $_SERVER ["PHP_SELF"] . '?action=delete&id=' . $id . '">' . $langs->trans('Delete') . '</a>';
316   - } else {
317   - print '<a class="butActionRefused" href="#" title="' . dol_escape_htmltag($langs->trans("NotAllowed")) . '">' . $langs->trans('Delete') . '</a>';
  294 + if ($user->rights->accountingex->admin)
  295 + {
  296 + print '<a class="butActionDelete" href="' . $_SERVER ["PHP_SELF"] . '?action=delete&id=' . $id . '">' . $langs->trans ( 'Delete' ) . '</a>';
  297 + }
  298 + else
  299 + {
  300 + print '<a class="butActionRefused" href="#" title="' . dol_escape_htmltag ( $langs->trans ( "NotAllowed" ) ) . '">' . $langs->trans ( 'Delete' ) . '</a>';
318 301 }
319 302  
320 303 print '</div>';
321 304 }
322 305 } else {
323   - dol_print_error($db);
  306 + dol_print_error ( $db );
324 307 }
325 308 }
326 309  
327   -llxFooter();
  310 +llxFooter ();
328 311  
329   -$db->close();
  312 +$db->close ();
330 313 ?>
331 314 \ No newline at end of file
... ...
accountingex/admin/fiscalyear.php
... ... @@ -17,23 +17,19 @@
17 17 */
18 18  
19 19 /**
20   - * \file accountingex/admin/fiscalyear.php
21   - * \ingroup Accounting Expert
22   - * \brief Page to setup fiscal year for accountancy
  20 + * \file accountingex/admin/fiscalyear.php
  21 + * \ingroup Accounting Expert
  22 + * \brief Page to setup fiscal year for accountancy
23 23 */
24 24  
25 25 // Dolibarr environment
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");
35   -
36   - // Class
  26 +$res=@include("../main.inc.php");
  27 +if (! $res && file_exists("../main.inc.php")) $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) die("Include of main fails");
  31 +
  32 +// Class
37 33 dol_include_once("/core/lib/date.lib.php");
38 34 dol_include_once("/accountingex/class/fiscalyear.class.php");
39 35  
... ... @@ -43,33 +39,28 @@ $langs-&gt;load(&quot;compta&quot;);
43 39 $langs->load("accountingex@accountingex");
44 40  
45 41 // Securite accès client
46   -if ($user->societe_id > 0)
47   - accessforbidden();
48   -if (! $user->rights->accountingex->admin)
49   - accessforbidden();
50   -
51   - // List of statut
52   -static $tmpstatut2label = array (
53   - '0' => 'OpenFiscalYear',
54   - '1' => 'CloseFiscalYear'
55   -);
56   -$statut2label = array (
57   - ''
  42 +if ($user->societe_id > 0) accessforbidden();
  43 +if (!$user->rights->accountingex->admin) accessforbidden();
  44 +
  45 +// List of statut
  46 +static $tmpstatut2label=array(
  47 + '0'=>'OpenFiscalYear',
  48 + '1'=>'CloseFiscalYear',
58 49 );
59   -foreach ( $tmpstatut2label as $key => $val )
60   - $statut2label [$key] = $langs->trans($val);
  50 +$statut2label=array('');
  51 +foreach ($tmpstatut2label as $key => $val) $statut2label[$key]=$langs->trans($val);
61 52  
62   -$mesg = '';
63   -$errors = array ();
64   -$action = GETPOST('action');
  53 +$mesg='';
  54 +$errors=array();
  55 +$action=GETPOST('action');
65 56  
66   -print $_POST ['label'];
67   -print $_POST ['startmonth'];
68   -print $_POST ['startday'];
69   -print $_POST ['startyear'];
70   -print $_POST ['endmonth'];
71   -print $_POST ['endday'];
72   -print $_POST ['endyear'];
  57 +print $_POST['label'];
  58 +print $_POST['startmonth'];
  59 +print $_POST['startday'];
  60 +print $_POST['startyear'];
  61 +print $_POST['endmonth'];
  62 +print $_POST['endday'];
  63 +print $_POST['endyear'];
73 64  
74 65 $object = new Accountancy($db);
75 66  
... ... @@ -78,47 +69,60 @@ $object = new Accountancy($db);
78 69 */
79 70  
80 71 // Add
81   -if ($action == 'add') {
82   - if (! GETPOST('cancel', 'alpha')) {
83   - $error = 0;
84   -
85   - $object->label = GETPOST('label', 'alpha');
86   - $object->datestart = dol_mktime(12, 0, 0, GETPOST('startmonth', 'int'), GETPOST('startday', 'int'), GETPOST('startyear', 'int'));
87   - $object->dateend = dol_mktime(12, 0, 0, GETPOST('endmonth', 'int'), GETPOST('endday', 'int'), GETPOST('endyear', 'int'));
88   - $object->statut = 0;
89   -
90   - if (! $object->label) {
91   - $mesg = '<div class="error">' . $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")) . '</div>';
92   - $error ++;
93   - }
94   - if (! $object->datestart) {
95   - $mesg = '<div class="error">' . $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("DateStart")) . '</div>';
96   - $error ++;
97   - }
98   - if (! $object->dateend) {
99   - $mesg = '<div class="error">' . $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("DateEnd")) . '</div>';
100   - $error ++;
101   - }
102   -
103   - if (! $error) {
104   - $id = $object->create();
105   -
106   - if ($id > 0) {
107   - header("Location: " . $_SERVER ["PHP_SELF"] . "?id=" . $id);
108   - exit();
109   - } else {
110   - $mesg = $object->error;
111   - $action = 'create';
112   - }
113   - } else {
114   - $action = 'create';
115   - }
116   - } else {
117   - header("Location: index.php");
118   - exit();
119   - }
120   -
121   - /*
  72 +if ($action == 'add')
  73 +{
  74 + if (! GETPOST('cancel','alpha'))
  75 + {
  76 + $error=0;
  77 +
  78 + $object->label = GETPOST('label','alpha');
  79 + $object->datestart = dol_mktime(12, 0, 0, GETPOST('startmonth','int'), GETPOST('startday','int'), GETPOST('startyear','int'));
  80 + $object->dateend = dol_mktime(12, 0, 0, GETPOST('endmonth','int'), GETPOST('endday','int'), GETPOST('endyear','int'));
  81 + $object->statut = 0;
  82 +
  83 + if (! $object->label)
  84 + {
  85 + $mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Label")).'</div>';
  86 + $error++;
  87 + }
  88 + if (! $object->datestart)
  89 + {
  90 + $mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("DateStart")).'</div>';
  91 + $error++;
  92 + }
  93 + if (! $object->dateend)
  94 + {
  95 + $mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("DateEnd")).'</div>';
  96 + $error++;
  97 + }
  98 +
  99 + if (! $error)
  100 + {
  101 + $id = $object->create();
  102 +
  103 + if ($id > 0)
  104 + {
  105 + header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $id);
  106 + exit;
  107 + }
  108 + else
  109 + {
  110 + $mesg=$object->error;
  111 + $action='create';
  112 + }
  113 + }
  114 + else
  115 + {
  116 + $action='create';
  117 + }
  118 + }
  119 + else
  120 + {
  121 + header("Location: index.php");
  122 + exit;
  123 + }
  124 +
  125 +/*
122 126 if (! GETPOST('cancel','alpha'))
123 127 {
124 128 $error=0;
... ... @@ -167,64 +171,81 @@ if ($action == &#39;add&#39;) {
167 171 }
168 172 }
169 173 }
170   -*/
  174 +*/
171 175 }
172 176  
173 177 // Rename field
174   -if ($action == 'update') {
175   - if ($_POST ["button"] != $langs->trans("Cancel")) {
176   - // Check values
177   - if (! GETPOST('type')) {
178   - $error ++;
  178 +if ($action == 'update')
  179 +{
  180 + if ($_POST["button"] != $langs->trans("Cancel"))
  181