Commit 878568cdc00b5cf9ed913ee3dc7d907ad4c53be7

Authored by aspangaro
1 parent 07dedf98
Exists in 3.5 and in 1 other branch 3.6

Merge with develop 3.7

accountingex/admin/account.php
... ... @@ -76,8 +76,7 @@ if ($action == 'delete') {
76 76 $accounting = new AccountingAccount($db);
77 77  
78 78 if ($action == 'disable') {
79   - $accounting = $accounting->fetch($id);
80   - if (! empty($accounting->id)) {
  79 + if ($accounting->fetch($id)) {
81 80 $result = $accounting->account_desactivate($id);
82 81 }
83 82  
... ... @@ -87,9 +86,7 @@ if ($action == 'disable') {
87 86 }
88 87 } else if ($action == 'enable') {
89 88  
90   - $accounting = $accounting->fetch($id);
91   -
92   - if (! empty($accounting->id)) {
  89 + if ($accounting->fetch($id)) {
93 90 $result = $accounting->account_activate($id);
94 91 }
95 92 $action = 'update';
... ... @@ -217,4 +214,5 @@ if ($result) {
217 214 }
218 215  
219 216 llxFooter();
  217 +
220 218 $db->close();
221 219 \ No newline at end of file
... ...
accountingex/class/accountingaccount.class.php
... ... @@ -27,7 +27,7 @@
27 27 * \class AccountingAccount
28 28 * \brief Classe permettant la gestion des comptes generaux de compta
29 29 */
30   -class AccountingAccount {
  30 +class AccountingAccount extends CommonObject {
31 31 var $db;
32 32 var $id;
33 33 var $rowid;
... ... @@ -101,6 +101,7 @@ class AccountingAccount {
101 101 function create($user, $notrigger = 0) {
102 102 global $conf, $langs;
103 103 $error = 0;
  104 + $now = dol_now();
104 105  
105 106 // Clean parameters
106 107 if (isset($this->fk_pcg_version))
... ...
accountingex/class/bookkeeping.class.php
... ... @@ -28,7 +28,7 @@
28 28 * \class BookKeeping
29 29 * \brief Classe permettant la gestion des comptes generaux de compta
30 30 */
31   -class BookKeeping {
  31 +class BookKeeping extends CommonObject {
32 32 var $db;
33 33 var $id;
34 34 var $doc_date;
... ...
accountingex/customer/liste.php
... ... @@ -20,7 +20,7 @@
20 20  
21 21 /**
22 22 * \file accountingex/customer/liste.php
23   - * \ingroup Accounting Expert
  23 + * \ingroup Accounting Expert
24 24 * \brief Page de ventilation des lignes de facture clients
25 25 */
26 26  
... ... @@ -89,7 +89,7 @@ if ($action == 'ventil') {
89 89 $cpt = 0;
90 90 foreach ( $mesCasesCochees as $maLigneCochee ) {
91 91 // print '<div><font color="red">id selectionnee : '.$monChoix."</font></div>";
92   - $maLigneCourante = split("_", $maLigneCochee);
  92 + $maLigneCourante = explode("_", $maLigneCochee);
93 93 $monId = $maLigneCourante[0];
94 94 $monNumLigne = $maLigneCourante[1];
95 95 $monCompte = $mesCodesVentilChoisis[$monNumLigne];
... ...
accountingex/journal/bankjournal.php
... ... @@ -24,7 +24,7 @@
24 24  
25 25 /**
26 26 * \file accountingex/journal/bankjournal.php
27   - * \ingroup Accounting Expert
  27 + * \ingroup Accounting Expert
28 28 * \brief Page with sells journal
29 29 */
30 30  
... ... @@ -76,7 +76,7 @@ if ($user-&gt;societe_id &gt; 0)
76 76 if (! $user->rights->accountingex->access)
77 77 accessforbidden();
78 78  
79   - /*
  79 +/*
80 80 * View
81 81 */
82 82  
... ... @@ -136,18 +136,19 @@ if ($result) {
136 136 $tabpay = array ();
137 137 $tabbq = array ();
138 138 $tabtp = array ();
139   - $tabcompany[$obj->rowid] = array (
140   - 'id' => $obj->socid,
141   - 'name' => $obj->name,
142   - 'code_client' => $obj->code_compta
143   - );
144 139 $tabtype = array ();
145 140  
146 141 $i = 0;
147 142 while ( $i < $num ) {
148 143 $obj = $db->fetch_object($result);
  144 +
  145 + $tabcompany[$obj->rowid] = array (
  146 + 'id' => $obj->socid,
  147 + 'name' => $obj->name,
  148 + 'code_client' => $obj->code_compta
  149 + );
149 150  
150   - // contrôles
  151 + // Controls
151 152 $compta_bank = $obj->account_number;
152 153 if ($obj->label == '(SupplierInvoicePayment)')
153 154 $compta_soc = (! empty($obj->code_compta_fournisseur) ? $obj->code_compta_fournisseur : $cptfour);
... ... @@ -167,66 +168,82 @@ if ($result) {
167 168 }
168 169 $links = $object->get_url($obj->rowid);
169 170  
170   - foreach ( $links as $key => $val ) {
171   -
172   - $tabtype[$obj->rowid] = $links[$key]['type'];
  171 + // get_url may return -1 which is not traversable
  172 + if (is_array($links)) {
173 173  
174   - if ($links[$key]['type'] == 'payment') {
175   - $paymentstatic->id = $links[$key]['url_id'];
176   - $tabpay[$obj->rowid]["lib"] .= ' ' . $paymentstatic->getNomUrl(2);
177   - } else if ($links[$key]['type'] == 'payment_supplier') {
178   - $paymentsupplierstatic->id = $links[$key]['url_id'];
179   - $paymentsupplierstatic->ref = $links[$key]['url_id'];
180   - $tabpay[$obj->rowid]["lib"] .= ' ' . $paymentsupplierstatic->getNomUrl(2);
181   - } else if ($links[$key]['type'] == 'company') {
182   -
183   - $societestatic->id = $links[$key]['url_id'];
184   - $societestatic->nom = $links[$key]['label'];
185   - $tabpay[$obj->rowid]["soclib"] = $societestatic->getNomUrl(1, '', 30);
186   - $tabtp[$obj->rowid][$compta_soc] += $obj->amount;
187   - } else if ($links[$key]['type'] == 'sc') {
188   -
189   - $chargestatic->id = $links[$key]['url_id'];
190   - $chargestatic->ref = $links[$key]['url_id'];
191   -
192   - $tabpay[$obj->rowid]["lib"] .= ' ' . $chargestatic->getNomUrl(2);
193   - if (preg_match('/^\((.*)\)$/i', $links[$key]['label'], $reg)) {
194   - if ($reg[1] == 'socialcontribution')
195   - $reg[1] = 'SocialContribution';
196   - $chargestatic->lib = $langs->trans($reg[1]);
197   - } else {
198   - $chargestatic->lib = $links[$key]['label'];
  174 + foreach ( $links as $key => $val ) {
  175 + $tabtype[$obj->rowid] = $links[$key]['type'];
  176 + if ($links[$key]['type'] == 'payment')
  177 + {
  178 + $paymentstatic->id = $links[$key]['url_id'];
  179 + $tabpay[$obj->rowid]["lib"] .= ' ' . $paymentstatic->getNomUrl(2);
  180 + }
  181 + else if ($links[$key]['type'] == 'payment_supplier')
  182 + {
  183 + $paymentsupplierstatic->id = $links[$key]['url_id'];
  184 + $paymentsupplierstatic->ref = $links[$key]['url_id'];
  185 + $tabpay[$obj->rowid]["lib"] .= ' ' . $paymentsupplierstatic->getNomUrl(2);
199 186 }
200   - $chargestatic->ref = $chargestatic->lib;
201   - $tabpay[$obj->rowid]["soclib"] = $chargestatic->getNomUrl(1, 30);
202   -
203   - $sqlmid = 'SELECT cchgsoc.accountancy_code';
204   - $sqlmid .= " FROM " . MAIN_DB_PREFIX . "c_chargesociales cchgsoc ";
205   - $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "chargesociales as chgsoc ON chgsoc.fk_type=cchgsoc.id";
206   - $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiementcharge as paycharg ON paycharg.fk_charge=chgsoc.rowid";
207   - $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "bank_url as bkurl ON bkurl.url_id=paycharg.rowid";
208   - $sqlmid .= " WHERE bkurl.fk_bank=" . $obj->rowid;
209   -
210   - dol_syslog("accountingex/journal/bankjournal.php:: sqlmid=" . $sqlmid, LOG_DEBUG);
211   - $resultmid = $db->query($sqlmid);
212   - if ($resultmid) {
213   - $objmid = $db->fetch_object($resultmid);
214   - $tabtp[$obj->rowid][$objmid->accountancy_code] += $obj->amount;
  187 + else if ($links[$key]['type'] == 'company')
  188 + {
  189 + $societestatic->id = $links[$key]['url_id'];
  190 + $societestatic->name = $links[$key]['label'];
  191 + $tabpay[$obj->rowid]["soclib"] = $societestatic->getNomUrl(1, '', 30);
  192 + $tabtp[$obj->rowid][$compta_soc] += $obj->amount;
  193 + }
  194 + else if ($links[$key]['type'] == 'sc')
  195 + {
  196 + $chargestatic->id = $links[$key]['url_id'];
  197 + $chargestatic->ref = $links[$key]['url_id'];
  198 +
  199 + $tabpay[$obj->rowid]["lib"] .= ' ' . $chargestatic->getNomUrl(2);
  200 + if (preg_match('/^\((.*)\)$/i', $links[$key]['label'], $reg)) {
  201 + if ($reg[1] == 'socialcontribution')
  202 + $reg[1] = 'SocialContribution';
  203 + $chargestatic->lib = $langs->trans($reg[1]);
  204 + }
  205 + else
  206 + {
  207 + $chargestatic->lib = $links[$key]['label'];
  208 + }
  209 + $chargestatic->ref = $chargestatic->lib;
  210 + $tabpay[$obj->rowid]["soclib"] = $chargestatic->getNomUrl(1, 30);
  211 +
  212 + $sqlmid = 'SELECT cchgsoc.accountancy_code';
  213 + $sqlmid .= " FROM " . MAIN_DB_PREFIX . "c_chargesociales cchgsoc ";
  214 + $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "chargesociales as chgsoc ON chgsoc.fk_type=cchgsoc.id";
  215 + $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiementcharge as paycharg ON paycharg.fk_charge=chgsoc.rowid";
  216 + $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "bank_url as bkurl ON bkurl.url_id=paycharg.rowid";
  217 + $sqlmid .= " WHERE bkurl.fk_bank=" . $obj->rowid;
  218 +
  219 + dol_syslog("accountancy/journal/bankjournal.php:: sqlmid=" . $sqlmid, LOG_DEBUG);
  220 + $resultmid = $db->query($sqlmid);
  221 + if ($resultmid)
  222 + {
  223 + $objmid = $db->fetch_object($resultmid);
  224 + $tabtp[$obj->rowid][$objmid->accountancy_code] += $obj->amount;
  225 + }
  226 + }
  227 + else if ($links[$key]['type'] == 'payment_vat')
  228 + {
  229 + $paymentvatstatic->id = $links[$key]['url_id'];
  230 + $paymentvatstatic->ref = $links[$key]['url_id'];
  231 + $tabpay[$obj->rowid]["lib"] .= ' ' . $paymentvatstatic->getNomUrl(2);
  232 + $tabtp[$obj->rowid][$cpttva] += $obj->amount;
  233 + }
  234 + else if ($links[$key]['type'] == 'payment_salary')
  235 + {
  236 + $paymentsalstatic->id = $links[$key]['url_id'];
  237 + $paymentsalstatic->ref = $links[$key]['url_id'];
  238 + $tabpay[$obj->rowid]["lib"] .= ' ' . $paymentsalstatic->getNomUrl(2);
  239 + $tabtp[$obj->rowid][$accountancy_account_salary] += $obj->amount;
  240 + }
  241 + else if ($links[$key]['type'] == 'banktransfert')
  242 + {
  243 + $tabpay[$obj->rowid]["lib"] .= ' ' . $paymentvatstatic->getNomUrl(2);
  244 + $tabtp[$obj->rowid][$cpttva] += $obj->amount;
215 245 }
216   - } else if ($links[$key]['type'] == 'payment_vat') {
217   -
218   - $paymentvatstatic->id = $links[$key]['url_id'];
219   - $paymentvatstatic->ref = $links[$key]['url_id'];
220   - $tabpay[$obj->rowid]["lib"] .= ' ' . $paymentvatstatic->getNomUrl(2);
221   - $tabtp[$obj->rowid][$cpttva] += $obj->amount;
222   - } else if ($links[$key]['type'] == 'banktransfert') {
223   -
224   - $tabpay[$obj->rowid]["lib"] .= ' ' . $paymentvatstatic->getNomUrl(2);
225   - $tabtp[$obj->rowid][$cpttva] += $obj->amount;
226 246 }
227   - /*else {
228   - $tabtp [$obj->rowid] [$cptsociale] += $obj->amount;
229   - }*/
230 247 }
231 248 $tabbq[$obj->rowid][$compta_bank] += $obj->amount;
232 249  
... ...
accountingex/journal/cashjournal.php
... ... @@ -23,9 +23,9 @@
23 23 */
24 24  
25 25 /**
26   - * \file accountingex/journal/cashjournal.php
27   - * \ingroup Accounting Expert
28   - * \brief Page with cash journal
  26 + * \file accountingex/journal/cashjournal.php
  27 + * \ingroup Accounting Expert
  28 + * \brief Page with cash journal
29 29 */
30 30  
31 31 // Dolibarr environment
... ... @@ -166,64 +166,66 @@ if ($result) {
166 166 }
167 167 $links = $object->get_url($obj->rowid);
168 168  
169   - foreach ( $links as $key => $val ) {
  169 + // get_url may return -1 which is not traversable
  170 + if (is_array($links)) {
  171 + foreach ($links as $key => $val) {
170 172  
171   - $tabtype[$obj->rowid] = $links[$key]['type'];
  173 + $tabtype[$obj->rowid] = $links[$key]['type'];
172 174  
173   - if ($links[$key]['type'] == 'payment') {
174   - $paymentstatic->id = $links[$key]['url_id'];
175   - $tabpay[$obj->rowid]["lib"] .= ' ' . $paymentstatic->getNomUrl(2);
176   - } else if ($links[$key]['type'] == 'payment_supplier') {
177   - $paymentsupplierstatic->id = $links[$key]['url_id'];
178   - $paymentsupplierstatic->ref = $links[$key]['url_id'];
179   - $tabpay[$obj->rowid]["lib"] .= ' ' . $paymentsupplierstatic->getNomUrl(2);
180   - } else if ($links[$key]['type'] == 'company') {
  175 + if ($links[$key]['type'] == 'payment') {
  176 + $paymentstatic->id = $links[$key]['url_id'];
  177 + $tabpay[$obj->rowid]["lib"] .= ' ' . $paymentstatic->getNomUrl(2);
  178 + } else if ($links[$key]['type'] == 'payment_supplier') {
  179 + $paymentsupplierstatic->id = $links[$key]['url_id'];
  180 + $paymentsupplierstatic->ref = $links[$key]['url_id'];
  181 + $tabpay[$obj->rowid]["lib"] .= ' ' . $paymentsupplierstatic->getNomUrl(2);
  182 + } else if ($links[$key]['type'] == 'company') {
  183 + $societestatic->id = $links[$key]['url_id'];
  184 + $societestatic->nom = $links[$key]['label'];
  185 + $tabpay[$obj->rowid]["soclib"] = $societestatic->getNomUrl(1, '', 30);
  186 + $tabtp[$obj->rowid][$compta_soc] += $obj->amount;
  187 + } else if ($links[$key]['type'] == 'sc') {
  188 + $chargestatic->id = $links[$key]['url_id'];
  189 + $chargestatic->ref = $links[$key]['url_id'];
181 190  
182   - $societestatic->id = $links[$key]['url_id'];
183   - $societestatic->nom = $links[$key]['label'];
184   - $tabpay[$obj->rowid]["soclib"] = $societestatic->getNomUrl(1, '', 30);
185   - $tabtp[$obj->rowid][$compta_soc] += $obj->amount;
186   - } else if ($links[$key]['type'] == 'sc') {
187   -
188   - $chargestatic->id = $links[$key]['url_id'];
189   - $chargestatic->ref = $links[$key]['url_id'];
190   -
191   - $tabpay[$obj->rowid]["lib"] .= ' ' . $chargestatic->getNomUrl(2);
192   - if (preg_match('/^\((.*)\)$/i', $links[$key]['label'], $reg)) {
193   - if ($reg[1] == 'socialcontribution')
194   - $reg[1] = 'SocialContribution';
195   - $chargestatic->lib = $langs->trans($reg[1]);
196   - } else {
197   - $chargestatic->lib = $links[$key]['label'];
198   - }
199   - $chargestatic->ref = $chargestatic->lib;
200   - $tabpay[$obj->rowid]["soclib"] = $chargestatic->getNomUrl(1, 30);
201   -
202   - $sqlmid = 'SELECT cchgsoc.accountancy_code';
203   - $sqlmid .= " FROM " . MAIN_DB_PREFIX . "c_chargesociales cchgsoc ";
204   - $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "chargesociales as chgsoc ON chgsoc.fk_type=cchgsoc.id";
205   - $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiementcharge as paycharg ON paycharg.fk_charge=chgsoc.rowid";
206   - $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "bank_url as bkurl ON bkurl.url_id=paycharg.rowid";
207   - $sqlmid .= " WHERE bkurl.fk_bank=" . $obj->rowid;
208   - dol_syslog("accountingex/journal/cashjournal.php:: sqlmid=" . $sqlmid, LOG_DEBUG);
209   - $resultmid = $db->query($sqlmid);
210   - if ($resultmid) {
211   - $objmid = $db->fetch_object($resultmid);
212   - $tabtp[$obj->rowid][$objmid->accountancy_code] += $obj->amount;
  191 + $tabpay[$obj->rowid]["lib"] .= ' ' . $chargestatic->getNomUrl(2);
  192 + if (preg_match('/^\((.*)\)$/i', $links[$key]['label'], $reg)) {
  193 + if ($reg[1] == 'socialcontribution')
  194 + $reg[1] = 'SocialContribution';
  195 + $chargestatic->lib = $langs->trans($reg[1]);
  196 + } else {
  197 + $chargestatic->lib = $links[$key]['label'];
  198 + }
  199 + $chargestatic->ref = $chargestatic->lib;
  200 + $tabpay[$obj->rowid]["soclib"] = $chargestatic->getNomUrl(1, 30);
  201 +
  202 + $sqlmid = 'SELECT cchgsoc.accountancy_code';
  203 + $sqlmid .= " FROM " . MAIN_DB_PREFIX . "c_chargesociales cchgsoc ";
  204 + $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "chargesociales as chgsoc ON chgsoc.fk_type=cchgsoc.id";
  205 + $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiementcharge as paycharg ON paycharg.fk_charge=chgsoc.rowid";
  206 + $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "bank_url as bkurl ON bkurl.url_id=paycharg.rowid";
  207 + $sqlmid .= " WHERE bkurl.fk_bank=" . $obj->rowid;
  208 +
  209 + dol_syslog("accountingex/journal/cashjournal.php:: sqlmid=" . $sqlmid, LOG_DEBUG);
  210 + $resultmid = $db->query($sqlmid);
  211 + if ($resultmid) {
  212 + $objmid = $db->fetch_object($resultmid);
  213 + $tabtp[$obj->rowid][$objmid->accountancy_code] += $obj->amount;
  214 + }
  215 + } else if ($links[$key]['type'] == 'payment_vat') {
  216 +
  217 + $paymentvatstatic->id = $links[$key]['url_id'];
  218 + $paymentvatstatic->ref = $links[$key]['url_id'];
  219 + $tabpay[$obj->rowid]["lib"] .= ' ' . $paymentvatstatic->getNomUrl(2);
  220 + $tabtp[$obj->rowid][$cpttva] += $obj->amount;
  221 + } else if ($links[$key]['type'] == 'banktransfert') {
  222 + $tabpay[$obj->rowid]["lib"] .= ' ' . $paymentvatstatic->getNomUrl(2);
  223 + $tabtp[$obj->rowid][$cpttva] += $obj->amount;
213 224 }
214   - } else if ($links[$key]['type'] == 'payment_vat') {
215   -
216   - $paymentvatstatic->id = $links[$key]['url_id'];
217   - $paymentvatstatic->ref = $links[$key]['url_id'];
218   - $tabpay[$obj->rowid]["lib"] .= ' ' . $paymentvatstatic->getNomUrl(2);
219   - $tabtp[$obj->rowid][$cpttva] += $obj->amount;
220   - } else if ($links[$key]['type'] == 'banktransfert') {
221   - $tabpay[$obj->rowid]["lib"] .= ' ' . $paymentvatstatic->getNomUrl(2);
222   - $tabtp[$obj->rowid][$cpttva] += $obj->amount;
  225 + /*else {
  226 + $tabtp [$obj->rowid] [$cptsociale] += $obj->amount;
  227 + }*/
223 228 }
224   - /*else {
225   - $tabtp [$obj->rowid] [$cptsociale] += $obj->amount;
226   - }*/
227 229 }
228 230 $tabbq[$obj->rowid][$compta_bank] += $obj->amount;
229 231  
... ...
accountingex/journal/purchasesjournal.php
... ... @@ -289,6 +289,8 @@ if ($action == &#39;export_csv&#39;) {
289 289 header('Content-Type: text/csv');
290 290 header('Content-Disposition: attachment;filename=journal_achats.csv');
291 291  
  292 + $companystatic = new Fournisseur($db);
  293 +
292 294 if ($conf->global->ACCOUNTINGEX_MODELCSV == 2) // Modèle Export Cegid Expert
293 295 {
294 296 foreach ( $tabfac as $key => $val ) {
... ...
accountingex/supplier/liste.php
... ... @@ -92,7 +92,7 @@ if ($action == &#39;ventil&#39;) {
92 92  
93 93 foreach ( $mesCasesCochees as $maLigneCochee ) {
94 94 // print '<div><font color="red">id selectionnee : '.$monChoix."</font></div>";
95   - $maLigneCourante = split("_", $maLigneCochee);
  95 + $maLigneCourante = explode("_", $maLigneCochee);
96 96 $monId = $maLigneCourante[0];
97 97 $monNumLigne = $maLigneCourante[1];
98 98 $monCompte = $mesCodesVentilChoisis[$monNumLigne];
... ...