Commit 1d132c7e5b7a872083671be0d7ceaf8c77f28725

Authored by Darkjeff
1 parent 98262834
Exists in 3.5 and in 2 other branches 3.4, 3.6

update accounting account

admin/fiche.php
... ... @@ -53,13 +53,13 @@ $accounting = new AccountingAccount($db);
53 53  
54 54 //action
55 55 if (GETPOST ( "action" ) == 'add') {
56   - $accounting->fk_pcg_version = GETPOST ( "fk_pcg_version" );
57   - $accounting->pcg_type = GETPOST ( "pcg_type" );
58   - $accounting->pcg_subtype = GETPOST ( "pcg_subtype" );
59   - $accounting->account_number = GETPOST ( "account_number" );
60   - $accounting->account_parent = GETPOST ( "account_parent" );
61   - $accounting->label = GETPOST ( "label" );
62   - $accounting->active = GETPOST ( "active" );
  56 + $accounting->fk_pcg_version = $conf->global->ACCOUNTING_PCG_VERSION;
  57 + $accounting->pcg_type = GETPOST ( "pcgType" );
  58 + $accounting->pcg_subtype = GETPOST ( "pcgSubType" );
  59 + $accounting->account_number = GETPOST ( "AccountNumber" );
  60 + $accounting->account_parent = GETPOST ( "AccountParent" );
  61 + $accounting->label = GETPOST ( "Label" );
  62 + $accounting->active = GETPOST ( "Active" );
63 63  
64 64  
65 65 $e_accounting = $accounting;
... ... @@ -85,13 +85,13 @@ else if ($action == 'edit')
85 85 {
86 86 $result = $accounting->fetch($id);
87 87  
88   - $accounting->fk_pcg_version = GETPOST('fk_pcg_version','int');
89   - $accounting->pcg_type = GETPOST('pcg_type','int');
90   - $accounting->pcg_subtype = GETPOST('pcg_subtype','int');
91   - $accounting->account_number = GETPOST('account_number','int');
92   - $accounting->account_parent = GETPOST('account_parent','int');
93   - $accounting->label = GETPOST('label','alpha');
94   - $accounting->active = GETPOST('active','int');
  88 + $accounting->fk_pcg_version = $conf->global->ACCOUNTING_PCG_VERSION;
  89 + $accounting->pcg_type = GETPOST('pcgType');
  90 + $accounting->pcg_subtype = GETPOST('pcgSubType');
  91 + $accounting->account_number = GETPOST('AccountNumber','int');
  92 + $accounting->account_parent = GETPOST('AccountParent','int');
  93 + $accounting->label = GETPOST('Label','alpha');
  94 + $accounting->active = GETPOST('Active','int');
95 95  
96 96 $result = $accounting->update($user);
97 97  
... ... @@ -129,11 +129,11 @@ if ($action == 'create') {
129 129 print '<table class="border" width="100%">';
130 130  
131 131 print '<tr><td width="20%">' . $langs->trans ( "AccountNumber" ) . '</td>';
132   - print '<td><input name="AccountNumber" size="30" value="' .$accounting->AccountNumber. '"</td></tr>';
  132 + print '<td><input name="AccountNumber" size="30" value="' .$accounting->account_number. '"</td></tr>';
133 133 print '<tr><td width="20%">' . $langs->trans ( "Label" ) . '</td>';
134 134 print '<td><input name="Label" size="30" value="' .$accounting->Label. '"</td></tr>';
135 135 print '<tr><td width="20%">' . $langs->trans ( "Accountparent" ) . '</td>';
136   - print '<td><input name="AccountParent" size="30" value="' .$accounting->AccountParent. '"</td></tr>';
  136 + print '<td><input name="AccountParent" size="30" value="' .$accounting->account_parent. '"</td></tr>';
137 137 print '<tr><td width="20%">' . $langs->trans ( "Pcgtype" ) . '</td>';
138 138 print '<td><input name="pcgType" size="30" value="' .$accounting->pcgType. '"</td></tr>';
139 139 print '<tr><td width="20%">' . $langs->trans ( "Pcgsubtype" ) . '</td>';
... ...
admin/importaccounts.php
... ... @@ -35,7 +35,7 @@ if (! $res) die(&quot;Include of main fails&quot;);
35 35  
36 36 require_once(DOL_DOCUMENT_ROOT."/compta/facture/class/facture.class.php");
37 37 require_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php");
38   -
  38 +dol_include_once ( "/ventilation/class/accountingaccount.class" );
39 39  
40 40 $langs->load("compta");
41 41 $langs->load("bills");
... ... @@ -48,7 +48,7 @@ if (!$user-&gt;rights-&gt;ventilation-&gt;access) accessforbidden();
48 48 if ($user->societe_id > 0) accessforbidden();
49 49  
50 50  
51   -llxHeader('',$langs->trans("Ventilation"));
  51 +llxHeader('',$langs->trans("ImportAccount"));
52 52  
53 53 if($_POST["action"] == 'ventil')
54 54 {
... ... @@ -61,32 +61,35 @@ if($_POST[&quot;action&quot;] == &#39;ventil&#39;)
61 61 $cpt = 0;
62 62 foreach($mesLignesCochees as $maLigneCochee)
63 63 {
  64 +
  65 + $AccountingAccount = new AccountingAccount ($db);
  66 +
64 67 //print '<div><font color="red">id selectionnee : '.$monChoix."</font></div>";
65 68 $maLigneCourante = split("_", $maLigneCochee);
66   - $monId = $maLigneCourante[0];
67   - $monNumLigne = $maLigneCourante[1];
68   - $monCompte = $mesCodesVentilChoisis[$monNumLigne];
  69 + $monAccount = $maLigneCourante[0];
  70 + $monLabel = $maLigneCourante[1];
  71 + $monParentAccount = $maLigneCourante[2];
  72 + //$monCompte = $mesCodesVentilChoisis[$monNumLigne];
69 73  
70   - $sql = " UPDATE ".MAIN_DB_PREFIX."facturedet";
71   - $sql .= " SET fk_code_ventilation = ".$monCompte;
72   - $sql .= " WHERE rowid = ".$monId;
73   -
74   - if($db->query($sql))
75   - {
76   - print '<div><font color="green">'.$langs->trans("Line of invoice").' '.$monId.' '.$langs->trans("VentilatedinAccount").' : '.$monCompte.'</font></div>';
77   - }
78   - else
79   - {
80   - print '<div><font color="red">'.$langs->trans("ErrorDB").' : '.$langs->trans("Line of invoice").' '.$monId.' '.$langs->trans("NotVentilatedinAccount").' : '.$monCompte.'<br/> <pre>'.$sql.'</pre></font></div>';
  74 + $AccountingAccount->fk_pcg_version = $conf->global->CHARTOFACCOUNTS;
  75 + $AccountingAccount->account_number = $monAccount;
  76 + $AccountingAccount->label = $monLabel;
  77 + $AccountingAccount->account_parent = $monParentAccount;
  78 +
  79 +
  80 + $result = $AccountingAccount->create ( $user );
  81 + if ($result > 0) {
  82 + setEventMessage ( $langs->trans ( "AccountingAccountAdd" ), 'mesgs' );
  83 + } else {
  84 + dol_print_error ( $db );
81 85 }
82   -
83 86 $cpt++;
84 87  
85 88 }
86 89 }
87 90 else
88 91 {
89   - print '<div><font color="red">'.$langs->trans("AnyLineVentilate").'</font></div>';
  92 + print '<div><font color="red">'.$langs->trans("AnyLineImport").'</font></div>';
90 93 }
91 94 print '<div><font color="red">'.$langs->trans("EndProcessing").'</font></div>';
92 95 }
... ... @@ -117,7 +120,7 @@ if ($resultCompte)
117 120 }
118 121  
119 122 /*
120   -* Lignes de factures
  123 +* list accounting account from product
121 124 *
122 125 */
123 126 $page = $_GET["page"];
... ... @@ -142,14 +145,14 @@ if ($result)
142 145 {
143 146 $num_lignes = $db->num_rows($result);
144 147 $i = 0;
145   - print_barre_liste($langs->trans("ImportAccount"),$page,"liste.php","",$sortfield,$sortorder,'',$num_lignes);
  148 + print_barre_liste($langs->trans("ImportAccount"),$page,"importaccounts.php","",$sortfield,$sortorder,'',$num_lignes);
146 149  
147 150  
148 151 print '<table class="noborder" width="100%">';
149 152 print '<tr class="liste_titre"><td>'.$langs->trans("accountingaccount").'</td>';
150 153 print '<td>'.$langs->trans("label").'</td>';
151 154 print '<td>'.$langs->trans("parentaccount").'</td>';
152   - print '<td align="center">'.$langs->trans("Ventilate").'</td>';
  155 + print '<td align="center">'.$langs->trans("Import").'</td>';
153 156 print '</tr>';
154 157  
155 158  
... ... @@ -166,25 +169,33 @@ if ($result)
166 169 print "<tr $bc[$var]>";
167 170  
168 171  
169   - print '<td align="right">';
  172 +
  173 +
  174 + print '<td align="left">';
170 175 print $objp->accounting;
171 176 print '</td>';
172 177  
  178 + print '<td align="left">';
  179 + print '<input name="intitule" size="70" value="">';
  180 + print '</td>';
173 181  
174 182 //Colonne choix du compte
175   - print '<td align="center">';
  183 + print '<td align="left">';
176 184 print $form->selectarray("codeventil[]",$cgs, $cgn[$objp->accounting]);
177 185 print '</td>';
178 186 //Colonne choix ligne a ventiler
  187 +
  188 + $checked = ('intitule' == 'O')?' checked=checked':'';
  189 +
179 190 print '<td align="center">';
180   - print '<input type="checkbox" name="mesCasesCochees[]" value="'.$objp->rowid."_".$i.'"'.($objp->accounting?"checked":"").'/>';
  191 + print '<input type="checkbox" name="mesCasesCochees[]"'.$checked .'/>';
181 192 print '</td>';
182 193  
183 194 print '</tr>';
184 195 $i++;
185 196 }
186 197  
187   - print '<tr><td colspan="8">&nbsp;</td></tr><tr><td colspan="8" align="center"><input type="submit" class="butAction" value="'.$langs->trans("Ventilate").'"></td></tr>';
  198 + print '<tr><td colspan="8">&nbsp;</td></tr><tr><td colspan="8" align="center"><input type="submit" class="butAction" value="'.$langs->trans("Import").'"></td></tr>';
188 199  
189 200 print '</table>';
190 201 print '</form>';
... ...
class/accountingaccount.class.php
... ... @@ -37,6 +37,7 @@ class AccountingAccount {
37 37 var $account_parent;
38 38 var $label;
39 39 var $active;
  40 + var $fk_user_author;
40 41  
41 42  
42 43 /**
... ... @@ -86,6 +87,7 @@ if ($rowid || $account_number) {
86 87 $this->account_parent = $obj->account_parent;
87 88 $this->label = $obj->label;
88 89 $this->active = $obj->active;
  90 + $this->fk_user_author = $obj->fk_user_author;
89 91  
90 92 return $obj->rowid;
91 93 }
... ... @@ -111,6 +113,7 @@ if ($rowid || $account_number) {
111 113 if (isset($this->account_parent)) $this->account_parent=trim($this->account_parent);
112 114 if (isset($this->label)) $this->account_parent=trim($this->label);
113 115 if (isset($this->active)) $this->active=trim($this->active);
  116 + if (isset($this->fk_user_author)) $this->fk_user_author=trim($this->fk_user_author);
114 117  
115 118  
116 119  
... ... @@ -127,6 +130,7 @@ if ($rowid || $account_number) {
127 130 $sql.= "account_parent,";
128 131 $sql.= "label,";
129 132 $sql.= "active,";
  133 + $sql .= " fk_user_author";
130 134  
131 135  
132 136 $sql.= ") VALUES (";
... ... @@ -138,7 +142,7 @@ if ($rowid || $account_number) {
138 142 $sql.= " ".(! isset($this->account_parent)?'NULL':"'".$this->db->escape($this->account_parent)."'").",";
139 143 $sql.= " ".(! isset($this->label)?'NULL':"'".$this->db->escape($this->label)."'").",";
140 144 $sql.= " ".(! isset($this->active)?'NULL':"'".$this->db->escape($this->active)."'").",";
141   -
  145 + $sql .= "'" . $user->id . "'";
142 146  
143 147 $sql.= ")";
144 148  
... ... @@ -197,13 +201,14 @@ if ($rowid || $account_number) {
197 201 $this->db->begin();
198 202  
199 203 $sql = "UPDATE ".MAIN_DB_PREFIX."accountingaccount ";
200   - $sql .= " SET fk_pcg_version = ".$this->fk_pcg_version;
201   - $sql .= " , pcg_type = '".$this->pcg_type."'";
202   - $sql .= " , pcg_subtype = '".$this->pcg_subtype."'";
  204 + $sql .= " SET fk_pcg_version = ".($this->fk_pcg_version?"'".$this->db->escape($this->fk_pcg_version)."'":"null");
  205 + $sql .= " , pcg_type = ".($this->pcg_type?"'".$this->db->escape($this->pcg_type)."'":"null");
  206 + $sql .= " , pcg_subtype = ".($this->pcg_subtype?"'".$this->db->escape($this->pcg_subtype)."'":"null");
203 207 $sql .= " , account_number = '".$this->account_number."'";
204 208 $sql .= " , account_parent = '".$this->account_parent."'";
205 209 $sql .= " , label = ".($this->label?"'".$this->db->escape($this->label)."'":"null");
206 210 $sql .= " , active = '".$this->active."'";
  211 + $sql .= " , fk_user_author = ".$user->id;
207 212 $sql .= " WHERE rowid = ".$this->id;
208 213  
209 214 dol_syslog(get_class($this)."::update sql=".$sql, LOG_DEBUG);
... ...
class/html.formventilation.class.php
... ... @@ -90,4 +90,12 @@ class FormVentilation extends Form {
90 90 return $out;
91 91 }
92 92  
  93 +
  94 +
  95 +
  96 +
  97 +
  98 +
  99 +
  100 +
93 101 }
... ...
img/AccountingExpert.png 0 → 100644

541 Bytes

sql/llx_accountingaccount.update.sql 0 → 100644
... ... @@ -0,0 +1,20 @@
  1 +-- ============================================================================
  2 +-- Copyright (C) 2013 Olivier Geffroy <jeff@jeffinfo.com>
  3 +--
  4 +-- This program is free software; you can redistribute it and/or modify
  5 +-- it under the terms of the GNU General Public License as published by
  6 +-- the Free Software Foundation; either version 3 of the License, or
  7 +-- (at your option) any later version.
  8 +--
  9 +-- This program is distributed in the hope that it will be useful,
  10 +-- but WITHOUT ANY WARRANTY; without even the implied warranty of
  11 +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12 +-- GNU General Public License for more details.
  13 +--
  14 +-- You should have received a copy of the GNU General Public License
  15 +-- along with this program. If not, see <http://www.gnu.org/licenses/>.
  16 +--
  17 +-- ============================================================================
  18 +
  19 +ALTER TABLE llx_accountingaccount add column fk_user_author int(11) DEFAULT NULL
  20 +
... ...