@@ -893,7 +893,7 @@ discard block |
||
893 | 893 | return $this->LibStatut($this->status, $mode); |
894 | 894 | } |
895 | 895 | |
896 | - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
896 | + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
897 | 897 | /** |
898 | 898 | * Return the status |
899 | 899 | * |
@@ -903,7 +903,7 @@ discard block |
||
903 | 903 | */ |
904 | 904 | public function LibStatut($status, $mode = 0) |
905 | 905 | { |
906 | - // phpcs:enable |
|
906 | + // phpcs:enable |
|
907 | 907 | if (empty($this->labelStatus) || empty($this->labelStatusShort)) { |
908 | 908 | global $langs; |
909 | 909 | //$langs->load("recruitment"); |
@@ -347,15 +347,15 @@ discard block |
||
347 | 347 | } |
348 | 348 | |
349 | 349 | /** |
350 | - * Create candidature object |
|
351 | - * |
|
352 | - * @param array $request_data Request datas |
|
353 | - * @return int ID of candidature |
|
354 | - * |
|
355 | - * @throws RestException |
|
356 | - * |
|
357 | - * @url POST candidature/ |
|
358 | - */ |
|
350 | + * Create candidature object |
|
351 | + * |
|
352 | + * @param array $request_data Request datas |
|
353 | + * @return int ID of candidature |
|
354 | + * |
|
355 | + * @throws RestException |
|
356 | + * |
|
357 | + * @url POST candidature/ |
|
358 | + */ |
|
359 | 359 | public function postCandidature($request_data = null) |
360 | 360 | { |
361 | 361 | if (!DolibarrApiAccess::$user->hasRight('recruitment', 'recruitmentjobposition', 'write')) { |
@@ -556,7 +556,7 @@ discard block |
||
556 | 556 | } |
557 | 557 | |
558 | 558 | |
559 | - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore |
|
559 | + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore |
|
560 | 560 | /** |
561 | 561 | * Clean sensible object datas |
562 | 562 | * |
@@ -565,7 +565,7 @@ discard block |
||
565 | 565 | */ |
566 | 566 | protected function _cleanObjectDatas($object) |
567 | 567 | { |
568 | - // phpcs:enable |
|
568 | + // phpcs:enable |
|
569 | 569 | $object = parent::_cleanObjectDatas($object); |
570 | 570 | |
571 | 571 | unset($object->rowid); |
@@ -1488,7 +1488,7 @@ discard block |
||
1488 | 1488 | return $this->LibStatut($this->status, $mode, $this->date_debut); |
1489 | 1489 | } |
1490 | 1490 | |
1491 | - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
1491 | + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
1492 | 1492 | /** |
1493 | 1493 | * Returns the label of a status |
1494 | 1494 | * |
@@ -1499,7 +1499,7 @@ discard block |
||
1499 | 1499 | */ |
1500 | 1500 | public function LibStatut($status, $mode = 0, $startdate = '') |
1501 | 1501 | { |
1502 | - // phpcs:enable |
|
1502 | + // phpcs:enable |
|
1503 | 1503 | global $langs; |
1504 | 1504 | |
1505 | 1505 | if (empty($this->labelStatus) || empty($this->labelStatusShort)) { |
@@ -2041,7 +2041,7 @@ discard block |
||
2041 | 2041 | } |
2042 | 2042 | |
2043 | 2043 | |
2044 | - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
2044 | + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
2045 | 2045 | /** |
2046 | 2046 | * Return list of people with permission to validate leave requests. |
2047 | 2047 | * Search for permission "approve leave requests" |
@@ -2050,7 +2050,7 @@ discard block |
||
2050 | 2050 | */ |
2051 | 2051 | public function fetch_users_approver_holiday() |
2052 | 2052 | { |
2053 | - // phpcs:enable |
|
2053 | + // phpcs:enable |
|
2054 | 2054 | $users_validator = array(); |
2055 | 2055 | |
2056 | 2056 | $sql = "SELECT DISTINCT ur.fk_user"; |
@@ -2431,7 +2431,7 @@ discard block |
||
2431 | 2431 | } |
2432 | 2432 | } |
2433 | 2433 | |
2434 | - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
2434 | + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
2435 | 2435 | /** |
2436 | 2436 | * Load indicators for dashboard (this->nbtodo and this->nbtodolate) |
2437 | 2437 | * |
@@ -2440,7 +2440,7 @@ discard block |
||
2440 | 2440 | */ |
2441 | 2441 | public function load_board($user) |
2442 | 2442 | { |
2443 | - // phpcs:enable |
|
2443 | + // phpcs:enable |
|
2444 | 2444 | global $conf, $langs; |
2445 | 2445 | |
2446 | 2446 | if ($user->socid) { |
@@ -367,235 +367,235 @@ discard block |
||
367 | 367 | // We save tabtype for a future use, to remember what kind of payment it is |
368 | 368 | $tabpay[$obj->rowid]['type'] = $links[$key]['type']; |
369 | 369 | $tabtype[$obj->rowid] = $links[$key]['type']; |
370 | - /* phpcs:disable -- Code does nothing at this moment -> commented |
|
370 | + /* phpcs:disable -- Code does nothing at this moment -> commented |
|
371 | 371 | } elseif (in_array($links[$key]['type'], array('company', 'user'))) { |
372 | 372 | if ($tabpay[$obj->rowid]['type'] == 'unknown') { |
373 | 373 | // We can guess here it is a bank record for a thirdparty company or a user. |
374 | 374 | // But we won't be able to record somewhere else than into a waiting account, because there is no other journal to record the contreparty. |
375 | 375 | } |
376 | 376 | */ // phpcs::enable |
377 | - } |
|
378 | - |
|
379 | - // Special case to ask later to add more request to get information for old links without company link. |
|
380 | - if ($links[$key]['type'] == 'withdraw') { |
|
381 | - $tabmoreinfo[$obj->rowid]['withdraw'] = 1; |
|
382 | - } |
|
377 | + } |
|
383 | 378 | |
384 | - if ($links[$key]['type'] == 'payment') { |
|
385 | - $paymentstatic->id = $links[$key]['url_id']; |
|
386 | - $paymentstatic->ref = $links[$key]['url_id']; |
|
387 | - $tabpay[$obj->rowid]["lib"] .= ' '.$paymentstatic->getNomUrl(2, '', ''); // TODO Do not include list of invoice in tooltip, the dol_string_nohtmltag is ko with this |
|
388 | - $tabpay[$obj->rowid]["paymentid"] = $paymentstatic->id; |
|
389 | - } elseif ($links[$key]['type'] == 'payment_supplier') { |
|
390 | - $paymentsupplierstatic->id = $links[$key]['url_id']; |
|
391 | - $paymentsupplierstatic->ref = $links[$key]['url_id']; |
|
392 | - $tabpay[$obj->rowid]["lib"] .= ' '.$paymentsupplierstatic->getNomUrl(2); |
|
393 | - $tabpay[$obj->rowid]["paymentsupplierid"] = $paymentsupplierstatic->id; |
|
394 | - } elseif ($links[$key]['type'] == 'company') { |
|
395 | - $societestatic->id = $links[$key]['url_id']; |
|
396 | - $societestatic->name = $links[$key]['label']; |
|
397 | - $societestatic->email = $tabcompany[$obj->rowid]['email']; |
|
398 | - $tabpay[$obj->rowid]["soclib"] = $societestatic->getNomUrl(1, '', 30); |
|
399 | - if ($compta_soc) { |
|
400 | - if (empty($tabtp[$obj->rowid][$compta_soc])) { |
|
401 | - $tabtp[$obj->rowid][$compta_soc] = $amounttouse; |
|
402 | - } else { |
|
403 | - $tabtp[$obj->rowid][$compta_soc] += $amounttouse; |
|
404 | - } |
|
405 | - } |
|
406 | - } elseif ($links[$key]['type'] == 'user') { |
|
407 | - $userstatic->id = $links[$key]['url_id']; |
|
408 | - $userstatic->name = $links[$key]['label']; |
|
409 | - $userstatic->email = $tabuser[$obj->rowid]['email']; |
|
410 | - $userstatic->firstname = $tabuser[$obj->rowid]['firstname']; |
|
411 | - $userstatic->lastname = $tabuser[$obj->rowid]['lastname']; |
|
412 | - $userstatic->status = $tabuser[$obj->rowid]['status']; |
|
413 | - $userstatic->accountancy_code = $tabuser[$obj->rowid]['accountancy_code']; |
|
414 | - if ($userstatic->id > 0) { |
|
415 | - $tabpay[$obj->rowid]["soclib"] = $userstatic->getNomUrl(1, 'accountancy', 0); |
|
416 | - } else { |
|
417 | - $tabpay[$obj->rowid]["soclib"] = '???'; // Should not happen, but happens with old data when id of user was not saved on expense report payment. |
|
418 | - } |
|
419 | - if ($compta_user) { |
|
420 | - $tabtp[$obj->rowid][$compta_user] += $amounttouse; |
|
421 | - } |
|
422 | - } elseif ($links[$key]['type'] == 'sc') { |
|
423 | - $chargestatic->id = $links[$key]['url_id']; |
|
424 | - $chargestatic->ref = $links[$key]['url_id']; |
|
425 | - |
|
426 | - $tabpay[$obj->rowid]["lib"] .= ' '.$chargestatic->getNomUrl(2); |
|
427 | - $reg = array(); |
|
428 | - if (preg_match('/^\((.*)\)$/i', $links[$key]['label'], $reg)) { |
|
429 | - if ($reg[1] == 'socialcontribution') { |
|
430 | - $reg[1] = 'SocialContribution'; |
|
431 | - } |
|
432 | - $chargestatic->label = $langs->trans($reg[1]); |
|
433 | - } else { |
|
434 | - $chargestatic->label = $links[$key]['label']; |
|
435 | - } |
|
436 | - $chargestatic->ref = $chargestatic->label; |
|
437 | - $tabpay[$obj->rowid]["soclib"] = $chargestatic->getNomUrl(1, 30); |
|
438 | - $tabpay[$obj->rowid]["paymentscid"] = $chargestatic->id; |
|
439 | - |
|
440 | - // Retrieve the accounting code of the social contribution of the payment from link of payment. |
|
441 | - // Note: We have the social contribution id, it can be faster to get accounting code from social contribution id. |
|
442 | - $sqlmid = "SELECT cchgsoc.accountancy_code"; |
|
443 | - $sqlmid .= " FROM ".MAIN_DB_PREFIX."c_chargesociales cchgsoc"; |
|
444 | - $sqlmid .= " INNER JOIN ".MAIN_DB_PREFIX."chargesociales as chgsoc ON chgsoc.fk_type = cchgsoc.id"; |
|
445 | - $sqlmid .= " INNER JOIN ".MAIN_DB_PREFIX."paiementcharge as paycharg ON paycharg.fk_charge = chgsoc.rowid"; |
|
446 | - $sqlmid .= " INNER JOIN ".MAIN_DB_PREFIX."bank_url as bkurl ON bkurl.url_id=paycharg.rowid AND bkurl.type = 'payment_sc'"; |
|
447 | - $sqlmid .= " WHERE bkurl.fk_bank = ".((int) $obj->rowid); |
|
448 | - |
|
449 | - dol_syslog("accountancy/journal/bankjournal.php:: sqlmid=".$sqlmid, LOG_DEBUG); |
|
450 | - $resultmid = $db->query($sqlmid); |
|
451 | - if ($resultmid) { |
|
452 | - $objmid = $db->fetch_object($resultmid); |
|
453 | - $tabtp[$obj->rowid][$objmid->accountancy_code] = isset($tabtp[$obj->rowid][$objmid->accountancy_code]) ? $tabtp[$obj->rowid][$objmid->accountancy_code] + $amounttouse : $amounttouse; |
|
454 | - } |
|
455 | - } elseif ($links[$key]['type'] == 'payment_donation') { |
|
456 | - $paymentdonstatic->id = $links[$key]['url_id']; |
|
457 | - $paymentdonstatic->ref = $links[$key]['url_id']; |
|
458 | - $paymentdonstatic->fk_donation = $links[$key]['url_id']; |
|
459 | - $tabpay[$obj->rowid]["lib"] .= ' '.$paymentdonstatic->getNomUrl(2); |
|
460 | - $tabpay[$obj->rowid]["paymentdonationid"] = $paymentdonstatic->id; |
|
461 | - $tabtp[$obj->rowid][$account_pay_donation] = isset($tabtp[$obj->rowid][$account_pay_donation]) ? $tabtp[$obj->rowid][$account_pay_donation] + $amounttouse : $amounttouse; |
|
462 | - } elseif ($links[$key]['type'] == 'member') { |
|
463 | - $paymentsubscriptionstatic->id = $links[$key]['url_id']; |
|
464 | - $paymentsubscriptionstatic->ref = $links[$key]['url_id']; |
|
465 | - $paymentsubscriptionstatic->label = $links[$key]['label']; |
|
466 | - $tabpay[$obj->rowid]["lib"] .= ' '.$paymentsubscriptionstatic->getNomUrl(2); |
|
467 | - $tabpay[$obj->rowid]["paymentsubscriptionid"] = $paymentsubscriptionstatic->id; |
|
468 | - $paymentsubscriptionstatic->fetch($paymentsubscriptionstatic->id); |
|
469 | - $tabtp[$obj->rowid][$account_pay_subscription] = isset($tabtp[$obj->rowid][$account_pay_subscription]) ? $tabtp[$obj->rowid][$account_pay_subscription] + $amounttouse : $amounttouse; |
|
470 | - } elseif ($links[$key]['type'] == 'payment_vat') { // Payment VAT |
|
471 | - $paymentvatstatic->id = $links[$key]['url_id']; |
|
472 | - $paymentvatstatic->ref = $links[$key]['url_id']; |
|
473 | - $paymentvatstatic->label = $links[$key]['label']; |
|
474 | - $tabpay[$obj->rowid]["lib"] .= ' '.$paymentvatstatic->getNomUrl(2); |
|
475 | - $tabpay[$obj->rowid]["paymentvatid"] = $paymentvatstatic->id; |
|
476 | - $tabtp[$obj->rowid][$account_pay_vat] = isset($tabtp[$obj->rowid][$account_pay_vat]) ? $tabtp[$obj->rowid][$account_pay_vat] + $amounttouse : $amounttouse; |
|
477 | - } elseif ($links[$key]['type'] == 'payment_salary') { |
|
478 | - $paymentsalstatic->id = $links[$key]['url_id']; |
|
479 | - $paymentsalstatic->ref = $links[$key]['url_id']; |
|
480 | - $paymentsalstatic->label = $links[$key]['label']; |
|
481 | - $tabpay[$obj->rowid]["lib"] .= ' '.$paymentsalstatic->getNomUrl(2); |
|
482 | - $tabpay[$obj->rowid]["paymentsalid"] = $paymentsalstatic->id; |
|
483 | - |
|
484 | - // This part of code is no more required. it is here to solve case where a link were missing (with v14.0.0) and keep writing in accountancy complete. |
|
485 | - // Note: A better way to fix this is to delete payment of salary and recreate it, or to fix the bookkeeping table manually after. |
|
486 | - if (getDolGlobalString('ACCOUNTANCY_AUTOFIX_MISSING_LINK_TO_USER_ON_SALARY_BANK_PAYMENT')) { |
|
487 | - $tmpsalary = new Salary($db); |
|
488 | - $tmpsalary->fetch($paymentsalstatic->id); |
|
489 | - $tmpsalary->fetch_user($tmpsalary->fk_user); |
|
490 | - |
|
491 | - $userstatic->id = $tmpsalary->user->id; |
|
492 | - $userstatic->name = $tmpsalary->user->name; |
|
493 | - $userstatic->email = $tmpsalary->user->email; |
|
494 | - $userstatic->firstname = $tmpsalary->user->firstname; |
|
495 | - $userstatic->lastname = $tmpsalary->user->lastname; |
|
496 | - $userstatic->status = $tmpsalary->user->status; |
|
497 | - $userstatic->accountancy_code = $tmpsalary->user->accountancy_code; |
|
498 | - |
|
499 | - if ($userstatic->id > 0) { |
|
500 | - $tabpay[$obj->rowid]["soclib"] = $userstatic->getNomUrl(1, 'accountancy', 0); |
|
501 | - } else { |
|
502 | - $tabpay[$obj->rowid]["soclib"] = '???'; // Should not happen |
|
503 | - } |
|
379 | + // Special case to ask later to add more request to get information for old links without company link. |
|
380 | + if ($links[$key]['type'] == 'withdraw') { |
|
381 | + $tabmoreinfo[$obj->rowid]['withdraw'] = 1; |
|
382 | + } |
|
504 | 383 | |
505 | - if (empty($obj->typeop_user)) { // Add test to avoid to add amount twice if a link already exists also on user. |
|
506 | - $compta_user = $userstatic->accountancy_code; |
|
507 | - if ($compta_user) { |
|
508 | - $tabtp[$obj->rowid][$compta_user] += $amounttouse; |
|
509 | - $tabuser[$obj->rowid] = array( |
|
510 | - 'id' => $userstatic->id, |
|
511 | - 'name' => dolGetFirstLastname($userstatic->firstname, $userstatic->lastname), |
|
512 | - 'lastname' => $userstatic->lastname, |
|
513 | - 'firstname' => $userstatic->firstname, |
|
514 | - 'email' => $userstatic->email, |
|
515 | - 'accountancy_code' => $compta_user, |
|
516 | - 'status' => $userstatic->status |
|
517 | - ); |
|
518 | - } |
|
519 | - } |
|
520 | - } |
|
521 | - } elseif ($links[$key]['type'] == 'payment_expensereport') { |
|
522 | - $paymentexpensereportstatic->id = $links[$key]['url_id']; |
|
523 | - $tabpay[$obj->rowid]["lib"] .= $paymentexpensereportstatic->getNomUrl(2); |
|
524 | - $tabpay[$obj->rowid]["paymentexpensereport"] = $paymentexpensereportstatic->id; |
|
525 | - } elseif ($links[$key]['type'] == 'payment_various') { |
|
526 | - $paymentvariousstatic->id = $links[$key]['url_id']; |
|
527 | - $paymentvariousstatic->ref = $links[$key]['url_id']; |
|
528 | - $paymentvariousstatic->label = $links[$key]['label']; |
|
529 | - $tabpay[$obj->rowid]["lib"] .= ' '.$paymentvariousstatic->getNomUrl(2); |
|
530 | - $tabpay[$obj->rowid]["paymentvariousid"] = $paymentvariousstatic->id; |
|
531 | - $paymentvariousstatic->fetch($paymentvariousstatic->id); |
|
532 | - $account_various = (!empty($paymentvariousstatic->accountancy_code) ? $paymentvariousstatic->accountancy_code : 'NotDefined'); // NotDefined is a reserved word |
|
533 | - $account_subledger = (!empty($paymentvariousstatic->subledger_account) ? $paymentvariousstatic->subledger_account : ''); // NotDefined is a reserved word |
|
534 | - $tabpay[$obj->rowid]["account_various"] = $account_various; |
|
535 | - $tabtp[$obj->rowid][$account_subledger] = isset($tabtp[$obj->rowid][$account_subledger]) ? $tabtp[$obj->rowid][$account_subledger] + $amounttouse : $amounttouse; |
|
536 | - } elseif ($links[$key]['type'] == 'payment_loan') { |
|
537 | - $paymentloanstatic->id = $links[$key]['url_id']; |
|
538 | - $paymentloanstatic->ref = $links[$key]['url_id']; |
|
539 | - $paymentloanstatic->fk_loan = $links[$key]['url_id']; |
|
540 | - $tabpay[$obj->rowid]["lib"] .= ' '.$paymentloanstatic->getNomUrl(2); |
|
541 | - $tabpay[$obj->rowid]["paymentloanid"] = $paymentloanstatic->id; |
|
542 | - //$tabtp[$obj->rowid][$account_pay_loan] += $amounttouse; |
|
543 | - $sqlmid = 'SELECT pl.amount_capital, pl.amount_insurance, pl.amount_interest, l.accountancy_account_capital, l.accountancy_account_insurance, l.accountancy_account_interest'; |
|
544 | - $sqlmid .= ' FROM '.MAIN_DB_PREFIX.'payment_loan as pl, '.MAIN_DB_PREFIX.'loan as l'; |
|
545 | - $sqlmid .= ' WHERE l.rowid = pl.fk_loan AND pl.fk_bank = '.((int) $obj->rowid); |
|
546 | - |
|
547 | - dol_syslog("accountancy/journal/bankjournal.php:: sqlmid=".$sqlmid, LOG_DEBUG); |
|
548 | - $resultmid = $db->query($sqlmid); |
|
549 | - if ($resultmid) { |
|
550 | - $objmid = $db->fetch_object($resultmid); |
|
551 | - $tabtp[$obj->rowid][$objmid->accountancy_account_capital] = isset($tabtp[$obj->rowid][$objmid->accountancy_account_capital]) ? $tabtp[$obj->rowid][$objmid->accountancy_account_capital] - $objmid->amount_capital : $amounttouse; |
|
552 | - $tabtp[$obj->rowid][$objmid->accountancy_account_insurance] = isset($tabtp[$obj->rowid][$objmid->accountancy_account_insurance]) ? $tabtp[$obj->rowid][$objmid->accountancy_account_insurance] - $objmid->amount_insurance : $amounttouse; |
|
553 | - $tabtp[$obj->rowid][$objmid->accountancy_account_interest] = isset($tabtp[$obj->rowid][$objmid->accountancy_account_interest]) ? $tabtp[$obj->rowid][$objmid->accountancy_account_interest] - $objmid->amount_interes : $amounttouse; |
|
554 | - } |
|
555 | - } elseif ($links[$key]['type'] == 'banktransfert') { |
|
556 | - $accountLinestatic->fetch($links[$key]['url_id']); |
|
557 | - $tabpay[$obj->rowid]["lib"] .= ' '.$langs->trans("BankTransfer").'- '.$accountLinestatic ->getNomUrl(1); |
|
558 | - $tabtp[$obj->rowid][$account_transfer] = isset($tabtp[$obj->rowid][$account_transfer]) ? $tabtp[$obj->rowid][$account_transfer] + $amounttouse : $amounttouse; |
|
559 | - $bankaccountstatic->fetch($tabpay[$obj->rowid]['fk_bank_account']); |
|
560 | - $tabpay[$obj->rowid]["soclib"] = $bankaccountstatic->getNomUrl(2); |
|
561 | - } |
|
562 | - } |
|
563 | - } |
|
384 | + if ($links[$key]['type'] == 'payment') { |
|
385 | + $paymentstatic->id = $links[$key]['url_id']; |
|
386 | + $paymentstatic->ref = $links[$key]['url_id']; |
|
387 | + $tabpay[$obj->rowid]["lib"] .= ' '.$paymentstatic->getNomUrl(2, '', ''); // TODO Do not include list of invoice in tooltip, the dol_string_nohtmltag is ko with this |
|
388 | + $tabpay[$obj->rowid]["paymentid"] = $paymentstatic->id; |
|
389 | + } elseif ($links[$key]['type'] == 'payment_supplier') { |
|
390 | + $paymentsupplierstatic->id = $links[$key]['url_id']; |
|
391 | + $paymentsupplierstatic->ref = $links[$key]['url_id']; |
|
392 | + $tabpay[$obj->rowid]["lib"] .= ' '.$paymentsupplierstatic->getNomUrl(2); |
|
393 | + $tabpay[$obj->rowid]["paymentsupplierid"] = $paymentsupplierstatic->id; |
|
394 | + } elseif ($links[$key]['type'] == 'company') { |
|
395 | + $societestatic->id = $links[$key]['url_id']; |
|
396 | + $societestatic->name = $links[$key]['label']; |
|
397 | + $societestatic->email = $tabcompany[$obj->rowid]['email']; |
|
398 | + $tabpay[$obj->rowid]["soclib"] = $societestatic->getNomUrl(1, '', 30); |
|
399 | + if ($compta_soc) { |
|
400 | + if (empty($tabtp[$obj->rowid][$compta_soc])) { |
|
401 | + $tabtp[$obj->rowid][$compta_soc] = $amounttouse; |
|
402 | + } else { |
|
403 | + $tabtp[$obj->rowid][$compta_soc] += $amounttouse; |
|
404 | + } |
|
405 | + } |
|
406 | + } elseif ($links[$key]['type'] == 'user') { |
|
407 | + $userstatic->id = $links[$key]['url_id']; |
|
408 | + $userstatic->name = $links[$key]['label']; |
|
409 | + $userstatic->email = $tabuser[$obj->rowid]['email']; |
|
410 | + $userstatic->firstname = $tabuser[$obj->rowid]['firstname']; |
|
411 | + $userstatic->lastname = $tabuser[$obj->rowid]['lastname']; |
|
412 | + $userstatic->status = $tabuser[$obj->rowid]['status']; |
|
413 | + $userstatic->accountancy_code = $tabuser[$obj->rowid]['accountancy_code']; |
|
414 | + if ($userstatic->id > 0) { |
|
415 | + $tabpay[$obj->rowid]["soclib"] = $userstatic->getNomUrl(1, 'accountancy', 0); |
|
416 | + } else { |
|
417 | + $tabpay[$obj->rowid]["soclib"] = '???'; // Should not happen, but happens with old data when id of user was not saved on expense report payment. |
|
418 | + } |
|
419 | + if ($compta_user) { |
|
420 | + $tabtp[$obj->rowid][$compta_user] += $amounttouse; |
|
421 | + } |
|
422 | + } elseif ($links[$key]['type'] == 'sc') { |
|
423 | + $chargestatic->id = $links[$key]['url_id']; |
|
424 | + $chargestatic->ref = $links[$key]['url_id']; |
|
425 | + |
|
426 | + $tabpay[$obj->rowid]["lib"] .= ' '.$chargestatic->getNomUrl(2); |
|
427 | + $reg = array(); |
|
428 | + if (preg_match('/^\((.*)\)$/i', $links[$key]['label'], $reg)) { |
|
429 | + if ($reg[1] == 'socialcontribution') { |
|
430 | + $reg[1] = 'SocialContribution'; |
|
431 | + } |
|
432 | + $chargestatic->label = $langs->trans($reg[1]); |
|
433 | + } else { |
|
434 | + $chargestatic->label = $links[$key]['label']; |
|
435 | + } |
|
436 | + $chargestatic->ref = $chargestatic->label; |
|
437 | + $tabpay[$obj->rowid]["soclib"] = $chargestatic->getNomUrl(1, 30); |
|
438 | + $tabpay[$obj->rowid]["paymentscid"] = $chargestatic->id; |
|
439 | + |
|
440 | + // Retrieve the accounting code of the social contribution of the payment from link of payment. |
|
441 | + // Note: We have the social contribution id, it can be faster to get accounting code from social contribution id. |
|
442 | + $sqlmid = "SELECT cchgsoc.accountancy_code"; |
|
443 | + $sqlmid .= " FROM ".MAIN_DB_PREFIX."c_chargesociales cchgsoc"; |
|
444 | + $sqlmid .= " INNER JOIN ".MAIN_DB_PREFIX."chargesociales as chgsoc ON chgsoc.fk_type = cchgsoc.id"; |
|
445 | + $sqlmid .= " INNER JOIN ".MAIN_DB_PREFIX."paiementcharge as paycharg ON paycharg.fk_charge = chgsoc.rowid"; |
|
446 | + $sqlmid .= " INNER JOIN ".MAIN_DB_PREFIX."bank_url as bkurl ON bkurl.url_id=paycharg.rowid AND bkurl.type = 'payment_sc'"; |
|
447 | + $sqlmid .= " WHERE bkurl.fk_bank = ".((int) $obj->rowid); |
|
448 | + |
|
449 | + dol_syslog("accountancy/journal/bankjournal.php:: sqlmid=".$sqlmid, LOG_DEBUG); |
|
450 | + $resultmid = $db->query($sqlmid); |
|
451 | + if ($resultmid) { |
|
452 | + $objmid = $db->fetch_object($resultmid); |
|
453 | + $tabtp[$obj->rowid][$objmid->accountancy_code] = isset($tabtp[$obj->rowid][$objmid->accountancy_code]) ? $tabtp[$obj->rowid][$objmid->accountancy_code] + $amounttouse : $amounttouse; |
|
454 | + } |
|
455 | + } elseif ($links[$key]['type'] == 'payment_donation') { |
|
456 | + $paymentdonstatic->id = $links[$key]['url_id']; |
|
457 | + $paymentdonstatic->ref = $links[$key]['url_id']; |
|
458 | + $paymentdonstatic->fk_donation = $links[$key]['url_id']; |
|
459 | + $tabpay[$obj->rowid]["lib"] .= ' '.$paymentdonstatic->getNomUrl(2); |
|
460 | + $tabpay[$obj->rowid]["paymentdonationid"] = $paymentdonstatic->id; |
|
461 | + $tabtp[$obj->rowid][$account_pay_donation] = isset($tabtp[$obj->rowid][$account_pay_donation]) ? $tabtp[$obj->rowid][$account_pay_donation] + $amounttouse : $amounttouse; |
|
462 | + } elseif ($links[$key]['type'] == 'member') { |
|
463 | + $paymentsubscriptionstatic->id = $links[$key]['url_id']; |
|
464 | + $paymentsubscriptionstatic->ref = $links[$key]['url_id']; |
|
465 | + $paymentsubscriptionstatic->label = $links[$key]['label']; |
|
466 | + $tabpay[$obj->rowid]["lib"] .= ' '.$paymentsubscriptionstatic->getNomUrl(2); |
|
467 | + $tabpay[$obj->rowid]["paymentsubscriptionid"] = $paymentsubscriptionstatic->id; |
|
468 | + $paymentsubscriptionstatic->fetch($paymentsubscriptionstatic->id); |
|
469 | + $tabtp[$obj->rowid][$account_pay_subscription] = isset($tabtp[$obj->rowid][$account_pay_subscription]) ? $tabtp[$obj->rowid][$account_pay_subscription] + $amounttouse : $amounttouse; |
|
470 | + } elseif ($links[$key]['type'] == 'payment_vat') { // Payment VAT |
|
471 | + $paymentvatstatic->id = $links[$key]['url_id']; |
|
472 | + $paymentvatstatic->ref = $links[$key]['url_id']; |
|
473 | + $paymentvatstatic->label = $links[$key]['label']; |
|
474 | + $tabpay[$obj->rowid]["lib"] .= ' '.$paymentvatstatic->getNomUrl(2); |
|
475 | + $tabpay[$obj->rowid]["paymentvatid"] = $paymentvatstatic->id; |
|
476 | + $tabtp[$obj->rowid][$account_pay_vat] = isset($tabtp[$obj->rowid][$account_pay_vat]) ? $tabtp[$obj->rowid][$account_pay_vat] + $amounttouse : $amounttouse; |
|
477 | + } elseif ($links[$key]['type'] == 'payment_salary') { |
|
478 | + $paymentsalstatic->id = $links[$key]['url_id']; |
|
479 | + $paymentsalstatic->ref = $links[$key]['url_id']; |
|
480 | + $paymentsalstatic->label = $links[$key]['label']; |
|
481 | + $tabpay[$obj->rowid]["lib"] .= ' '.$paymentsalstatic->getNomUrl(2); |
|
482 | + $tabpay[$obj->rowid]["paymentsalid"] = $paymentsalstatic->id; |
|
483 | + |
|
484 | + // This part of code is no more required. it is here to solve case where a link were missing (with v14.0.0) and keep writing in accountancy complete. |
|
485 | + // Note: A better way to fix this is to delete payment of salary and recreate it, or to fix the bookkeeping table manually after. |
|
486 | + if (getDolGlobalString('ACCOUNTANCY_AUTOFIX_MISSING_LINK_TO_USER_ON_SALARY_BANK_PAYMENT')) { |
|
487 | + $tmpsalary = new Salary($db); |
|
488 | + $tmpsalary->fetch($paymentsalstatic->id); |
|
489 | + $tmpsalary->fetch_user($tmpsalary->fk_user); |
|
490 | + |
|
491 | + $userstatic->id = $tmpsalary->user->id; |
|
492 | + $userstatic->name = $tmpsalary->user->name; |
|
493 | + $userstatic->email = $tmpsalary->user->email; |
|
494 | + $userstatic->firstname = $tmpsalary->user->firstname; |
|
495 | + $userstatic->lastname = $tmpsalary->user->lastname; |
|
496 | + $userstatic->status = $tmpsalary->user->status; |
|
497 | + $userstatic->accountancy_code = $tmpsalary->user->accountancy_code; |
|
498 | + |
|
499 | + if ($userstatic->id > 0) { |
|
500 | + $tabpay[$obj->rowid]["soclib"] = $userstatic->getNomUrl(1, 'accountancy', 0); |
|
501 | + } else { |
|
502 | + $tabpay[$obj->rowid]["soclib"] = '???'; // Should not happen |
|
503 | + } |
|
504 | + |
|
505 | + if (empty($obj->typeop_user)) { // Add test to avoid to add amount twice if a link already exists also on user. |
|
506 | + $compta_user = $userstatic->accountancy_code; |
|
507 | + if ($compta_user) { |
|
508 | + $tabtp[$obj->rowid][$compta_user] += $amounttouse; |
|
509 | + $tabuser[$obj->rowid] = array( |
|
510 | + 'id' => $userstatic->id, |
|
511 | + 'name' => dolGetFirstLastname($userstatic->firstname, $userstatic->lastname), |
|
512 | + 'lastname' => $userstatic->lastname, |
|
513 | + 'firstname' => $userstatic->firstname, |
|
514 | + 'email' => $userstatic->email, |
|
515 | + 'accountancy_code' => $compta_user, |
|
516 | + 'status' => $userstatic->status |
|
517 | + ); |
|
518 | + } |
|
519 | + } |
|
520 | + } |
|
521 | + } elseif ($links[$key]['type'] == 'payment_expensereport') { |
|
522 | + $paymentexpensereportstatic->id = $links[$key]['url_id']; |
|
523 | + $tabpay[$obj->rowid]["lib"] .= $paymentexpensereportstatic->getNomUrl(2); |
|
524 | + $tabpay[$obj->rowid]["paymentexpensereport"] = $paymentexpensereportstatic->id; |
|
525 | + } elseif ($links[$key]['type'] == 'payment_various') { |
|
526 | + $paymentvariousstatic->id = $links[$key]['url_id']; |
|
527 | + $paymentvariousstatic->ref = $links[$key]['url_id']; |
|
528 | + $paymentvariousstatic->label = $links[$key]['label']; |
|
529 | + $tabpay[$obj->rowid]["lib"] .= ' '.$paymentvariousstatic->getNomUrl(2); |
|
530 | + $tabpay[$obj->rowid]["paymentvariousid"] = $paymentvariousstatic->id; |
|
531 | + $paymentvariousstatic->fetch($paymentvariousstatic->id); |
|
532 | + $account_various = (!empty($paymentvariousstatic->accountancy_code) ? $paymentvariousstatic->accountancy_code : 'NotDefined'); // NotDefined is a reserved word |
|
533 | + $account_subledger = (!empty($paymentvariousstatic->subledger_account) ? $paymentvariousstatic->subledger_account : ''); // NotDefined is a reserved word |
|
534 | + $tabpay[$obj->rowid]["account_various"] = $account_various; |
|
535 | + $tabtp[$obj->rowid][$account_subledger] = isset($tabtp[$obj->rowid][$account_subledger]) ? $tabtp[$obj->rowid][$account_subledger] + $amounttouse : $amounttouse; |
|
536 | + } elseif ($links[$key]['type'] == 'payment_loan') { |
|
537 | + $paymentloanstatic->id = $links[$key]['url_id']; |
|
538 | + $paymentloanstatic->ref = $links[$key]['url_id']; |
|
539 | + $paymentloanstatic->fk_loan = $links[$key]['url_id']; |
|
540 | + $tabpay[$obj->rowid]["lib"] .= ' '.$paymentloanstatic->getNomUrl(2); |
|
541 | + $tabpay[$obj->rowid]["paymentloanid"] = $paymentloanstatic->id; |
|
542 | + //$tabtp[$obj->rowid][$account_pay_loan] += $amounttouse; |
|
543 | + $sqlmid = 'SELECT pl.amount_capital, pl.amount_insurance, pl.amount_interest, l.accountancy_account_capital, l.accountancy_account_insurance, l.accountancy_account_interest'; |
|
544 | + $sqlmid .= ' FROM '.MAIN_DB_PREFIX.'payment_loan as pl, '.MAIN_DB_PREFIX.'loan as l'; |
|
545 | + $sqlmid .= ' WHERE l.rowid = pl.fk_loan AND pl.fk_bank = '.((int) $obj->rowid); |
|
546 | + |
|
547 | + dol_syslog("accountancy/journal/bankjournal.php:: sqlmid=".$sqlmid, LOG_DEBUG); |
|
548 | + $resultmid = $db->query($sqlmid); |
|
549 | + if ($resultmid) { |
|
550 | + $objmid = $db->fetch_object($resultmid); |
|
551 | + $tabtp[$obj->rowid][$objmid->accountancy_account_capital] = isset($tabtp[$obj->rowid][$objmid->accountancy_account_capital]) ? $tabtp[$obj->rowid][$objmid->accountancy_account_capital] - $objmid->amount_capital : $amounttouse; |
|
552 | + $tabtp[$obj->rowid][$objmid->accountancy_account_insurance] = isset($tabtp[$obj->rowid][$objmid->accountancy_account_insurance]) ? $tabtp[$obj->rowid][$objmid->accountancy_account_insurance] - $objmid->amount_insurance : $amounttouse; |
|
553 | + $tabtp[$obj->rowid][$objmid->accountancy_account_interest] = isset($tabtp[$obj->rowid][$objmid->accountancy_account_interest]) ? $tabtp[$obj->rowid][$objmid->accountancy_account_interest] - $objmid->amount_interes : $amounttouse; |
|
554 | + } |
|
555 | + } elseif ($links[$key]['type'] == 'banktransfert') { |
|
556 | + $accountLinestatic->fetch($links[$key]['url_id']); |
|
557 | + $tabpay[$obj->rowid]["lib"] .= ' '.$langs->trans("BankTransfer").'- '.$accountLinestatic ->getNomUrl(1); |
|
558 | + $tabtp[$obj->rowid][$account_transfer] = isset($tabtp[$obj->rowid][$account_transfer]) ? $tabtp[$obj->rowid][$account_transfer] + $amounttouse : $amounttouse; |
|
559 | + $bankaccountstatic->fetch($tabpay[$obj->rowid]['fk_bank_account']); |
|
560 | + $tabpay[$obj->rowid]["soclib"] = $bankaccountstatic->getNomUrl(2); |
|
561 | + } |
|
562 | + } |
|
563 | + } |
|
564 | 564 | |
565 | - if (empty($tabbq[$obj->rowid][$compta_bank])) { |
|
566 | - $tabbq[$obj->rowid][$compta_bank] = $amounttouse; |
|
567 | - } else { |
|
568 | - $tabbq[$obj->rowid][$compta_bank] += $amounttouse; |
|
569 | - } |
|
565 | + if (empty($tabbq[$obj->rowid][$compta_bank])) { |
|
566 | + $tabbq[$obj->rowid][$compta_bank] = $amounttouse; |
|
567 | + } else { |
|
568 | + $tabbq[$obj->rowid][$compta_bank] += $amounttouse; |
|
569 | + } |
|
570 | 570 | |
571 | - // If no links were found to know the amount on thirdparty, we try to guess it. |
|
572 | - // This may happens on bank entries without the links lines to 'company'. |
|
573 | - if (empty($tabtp[$obj->rowid]) && !empty($tabmoreinfo[$obj->rowid]['withdraw'])) { // If we don't find 'company' link because it is an old 'withdraw' record |
|
574 | - foreach ($links as $key => $val) { |
|
575 | - if ($links[$key]['type'] == 'payment') { |
|
576 | - // Get thirdparty |
|
577 | - $tmppayment->fetch($links[$key]['url_id']); |
|
578 | - $arrayofamounts = $tmppayment->getAmountsArray(); |
|
579 | - if (is_array($arrayofamounts)) { |
|
580 | - foreach ($arrayofamounts as $invoiceid => $amount) { |
|
581 | - $tmpinvoice->fetch($invoiceid); |
|
582 | - $tmpinvoice->fetch_thirdparty(); |
|
583 | - if ($tmpinvoice->thirdparty->code_compta_client) { |
|
584 | - $tabtp[$obj->rowid][$tmpinvoice->thirdparty->code_compta_client] += $amount; |
|
585 | - } |
|
586 | - } |
|
587 | - } |
|
588 | - } |
|
589 | - } |
|
590 | - } |
|
571 | + // If no links were found to know the amount on thirdparty, we try to guess it. |
|
572 | + // This may happens on bank entries without the links lines to 'company'. |
|
573 | + if (empty($tabtp[$obj->rowid]) && !empty($tabmoreinfo[$obj->rowid]['withdraw'])) { // If we don't find 'company' link because it is an old 'withdraw' record |
|
574 | + foreach ($links as $key => $val) { |
|
575 | + if ($links[$key]['type'] == 'payment') { |
|
576 | + // Get thirdparty |
|
577 | + $tmppayment->fetch($links[$key]['url_id']); |
|
578 | + $arrayofamounts = $tmppayment->getAmountsArray(); |
|
579 | + if (is_array($arrayofamounts)) { |
|
580 | + foreach ($arrayofamounts as $invoiceid => $amount) { |
|
581 | + $tmpinvoice->fetch($invoiceid); |
|
582 | + $tmpinvoice->fetch_thirdparty(); |
|
583 | + if ($tmpinvoice->thirdparty->code_compta_client) { |
|
584 | + $tabtp[$obj->rowid][$tmpinvoice->thirdparty->code_compta_client] += $amount; |
|
585 | + } |
|
586 | + } |
|
587 | + } |
|
588 | + } |
|
589 | + } |
|
590 | + } |
|
591 | 591 | |
592 | - // If no links were found to know the amount on thirdparty/user, we init it to account 'NotDefined'. |
|
593 | - if (empty($tabtp[$obj->rowid])) { |
|
594 | - $tabtp[$obj->rowid]['NotDefined'] = $tabbq[$obj->rowid][$compta_bank]; |
|
595 | - } |
|
592 | + // If no links were found to know the amount on thirdparty/user, we init it to account 'NotDefined'. |
|
593 | + if (empty($tabtp[$obj->rowid])) { |
|
594 | + $tabtp[$obj->rowid]['NotDefined'] = $tabbq[$obj->rowid][$compta_bank]; |
|
595 | + } |
|
596 | 596 | |
597 | - // Check account number is ok |
|
598 | - /*if ($action == 'writebookkeeping') // Make test now in such a case |
|
597 | + // Check account number is ok |
|
598 | + /*if ($action == 'writebookkeeping') // Make test now in such a case |
|
599 | 599 | { |
600 | 600 | reset($tabbq[$obj->rowid]); |
601 | 601 | $first_key_tabbq = key($tabbq[$obj->rowid]); |
@@ -613,12 +613,12 @@ discard block |
||
613 | 613 | } |
614 | 614 | }*/ |
615 | 615 | |
616 | - // if($obj->socid)$tabtp[$obj->rowid][$compta_soc] += $amounttouse; |
|
616 | + // if($obj->socid)$tabtp[$obj->rowid][$compta_soc] += $amounttouse; |
|
617 | 617 | |
618 | - $i++; |
|
619 | - } |
|
618 | + $i++; |
|
619 | + } |
|
620 | 620 | } else { |
621 | - dol_print_error($db); |
|
621 | + dol_print_error($db); |
|
622 | 622 | } |
623 | 623 | |
624 | 624 | |
@@ -630,455 +630,455 @@ discard block |
||
630 | 630 | |
631 | 631 | // Write bookkeeping |
632 | 632 | if (!$error && $action == 'writebookkeeping') { |
633 | - $now = dol_now(); |
|
634 | - |
|
635 | - $accountingaccountcustomer = new AccountingAccount($db); |
|
636 | - $accountingaccountcustomer->fetch(null, getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER'), true); |
|
637 | - |
|
638 | - $accountingaccountsupplier = new AccountingAccount($db); |
|
639 | - $accountingaccountsupplier->fetch(null, getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER'), true); |
|
640 | - |
|
641 | - $accountingaccountpayment = new AccountingAccount($db); |
|
642 | - $accountingaccountpayment->fetch(null, getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT'), true); |
|
643 | - |
|
644 | - $accountingaccountexpensereport = new AccountingAccount($db); |
|
645 | - $accountingaccountexpensereport->fetch(null, $conf->global->ACCOUNTING_ACCOUNT_EXPENSEREPORT, true); |
|
646 | - |
|
647 | - $accountingaccountsuspense = new AccountingAccount($db); |
|
648 | - $accountingaccountsuspense->fetch(null, getDolGlobalString('ACCOUNTING_ACCOUNT_SUSPENSE'), true); |
|
649 | - |
|
650 | - $error = 0; |
|
651 | - foreach ($tabpay as $key => $val) { // $key is rowid into llx_bank |
|
652 | - $date = dol_print_date($val["date"], 'day'); |
|
653 | - |
|
654 | - $ref = getSourceDocRef($val, $tabtype[$key]); |
|
655 | - |
|
656 | - $errorforline = 0; |
|
657 | - |
|
658 | - $totalcredit = 0; |
|
659 | - $totaldebit = 0; |
|
660 | - |
|
661 | - $db->begin(); |
|
662 | - |
|
663 | - // Introduce a protection. Total of tabtp must be total of tabbq |
|
664 | - //var_dump($tabpay); |
|
665 | - //var_dump($tabtp); |
|
666 | - //var_dump($tabbq);exit; |
|
667 | - |
|
668 | - // Bank |
|
669 | - if (!$errorforline && is_array($tabbq[$key])) { |
|
670 | - // Line into bank account |
|
671 | - foreach ($tabbq[$key] as $k => $mt) { |
|
672 | - if ($mt) { |
|
673 | - if (empty($conf->cache['accountingaccountincurrententity'][$k])) { |
|
674 | - $accountingaccount = new AccountingAccount($db); |
|
675 | - $accountingaccount->fetch(0, $k, true); // $k is accounting account of the bank. |
|
676 | - $conf->cache['accountingaccountincurrententity'][$k] = $accountingaccount; |
|
677 | - } else { |
|
678 | - $accountingaccount = $conf->cache['accountingaccountincurrententity'][$k]; |
|
679 | - } |
|
680 | - |
|
681 | - $account_label = $accountingaccount->label; |
|
682 | - |
|
683 | - $reflabel = ''; |
|
684 | - if (!empty($val['lib'])) { |
|
685 | - $reflabel .= dol_string_nohtmltag($val['lib'])." - "; |
|
686 | - } |
|
687 | - $reflabel .= $langs->trans("Bank").' '.dol_string_nohtmltag($val['bank_account_ref']); |
|
688 | - if (!empty($val['soclib'])) { |
|
689 | - $reflabel .= " - ".dol_string_nohtmltag($val['soclib']); |
|
690 | - } |
|
691 | - |
|
692 | - $bookkeeping = new BookKeeping($db); |
|
693 | - $bookkeeping->doc_date = $val["date"]; |
|
694 | - $bookkeeping->doc_ref = $ref; |
|
695 | - $bookkeeping->doc_type = 'bank'; |
|
696 | - $bookkeeping->fk_doc = $key; |
|
697 | - $bookkeeping->fk_docdet = $val["fk_bank"]; |
|
698 | - |
|
699 | - $bookkeeping->numero_compte = $k; |
|
700 | - $bookkeeping->label_compte = $account_label; |
|
701 | - |
|
702 | - $bookkeeping->label_operation = $reflabel; |
|
703 | - $bookkeeping->montant = $mt; |
|
704 | - $bookkeeping->sens = ($mt >= 0) ? 'D' : 'C'; |
|
705 | - $bookkeeping->debit = ($mt >= 0 ? $mt : 0); |
|
706 | - $bookkeeping->credit = ($mt < 0 ? -$mt : 0); |
|
707 | - $bookkeeping->code_journal = $journal; |
|
708 | - $bookkeeping->journal_label = $langs->transnoentities($journal_label); |
|
709 | - $bookkeeping->fk_user_author = $user->id; |
|
710 | - $bookkeeping->date_creation = $now; |
|
711 | - |
|
712 | - // No subledger_account value for the bank line but add a specific label_operation |
|
713 | - $bookkeeping->subledger_account = ''; |
|
714 | - $bookkeeping->label_operation = $reflabel; |
|
715 | - $bookkeeping->entity = $conf->entity; |
|
716 | - |
|
717 | - $totaldebit += $bookkeeping->debit; |
|
718 | - $totalcredit += $bookkeeping->credit; |
|
719 | - |
|
720 | - $result = $bookkeeping->create($user); |
|
721 | - if ($result < 0) { |
|
722 | - if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') { // Already exists |
|
723 | - $error++; |
|
724 | - $errorforline++; |
|
725 | - setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings'); |
|
726 | - } else { |
|
727 | - $error++; |
|
728 | - $errorforline++; |
|
729 | - setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors'); |
|
730 | - } |
|
731 | - } |
|
732 | - } |
|
733 | - } |
|
734 | - } |
|
735 | - |
|
736 | - // Third party |
|
737 | - if (!$errorforline) { |
|
738 | - if (is_array($tabtp[$key])) { |
|
739 | - // Line into thirdparty account |
|
740 | - foreach ($tabtp[$key] as $k => $mt) { |
|
741 | - if ($mt) { |
|
742 | - $lettering = false; |
|
743 | - |
|
744 | - $reflabel = ''; |
|
745 | - if (!empty($val['lib'])) { |
|
746 | - $reflabel .= dol_string_nohtmltag($val['lib']).($val['soclib'] ? " - " : ""); |
|
747 | - } |
|
748 | - if ($tabtype[$key] == 'banktransfert') { |
|
749 | - $reflabel .= dol_string_nohtmltag($langs->transnoentitiesnoconv('TransitionalAccount').' '.$account_transfer); |
|
750 | - } else { |
|
751 | - $reflabel .= dol_string_nohtmltag($val['soclib']); |
|
752 | - } |
|
633 | + $now = dol_now(); |
|
634 | + |
|
635 | + $accountingaccountcustomer = new AccountingAccount($db); |
|
636 | + $accountingaccountcustomer->fetch(null, getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER'), true); |
|
637 | + |
|
638 | + $accountingaccountsupplier = new AccountingAccount($db); |
|
639 | + $accountingaccountsupplier->fetch(null, getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER'), true); |
|
640 | + |
|
641 | + $accountingaccountpayment = new AccountingAccount($db); |
|
642 | + $accountingaccountpayment->fetch(null, getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT'), true); |
|
643 | + |
|
644 | + $accountingaccountexpensereport = new AccountingAccount($db); |
|
645 | + $accountingaccountexpensereport->fetch(null, $conf->global->ACCOUNTING_ACCOUNT_EXPENSEREPORT, true); |
|
646 | + |
|
647 | + $accountingaccountsuspense = new AccountingAccount($db); |
|
648 | + $accountingaccountsuspense->fetch(null, getDolGlobalString('ACCOUNTING_ACCOUNT_SUSPENSE'), true); |
|
649 | + |
|
650 | + $error = 0; |
|
651 | + foreach ($tabpay as $key => $val) { // $key is rowid into llx_bank |
|
652 | + $date = dol_print_date($val["date"], 'day'); |
|
653 | + |
|
654 | + $ref = getSourceDocRef($val, $tabtype[$key]); |
|
655 | + |
|
656 | + $errorforline = 0; |
|
657 | + |
|
658 | + $totalcredit = 0; |
|
659 | + $totaldebit = 0; |
|
660 | + |
|
661 | + $db->begin(); |
|
662 | + |
|
663 | + // Introduce a protection. Total of tabtp must be total of tabbq |
|
664 | + //var_dump($tabpay); |
|
665 | + //var_dump($tabtp); |
|
666 | + //var_dump($tabbq);exit; |
|
667 | + |
|
668 | + // Bank |
|
669 | + if (!$errorforline && is_array($tabbq[$key])) { |
|
670 | + // Line into bank account |
|
671 | + foreach ($tabbq[$key] as $k => $mt) { |
|
672 | + if ($mt) { |
|
673 | + if (empty($conf->cache['accountingaccountincurrententity'][$k])) { |
|
674 | + $accountingaccount = new AccountingAccount($db); |
|
675 | + $accountingaccount->fetch(0, $k, true); // $k is accounting account of the bank. |
|
676 | + $conf->cache['accountingaccountincurrententity'][$k] = $accountingaccount; |
|
677 | + } else { |
|
678 | + $accountingaccount = $conf->cache['accountingaccountincurrententity'][$k]; |
|
679 | + } |
|
680 | + |
|
681 | + $account_label = $accountingaccount->label; |
|
682 | + |
|
683 | + $reflabel = ''; |
|
684 | + if (!empty($val['lib'])) { |
|
685 | + $reflabel .= dol_string_nohtmltag($val['lib'])." - "; |
|
686 | + } |
|
687 | + $reflabel .= $langs->trans("Bank").' '.dol_string_nohtmltag($val['bank_account_ref']); |
|
688 | + if (!empty($val['soclib'])) { |
|
689 | + $reflabel .= " - ".dol_string_nohtmltag($val['soclib']); |
|
690 | + } |
|
691 | + |
|
692 | + $bookkeeping = new BookKeeping($db); |
|
693 | + $bookkeeping->doc_date = $val["date"]; |
|
694 | + $bookkeeping->doc_ref = $ref; |
|
695 | + $bookkeeping->doc_type = 'bank'; |
|
696 | + $bookkeeping->fk_doc = $key; |
|
697 | + $bookkeeping->fk_docdet = $val["fk_bank"]; |
|
698 | + |
|
699 | + $bookkeeping->numero_compte = $k; |
|
700 | + $bookkeeping->label_compte = $account_label; |
|
701 | + |
|
702 | + $bookkeeping->label_operation = $reflabel; |
|
703 | + $bookkeeping->montant = $mt; |
|
704 | + $bookkeeping->sens = ($mt >= 0) ? 'D' : 'C'; |
|
705 | + $bookkeeping->debit = ($mt >= 0 ? $mt : 0); |
|
706 | + $bookkeeping->credit = ($mt < 0 ? -$mt : 0); |
|
707 | + $bookkeeping->code_journal = $journal; |
|
708 | + $bookkeeping->journal_label = $langs->transnoentities($journal_label); |
|
709 | + $bookkeeping->fk_user_author = $user->id; |
|
710 | + $bookkeeping->date_creation = $now; |
|
711 | + |
|
712 | + // No subledger_account value for the bank line but add a specific label_operation |
|
713 | + $bookkeeping->subledger_account = ''; |
|
714 | + $bookkeeping->label_operation = $reflabel; |
|
715 | + $bookkeeping->entity = $conf->entity; |
|
716 | + |
|
717 | + $totaldebit += $bookkeeping->debit; |
|
718 | + $totalcredit += $bookkeeping->credit; |
|
719 | + |
|
720 | + $result = $bookkeeping->create($user); |
|
721 | + if ($result < 0) { |
|
722 | + if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') { // Already exists |
|
723 | + $error++; |
|
724 | + $errorforline++; |
|
725 | + setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings'); |
|
726 | + } else { |
|
727 | + $error++; |
|
728 | + $errorforline++; |
|
729 | + setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors'); |
|
730 | + } |
|
731 | + } |
|
732 | + } |
|
733 | + } |
|
734 | + } |
|
753 | 735 | |
754 | - $bookkeeping = new BookKeeping($db); |
|
755 | - $bookkeeping->doc_date = $val["date"]; |
|
756 | - $bookkeeping->doc_ref = $ref; |
|
757 | - $bookkeeping->doc_type = 'bank'; |
|
758 | - $bookkeeping->fk_doc = $key; |
|
759 | - $bookkeeping->fk_docdet = $val["fk_bank"]; |
|
760 | - |
|
761 | - $bookkeeping->label_operation = $reflabel; |
|
762 | - $bookkeeping->montant = $mt; |
|
763 | - $bookkeeping->sens = ($mt < 0) ? 'D' : 'C'; |
|
764 | - $bookkeeping->debit = ($mt < 0 ? -$mt : 0); |
|
765 | - $bookkeeping->credit = ($mt >= 0) ? $mt : 0; |
|
766 | - $bookkeeping->code_journal = $journal; |
|
767 | - $bookkeeping->journal_label = $langs->transnoentities($journal_label); |
|
768 | - $bookkeeping->fk_user_author = $user->id; |
|
769 | - $bookkeeping->date_creation = $now; |
|
770 | - |
|
771 | - if ($tabtype[$key] == 'payment') { // If payment is payment of customer invoice, we get ref of invoice |
|
772 | - $lettering = true; |
|
773 | - $bookkeeping->subledger_account = $k; // For payment, the subledger account is stored as $key of $tabtp |
|
774 | - $bookkeeping->subledger_label = $tabcompany[$key]['name']; // $tabcompany is defined only if we are sure there is 1 thirdparty for the bank transaction |
|
775 | - $bookkeeping->numero_compte = getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER'); |
|
776 | - $bookkeeping->label_compte = $accountingaccountcustomer->label; |
|
777 | - } elseif ($tabtype[$key] == 'payment_supplier') { // If payment is payment of supplier invoice, we get ref of invoice |
|
778 | - $lettering = true; |
|
779 | - $bookkeeping->subledger_account = $k; // For payment, the subledger account is stored as $key of $tabtp |
|
780 | - $bookkeeping->subledger_label = $tabcompany[$key]['name']; // $tabcompany is defined only if we are sure there is 1 thirdparty for the bank transaction |
|
781 | - $bookkeeping->numero_compte = getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER'); |
|
782 | - $bookkeeping->label_compte = $accountingaccountsupplier->label; |
|
783 | - } elseif ($tabtype[$key] == 'payment_expensereport') { |
|
784 | - $bookkeeping->subledger_account = $tabuser[$key]['accountancy_code']; |
|
785 | - $bookkeeping->subledger_label = $tabuser[$key]['name']; |
|
786 | - $bookkeeping->numero_compte = getDolGlobalString('ACCOUNTING_ACCOUNT_EXPENSEREPORT'); |
|
787 | - $bookkeeping->label_compte = $accountingaccountexpensereport->label; |
|
788 | - } elseif ($tabtype[$key] == 'payment_salary') { |
|
789 | - $bookkeeping->subledger_account = $tabuser[$key]['accountancy_code']; |
|
790 | - $bookkeeping->subledger_label = $tabuser[$key]['name']; |
|
791 | - $bookkeeping->numero_compte = getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT'); |
|
792 | - $bookkeeping->label_compte = $accountingaccountpayment->label; |
|
793 | - } elseif (in_array($tabtype[$key], array('sc', 'payment_sc'))) { // If payment is payment of social contribution |
|
794 | - $bookkeeping->subledger_account = ''; |
|
795 | - $bookkeeping->subledger_label = ''; |
|
796 | - $accountingaccount->fetch(null, $k, true); // TODO Use a cache |
|
797 | - $bookkeeping->numero_compte = $k; |
|
798 | - $bookkeeping->label_compte = $accountingaccount->label; |
|
799 | - } elseif ($tabtype[$key] == 'payment_vat') { |
|
800 | - $bookkeeping->subledger_account = ''; |
|
801 | - $bookkeeping->subledger_label = ''; |
|
802 | - $accountingaccount->fetch(null, $k, true); // TODO Use a cache |
|
803 | - $bookkeeping->numero_compte = $k; |
|
804 | - $bookkeeping->label_compte = $accountingaccount->label; |
|
805 | - } elseif ($tabtype[$key] == 'payment_donation') { |
|
806 | - $bookkeeping->subledger_account = ''; |
|
807 | - $bookkeeping->subledger_label = ''; |
|
808 | - $accountingaccount->fetch(null, $k, true); // TODO Use a cache |
|
809 | - $bookkeeping->numero_compte = $k; |
|
810 | - $bookkeeping->label_compte = $accountingaccount->label; |
|
811 | - } elseif ($tabtype[$key] == 'member') { |
|
812 | - $bookkeeping->subledger_account = ''; |
|
813 | - $bookkeeping->subledger_label = ''; |
|
814 | - $accountingaccount->fetch(null, $k, true); // TODO Use a cache |
|
815 | - $bookkeeping->numero_compte = $k; |
|
816 | - $bookkeeping->label_compte = $accountingaccount->label; |
|
817 | - } elseif ($tabtype[$key] == 'payment_loan') { |
|
818 | - $bookkeeping->subledger_account = ''; |
|
819 | - $bookkeeping->subledger_label = ''; |
|
820 | - $accountingaccount->fetch(null, $k, true); // TODO Use a cache |
|
821 | - $bookkeeping->numero_compte = $k; |
|
822 | - $bookkeeping->label_compte = $accountingaccount->label; |
|
823 | - } elseif ($tabtype[$key] == 'payment_various') { |
|
824 | - $bookkeeping->subledger_account = $k; |
|
825 | - $bookkeeping->subledger_label = $tabcompany[$key]['name']; |
|
826 | - $accountingaccount->fetch(null, $tabpay[$key]["account_various"], true); // TODO Use a cache |
|
827 | - $bookkeeping->numero_compte = $tabpay[$key]["account_various"]; |
|
828 | - $bookkeeping->label_compte = $accountingaccount->label; |
|
829 | - } elseif ($tabtype[$key] == 'banktransfert') { |
|
830 | - $bookkeeping->subledger_account = ''; |
|
831 | - $bookkeeping->subledger_label = ''; |
|
832 | - $accountingaccount->fetch(null, $k, true); // TODO Use a cache |
|
833 | - $bookkeeping->numero_compte = $k; |
|
834 | - $bookkeeping->label_compte = $accountingaccount->label; |
|
835 | - } else { |
|
836 | - if ($tabtype[$key] == 'unknown') { // Unknown transaction, we will use a waiting account for thirdparty. |
|
837 | - // Temporary account |
|
838 | - $bookkeeping->subledger_account = ''; |
|
839 | - $bookkeeping->subledger_label = ''; |
|
840 | - $bookkeeping->numero_compte = getDolGlobalString('ACCOUNTING_ACCOUNT_SUSPENSE'); |
|
841 | - $bookkeeping->label_compte = $accountingaccountsuspense->label; |
|
842 | - } |
|
843 | - } |
|
844 | - $bookkeeping->label_operation = $reflabel; |
|
845 | - $bookkeeping->entity = $conf->entity; |
|
846 | - |
|
847 | - $totaldebit += $bookkeeping->debit; |
|
848 | - $totalcredit += $bookkeeping->credit; |
|
849 | - |
|
850 | - $result = $bookkeeping->create($user); |
|
851 | - if ($result < 0) { |
|
852 | - if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') { // Already exists |
|
853 | - $error++; |
|
854 | - $errorforline++; |
|
855 | - setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings'); |
|
856 | - } else { |
|
857 | - $error++; |
|
858 | - $errorforline++; |
|
859 | - setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors'); |
|
860 | - } |
|
861 | - } else { |
|
862 | - if ($lettering && getDolGlobalInt('ACCOUNTING_ENABLE_LETTERING') && getDolGlobalInt('ACCOUNTING_ENABLE_AUTOLETTERING')) { |
|
863 | - require_once constant('DOL_DOCUMENT_ROOT') . '/accountancy/class/lettering.class.php'; |
|
864 | - $lettering_static = new Lettering($db); |
|
865 | - $nb_lettering = $lettering_static->bookkeepingLetteringAll(array($bookkeeping->id)); |
|
866 | - } |
|
867 | - } |
|
868 | - } |
|
869 | - } |
|
870 | - } else { // If thirdparty unknown, output the waiting account |
|
871 | - foreach ($tabbq[$key] as $k => $mt) { |
|
872 | - if ($mt) { |
|
873 | - $reflabel = ''; |
|
874 | - if (!empty($val['lib'])) { |
|
875 | - $reflabel .= dol_string_nohtmltag($val['lib'])." - "; |
|
876 | - } |
|
877 | - $reflabel .= dol_string_nohtmltag('WaitingAccount'); |
|
878 | - |
|
879 | - $bookkeeping = new BookKeeping($db); |
|
880 | - $bookkeeping->doc_date = $val["date"]; |
|
881 | - $bookkeeping->doc_ref = $ref; |
|
882 | - $bookkeeping->doc_type = 'bank'; |
|
883 | - $bookkeeping->fk_doc = $key; |
|
884 | - $bookkeeping->fk_docdet = $val["fk_bank"]; |
|
885 | - $bookkeeping->montant = $mt; |
|
886 | - $bookkeeping->sens = ($mt < 0) ? 'D' : 'C'; |
|
887 | - $bookkeeping->debit = ($mt < 0 ? -$mt : 0); |
|
888 | - $bookkeeping->credit = ($mt >= 0) ? $mt : 0; |
|
889 | - $bookkeeping->code_journal = $journal; |
|
890 | - $bookkeeping->journal_label = $langs->transnoentities($journal_label); |
|
891 | - $bookkeeping->fk_user_author = $user->id; |
|
892 | - $bookkeeping->date_creation = $now; |
|
893 | - $bookkeeping->label_compte = ''; |
|
894 | - $bookkeeping->label_operation = $reflabel; |
|
895 | - $bookkeeping->entity = $conf->entity; |
|
896 | - |
|
897 | - $totaldebit += $bookkeeping->debit; |
|
898 | - $totalcredit += $bookkeeping->credit; |
|
899 | - |
|
900 | - $result = $bookkeeping->create($user); |
|
901 | - |
|
902 | - if ($result < 0) { |
|
903 | - if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') { // Already exists |
|
904 | - $error++; |
|
905 | - $errorforline++; |
|
906 | - setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings'); |
|
907 | - } else { |
|
908 | - $error++; |
|
909 | - $errorforline++; |
|
910 | - setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors'); |
|
911 | - } |
|
912 | - } |
|
913 | - } |
|
914 | - } |
|
915 | - } |
|
916 | - } |
|
736 | + // Third party |
|
737 | + if (!$errorforline) { |
|
738 | + if (is_array($tabtp[$key])) { |
|
739 | + // Line into thirdparty account |
|
740 | + foreach ($tabtp[$key] as $k => $mt) { |
|
741 | + if ($mt) { |
|
742 | + $lettering = false; |
|
743 | + |
|
744 | + $reflabel = ''; |
|
745 | + if (!empty($val['lib'])) { |
|
746 | + $reflabel .= dol_string_nohtmltag($val['lib']).($val['soclib'] ? " - " : ""); |
|
747 | + } |
|
748 | + if ($tabtype[$key] == 'banktransfert') { |
|
749 | + $reflabel .= dol_string_nohtmltag($langs->transnoentitiesnoconv('TransitionalAccount').' '.$account_transfer); |
|
750 | + } else { |
|
751 | + $reflabel .= dol_string_nohtmltag($val['soclib']); |
|
752 | + } |
|
753 | + |
|
754 | + $bookkeeping = new BookKeeping($db); |
|
755 | + $bookkeeping->doc_date = $val["date"]; |
|
756 | + $bookkeeping->doc_ref = $ref; |
|
757 | + $bookkeeping->doc_type = 'bank'; |
|
758 | + $bookkeeping->fk_doc = $key; |
|
759 | + $bookkeeping->fk_docdet = $val["fk_bank"]; |
|
760 | + |
|
761 | + $bookkeeping->label_operation = $reflabel; |
|
762 | + $bookkeeping->montant = $mt; |
|
763 | + $bookkeeping->sens = ($mt < 0) ? 'D' : 'C'; |
|
764 | + $bookkeeping->debit = ($mt < 0 ? -$mt : 0); |
|
765 | + $bookkeeping->credit = ($mt >= 0) ? $mt : 0; |
|
766 | + $bookkeeping->code_journal = $journal; |
|
767 | + $bookkeeping->journal_label = $langs->transnoentities($journal_label); |
|
768 | + $bookkeeping->fk_user_author = $user->id; |
|
769 | + $bookkeeping->date_creation = $now; |
|
770 | + |
|
771 | + if ($tabtype[$key] == 'payment') { // If payment is payment of customer invoice, we get ref of invoice |
|
772 | + $lettering = true; |
|
773 | + $bookkeeping->subledger_account = $k; // For payment, the subledger account is stored as $key of $tabtp |
|
774 | + $bookkeeping->subledger_label = $tabcompany[$key]['name']; // $tabcompany is defined only if we are sure there is 1 thirdparty for the bank transaction |
|
775 | + $bookkeeping->numero_compte = getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER'); |
|
776 | + $bookkeeping->label_compte = $accountingaccountcustomer->label; |
|
777 | + } elseif ($tabtype[$key] == 'payment_supplier') { // If payment is payment of supplier invoice, we get ref of invoice |
|
778 | + $lettering = true; |
|
779 | + $bookkeeping->subledger_account = $k; // For payment, the subledger account is stored as $key of $tabtp |
|
780 | + $bookkeeping->subledger_label = $tabcompany[$key]['name']; // $tabcompany is defined only if we are sure there is 1 thirdparty for the bank transaction |
|
781 | + $bookkeeping->numero_compte = getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER'); |
|
782 | + $bookkeeping->label_compte = $accountingaccountsupplier->label; |
|
783 | + } elseif ($tabtype[$key] == 'payment_expensereport') { |
|
784 | + $bookkeeping->subledger_account = $tabuser[$key]['accountancy_code']; |
|
785 | + $bookkeeping->subledger_label = $tabuser[$key]['name']; |
|
786 | + $bookkeeping->numero_compte = getDolGlobalString('ACCOUNTING_ACCOUNT_EXPENSEREPORT'); |
|
787 | + $bookkeeping->label_compte = $accountingaccountexpensereport->label; |
|
788 | + } elseif ($tabtype[$key] == 'payment_salary') { |
|
789 | + $bookkeeping->subledger_account = $tabuser[$key]['accountancy_code']; |
|
790 | + $bookkeeping->subledger_label = $tabuser[$key]['name']; |
|
791 | + $bookkeeping->numero_compte = getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT'); |
|
792 | + $bookkeeping->label_compte = $accountingaccountpayment->label; |
|
793 | + } elseif (in_array($tabtype[$key], array('sc', 'payment_sc'))) { // If payment is payment of social contribution |
|
794 | + $bookkeeping->subledger_account = ''; |
|
795 | + $bookkeeping->subledger_label = ''; |
|
796 | + $accountingaccount->fetch(null, $k, true); // TODO Use a cache |
|
797 | + $bookkeeping->numero_compte = $k; |
|
798 | + $bookkeeping->label_compte = $accountingaccount->label; |
|
799 | + } elseif ($tabtype[$key] == 'payment_vat') { |
|
800 | + $bookkeeping->subledger_account = ''; |
|
801 | + $bookkeeping->subledger_label = ''; |
|
802 | + $accountingaccount->fetch(null, $k, true); // TODO Use a cache |
|
803 | + $bookkeeping->numero_compte = $k; |
|
804 | + $bookkeeping->label_compte = $accountingaccount->label; |
|
805 | + } elseif ($tabtype[$key] == 'payment_donation') { |
|
806 | + $bookkeeping->subledger_account = ''; |
|
807 | + $bookkeeping->subledger_label = ''; |
|
808 | + $accountingaccount->fetch(null, $k, true); // TODO Use a cache |
|
809 | + $bookkeeping->numero_compte = $k; |
|
810 | + $bookkeeping->label_compte = $accountingaccount->label; |
|
811 | + } elseif ($tabtype[$key] == 'member') { |
|
812 | + $bookkeeping->subledger_account = ''; |
|
813 | + $bookkeeping->subledger_label = ''; |
|
814 | + $accountingaccount->fetch(null, $k, true); // TODO Use a cache |
|
815 | + $bookkeeping->numero_compte = $k; |
|
816 | + $bookkeeping->label_compte = $accountingaccount->label; |
|
817 | + } elseif ($tabtype[$key] == 'payment_loan') { |
|
818 | + $bookkeeping->subledger_account = ''; |
|
819 | + $bookkeeping->subledger_label = ''; |
|
820 | + $accountingaccount->fetch(null, $k, true); // TODO Use a cache |
|
821 | + $bookkeeping->numero_compte = $k; |
|
822 | + $bookkeeping->label_compte = $accountingaccount->label; |
|
823 | + } elseif ($tabtype[$key] == 'payment_various') { |
|
824 | + $bookkeeping->subledger_account = $k; |
|
825 | + $bookkeeping->subledger_label = $tabcompany[$key]['name']; |
|
826 | + $accountingaccount->fetch(null, $tabpay[$key]["account_various"], true); // TODO Use a cache |
|
827 | + $bookkeeping->numero_compte = $tabpay[$key]["account_various"]; |
|
828 | + $bookkeeping->label_compte = $accountingaccount->label; |
|
829 | + } elseif ($tabtype[$key] == 'banktransfert') { |
|
830 | + $bookkeeping->subledger_account = ''; |
|
831 | + $bookkeeping->subledger_label = ''; |
|
832 | + $accountingaccount->fetch(null, $k, true); // TODO Use a cache |
|
833 | + $bookkeeping->numero_compte = $k; |
|
834 | + $bookkeeping->label_compte = $accountingaccount->label; |
|
835 | + } else { |
|
836 | + if ($tabtype[$key] == 'unknown') { // Unknown transaction, we will use a waiting account for thirdparty. |
|
837 | + // Temporary account |
|
838 | + $bookkeeping->subledger_account = ''; |
|
839 | + $bookkeeping->subledger_label = ''; |
|
840 | + $bookkeeping->numero_compte = getDolGlobalString('ACCOUNTING_ACCOUNT_SUSPENSE'); |
|
841 | + $bookkeeping->label_compte = $accountingaccountsuspense->label; |
|
842 | + } |
|
843 | + } |
|
844 | + $bookkeeping->label_operation = $reflabel; |
|
845 | + $bookkeeping->entity = $conf->entity; |
|
846 | + |
|
847 | + $totaldebit += $bookkeeping->debit; |
|
848 | + $totalcredit += $bookkeeping->credit; |
|
849 | + |
|
850 | + $result = $bookkeeping->create($user); |
|
851 | + if ($result < 0) { |
|
852 | + if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') { // Already exists |
|
853 | + $error++; |
|
854 | + $errorforline++; |
|
855 | + setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings'); |
|
856 | + } else { |
|
857 | + $error++; |
|
858 | + $errorforline++; |
|
859 | + setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors'); |
|
860 | + } |
|
861 | + } else { |
|
862 | + if ($lettering && getDolGlobalInt('ACCOUNTING_ENABLE_LETTERING') && getDolGlobalInt('ACCOUNTING_ENABLE_AUTOLETTERING')) { |
|
863 | + require_once constant('DOL_DOCUMENT_ROOT') . '/accountancy/class/lettering.class.php'; |
|
864 | + $lettering_static = new Lettering($db); |
|
865 | + $nb_lettering = $lettering_static->bookkeepingLetteringAll(array($bookkeeping->id)); |
|
866 | + } |
|
867 | + } |
|
868 | + } |
|
869 | + } |
|
870 | + } else { // If thirdparty unknown, output the waiting account |
|
871 | + foreach ($tabbq[$key] as $k => $mt) { |
|
872 | + if ($mt) { |
|
873 | + $reflabel = ''; |
|
874 | + if (!empty($val['lib'])) { |
|
875 | + $reflabel .= dol_string_nohtmltag($val['lib'])." - "; |
|
876 | + } |
|
877 | + $reflabel .= dol_string_nohtmltag('WaitingAccount'); |
|
878 | + |
|
879 | + $bookkeeping = new BookKeeping($db); |
|
880 | + $bookkeeping->doc_date = $val["date"]; |
|
881 | + $bookkeeping->doc_ref = $ref; |
|
882 | + $bookkeeping->doc_type = 'bank'; |
|
883 | + $bookkeeping->fk_doc = $key; |
|
884 | + $bookkeeping->fk_docdet = $val["fk_bank"]; |
|
885 | + $bookkeeping->montant = $mt; |
|
886 | + $bookkeeping->sens = ($mt < 0) ? 'D' : 'C'; |
|
887 | + $bookkeeping->debit = ($mt < 0 ? -$mt : 0); |
|
888 | + $bookkeeping->credit = ($mt >= 0) ? $mt : 0; |
|
889 | + $bookkeeping->code_journal = $journal; |
|
890 | + $bookkeeping->journal_label = $langs->transnoentities($journal_label); |
|
891 | + $bookkeeping->fk_user_author = $user->id; |
|
892 | + $bookkeeping->date_creation = $now; |
|
893 | + $bookkeeping->label_compte = ''; |
|
894 | + $bookkeeping->label_operation = $reflabel; |
|
895 | + $bookkeeping->entity = $conf->entity; |
|
896 | + |
|
897 | + $totaldebit += $bookkeeping->debit; |
|
898 | + $totalcredit += $bookkeeping->credit; |
|
899 | + |
|
900 | + $result = $bookkeeping->create($user); |
|
901 | + |
|
902 | + if ($result < 0) { |
|
903 | + if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') { // Already exists |
|
904 | + $error++; |
|
905 | + $errorforline++; |
|
906 | + setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings'); |
|
907 | + } else { |
|
908 | + $error++; |
|
909 | + $errorforline++; |
|
910 | + setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors'); |
|
911 | + } |
|
912 | + } |
|
913 | + } |
|
914 | + } |
|
915 | + } |
|
916 | + } |
|
917 | 917 | |
918 | - if (price2num($totaldebit, 'MT') != price2num($totalcredit, 'MT')) { |
|
919 | - $error++; |
|
920 | - $errorforline++; |
|
921 | - setEventMessages('We tried to insert a non balanced transaction in book for '.$ref.'. Canceled. Surely a bug.', null, 'errors'); |
|
922 | - } |
|
918 | + if (price2num($totaldebit, 'MT') != price2num($totalcredit, 'MT')) { |
|
919 | + $error++; |
|
920 | + $errorforline++; |
|
921 | + setEventMessages('We tried to insert a non balanced transaction in book for '.$ref.'. Canceled. Surely a bug.', null, 'errors'); |
|
922 | + } |
|
923 | 923 | |
924 | - if (!$errorforline) { |
|
925 | - $db->commit(); |
|
926 | - } else { |
|
927 | - //print 'KO for line '.$key.' '.$error.'<br>'; |
|
928 | - $db->rollback(); |
|
924 | + if (!$errorforline) { |
|
925 | + $db->commit(); |
|
926 | + } else { |
|
927 | + //print 'KO for line '.$key.' '.$error.'<br>'; |
|
928 | + $db->rollback(); |
|
929 | 929 | |
930 | - $MAXNBERRORS = 5; |
|
931 | - if ($error >= $MAXNBERRORS) { |
|
932 | - setEventMessages($langs->trans("ErrorTooManyErrorsProcessStopped").' (>'.$MAXNBERRORS.')', null, 'errors'); |
|
933 | - break; // Break in the foreach |
|
934 | - } |
|
935 | - } |
|
936 | - } |
|
937 | - |
|
938 | - if (empty($error) && count($tabpay) > 0) { |
|
939 | - setEventMessages($langs->trans("GeneralLedgerIsWritten"), null, 'mesgs'); |
|
940 | - } elseif (count($tabpay) == $error) { |
|
941 | - setEventMessages($langs->trans("NoNewRecordSaved"), null, 'warnings'); |
|
942 | - } else { |
|
943 | - setEventMessages($langs->trans("GeneralLedgerSomeRecordWasNotRecorded"), null, 'warnings'); |
|
944 | - } |
|
945 | - |
|
946 | - $action = ''; |
|
947 | - |
|
948 | - // Must reload data, so we make a redirect |
|
949 | - if (count($tabpay) != $error) { |
|
950 | - $param = 'id_journal='.$id_journal; |
|
951 | - $param .= '&date_startday='.$date_startday; |
|
952 | - $param .= '&date_startmonth='.$date_startmonth; |
|
953 | - $param .= '&date_startyear='.$date_startyear; |
|
954 | - $param .= '&date_endday='.$date_endday; |
|
955 | - $param .= '&date_endmonth='.$date_endmonth; |
|
956 | - $param .= '&date_endyear='.$date_endyear; |
|
957 | - $param .= '&in_bookkeeping='.$in_bookkeeping; |
|
958 | - header("Location: ".$_SERVER['PHP_SELF'].($param ? '?'.$param : '')); |
|
959 | - exit; |
|
960 | - } |
|
930 | + $MAXNBERRORS = 5; |
|
931 | + if ($error >= $MAXNBERRORS) { |
|
932 | + setEventMessages($langs->trans("ErrorTooManyErrorsProcessStopped").' (>'.$MAXNBERRORS.')', null, 'errors'); |
|
933 | + break; // Break in the foreach |
|
934 | + } |
|
935 | + } |
|
936 | + } |
|
937 | + |
|
938 | + if (empty($error) && count($tabpay) > 0) { |
|
939 | + setEventMessages($langs->trans("GeneralLedgerIsWritten"), null, 'mesgs'); |
|
940 | + } elseif (count($tabpay) == $error) { |
|
941 | + setEventMessages($langs->trans("NoNewRecordSaved"), null, 'warnings'); |
|
942 | + } else { |
|
943 | + setEventMessages($langs->trans("GeneralLedgerSomeRecordWasNotRecorded"), null, 'warnings'); |
|
944 | + } |
|
945 | + |
|
946 | + $action = ''; |
|
947 | + |
|
948 | + // Must reload data, so we make a redirect |
|
949 | + if (count($tabpay) != $error) { |
|
950 | + $param = 'id_journal='.$id_journal; |
|
951 | + $param .= '&date_startday='.$date_startday; |
|
952 | + $param .= '&date_startmonth='.$date_startmonth; |
|
953 | + $param .= '&date_startyear='.$date_startyear; |
|
954 | + $param .= '&date_endday='.$date_endday; |
|
955 | + $param .= '&date_endmonth='.$date_endmonth; |
|
956 | + $param .= '&date_endyear='.$date_endyear; |
|
957 | + $param .= '&in_bookkeeping='.$in_bookkeeping; |
|
958 | + header("Location: ".$_SERVER['PHP_SELF'].($param ? '?'.$param : '')); |
|
959 | + exit; |
|
960 | + } |
|
961 | 961 | } |
962 | 962 | |
963 | 963 | |
964 | 964 | |
965 | 965 | // Export |
966 | 966 | if ($action == 'exportcsv') { // ISO and not UTF8 ! |
967 | - $sep = getDolGlobalString('ACCOUNTING_EXPORT_SEPARATORCSV'); |
|
968 | - |
|
969 | - $filename = 'journal'; |
|
970 | - $type_export = 'journal'; |
|
971 | - include DOL_DOCUMENT_ROOT.'/accountancy/tpl/export_journal.tpl.php'; |
|
972 | - |
|
973 | - // CSV header line |
|
974 | - print '"'.$langs->transnoentitiesnoconv("BankId").'"'.$sep; |
|
975 | - print '"'.$langs->transnoentitiesnoconv("Date").'"'.$sep; |
|
976 | - print '"'.$langs->transnoentitiesnoconv("PaymentMode").'"'.$sep; |
|
977 | - print '"'.$langs->transnoentitiesnoconv("AccountAccounting").'"'.$sep; |
|
978 | - print '"'.$langs->transnoentitiesnoconv("LedgerAccount").'"'.$sep; |
|
979 | - print '"'.$langs->transnoentitiesnoconv("SubledgerAccount").'"'.$sep; |
|
980 | - print '"'.$langs->transnoentitiesnoconv("Label").'"'.$sep; |
|
981 | - print '"'.$langs->transnoentitiesnoconv("AccountingDebit").'"'.$sep; |
|
982 | - print '"'.$langs->transnoentitiesnoconv("AccountingCredit").'"'.$sep; |
|
983 | - print '"'.$langs->transnoentitiesnoconv("Journal").'"'.$sep; |
|
984 | - print '"'.$langs->transnoentitiesnoconv("Note").'"'.$sep; |
|
985 | - print "\n"; |
|
986 | - |
|
987 | - foreach ($tabpay as $key => $val) { |
|
988 | - $date = dol_print_date($val["date"], 'day'); |
|
989 | - |
|
990 | - $ref = getSourceDocRef($val, $tabtype[$key]); |
|
991 | - |
|
992 | - // Bank |
|
993 | - foreach ($tabbq[$key] as $k => $mt) { |
|
994 | - if ($mt) { |
|
995 | - $reflabel = ''; |
|
996 | - if (!empty($val['lib'])) { |
|
997 | - $reflabel .= dol_string_nohtmltag($val['lib'])." - "; |
|
998 | - } |
|
999 | - $reflabel .= $langs->trans("Bank").' '.dol_string_nohtmltag($val['bank_account_ref']); |
|
1000 | - if (!empty($val['soclib'])) { |
|
1001 | - $reflabel .= " - ".dol_string_nohtmltag($val['soclib']); |
|
1002 | - } |
|
1003 | - |
|
1004 | - print '"'.$key.'"'.$sep; |
|
1005 | - print '"'.$date.'"'.$sep; |
|
1006 | - print '"'.$val["type_payment"].'"'.$sep; |
|
1007 | - print '"'.length_accountg(html_entity_decode($k)).'"'.$sep; |
|
1008 | - print '"'.length_accounta(html_entity_decode($k)).'"'.$sep; |
|
1009 | - print " ".$sep; |
|
1010 | - print '"'.$reflabel.'"'.$sep; |
|
1011 | - print '"'.($mt >= 0 ? price($mt) : '').'"'.$sep; |
|
1012 | - print '"'.($mt < 0 ? price(-$mt) : '').'"'.$sep; |
|
1013 | - print '"'.$journal.'"'.$sep; |
|
1014 | - print '"'.dol_string_nohtmltag($ref).'"'.$sep; |
|
1015 | - print "\n"; |
|
1016 | - } |
|
1017 | - } |
|
967 | + $sep = getDolGlobalString('ACCOUNTING_EXPORT_SEPARATORCSV'); |
|
968 | + |
|
969 | + $filename = 'journal'; |
|
970 | + $type_export = 'journal'; |
|
971 | + include DOL_DOCUMENT_ROOT.'/accountancy/tpl/export_journal.tpl.php'; |
|
972 | + |
|
973 | + // CSV header line |
|
974 | + print '"'.$langs->transnoentitiesnoconv("BankId").'"'.$sep; |
|
975 | + print '"'.$langs->transnoentitiesnoconv("Date").'"'.$sep; |
|
976 | + print '"'.$langs->transnoentitiesnoconv("PaymentMode").'"'.$sep; |
|
977 | + print '"'.$langs->transnoentitiesnoconv("AccountAccounting").'"'.$sep; |
|
978 | + print '"'.$langs->transnoentitiesnoconv("LedgerAccount").'"'.$sep; |
|
979 | + print '"'.$langs->transnoentitiesnoconv("SubledgerAccount").'"'.$sep; |
|
980 | + print '"'.$langs->transnoentitiesnoconv("Label").'"'.$sep; |
|
981 | + print '"'.$langs->transnoentitiesnoconv("AccountingDebit").'"'.$sep; |
|
982 | + print '"'.$langs->transnoentitiesnoconv("AccountingCredit").'"'.$sep; |
|
983 | + print '"'.$langs->transnoentitiesnoconv("Journal").'"'.$sep; |
|
984 | + print '"'.$langs->transnoentitiesnoconv("Note").'"'.$sep; |
|
985 | + print "\n"; |
|
986 | + |
|
987 | + foreach ($tabpay as $key => $val) { |
|
988 | + $date = dol_print_date($val["date"], 'day'); |
|
989 | + |
|
990 | + $ref = getSourceDocRef($val, $tabtype[$key]); |
|
991 | + |
|
992 | + // Bank |
|
993 | + foreach ($tabbq[$key] as $k => $mt) { |
|
994 | + if ($mt) { |
|
995 | + $reflabel = ''; |
|
996 | + if (!empty($val['lib'])) { |
|
997 | + $reflabel .= dol_string_nohtmltag($val['lib'])." - "; |
|
998 | + } |
|
999 | + $reflabel .= $langs->trans("Bank").' '.dol_string_nohtmltag($val['bank_account_ref']); |
|
1000 | + if (!empty($val['soclib'])) { |
|
1001 | + $reflabel .= " - ".dol_string_nohtmltag($val['soclib']); |
|
1002 | + } |
|
1018 | 1003 | |
1019 | - // Third party |
|
1020 | - if (is_array($tabtp[$key])) { |
|
1021 | - foreach ($tabtp[$key] as $k => $mt) { |
|
1022 | - if ($mt) { |
|
1023 | - $reflabel = ''; |
|
1024 | - if (!empty($val['lib'])) { |
|
1025 | - $reflabel .= dol_string_nohtmltag($val['lib']).($val['soclib'] ? " - " : ""); |
|
1026 | - } |
|
1027 | - if ($tabtype[$key] == 'banktransfert') { |
|
1028 | - $reflabel .= dol_string_nohtmltag($langs->transnoentitiesnoconv('TransitionalAccount').' '.$account_transfer); |
|
1029 | - } else { |
|
1030 | - $reflabel .= dol_string_nohtmltag($val['soclib']); |
|
1031 | - } |
|
1004 | + print '"'.$key.'"'.$sep; |
|
1005 | + print '"'.$date.'"'.$sep; |
|
1006 | + print '"'.$val["type_payment"].'"'.$sep; |
|
1007 | + print '"'.length_accountg(html_entity_decode($k)).'"'.$sep; |
|
1008 | + print '"'.length_accounta(html_entity_decode($k)).'"'.$sep; |
|
1009 | + print " ".$sep; |
|
1010 | + print '"'.$reflabel.'"'.$sep; |
|
1011 | + print '"'.($mt >= 0 ? price($mt) : '').'"'.$sep; |
|
1012 | + print '"'.($mt < 0 ? price(-$mt) : '').'"'.$sep; |
|
1013 | + print '"'.$journal.'"'.$sep; |
|
1014 | + print '"'.dol_string_nohtmltag($ref).'"'.$sep; |
|
1015 | + print "\n"; |
|
1016 | + } |
|
1017 | + } |
|
1032 | 1018 | |
1033 | - print '"'.$key.'"'.$sep; |
|
1034 | - print '"'.$date.'"'.$sep; |
|
1035 | - print '"'.$val["type_payment"].'"'.$sep; |
|
1036 | - print '"'.length_accountg(html_entity_decode($k)).'"'.$sep; |
|
1037 | - if ($tabtype[$key] == 'payment_supplier') { |
|
1038 | - print '"'.getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER').'"'.$sep; |
|
1039 | - } elseif ($tabtype[$key] == 'payment') { |
|
1040 | - print '"'.getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER').'"'.$sep; |
|
1041 | - } elseif ($tabtype[$key] == 'payment_expensereport') { |
|
1042 | - print '"'.getDolGlobalString('ACCOUNTING_ACCOUNT_EXPENSEREPORT').'"'.$sep; |
|
1043 | - } elseif ($tabtype[$key] == 'payment_salary') { |
|
1044 | - print '"'.getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT').'"'.$sep; |
|
1045 | - } else { |
|
1046 | - print '"'.length_accountg(html_entity_decode($k)).'"'.$sep; |
|
1047 | - } |
|
1048 | - print '"'.length_accounta(html_entity_decode($k)).'"'.$sep; |
|
1049 | - print '"'.$reflabel.'"'.$sep; |
|
1050 | - print '"'.($mt < 0 ? price(-$mt) : '').'"'.$sep; |
|
1051 | - print '"'.($mt >= 0 ? price($mt) : '').'"'.$sep; |
|
1052 | - print '"'.$journal.'"'.$sep; |
|
1053 | - print '"'.dol_string_nohtmltag($ref).'"'.$sep; |
|
1054 | - print "\n"; |
|
1055 | - } |
|
1056 | - } |
|
1057 | - } else { // If thirdparty unknown, output the waiting account |
|
1058 | - foreach ($tabbq[$key] as $k => $mt) { |
|
1059 | - if ($mt) { |
|
1060 | - $reflabel = ''; |
|
1061 | - if (!empty($val['lib'])) { |
|
1062 | - $reflabel .= dol_string_nohtmltag($val['lib'])." - "; |
|
1063 | - } |
|
1064 | - $reflabel .= dol_string_nohtmltag('WaitingAccount'); |
|
1065 | - |
|
1066 | - print '"'.$key.'"'.$sep; |
|
1067 | - print '"'.$date.'"'.$sep; |
|
1068 | - print '"'.$val["type_payment"].'"'.$sep; |
|
1069 | - print '"'.length_accountg(getDolGlobalString('ACCOUNTING_ACCOUNT_SUSPENSE')).'"'.$sep; |
|
1070 | - print '"'.length_accounta(getDolGlobalString('ACCOUNTING_ACCOUNT_SUSPENSE')).'"'.$sep; |
|
1071 | - print $sep; |
|
1072 | - print '"'.$reflabel.'"'.$sep; |
|
1073 | - print '"'.($mt < 0 ? price(-$mt) : '').'"'.$sep; |
|
1074 | - print '"'.($mt >= 0 ? price($mt) : '').'"'.$sep; |
|
1075 | - print '"'.$journal.'"'.$sep; |
|
1076 | - print '"'.dol_string_nohtmltag($ref).'"'.$sep; |
|
1077 | - print "\n"; |
|
1078 | - } |
|
1079 | - } |
|
1080 | - } |
|
1081 | - } |
|
1019 | + // Third party |
|
1020 | + if (is_array($tabtp[$key])) { |
|
1021 | + foreach ($tabtp[$key] as $k => $mt) { |
|
1022 | + if ($mt) { |
|
1023 | + $reflabel = ''; |
|
1024 | + if (!empty($val['lib'])) { |
|
1025 | + $reflabel .= dol_string_nohtmltag($val['lib']).($val['soclib'] ? " - " : ""); |
|
1026 | + } |
|
1027 | + if ($tabtype[$key] == 'banktransfert') { |
|
1028 | + $reflabel .= dol_string_nohtmltag($langs->transnoentitiesnoconv('TransitionalAccount').' '.$account_transfer); |
|
1029 | + } else { |
|
1030 | + $reflabel .= dol_string_nohtmltag($val['soclib']); |
|
1031 | + } |
|
1032 | + |
|
1033 | + print '"'.$key.'"'.$sep; |
|
1034 | + print '"'.$date.'"'.$sep; |
|
1035 | + print '"'.$val["type_payment"].'"'.$sep; |
|
1036 | + print '"'.length_accountg(html_entity_decode($k)).'"'.$sep; |
|
1037 | + if ($tabtype[$key] == 'payment_supplier') { |
|
1038 | + print '"'.getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER').'"'.$sep; |
|
1039 | + } elseif ($tabtype[$key] == 'payment') { |
|
1040 | + print '"'.getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER').'"'.$sep; |
|
1041 | + } elseif ($tabtype[$key] == 'payment_expensereport') { |
|
1042 | + print '"'.getDolGlobalString('ACCOUNTING_ACCOUNT_EXPENSEREPORT').'"'.$sep; |
|
1043 | + } elseif ($tabtype[$key] == 'payment_salary') { |
|
1044 | + print '"'.getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT').'"'.$sep; |
|
1045 | + } else { |
|
1046 | + print '"'.length_accountg(html_entity_decode($k)).'"'.$sep; |
|
1047 | + } |
|
1048 | + print '"'.length_accounta(html_entity_decode($k)).'"'.$sep; |
|
1049 | + print '"'.$reflabel.'"'.$sep; |
|
1050 | + print '"'.($mt < 0 ? price(-$mt) : '').'"'.$sep; |
|
1051 | + print '"'.($mt >= 0 ? price($mt) : '').'"'.$sep; |
|
1052 | + print '"'.$journal.'"'.$sep; |
|
1053 | + print '"'.dol_string_nohtmltag($ref).'"'.$sep; |
|
1054 | + print "\n"; |
|
1055 | + } |
|
1056 | + } |
|
1057 | + } else { // If thirdparty unknown, output the waiting account |
|
1058 | + foreach ($tabbq[$key] as $k => $mt) { |
|
1059 | + if ($mt) { |
|
1060 | + $reflabel = ''; |
|
1061 | + if (!empty($val['lib'])) { |
|
1062 | + $reflabel .= dol_string_nohtmltag($val['lib'])." - "; |
|
1063 | + } |
|
1064 | + $reflabel .= dol_string_nohtmltag('WaitingAccount'); |
|
1065 | + |
|
1066 | + print '"'.$key.'"'.$sep; |
|
1067 | + print '"'.$date.'"'.$sep; |
|
1068 | + print '"'.$val["type_payment"].'"'.$sep; |
|
1069 | + print '"'.length_accountg(getDolGlobalString('ACCOUNTING_ACCOUNT_SUSPENSE')).'"'.$sep; |
|
1070 | + print '"'.length_accounta(getDolGlobalString('ACCOUNTING_ACCOUNT_SUSPENSE')).'"'.$sep; |
|
1071 | + print $sep; |
|
1072 | + print '"'.$reflabel.'"'.$sep; |
|
1073 | + print '"'.($mt < 0 ? price(-$mt) : '').'"'.$sep; |
|
1074 | + print '"'.($mt >= 0 ? price($mt) : '').'"'.$sep; |
|
1075 | + print '"'.$journal.'"'.$sep; |
|
1076 | + print '"'.dol_string_nohtmltag($ref).'"'.$sep; |
|
1077 | + print "\n"; |
|
1078 | + } |
|
1079 | + } |
|
1080 | + } |
|
1081 | + } |
|
1082 | 1082 | } |
1083 | 1083 | |
1084 | 1084 | |
@@ -1089,117 +1089,117 @@ discard block |
||
1089 | 1089 | $form = new Form($db); |
1090 | 1090 | |
1091 | 1091 | if (empty($action) || $action == 'view') { |
1092 | - $invoicestatic = new Facture($db); |
|
1093 | - $invoicesupplierstatic = new FactureFournisseur($db); |
|
1094 | - $expensereportstatic = new ExpenseReport($db); |
|
1095 | - $vatstatic = new Tva($db); |
|
1096 | - $donationstatic = new Don($db); |
|
1097 | - $loanstatic = new Loan($db); |
|
1098 | - $salarystatic = new Salary($db); |
|
1099 | - $variousstatic = new PaymentVarious($db); |
|
1100 | - |
|
1101 | - $title = $langs->trans("GenerationOfAccountingEntries").' - '.$accountingjournalstatic->getNomUrl(0, 2, 1, '', 1); |
|
1102 | - $help_url ='EN:Module_Double_Entry_Accounting|FR:Module_Comptabilité_en_Partie_Double#Génération_des_écritures_en_comptabilité'; |
|
1103 | - llxHeader('', dol_string_nohtmltag($title), $help_url, '', 0, 0, '', '', '', 'mod-accountancy accountancy-generation page-bankjournal'); |
|
1104 | - |
|
1105 | - $nom = $title; |
|
1106 | - $builddate = dol_now(); |
|
1107 | - //$description = $langs->trans("DescFinanceJournal") . '<br>'; |
|
1108 | - $description = $langs->trans("DescJournalOnlyBindedVisible").'<br>'; |
|
1109 | - |
|
1110 | - $listofchoices = array( |
|
1111 | - 'notyet' => $langs->trans("NotYetInGeneralLedger"), |
|
1112 | - 'already' => $langs->trans("AlreadyInGeneralLedger") |
|
1113 | - ); |
|
1114 | - $period = $form->selectDate($date_start ? $date_start : -1, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end ? $date_end : -1, 'date_end', 0, 0, 0, '', 1, 0); |
|
1115 | - $period .= ' - '.$langs->trans("JournalizationInLedgerStatus").' '.$form->selectarray('in_bookkeeping', $listofchoices, $in_bookkeeping, 1); |
|
1116 | - |
|
1117 | - $varlink = 'id_journal='.$id_journal; |
|
1118 | - $periodlink = ''; |
|
1119 | - $exportlink = ''; |
|
1120 | - |
|
1121 | - $listofchoices = array( |
|
1122 | - 1 => $langs->trans("TransfertAllBankLines"), |
|
1123 | - 2 => $langs->trans("TransfertOnlyConciliatedBankLine") |
|
1124 | - ); |
|
1125 | - $moreoptions = [ "BankLineConciliated" => $form->selectarray('only_rappro', $listofchoices, $only_rappro)]; |
|
1126 | - |
|
1127 | - journalHead($nom, '', $period, $periodlink, $description, $builddate, $exportlink, array('action' => ''), '', $varlink, $moreoptions); |
|
1128 | - |
|
1129 | - $desc = ''; |
|
1130 | - |
|
1131 | - if (getDolGlobalString('ACCOUNTANCY_FISCAL_PERIOD_MODE') != 'blockedonclosed') { |
|
1132 | - // Test that setup is complete (we are in accounting, so test on entity is always on $conf->entity only, no sharing allowed) |
|
1133 | - // Fiscal period test |
|
1134 | - $sql = "SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX."accounting_fiscalyear WHERE entity = ".((int) $conf->entity); |
|
1135 | - $resql = $db->query($sql); |
|
1136 | - if ($resql) { |
|
1137 | - $obj = $db->fetch_object($resql); |
|
1138 | - if ($obj->nb == 0) { |
|
1139 | - print '<br><div class="warning">'.img_warning().' '.$langs->trans("TheFiscalPeriodIsNotDefined"); |
|
1140 | - $desc = ' : '.$langs->trans("AccountancyAreaDescFiscalPeriod", 4, '{link}'); |
|
1141 | - $desc = str_replace('{link}', '<strong>'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("FiscalPeriod").'</strong>', $desc); |
|
1142 | - print $desc; |
|
1143 | - print '</div>'; |
|
1144 | - } |
|
1145 | - } else { |
|
1146 | - dol_print_error($db); |
|
1147 | - } |
|
1148 | - } |
|
1149 | - |
|
1150 | - // Bank test |
|
1151 | - $sql = "SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX."bank_account WHERE entity = ".((int) $conf->entity)." AND fk_accountancy_journal IS NULL AND clos=0"; |
|
1152 | - $resql = $db->query($sql); |
|
1153 | - if ($resql) { |
|
1154 | - $obj = $db->fetch_object($resql); |
|
1155 | - if ($obj->nb > 0) { |
|
1156 | - print '<br><div class="warning">'.img_warning().' '.$langs->trans("TheJournalCodeIsNotDefinedOnSomeBankAccount"); |
|
1157 | - $desc = ' : '.$langs->trans("AccountancyAreaDescBank", 6, '{link}'); |
|
1158 | - $desc = str_replace('{link}', '<strong>'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("BankAccounts").'</strong>', $desc); |
|
1159 | - print $desc; |
|
1160 | - print '</div>'; |
|
1161 | - } |
|
1162 | - } else { |
|
1163 | - dol_print_error($db); |
|
1164 | - } |
|
1092 | + $invoicestatic = new Facture($db); |
|
1093 | + $invoicesupplierstatic = new FactureFournisseur($db); |
|
1094 | + $expensereportstatic = new ExpenseReport($db); |
|
1095 | + $vatstatic = new Tva($db); |
|
1096 | + $donationstatic = new Don($db); |
|
1097 | + $loanstatic = new Loan($db); |
|
1098 | + $salarystatic = new Salary($db); |
|
1099 | + $variousstatic = new PaymentVarious($db); |
|
1100 | + |
|
1101 | + $title = $langs->trans("GenerationOfAccountingEntries").' - '.$accountingjournalstatic->getNomUrl(0, 2, 1, '', 1); |
|
1102 | + $help_url ='EN:Module_Double_Entry_Accounting|FR:Module_Comptabilité_en_Partie_Double#Génération_des_écritures_en_comptabilité'; |
|
1103 | + llxHeader('', dol_string_nohtmltag($title), $help_url, '', 0, 0, '', '', '', 'mod-accountancy accountancy-generation page-bankjournal'); |
|
1104 | + |
|
1105 | + $nom = $title; |
|
1106 | + $builddate = dol_now(); |
|
1107 | + //$description = $langs->trans("DescFinanceJournal") . '<br>'; |
|
1108 | + $description = $langs->trans("DescJournalOnlyBindedVisible").'<br>'; |
|
1109 | + |
|
1110 | + $listofchoices = array( |
|
1111 | + 'notyet' => $langs->trans("NotYetInGeneralLedger"), |
|
1112 | + 'already' => $langs->trans("AlreadyInGeneralLedger") |
|
1113 | + ); |
|
1114 | + $period = $form->selectDate($date_start ? $date_start : -1, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end ? $date_end : -1, 'date_end', 0, 0, 0, '', 1, 0); |
|
1115 | + $period .= ' - '.$langs->trans("JournalizationInLedgerStatus").' '.$form->selectarray('in_bookkeeping', $listofchoices, $in_bookkeeping, 1); |
|
1116 | + |
|
1117 | + $varlink = 'id_journal='.$id_journal; |
|
1118 | + $periodlink = ''; |
|
1119 | + $exportlink = ''; |
|
1120 | + |
|
1121 | + $listofchoices = array( |
|
1122 | + 1 => $langs->trans("TransfertAllBankLines"), |
|
1123 | + 2 => $langs->trans("TransfertOnlyConciliatedBankLine") |
|
1124 | + ); |
|
1125 | + $moreoptions = [ "BankLineConciliated" => $form->selectarray('only_rappro', $listofchoices, $only_rappro)]; |
|
1126 | + |
|
1127 | + journalHead($nom, '', $period, $periodlink, $description, $builddate, $exportlink, array('action' => ''), '', $varlink, $moreoptions); |
|
1128 | + |
|
1129 | + $desc = ''; |
|
1130 | + |
|
1131 | + if (getDolGlobalString('ACCOUNTANCY_FISCAL_PERIOD_MODE') != 'blockedonclosed') { |
|
1132 | + // Test that setup is complete (we are in accounting, so test on entity is always on $conf->entity only, no sharing allowed) |
|
1133 | + // Fiscal period test |
|
1134 | + $sql = "SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX."accounting_fiscalyear WHERE entity = ".((int) $conf->entity); |
|
1135 | + $resql = $db->query($sql); |
|
1136 | + if ($resql) { |
|
1137 | + $obj = $db->fetch_object($resql); |
|
1138 | + if ($obj->nb == 0) { |
|
1139 | + print '<br><div class="warning">'.img_warning().' '.$langs->trans("TheFiscalPeriodIsNotDefined"); |
|
1140 | + $desc = ' : '.$langs->trans("AccountancyAreaDescFiscalPeriod", 4, '{link}'); |
|
1141 | + $desc = str_replace('{link}', '<strong>'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("FiscalPeriod").'</strong>', $desc); |
|
1142 | + print $desc; |
|
1143 | + print '</div>'; |
|
1144 | + } |
|
1145 | + } else { |
|
1146 | + dol_print_error($db); |
|
1147 | + } |
|
1148 | + } |
|
1149 | + |
|
1150 | + // Bank test |
|
1151 | + $sql = "SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX."bank_account WHERE entity = ".((int) $conf->entity)." AND fk_accountancy_journal IS NULL AND clos=0"; |
|
1152 | + $resql = $db->query($sql); |
|
1153 | + if ($resql) { |
|
1154 | + $obj = $db->fetch_object($resql); |
|
1155 | + if ($obj->nb > 0) { |
|
1156 | + print '<br><div class="warning">'.img_warning().' '.$langs->trans("TheJournalCodeIsNotDefinedOnSomeBankAccount"); |
|
1157 | + $desc = ' : '.$langs->trans("AccountancyAreaDescBank", 6, '{link}'); |
|
1158 | + $desc = str_replace('{link}', '<strong>'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("BankAccounts").'</strong>', $desc); |
|
1159 | + print $desc; |
|
1160 | + print '</div>'; |
|
1161 | + } |
|
1162 | + } else { |
|
1163 | + dol_print_error($db); |
|
1164 | + } |
|
1165 | 1165 | |
1166 | 1166 | |
1167 | - // Button to write into Ledger |
|
1168 | - if (getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER') == "" || getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER') == '-1' |
|
1169 | - || getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER') == "" || getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER') == '-1' |
|
1170 | - || (isModEnabled("salaries") && (getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT') == "" || getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT') == '-1')) |
|
1171 | - || (isModEnabled("expensereport") && (getDolGlobalString('ACCOUNTING_ACCOUNT_EXPENSEREPORT') == "" || getDolGlobalString('ACCOUNTING_ACCOUNT_EXPENSEREPORT') == '-1'))) { |
|
1167 | + // Button to write into Ledger |
|
1168 | + if (getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER') == "" || getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER') == '-1' |
|
1169 | + || getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER') == "" || getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER') == '-1' |
|
1170 | + || (isModEnabled("salaries") && (getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT') == "" || getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT') == '-1')) |
|
1171 | + || (isModEnabled("expensereport") && (getDolGlobalString('ACCOUNTING_ACCOUNT_EXPENSEREPORT') == "" || getDolGlobalString('ACCOUNTING_ACCOUNT_EXPENSEREPORT') == '-1'))) { |
|
1172 | 1172 | |
1173 | 1173 | |
1174 | - print($desc ? '' : '<br>').'<div class="warning">'.img_warning().' '.$langs->trans("SomeMandatoryStepsOfSetupWereNotDone"); |
|
1175 | - $desc = ' : '.$langs->trans("AccountancyAreaDescMisc", 4, '{link}'); |
|
1176 | - $desc = str_replace('{link}', '<strong>'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("MenuDefaultAccounts").'</strong>', $desc); |
|
1177 | - print $desc; |
|
1178 | - print '</div>'; |
|
1179 | - } |
|
1174 | + print($desc ? '' : '<br>').'<div class="warning">'.img_warning().' '.$langs->trans("SomeMandatoryStepsOfSetupWereNotDone"); |
|
1175 | + $desc = ' : '.$langs->trans("AccountancyAreaDescMisc", 4, '{link}'); |
|
1176 | + $desc = str_replace('{link}', '<strong>'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("MenuDefaultAccounts").'</strong>', $desc); |
|
1177 | + print $desc; |
|
1178 | + print '</div>'; |
|
1179 | + } |
|
1180 | 1180 | |
1181 | 1181 | |
1182 | - print '<br><div class="tabsAction tabsActionNoBottom centerimp">'; |
|
1182 | + print '<br><div class="tabsAction tabsActionNoBottom centerimp">'; |
|
1183 | 1183 | |
1184 | - if (getDolGlobalString('ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL') && $in_bookkeeping == 'notyet') { |
|
1185 | - print '<input type="button" class="butAction" name="exportcsv" value="'.$langs->trans("ExportDraftJournal").'" onclick="launch_export();" />'; |
|
1186 | - } |
|
1184 | + if (getDolGlobalString('ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL') && $in_bookkeeping == 'notyet') { |
|
1185 | + print '<input type="button" class="butAction" name="exportcsv" value="'.$langs->trans("ExportDraftJournal").'" onclick="launch_export();" />'; |
|
1186 | + } |
|
1187 | 1187 | |
1188 | - if (getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER') == "" || getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER') == '-1' |
|
1189 | - || getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER') == "" || getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER') == '-1') { |
|
1190 | - print '<input type="button" class="butActionRefused classfortooltip" title="'.dol_escape_htmltag($langs->trans("SomeMandatoryStepsOfSetupWereNotDone")).'" value="'.$langs->trans("WriteBookKeeping").'" />'; |
|
1191 | - } else { |
|
1192 | - if ($in_bookkeeping == 'notyet') { |
|
1193 | - print '<input type="button" class="butAction" name="writebookkeeping" value="'.$langs->trans("WriteBookKeeping").'" onclick="writebookkeeping();" />'; |
|
1194 | - } else { |
|
1195 | - print '<a class="butActionRefused classfortooltip" name="writebookkeeping">'.$langs->trans("WriteBookKeeping").'</a>'; |
|
1196 | - } |
|
1197 | - } |
|
1188 | + if (getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER') == "" || getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER') == '-1' |
|
1189 | + || getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER') == "" || getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER') == '-1') { |
|
1190 | + print '<input type="button" class="butActionRefused classfortooltip" title="'.dol_escape_htmltag($langs->trans("SomeMandatoryStepsOfSetupWereNotDone")).'" value="'.$langs->trans("WriteBookKeeping").'" />'; |
|
1191 | + } else { |
|
1192 | + if ($in_bookkeeping == 'notyet') { |
|
1193 | + print '<input type="button" class="butAction" name="writebookkeeping" value="'.$langs->trans("WriteBookKeeping").'" onclick="writebookkeeping();" />'; |
|
1194 | + } else { |
|
1195 | + print '<a class="butActionRefused classfortooltip" name="writebookkeeping">'.$langs->trans("WriteBookKeeping").'</a>'; |
|
1196 | + } |
|
1197 | + } |
|
1198 | 1198 | |
1199 | - print '</div>'; |
|
1199 | + print '</div>'; |
|
1200 | 1200 | |
1201 | - // TODO Avoid using js. We can use a direct link with $param |
|
1202 | - print ' |
|
1201 | + // TODO Avoid using js. We can use a direct link with $param |
|
1202 | + print ' |
|
1203 | 1203 | <script type="text/javascript"> |
1204 | 1204 | function launch_export() { |
1205 | 1205 | console.log("Set value into form and submit"); |
@@ -1215,259 +1215,259 @@ discard block |
||
1215 | 1215 | } |
1216 | 1216 | </script>'; |
1217 | 1217 | |
1218 | - /* |
|
1218 | + /* |
|
1219 | 1219 | * Show result array |
1220 | 1220 | */ |
1221 | - print '<br>'; |
|
1222 | - |
|
1223 | - $i = 0; |
|
1224 | - print '<div class="div-table-responsive">'; |
|
1225 | - print '<table class="noborder centpercent">'; |
|
1226 | - print '<tr class="liste_titre">'; |
|
1227 | - print "<td>".$langs->trans("Date")."</td>"; |
|
1228 | - print "<td>".$langs->trans("Piece").' ('.$langs->trans("ObjectsRef").")</td>"; |
|
1229 | - print "<td>".$langs->trans("AccountAccounting")."</td>"; |
|
1230 | - print "<td>".$langs->trans("SubledgerAccount")."</td>"; |
|
1231 | - print "<td>".$langs->trans("LabelOperation")."</td>"; |
|
1232 | - print '<td class="center">'.$langs->trans("PaymentMode")."</td>"; |
|
1233 | - print '<td class="right">'.$langs->trans("AccountingDebit")."</td>"; |
|
1234 | - print '<td class="right">'.$langs->trans("AccountingCredit")."</td>"; |
|
1235 | - print "</tr>\n"; |
|
1236 | - |
|
1237 | - $r = ''; |
|
1238 | - |
|
1239 | - foreach ($tabpay as $key => $val) { // $key is rowid in llx_bank |
|
1240 | - $date = dol_print_date($val["date"], 'day'); |
|
1241 | - |
|
1242 | - $ref = getSourceDocRef($val, $tabtype[$key]); |
|
1243 | - |
|
1244 | - // Bank |
|
1245 | - foreach ($tabbq[$key] as $k => $mt) { |
|
1246 | - if ($mt) { |
|
1247 | - $reflabel = ''; |
|
1248 | - if (!empty($val['lib'])) { |
|
1249 | - $reflabel .= $val['lib']." - "; |
|
1250 | - } |
|
1251 | - $reflabel .= $langs->trans("Bank").' '.$val['bank_account_ref']; |
|
1252 | - if (!empty($val['soclib'])) { |
|
1253 | - $reflabel .= " - ".$val['soclib']; |
|
1254 | - } |
|
1221 | + print '<br>'; |
|
1255 | 1222 | |
1256 | - //var_dump($tabpay[$key]); |
|
1257 | - print '<!-- Bank bank.rowid='.$key.' type='.$tabpay[$key]['type'].' ref='.$tabpay[$key]['ref'].'-->'; |
|
1258 | - print '<tr class="oddeven">'; |
|
1223 | + $i = 0; |
|
1224 | + print '<div class="div-table-responsive">'; |
|
1225 | + print '<table class="noborder centpercent">'; |
|
1226 | + print '<tr class="liste_titre">'; |
|
1227 | + print "<td>".$langs->trans("Date")."</td>"; |
|
1228 | + print "<td>".$langs->trans("Piece").' ('.$langs->trans("ObjectsRef").")</td>"; |
|
1229 | + print "<td>".$langs->trans("AccountAccounting")."</td>"; |
|
1230 | + print "<td>".$langs->trans("SubledgerAccount")."</td>"; |
|
1231 | + print "<td>".$langs->trans("LabelOperation")."</td>"; |
|
1232 | + print '<td class="center">'.$langs->trans("PaymentMode")."</td>"; |
|
1233 | + print '<td class="right">'.$langs->trans("AccountingDebit")."</td>"; |
|
1234 | + print '<td class="right">'.$langs->trans("AccountingCredit")."</td>"; |
|
1235 | + print "</tr>\n"; |
|
1236 | + |
|
1237 | + $r = ''; |
|
1238 | + |
|
1239 | + foreach ($tabpay as $key => $val) { // $key is rowid in llx_bank |
|
1240 | + $date = dol_print_date($val["date"], 'day'); |
|
1241 | + |
|
1242 | + $ref = getSourceDocRef($val, $tabtype[$key]); |
|
1243 | + |
|
1244 | + // Bank |
|
1245 | + foreach ($tabbq[$key] as $k => $mt) { |
|
1246 | + if ($mt) { |
|
1247 | + $reflabel = ''; |
|
1248 | + if (!empty($val['lib'])) { |
|
1249 | + $reflabel .= $val['lib']." - "; |
|
1250 | + } |
|
1251 | + $reflabel .= $langs->trans("Bank").' '.$val['bank_account_ref']; |
|
1252 | + if (!empty($val['soclib'])) { |
|
1253 | + $reflabel .= " - ".$val['soclib']; |
|
1254 | + } |
|
1259 | 1255 | |
1260 | - // Date |
|
1261 | - print "<td>".$date."</td>"; |
|
1256 | + //var_dump($tabpay[$key]); |
|
1257 | + print '<!-- Bank bank.rowid='.$key.' type='.$tabpay[$key]['type'].' ref='.$tabpay[$key]['ref'].'-->'; |
|
1258 | + print '<tr class="oddeven">'; |
|
1262 | 1259 | |
1263 | - // Ref |
|
1264 | - print "<td>".dol_escape_htmltag($ref)."</td>"; |
|
1260 | + // Date |
|
1261 | + print "<td>".$date."</td>"; |
|
1265 | 1262 | |
1266 | - // Ledger account |
|
1267 | - $accounttoshow = length_accountg($k); |
|
1268 | - if (empty($accounttoshow) || $accounttoshow == 'NotDefined') { |
|
1269 | - $accounttoshow = '<span class="error">'.$langs->trans("BankAccountNotDefined").'</span>'; |
|
1270 | - } |
|
1271 | - print '<td class="maxwidth300" title="'.dol_escape_htmltag(dol_string_nohtmltag($accounttoshow)).'">'; |
|
1272 | - print $accounttoshow; |
|
1273 | - print "</td>"; |
|
1263 | + // Ref |
|
1264 | + print "<td>".dol_escape_htmltag($ref)."</td>"; |
|
1274 | 1265 | |
1275 | - // Subledger account |
|
1276 | - print '<td class="maxwidth300">'; |
|
1277 | - /*$accounttoshow = length_accountg($k); |
|
1266 | + // Ledger account |
|
1267 | + $accounttoshow = length_accountg($k); |
|
1268 | + if (empty($accounttoshow) || $accounttoshow == 'NotDefined') { |
|
1269 | + $accounttoshow = '<span class="error">'.$langs->trans("BankAccountNotDefined").'</span>'; |
|
1270 | + } |
|
1271 | + print '<td class="maxwidth300" title="'.dol_escape_htmltag(dol_string_nohtmltag($accounttoshow)).'">'; |
|
1272 | + print $accounttoshow; |
|
1273 | + print "</td>"; |
|
1274 | + |
|
1275 | + // Subledger account |
|
1276 | + print '<td class="maxwidth300">'; |
|
1277 | + /*$accounttoshow = length_accountg($k); |
|
1278 | 1278 | if (empty($accounttoshow) || $accounttoshow == 'NotDefined') |
1279 | 1279 | { |
1280 | 1280 | print '<span class="error">'.$langs->trans("BankAccountNotDefined").'</span>'; |
1281 | 1281 | } |
1282 | 1282 | else print $accounttoshow;*/ |
1283 | - print "</td>"; |
|
1284 | - |
|
1285 | - // Label operation |
|
1286 | - print '<td>'; |
|
1287 | - print $reflabel; // This is already html escaped content |
|
1288 | - print "</td>"; |
|
1289 | - |
|
1290 | - print '<td class="center">'.$val["type_payment"]."</td>"; |
|
1291 | - print '<td class="right nowraponall amount">'.($mt >= 0 ? price($mt) : '')."</td>"; |
|
1292 | - print '<td class="right nowraponall amount">'.($mt < 0 ? price(-$mt) : '')."</td>"; |
|
1293 | - print "</tr>"; |
|
1294 | - |
|
1295 | - $i++; |
|
1296 | - } |
|
1297 | - } |
|
1298 | - |
|
1299 | - // Third party |
|
1300 | - if (is_array($tabtp[$key])) { |
|
1301 | - foreach ($tabtp[$key] as $k => $mt) { |
|
1302 | - if ($mt) { |
|
1303 | - $reflabel = ''; |
|
1304 | - if (!empty($val['lib'])) { |
|
1305 | - $reflabel .= $val['lib'].(isset($val['soclib']) ? " - " : ""); |
|
1306 | - } |
|
1307 | - if ($tabtype[$key] == 'banktransfert') { |
|
1308 | - $reflabel .= $langs->trans('TransitionalAccount').' '.$account_transfer; |
|
1309 | - } else { |
|
1310 | - $reflabel .= isset($val['soclib']) ? $val['soclib'] : ""; |
|
1311 | - } |
|
1312 | - |
|
1313 | - print '<!-- Thirdparty bank.rowid='.$key.' -->'; |
|
1314 | - print '<tr class="oddeven">'; |
|
1315 | - |
|
1316 | - // Date |
|
1317 | - print "<td>".$date."</td>"; |
|
1318 | - |
|
1319 | - // Ref |
|
1320 | - print "<td>".dol_escape_htmltag($ref)."</td>"; |
|
1321 | - |
|
1322 | - // Ledger account |
|
1323 | - $account_ledger = $k; |
|
1324 | - // Try to force general ledger account depending on type |
|
1325 | - if ($tabtype[$key] == 'payment') { |
|
1326 | - $account_ledger = getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER'); |
|
1327 | - } |
|
1328 | - if ($tabtype[$key] == 'payment_supplier') { |
|
1329 | - $account_ledger = getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER'); |
|
1330 | - } |
|
1331 | - if ($tabtype[$key] == 'payment_expensereport') { |
|
1332 | - $account_ledger = getDolGlobalString('ACCOUNTING_ACCOUNT_EXPENSEREPORT'); |
|
1333 | - } |
|
1334 | - if ($tabtype[$key] == 'payment_salary') { |
|
1335 | - $account_ledger = getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT'); |
|
1336 | - } |
|
1337 | - if ($tabtype[$key] == 'payment_vat') { |
|
1338 | - $account_ledger = getDolGlobalString('ACCOUNTING_VAT_PAY_ACCOUNT'); |
|
1339 | - } |
|
1340 | - if ($tabtype[$key] == 'member') { |
|
1341 | - $account_ledger = getDolGlobalString('ADHERENT_SUBSCRIPTION_ACCOUNTINGACCOUNT'); |
|
1342 | - } |
|
1343 | - if ($tabtype[$key] == 'payment_various') { |
|
1344 | - $account_ledger = $tabpay[$key]["account_various"]; |
|
1345 | - } |
|
1346 | - $accounttoshow = length_accountg($account_ledger); |
|
1347 | - if (empty($accounttoshow) || $accounttoshow == 'NotDefined') { |
|
1348 | - if ($tabtype[$key] == 'unknown') { |
|
1349 | - // We will accept writing, but into a waiting account |
|
1350 | - if (!getDolGlobalString('ACCOUNTING_ACCOUNT_SUSPENSE') || getDolGlobalString('ACCOUNTING_ACCOUNT_SUSPENSE') == '-1') { |
|
1351 | - $accounttoshow = '<span class="error small">'.$langs->trans('UnknownAccountForThirdpartyAndWaitingAccountNotDefinedBlocking').'</span>'; |
|
1352 | - } else { |
|
1353 | - $accounttoshow = '<span class="warning small">'.$langs->trans('UnknownAccountForThirdparty', length_accountg(getDolGlobalString('ACCOUNTING_ACCOUNT_SUSPENSE'))).'</span>'; // We will use a waiting account |
|
1354 | - } |
|
1355 | - } else { |
|
1356 | - // We will refuse writing |
|
1357 | - $errorstring = 'UnknownAccountForThirdpartyBlocking'; |
|
1358 | - if ($tabtype[$key] == 'payment') { |
|
1359 | - $errorstring = 'MainAccountForCustomersNotDefined'; |
|
1360 | - } |
|
1361 | - if ($tabtype[$key] == 'payment_supplier') { |
|
1362 | - $errorstring = 'MainAccountForSuppliersNotDefined'; |
|
1363 | - } |
|
1364 | - if ($tabtype[$key] == 'payment_expensereport') { |
|
1365 | - $errorstring = 'MainAccountForUsersNotDefined'; |
|
1366 | - } |
|
1367 | - if ($tabtype[$key] == 'payment_salary') { |
|
1368 | - $errorstring = 'MainAccountForUsersNotDefined'; |
|
1369 | - } |
|
1370 | - if ($tabtype[$key] == 'payment_vat') { |
|
1371 | - $errorstring = 'MainAccountForVatPaymentNotDefined'; |
|
1372 | - } |
|
1373 | - if ($tabtype[$key] == 'member') { |
|
1374 | - $errorstring = 'MainAccountForSubscriptionPaymentNotDefined'; |
|
1375 | - } |
|
1376 | - $accounttoshow = '<span class="error small">'.$langs->trans($errorstring).'</span>'; |
|
1377 | - } |
|
1378 | - } |
|
1379 | - print '<td class="maxwidth300" title="'.dol_escape_htmltag(dol_string_nohtmltag($accounttoshow)).'">'; |
|
1380 | - print $accounttoshow; // This is a HTML string |
|
1381 | - print "</td>"; |
|
1382 | - |
|
1383 | - // Subledger account |
|
1384 | - $accounttoshowsubledger = ''; |
|
1385 | - if (in_array($tabtype[$key], array('payment', 'payment_supplier', 'payment_expensereport', 'payment_salary', 'payment_various'))) { // Type of payments that uses a subledger |
|
1386 | - $accounttoshowsubledger = length_accounta($k); |
|
1387 | - if ($accounttoshow != $accounttoshowsubledger) { |
|
1388 | - if (empty($accounttoshowsubledger) || $accounttoshowsubledger == 'NotDefined') { |
|
1389 | - //var_dump($tabpay[$key]); |
|
1390 | - //var_dump($tabtype[$key]); |
|
1391 | - //var_dump($tabbq[$key]); |
|
1392 | - //print '<span class="error">'.$langs->trans("ThirdpartyAccountNotDefined").'</span>'; |
|
1393 | - if (!empty($tabcompany[$key]['code_compta'])) { |
|
1394 | - if (in_array($tabtype[$key], array('payment_various', 'payment_salary'))) { |
|
1395 | - // For such case, if subledger is not defined, we won't use subledger accounts. |
|
1396 | - $accounttoshowsubledger = '<span class="warning small">'.$langs->trans("ThirdpartyAccountNotDefinedOrThirdPartyUnknownSubledgerIgnored").'</span>'; |
|
1397 | - } else { |
|
1398 | - $accounttoshowsubledger = '<span class="warning small">'.$langs->trans("ThirdpartyAccountNotDefinedOrThirdPartyUnknown", $tabcompany[$key]['code_compta']).'</span>'; |
|
1399 | - } |
|
1400 | - } else { |
|
1401 | - $accounttoshowsubledger = '<span class="error small">'.$langs->trans("ThirdpartyAccountNotDefinedOrThirdPartyUnknownBlocking").'</span>'; |
|
1402 | - } |
|
1403 | - } |
|
1404 | - } else { |
|
1405 | - $accounttoshowsubledger = ''; |
|
1406 | - } |
|
1407 | - } |
|
1408 | - print '<td class="maxwidth300">'; |
|
1409 | - print $accounttoshowsubledger; // This is a html string |
|
1410 | - print "</td>"; |
|
1411 | - |
|
1412 | - print "<td>".$reflabel."</td>"; |
|
1413 | - |
|
1414 | - print '<td class="center">'.$val["type_payment"]."</td>"; |
|
1283 | + print "</td>"; |
|
1415 | 1284 | |
1416 | - print '<td class="right nowraponall amount">'.($mt < 0 ? price(-$mt) : '')."</td>"; |
|
1285 | + // Label operation |
|
1286 | + print '<td>'; |
|
1287 | + print $reflabel; // This is already html escaped content |
|
1288 | + print "</td>"; |
|
1417 | 1289 | |
1418 | - print '<td class="right nowraponall amount">'.($mt >= 0 ? price($mt) : '')."</td>"; |
|
1290 | + print '<td class="center">'.$val["type_payment"]."</td>"; |
|
1291 | + print '<td class="right nowraponall amount">'.($mt >= 0 ? price($mt) : '')."</td>"; |
|
1292 | + print '<td class="right nowraponall amount">'.($mt < 0 ? price(-$mt) : '')."</td>"; |
|
1293 | + print "</tr>"; |
|
1419 | 1294 | |
1420 | - print "</tr>"; |
|
1295 | + $i++; |
|
1296 | + } |
|
1297 | + } |
|
1421 | 1298 | |
1422 | - $i++; |
|
1423 | - } |
|
1424 | - } |
|
1425 | - } else { // Waiting account |
|
1426 | - foreach ($tabbq[$key] as $k => $mt) { |
|
1427 | - if ($mt) { |
|
1428 | - $reflabel = ''; |
|
1429 | - if (!empty($val['lib'])) { |
|
1430 | - $reflabel .= $val['lib']." - "; |
|
1431 | - } |
|
1432 | - $reflabel .= 'WaitingAccount'; |
|
1433 | - |
|
1434 | - print '<!-- Wait bank.rowid='.$key.' -->'; |
|
1435 | - print '<tr class="oddeven">'; |
|
1436 | - print "<td>".$date."</td>"; |
|
1437 | - print "<td>".$ref."</td>"; |
|
1438 | - // Ledger account |
|
1439 | - print "<td>"; |
|
1440 | - /*if (empty($accounttoshow) || $accounttoshow == 'NotDefined') |
|
1299 | + // Third party |
|
1300 | + if (is_array($tabtp[$key])) { |
|
1301 | + foreach ($tabtp[$key] as $k => $mt) { |
|
1302 | + if ($mt) { |
|
1303 | + $reflabel = ''; |
|
1304 | + if (!empty($val['lib'])) { |
|
1305 | + $reflabel .= $val['lib'].(isset($val['soclib']) ? " - " : ""); |
|
1306 | + } |
|
1307 | + if ($tabtype[$key] == 'banktransfert') { |
|
1308 | + $reflabel .= $langs->trans('TransitionalAccount').' '.$account_transfer; |
|
1309 | + } else { |
|
1310 | + $reflabel .= isset($val['soclib']) ? $val['soclib'] : ""; |
|
1311 | + } |
|
1312 | + |
|
1313 | + print '<!-- Thirdparty bank.rowid='.$key.' -->'; |
|
1314 | + print '<tr class="oddeven">'; |
|
1315 | + |
|
1316 | + // Date |
|
1317 | + print "<td>".$date."</td>"; |
|
1318 | + |
|
1319 | + // Ref |
|
1320 | + print "<td>".dol_escape_htmltag($ref)."</td>"; |
|
1321 | + |
|
1322 | + // Ledger account |
|
1323 | + $account_ledger = $k; |
|
1324 | + // Try to force general ledger account depending on type |
|
1325 | + if ($tabtype[$key] == 'payment') { |
|
1326 | + $account_ledger = getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER'); |
|
1327 | + } |
|
1328 | + if ($tabtype[$key] == 'payment_supplier') { |
|
1329 | + $account_ledger = getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER'); |
|
1330 | + } |
|
1331 | + if ($tabtype[$key] == 'payment_expensereport') { |
|
1332 | + $account_ledger = getDolGlobalString('ACCOUNTING_ACCOUNT_EXPENSEREPORT'); |
|
1333 | + } |
|
1334 | + if ($tabtype[$key] == 'payment_salary') { |
|
1335 | + $account_ledger = getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT'); |
|
1336 | + } |
|
1337 | + if ($tabtype[$key] == 'payment_vat') { |
|
1338 | + $account_ledger = getDolGlobalString('ACCOUNTING_VAT_PAY_ACCOUNT'); |
|
1339 | + } |
|
1340 | + if ($tabtype[$key] == 'member') { |
|
1341 | + $account_ledger = getDolGlobalString('ADHERENT_SUBSCRIPTION_ACCOUNTINGACCOUNT'); |
|
1342 | + } |
|
1343 | + if ($tabtype[$key] == 'payment_various') { |
|
1344 | + $account_ledger = $tabpay[$key]["account_various"]; |
|
1345 | + } |
|
1346 | + $accounttoshow = length_accountg($account_ledger); |
|
1347 | + if (empty($accounttoshow) || $accounttoshow == 'NotDefined') { |
|
1348 | + if ($tabtype[$key] == 'unknown') { |
|
1349 | + // We will accept writing, but into a waiting account |
|
1350 | + if (!getDolGlobalString('ACCOUNTING_ACCOUNT_SUSPENSE') || getDolGlobalString('ACCOUNTING_ACCOUNT_SUSPENSE') == '-1') { |
|
1351 | + $accounttoshow = '<span class="error small">'.$langs->trans('UnknownAccountForThirdpartyAndWaitingAccountNotDefinedBlocking').'</span>'; |
|
1352 | + } else { |
|
1353 | + $accounttoshow = '<span class="warning small">'.$langs->trans('UnknownAccountForThirdparty', length_accountg(getDolGlobalString('ACCOUNTING_ACCOUNT_SUSPENSE'))).'</span>'; // We will use a waiting account |
|
1354 | + } |
|
1355 | + } else { |
|
1356 | + // We will refuse writing |
|
1357 | + $errorstring = 'UnknownAccountForThirdpartyBlocking'; |
|
1358 | + if ($tabtype[$key] == 'payment') { |
|
1359 | + $errorstring = 'MainAccountForCustomersNotDefined'; |
|
1360 | + } |
|
1361 | + if ($tabtype[$key] == 'payment_supplier') { |
|
1362 | + $errorstring = 'MainAccountForSuppliersNotDefined'; |
|
1363 | + } |
|
1364 | + if ($tabtype[$key] == 'payment_expensereport') { |
|
1365 | + $errorstring = 'MainAccountForUsersNotDefined'; |
|
1366 | + } |
|
1367 | + if ($tabtype[$key] == 'payment_salary') { |
|
1368 | + $errorstring = 'MainAccountForUsersNotDefined'; |
|
1369 | + } |
|
1370 | + if ($tabtype[$key] == 'payment_vat') { |
|
1371 | + $errorstring = 'MainAccountForVatPaymentNotDefined'; |
|
1372 | + } |
|
1373 | + if ($tabtype[$key] == 'member') { |
|
1374 | + $errorstring = 'MainAccountForSubscriptionPaymentNotDefined'; |
|
1375 | + } |
|
1376 | + $accounttoshow = '<span class="error small">'.$langs->trans($errorstring).'</span>'; |
|
1377 | + } |
|
1378 | + } |
|
1379 | + print '<td class="maxwidth300" title="'.dol_escape_htmltag(dol_string_nohtmltag($accounttoshow)).'">'; |
|
1380 | + print $accounttoshow; // This is a HTML string |
|
1381 | + print "</td>"; |
|
1382 | + |
|
1383 | + // Subledger account |
|
1384 | + $accounttoshowsubledger = ''; |
|
1385 | + if (in_array($tabtype[$key], array('payment', 'payment_supplier', 'payment_expensereport', 'payment_salary', 'payment_various'))) { // Type of payments that uses a subledger |
|
1386 | + $accounttoshowsubledger = length_accounta($k); |
|
1387 | + if ($accounttoshow != $accounttoshowsubledger) { |
|
1388 | + if (empty($accounttoshowsubledger) || $accounttoshowsubledger == 'NotDefined') { |
|
1389 | + //var_dump($tabpay[$key]); |
|
1390 | + //var_dump($tabtype[$key]); |
|
1391 | + //var_dump($tabbq[$key]); |
|
1392 | + //print '<span class="error">'.$langs->trans("ThirdpartyAccountNotDefined").'</span>'; |
|
1393 | + if (!empty($tabcompany[$key]['code_compta'])) { |
|
1394 | + if (in_array($tabtype[$key], array('payment_various', 'payment_salary'))) { |
|
1395 | + // For such case, if subledger is not defined, we won't use subledger accounts. |
|
1396 | + $accounttoshowsubledger = '<span class="warning small">'.$langs->trans("ThirdpartyAccountNotDefinedOrThirdPartyUnknownSubledgerIgnored").'</span>'; |
|
1397 | + } else { |
|
1398 | + $accounttoshowsubledger = '<span class="warning small">'.$langs->trans("ThirdpartyAccountNotDefinedOrThirdPartyUnknown", $tabcompany[$key]['code_compta']).'</span>'; |
|
1399 | + } |
|
1400 | + } else { |
|
1401 | + $accounttoshowsubledger = '<span class="error small">'.$langs->trans("ThirdpartyAccountNotDefinedOrThirdPartyUnknownBlocking").'</span>'; |
|
1402 | + } |
|
1403 | + } |
|
1404 | + } else { |
|
1405 | + $accounttoshowsubledger = ''; |
|
1406 | + } |
|
1407 | + } |
|
1408 | + print '<td class="maxwidth300">'; |
|
1409 | + print $accounttoshowsubledger; // This is a html string |
|
1410 | + print "</td>"; |
|
1411 | + |
|
1412 | + print "<td>".$reflabel."</td>"; |
|
1413 | + |
|
1414 | + print '<td class="center">'.$val["type_payment"]."</td>"; |
|
1415 | + |
|
1416 | + print '<td class="right nowraponall amount">'.($mt < 0 ? price(-$mt) : '')."</td>"; |
|
1417 | + |
|
1418 | + print '<td class="right nowraponall amount">'.($mt >= 0 ? price($mt) : '')."</td>"; |
|
1419 | + |
|
1420 | + print "</tr>"; |
|
1421 | + |
|
1422 | + $i++; |
|
1423 | + } |
|
1424 | + } |
|
1425 | + } else { // Waiting account |
|
1426 | + foreach ($tabbq[$key] as $k => $mt) { |
|
1427 | + if ($mt) { |
|
1428 | + $reflabel = ''; |
|
1429 | + if (!empty($val['lib'])) { |
|
1430 | + $reflabel .= $val['lib']." - "; |
|
1431 | + } |
|
1432 | + $reflabel .= 'WaitingAccount'; |
|
1433 | + |
|
1434 | + print '<!-- Wait bank.rowid='.$key.' -->'; |
|
1435 | + print '<tr class="oddeven">'; |
|
1436 | + print "<td>".$date."</td>"; |
|
1437 | + print "<td>".$ref."</td>"; |
|
1438 | + // Ledger account |
|
1439 | + print "<td>"; |
|
1440 | + /*if (empty($accounttoshow) || $accounttoshow == 'NotDefined') |
|
1441 | 1441 | { |
1442 | 1442 | print '<span class="error">'.$langs->trans("WaitAccountNotDefined").'</span>'; |
1443 | 1443 | } |
1444 | 1444 | else */ |
1445 | - print length_accountg(getDolGlobalString('ACCOUNTING_ACCOUNT_SUSPENSE')); |
|
1446 | - print "</td>"; |
|
1447 | - // Subledger account |
|
1448 | - print "<td>"; |
|
1449 | - print "</td>"; |
|
1450 | - print "<td>".dol_escape_htmltag($reflabel)."</td>"; |
|
1451 | - print '<td class="center">'.$val["type_payment"]."</td>"; |
|
1452 | - print '<td class="right nowraponall amount">'.($mt < 0 ? price(-$mt) : '')."</td>"; |
|
1453 | - print '<td class="right nowraponall amount">'.($mt >= 0 ? price($mt) : '')."</td>"; |
|
1454 | - print "</tr>"; |
|
1455 | - |
|
1456 | - $i++; |
|
1457 | - } |
|
1458 | - } |
|
1459 | - } |
|
1460 | - } |
|
1445 | + print length_accountg(getDolGlobalString('ACCOUNTING_ACCOUNT_SUSPENSE')); |
|
1446 | + print "</td>"; |
|
1447 | + // Subledger account |
|
1448 | + print "<td>"; |
|
1449 | + print "</td>"; |
|
1450 | + print "<td>".dol_escape_htmltag($reflabel)."</td>"; |
|
1451 | + print '<td class="center">'.$val["type_payment"]."</td>"; |
|
1452 | + print '<td class="right nowraponall amount">'.($mt < 0 ? price(-$mt) : '')."</td>"; |
|
1453 | + print '<td class="right nowraponall amount">'.($mt >= 0 ? price($mt) : '')."</td>"; |
|
1454 | + print "</tr>"; |
|
1455 | + |
|
1456 | + $i++; |
|
1457 | + } |
|
1458 | + } |
|
1459 | + } |
|
1460 | + } |
|
1461 | 1461 | |
1462 | - if (!$i) { |
|
1463 | - $colspan = 8; |
|
1464 | - print '<tr class="oddeven"><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>'; |
|
1465 | - } |
|
1462 | + if (!$i) { |
|
1463 | + $colspan = 8; |
|
1464 | + print '<tr class="oddeven"><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>'; |
|
1465 | + } |
|
1466 | 1466 | |
1467 | - print "</table>"; |
|
1468 | - print '</div>'; |
|
1467 | + print "</table>"; |
|
1468 | + print '</div>'; |
|
1469 | 1469 | |
1470 | - llxFooter(); |
|
1470 | + llxFooter(); |
|
1471 | 1471 | } |
1472 | 1472 | |
1473 | 1473 | $db->close(); |
@@ -1483,110 +1483,110 @@ discard block |
||
1483 | 1483 | */ |
1484 | 1484 | function getSourceDocRef($val, $typerecord) |
1485 | 1485 | { |
1486 | - global $db, $langs; |
|
1487 | - |
|
1488 | - // Defined the docref into $ref (We start with $val['ref'] by default and we complete according to other data) |
|
1489 | - // WE MUST HAVE SAME REF FOR ALL LINES WE WILL RECORD INTO THE BOOKKEEPING |
|
1490 | - $ref = $val['ref']; |
|
1491 | - if ($ref == '(SupplierInvoicePayment)' || $ref == '(SupplierInvoicePaymentBack)') { |
|
1492 | - $ref = $langs->transnoentitiesnoconv('Supplier'); |
|
1493 | - } |
|
1494 | - if ($ref == '(CustomerInvoicePayment)' || $ref == '(CustomerInvoicePaymentBack)') { |
|
1495 | - $ref = $langs->transnoentitiesnoconv('Customer'); |
|
1496 | - } |
|
1497 | - if ($ref == '(SocialContributionPayment)') { |
|
1498 | - $ref = $langs->transnoentitiesnoconv('SocialContribution'); |
|
1499 | - } |
|
1500 | - if ($ref == '(DonationPayment)') { |
|
1501 | - $ref = $langs->transnoentitiesnoconv('Donation'); |
|
1502 | - } |
|
1503 | - if ($ref == '(SubscriptionPayment)') { |
|
1504 | - $ref = $langs->transnoentitiesnoconv('Subscription'); |
|
1505 | - } |
|
1506 | - if ($ref == '(ExpenseReportPayment)') { |
|
1507 | - $ref = $langs->transnoentitiesnoconv('Employee'); |
|
1508 | - } |
|
1509 | - if ($ref == '(LoanPayment)') { |
|
1510 | - $ref = $langs->transnoentitiesnoconv('Loan'); |
|
1511 | - } |
|
1512 | - if ($ref == '(payment_salary)') { |
|
1513 | - $ref = $langs->transnoentitiesnoconv('Employee'); |
|
1514 | - } |
|
1515 | - |
|
1516 | - $sqlmid = ''; |
|
1517 | - if ($typerecord == 'payment') { |
|
1518 | - if (getDolGlobalInt('FACTURE_DEPOSITS_ARE_JUST_PAYMENTS')) { |
|
1519 | - $sqlmid = "SELECT payfac.fk_facture as id, ".$db->ifsql('f1.rowid IS NULL', 'f.ref', 'f1.ref')." as ref"; |
|
1520 | - $sqlmid .= " FROM ".$db->prefix()."paiement_facture as payfac"; |
|
1521 | - $sqlmid .= " LEFT JOIN ".$db->prefix()."facture as f ON f.rowid = payfac.fk_facture"; |
|
1522 | - $sqlmid .= " LEFT JOIN ".$db->prefix()."societe_remise_except as sre ON sre.fk_facture_source = payfac.fk_facture"; |
|
1523 | - $sqlmid .= " LEFT JOIN ".$db->prefix()."facture as f1 ON f1.rowid = sre.fk_facture"; |
|
1524 | - $sqlmid .= " WHERE payfac.fk_paiement=".((int) $val['paymentid']); |
|
1525 | - } else { |
|
1526 | - $sqlmid = "SELECT payfac.fk_facture as id, f.ref as ref"; |
|
1527 | - $sqlmid .= " FROM ".$db->prefix()."paiement_facture as payfac"; |
|
1528 | - $sqlmid .= " INNER JOIN ".$db->prefix()."facture as f ON f.rowid = payfac.fk_facture"; |
|
1529 | - $sqlmid .= " WHERE payfac.fk_paiement=".((int) $val['paymentid']); |
|
1530 | - } |
|
1531 | - $ref = $langs->transnoentitiesnoconv("Invoice"); |
|
1532 | - } elseif ($typerecord == 'payment_supplier') { |
|
1533 | - $sqlmid = 'SELECT payfac.fk_facturefourn as id, f.ref'; |
|
1534 | - $sqlmid .= " FROM ".MAIN_DB_PREFIX."paiementfourn_facturefourn as payfac, ".MAIN_DB_PREFIX."facture_fourn as f"; |
|
1535 | - $sqlmid .= " WHERE payfac.fk_facturefourn = f.rowid AND payfac.fk_paiementfourn=".((int) $val["paymentsupplierid"]); |
|
1536 | - $ref = $langs->transnoentitiesnoconv("SupplierInvoice"); |
|
1537 | - } elseif ($typerecord == 'payment_expensereport') { |
|
1538 | - $sqlmid = 'SELECT e.rowid as id, e.ref'; |
|
1539 | - $sqlmid .= " FROM ".MAIN_DB_PREFIX."payment_expensereport as pe, ".MAIN_DB_PREFIX."expensereport as e"; |
|
1540 | - $sqlmid .= " WHERE pe.rowid=".((int) $val["paymentexpensereport"])." AND pe.fk_expensereport = e.rowid"; |
|
1541 | - $ref = $langs->transnoentitiesnoconv("ExpenseReport"); |
|
1542 | - } elseif ($typerecord == 'payment_salary') { |
|
1543 | - $sqlmid = 'SELECT s.rowid as ref'; |
|
1544 | - $sqlmid .= " FROM ".MAIN_DB_PREFIX."payment_salary as s"; |
|
1545 | - $sqlmid .= " WHERE s.rowid=".((int) $val["paymentsalid"]); |
|
1546 | - $ref = $langs->transnoentitiesnoconv("SalaryPayment"); |
|
1547 | - } elseif ($typerecord == 'sc') { |
|
1548 | - $sqlmid = 'SELECT sc.rowid as ref'; |
|
1549 | - $sqlmid .= " FROM ".MAIN_DB_PREFIX."paiementcharge as sc"; |
|
1550 | - $sqlmid .= " WHERE sc.rowid=".((int) $val["paymentscid"]); |
|
1551 | - $ref = $langs->transnoentitiesnoconv("SocialContribution"); |
|
1552 | - } elseif ($typerecord == 'payment_vat') { |
|
1553 | - $sqlmid = 'SELECT v.rowid as ref'; |
|
1554 | - $sqlmid .= " FROM ".MAIN_DB_PREFIX."tva as v"; |
|
1555 | - $sqlmid .= " WHERE v.rowid=".((int) $val["paymentvatid"]); |
|
1556 | - $ref = $langs->transnoentitiesnoconv("PaymentVat"); |
|
1557 | - } elseif ($typerecord == 'payment_donation') { |
|
1558 | - $sqlmid = 'SELECT payd.fk_donation as ref'; |
|
1559 | - $sqlmid .= " FROM ".MAIN_DB_PREFIX."payment_donation as payd"; |
|
1560 | - $sqlmid .= " WHERE payd.fk_donation=".((int) $val["paymentdonationid"]); |
|
1561 | - $ref = $langs->transnoentitiesnoconv("Donation"); |
|
1562 | - } elseif ($typerecord == 'payment_loan') { |
|
1563 | - $sqlmid = 'SELECT l.rowid as ref'; |
|
1564 | - $sqlmid .= " FROM ".MAIN_DB_PREFIX."payment_loan as l"; |
|
1565 | - $sqlmid .= " WHERE l.rowid=".((int) $val["paymentloanid"]); |
|
1566 | - $ref = $langs->transnoentitiesnoconv("LoanPayment"); |
|
1567 | - } elseif ($typerecord == 'payment_various') { |
|
1568 | - $sqlmid = 'SELECT v.rowid as ref'; |
|
1569 | - $sqlmid .= " FROM ".MAIN_DB_PREFIX."payment_various as v"; |
|
1570 | - $sqlmid .= " WHERE v.rowid=".((int) $val["paymentvariousid"]); |
|
1571 | - $ref = $langs->transnoentitiesnoconv("VariousPayment"); |
|
1572 | - } |
|
1573 | - // Add warning |
|
1574 | - if (empty($sqlmid)) { |
|
1575 | - dol_syslog("Found a typerecord=".$typerecord." not supported", LOG_WARNING); |
|
1576 | - } |
|
1577 | - |
|
1578 | - if ($sqlmid) { |
|
1579 | - dol_syslog("accountancy/journal/bankjournal.php::sqlmid=".$sqlmid, LOG_DEBUG); |
|
1580 | - $resultmid = $db->query($sqlmid); |
|
1581 | - if ($resultmid) { |
|
1582 | - while ($objmid = $db->fetch_object($resultmid)) { |
|
1583 | - $ref .= ' '.$objmid->ref; |
|
1584 | - } |
|
1585 | - } else { |
|
1586 | - dol_print_error($db); |
|
1587 | - } |
|
1588 | - } |
|
1486 | + global $db, $langs; |
|
1487 | + |
|
1488 | + // Defined the docref into $ref (We start with $val['ref'] by default and we complete according to other data) |
|
1489 | + // WE MUST HAVE SAME REF FOR ALL LINES WE WILL RECORD INTO THE BOOKKEEPING |
|
1490 | + $ref = $val['ref']; |
|
1491 | + if ($ref == '(SupplierInvoicePayment)' || $ref == '(SupplierInvoicePaymentBack)') { |
|
1492 | + $ref = $langs->transnoentitiesnoconv('Supplier'); |
|
1493 | + } |
|
1494 | + if ($ref == '(CustomerInvoicePayment)' || $ref == '(CustomerInvoicePaymentBack)') { |
|
1495 | + $ref = $langs->transnoentitiesnoconv('Customer'); |
|
1496 | + } |
|
1497 | + if ($ref == '(SocialContributionPayment)') { |
|
1498 | + $ref = $langs->transnoentitiesnoconv('SocialContribution'); |
|
1499 | + } |
|
1500 | + if ($ref == '(DonationPayment)') { |
|
1501 | + $ref = $langs->transnoentitiesnoconv('Donation'); |
|
1502 | + } |
|
1503 | + if ($ref == '(SubscriptionPayment)') { |
|
1504 | + $ref = $langs->transnoentitiesnoconv('Subscription'); |
|
1505 | + } |
|
1506 | + if ($ref == '(ExpenseReportPayment)') { |
|
1507 | + $ref = $langs->transnoentitiesnoconv('Employee'); |
|
1508 | + } |
|
1509 | + if ($ref == '(LoanPayment)') { |
|
1510 | + $ref = $langs->transnoentitiesnoconv('Loan'); |
|
1511 | + } |
|
1512 | + if ($ref == '(payment_salary)') { |
|
1513 | + $ref = $langs->transnoentitiesnoconv('Employee'); |
|
1514 | + } |
|
1515 | + |
|
1516 | + $sqlmid = ''; |
|
1517 | + if ($typerecord == 'payment') { |
|
1518 | + if (getDolGlobalInt('FACTURE_DEPOSITS_ARE_JUST_PAYMENTS')) { |
|
1519 | + $sqlmid = "SELECT payfac.fk_facture as id, ".$db->ifsql('f1.rowid IS NULL', 'f.ref', 'f1.ref')." as ref"; |
|
1520 | + $sqlmid .= " FROM ".$db->prefix()."paiement_facture as payfac"; |
|
1521 | + $sqlmid .= " LEFT JOIN ".$db->prefix()."facture as f ON f.rowid = payfac.fk_facture"; |
|
1522 | + $sqlmid .= " LEFT JOIN ".$db->prefix()."societe_remise_except as sre ON sre.fk_facture_source = payfac.fk_facture"; |
|
1523 | + $sqlmid .= " LEFT JOIN ".$db->prefix()."facture as f1 ON f1.rowid = sre.fk_facture"; |
|
1524 | + $sqlmid .= " WHERE payfac.fk_paiement=".((int) $val['paymentid']); |
|
1525 | + } else { |
|
1526 | + $sqlmid = "SELECT payfac.fk_facture as id, f.ref as ref"; |
|
1527 | + $sqlmid .= " FROM ".$db->prefix()."paiement_facture as payfac"; |
|
1528 | + $sqlmid .= " INNER JOIN ".$db->prefix()."facture as f ON f.rowid = payfac.fk_facture"; |
|
1529 | + $sqlmid .= " WHERE payfac.fk_paiement=".((int) $val['paymentid']); |
|
1530 | + } |
|
1531 | + $ref = $langs->transnoentitiesnoconv("Invoice"); |
|
1532 | + } elseif ($typerecord == 'payment_supplier') { |
|
1533 | + $sqlmid = 'SELECT payfac.fk_facturefourn as id, f.ref'; |
|
1534 | + $sqlmid .= " FROM ".MAIN_DB_PREFIX."paiementfourn_facturefourn as payfac, ".MAIN_DB_PREFIX."facture_fourn as f"; |
|
1535 | + $sqlmid .= " WHERE payfac.fk_facturefourn = f.rowid AND payfac.fk_paiementfourn=".((int) $val["paymentsupplierid"]); |
|
1536 | + $ref = $langs->transnoentitiesnoconv("SupplierInvoice"); |
|
1537 | + } elseif ($typerecord == 'payment_expensereport') { |
|
1538 | + $sqlmid = 'SELECT e.rowid as id, e.ref'; |
|
1539 | + $sqlmid .= " FROM ".MAIN_DB_PREFIX."payment_expensereport as pe, ".MAIN_DB_PREFIX."expensereport as e"; |
|
1540 | + $sqlmid .= " WHERE pe.rowid=".((int) $val["paymentexpensereport"])." AND pe.fk_expensereport = e.rowid"; |
|
1541 | + $ref = $langs->transnoentitiesnoconv("ExpenseReport"); |
|
1542 | + } elseif ($typerecord == 'payment_salary') { |
|
1543 | + $sqlmid = 'SELECT s.rowid as ref'; |
|
1544 | + $sqlmid .= " FROM ".MAIN_DB_PREFIX."payment_salary as s"; |
|
1545 | + $sqlmid .= " WHERE s.rowid=".((int) $val["paymentsalid"]); |
|
1546 | + $ref = $langs->transnoentitiesnoconv("SalaryPayment"); |
|
1547 | + } elseif ($typerecord == 'sc') { |
|
1548 | + $sqlmid = 'SELECT sc.rowid as ref'; |
|
1549 | + $sqlmid .= " FROM ".MAIN_DB_PREFIX."paiementcharge as sc"; |
|
1550 | + $sqlmid .= " WHERE sc.rowid=".((int) $val["paymentscid"]); |
|
1551 | + $ref = $langs->transnoentitiesnoconv("SocialContribution"); |
|
1552 | + } elseif ($typerecord == 'payment_vat') { |
|
1553 | + $sqlmid = 'SELECT v.rowid as ref'; |
|
1554 | + $sqlmid .= " FROM ".MAIN_DB_PREFIX."tva as v"; |
|
1555 | + $sqlmid .= " WHERE v.rowid=".((int) $val["paymentvatid"]); |
|
1556 | + $ref = $langs->transnoentitiesnoconv("PaymentVat"); |
|
1557 | + } elseif ($typerecord == 'payment_donation') { |
|
1558 | + $sqlmid = 'SELECT payd.fk_donation as ref'; |
|
1559 | + $sqlmid .= " FROM ".MAIN_DB_PREFIX."payment_donation as payd"; |
|
1560 | + $sqlmid .= " WHERE payd.fk_donation=".((int) $val["paymentdonationid"]); |
|
1561 | + $ref = $langs->transnoentitiesnoconv("Donation"); |
|
1562 | + } elseif ($typerecord == 'payment_loan') { |
|
1563 | + $sqlmid = 'SELECT l.rowid as ref'; |
|
1564 | + $sqlmid .= " FROM ".MAIN_DB_PREFIX."payment_loan as l"; |
|
1565 | + $sqlmid .= " WHERE l.rowid=".((int) $val["paymentloanid"]); |
|
1566 | + $ref = $langs->transnoentitiesnoconv("LoanPayment"); |
|
1567 | + } elseif ($typerecord == 'payment_various') { |
|
1568 | + $sqlmid = 'SELECT v.rowid as ref'; |
|
1569 | + $sqlmid .= " FROM ".MAIN_DB_PREFIX."payment_various as v"; |
|
1570 | + $sqlmid .= " WHERE v.rowid=".((int) $val["paymentvariousid"]); |
|
1571 | + $ref = $langs->transnoentitiesnoconv("VariousPayment"); |
|
1572 | + } |
|
1573 | + // Add warning |
|
1574 | + if (empty($sqlmid)) { |
|
1575 | + dol_syslog("Found a typerecord=".$typerecord." not supported", LOG_WARNING); |
|
1576 | + } |
|
1577 | + |
|
1578 | + if ($sqlmid) { |
|
1579 | + dol_syslog("accountancy/journal/bankjournal.php::sqlmid=".$sqlmid, LOG_DEBUG); |
|
1580 | + $resultmid = $db->query($sqlmid); |
|
1581 | + if ($resultmid) { |
|
1582 | + while ($objmid = $db->fetch_object($resultmid)) { |
|
1583 | + $ref .= ' '.$objmid->ref; |
|
1584 | + } |
|
1585 | + } else { |
|
1586 | + dol_print_error($db); |
|
1587 | + } |
|
1588 | + } |
|
1589 | 1589 | |
1590 | - $ref = dol_trunc($langs->transnoentitiesnoconv("BankId").' '.$val['fk_bank'].' - '.$ref, 295); // 295 + 3 dots (...) is < than max size of 300 |
|
1591 | - return $ref; |
|
1590 | + $ref = dol_trunc($langs->transnoentitiesnoconv("BankId").' '.$val['fk_bank'].' - '.$ref, 295); // 295 + 3 dots (...) is < than max size of 300 |
|
1591 | + return $ref; |
|
1592 | 1592 | } |
@@ -1987,7 +1987,7 @@ discard block |
||
1987 | 1987 | return 1; |
1988 | 1988 | } |
1989 | 1989 | |
1990 | - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
1990 | + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
1991 | 1991 | /** |
1992 | 1992 | * Export bookkeeping |
1993 | 1993 | * |
@@ -1996,7 +1996,7 @@ discard block |
||
1996 | 1996 | */ |
1997 | 1997 | public function export_bookkeeping($model = 'ebp') |
1998 | 1998 | { |
1999 | - // phpcs:enable |
|
1999 | + // phpcs:enable |
|
2000 | 2000 | global $conf; |
2001 | 2001 | |
2002 | 2002 | $sql = "SELECT rowid, doc_date, doc_type,"; |
@@ -2180,7 +2180,7 @@ discard block |
||
2180 | 2180 | */ |
2181 | 2181 | } |
2182 | 2182 | |
2183 | - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
2183 | + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
2184 | 2184 | /** |
2185 | 2185 | * Return list of accounts with label by chart of accounts |
2186 | 2186 | * |
@@ -2195,7 +2195,7 @@ discard block |
||
2195 | 2195 | */ |
2196 | 2196 | public function select_account($selectid, $htmlname = 'account', $showempty = 0, $event = array(), $select_in = 0, $select_out = 0, $aabase = '') |
2197 | 2197 | { |
2198 | - // phpcs:enable |
|
2198 | + // phpcs:enable |
|
2199 | 2199 | global $conf; |
2200 | 2200 | |
2201 | 2201 | require_once constant('DOL_DOCUMENT_ROOT') . '/core/lib/accounting.lib.php'; |
@@ -2292,7 +2292,7 @@ discard block |
||
2292 | 2292 | } |
2293 | 2293 | } |
2294 | 2294 | |
2295 | - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
2295 | + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
2296 | 2296 | /** |
2297 | 2297 | * Description of accounting account |
2298 | 2298 | * |
@@ -2301,7 +2301,7 @@ discard block |
||
2301 | 2301 | */ |
2302 | 2302 | public function get_compte_desc($account = null) |
2303 | 2303 | { |
2304 | - // phpcs:enable |
|
2304 | + // phpcs:enable |
|
2305 | 2305 | global $conf; |
2306 | 2306 | |
2307 | 2307 | $pcgver = getDolGlobalInt('CHARTOFACCOUNTS'); |
@@ -2545,14 +2545,14 @@ |
||
2545 | 2545 | } |
2546 | 2546 | |
2547 | 2547 | /** |
2548 | - * Export format : iSuite Expert |
|
2549 | - * |
|
2550 | - * by OpenSolus [https://opensolus.fr] |
|
2551 | - * |
|
2548 | + * Export format : iSuite Expert |
|
2549 | + * |
|
2550 | + * by OpenSolus [https://opensolus.fr] |
|
2551 | + * |
|
2552 | 2552 | * @param array $objectLines data |
2553 | 2553 | * @param resource $exportFile [=null] File resource to export or print if null |
2554 | 2554 | * @return void |
2555 | - */ |
|
2555 | + */ |
|
2556 | 2556 | public function exportiSuiteExpert($objectLines, $exportFile = null) |
2557 | 2557 | { |
2558 | 2558 | $separator = ';'; |
@@ -698,7 +698,7 @@ discard block |
||
698 | 698 | return $this->LibStatut($this->status, $mode); |
699 | 699 | } |
700 | 700 | |
701 | - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
701 | + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
702 | 702 | /** |
703 | 703 | * Return the label of a given status |
704 | 704 | * |
@@ -708,7 +708,7 @@ discard block |
||
708 | 708 | */ |
709 | 709 | public function LibStatut($status, $mode = 0) |
710 | 710 | { |
711 | - // phpcs:enable |
|
711 | + // phpcs:enable |
|
712 | 712 | if (empty($this->labelStatus) || empty($this->labelStatusShort)) { |
713 | 713 | global $langs; |
714 | 714 | $langs->load("users"); |
@@ -337,7 +337,7 @@ discard block |
||
337 | 337 | return $this->LibType($this->nature, $mode); |
338 | 338 | } |
339 | 339 | |
340 | - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
340 | + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
341 | 341 | /** |
342 | 342 | * Return type of an accounting journal |
343 | 343 | * |
@@ -347,7 +347,7 @@ discard block |
||
347 | 347 | */ |
348 | 348 | public function LibType($nature, $mode = 0) |
349 | 349 | { |
350 | - // phpcs:enable |
|
350 | + // phpcs:enable |
|
351 | 351 | global $langs; |
352 | 352 | |
353 | 353 | $langs->loadLangs(array("accountancy")); |
@@ -235,10 +235,10 @@ |
||
235 | 235 | $id = $ecmdirtmp->create($user); |
236 | 236 | if ($id > 0) { |
237 | 237 | $newdirsql = array('id' => $id, |
238 | - 'id_mere' => $ecmdirtmp->fk_parent, |
|
239 | - 'label' => $ecmdirtmp->label, |
|
240 | - 'description' => $ecmdirtmp->description, |
|
241 | - 'fullrelativename' => $relativepathmissing); |
|
238 | + 'id_mere' => $ecmdirtmp->fk_parent, |
|
239 | + 'label' => $ecmdirtmp->label, |
|
240 | + 'description' => $ecmdirtmp->description, |
|
241 | + 'fullrelativename' => $relativepathmissing); |
|
242 | 242 | $sqltree[] = $newdirsql; // We complete fulltree for following loops |
243 | 243 | //var_dump($sqltree); |
244 | 244 | $adirwascreated = 1; |