@@ -576,7 +576,7 @@ discard block |
||
| 576 | 576 | return $this->LibStatut($this->status, $mode); |
| 577 | 577 | } |
| 578 | 578 | |
| 579 | - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 579 | + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 580 | 580 | /** |
| 581 | 581 | * Return the status |
| 582 | 582 | * |
@@ -587,7 +587,7 @@ discard block |
||
| 587 | 587 | */ |
| 588 | 588 | public function LibStatut($status, $mode = 0) |
| 589 | 589 | { |
| 590 | - // phpcs:enable |
|
| 590 | + // phpcs:enable |
|
| 591 | 591 | global $langs; |
| 592 | 592 | |
| 593 | 593 | if (empty($this->labelStatus) || empty($this->labelStatusShort)) { |
@@ -295,7 +295,7 @@ discard block |
||
| 295 | 295 | ); |
| 296 | 296 | } |
| 297 | 297 | |
| 298 | - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore |
|
| 298 | + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore |
|
| 299 | 299 | /** |
| 300 | 300 | * Clean sensible object datas |
| 301 | 301 | * |
@@ -304,30 +304,30 @@ discard block |
||
| 304 | 304 | */ |
| 305 | 305 | public function _cleanObjectDatas($object) |
| 306 | 306 | { |
| 307 | - // phpcs:disable |
|
| 308 | - $object = parent::_cleanObjectDatas($object); |
|
| 309 | - |
|
| 310 | - return $object; |
|
| 311 | - } |
|
| 312 | - |
|
| 313 | - /** |
|
| 314 | - * Validate fields before create or update object |
|
| 315 | - * |
|
| 316 | - * @param array $data Array of data to validate |
|
| 317 | - * @param array $fields Array of fields needed |
|
| 318 | - * @return array |
|
| 319 | - * |
|
| 320 | - * @throws RestException |
|
| 321 | - */ |
|
| 322 | - private function validate($data, $fields) |
|
| 323 | - { |
|
| 324 | - $hook = array(); |
|
| 325 | - foreach ($fields as $field) { |
|
| 326 | - if (!isset($data[$field])) { |
|
| 327 | - throw new RestException(400, $field." field missing"); |
|
| 328 | - } |
|
| 329 | - $hook[$field] = $data[$field]; |
|
| 330 | - } |
|
| 331 | - return $hook; |
|
| 332 | - } |
|
| 307 | + // phpcs:disable |
|
| 308 | + $object = parent::_cleanObjectDatas($object); |
|
| 309 | + |
|
| 310 | + return $object; |
|
| 311 | + } |
|
| 312 | + |
|
| 313 | + /** |
|
| 314 | + * Validate fields before create or update object |
|
| 315 | + * |
|
| 316 | + * @param array $data Array of data to validate |
|
| 317 | + * @param array $fields Array of fields needed |
|
| 318 | + * @return array |
|
| 319 | + * |
|
| 320 | + * @throws RestException |
|
| 321 | + */ |
|
| 322 | + private function validate($data, $fields) |
|
| 323 | + { |
|
| 324 | + $hook = array(); |
|
| 325 | + foreach ($fields as $field) { |
|
| 326 | + if (!isset($data[$field])) { |
|
| 327 | + throw new RestException(400, $field." field missing"); |
|
| 328 | + } |
|
| 329 | + $hook[$field] = $data[$field]; |
|
| 330 | + } |
|
| 331 | + return $hook; |
|
| 332 | + } |
|
| 333 | 333 | } |
@@ -324,7 +324,7 @@ |
||
| 324 | 324 | $hook = array(); |
| 325 | 325 | foreach ($fields as $field) { |
| 326 | 326 | if (!isset($data[$field])) { |
| 327 | - throw new RestException(400, $field." field missing"); |
|
| 327 | + throw new RestException(400, $field . " field missing"); |
|
| 328 | 328 | } |
| 329 | 329 | $hook[$field] = $data[$field]; |
| 330 | 330 | } |
@@ -837,7 +837,7 @@ discard block |
||
| 837 | 837 | return $this->LibStatut($this->status, $mode); |
| 838 | 838 | } |
| 839 | 839 | |
| 840 | - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 840 | + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 841 | 841 | /** |
| 842 | 842 | * Return the label of a given status |
| 843 | 843 | * |
@@ -847,7 +847,7 @@ discard block |
||
| 847 | 847 | */ |
| 848 | 848 | public function LibStatut($status, $mode = 0) |
| 849 | 849 | { |
| 850 | - // phpcs:enable |
|
| 850 | + // phpcs:enable |
|
| 851 | 851 | if (empty($this->labelStatus) || empty($this->labelStatusShort)) { |
| 852 | 852 | global $langs; |
| 853 | 853 | |
@@ -847,7 +847,7 @@ discard block |
||
| 847 | 847 | return $this->LibStatut($this->status, $mode); |
| 848 | 848 | } |
| 849 | 849 | |
| 850 | - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 850 | + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 851 | 851 | /** |
| 852 | 852 | * Return the status |
| 853 | 853 | * |
@@ -857,7 +857,7 @@ discard block |
||
| 857 | 857 | */ |
| 858 | 858 | public function LibStatut($status, $mode = 0) |
| 859 | 859 | { |
| 860 | - // phpcs:enable |
|
| 860 | + // phpcs:enable |
|
| 861 | 861 | if (empty($this->labelStatus) || empty($this->labelStatusShort)) { |
| 862 | 862 | global $langs; |
| 863 | 863 | //$langs->load("agenda"); |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | return $object; |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 84 | + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 85 | 85 | /** |
| 86 | 86 | * Set content of ->tpl array, to use into template |
| 87 | 87 | * |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | */ |
| 92 | 92 | public function assign_values(&$action, $id) |
| 93 | 93 | { |
| 94 | - // phpcs:enable |
|
| 94 | + // phpcs:enable |
|
| 95 | 95 | global $conf, $langs, $user, $canvas; |
| 96 | 96 | global $form, $formcompany, $objsoc; |
| 97 | 97 | |
@@ -275,7 +275,7 @@ discard block |
||
| 275 | 275 | } |
| 276 | 276 | } |
| 277 | 277 | |
| 278 | - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 278 | + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 279 | 279 | /** |
| 280 | 280 | * Assign POST values into object |
| 281 | 281 | * |
@@ -283,7 +283,7 @@ discard block |
||
| 283 | 283 | */ |
| 284 | 284 | private function assign_post() |
| 285 | 285 | { |
| 286 | - // phpcs:enable |
|
| 286 | + // phpcs:enable |
|
| 287 | 287 | global $langs, $mysoc; |
| 288 | 288 | |
| 289 | 289 | $this->object->socid = GETPOSTINT("socid"); |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | return $out; |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 77 | + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 78 | 78 | /** |
| 79 | 79 | * Assign custom values for canvas |
| 80 | 80 | * |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | */ |
| 85 | 85 | public function assign_values(&$action, $id) |
| 86 | 86 | { |
| 87 | - // phpcs:enable |
|
| 87 | + // phpcs:enable |
|
| 88 | 88 | global $conf, $db, $langs, $user; |
| 89 | 89 | global $form; |
| 90 | 90 | |
@@ -754,8 +754,8 @@ discard block |
||
| 754 | 754 | } |
| 755 | 755 | |
| 756 | 756 | |
| 757 | - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 758 | - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore |
|
| 757 | + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 758 | + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore |
|
| 759 | 759 | /** |
| 760 | 760 | * Return DN string complete in the LDAP directory for the object |
| 761 | 761 | * |
@@ -767,7 +767,7 @@ discard block |
||
| 767 | 767 | */ |
| 768 | 768 | public function _load_ldap_dn($info, $mode = 0) |
| 769 | 769 | { |
| 770 | - // phpcs:enable |
|
| 770 | + // phpcs:enable |
|
| 771 | 771 | global $conf; |
| 772 | 772 | $dn = ''; |
| 773 | 773 | if ($mode == 0) { |
@@ -781,8 +781,8 @@ discard block |
||
| 781 | 781 | } |
| 782 | 782 | |
| 783 | 783 | |
| 784 | - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 785 | - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore |
|
| 784 | + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 785 | + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore |
|
| 786 | 786 | /** |
| 787 | 787 | * Initialize info table (LDAP attributes table) |
| 788 | 788 | * |
@@ -790,7 +790,7 @@ discard block |
||
| 790 | 790 | */ |
| 791 | 791 | public function _load_ldap_info() |
| 792 | 792 | { |
| 793 | - // phpcs:enable |
|
| 793 | + // phpcs:enable |
|
| 794 | 794 | global $conf, $langs; |
| 795 | 795 | |
| 796 | 796 | $info = array(); |
@@ -891,7 +891,7 @@ discard block |
||
| 891 | 891 | } |
| 892 | 892 | |
| 893 | 893 | |
| 894 | - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 894 | + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 895 | 895 | /** |
| 896 | 896 | * Update field alert birthday |
| 897 | 897 | * |
@@ -902,7 +902,7 @@ discard block |
||
| 902 | 902 | */ |
| 903 | 903 | public function update_perso($id, $user = null, $notrigger = 0) |
| 904 | 904 | { |
| 905 | - // phpcs:enable |
|
| 905 | + // phpcs:enable |
|
| 906 | 906 | $error = 0; |
| 907 | 907 | $result = false; |
| 908 | 908 | |
@@ -1186,7 +1186,7 @@ discard block |
||
| 1186 | 1186 | } |
| 1187 | 1187 | } |
| 1188 | 1188 | |
| 1189 | - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 1189 | + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 1190 | 1190 | /** |
| 1191 | 1191 | * Load number of elements the contact is used as a link for |
| 1192 | 1192 | * ref_facturation |
@@ -1198,7 +1198,7 @@ discard block |
||
| 1198 | 1198 | */ |
| 1199 | 1199 | public function load_ref_elements() |
| 1200 | 1200 | { |
| 1201 | - // phpcs:enable |
|
| 1201 | + // phpcs:enable |
|
| 1202 | 1202 | // Count the elements for which it is contact |
| 1203 | 1203 | $sql = "SELECT tc.element, count(ec.rowid) as nb"; |
| 1204 | 1204 | $sql .= " FROM " . MAIN_DB_PREFIX . "element_contact as ec, " . MAIN_DB_PREFIX . "c_type_contact as tc"; |
@@ -1582,7 +1582,7 @@ discard block |
||
| 1582 | 1582 | return $this->LibStatut($this->statut, $mode); |
| 1583 | 1583 | } |
| 1584 | 1584 | |
| 1585 | - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 1585 | + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 1586 | 1586 | /** |
| 1587 | 1587 | * Return the label of a given status |
| 1588 | 1588 | * |
@@ -1592,7 +1592,7 @@ discard block |
||
| 1592 | 1592 | */ |
| 1593 | 1593 | public function LibStatut($status, $mode) |
| 1594 | 1594 | { |
| 1595 | - // phpcs:enable |
|
| 1595 | + // phpcs:enable |
|
| 1596 | 1596 | global $langs; |
| 1597 | 1597 | |
| 1598 | 1598 | $labelStatus = array( |
@@ -1620,7 +1620,7 @@ discard block |
||
| 1620 | 1620 | } |
| 1621 | 1621 | |
| 1622 | 1622 | |
| 1623 | - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 1623 | + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 1624 | 1624 | /** |
| 1625 | 1625 | * Return translated label of Public or Private |
| 1626 | 1626 | * |
@@ -1629,7 +1629,7 @@ discard block |
||
| 1629 | 1629 | */ |
| 1630 | 1630 | public function LibPubPriv($status) |
| 1631 | 1631 | { |
| 1632 | - // phpcs:enable |
|
| 1632 | + // phpcs:enable |
|
| 1633 | 1633 | global $langs; |
| 1634 | 1634 | if ($status == '1') { |
| 1635 | 1635 | return $langs->trans('ContactPrivate'); |
@@ -215,8 +215,8 @@ discard block |
||
| 215 | 215 | /** |
| 216 | 216 | * @var int Thirdparty ID |
| 217 | 217 | */ |
| 218 | - public $socid; // both socid and fk_soc are used |
|
| 219 | - public $fk_soc; // both socid and fk_soc are used |
|
| 218 | + public $socid; // both socid and fk_soc are used |
|
| 219 | + public $fk_soc; // both socid and fk_soc are used |
|
| 220 | 220 | |
| 221 | 221 | /** |
| 222 | 222 | * @var string Thirdparty name |
@@ -1067,8 +1067,8 @@ discard block |
||
| 1067 | 1067 | $this->country_code = $obj->country_id ? $obj->country_code : ''; |
| 1068 | 1068 | $this->country = $obj->country_id ? ($langs->trans('Country' . $obj->country_code) != 'Country' . $obj->country_code ? $langs->transnoentities('Country' . $obj->country_code) : $obj->country) : ''; |
| 1069 | 1069 | |
| 1070 | - $this->fk_soc = $obj->fk_soc; // Both fk_soc and socid are used |
|
| 1071 | - $this->socid = $obj->fk_soc; // Both fk_soc and socid are used |
|
| 1070 | + $this->fk_soc = $obj->fk_soc; // Both fk_soc and socid are used |
|
| 1071 | + $this->socid = $obj->fk_soc; // Both fk_soc and socid are used |
|
| 1072 | 1072 | $this->socname = $obj->socname; |
| 1073 | 1073 | $this->poste = $obj->poste; |
| 1074 | 1074 | $this->statut = $obj->statut; |
@@ -1876,7 +1876,7 @@ discard block |
||
| 1876 | 1876 | $error = 0; |
| 1877 | 1877 | |
| 1878 | 1878 | if (!isset($this->roles)) { |
| 1879 | - return 0; // Avoid to loose roles when property not set |
|
| 1879 | + return 0; // Avoid to loose roles when property not set |
|
| 1880 | 1880 | } |
| 1881 | 1881 | |
| 1882 | 1882 | $this->db->begin(); |
@@ -1151,7 +1151,7 @@ discard block |
||
| 1151 | 1151 | } |
| 1152 | 1152 | |
| 1153 | 1153 | |
| 1154 | - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 1154 | + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 1155 | 1155 | /** |
| 1156 | 1156 | * Run a job. |
| 1157 | 1157 | * Once job is finished, status and nb of run is updated. |
@@ -1162,7 +1162,7 @@ discard block |
||
| 1162 | 1162 | */ |
| 1163 | 1163 | public function run_jobs(string $userlogin) |
| 1164 | 1164 | { |
| 1165 | - // phpcs:enable |
|
| 1165 | + // phpcs:enable |
|
| 1166 | 1166 | global $langs, $conf, $hookmanager; |
| 1167 | 1167 | |
| 1168 | 1168 | $hookmanager->initHooks(array('cron')); |
@@ -1442,7 +1442,7 @@ discard block |
||
| 1442 | 1442 | } |
| 1443 | 1443 | |
| 1444 | 1444 | |
| 1445 | - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 1445 | + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 1446 | 1446 | /** |
| 1447 | 1447 | * Reprogram a job |
| 1448 | 1448 | * |
@@ -1452,7 +1452,7 @@ discard block |
||
| 1452 | 1452 | */ |
| 1453 | 1453 | public function reprogram_jobs(string $userlogin, int $now) |
| 1454 | 1454 | { |
| 1455 | - // phpcs:enable |
|
| 1455 | + // phpcs:enable |
|
| 1456 | 1456 | dol_syslog(get_class($this) . "::reprogram_jobs userlogin:$userlogin", LOG_DEBUG); |
| 1457 | 1457 | |
| 1458 | 1458 | require_once DOL_DOCUMENT_ROOT . '/user/class/user.class.php'; |
@@ -1533,7 +1533,7 @@ discard block |
||
| 1533 | 1533 | return $this->LibStatut($this->status, $mode, $this->processing, $this->lastresult); |
| 1534 | 1534 | } |
| 1535 | 1535 | |
| 1536 | - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 1536 | + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
|
| 1537 | 1537 | /** |
| 1538 | 1538 | * Return label of a giver status |
| 1539 | 1539 | * |
@@ -1545,7 +1545,7 @@ discard block |
||
| 1545 | 1545 | */ |
| 1546 | 1546 | public function LibStatut(int $status, int $mode = 0, int $processing = 0, string $lastResult = '') |
| 1547 | 1547 | { |
| 1548 | - // phpcs:enable |
|
| 1548 | + // phpcs:enable |
|
| 1549 | 1549 | $this->labelStatus = array(); // Force reset o array because label depends on other fields |
| 1550 | 1550 | $this->labelStatusShort = array(); |
| 1551 | 1551 | |
@@ -1015,7 +1015,7 @@ discard block |
||
| 1015 | 1015 | $datas['ref'] = '<br><b>' . $langs->trans('Ref') . ':</b> ' . dol_escape_htmltag($this->ref); |
| 1016 | 1016 | $datas['label'] = '<br><b>' . $langs->trans('Title') . ':</b> ' . $langs->trans($this->label); |
| 1017 | 1017 | if ($this->label != $langs->trans($this->label)) { |
| 1018 | - $datas['label'] .= ' <span class="opacitymedium">(' . $this->label . ')</span>'; |
|
| 1018 | + $datas['label'] .= ' <span class="opacitymedium">(' . $this->label . ')</span>'; |
|
| 1019 | 1019 | } |
| 1020 | 1020 | if (!empty($this->params)) { |
| 1021 | 1021 | $datas['params'] = '<br><b>' . $langs->trans('Parameters') . ':</b> ' . dol_escape_htmltag($this->params); |
@@ -1435,7 +1435,7 @@ discard block |
||
| 1435 | 1435 | $msg = $langs->trans("ErrorInBatch", $this->label); |
| 1436 | 1436 | $from = getDolGlobalString('MAIN_MAIL_EMAIL_FROM'); |
| 1437 | 1437 | $cmailfile = new CMailFile($subject, $this->email_alert, $from, $msg); |
| 1438 | - $result = $cmailfile->sendfile(); // Do not test result |
|
| 1438 | + $result = $cmailfile->sendfile(); // Do not test result |
|
| 1439 | 1439 | } |
| 1440 | 1440 | |
| 1441 | 1441 | return $error ? -1 : 1; |
@@ -352,236 +352,236 @@ discard block |
||
| 352 | 352 | // We save tabtype for a future use, to remember what kind of payment it is |
| 353 | 353 | $tabpay[$obj->rowid]['type'] = $links[$key]['type']; |
| 354 | 354 | $tabtype[$obj->rowid] = $links[$key]['type']; |
| 355 | - /* phpcs:disable -- Code does nothing at this moment -> commented |
|
| 355 | + /* phpcs:disable -- Code does nothing at this moment -> commented |
|
| 356 | 356 | } elseif (in_array($links[$key]['type'], array('company', 'user'))) { |
| 357 | 357 | if ($tabpay[$obj->rowid]['type'] == 'unknown') { |
| 358 | 358 | // We can guess here it is a bank record for a thirdparty company or a user. |
| 359 | 359 | // 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. |
| 360 | 360 | } |
| 361 | 361 | */ // phpcs::enable |
| 362 | - } |
|
| 363 | - |
|
| 364 | - // Special case to ask later to add more request to get information for old links without company link. |
|
| 365 | - if ($links[$key]['type'] == 'withdraw') { |
|
| 366 | - $tabmoreinfo[$obj->rowid]['withdraw'] = 1; |
|
| 367 | - } |
|
| 362 | + } |
|
| 368 | 363 | |
| 369 | - if ($links[$key]['type'] == 'payment') { |
|
| 370 | - $paymentstatic->id = $links[$key]['url_id']; |
|
| 371 | - $paymentstatic->ref = $links[$key]['url_id']; |
|
| 372 | - $tabpay[$obj->rowid]["lib"] .= ' '.$paymentstatic->getNomUrl(2, '', ''); // TODO Do not include list of invoice in tooltip, the dol_string_nohtmltag is ko with this |
|
| 373 | - $tabpay[$obj->rowid]["paymentid"] = $paymentstatic->id; |
|
| 374 | - } elseif ($links[$key]['type'] == 'payment_supplier') { |
|
| 375 | - $paymentsupplierstatic->id = $links[$key]['url_id']; |
|
| 376 | - $paymentsupplierstatic->ref = $links[$key]['url_id']; |
|
| 377 | - $tabpay[$obj->rowid]["lib"] .= ' '.$paymentsupplierstatic->getNomUrl(2); |
|
| 378 | - $tabpay[$obj->rowid]["paymentsupplierid"] = $paymentsupplierstatic->id; |
|
| 379 | - } elseif ($links[$key]['type'] == 'company') { |
|
| 380 | - $societestatic->id = $links[$key]['url_id']; |
|
| 381 | - $societestatic->name = $links[$key]['label']; |
|
| 382 | - $societestatic->email = $tabcompany[$obj->rowid]['email']; |
|
| 383 | - $tabpay[$obj->rowid]["soclib"] = $societestatic->getNomUrl(1, '', 30); |
|
| 384 | - if ($compta_soc) { |
|
| 385 | - if (empty($tabtp[$obj->rowid][$compta_soc])) { |
|
| 386 | - $tabtp[$obj->rowid][$compta_soc] = $amounttouse; |
|
| 387 | - } else { |
|
| 388 | - $tabtp[$obj->rowid][$compta_soc] += $amounttouse; |
|
| 389 | - } |
|
| 390 | - } |
|
| 391 | - } elseif ($links[$key]['type'] == 'user') { |
|
| 392 | - $userstatic->id = $links[$key]['url_id']; |
|
| 393 | - $userstatic->name = $links[$key]['label']; |
|
| 394 | - $userstatic->email = $tabuser[$obj->rowid]['email']; |
|
| 395 | - $userstatic->firstname = $tabuser[$obj->rowid]['firstname']; |
|
| 396 | - $userstatic->lastname = $tabuser[$obj->rowid]['lastname']; |
|
| 397 | - $userstatic->statut = $tabuser[$obj->rowid]['status']; |
|
| 398 | - $userstatic->status = $tabuser[$obj->rowid]['status']; |
|
| 399 | - $userstatic->accountancy_code = $tabuser[$obj->rowid]['accountancy_code']; |
|
| 400 | - if ($userstatic->id > 0) { |
|
| 401 | - $tabpay[$obj->rowid]["soclib"] = $userstatic->getNomUrl(1, 'accountancy', 0); |
|
| 402 | - } else { |
|
| 403 | - $tabpay[$obj->rowid]["soclib"] = '???'; // Should not happen, but happens with old data when id of user was not saved on expense report payment. |
|
| 404 | - } |
|
| 405 | - if ($compta_user) { |
|
| 406 | - $tabtp[$obj->rowid][$compta_user] += $amounttouse; |
|
| 407 | - } |
|
| 408 | - } elseif ($links[$key]['type'] == 'sc') { |
|
| 409 | - $chargestatic->id = $links[$key]['url_id']; |
|
| 410 | - $chargestatic->ref = $links[$key]['url_id']; |
|
| 411 | - |
|
| 412 | - $tabpay[$obj->rowid]["lib"] .= ' '.$chargestatic->getNomUrl(2); |
|
| 413 | - $reg = array(); |
|
| 414 | - if (preg_match('/^\((.*)\)$/i', $links[$key]['label'], $reg)) { |
|
| 415 | - if ($reg[1] == 'socialcontribution') { |
|
| 416 | - $reg[1] = 'SocialContribution'; |
|
| 417 | - } |
|
| 418 | - $chargestatic->label = $langs->trans($reg[1]); |
|
| 419 | - } else { |
|
| 420 | - $chargestatic->label = $links[$key]['label']; |
|
| 421 | - } |
|
| 422 | - $chargestatic->ref = $chargestatic->label; |
|
| 423 | - $tabpay[$obj->rowid]["soclib"] = $chargestatic->getNomUrl(1, 30); |
|
| 424 | - $tabpay[$obj->rowid]["paymentscid"] = $chargestatic->id; |
|
| 425 | - |
|
| 426 | - // Retrieve the accounting code of the social contribution of the payment from link of payment. |
|
| 427 | - // Note: We have the social contribution id, it can be faster to get accounting code from social contribution id. |
|
| 428 | - $sqlmid = "SELECT cchgsoc.accountancy_code"; |
|
| 429 | - $sqlmid .= " FROM ".MAIN_DB_PREFIX."c_chargesociales cchgsoc"; |
|
| 430 | - $sqlmid .= " INNER JOIN ".MAIN_DB_PREFIX."chargesociales as chgsoc ON chgsoc.fk_type = cchgsoc.id"; |
|
| 431 | - $sqlmid .= " INNER JOIN ".MAIN_DB_PREFIX."paiementcharge as paycharg ON paycharg.fk_charge = chgsoc.rowid"; |
|
| 432 | - $sqlmid .= " INNER JOIN ".MAIN_DB_PREFIX."bank_url as bkurl ON bkurl.url_id=paycharg.rowid AND bkurl.type = 'payment_sc'"; |
|
| 433 | - $sqlmid .= " WHERE bkurl.fk_bank = ".((int) $obj->rowid); |
|
| 434 | - |
|
| 435 | - dol_syslog("accountancy/journal/bankjournal.php:: sqlmid=".$sqlmid, LOG_DEBUG); |
|
| 436 | - $resultmid = $db->query($sqlmid); |
|
| 437 | - if ($resultmid) { |
|
| 438 | - $objmid = $db->fetch_object($resultmid); |
|
| 439 | - $tabtp[$obj->rowid][$objmid->accountancy_code] += $amounttouse; |
|
| 440 | - } |
|
| 441 | - } elseif ($links[$key]['type'] == 'payment_donation') { |
|
| 442 | - $paymentdonstatic->id = $links[$key]['url_id']; |
|
| 443 | - $paymentdonstatic->ref = $links[$key]['url_id']; |
|
| 444 | - $paymentdonstatic->fk_donation = $links[$key]['url_id']; |
|
| 445 | - $tabpay[$obj->rowid]["lib"] .= ' '.$paymentdonstatic->getNomUrl(2); |
|
| 446 | - $tabpay[$obj->rowid]["paymentdonationid"] = $paymentdonstatic->id; |
|
| 447 | - $tabtp[$obj->rowid][$account_pay_donation] += $amounttouse; |
|
| 448 | - } elseif ($links[$key]['type'] == 'member') { |
|
| 449 | - $paymentsubscriptionstatic->id = $links[$key]['url_id']; |
|
| 450 | - $paymentsubscriptionstatic->ref = $links[$key]['url_id']; |
|
| 451 | - $paymentsubscriptionstatic->label = $links[$key]['label']; |
|
| 452 | - $tabpay[$obj->rowid]["lib"] .= ' '.$paymentsubscriptionstatic->getNomUrl(2); |
|
| 453 | - $tabpay[$obj->rowid]["paymentsubscriptionid"] = $paymentsubscriptionstatic->id; |
|
| 454 | - $paymentsubscriptionstatic->fetch($paymentsubscriptionstatic->id); |
|
| 455 | - $tabtp[$obj->rowid][$account_pay_subscription] += $amounttouse; |
|
| 456 | - } elseif ($links[$key]['type'] == 'payment_vat') { // Payment VAT |
|
| 457 | - $paymentvatstatic->id = $links[$key]['url_id']; |
|
| 458 | - $paymentvatstatic->ref = $links[$key]['url_id']; |
|
| 459 | - $paymentvatstatic->label = $links[$key]['label']; |
|
| 460 | - $tabpay[$obj->rowid]["lib"] .= ' '.$paymentvatstatic->getNomUrl(2); |
|
| 461 | - $tabpay[$obj->rowid]["paymentvatid"] = $paymentvatstatic->id; |
|
| 462 | - $tabtp[$obj->rowid][$account_pay_vat] += $amounttouse; |
|
| 463 | - } elseif ($links[$key]['type'] == 'payment_salary') { |
|
| 464 | - $paymentsalstatic->id = $links[$key]['url_id']; |
|
| 465 | - $paymentsalstatic->ref = $links[$key]['url_id']; |
|
| 466 | - $paymentsalstatic->label = $links[$key]['label']; |
|
| 467 | - $tabpay[$obj->rowid]["lib"] .= ' '.$paymentsalstatic->getNomUrl(2); |
|
| 468 | - $tabpay[$obj->rowid]["paymentsalid"] = $paymentsalstatic->id; |
|
| 469 | - |
|
| 470 | - // 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. |
|
| 471 | - // Note: A better way to fix this is to delete payment of salary and recreate it, or to fix the bookkeeping table manually after. |
|
| 472 | - if (getDolGlobalString('ACCOUNTANCY_AUTOFIX_MISSING_LINK_TO_USER_ON_SALARY_BANK_PAYMENT')) { |
|
| 473 | - $tmpsalary = new Salary($db); |
|
| 474 | - $tmpsalary->fetch($paymentsalstatic->id); |
|
| 475 | - $tmpsalary->fetch_user($tmpsalary->fk_user); |
|
| 476 | - |
|
| 477 | - $userstatic->id = $tmpsalary->user->id; |
|
| 478 | - $userstatic->name = $tmpsalary->user->name; |
|
| 479 | - $userstatic->email = $tmpsalary->user->email; |
|
| 480 | - $userstatic->firstname = $tmpsalary->user->firstname; |
|
| 481 | - $userstatic->lastname = $tmpsalary->user->lastname; |
|
| 482 | - $userstatic->statut = $tmpsalary->user->status; |
|
| 483 | - $userstatic->accountancy_code = $tmpsalary->user->accountancy_code; |
|
| 484 | - |
|
| 485 | - if ($userstatic->id > 0) { |
|
| 486 | - $tabpay[$obj->rowid]["soclib"] = $userstatic->getNomUrl(1, 'accountancy', 0); |
|
| 487 | - } else { |
|
| 488 | - $tabpay[$obj->rowid]["soclib"] = '???'; // Should not happen |
|
| 489 | - } |
|
| 364 | + // Special case to ask later to add more request to get information for old links without company link. |
|
| 365 | + if ($links[$key]['type'] == 'withdraw') { |
|
| 366 | + $tabmoreinfo[$obj->rowid]['withdraw'] = 1; |
|
| 367 | + } |
|
| 490 | 368 | |
| 491 | - if (empty($obj->typeop_user)) { // Add test to avoid to add amount twice if a link already exists also on user. |
|
| 492 | - $compta_user = $userstatic->accountancy_code; |
|
| 493 | - if ($compta_user) { |
|
| 494 | - $tabtp[$obj->rowid][$compta_user] += $amounttouse; |
|
| 495 | - $tabuser[$obj->rowid] = array( |
|
| 496 | - 'id' => $userstatic->id, |
|
| 497 | - 'name' => dolGetFirstLastname($userstatic->firstname, $userstatic->lastname), |
|
| 498 | - 'lastname' => $userstatic->lastname, |
|
| 499 | - 'firstname' => $userstatic->firstname, |
|
| 500 | - 'email' => $userstatic->email, |
|
| 501 | - 'accountancy_code' => $compta_user, |
|
| 502 | - 'status' => $userstatic->status |
|
| 503 | - ); |
|
| 504 | - } |
|
| 505 | - } |
|
| 506 | - } |
|
| 507 | - } elseif ($links[$key]['type'] == 'payment_expensereport') { |
|
| 508 | - $paymentexpensereportstatic->id = $links[$key]['url_id']; |
|
| 509 | - $tabpay[$obj->rowid]["lib"] .= $paymentexpensereportstatic->getNomUrl(2); |
|
| 510 | - $tabpay[$obj->rowid]["paymentexpensereport"] = $paymentexpensereportstatic->id; |
|
| 511 | - } elseif ($links[$key]['type'] == 'payment_various') { |
|
| 512 | - $paymentvariousstatic->id = $links[$key]['url_id']; |
|
| 513 | - $paymentvariousstatic->ref = $links[$key]['url_id']; |
|
| 514 | - $paymentvariousstatic->label = $links[$key]['label']; |
|
| 515 | - $tabpay[$obj->rowid]["lib"] .= ' '.$paymentvariousstatic->getNomUrl(2); |
|
| 516 | - $tabpay[$obj->rowid]["paymentvariousid"] = $paymentvariousstatic->id; |
|
| 517 | - $paymentvariousstatic->fetch($paymentvariousstatic->id); |
|
| 518 | - $account_various = (!empty($paymentvariousstatic->accountancy_code) ? $paymentvariousstatic->accountancy_code : 'NotDefined'); // NotDefined is a reserved word |
|
| 519 | - $account_subledger = (!empty($paymentvariousstatic->subledger_account) ? $paymentvariousstatic->subledger_account : ''); // NotDefined is a reserved word |
|
| 520 | - $tabpay[$obj->rowid]["account_various"] = $account_various; |
|
| 521 | - $tabtp[$obj->rowid][$account_subledger] += $amounttouse; |
|
| 522 | - } elseif ($links[$key]['type'] == 'payment_loan') { |
|
| 523 | - $paymentloanstatic->id = $links[$key]['url_id']; |
|
| 524 | - $paymentloanstatic->ref = $links[$key]['url_id']; |
|
| 525 | - $paymentloanstatic->fk_loan = $links[$key]['url_id']; |
|
| 526 | - $tabpay[$obj->rowid]["lib"] .= ' '.$paymentloanstatic->getNomUrl(2); |
|
| 527 | - $tabpay[$obj->rowid]["paymentloanid"] = $paymentloanstatic->id; |
|
| 528 | - //$tabtp[$obj->rowid][$account_pay_loan] += $amounttouse; |
|
| 529 | - $sqlmid = 'SELECT pl.amount_capital, pl.amount_insurance, pl.amount_interest, l.accountancy_account_capital, l.accountancy_account_insurance, l.accountancy_account_interest'; |
|
| 530 | - $sqlmid .= ' FROM '.MAIN_DB_PREFIX.'payment_loan as pl, '.MAIN_DB_PREFIX.'loan as l'; |
|
| 531 | - $sqlmid .= ' WHERE l.rowid = pl.fk_loan AND pl.fk_bank = '.((int) $obj->rowid); |
|
| 532 | - |
|
| 533 | - dol_syslog("accountancy/journal/bankjournal.php:: sqlmid=".$sqlmid, LOG_DEBUG); |
|
| 534 | - $resultmid = $db->query($sqlmid); |
|
| 535 | - if ($resultmid) { |
|
| 536 | - $objmid = $db->fetch_object($resultmid); |
|
| 537 | - $tabtp[$obj->rowid][$objmid->accountancy_account_capital] -= $objmid->amount_capital; |
|
| 538 | - $tabtp[$obj->rowid][$objmid->accountancy_account_insurance] -= $objmid->amount_insurance; |
|
| 539 | - $tabtp[$obj->rowid][$objmid->accountancy_account_interest] -= $objmid->amount_interest; |
|
| 540 | - } |
|
| 541 | - } elseif ($links[$key]['type'] == 'banktransfert') { |
|
| 542 | - $accountLinestatic->fetch($links[$key]['url_id']); |
|
| 543 | - $tabpay[$obj->rowid]["lib"] .= ' '.$langs->trans("BankTransfer").'- '.$accountLinestatic ->getNomUrl(1); |
|
| 544 | - $tabtp[$obj->rowid][$account_transfer] += $amounttouse; |
|
| 545 | - $bankaccountstatic->fetch($tabpay[$obj->rowid]['fk_bank_account']); |
|
| 546 | - $tabpay[$obj->rowid]["soclib"] = $bankaccountstatic->getNomUrl(2); |
|
| 547 | - } |
|
| 548 | - } |
|
| 549 | - } |
|
| 369 | + if ($links[$key]['type'] == 'payment') { |
|
| 370 | + $paymentstatic->id = $links[$key]['url_id']; |
|
| 371 | + $paymentstatic->ref = $links[$key]['url_id']; |
|
| 372 | + $tabpay[$obj->rowid]["lib"] .= ' '.$paymentstatic->getNomUrl(2, '', ''); // TODO Do not include list of invoice in tooltip, the dol_string_nohtmltag is ko with this |
|
| 373 | + $tabpay[$obj->rowid]["paymentid"] = $paymentstatic->id; |
|
| 374 | + } elseif ($links[$key]['type'] == 'payment_supplier') { |
|
| 375 | + $paymentsupplierstatic->id = $links[$key]['url_id']; |
|
| 376 | + $paymentsupplierstatic->ref = $links[$key]['url_id']; |
|
| 377 | + $tabpay[$obj->rowid]["lib"] .= ' '.$paymentsupplierstatic->getNomUrl(2); |
|
| 378 | + $tabpay[$obj->rowid]["paymentsupplierid"] = $paymentsupplierstatic->id; |
|
| 379 | + } elseif ($links[$key]['type'] == 'company') { |
|
| 380 | + $societestatic->id = $links[$key]['url_id']; |
|
| 381 | + $societestatic->name = $links[$key]['label']; |
|
| 382 | + $societestatic->email = $tabcompany[$obj->rowid]['email']; |
|
| 383 | + $tabpay[$obj->rowid]["soclib"] = $societestatic->getNomUrl(1, '', 30); |
|
| 384 | + if ($compta_soc) { |
|
| 385 | + if (empty($tabtp[$obj->rowid][$compta_soc])) { |
|
| 386 | + $tabtp[$obj->rowid][$compta_soc] = $amounttouse; |
|
| 387 | + } else { |
|
| 388 | + $tabtp[$obj->rowid][$compta_soc] += $amounttouse; |
|
| 389 | + } |
|
| 390 | + } |
|
| 391 | + } elseif ($links[$key]['type'] == 'user') { |
|
| 392 | + $userstatic->id = $links[$key]['url_id']; |
|
| 393 | + $userstatic->name = $links[$key]['label']; |
|
| 394 | + $userstatic->email = $tabuser[$obj->rowid]['email']; |
|
| 395 | + $userstatic->firstname = $tabuser[$obj->rowid]['firstname']; |
|
| 396 | + $userstatic->lastname = $tabuser[$obj->rowid]['lastname']; |
|
| 397 | + $userstatic->statut = $tabuser[$obj->rowid]['status']; |
|
| 398 | + $userstatic->status = $tabuser[$obj->rowid]['status']; |
|
| 399 | + $userstatic->accountancy_code = $tabuser[$obj->rowid]['accountancy_code']; |
|
| 400 | + if ($userstatic->id > 0) { |
|
| 401 | + $tabpay[$obj->rowid]["soclib"] = $userstatic->getNomUrl(1, 'accountancy', 0); |
|
| 402 | + } else { |
|
| 403 | + $tabpay[$obj->rowid]["soclib"] = '???'; // Should not happen, but happens with old data when id of user was not saved on expense report payment. |
|
| 404 | + } |
|
| 405 | + if ($compta_user) { |
|
| 406 | + $tabtp[$obj->rowid][$compta_user] += $amounttouse; |
|
| 407 | + } |
|
| 408 | + } elseif ($links[$key]['type'] == 'sc') { |
|
| 409 | + $chargestatic->id = $links[$key]['url_id']; |
|
| 410 | + $chargestatic->ref = $links[$key]['url_id']; |
|
| 411 | + |
|
| 412 | + $tabpay[$obj->rowid]["lib"] .= ' '.$chargestatic->getNomUrl(2); |
|
| 413 | + $reg = array(); |
|
| 414 | + if (preg_match('/^\((.*)\)$/i', $links[$key]['label'], $reg)) { |
|
| 415 | + if ($reg[1] == 'socialcontribution') { |
|
| 416 | + $reg[1] = 'SocialContribution'; |
|
| 417 | + } |
|
| 418 | + $chargestatic->label = $langs->trans($reg[1]); |
|
| 419 | + } else { |
|
| 420 | + $chargestatic->label = $links[$key]['label']; |
|
| 421 | + } |
|
| 422 | + $chargestatic->ref = $chargestatic->label; |
|
| 423 | + $tabpay[$obj->rowid]["soclib"] = $chargestatic->getNomUrl(1, 30); |
|
| 424 | + $tabpay[$obj->rowid]["paymentscid"] = $chargestatic->id; |
|
| 425 | + |
|
| 426 | + // Retrieve the accounting code of the social contribution of the payment from link of payment. |
|
| 427 | + // Note: We have the social contribution id, it can be faster to get accounting code from social contribution id. |
|
| 428 | + $sqlmid = "SELECT cchgsoc.accountancy_code"; |
|
| 429 | + $sqlmid .= " FROM ".MAIN_DB_PREFIX."c_chargesociales cchgsoc"; |
|
| 430 | + $sqlmid .= " INNER JOIN ".MAIN_DB_PREFIX."chargesociales as chgsoc ON chgsoc.fk_type = cchgsoc.id"; |
|
| 431 | + $sqlmid .= " INNER JOIN ".MAIN_DB_PREFIX."paiementcharge as paycharg ON paycharg.fk_charge = chgsoc.rowid"; |
|
| 432 | + $sqlmid .= " INNER JOIN ".MAIN_DB_PREFIX."bank_url as bkurl ON bkurl.url_id=paycharg.rowid AND bkurl.type = 'payment_sc'"; |
|
| 433 | + $sqlmid .= " WHERE bkurl.fk_bank = ".((int) $obj->rowid); |
|
| 434 | + |
|
| 435 | + dol_syslog("accountancy/journal/bankjournal.php:: sqlmid=".$sqlmid, LOG_DEBUG); |
|
| 436 | + $resultmid = $db->query($sqlmid); |
|
| 437 | + if ($resultmid) { |
|
| 438 | + $objmid = $db->fetch_object($resultmid); |
|
| 439 | + $tabtp[$obj->rowid][$objmid->accountancy_code] += $amounttouse; |
|
| 440 | + } |
|
| 441 | + } elseif ($links[$key]['type'] == 'payment_donation') { |
|
| 442 | + $paymentdonstatic->id = $links[$key]['url_id']; |
|
| 443 | + $paymentdonstatic->ref = $links[$key]['url_id']; |
|
| 444 | + $paymentdonstatic->fk_donation = $links[$key]['url_id']; |
|
| 445 | + $tabpay[$obj->rowid]["lib"] .= ' '.$paymentdonstatic->getNomUrl(2); |
|
| 446 | + $tabpay[$obj->rowid]["paymentdonationid"] = $paymentdonstatic->id; |
|
| 447 | + $tabtp[$obj->rowid][$account_pay_donation] += $amounttouse; |
|
| 448 | + } elseif ($links[$key]['type'] == 'member') { |
|
| 449 | + $paymentsubscriptionstatic->id = $links[$key]['url_id']; |
|
| 450 | + $paymentsubscriptionstatic->ref = $links[$key]['url_id']; |
|
| 451 | + $paymentsubscriptionstatic->label = $links[$key]['label']; |
|
| 452 | + $tabpay[$obj->rowid]["lib"] .= ' '.$paymentsubscriptionstatic->getNomUrl(2); |
|
| 453 | + $tabpay[$obj->rowid]["paymentsubscriptionid"] = $paymentsubscriptionstatic->id; |
|
| 454 | + $paymentsubscriptionstatic->fetch($paymentsubscriptionstatic->id); |
|
| 455 | + $tabtp[$obj->rowid][$account_pay_subscription] += $amounttouse; |
|
| 456 | + } elseif ($links[$key]['type'] == 'payment_vat') { // Payment VAT |
|
| 457 | + $paymentvatstatic->id = $links[$key]['url_id']; |
|
| 458 | + $paymentvatstatic->ref = $links[$key]['url_id']; |
|
| 459 | + $paymentvatstatic->label = $links[$key]['label']; |
|
| 460 | + $tabpay[$obj->rowid]["lib"] .= ' '.$paymentvatstatic->getNomUrl(2); |
|
| 461 | + $tabpay[$obj->rowid]["paymentvatid"] = $paymentvatstatic->id; |
|
| 462 | + $tabtp[$obj->rowid][$account_pay_vat] += $amounttouse; |
|
| 463 | + } elseif ($links[$key]['type'] == 'payment_salary') { |
|
| 464 | + $paymentsalstatic->id = $links[$key]['url_id']; |
|
| 465 | + $paymentsalstatic->ref = $links[$key]['url_id']; |
|
| 466 | + $paymentsalstatic->label = $links[$key]['label']; |
|
| 467 | + $tabpay[$obj->rowid]["lib"] .= ' '.$paymentsalstatic->getNomUrl(2); |
|
| 468 | + $tabpay[$obj->rowid]["paymentsalid"] = $paymentsalstatic->id; |
|
| 469 | + |
|
| 470 | + // 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. |
|
| 471 | + // Note: A better way to fix this is to delete payment of salary and recreate it, or to fix the bookkeeping table manually after. |
|
| 472 | + if (getDolGlobalString('ACCOUNTANCY_AUTOFIX_MISSING_LINK_TO_USER_ON_SALARY_BANK_PAYMENT')) { |
|
| 473 | + $tmpsalary = new Salary($db); |
|
| 474 | + $tmpsalary->fetch($paymentsalstatic->id); |
|
| 475 | + $tmpsalary->fetch_user($tmpsalary->fk_user); |
|
| 476 | + |
|
| 477 | + $userstatic->id = $tmpsalary->user->id; |
|
| 478 | + $userstatic->name = $tmpsalary->user->name; |
|
| 479 | + $userstatic->email = $tmpsalary->user->email; |
|
| 480 | + $userstatic->firstname = $tmpsalary->user->firstname; |
|
| 481 | + $userstatic->lastname = $tmpsalary->user->lastname; |
|
| 482 | + $userstatic->statut = $tmpsalary->user->status; |
|
| 483 | + $userstatic->accountancy_code = $tmpsalary->user->accountancy_code; |
|
| 484 | + |
|
| 485 | + if ($userstatic->id > 0) { |
|
| 486 | + $tabpay[$obj->rowid]["soclib"] = $userstatic->getNomUrl(1, 'accountancy', 0); |
|
| 487 | + } else { |
|
| 488 | + $tabpay[$obj->rowid]["soclib"] = '???'; // Should not happen |
|
| 489 | + } |
|
| 490 | + |
|
| 491 | + if (empty($obj->typeop_user)) { // Add test to avoid to add amount twice if a link already exists also on user. |
|
| 492 | + $compta_user = $userstatic->accountancy_code; |
|
| 493 | + if ($compta_user) { |
|
| 494 | + $tabtp[$obj->rowid][$compta_user] += $amounttouse; |
|
| 495 | + $tabuser[$obj->rowid] = array( |
|
| 496 | + 'id' => $userstatic->id, |
|
| 497 | + 'name' => dolGetFirstLastname($userstatic->firstname, $userstatic->lastname), |
|
| 498 | + 'lastname' => $userstatic->lastname, |
|
| 499 | + 'firstname' => $userstatic->firstname, |
|
| 500 | + 'email' => $userstatic->email, |
|
| 501 | + 'accountancy_code' => $compta_user, |
|
| 502 | + 'status' => $userstatic->status |
|
| 503 | + ); |
|
| 504 | + } |
|
| 505 | + } |
|
| 506 | + } |
|
| 507 | + } elseif ($links[$key]['type'] == 'payment_expensereport') { |
|
| 508 | + $paymentexpensereportstatic->id = $links[$key]['url_id']; |
|
| 509 | + $tabpay[$obj->rowid]["lib"] .= $paymentexpensereportstatic->getNomUrl(2); |
|
| 510 | + $tabpay[$obj->rowid]["paymentexpensereport"] = $paymentexpensereportstatic->id; |
|
| 511 | + } elseif ($links[$key]['type'] == 'payment_various') { |
|
| 512 | + $paymentvariousstatic->id = $links[$key]['url_id']; |
|
| 513 | + $paymentvariousstatic->ref = $links[$key]['url_id']; |
|
| 514 | + $paymentvariousstatic->label = $links[$key]['label']; |
|
| 515 | + $tabpay[$obj->rowid]["lib"] .= ' '.$paymentvariousstatic->getNomUrl(2); |
|
| 516 | + $tabpay[$obj->rowid]["paymentvariousid"] = $paymentvariousstatic->id; |
|
| 517 | + $paymentvariousstatic->fetch($paymentvariousstatic->id); |
|
| 518 | + $account_various = (!empty($paymentvariousstatic->accountancy_code) ? $paymentvariousstatic->accountancy_code : 'NotDefined'); // NotDefined is a reserved word |
|
| 519 | + $account_subledger = (!empty($paymentvariousstatic->subledger_account) ? $paymentvariousstatic->subledger_account : ''); // NotDefined is a reserved word |
|
| 520 | + $tabpay[$obj->rowid]["account_various"] = $account_various; |
|
| 521 | + $tabtp[$obj->rowid][$account_subledger] += $amounttouse; |
|
| 522 | + } elseif ($links[$key]['type'] == 'payment_loan') { |
|
| 523 | + $paymentloanstatic->id = $links[$key]['url_id']; |
|
| 524 | + $paymentloanstatic->ref = $links[$key]['url_id']; |
|
| 525 | + $paymentloanstatic->fk_loan = $links[$key]['url_id']; |
|
| 526 | + $tabpay[$obj->rowid]["lib"] .= ' '.$paymentloanstatic->getNomUrl(2); |
|
| 527 | + $tabpay[$obj->rowid]["paymentloanid"] = $paymentloanstatic->id; |
|
| 528 | + //$tabtp[$obj->rowid][$account_pay_loan] += $amounttouse; |
|
| 529 | + $sqlmid = 'SELECT pl.amount_capital, pl.amount_insurance, pl.amount_interest, l.accountancy_account_capital, l.accountancy_account_insurance, l.accountancy_account_interest'; |
|
| 530 | + $sqlmid .= ' FROM '.MAIN_DB_PREFIX.'payment_loan as pl, '.MAIN_DB_PREFIX.'loan as l'; |
|
| 531 | + $sqlmid .= ' WHERE l.rowid = pl.fk_loan AND pl.fk_bank = '.((int) $obj->rowid); |
|
| 532 | + |
|
| 533 | + dol_syslog("accountancy/journal/bankjournal.php:: sqlmid=".$sqlmid, LOG_DEBUG); |
|
| 534 | + $resultmid = $db->query($sqlmid); |
|
| 535 | + if ($resultmid) { |
|
| 536 | + $objmid = $db->fetch_object($resultmid); |
|
| 537 | + $tabtp[$obj->rowid][$objmid->accountancy_account_capital] -= $objmid->amount_capital; |
|
| 538 | + $tabtp[$obj->rowid][$objmid->accountancy_account_insurance] -= $objmid->amount_insurance; |
|
| 539 | + $tabtp[$obj->rowid][$objmid->accountancy_account_interest] -= $objmid->amount_interest; |
|
| 540 | + } |
|
| 541 | + } elseif ($links[$key]['type'] == 'banktransfert') { |
|
| 542 | + $accountLinestatic->fetch($links[$key]['url_id']); |
|
| 543 | + $tabpay[$obj->rowid]["lib"] .= ' '.$langs->trans("BankTransfer").'- '.$accountLinestatic ->getNomUrl(1); |
|
| 544 | + $tabtp[$obj->rowid][$account_transfer] += $amounttouse; |
|
| 545 | + $bankaccountstatic->fetch($tabpay[$obj->rowid]['fk_bank_account']); |
|
| 546 | + $tabpay[$obj->rowid]["soclib"] = $bankaccountstatic->getNomUrl(2); |
|
| 547 | + } |
|
| 548 | + } |
|
| 549 | + } |
|
| 550 | 550 | |
| 551 | - if (empty($tabbq[$obj->rowid][$compta_bank])) { |
|
| 552 | - $tabbq[$obj->rowid][$compta_bank] = $amounttouse; |
|
| 553 | - } else { |
|
| 554 | - $tabbq[$obj->rowid][$compta_bank] += $amounttouse; |
|
| 555 | - } |
|
| 551 | + if (empty($tabbq[$obj->rowid][$compta_bank])) { |
|
| 552 | + $tabbq[$obj->rowid][$compta_bank] = $amounttouse; |
|
| 553 | + } else { |
|
| 554 | + $tabbq[$obj->rowid][$compta_bank] += $amounttouse; |
|
| 555 | + } |
|
| 556 | 556 | |
| 557 | - // If no links were found to know the amount on thirdparty, we try to guess it. |
|
| 558 | - // This may happens on bank entries without the links lines to 'company'. |
|
| 559 | - if (empty($tabtp[$obj->rowid]) && !empty($tabmoreinfo[$obj->rowid]['withdraw'])) { // If we don't find 'company' link because it is an old 'withdraw' record |
|
| 560 | - foreach ($links as $key => $val) { |
|
| 561 | - if ($links[$key]['type'] == 'payment') { |
|
| 562 | - // Get thirdparty |
|
| 563 | - $tmppayment->fetch($links[$key]['url_id']); |
|
| 564 | - $arrayofamounts = $tmppayment->getAmountsArray(); |
|
| 565 | - if (is_array($arrayofamounts)) { |
|
| 566 | - foreach ($arrayofamounts as $invoiceid => $amount) { |
|
| 567 | - $tmpinvoice->fetch($invoiceid); |
|
| 568 | - $tmpinvoice->fetch_thirdparty(); |
|
| 569 | - if ($tmpinvoice->thirdparty->code_compta_client) { |
|
| 570 | - $tabtp[$obj->rowid][$tmpinvoice->thirdparty->code_compta_client] += $amount; |
|
| 571 | - } |
|
| 572 | - } |
|
| 573 | - } |
|
| 574 | - } |
|
| 575 | - } |
|
| 576 | - } |
|
| 557 | + // If no links were found to know the amount on thirdparty, we try to guess it. |
|
| 558 | + // This may happens on bank entries without the links lines to 'company'. |
|
| 559 | + if (empty($tabtp[$obj->rowid]) && !empty($tabmoreinfo[$obj->rowid]['withdraw'])) { // If we don't find 'company' link because it is an old 'withdraw' record |
|
| 560 | + foreach ($links as $key => $val) { |
|
| 561 | + if ($links[$key]['type'] == 'payment') { |
|
| 562 | + // Get thirdparty |
|
| 563 | + $tmppayment->fetch($links[$key]['url_id']); |
|
| 564 | + $arrayofamounts = $tmppayment->getAmountsArray(); |
|
| 565 | + if (is_array($arrayofamounts)) { |
|
| 566 | + foreach ($arrayofamounts as $invoiceid => $amount) { |
|
| 567 | + $tmpinvoice->fetch($invoiceid); |
|
| 568 | + $tmpinvoice->fetch_thirdparty(); |
|
| 569 | + if ($tmpinvoice->thirdparty->code_compta_client) { |
|
| 570 | + $tabtp[$obj->rowid][$tmpinvoice->thirdparty->code_compta_client] += $amount; |
|
| 571 | + } |
|
| 572 | + } |
|
| 573 | + } |
|
| 574 | + } |
|
| 575 | + } |
|
| 576 | + } |
|
| 577 | 577 | |
| 578 | - // If no links were found to know the amount on thirdparty/user, we init it to account 'NotDefined'. |
|
| 579 | - if (empty($tabtp[$obj->rowid])) { |
|
| 580 | - $tabtp[$obj->rowid]['NotDefined'] = $tabbq[$obj->rowid][$compta_bank]; |
|
| 581 | - } |
|
| 578 | + // If no links were found to know the amount on thirdparty/user, we init it to account 'NotDefined'. |
|
| 579 | + if (empty($tabtp[$obj->rowid])) { |
|
| 580 | + $tabtp[$obj->rowid]['NotDefined'] = $tabbq[$obj->rowid][$compta_bank]; |
|
| 581 | + } |
|
| 582 | 582 | |
| 583 | - // Check account number is ok |
|
| 584 | - /*if ($action == 'writebookkeeping') // Make test now in such a case |
|
| 583 | + // Check account number is ok |
|
| 584 | + /*if ($action == 'writebookkeeping') // Make test now in such a case |
|
| 585 | 585 | { |
| 586 | 586 | reset($tabbq[$obj->rowid]); |
| 587 | 587 | $first_key_tabbq = key($tabbq[$obj->rowid]); |
@@ -599,12 +599,12 @@ discard block |
||
| 599 | 599 | } |
| 600 | 600 | }*/ |
| 601 | 601 | |
| 602 | - // if($obj->socid)$tabtp[$obj->rowid][$compta_soc] += $amounttouse; |
|
| 602 | + // if($obj->socid)$tabtp[$obj->rowid][$compta_soc] += $amounttouse; |
|
| 603 | 603 | |
| 604 | - $i++; |
|
| 605 | - } |
|
| 604 | + $i++; |
|
| 605 | + } |
|
| 606 | 606 | } else { |
| 607 | - dol_print_error($db); |
|
| 607 | + dol_print_error($db); |
|
| 608 | 608 | } |
| 609 | 609 | |
| 610 | 610 | |
@@ -616,445 +616,445 @@ discard block |
||
| 616 | 616 | |
| 617 | 617 | // Write bookkeeping |
| 618 | 618 | if (!$error && $action == 'writebookkeeping') { |
| 619 | - $now = dol_now(); |
|
| 620 | - |
|
| 621 | - $accountingaccountcustomer = new AccountingAccount($db); |
|
| 622 | - $accountingaccountcustomer->fetch(null, getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER'), true); |
|
| 623 | - |
|
| 624 | - $accountingaccountsupplier = new AccountingAccount($db); |
|
| 625 | - $accountingaccountsupplier->fetch(null, getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER'), true); |
|
| 626 | - |
|
| 627 | - $accountingaccountpayment = new AccountingAccount($db); |
|
| 628 | - $accountingaccountpayment->fetch(null, getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT'), true); |
|
| 629 | - |
|
| 630 | - $accountingaccountsuspense = new AccountingAccount($db); |
|
| 631 | - $accountingaccountsuspense->fetch(null, getDolGlobalString('ACCOUNTING_ACCOUNT_SUSPENSE'), true); |
|
| 632 | - |
|
| 633 | - $error = 0; |
|
| 634 | - foreach ($tabpay as $key => $val) { // $key is rowid into llx_bank |
|
| 635 | - $date = dol_print_date($val["date"], 'day'); |
|
| 636 | - |
|
| 637 | - $ref = getSourceDocRef($val, $tabtype[$key]); |
|
| 638 | - |
|
| 639 | - $errorforline = 0; |
|
| 640 | - |
|
| 641 | - $totalcredit = 0; |
|
| 642 | - $totaldebit = 0; |
|
| 643 | - |
|
| 644 | - $db->begin(); |
|
| 645 | - |
|
| 646 | - // Introduce a protection. Total of tabtp must be total of tabbq |
|
| 647 | - //var_dump($tabpay); |
|
| 648 | - //var_dump($tabtp); |
|
| 649 | - //var_dump($tabbq);exit; |
|
| 650 | - |
|
| 651 | - // Bank |
|
| 652 | - if (!$errorforline && is_array($tabbq[$key])) { |
|
| 653 | - // Line into bank account |
|
| 654 | - foreach ($tabbq[$key] as $k => $mt) { |
|
| 655 | - if ($mt) { |
|
| 656 | - $accountingaccount->fetch(null, $k, true); // $k is accounting bank account. TODO We should use a cache here to avoid this fetch |
|
| 657 | - $account_label = $accountingaccount->label; |
|
| 658 | - |
|
| 659 | - $reflabel = ''; |
|
| 660 | - if (!empty($val['lib'])) { |
|
| 661 | - $reflabel .= dol_string_nohtmltag($val['lib'])." - "; |
|
| 662 | - } |
|
| 663 | - $reflabel .= $langs->trans("Bank").' '.dol_string_nohtmltag($val['bank_account_ref']); |
|
| 664 | - if (!empty($val['soclib'])) { |
|
| 665 | - $reflabel .= " - ".dol_string_nohtmltag($val['soclib']); |
|
| 666 | - } |
|
| 667 | - |
|
| 668 | - $bookkeeping = new BookKeeping($db); |
|
| 669 | - $bookkeeping->doc_date = $val["date"]; |
|
| 670 | - $bookkeeping->doc_ref = $ref; |
|
| 671 | - $bookkeeping->doc_type = 'bank'; |
|
| 672 | - $bookkeeping->fk_doc = $key; |
|
| 673 | - $bookkeeping->fk_docdet = $val["fk_bank"]; |
|
| 674 | - |
|
| 675 | - $bookkeeping->numero_compte = $k; |
|
| 676 | - $bookkeeping->label_compte = $account_label; |
|
| 677 | - |
|
| 678 | - $bookkeeping->label_operation = $reflabel; |
|
| 679 | - $bookkeeping->montant = $mt; |
|
| 680 | - $bookkeeping->sens = ($mt >= 0) ? 'D' : 'C'; |
|
| 681 | - $bookkeeping->debit = ($mt >= 0 ? $mt : 0); |
|
| 682 | - $bookkeeping->credit = ($mt < 0 ? -$mt : 0); |
|
| 683 | - $bookkeeping->code_journal = $journal; |
|
| 684 | - $bookkeeping->journal_label = $langs->transnoentities($journal_label); |
|
| 685 | - $bookkeeping->fk_user_author = $user->id; |
|
| 686 | - $bookkeeping->date_creation = $now; |
|
| 687 | - |
|
| 688 | - // No subledger_account value for the bank line but add a specific label_operation |
|
| 689 | - $bookkeeping->subledger_account = ''; |
|
| 690 | - $bookkeeping->label_operation = $reflabel; |
|
| 691 | - $bookkeeping->entity = $conf->entity; |
|
| 692 | - |
|
| 693 | - $totaldebit += $bookkeeping->debit; |
|
| 694 | - $totalcredit += $bookkeeping->credit; |
|
| 695 | - |
|
| 696 | - $result = $bookkeeping->create($user); |
|
| 697 | - if ($result < 0) { |
|
| 698 | - if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') { // Already exists |
|
| 699 | - $error++; |
|
| 700 | - $errorforline++; |
|
| 701 | - setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings'); |
|
| 702 | - } else { |
|
| 703 | - $error++; |
|
| 704 | - $errorforline++; |
|
| 705 | - setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors'); |
|
| 706 | - } |
|
| 707 | - } |
|
| 708 | - } |
|
| 709 | - } |
|
| 710 | - } |
|
| 711 | - |
|
| 712 | - // Third party |
|
| 713 | - if (!$errorforline) { |
|
| 714 | - if (is_array($tabtp[$key])) { |
|
| 715 | - // Line into thirdparty account |
|
| 716 | - foreach ($tabtp[$key] as $k => $mt) { |
|
| 717 | - if ($mt) { |
|
| 718 | - $lettering = false; |
|
| 719 | - |
|
| 720 | - $reflabel = ''; |
|
| 721 | - if (!empty($val['lib'])) { |
|
| 722 | - $reflabel .= dol_string_nohtmltag($val['lib']).($val['soclib'] ? " - " : ""); |
|
| 723 | - } |
|
| 724 | - if ($tabtype[$key] == 'banktransfert') { |
|
| 725 | - $reflabel .= dol_string_nohtmltag($langs->transnoentitiesnoconv('TransitionalAccount').' '.$account_transfer); |
|
| 726 | - } else { |
|
| 727 | - $reflabel .= dol_string_nohtmltag($val['soclib']); |
|
| 728 | - } |
|
| 619 | + $now = dol_now(); |
|
| 620 | + |
|
| 621 | + $accountingaccountcustomer = new AccountingAccount($db); |
|
| 622 | + $accountingaccountcustomer->fetch(null, getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER'), true); |
|
| 623 | + |
|
| 624 | + $accountingaccountsupplier = new AccountingAccount($db); |
|
| 625 | + $accountingaccountsupplier->fetch(null, getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER'), true); |
|
| 626 | + |
|
| 627 | + $accountingaccountpayment = new AccountingAccount($db); |
|
| 628 | + $accountingaccountpayment->fetch(null, getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT'), true); |
|
| 629 | + |
|
| 630 | + $accountingaccountsuspense = new AccountingAccount($db); |
|
| 631 | + $accountingaccountsuspense->fetch(null, getDolGlobalString('ACCOUNTING_ACCOUNT_SUSPENSE'), true); |
|
| 632 | + |
|
| 633 | + $error = 0; |
|
| 634 | + foreach ($tabpay as $key => $val) { // $key is rowid into llx_bank |
|
| 635 | + $date = dol_print_date($val["date"], 'day'); |
|
| 636 | + |
|
| 637 | + $ref = getSourceDocRef($val, $tabtype[$key]); |
|
| 638 | + |
|
| 639 | + $errorforline = 0; |
|
| 640 | + |
|
| 641 | + $totalcredit = 0; |
|
| 642 | + $totaldebit = 0; |
|
| 643 | + |
|
| 644 | + $db->begin(); |
|
| 645 | + |
|
| 646 | + // Introduce a protection. Total of tabtp must be total of tabbq |
|
| 647 | + //var_dump($tabpay); |
|
| 648 | + //var_dump($tabtp); |
|
| 649 | + //var_dump($tabbq);exit; |
|
| 650 | + |
|
| 651 | + // Bank |
|
| 652 | + if (!$errorforline && is_array($tabbq[$key])) { |
|
| 653 | + // Line into bank account |
|
| 654 | + foreach ($tabbq[$key] as $k => $mt) { |
|
| 655 | + if ($mt) { |
|
| 656 | + $accountingaccount->fetch(null, $k, true); // $k is accounting bank account. TODO We should use a cache here to avoid this fetch |
|
| 657 | + $account_label = $accountingaccount->label; |
|
| 658 | + |
|
| 659 | + $reflabel = ''; |
|
| 660 | + if (!empty($val['lib'])) { |
|
| 661 | + $reflabel .= dol_string_nohtmltag($val['lib'])." - "; |
|
| 662 | + } |
|
| 663 | + $reflabel .= $langs->trans("Bank").' '.dol_string_nohtmltag($val['bank_account_ref']); |
|
| 664 | + if (!empty($val['soclib'])) { |
|
| 665 | + $reflabel .= " - ".dol_string_nohtmltag($val['soclib']); |
|
| 666 | + } |
|
| 667 | + |
|
| 668 | + $bookkeeping = new BookKeeping($db); |
|
| 669 | + $bookkeeping->doc_date = $val["date"]; |
|
| 670 | + $bookkeeping->doc_ref = $ref; |
|
| 671 | + $bookkeeping->doc_type = 'bank'; |
|
| 672 | + $bookkeeping->fk_doc = $key; |
|
| 673 | + $bookkeeping->fk_docdet = $val["fk_bank"]; |
|
| 674 | + |
|
| 675 | + $bookkeeping->numero_compte = $k; |
|
| 676 | + $bookkeeping->label_compte = $account_label; |
|
| 677 | + |
|
| 678 | + $bookkeeping->label_operation = $reflabel; |
|
| 679 | + $bookkeeping->montant = $mt; |
|
| 680 | + $bookkeeping->sens = ($mt >= 0) ? 'D' : 'C'; |
|
| 681 | + $bookkeeping->debit = ($mt >= 0 ? $mt : 0); |
|
| 682 | + $bookkeeping->credit = ($mt < 0 ? -$mt : 0); |
|
| 683 | + $bookkeeping->code_journal = $journal; |
|
| 684 | + $bookkeeping->journal_label = $langs->transnoentities($journal_label); |
|
| 685 | + $bookkeeping->fk_user_author = $user->id; |
|
| 686 | + $bookkeeping->date_creation = $now; |
|
| 687 | + |
|
| 688 | + // No subledger_account value for the bank line but add a specific label_operation |
|
| 689 | + $bookkeeping->subledger_account = ''; |
|
| 690 | + $bookkeeping->label_operation = $reflabel; |
|
| 691 | + $bookkeeping->entity = $conf->entity; |
|
| 692 | + |
|
| 693 | + $totaldebit += $bookkeeping->debit; |
|
| 694 | + $totalcredit += $bookkeeping->credit; |
|
| 695 | + |
|
| 696 | + $result = $bookkeeping->create($user); |
|
| 697 | + if ($result < 0) { |
|
| 698 | + if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') { // Already exists |
|
| 699 | + $error++; |
|
| 700 | + $errorforline++; |
|
| 701 | + setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings'); |
|
| 702 | + } else { |
|
| 703 | + $error++; |
|
| 704 | + $errorforline++; |
|
| 705 | + setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors'); |
|
| 706 | + } |
|
| 707 | + } |
|
| 708 | + } |
|
| 709 | + } |
|
| 710 | + } |
|
| 729 | 711 | |
| 730 | - $bookkeeping = new BookKeeping($db); |
|
| 731 | - $bookkeeping->doc_date = $val["date"]; |
|
| 732 | - $bookkeeping->doc_ref = $ref; |
|
| 733 | - $bookkeeping->doc_type = 'bank'; |
|
| 734 | - $bookkeeping->fk_doc = $key; |
|
| 735 | - $bookkeeping->fk_docdet = $val["fk_bank"]; |
|
| 736 | - |
|
| 737 | - $bookkeeping->label_operation = $reflabel; |
|
| 738 | - $bookkeeping->montant = $mt; |
|
| 739 | - $bookkeeping->sens = ($mt < 0) ? 'D' : 'C'; |
|
| 740 | - $bookkeeping->debit = ($mt < 0 ? -$mt : 0); |
|
| 741 | - $bookkeeping->credit = ($mt >= 0) ? $mt : 0; |
|
| 742 | - $bookkeeping->code_journal = $journal; |
|
| 743 | - $bookkeeping->journal_label = $langs->transnoentities($journal_label); |
|
| 744 | - $bookkeeping->fk_user_author = $user->id; |
|
| 745 | - $bookkeeping->date_creation = $now; |
|
| 746 | - |
|
| 747 | - if ($tabtype[$key] == 'payment') { // If payment is payment of customer invoice, we get ref of invoice |
|
| 748 | - $lettering = true; |
|
| 749 | - $bookkeeping->subledger_account = $k; // For payment, the subledger account is stored as $key of $tabtp |
|
| 750 | - $bookkeeping->subledger_label = $tabcompany[$key]['name']; // $tabcompany is defined only if we are sure there is 1 thirdparty for the bank transaction |
|
| 751 | - $bookkeeping->numero_compte = getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER'); |
|
| 752 | - $bookkeeping->label_compte = $accountingaccountcustomer->label; |
|
| 753 | - } elseif ($tabtype[$key] == 'payment_supplier') { // If payment is payment of supplier invoice, we get ref of invoice |
|
| 754 | - $lettering = true; |
|
| 755 | - $bookkeeping->subledger_account = $k; // For payment, the subledger account is stored as $key of $tabtp |
|
| 756 | - $bookkeeping->subledger_label = $tabcompany[$key]['name']; // $tabcompany is defined only if we are sure there is 1 thirdparty for the bank transaction |
|
| 757 | - $bookkeeping->numero_compte = getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER'); |
|
| 758 | - $bookkeeping->label_compte = $accountingaccountsupplier->label; |
|
| 759 | - } elseif ($tabtype[$key] == 'payment_expensereport') { |
|
| 760 | - $bookkeeping->subledger_account = $tabuser[$key]['accountancy_code']; |
|
| 761 | - $bookkeeping->subledger_label = $tabuser[$key]['name']; |
|
| 762 | - $bookkeeping->numero_compte = getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT'); |
|
| 763 | - $bookkeeping->label_compte = $accountingaccountpayment->label; |
|
| 764 | - } elseif ($tabtype[$key] == 'payment_salary') { |
|
| 765 | - $bookkeeping->subledger_account = $tabuser[$key]['accountancy_code']; |
|
| 766 | - $bookkeeping->subledger_label = $tabuser[$key]['name']; |
|
| 767 | - $bookkeeping->numero_compte = getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT'); |
|
| 768 | - $bookkeeping->label_compte = $accountingaccountpayment->label; |
|
| 769 | - } elseif (in_array($tabtype[$key], array('sc', 'payment_sc'))) { // If payment is payment of social contribution |
|
| 770 | - $bookkeeping->subledger_account = ''; |
|
| 771 | - $bookkeeping->subledger_label = ''; |
|
| 772 | - $accountingaccount->fetch(null, $k, true); // TODO Use a cache |
|
| 773 | - $bookkeeping->numero_compte = $k; |
|
| 774 | - $bookkeeping->label_compte = $accountingaccount->label; |
|
| 775 | - } elseif ($tabtype[$key] == 'payment_vat') { |
|
| 776 | - $bookkeeping->subledger_account = ''; |
|
| 777 | - $bookkeeping->subledger_label = ''; |
|
| 778 | - $accountingaccount->fetch(null, $k, true); // TODO Use a cache |
|
| 779 | - $bookkeeping->numero_compte = $k; |
|
| 780 | - $bookkeeping->label_compte = $accountingaccount->label; |
|
| 781 | - } elseif ($tabtype[$key] == 'payment_donation') { |
|
| 782 | - $bookkeeping->subledger_account = ''; |
|
| 783 | - $bookkeeping->subledger_label = ''; |
|
| 784 | - $accountingaccount->fetch(null, $k, true); // TODO Use a cache |
|
| 785 | - $bookkeeping->numero_compte = $k; |
|
| 786 | - $bookkeeping->label_compte = $accountingaccount->label; |
|
| 787 | - } elseif ($tabtype[$key] == 'member') { |
|
| 788 | - $bookkeeping->subledger_account = ''; |
|
| 789 | - $bookkeeping->subledger_label = ''; |
|
| 790 | - $accountingaccount->fetch(null, $k, true); // TODO Use a cache |
|
| 791 | - $bookkeeping->numero_compte = $k; |
|
| 792 | - $bookkeeping->label_compte = $accountingaccount->label; |
|
| 793 | - } elseif ($tabtype[$key] == 'payment_loan') { |
|
| 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_various') { |
|
| 800 | - $bookkeeping->subledger_account = $k; |
|
| 801 | - $bookkeeping->subledger_label = $tabcompany[$key]['name']; |
|
| 802 | - $accountingaccount->fetch(null, $tabpay[$key]["account_various"], true); // TODO Use a cache |
|
| 803 | - $bookkeeping->numero_compte = $tabpay[$key]["account_various"]; |
|
| 804 | - $bookkeeping->label_compte = $accountingaccount->label; |
|
| 805 | - } elseif ($tabtype[$key] == 'banktransfert') { |
|
| 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 | - } else { |
|
| 812 | - if ($tabtype[$key] == 'unknown') { // Unknown transaction, we will use a waiting account for thirdparty. |
|
| 813 | - // Temporary account |
|
| 814 | - $bookkeeping->subledger_account = ''; |
|
| 815 | - $bookkeeping->subledger_label = ''; |
|
| 816 | - $bookkeeping->numero_compte = getDolGlobalString('ACCOUNTING_ACCOUNT_SUSPENSE'); |
|
| 817 | - $bookkeeping->label_compte = $accountingaccountsuspense->label; |
|
| 818 | - } |
|
| 819 | - } |
|
| 820 | - $bookkeeping->label_operation = $reflabel; |
|
| 821 | - $bookkeeping->entity = $conf->entity; |
|
| 822 | - |
|
| 823 | - $totaldebit += $bookkeeping->debit; |
|
| 824 | - $totalcredit += $bookkeeping->credit; |
|
| 825 | - |
|
| 826 | - $result = $bookkeeping->create($user); |
|
| 827 | - if ($result < 0) { |
|
| 828 | - if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') { // Already exists |
|
| 829 | - $error++; |
|
| 830 | - $errorforline++; |
|
| 831 | - setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings'); |
|
| 832 | - } else { |
|
| 833 | - $error++; |
|
| 834 | - $errorforline++; |
|
| 835 | - setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors'); |
|
| 836 | - } |
|
| 837 | - } else { |
|
| 838 | - if ($lettering && getDolGlobalInt('ACCOUNTING_ENABLE_LETTERING') && getDolGlobalInt('ACCOUNTING_ENABLE_AUTOLETTERING')) { |
|
| 839 | - require_once DOL_DOCUMENT_ROOT . '/accountancy/class/lettering.class.php'; |
|
| 840 | - $lettering_static = new Lettering($db); |
|
| 841 | - $nb_lettering = $lettering_static->bookkeepingLetteringAll(array($bookkeeping->id)); |
|
| 842 | - } |
|
| 843 | - } |
|
| 844 | - } |
|
| 845 | - } |
|
| 846 | - } else { // If thirdparty unknown, output the waiting account |
|
| 847 | - foreach ($tabbq[$key] as $k => $mt) { |
|
| 848 | - if ($mt) { |
|
| 849 | - $reflabel = ''; |
|
| 850 | - if (!empty($val['lib'])) { |
|
| 851 | - $reflabel .= dol_string_nohtmltag($val['lib'])." - "; |
|
| 852 | - } |
|
| 853 | - $reflabel .= dol_string_nohtmltag('WaitingAccount'); |
|
| 854 | - |
|
| 855 | - $bookkeeping = new BookKeeping($db); |
|
| 856 | - $bookkeeping->doc_date = $val["date"]; |
|
| 857 | - $bookkeeping->doc_ref = $ref; |
|
| 858 | - $bookkeeping->doc_type = 'bank'; |
|
| 859 | - $bookkeeping->fk_doc = $key; |
|
| 860 | - $bookkeeping->fk_docdet = $val["fk_bank"]; |
|
| 861 | - $bookkeeping->montant = $mt; |
|
| 862 | - $bookkeeping->sens = ($mt < 0) ? 'D' : 'C'; |
|
| 863 | - $bookkeeping->debit = ($mt < 0 ? -$mt : 0); |
|
| 864 | - $bookkeeping->credit = ($mt >= 0) ? $mt : 0; |
|
| 865 | - $bookkeeping->code_journal = $journal; |
|
| 866 | - $bookkeeping->journal_label = $langs->transnoentities($journal_label); |
|
| 867 | - $bookkeeping->fk_user_author = $user->id; |
|
| 868 | - $bookkeeping->date_creation = $now; |
|
| 869 | - $bookkeeping->label_compte = ''; |
|
| 870 | - $bookkeeping->label_operation = $reflabel; |
|
| 871 | - $bookkeeping->entity = $conf->entity; |
|
| 872 | - |
|
| 873 | - $totaldebit += $bookkeeping->debit; |
|
| 874 | - $totalcredit += $bookkeeping->credit; |
|
| 875 | - |
|
| 876 | - $result = $bookkeeping->create($user); |
|
| 877 | - |
|
| 878 | - if ($result < 0) { |
|
| 879 | - if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') { // Already exists |
|
| 880 | - $error++; |
|
| 881 | - $errorforline++; |
|
| 882 | - setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings'); |
|
| 883 | - } else { |
|
| 884 | - $error++; |
|
| 885 | - $errorforline++; |
|
| 886 | - setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors'); |
|
| 887 | - } |
|
| 888 | - } |
|
| 889 | - } |
|
| 890 | - } |
|
| 891 | - } |
|
| 892 | - } |
|
| 712 | + // Third party |
|
| 713 | + if (!$errorforline) { |
|
| 714 | + if (is_array($tabtp[$key])) { |
|
| 715 | + // Line into thirdparty account |
|
| 716 | + foreach ($tabtp[$key] as $k => $mt) { |
|
| 717 | + if ($mt) { |
|
| 718 | + $lettering = false; |
|
| 719 | + |
|
| 720 | + $reflabel = ''; |
|
| 721 | + if (!empty($val['lib'])) { |
|
| 722 | + $reflabel .= dol_string_nohtmltag($val['lib']).($val['soclib'] ? " - " : ""); |
|
| 723 | + } |
|
| 724 | + if ($tabtype[$key] == 'banktransfert') { |
|
| 725 | + $reflabel .= dol_string_nohtmltag($langs->transnoentitiesnoconv('TransitionalAccount').' '.$account_transfer); |
|
| 726 | + } else { |
|
| 727 | + $reflabel .= dol_string_nohtmltag($val['soclib']); |
|
| 728 | + } |
|
| 729 | + |
|
| 730 | + $bookkeeping = new BookKeeping($db); |
|
| 731 | + $bookkeeping->doc_date = $val["date"]; |
|
| 732 | + $bookkeeping->doc_ref = $ref; |
|
| 733 | + $bookkeeping->doc_type = 'bank'; |
|
| 734 | + $bookkeeping->fk_doc = $key; |
|
| 735 | + $bookkeeping->fk_docdet = $val["fk_bank"]; |
|
| 736 | + |
|
| 737 | + $bookkeeping->label_operation = $reflabel; |
|
| 738 | + $bookkeeping->montant = $mt; |
|
| 739 | + $bookkeeping->sens = ($mt < 0) ? 'D' : 'C'; |
|
| 740 | + $bookkeeping->debit = ($mt < 0 ? -$mt : 0); |
|
| 741 | + $bookkeeping->credit = ($mt >= 0) ? $mt : 0; |
|
| 742 | + $bookkeeping->code_journal = $journal; |
|
| 743 | + $bookkeeping->journal_label = $langs->transnoentities($journal_label); |
|
| 744 | + $bookkeeping->fk_user_author = $user->id; |
|
| 745 | + $bookkeeping->date_creation = $now; |
|
| 746 | + |
|
| 747 | + if ($tabtype[$key] == 'payment') { // If payment is payment of customer invoice, we get ref of invoice |
|
| 748 | + $lettering = true; |
|
| 749 | + $bookkeeping->subledger_account = $k; // For payment, the subledger account is stored as $key of $tabtp |
|
| 750 | + $bookkeeping->subledger_label = $tabcompany[$key]['name']; // $tabcompany is defined only if we are sure there is 1 thirdparty for the bank transaction |
|
| 751 | + $bookkeeping->numero_compte = getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER'); |
|
| 752 | + $bookkeeping->label_compte = $accountingaccountcustomer->label; |
|
| 753 | + } elseif ($tabtype[$key] == 'payment_supplier') { // If payment is payment of supplier invoice, we get ref of invoice |
|
| 754 | + $lettering = true; |
|
| 755 | + $bookkeeping->subledger_account = $k; // For payment, the subledger account is stored as $key of $tabtp |
|
| 756 | + $bookkeeping->subledger_label = $tabcompany[$key]['name']; // $tabcompany is defined only if we are sure there is 1 thirdparty for the bank transaction |
|
| 757 | + $bookkeeping->numero_compte = getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER'); |
|
| 758 | + $bookkeeping->label_compte = $accountingaccountsupplier->label; |
|
| 759 | + } elseif ($tabtype[$key] == 'payment_expensereport') { |
|
| 760 | + $bookkeeping->subledger_account = $tabuser[$key]['accountancy_code']; |
|
| 761 | + $bookkeeping->subledger_label = $tabuser[$key]['name']; |
|
| 762 | + $bookkeeping->numero_compte = getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT'); |
|
| 763 | + $bookkeeping->label_compte = $accountingaccountpayment->label; |
|
| 764 | + } elseif ($tabtype[$key] == 'payment_salary') { |
|
| 765 | + $bookkeeping->subledger_account = $tabuser[$key]['accountancy_code']; |
|
| 766 | + $bookkeeping->subledger_label = $tabuser[$key]['name']; |
|
| 767 | + $bookkeeping->numero_compte = getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT'); |
|
| 768 | + $bookkeeping->label_compte = $accountingaccountpayment->label; |
|
| 769 | + } elseif (in_array($tabtype[$key], array('sc', 'payment_sc'))) { // If payment is payment of social contribution |
|
| 770 | + $bookkeeping->subledger_account = ''; |
|
| 771 | + $bookkeeping->subledger_label = ''; |
|
| 772 | + $accountingaccount->fetch(null, $k, true); // TODO Use a cache |
|
| 773 | + $bookkeeping->numero_compte = $k; |
|
| 774 | + $bookkeeping->label_compte = $accountingaccount->label; |
|
| 775 | + } elseif ($tabtype[$key] == 'payment_vat') { |
|
| 776 | + $bookkeeping->subledger_account = ''; |
|
| 777 | + $bookkeeping->subledger_label = ''; |
|
| 778 | + $accountingaccount->fetch(null, $k, true); // TODO Use a cache |
|
| 779 | + $bookkeeping->numero_compte = $k; |
|
| 780 | + $bookkeeping->label_compte = $accountingaccount->label; |
|
| 781 | + } elseif ($tabtype[$key] == 'payment_donation') { |
|
| 782 | + $bookkeeping->subledger_account = ''; |
|
| 783 | + $bookkeeping->subledger_label = ''; |
|
| 784 | + $accountingaccount->fetch(null, $k, true); // TODO Use a cache |
|
| 785 | + $bookkeeping->numero_compte = $k; |
|
| 786 | + $bookkeeping->label_compte = $accountingaccount->label; |
|
| 787 | + } elseif ($tabtype[$key] == 'member') { |
|
| 788 | + $bookkeeping->subledger_account = ''; |
|
| 789 | + $bookkeeping->subledger_label = ''; |
|
| 790 | + $accountingaccount->fetch(null, $k, true); // TODO Use a cache |
|
| 791 | + $bookkeeping->numero_compte = $k; |
|
| 792 | + $bookkeeping->label_compte = $accountingaccount->label; |
|
| 793 | + } elseif ($tabtype[$key] == 'payment_loan') { |
|
| 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_various') { |
|
| 800 | + $bookkeeping->subledger_account = $k; |
|
| 801 | + $bookkeeping->subledger_label = $tabcompany[$key]['name']; |
|
| 802 | + $accountingaccount->fetch(null, $tabpay[$key]["account_various"], true); // TODO Use a cache |
|
| 803 | + $bookkeeping->numero_compte = $tabpay[$key]["account_various"]; |
|
| 804 | + $bookkeeping->label_compte = $accountingaccount->label; |
|
| 805 | + } elseif ($tabtype[$key] == 'banktransfert') { |
|
| 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 | + } else { |
|
| 812 | + if ($tabtype[$key] == 'unknown') { // Unknown transaction, we will use a waiting account for thirdparty. |
|
| 813 | + // Temporary account |
|
| 814 | + $bookkeeping->subledger_account = ''; |
|
| 815 | + $bookkeeping->subledger_label = ''; |
|
| 816 | + $bookkeeping->numero_compte = getDolGlobalString('ACCOUNTING_ACCOUNT_SUSPENSE'); |
|
| 817 | + $bookkeeping->label_compte = $accountingaccountsuspense->label; |
|
| 818 | + } |
|
| 819 | + } |
|
| 820 | + $bookkeeping->label_operation = $reflabel; |
|
| 821 | + $bookkeeping->entity = $conf->entity; |
|
| 822 | + |
|
| 823 | + $totaldebit += $bookkeeping->debit; |
|
| 824 | + $totalcredit += $bookkeeping->credit; |
|
| 825 | + |
|
| 826 | + $result = $bookkeeping->create($user); |
|
| 827 | + if ($result < 0) { |
|
| 828 | + if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') { // Already exists |
|
| 829 | + $error++; |
|
| 830 | + $errorforline++; |
|
| 831 | + setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings'); |
|
| 832 | + } else { |
|
| 833 | + $error++; |
|
| 834 | + $errorforline++; |
|
| 835 | + setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors'); |
|
| 836 | + } |
|
| 837 | + } else { |
|
| 838 | + if ($lettering && getDolGlobalInt('ACCOUNTING_ENABLE_LETTERING') && getDolGlobalInt('ACCOUNTING_ENABLE_AUTOLETTERING')) { |
|
| 839 | + require_once DOL_DOCUMENT_ROOT . '/accountancy/class/lettering.class.php'; |
|
| 840 | + $lettering_static = new Lettering($db); |
|
| 841 | + $nb_lettering = $lettering_static->bookkeepingLetteringAll(array($bookkeeping->id)); |
|
| 842 | + } |
|
| 843 | + } |
|
| 844 | + } |
|
| 845 | + } |
|
| 846 | + } else { // If thirdparty unknown, output the waiting account |
|
| 847 | + foreach ($tabbq[$key] as $k => $mt) { |
|
| 848 | + if ($mt) { |
|
| 849 | + $reflabel = ''; |
|
| 850 | + if (!empty($val['lib'])) { |
|
| 851 | + $reflabel .= dol_string_nohtmltag($val['lib'])." - "; |
|
| 852 | + } |
|
| 853 | + $reflabel .= dol_string_nohtmltag('WaitingAccount'); |
|
| 854 | + |
|
| 855 | + $bookkeeping = new BookKeeping($db); |
|
| 856 | + $bookkeeping->doc_date = $val["date"]; |
|
| 857 | + $bookkeeping->doc_ref = $ref; |
|
| 858 | + $bookkeeping->doc_type = 'bank'; |
|
| 859 | + $bookkeeping->fk_doc = $key; |
|
| 860 | + $bookkeeping->fk_docdet = $val["fk_bank"]; |
|
| 861 | + $bookkeeping->montant = $mt; |
|
| 862 | + $bookkeeping->sens = ($mt < 0) ? 'D' : 'C'; |
|
| 863 | + $bookkeeping->debit = ($mt < 0 ? -$mt : 0); |
|
| 864 | + $bookkeeping->credit = ($mt >= 0) ? $mt : 0; |
|
| 865 | + $bookkeeping->code_journal = $journal; |
|
| 866 | + $bookkeeping->journal_label = $langs->transnoentities($journal_label); |
|
| 867 | + $bookkeeping->fk_user_author = $user->id; |
|
| 868 | + $bookkeeping->date_creation = $now; |
|
| 869 | + $bookkeeping->label_compte = ''; |
|
| 870 | + $bookkeeping->label_operation = $reflabel; |
|
| 871 | + $bookkeeping->entity = $conf->entity; |
|
| 872 | + |
|
| 873 | + $totaldebit += $bookkeeping->debit; |
|
| 874 | + $totalcredit += $bookkeeping->credit; |
|
| 875 | + |
|
| 876 | + $result = $bookkeeping->create($user); |
|
| 877 | + |
|
| 878 | + if ($result < 0) { |
|
| 879 | + if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') { // Already exists |
|
| 880 | + $error++; |
|
| 881 | + $errorforline++; |
|
| 882 | + setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings'); |
|
| 883 | + } else { |
|
| 884 | + $error++; |
|
| 885 | + $errorforline++; |
|
| 886 | + setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors'); |
|
| 887 | + } |
|
| 888 | + } |
|
| 889 | + } |
|
| 890 | + } |
|
| 891 | + } |
|
| 892 | + } |
|
| 893 | 893 | |
| 894 | - if (price2num($totaldebit, 'MT') != price2num($totalcredit, 'MT')) { |
|
| 895 | - $error++; |
|
| 896 | - $errorforline++; |
|
| 897 | - setEventMessages('We tried to insert a non balanced transaction in book for '.$ref.'. Canceled. Surely a bug.', null, 'errors'); |
|
| 898 | - } |
|
| 894 | + if (price2num($totaldebit, 'MT') != price2num($totalcredit, 'MT')) { |
|
| 895 | + $error++; |
|
| 896 | + $errorforline++; |
|
| 897 | + setEventMessages('We tried to insert a non balanced transaction in book for '.$ref.'. Canceled. Surely a bug.', null, 'errors'); |
|
| 898 | + } |
|
| 899 | 899 | |
| 900 | - if (!$errorforline) { |
|
| 901 | - $db->commit(); |
|
| 902 | - } else { |
|
| 903 | - //print 'KO for line '.$key.' '.$error.'<br>'; |
|
| 904 | - $db->rollback(); |
|
| 900 | + if (!$errorforline) { |
|
| 901 | + $db->commit(); |
|
| 902 | + } else { |
|
| 903 | + //print 'KO for line '.$key.' '.$error.'<br>'; |
|
| 904 | + $db->rollback(); |
|
| 905 | 905 | |
| 906 | - $MAXNBERRORS = 5; |
|
| 907 | - if ($error >= $MAXNBERRORS) { |
|
| 908 | - setEventMessages($langs->trans("ErrorTooManyErrorsProcessStopped").' (>'.$MAXNBERRORS.')', null, 'errors'); |
|
| 909 | - break; // Break in the foreach |
|
| 910 | - } |
|
| 911 | - } |
|
| 912 | - } |
|
| 913 | - |
|
| 914 | - if (empty($error) && count($tabpay) > 0) { |
|
| 915 | - setEventMessages($langs->trans("GeneralLedgerIsWritten"), null, 'mesgs'); |
|
| 916 | - } elseif (count($tabpay) == $error) { |
|
| 917 | - setEventMessages($langs->trans("NoNewRecordSaved"), null, 'warnings'); |
|
| 918 | - } else { |
|
| 919 | - setEventMessages($langs->trans("GeneralLedgerSomeRecordWasNotRecorded"), null, 'warnings'); |
|
| 920 | - } |
|
| 921 | - |
|
| 922 | - $action = ''; |
|
| 923 | - |
|
| 924 | - // Must reload data, so we make a redirect |
|
| 925 | - if (count($tabpay) != $error) { |
|
| 926 | - $param = 'id_journal='.$id_journal; |
|
| 927 | - $param .= '&date_startday='.$date_startday; |
|
| 928 | - $param .= '&date_startmonth='.$date_startmonth; |
|
| 929 | - $param .= '&date_startyear='.$date_startyear; |
|
| 930 | - $param .= '&date_endday='.$date_endday; |
|
| 931 | - $param .= '&date_endmonth='.$date_endmonth; |
|
| 932 | - $param .= '&date_endyear='.$date_endyear; |
|
| 933 | - $param .= '&in_bookkeeping='.$in_bookkeeping; |
|
| 934 | - header("Location: ".$_SERVER['PHP_SELF'].($param ? '?'.$param : '')); |
|
| 935 | - exit; |
|
| 936 | - } |
|
| 906 | + $MAXNBERRORS = 5; |
|
| 907 | + if ($error >= $MAXNBERRORS) { |
|
| 908 | + setEventMessages($langs->trans("ErrorTooManyErrorsProcessStopped").' (>'.$MAXNBERRORS.')', null, 'errors'); |
|
| 909 | + break; // Break in the foreach |
|
| 910 | + } |
|
| 911 | + } |
|
| 912 | + } |
|
| 913 | + |
|
| 914 | + if (empty($error) && count($tabpay) > 0) { |
|
| 915 | + setEventMessages($langs->trans("GeneralLedgerIsWritten"), null, 'mesgs'); |
|
| 916 | + } elseif (count($tabpay) == $error) { |
|
| 917 | + setEventMessages($langs->trans("NoNewRecordSaved"), null, 'warnings'); |
|
| 918 | + } else { |
|
| 919 | + setEventMessages($langs->trans("GeneralLedgerSomeRecordWasNotRecorded"), null, 'warnings'); |
|
| 920 | + } |
|
| 921 | + |
|
| 922 | + $action = ''; |
|
| 923 | + |
|
| 924 | + // Must reload data, so we make a redirect |
|
| 925 | + if (count($tabpay) != $error) { |
|
| 926 | + $param = 'id_journal='.$id_journal; |
|
| 927 | + $param .= '&date_startday='.$date_startday; |
|
| 928 | + $param .= '&date_startmonth='.$date_startmonth; |
|
| 929 | + $param .= '&date_startyear='.$date_startyear; |
|
| 930 | + $param .= '&date_endday='.$date_endday; |
|
| 931 | + $param .= '&date_endmonth='.$date_endmonth; |
|
| 932 | + $param .= '&date_endyear='.$date_endyear; |
|
| 933 | + $param .= '&in_bookkeeping='.$in_bookkeeping; |
|
| 934 | + header("Location: ".$_SERVER['PHP_SELF'].($param ? '?'.$param : '')); |
|
| 935 | + exit; |
|
| 936 | + } |
|
| 937 | 937 | } |
| 938 | 938 | |
| 939 | 939 | |
| 940 | 940 | |
| 941 | 941 | // Export |
| 942 | 942 | if ($action == 'exportcsv') { // ISO and not UTF8 ! |
| 943 | - $sep = getDolGlobalString('ACCOUNTING_EXPORT_SEPARATORCSV'); |
|
| 944 | - |
|
| 945 | - $filename = 'journal'; |
|
| 946 | - $type_export = 'journal'; |
|
| 947 | - include DOL_DOCUMENT_ROOT.'/accountancy/tpl/export_journal.tpl.php'; |
|
| 948 | - |
|
| 949 | - // CSV header line |
|
| 950 | - print '"'.$langs->transnoentitiesnoconv("BankId").'"'.$sep; |
|
| 951 | - print '"'.$langs->transnoentitiesnoconv("Date").'"'.$sep; |
|
| 952 | - print '"'.$langs->transnoentitiesnoconv("PaymentMode").'"'.$sep; |
|
| 953 | - print '"'.$langs->transnoentitiesnoconv("AccountAccounting").'"'.$sep; |
|
| 954 | - print '"'.$langs->transnoentitiesnoconv("LedgerAccount").'"'.$sep; |
|
| 955 | - print '"'.$langs->transnoentitiesnoconv("SubledgerAccount").'"'.$sep; |
|
| 956 | - print '"'.$langs->transnoentitiesnoconv("Label").'"'.$sep; |
|
| 957 | - print '"'.$langs->transnoentitiesnoconv("AccountingDebit").'"'.$sep; |
|
| 958 | - print '"'.$langs->transnoentitiesnoconv("AccountingCredit").'"'.$sep; |
|
| 959 | - print '"'.$langs->transnoentitiesnoconv("Journal").'"'.$sep; |
|
| 960 | - print '"'.$langs->transnoentitiesnoconv("Note").'"'.$sep; |
|
| 961 | - print "\n"; |
|
| 962 | - |
|
| 963 | - foreach ($tabpay as $key => $val) { |
|
| 964 | - $date = dol_print_date($val["date"], 'day'); |
|
| 965 | - |
|
| 966 | - $ref = getSourceDocRef($val, $tabtype[$key]); |
|
| 967 | - |
|
| 968 | - // Bank |
|
| 969 | - foreach ($tabbq[$key] as $k => $mt) { |
|
| 970 | - if ($mt) { |
|
| 971 | - $reflabel = ''; |
|
| 972 | - if (!empty($val['lib'])) { |
|
| 973 | - $reflabel .= dol_string_nohtmltag($val['lib'])." - "; |
|
| 974 | - } |
|
| 975 | - $reflabel .= $langs->trans("Bank").' '.dol_string_nohtmltag($val['bank_account_ref']); |
|
| 976 | - if (!empty($val['soclib'])) { |
|
| 977 | - $reflabel .= " - ".dol_string_nohtmltag($val['soclib']); |
|
| 978 | - } |
|
| 979 | - |
|
| 980 | - print '"'.$key.'"'.$sep; |
|
| 981 | - print '"'.$date.'"'.$sep; |
|
| 982 | - print '"'.$val["type_payment"].'"'.$sep; |
|
| 983 | - print '"'.length_accountg(html_entity_decode($k)).'"'.$sep; |
|
| 984 | - print '"'.length_accounta(html_entity_decode($k)).'"'.$sep; |
|
| 985 | - print " ".$sep; |
|
| 986 | - print '"'.$reflabel.'"'.$sep; |
|
| 987 | - print '"'.($mt >= 0 ? price($mt) : '').'"'.$sep; |
|
| 988 | - print '"'.($mt < 0 ? price(-$mt) : '').'"'.$sep; |
|
| 989 | - print '"'.$journal.'"'.$sep; |
|
| 990 | - print '"'.dol_string_nohtmltag($ref).'"'.$sep; |
|
| 991 | - print "\n"; |
|
| 992 | - } |
|
| 993 | - } |
|
| 943 | + $sep = getDolGlobalString('ACCOUNTING_EXPORT_SEPARATORCSV'); |
|
| 944 | + |
|
| 945 | + $filename = 'journal'; |
|
| 946 | + $type_export = 'journal'; |
|
| 947 | + include DOL_DOCUMENT_ROOT.'/accountancy/tpl/export_journal.tpl.php'; |
|
| 948 | + |
|
| 949 | + // CSV header line |
|
| 950 | + print '"'.$langs->transnoentitiesnoconv("BankId").'"'.$sep; |
|
| 951 | + print '"'.$langs->transnoentitiesnoconv("Date").'"'.$sep; |
|
| 952 | + print '"'.$langs->transnoentitiesnoconv("PaymentMode").'"'.$sep; |
|
| 953 | + print '"'.$langs->transnoentitiesnoconv("AccountAccounting").'"'.$sep; |
|
| 954 | + print '"'.$langs->transnoentitiesnoconv("LedgerAccount").'"'.$sep; |
|
| 955 | + print '"'.$langs->transnoentitiesnoconv("SubledgerAccount").'"'.$sep; |
|
| 956 | + print '"'.$langs->transnoentitiesnoconv("Label").'"'.$sep; |
|
| 957 | + print '"'.$langs->transnoentitiesnoconv("AccountingDebit").'"'.$sep; |
|
| 958 | + print '"'.$langs->transnoentitiesnoconv("AccountingCredit").'"'.$sep; |
|
| 959 | + print '"'.$langs->transnoentitiesnoconv("Journal").'"'.$sep; |
|
| 960 | + print '"'.$langs->transnoentitiesnoconv("Note").'"'.$sep; |
|
| 961 | + print "\n"; |
|
| 962 | + |
|
| 963 | + foreach ($tabpay as $key => $val) { |
|
| 964 | + $date = dol_print_date($val["date"], 'day'); |
|
| 965 | + |
|
| 966 | + $ref = getSourceDocRef($val, $tabtype[$key]); |
|
| 967 | + |
|
| 968 | + // Bank |
|
| 969 | + foreach ($tabbq[$key] as $k => $mt) { |
|
| 970 | + if ($mt) { |
|
| 971 | + $reflabel = ''; |
|
| 972 | + if (!empty($val['lib'])) { |
|
| 973 | + $reflabel .= dol_string_nohtmltag($val['lib'])." - "; |
|
| 974 | + } |
|
| 975 | + $reflabel .= $langs->trans("Bank").' '.dol_string_nohtmltag($val['bank_account_ref']); |
|
| 976 | + if (!empty($val['soclib'])) { |
|
| 977 | + $reflabel .= " - ".dol_string_nohtmltag($val['soclib']); |
|
| 978 | + } |
|
| 994 | 979 | |
| 995 | - // Third party |
|
| 996 | - if (is_array($tabtp[$key])) { |
|
| 997 | - foreach ($tabtp[$key] as $k => $mt) { |
|
| 998 | - if ($mt) { |
|
| 999 | - $reflabel = ''; |
|
| 1000 | - if (!empty($val['lib'])) { |
|
| 1001 | - $reflabel .= dol_string_nohtmltag($val['lib']).($val['soclib'] ? " - " : ""); |
|
| 1002 | - } |
|
| 1003 | - if ($tabtype[$key] == 'banktransfert') { |
|
| 1004 | - $reflabel .= dol_string_nohtmltag($langs->transnoentitiesnoconv('TransitionalAccount').' '.$account_transfer); |
|
| 1005 | - } else { |
|
| 1006 | - $reflabel .= dol_string_nohtmltag($val['soclib']); |
|
| 1007 | - } |
|
| 980 | + print '"'.$key.'"'.$sep; |
|
| 981 | + print '"'.$date.'"'.$sep; |
|
| 982 | + print '"'.$val["type_payment"].'"'.$sep; |
|
| 983 | + print '"'.length_accountg(html_entity_decode($k)).'"'.$sep; |
|
| 984 | + print '"'.length_accounta(html_entity_decode($k)).'"'.$sep; |
|
| 985 | + print " ".$sep; |
|
| 986 | + print '"'.$reflabel.'"'.$sep; |
|
| 987 | + print '"'.($mt >= 0 ? price($mt) : '').'"'.$sep; |
|
| 988 | + print '"'.($mt < 0 ? price(-$mt) : '').'"'.$sep; |
|
| 989 | + print '"'.$journal.'"'.$sep; |
|
| 990 | + print '"'.dol_string_nohtmltag($ref).'"'.$sep; |
|
| 991 | + print "\n"; |
|
| 992 | + } |
|
| 993 | + } |
|
| 1008 | 994 | |
| 1009 | - print '"'.$key.'"'.$sep; |
|
| 1010 | - print '"'.$date.'"'.$sep; |
|
| 1011 | - print '"'.$val["type_payment"].'"'.$sep; |
|
| 1012 | - print '"'.length_accountg(html_entity_decode($k)).'"'.$sep; |
|
| 1013 | - if ($tabtype[$key] == 'payment_supplier') { |
|
| 1014 | - print '"'.getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER').'"'.$sep; |
|
| 1015 | - } elseif ($tabtype[$key] == 'payment') { |
|
| 1016 | - print '"'.getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER').'"'.$sep; |
|
| 1017 | - } elseif ($tabtype[$key] == 'payment_expensereport') { |
|
| 1018 | - print '"'.getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT').'"'.$sep; |
|
| 1019 | - } elseif ($tabtype[$key] == 'payment_salary') { |
|
| 1020 | - print '"'.getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT').'"'.$sep; |
|
| 1021 | - } else { |
|
| 1022 | - print '"'.length_accountg(html_entity_decode($k)).'"'.$sep; |
|
| 1023 | - } |
|
| 1024 | - print '"'.length_accounta(html_entity_decode($k)).'"'.$sep; |
|
| 1025 | - print '"'.$reflabel.'"'.$sep; |
|
| 1026 | - print '"'.($mt < 0 ? price(-$mt) : '').'"'.$sep; |
|
| 1027 | - print '"'.($mt >= 0 ? price($mt) : '').'"'.$sep; |
|
| 1028 | - print '"'.$journal.'"'.$sep; |
|
| 1029 | - print '"'.dol_string_nohtmltag($ref).'"'.$sep; |
|
| 1030 | - print "\n"; |
|
| 1031 | - } |
|
| 1032 | - } |
|
| 1033 | - } else { // If thirdparty unknown, output the waiting account |
|
| 1034 | - foreach ($tabbq[$key] as $k => $mt) { |
|
| 1035 | - if ($mt) { |
|
| 1036 | - $reflabel = ''; |
|
| 1037 | - if (!empty($val['lib'])) { |
|
| 1038 | - $reflabel .= dol_string_nohtmltag($val['lib'])." - "; |
|
| 1039 | - } |
|
| 1040 | - $reflabel .= dol_string_nohtmltag('WaitingAccount'); |
|
| 1041 | - |
|
| 1042 | - print '"'.$key.'"'.$sep; |
|
| 1043 | - print '"'.$date.'"'.$sep; |
|
| 1044 | - print '"'.$val["type_payment"].'"'.$sep; |
|
| 1045 | - print '"'.length_accountg(getDolGlobalString('ACCOUNTING_ACCOUNT_SUSPENSE')).'"'.$sep; |
|
| 1046 | - print '"'.length_accounta(getDolGlobalString('ACCOUNTING_ACCOUNT_SUSPENSE')).'"'.$sep; |
|
| 1047 | - print $sep; |
|
| 1048 | - print '"'.$reflabel.'"'.$sep; |
|
| 1049 | - print '"'.($mt < 0 ? price(-$mt) : '').'"'.$sep; |
|
| 1050 | - print '"'.($mt >= 0 ? price($mt) : '').'"'.$sep; |
|
| 1051 | - print '"'.$journal.'"'.$sep; |
|
| 1052 | - print '"'.dol_string_nohtmltag($ref).'"'.$sep; |
|
| 1053 | - print "\n"; |
|
| 1054 | - } |
|
| 1055 | - } |
|
| 1056 | - } |
|
| 1057 | - } |
|
| 995 | + // Third party |
|
| 996 | + if (is_array($tabtp[$key])) { |
|
| 997 | + foreach ($tabtp[$key] as $k => $mt) { |
|
| 998 | + if ($mt) { |
|
| 999 | + $reflabel = ''; |
|
| 1000 | + if (!empty($val['lib'])) { |
|
| 1001 | + $reflabel .= dol_string_nohtmltag($val['lib']).($val['soclib'] ? " - " : ""); |
|
| 1002 | + } |
|
| 1003 | + if ($tabtype[$key] == 'banktransfert') { |
|
| 1004 | + $reflabel .= dol_string_nohtmltag($langs->transnoentitiesnoconv('TransitionalAccount').' '.$account_transfer); |
|
| 1005 | + } else { |
|
| 1006 | + $reflabel .= dol_string_nohtmltag($val['soclib']); |
|
| 1007 | + } |
|
| 1008 | + |
|
| 1009 | + print '"'.$key.'"'.$sep; |
|
| 1010 | + print '"'.$date.'"'.$sep; |
|
| 1011 | + print '"'.$val["type_payment"].'"'.$sep; |
|
| 1012 | + print '"'.length_accountg(html_entity_decode($k)).'"'.$sep; |
|
| 1013 | + if ($tabtype[$key] == 'payment_supplier') { |
|
| 1014 | + print '"'.getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER').'"'.$sep; |
|
| 1015 | + } elseif ($tabtype[$key] == 'payment') { |
|
| 1016 | + print '"'.getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER').'"'.$sep; |
|
| 1017 | + } elseif ($tabtype[$key] == 'payment_expensereport') { |
|
| 1018 | + print '"'.getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT').'"'.$sep; |
|
| 1019 | + } elseif ($tabtype[$key] == 'payment_salary') { |
|
| 1020 | + print '"'.getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT').'"'.$sep; |
|
| 1021 | + } else { |
|
| 1022 | + print '"'.length_accountg(html_entity_decode($k)).'"'.$sep; |
|
| 1023 | + } |
|
| 1024 | + print '"'.length_accounta(html_entity_decode($k)).'"'.$sep; |
|
| 1025 | + print '"'.$reflabel.'"'.$sep; |
|
| 1026 | + print '"'.($mt < 0 ? price(-$mt) : '').'"'.$sep; |
|
| 1027 | + print '"'.($mt >= 0 ? price($mt) : '').'"'.$sep; |
|
| 1028 | + print '"'.$journal.'"'.$sep; |
|
| 1029 | + print '"'.dol_string_nohtmltag($ref).'"'.$sep; |
|
| 1030 | + print "\n"; |
|
| 1031 | + } |
|
| 1032 | + } |
|
| 1033 | + } else { // If thirdparty unknown, output the waiting account |
|
| 1034 | + foreach ($tabbq[$key] as $k => $mt) { |
|
| 1035 | + if ($mt) { |
|
| 1036 | + $reflabel = ''; |
|
| 1037 | + if (!empty($val['lib'])) { |
|
| 1038 | + $reflabel .= dol_string_nohtmltag($val['lib'])." - "; |
|
| 1039 | + } |
|
| 1040 | + $reflabel .= dol_string_nohtmltag('WaitingAccount'); |
|
| 1041 | + |
|
| 1042 | + print '"'.$key.'"'.$sep; |
|
| 1043 | + print '"'.$date.'"'.$sep; |
|
| 1044 | + print '"'.$val["type_payment"].'"'.$sep; |
|
| 1045 | + print '"'.length_accountg(getDolGlobalString('ACCOUNTING_ACCOUNT_SUSPENSE')).'"'.$sep; |
|
| 1046 | + print '"'.length_accounta(getDolGlobalString('ACCOUNTING_ACCOUNT_SUSPENSE')).'"'.$sep; |
|
| 1047 | + print $sep; |
|
| 1048 | + print '"'.$reflabel.'"'.$sep; |
|
| 1049 | + print '"'.($mt < 0 ? price(-$mt) : '').'"'.$sep; |
|
| 1050 | + print '"'.($mt >= 0 ? price($mt) : '').'"'.$sep; |
|
| 1051 | + print '"'.$journal.'"'.$sep; |
|
| 1052 | + print '"'.dol_string_nohtmltag($ref).'"'.$sep; |
|
| 1053 | + print "\n"; |
|
| 1054 | + } |
|
| 1055 | + } |
|
| 1056 | + } |
|
| 1057 | + } |
|
| 1058 | 1058 | } |
| 1059 | 1059 | |
| 1060 | 1060 | |
@@ -1065,108 +1065,108 @@ discard block |
||
| 1065 | 1065 | $form = new Form($db); |
| 1066 | 1066 | |
| 1067 | 1067 | if (empty($action) || $action == 'view') { |
| 1068 | - $invoicestatic = new Facture($db); |
|
| 1069 | - $invoicesupplierstatic = new FactureFournisseur($db); |
|
| 1070 | - $expensereportstatic = new ExpenseReport($db); |
|
| 1071 | - $vatstatic = new Tva($db); |
|
| 1072 | - $donationstatic = new Don($db); |
|
| 1073 | - $loanstatic = new Loan($db); |
|
| 1074 | - $salarystatic = new Salary($db); |
|
| 1075 | - $variousstatic = new PaymentVarious($db); |
|
| 1076 | - |
|
| 1077 | - $title = $langs->trans("GenerationOfAccountingEntries").' - '.$accountingjournalstatic->getNomUrl(0, 2, 1, '', 1); |
|
| 1078 | - |
|
| 1079 | - llxHeader('', dol_string_nohtmltag($title)); |
|
| 1080 | - |
|
| 1081 | - $nom = $title; |
|
| 1082 | - $builddate = dol_now(); |
|
| 1083 | - //$description = $langs->trans("DescFinanceJournal") . '<br>'; |
|
| 1084 | - $description = $langs->trans("DescJournalOnlyBindedVisible").'<br>'; |
|
| 1085 | - |
|
| 1086 | - $listofchoices = array( |
|
| 1087 | - 'notyet' => $langs->trans("NotYetInGeneralLedger"), |
|
| 1088 | - 'already' => $langs->trans("AlreadyInGeneralLedger") |
|
| 1089 | - ); |
|
| 1090 | - $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); |
|
| 1091 | - $period .= ' - '.$langs->trans("JournalizationInLedgerStatus").' '.$form->selectarray('in_bookkeeping', $listofchoices, $in_bookkeeping, 1); |
|
| 1092 | - |
|
| 1093 | - $varlink = 'id_journal='.$id_journal; |
|
| 1094 | - $periodlink = ''; |
|
| 1095 | - $exportlink = ''; |
|
| 1096 | - |
|
| 1097 | - journalHead($nom, '', $period, $periodlink, $description, $builddate, $exportlink, array('action' => ''), '', $varlink); |
|
| 1098 | - |
|
| 1099 | - $desc = ''; |
|
| 1100 | - |
|
| 1101 | - if (getDolGlobalString('ACCOUNTANCY_FISCAL_PERIOD_MODE') != 'blockedonclosed') { |
|
| 1102 | - // Test that setup is complete (we are in accounting, so test on entity is always on $conf->entity only, no sharing allowed) |
|
| 1103 | - // Fiscal period test |
|
| 1104 | - $sql = "SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX."accounting_fiscalyear WHERE entity = ".((int) $conf->entity); |
|
| 1105 | - $resql = $db->query($sql); |
|
| 1106 | - if ($resql) { |
|
| 1107 | - $obj = $db->fetch_object($resql); |
|
| 1108 | - if ($obj->nb == 0) { |
|
| 1109 | - print '<br><div class="warning">'.img_warning().' '.$langs->trans("TheFiscalPeriodIsNotDefined"); |
|
| 1110 | - $desc = ' : '.$langs->trans("AccountancyAreaDescFiscalPeriod", 4, '{link}'); |
|
| 1111 | - $desc = str_replace('{link}', '<strong>'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("FiscalPeriod").'</strong>', $desc); |
|
| 1112 | - print $desc; |
|
| 1113 | - print '</div>'; |
|
| 1114 | - } |
|
| 1115 | - } else { |
|
| 1116 | - dol_print_error($db); |
|
| 1117 | - } |
|
| 1118 | - } |
|
| 1119 | - |
|
| 1120 | - // Bank test |
|
| 1121 | - $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"; |
|
| 1122 | - $resql = $db->query($sql); |
|
| 1123 | - if ($resql) { |
|
| 1124 | - $obj = $db->fetch_object($resql); |
|
| 1125 | - if ($obj->nb > 0) { |
|
| 1126 | - print '<br><div class="warning">'.img_warning().' '.$langs->trans("TheJournalCodeIsNotDefinedOnSomeBankAccount"); |
|
| 1127 | - $desc = ' : '.$langs->trans("AccountancyAreaDescBank", 6, '{link}'); |
|
| 1128 | - $desc = str_replace('{link}', '<strong>'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("BankAccounts").'</strong>', $desc); |
|
| 1129 | - print $desc; |
|
| 1130 | - print '</div>'; |
|
| 1131 | - } |
|
| 1132 | - } else { |
|
| 1133 | - dol_print_error($db); |
|
| 1134 | - } |
|
| 1135 | - |
|
| 1136 | - |
|
| 1137 | - // Button to write into Ledger |
|
| 1138 | - if (getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER') == "" || getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER') == '-1' |
|
| 1139 | - || getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER') == "" || getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER') == '-1' |
|
| 1140 | - || getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT') == "" || getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT') == '-1') { |
|
| 1141 | - print($desc ? '' : '<br>').'<div class="warning">'.img_warning().' '.$langs->trans("SomeMandatoryStepsOfSetupWereNotDone"); |
|
| 1142 | - $desc = ' : '.$langs->trans("AccountancyAreaDescMisc", 4, '{link}'); |
|
| 1143 | - $desc = str_replace('{link}', '<strong>'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("MenuDefaultAccounts").'</strong>', $desc); |
|
| 1144 | - print $desc; |
|
| 1145 | - print '</div>'; |
|
| 1146 | - } |
|
| 1147 | - |
|
| 1148 | - |
|
| 1149 | - print '<br><div class="tabsAction tabsActionNoBottom centerimp">'; |
|
| 1150 | - |
|
| 1151 | - if (getDolGlobalString('ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL') && $in_bookkeeping == 'notyet') { |
|
| 1152 | - print '<input type="button" class="butAction" name="exportcsv" value="'.$langs->trans("ExportDraftJournal").'" onclick="launch_export();" />'; |
|
| 1153 | - } |
|
| 1154 | - |
|
| 1155 | - if (getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER') == "" || getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER') == '-1' |
|
| 1156 | - || getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER') == "" || getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER') == '-1') { |
|
| 1157 | - print '<input type="button" class="butActionRefused classfortooltip" title="'.dol_escape_htmltag($langs->trans("SomeMandatoryStepsOfSetupWereNotDone")).'" value="'.$langs->trans("WriteBookKeeping").'" />'; |
|
| 1158 | - } else { |
|
| 1159 | - if ($in_bookkeeping == 'notyet') { |
|
| 1160 | - print '<input type="button" class="butAction" name="writebookkeeping" value="'.$langs->trans("WriteBookKeeping").'" onclick="writebookkeeping();" />'; |
|
| 1161 | - } else { |
|
| 1162 | - print '<a class="butActionRefused classfortooltip" name="writebookkeeping">'.$langs->trans("WriteBookKeeping").'</a>'; |
|
| 1163 | - } |
|
| 1164 | - } |
|
| 1068 | + $invoicestatic = new Facture($db); |
|
| 1069 | + $invoicesupplierstatic = new FactureFournisseur($db); |
|
| 1070 | + $expensereportstatic = new ExpenseReport($db); |
|
| 1071 | + $vatstatic = new Tva($db); |
|
| 1072 | + $donationstatic = new Don($db); |
|
| 1073 | + $loanstatic = new Loan($db); |
|
| 1074 | + $salarystatic = new Salary($db); |
|
| 1075 | + $variousstatic = new PaymentVarious($db); |
|
| 1076 | + |
|
| 1077 | + $title = $langs->trans("GenerationOfAccountingEntries").' - '.$accountingjournalstatic->getNomUrl(0, 2, 1, '', 1); |
|
| 1078 | + |
|
| 1079 | + llxHeader('', dol_string_nohtmltag($title)); |
|
| 1080 | + |
|
| 1081 | + $nom = $title; |
|
| 1082 | + $builddate = dol_now(); |
|
| 1083 | + //$description = $langs->trans("DescFinanceJournal") . '<br>'; |
|
| 1084 | + $description = $langs->trans("DescJournalOnlyBindedVisible").'<br>'; |
|
| 1085 | + |
|
| 1086 | + $listofchoices = array( |
|
| 1087 | + 'notyet' => $langs->trans("NotYetInGeneralLedger"), |
|
| 1088 | + 'already' => $langs->trans("AlreadyInGeneralLedger") |
|
| 1089 | + ); |
|
| 1090 | + $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); |
|
| 1091 | + $period .= ' - '.$langs->trans("JournalizationInLedgerStatus").' '.$form->selectarray('in_bookkeeping', $listofchoices, $in_bookkeeping, 1); |
|
| 1092 | + |
|
| 1093 | + $varlink = 'id_journal='.$id_journal; |
|
| 1094 | + $periodlink = ''; |
|
| 1095 | + $exportlink = ''; |
|
| 1096 | + |
|
| 1097 | + journalHead($nom, '', $period, $periodlink, $description, $builddate, $exportlink, array('action' => ''), '', $varlink); |
|
| 1098 | + |
|
| 1099 | + $desc = ''; |
|
| 1100 | + |
|
| 1101 | + if (getDolGlobalString('ACCOUNTANCY_FISCAL_PERIOD_MODE') != 'blockedonclosed') { |
|
| 1102 | + // Test that setup is complete (we are in accounting, so test on entity is always on $conf->entity only, no sharing allowed) |
|
| 1103 | + // Fiscal period test |
|
| 1104 | + $sql = "SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX."accounting_fiscalyear WHERE entity = ".((int) $conf->entity); |
|
| 1105 | + $resql = $db->query($sql); |
|
| 1106 | + if ($resql) { |
|
| 1107 | + $obj = $db->fetch_object($resql); |
|
| 1108 | + if ($obj->nb == 0) { |
|
| 1109 | + print '<br><div class="warning">'.img_warning().' '.$langs->trans("TheFiscalPeriodIsNotDefined"); |
|
| 1110 | + $desc = ' : '.$langs->trans("AccountancyAreaDescFiscalPeriod", 4, '{link}'); |
|
| 1111 | + $desc = str_replace('{link}', '<strong>'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("FiscalPeriod").'</strong>', $desc); |
|
| 1112 | + print $desc; |
|
| 1113 | + print '</div>'; |
|
| 1114 | + } |
|
| 1115 | + } else { |
|
| 1116 | + dol_print_error($db); |
|
| 1117 | + } |
|
| 1118 | + } |
|
| 1119 | + |
|
| 1120 | + // Bank test |
|
| 1121 | + $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"; |
|
| 1122 | + $resql = $db->query($sql); |
|
| 1123 | + if ($resql) { |
|
| 1124 | + $obj = $db->fetch_object($resql); |
|
| 1125 | + if ($obj->nb > 0) { |
|
| 1126 | + print '<br><div class="warning">'.img_warning().' '.$langs->trans("TheJournalCodeIsNotDefinedOnSomeBankAccount"); |
|
| 1127 | + $desc = ' : '.$langs->trans("AccountancyAreaDescBank", 6, '{link}'); |
|
| 1128 | + $desc = str_replace('{link}', '<strong>'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("BankAccounts").'</strong>', $desc); |
|
| 1129 | + print $desc; |
|
| 1130 | + print '</div>'; |
|
| 1131 | + } |
|
| 1132 | + } else { |
|
| 1133 | + dol_print_error($db); |
|
| 1134 | + } |
|
| 1135 | + |
|
| 1136 | + |
|
| 1137 | + // Button to write into Ledger |
|
| 1138 | + if (getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER') == "" || getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER') == '-1' |
|
| 1139 | + || getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER') == "" || getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER') == '-1' |
|
| 1140 | + || getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT') == "" || getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT') == '-1') { |
|
| 1141 | + print($desc ? '' : '<br>').'<div class="warning">'.img_warning().' '.$langs->trans("SomeMandatoryStepsOfSetupWereNotDone"); |
|
| 1142 | + $desc = ' : '.$langs->trans("AccountancyAreaDescMisc", 4, '{link}'); |
|
| 1143 | + $desc = str_replace('{link}', '<strong>'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("MenuDefaultAccounts").'</strong>', $desc); |
|
| 1144 | + print $desc; |
|
| 1145 | + print '</div>'; |
|
| 1146 | + } |
|
| 1147 | + |
|
| 1148 | + |
|
| 1149 | + print '<br><div class="tabsAction tabsActionNoBottom centerimp">'; |
|
| 1150 | + |
|
| 1151 | + if (getDolGlobalString('ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL') && $in_bookkeeping == 'notyet') { |
|
| 1152 | + print '<input type="button" class="butAction" name="exportcsv" value="'.$langs->trans("ExportDraftJournal").'" onclick="launch_export();" />'; |
|
| 1153 | + } |
|
| 1154 | + |
|
| 1155 | + if (getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER') == "" || getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER') == '-1' |
|
| 1156 | + || getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER') == "" || getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER') == '-1') { |
|
| 1157 | + print '<input type="button" class="butActionRefused classfortooltip" title="'.dol_escape_htmltag($langs->trans("SomeMandatoryStepsOfSetupWereNotDone")).'" value="'.$langs->trans("WriteBookKeeping").'" />'; |
|
| 1158 | + } else { |
|
| 1159 | + if ($in_bookkeeping == 'notyet') { |
|
| 1160 | + print '<input type="button" class="butAction" name="writebookkeeping" value="'.$langs->trans("WriteBookKeeping").'" onclick="writebookkeeping();" />'; |
|
| 1161 | + } else { |
|
| 1162 | + print '<a class="butActionRefused classfortooltip" name="writebookkeeping">'.$langs->trans("WriteBookKeeping").'</a>'; |
|
| 1163 | + } |
|
| 1164 | + } |
|
| 1165 | 1165 | |
| 1166 | - print '</div>'; |
|
| 1166 | + print '</div>'; |
|
| 1167 | 1167 | |
| 1168 | - // TODO Avoid using js. We can use a direct link with $param |
|
| 1169 | - print ' |
|
| 1168 | + // TODO Avoid using js. We can use a direct link with $param |
|
| 1169 | + print ' |
|
| 1170 | 1170 | <script type="text/javascript"> |
| 1171 | 1171 | function launch_export() { |
| 1172 | 1172 | console.log("Set value into form and submit"); |
@@ -1182,259 +1182,259 @@ discard block |
||
| 1182 | 1182 | } |
| 1183 | 1183 | </script>'; |
| 1184 | 1184 | |
| 1185 | - /* |
|
| 1185 | + /* |
|
| 1186 | 1186 | * Show result array |
| 1187 | 1187 | */ |
| 1188 | - print '<br>'; |
|
| 1189 | - |
|
| 1190 | - $i = 0; |
|
| 1191 | - print '<div class="div-table-responsive">'; |
|
| 1192 | - print '<table class="noborder centpercent">'; |
|
| 1193 | - print '<tr class="liste_titre">'; |
|
| 1194 | - print "<td>".$langs->trans("Date")."</td>"; |
|
| 1195 | - print "<td>".$langs->trans("Piece").' ('.$langs->trans("ObjectsRef").")</td>"; |
|
| 1196 | - print "<td>".$langs->trans("AccountAccounting")."</td>"; |
|
| 1197 | - print "<td>".$langs->trans("SubledgerAccount")."</td>"; |
|
| 1198 | - print "<td>".$langs->trans("LabelOperation")."</td>"; |
|
| 1199 | - print '<td class="center">'.$langs->trans("PaymentMode")."</td>"; |
|
| 1200 | - print '<td class="right">'.$langs->trans("AccountingDebit")."</td>"; |
|
| 1201 | - print '<td class="right">'.$langs->trans("AccountingCredit")."</td>"; |
|
| 1202 | - print "</tr>\n"; |
|
| 1203 | - |
|
| 1204 | - $r = ''; |
|
| 1205 | - |
|
| 1206 | - foreach ($tabpay as $key => $val) { // $key is rowid in llx_bank |
|
| 1207 | - $date = dol_print_date($val["date"], 'day'); |
|
| 1208 | - |
|
| 1209 | - $ref = getSourceDocRef($val, $tabtype[$key]); |
|
| 1210 | - |
|
| 1211 | - // Bank |
|
| 1212 | - foreach ($tabbq[$key] as $k => $mt) { |
|
| 1213 | - if ($mt) { |
|
| 1214 | - $reflabel = ''; |
|
| 1215 | - if (!empty($val['lib'])) { |
|
| 1216 | - $reflabel .= $val['lib']." - "; |
|
| 1217 | - } |
|
| 1218 | - $reflabel .= $langs->trans("Bank").' '.$val['bank_account_ref']; |
|
| 1219 | - if (!empty($val['soclib'])) { |
|
| 1220 | - $reflabel .= " - ".$val['soclib']; |
|
| 1221 | - } |
|
| 1188 | + print '<br>'; |
|
| 1222 | 1189 | |
| 1223 | - //var_dump($tabpay[$key]); |
|
| 1224 | - print '<!-- Bank bank.rowid='.$key.' type='.$tabpay[$key]['type'].' ref='.$tabpay[$key]['ref'].'-->'; |
|
| 1225 | - print '<tr class="oddeven">'; |
|
| 1190 | + $i = 0; |
|
| 1191 | + print '<div class="div-table-responsive">'; |
|
| 1192 | + print '<table class="noborder centpercent">'; |
|
| 1193 | + print '<tr class="liste_titre">'; |
|
| 1194 | + print "<td>".$langs->trans("Date")."</td>"; |
|
| 1195 | + print "<td>".$langs->trans("Piece").' ('.$langs->trans("ObjectsRef").")</td>"; |
|
| 1196 | + print "<td>".$langs->trans("AccountAccounting")."</td>"; |
|
| 1197 | + print "<td>".$langs->trans("SubledgerAccount")."</td>"; |
|
| 1198 | + print "<td>".$langs->trans("LabelOperation")."</td>"; |
|
| 1199 | + print '<td class="center">'.$langs->trans("PaymentMode")."</td>"; |
|
| 1200 | + print '<td class="right">'.$langs->trans("AccountingDebit")."</td>"; |
|
| 1201 | + print '<td class="right">'.$langs->trans("AccountingCredit")."</td>"; |
|
| 1202 | + print "</tr>\n"; |
|
| 1203 | + |
|
| 1204 | + $r = ''; |
|
| 1205 | + |
|
| 1206 | + foreach ($tabpay as $key => $val) { // $key is rowid in llx_bank |
|
| 1207 | + $date = dol_print_date($val["date"], 'day'); |
|
| 1208 | + |
|
| 1209 | + $ref = getSourceDocRef($val, $tabtype[$key]); |
|
| 1210 | + |
|
| 1211 | + // Bank |
|
| 1212 | + foreach ($tabbq[$key] as $k => $mt) { |
|
| 1213 | + if ($mt) { |
|
| 1214 | + $reflabel = ''; |
|
| 1215 | + if (!empty($val['lib'])) { |
|
| 1216 | + $reflabel .= $val['lib']." - "; |
|
| 1217 | + } |
|
| 1218 | + $reflabel .= $langs->trans("Bank").' '.$val['bank_account_ref']; |
|
| 1219 | + if (!empty($val['soclib'])) { |
|
| 1220 | + $reflabel .= " - ".$val['soclib']; |
|
| 1221 | + } |
|
| 1226 | 1222 | |
| 1227 | - // Date |
|
| 1228 | - print "<td>".$date."</td>"; |
|
| 1223 | + //var_dump($tabpay[$key]); |
|
| 1224 | + print '<!-- Bank bank.rowid='.$key.' type='.$tabpay[$key]['type'].' ref='.$tabpay[$key]['ref'].'-->'; |
|
| 1225 | + print '<tr class="oddeven">'; |
|
| 1229 | 1226 | |
| 1230 | - // Ref |
|
| 1231 | - print "<td>".dol_escape_htmltag($ref)."</td>"; |
|
| 1227 | + // Date |
|
| 1228 | + print "<td>".$date."</td>"; |
|
| 1232 | 1229 | |
| 1233 | - // Ledger account |
|
| 1234 | - $accounttoshow = length_accountg($k); |
|
| 1235 | - if (empty($accounttoshow) || $accounttoshow == 'NotDefined') { |
|
| 1236 | - $accounttoshow = '<span class="error">'.$langs->trans("BankAccountNotDefined").'</span>'; |
|
| 1237 | - } |
|
| 1238 | - print '<td class="maxwidth300" title="'.dol_escape_htmltag(dol_string_nohtmltag($accounttoshow)).'">'; |
|
| 1239 | - print $accounttoshow; |
|
| 1240 | - print "</td>"; |
|
| 1230 | + // Ref |
|
| 1231 | + print "<td>".dol_escape_htmltag($ref)."</td>"; |
|
| 1232 | + |
|
| 1233 | + // Ledger account |
|
| 1234 | + $accounttoshow = length_accountg($k); |
|
| 1235 | + if (empty($accounttoshow) || $accounttoshow == 'NotDefined') { |
|
| 1236 | + $accounttoshow = '<span class="error">'.$langs->trans("BankAccountNotDefined").'</span>'; |
|
| 1237 | + } |
|
| 1238 | + print '<td class="maxwidth300" title="'.dol_escape_htmltag(dol_string_nohtmltag($accounttoshow)).'">'; |
|
| 1239 | + print $accounttoshow; |
|
| 1240 | + print "</td>"; |
|
| 1241 | 1241 | |
| 1242 | - // Subledger account |
|
| 1243 | - print '<td class="maxwidth300">'; |
|
| 1244 | - /*$accounttoshow = length_accountg($k); |
|
| 1242 | + // Subledger account |
|
| 1243 | + print '<td class="maxwidth300">'; |
|
| 1244 | + /*$accounttoshow = length_accountg($k); |
|
| 1245 | 1245 | if (empty($accounttoshow) || $accounttoshow == 'NotDefined') |
| 1246 | 1246 | { |
| 1247 | 1247 | print '<span class="error">'.$langs->trans("BankAccountNotDefined").'</span>'; |
| 1248 | 1248 | } |
| 1249 | 1249 | else print $accounttoshow;*/ |
| 1250 | - print "</td>"; |
|
| 1250 | + print "</td>"; |
|
| 1251 | 1251 | |
| 1252 | - // Label operation |
|
| 1253 | - print '<td>'; |
|
| 1254 | - print $reflabel; // This is already html escaped content |
|
| 1255 | - print "</td>"; |
|
| 1252 | + // Label operation |
|
| 1253 | + print '<td>'; |
|
| 1254 | + print $reflabel; // This is already html escaped content |
|
| 1255 | + print "</td>"; |
|
| 1256 | 1256 | |
| 1257 | - print '<td class="center">'.$val["type_payment"]."</td>"; |
|
| 1258 | - print '<td class="right nowraponall amount">'.($mt >= 0 ? price($mt) : '')."</td>"; |
|
| 1259 | - print '<td class="right nowraponall amount">'.($mt < 0 ? price(-$mt) : '')."</td>"; |
|
| 1260 | - print "</tr>"; |
|
| 1257 | + print '<td class="center">'.$val["type_payment"]."</td>"; |
|
| 1258 | + print '<td class="right nowraponall amount">'.($mt >= 0 ? price($mt) : '')."</td>"; |
|
| 1259 | + print '<td class="right nowraponall amount">'.($mt < 0 ? price(-$mt) : '')."</td>"; |
|
| 1260 | + print "</tr>"; |
|
| 1261 | 1261 | |
| 1262 | - $i++; |
|
| 1263 | - } |
|
| 1264 | - } |
|
| 1265 | - |
|
| 1266 | - // Third party |
|
| 1267 | - if (is_array($tabtp[$key])) { |
|
| 1268 | - foreach ($tabtp[$key] as $k => $mt) { |
|
| 1269 | - if ($mt) { |
|
| 1270 | - $reflabel = ''; |
|
| 1271 | - if (!empty($val['lib'])) { |
|
| 1272 | - $reflabel .= $val['lib'].($val['soclib'] ? " - " : ""); |
|
| 1273 | - } |
|
| 1274 | - if ($tabtype[$key] == 'banktransfert') { |
|
| 1275 | - $reflabel .= $langs->trans('TransitionalAccount').' '.$account_transfer; |
|
| 1276 | - } else { |
|
| 1277 | - $reflabel .= $val['soclib']; |
|
| 1278 | - } |
|
| 1279 | - |
|
| 1280 | - print '<!-- Thirdparty bank.rowid='.$key.' -->'; |
|
| 1281 | - print '<tr class="oddeven">'; |
|
| 1282 | - |
|
| 1283 | - // Date |
|
| 1284 | - print "<td>".$date."</td>"; |
|
| 1285 | - |
|
| 1286 | - // Ref |
|
| 1287 | - print "<td>".dol_escape_htmltag($ref)."</td>"; |
|
| 1288 | - |
|
| 1289 | - // Ledger account |
|
| 1290 | - $account_ledger = $k; |
|
| 1291 | - // Try to force general ledger account depending on type |
|
| 1292 | - if ($tabtype[$key] == 'payment') { |
|
| 1293 | - $account_ledger = getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER'); |
|
| 1294 | - } |
|
| 1295 | - if ($tabtype[$key] == 'payment_supplier') { |
|
| 1296 | - $account_ledger = getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER'); |
|
| 1297 | - } |
|
| 1298 | - if ($tabtype[$key] == 'payment_expensereport') { |
|
| 1299 | - $account_ledger = getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT'); |
|
| 1300 | - } |
|
| 1301 | - if ($tabtype[$key] == 'payment_salary') { |
|
| 1302 | - $account_ledger = getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT'); |
|
| 1303 | - } |
|
| 1304 | - if ($tabtype[$key] == 'payment_vat') { |
|
| 1305 | - $account_ledger = getDolGlobalString('ACCOUNTING_VAT_PAY_ACCOUNT'); |
|
| 1306 | - } |
|
| 1307 | - if ($tabtype[$key] == 'member') { |
|
| 1308 | - $account_ledger = getDolGlobalString('ADHERENT_SUBSCRIPTION_ACCOUNTINGACCOUNT'); |
|
| 1309 | - } |
|
| 1310 | - if ($tabtype[$key] == 'payment_various') { |
|
| 1311 | - $account_ledger = $tabpay[$key]["account_various"]; |
|
| 1312 | - } |
|
| 1313 | - $accounttoshow = length_accountg($account_ledger); |
|
| 1314 | - if (empty($accounttoshow) || $accounttoshow == 'NotDefined') { |
|
| 1315 | - if ($tabtype[$key] == 'unknown') { |
|
| 1316 | - // We will accept writing, but into a waiting account |
|
| 1317 | - if (!getDolGlobalString('ACCOUNTING_ACCOUNT_SUSPENSE') || getDolGlobalString('ACCOUNTING_ACCOUNT_SUSPENSE') == '-1') { |
|
| 1318 | - $accounttoshow = '<span class="error small">'.$langs->trans('UnknownAccountForThirdpartyAndWaitingAccountNotDefinedBlocking').'</span>'; |
|
| 1319 | - } else { |
|
| 1320 | - $accounttoshow = '<span class="warning small">'.$langs->trans('UnknownAccountForThirdparty', length_accountg(getDolGlobalString('ACCOUNTING_ACCOUNT_SUSPENSE'))).'</span>'; // We will use a waiting account |
|
| 1321 | - } |
|
| 1322 | - } else { |
|
| 1323 | - // We will refuse writing |
|
| 1324 | - $errorstring = 'UnknownAccountForThirdpartyBlocking'; |
|
| 1325 | - if ($tabtype[$key] == 'payment') { |
|
| 1326 | - $errorstring = 'MainAccountForCustomersNotDefined'; |
|
| 1327 | - } |
|
| 1328 | - if ($tabtype[$key] == 'payment_supplier') { |
|
| 1329 | - $errorstring = 'MainAccountForSuppliersNotDefined'; |
|
| 1330 | - } |
|
| 1331 | - if ($tabtype[$key] == 'payment_expensereport') { |
|
| 1332 | - $errorstring = 'MainAccountForUsersNotDefined'; |
|
| 1333 | - } |
|
| 1334 | - if ($tabtype[$key] == 'payment_salary') { |
|
| 1335 | - $errorstring = 'MainAccountForUsersNotDefined'; |
|
| 1336 | - } |
|
| 1337 | - if ($tabtype[$key] == 'payment_vat') { |
|
| 1338 | - $errorstring = 'MainAccountForVatPaymentNotDefined'; |
|
| 1339 | - } |
|
| 1340 | - if ($tabtype[$key] == 'member') { |
|
| 1341 | - $errorstring = 'MainAccountForSubscriptionPaymentNotDefined'; |
|
| 1342 | - } |
|
| 1343 | - $accounttoshow = '<span class="error small">'.$langs->trans($errorstring).'</span>'; |
|
| 1344 | - } |
|
| 1345 | - } |
|
| 1346 | - print '<td class="maxwidth300" title="'.dol_escape_htmltag(dol_string_nohtmltag($accounttoshow)).'">'; |
|
| 1347 | - print $accounttoshow; // This is a HTML string |
|
| 1348 | - print "</td>"; |
|
| 1349 | - |
|
| 1350 | - // Subledger account |
|
| 1351 | - $accounttoshowsubledger = ''; |
|
| 1352 | - if (in_array($tabtype[$key], array('payment', 'payment_supplier', 'payment_expensereport', 'payment_salary', 'payment_various'))) { // Type of payments that uses a subledger |
|
| 1353 | - $accounttoshowsubledger = length_accounta($k); |
|
| 1354 | - if ($accounttoshow != $accounttoshowsubledger) { |
|
| 1355 | - if (empty($accounttoshowsubledger) || $accounttoshowsubledger == 'NotDefined') { |
|
| 1356 | - //var_dump($tabpay[$key]); |
|
| 1357 | - //var_dump($tabtype[$key]); |
|
| 1358 | - //var_dump($tabbq[$key]); |
|
| 1359 | - //print '<span class="error">'.$langs->trans("ThirdpartyAccountNotDefined").'</span>'; |
|
| 1360 | - if (!empty($tabcompany[$key]['code_compta'])) { |
|
| 1361 | - if (in_array($tabtype[$key], array('payment_various', 'payment_salary'))) { |
|
| 1362 | - // For such case, if subledger is not defined, we won't use subledger accounts. |
|
| 1363 | - $accounttoshowsubledger = '<span class="warning small">'.$langs->trans("ThirdpartyAccountNotDefinedOrThirdPartyUnknownSubledgerIgnored").'</span>'; |
|
| 1364 | - } else { |
|
| 1365 | - $accounttoshowsubledger = '<span class="warning small">'.$langs->trans("ThirdpartyAccountNotDefinedOrThirdPartyUnknown", $tabcompany[$key]['code_compta']).'</span>'; |
|
| 1366 | - } |
|
| 1367 | - } else { |
|
| 1368 | - $accounttoshowsubledger = '<span class="error small">'.$langs->trans("ThirdpartyAccountNotDefinedOrThirdPartyUnknownBlocking").'</span>'; |
|
| 1369 | - } |
|
| 1370 | - } |
|
| 1371 | - } else { |
|
| 1372 | - $accounttoshowsubledger = ''; |
|
| 1373 | - } |
|
| 1374 | - } |
|
| 1375 | - print '<td class="maxwidth300">'; |
|
| 1376 | - print $accounttoshowsubledger; // This is a html string |
|
| 1377 | - print "</td>"; |
|
| 1378 | - |
|
| 1379 | - print "<td>".$reflabel."</td>"; |
|
| 1380 | - |
|
| 1381 | - print '<td class="center">'.$val["type_payment"]."</td>"; |
|
| 1382 | - |
|
| 1383 | - print '<td class="right nowraponall amount">'.($mt < 0 ? price(-$mt) : '')."</td>"; |
|
| 1384 | - |
|
| 1385 | - print '<td class="right nowraponall amount">'.($mt >= 0 ? price($mt) : '')."</td>"; |
|
| 1386 | - |
|
| 1387 | - print "</tr>"; |
|
| 1262 | + $i++; |
|
| 1263 | + } |
|
| 1264 | + } |
|
| 1388 | 1265 | |
| 1389 | - $i++; |
|
| 1390 | - } |
|
| 1391 | - } |
|
| 1392 | - } else { // Waiting account |
|
| 1393 | - foreach ($tabbq[$key] as $k => $mt) { |
|
| 1394 | - if ($mt) { |
|
| 1395 | - $reflabel = ''; |
|
| 1396 | - if (!empty($val['lib'])) { |
|
| 1397 | - $reflabel .= $val['lib']." - "; |
|
| 1398 | - } |
|
| 1399 | - $reflabel .= 'WaitingAccount'; |
|
| 1400 | - |
|
| 1401 | - print '<!-- Wait bank.rowid='.$key.' -->'; |
|
| 1402 | - print '<tr class="oddeven">'; |
|
| 1403 | - print "<td>".$date."</td>"; |
|
| 1404 | - print "<td>".$ref."</td>"; |
|
| 1405 | - // Ledger account |
|
| 1406 | - print "<td>"; |
|
| 1407 | - /*if (empty($accounttoshow) || $accounttoshow == 'NotDefined') |
|
| 1266 | + // Third party |
|
| 1267 | + if (is_array($tabtp[$key])) { |
|
| 1268 | + foreach ($tabtp[$key] as $k => $mt) { |
|
| 1269 | + if ($mt) { |
|
| 1270 | + $reflabel = ''; |
|
| 1271 | + if (!empty($val['lib'])) { |
|
| 1272 | + $reflabel .= $val['lib'].($val['soclib'] ? " - " : ""); |
|
| 1273 | + } |
|
| 1274 | + if ($tabtype[$key] == 'banktransfert') { |
|
| 1275 | + $reflabel .= $langs->trans('TransitionalAccount').' '.$account_transfer; |
|
| 1276 | + } else { |
|
| 1277 | + $reflabel .= $val['soclib']; |
|
| 1278 | + } |
|
| 1279 | + |
|
| 1280 | + print '<!-- Thirdparty bank.rowid='.$key.' -->'; |
|
| 1281 | + print '<tr class="oddeven">'; |
|
| 1282 | + |
|
| 1283 | + // Date |
|
| 1284 | + print "<td>".$date."</td>"; |
|
| 1285 | + |
|
| 1286 | + // Ref |
|
| 1287 | + print "<td>".dol_escape_htmltag($ref)."</td>"; |
|
| 1288 | + |
|
| 1289 | + // Ledger account |
|
| 1290 | + $account_ledger = $k; |
|
| 1291 | + // Try to force general ledger account depending on type |
|
| 1292 | + if ($tabtype[$key] == 'payment') { |
|
| 1293 | + $account_ledger = getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER'); |
|
| 1294 | + } |
|
| 1295 | + if ($tabtype[$key] == 'payment_supplier') { |
|
| 1296 | + $account_ledger = getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER'); |
|
| 1297 | + } |
|
| 1298 | + if ($tabtype[$key] == 'payment_expensereport') { |
|
| 1299 | + $account_ledger = getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT'); |
|
| 1300 | + } |
|
| 1301 | + if ($tabtype[$key] == 'payment_salary') { |
|
| 1302 | + $account_ledger = getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT'); |
|
| 1303 | + } |
|
| 1304 | + if ($tabtype[$key] == 'payment_vat') { |
|
| 1305 | + $account_ledger = getDolGlobalString('ACCOUNTING_VAT_PAY_ACCOUNT'); |
|
| 1306 | + } |
|
| 1307 | + if ($tabtype[$key] == 'member') { |
|
| 1308 | + $account_ledger = getDolGlobalString('ADHERENT_SUBSCRIPTION_ACCOUNTINGACCOUNT'); |
|
| 1309 | + } |
|
| 1310 | + if ($tabtype[$key] == 'payment_various') { |
|
| 1311 | + $account_ledger = $tabpay[$key]["account_various"]; |
|
| 1312 | + } |
|
| 1313 | + $accounttoshow = length_accountg($account_ledger); |
|
| 1314 | + if (empty($accounttoshow) || $accounttoshow == 'NotDefined') { |
|
| 1315 | + if ($tabtype[$key] == 'unknown') { |
|
| 1316 | + // We will accept writing, but into a waiting account |
|
| 1317 | + if (!getDolGlobalString('ACCOUNTING_ACCOUNT_SUSPENSE') || getDolGlobalString('ACCOUNTING_ACCOUNT_SUSPENSE') == '-1') { |
|
| 1318 | + $accounttoshow = '<span class="error small">'.$langs->trans('UnknownAccountForThirdpartyAndWaitingAccountNotDefinedBlocking').'</span>'; |
|
| 1319 | + } else { |
|
| 1320 | + $accounttoshow = '<span class="warning small">'.$langs->trans('UnknownAccountForThirdparty', length_accountg(getDolGlobalString('ACCOUNTING_ACCOUNT_SUSPENSE'))).'</span>'; // We will use a waiting account |
|
| 1321 | + } |
|
| 1322 | + } else { |
|
| 1323 | + // We will refuse writing |
|
| 1324 | + $errorstring = 'UnknownAccountForThirdpartyBlocking'; |
|
| 1325 | + if ($tabtype[$key] == 'payment') { |
|
| 1326 | + $errorstring = 'MainAccountForCustomersNotDefined'; |
|
| 1327 | + } |
|
| 1328 | + if ($tabtype[$key] == 'payment_supplier') { |
|
| 1329 | + $errorstring = 'MainAccountForSuppliersNotDefined'; |
|
| 1330 | + } |
|
| 1331 | + if ($tabtype[$key] == 'payment_expensereport') { |
|
| 1332 | + $errorstring = 'MainAccountForUsersNotDefined'; |
|
| 1333 | + } |
|
| 1334 | + if ($tabtype[$key] == 'payment_salary') { |
|
| 1335 | + $errorstring = 'MainAccountForUsersNotDefined'; |
|
| 1336 | + } |
|
| 1337 | + if ($tabtype[$key] == 'payment_vat') { |
|
| 1338 | + $errorstring = 'MainAccountForVatPaymentNotDefined'; |
|
| 1339 | + } |
|
| 1340 | + if ($tabtype[$key] == 'member') { |
|
| 1341 | + $errorstring = 'MainAccountForSubscriptionPaymentNotDefined'; |
|
| 1342 | + } |
|
| 1343 | + $accounttoshow = '<span class="error small">'.$langs->trans($errorstring).'</span>'; |
|
| 1344 | + } |
|
| 1345 | + } |
|
| 1346 | + print '<td class="maxwidth300" title="'.dol_escape_htmltag(dol_string_nohtmltag($accounttoshow)).'">'; |
|
| 1347 | + print $accounttoshow; // This is a HTML string |
|
| 1348 | + print "</td>"; |
|
| 1349 | + |
|
| 1350 | + // Subledger account |
|
| 1351 | + $accounttoshowsubledger = ''; |
|
| 1352 | + if (in_array($tabtype[$key], array('payment', 'payment_supplier', 'payment_expensereport', 'payment_salary', 'payment_various'))) { // Type of payments that uses a subledger |
|
| 1353 | + $accounttoshowsubledger = length_accounta($k); |
|
| 1354 | + if ($accounttoshow != $accounttoshowsubledger) { |
|
| 1355 | + if (empty($accounttoshowsubledger) || $accounttoshowsubledger == 'NotDefined') { |
|
| 1356 | + //var_dump($tabpay[$key]); |
|
| 1357 | + //var_dump($tabtype[$key]); |
|
| 1358 | + //var_dump($tabbq[$key]); |
|
| 1359 | + //print '<span class="error">'.$langs->trans("ThirdpartyAccountNotDefined").'</span>'; |
|
| 1360 | + if (!empty($tabcompany[$key]['code_compta'])) { |
|
| 1361 | + if (in_array($tabtype[$key], array('payment_various', 'payment_salary'))) { |
|
| 1362 | + // For such case, if subledger is not defined, we won't use subledger accounts. |
|
| 1363 | + $accounttoshowsubledger = '<span class="warning small">'.$langs->trans("ThirdpartyAccountNotDefinedOrThirdPartyUnknownSubledgerIgnored").'</span>'; |
|
| 1364 | + } else { |
|
| 1365 | + $accounttoshowsubledger = '<span class="warning small">'.$langs->trans("ThirdpartyAccountNotDefinedOrThirdPartyUnknown", $tabcompany[$key]['code_compta']).'</span>'; |
|
| 1366 | + } |
|
| 1367 | + } else { |
|
| 1368 | + $accounttoshowsubledger = '<span class="error small">'.$langs->trans("ThirdpartyAccountNotDefinedOrThirdPartyUnknownBlocking").'</span>'; |
|
| 1369 | + } |
|
| 1370 | + } |
|
| 1371 | + } else { |
|
| 1372 | + $accounttoshowsubledger = ''; |
|
| 1373 | + } |
|
| 1374 | + } |
|
| 1375 | + print '<td class="maxwidth300">'; |
|
| 1376 | + print $accounttoshowsubledger; // This is a html string |
|
| 1377 | + print "</td>"; |
|
| 1378 | + |
|
| 1379 | + print "<td>".$reflabel."</td>"; |
|
| 1380 | + |
|
| 1381 | + print '<td class="center">'.$val["type_payment"]."</td>"; |
|
| 1382 | + |
|
| 1383 | + print '<td class="right nowraponall amount">'.($mt < 0 ? price(-$mt) : '')."</td>"; |
|
| 1384 | + |
|
| 1385 | + print '<td class="right nowraponall amount">'.($mt >= 0 ? price($mt) : '')."</td>"; |
|
| 1386 | + |
|
| 1387 | + print "</tr>"; |
|
| 1388 | + |
|
| 1389 | + $i++; |
|
| 1390 | + } |
|
| 1391 | + } |
|
| 1392 | + } else { // Waiting account |
|
| 1393 | + foreach ($tabbq[$key] as $k => $mt) { |
|
| 1394 | + if ($mt) { |
|
| 1395 | + $reflabel = ''; |
|
| 1396 | + if (!empty($val['lib'])) { |
|
| 1397 | + $reflabel .= $val['lib']." - "; |
|
| 1398 | + } |
|
| 1399 | + $reflabel .= 'WaitingAccount'; |
|
| 1400 | + |
|
| 1401 | + print '<!-- Wait bank.rowid='.$key.' -->'; |
|
| 1402 | + print '<tr class="oddeven">'; |
|
| 1403 | + print "<td>".$date."</td>"; |
|
| 1404 | + print "<td>".$ref."</td>"; |
|
| 1405 | + // Ledger account |
|
| 1406 | + print "<td>"; |
|
| 1407 | + /*if (empty($accounttoshow) || $accounttoshow == 'NotDefined') |
|
| 1408 | 1408 | { |
| 1409 | 1409 | print '<span class="error">'.$langs->trans("WaitAccountNotDefined").'</span>'; |
| 1410 | 1410 | } |
| 1411 | 1411 | else */ |
| 1412 | - print length_accountg(getDolGlobalString('ACCOUNTING_ACCOUNT_SUSPENSE')); |
|
| 1413 | - print "</td>"; |
|
| 1414 | - // Subledger account |
|
| 1415 | - print "<td>"; |
|
| 1416 | - print "</td>"; |
|
| 1417 | - print "<td>".dol_escape_htmltag($reflabel)."</td>"; |
|
| 1418 | - print '<td class="center">'.$val["type_payment"]."</td>"; |
|
| 1419 | - print '<td class="right nowraponall amount">'.($mt < 0 ? price(-$mt) : '')."</td>"; |
|
| 1420 | - print '<td class="right nowraponall amount">'.($mt >= 0 ? price($mt) : '')."</td>"; |
|
| 1421 | - print "</tr>"; |
|
| 1422 | - |
|
| 1423 | - $i++; |
|
| 1424 | - } |
|
| 1425 | - } |
|
| 1426 | - } |
|
| 1427 | - } |
|
| 1412 | + print length_accountg(getDolGlobalString('ACCOUNTING_ACCOUNT_SUSPENSE')); |
|
| 1413 | + print "</td>"; |
|
| 1414 | + // Subledger account |
|
| 1415 | + print "<td>"; |
|
| 1416 | + print "</td>"; |
|
| 1417 | + print "<td>".dol_escape_htmltag($reflabel)."</td>"; |
|
| 1418 | + print '<td class="center">'.$val["type_payment"]."</td>"; |
|
| 1419 | + print '<td class="right nowraponall amount">'.($mt < 0 ? price(-$mt) : '')."</td>"; |
|
| 1420 | + print '<td class="right nowraponall amount">'.($mt >= 0 ? price($mt) : '')."</td>"; |
|
| 1421 | + print "</tr>"; |
|
| 1422 | + |
|
| 1423 | + $i++; |
|
| 1424 | + } |
|
| 1425 | + } |
|
| 1426 | + } |
|
| 1427 | + } |
|
| 1428 | 1428 | |
| 1429 | - if (!$i) { |
|
| 1430 | - $colspan = 8; |
|
| 1431 | - print '<tr class="oddeven"><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>'; |
|
| 1432 | - } |
|
| 1429 | + if (!$i) { |
|
| 1430 | + $colspan = 8; |
|
| 1431 | + print '<tr class="oddeven"><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>'; |
|
| 1432 | + } |
|
| 1433 | 1433 | |
| 1434 | - print "</table>"; |
|
| 1435 | - print '</div>'; |
|
| 1434 | + print "</table>"; |
|
| 1435 | + print '</div>'; |
|
| 1436 | 1436 | |
| 1437 | - llxFooter(); |
|
| 1437 | + llxFooter(); |
|
| 1438 | 1438 | } |
| 1439 | 1439 | |
| 1440 | 1440 | $db->close(); |
@@ -1450,110 +1450,110 @@ discard block |
||
| 1450 | 1450 | */ |
| 1451 | 1451 | function getSourceDocRef($val, $typerecord) |
| 1452 | 1452 | { |
| 1453 | - global $db, $langs; |
|
| 1454 | - |
|
| 1455 | - // Defined the docref into $ref (We start with $val['ref'] by default and we complete according to other data) |
|
| 1456 | - // WE MUST HAVE SAME REF FOR ALL LINES WE WILL RECORD INTO THE BOOKKEEPING |
|
| 1457 | - $ref = $val['ref']; |
|
| 1458 | - if ($ref == '(SupplierInvoicePayment)' || $ref == '(SupplierInvoicePaymentBack)') { |
|
| 1459 | - $ref = $langs->transnoentitiesnoconv('Supplier'); |
|
| 1460 | - } |
|
| 1461 | - if ($ref == '(CustomerInvoicePayment)' || $ref == '(CustomerInvoicePaymentBack)') { |
|
| 1462 | - $ref = $langs->transnoentitiesnoconv('Customer'); |
|
| 1463 | - } |
|
| 1464 | - if ($ref == '(SocialContributionPayment)') { |
|
| 1465 | - $ref = $langs->transnoentitiesnoconv('SocialContribution'); |
|
| 1466 | - } |
|
| 1467 | - if ($ref == '(DonationPayment)') { |
|
| 1468 | - $ref = $langs->transnoentitiesnoconv('Donation'); |
|
| 1469 | - } |
|
| 1470 | - if ($ref == '(SubscriptionPayment)') { |
|
| 1471 | - $ref = $langs->transnoentitiesnoconv('Subscription'); |
|
| 1472 | - } |
|
| 1473 | - if ($ref == '(ExpenseReportPayment)') { |
|
| 1474 | - $ref = $langs->transnoentitiesnoconv('Employee'); |
|
| 1475 | - } |
|
| 1476 | - if ($ref == '(LoanPayment)') { |
|
| 1477 | - $ref = $langs->transnoentitiesnoconv('Loan'); |
|
| 1478 | - } |
|
| 1479 | - if ($ref == '(payment_salary)') { |
|
| 1480 | - $ref = $langs->transnoentitiesnoconv('Employee'); |
|
| 1481 | - } |
|
| 1482 | - |
|
| 1483 | - $sqlmid = ''; |
|
| 1484 | - if ($typerecord == 'payment') { |
|
| 1485 | - if (getDolGlobalInt('FACTURE_DEPOSITS_ARE_JUST_PAYMENTS')) { |
|
| 1486 | - $sqlmid = "SELECT payfac.fk_facture as id, ".$db->ifsql('f1.rowid IS NULL', 'f.ref', 'f1.ref')." as ref"; |
|
| 1487 | - $sqlmid .= " FROM ".$db->prefix()."paiement_facture as payfac"; |
|
| 1488 | - $sqlmid .= " LEFT JOIN ".$db->prefix()."facture as f ON f.rowid = payfac.fk_facture"; |
|
| 1489 | - $sqlmid .= " LEFT JOIN ".$db->prefix()."societe_remise_except as sre ON sre.fk_facture_source = payfac.fk_facture"; |
|
| 1490 | - $sqlmid .= " LEFT JOIN ".$db->prefix()."facture as f1 ON f1.rowid = sre.fk_facture"; |
|
| 1491 | - $sqlmid .= " WHERE payfac.fk_paiement=".((int) $val['paymentid']); |
|
| 1492 | - } else { |
|
| 1493 | - $sqlmid = "SELECT payfac.fk_facture as id, f.ref as ref"; |
|
| 1494 | - $sqlmid .= " FROM ".$db->prefix()."paiement_facture as payfac"; |
|
| 1495 | - $sqlmid .= " INNER JOIN ".$db->prefix()."facture as f ON f.rowid = payfac.fk_facture"; |
|
| 1496 | - $sqlmid .= " WHERE payfac.fk_paiement=".((int) $val['paymentid']); |
|
| 1497 | - } |
|
| 1498 | - $ref = $langs->transnoentitiesnoconv("Invoice"); |
|
| 1499 | - } elseif ($typerecord == 'payment_supplier') { |
|
| 1500 | - $sqlmid = 'SELECT payfac.fk_facturefourn as id, f.ref'; |
|
| 1501 | - $sqlmid .= " FROM ".MAIN_DB_PREFIX."paiementfourn_facturefourn as payfac, ".MAIN_DB_PREFIX."facture_fourn as f"; |
|
| 1502 | - $sqlmid .= " WHERE payfac.fk_facturefourn = f.rowid AND payfac.fk_paiementfourn=".((int) $val["paymentsupplierid"]); |
|
| 1503 | - $ref = $langs->transnoentitiesnoconv("SupplierInvoice"); |
|
| 1504 | - } elseif ($typerecord == 'payment_expensereport') { |
|
| 1505 | - $sqlmid = 'SELECT e.rowid as id, e.ref'; |
|
| 1506 | - $sqlmid .= " FROM ".MAIN_DB_PREFIX."payment_expensereport as pe, ".MAIN_DB_PREFIX."expensereport as e"; |
|
| 1507 | - $sqlmid .= " WHERE pe.rowid=".((int) $val["paymentexpensereport"])." AND pe.fk_expensereport = e.rowid"; |
|
| 1508 | - $ref = $langs->transnoentitiesnoconv("ExpenseReport"); |
|
| 1509 | - } elseif ($typerecord == 'payment_salary') { |
|
| 1510 | - $sqlmid = 'SELECT s.rowid as ref'; |
|
| 1511 | - $sqlmid .= " FROM ".MAIN_DB_PREFIX."payment_salary as s"; |
|
| 1512 | - $sqlmid .= " WHERE s.rowid=".((int) $val["paymentsalid"]); |
|
| 1513 | - $ref = $langs->transnoentitiesnoconv("SalaryPayment"); |
|
| 1514 | - } elseif ($typerecord == 'sc') { |
|
| 1515 | - $sqlmid = 'SELECT sc.rowid as ref'; |
|
| 1516 | - $sqlmid .= " FROM ".MAIN_DB_PREFIX."paiementcharge as sc"; |
|
| 1517 | - $sqlmid .= " WHERE sc.rowid=".((int) $val["paymentscid"]); |
|
| 1518 | - $ref = $langs->transnoentitiesnoconv("SocialContribution"); |
|
| 1519 | - } elseif ($typerecord == 'payment_vat') { |
|
| 1520 | - $sqlmid = 'SELECT v.rowid as ref'; |
|
| 1521 | - $sqlmid .= " FROM ".MAIN_DB_PREFIX."tva as v"; |
|
| 1522 | - $sqlmid .= " WHERE v.rowid=".((int) $val["paymentvatid"]); |
|
| 1523 | - $ref = $langs->transnoentitiesnoconv("PaymentVat"); |
|
| 1524 | - } elseif ($typerecord == 'payment_donation') { |
|
| 1525 | - $sqlmid = 'SELECT payd.fk_donation as ref'; |
|
| 1526 | - $sqlmid .= " FROM ".MAIN_DB_PREFIX."payment_donation as payd"; |
|
| 1527 | - $sqlmid .= " WHERE payd.fk_donation=".((int) $val["paymentdonationid"]); |
|
| 1528 | - $ref = $langs->transnoentitiesnoconv("Donation"); |
|
| 1529 | - } elseif ($typerecord == 'payment_loan') { |
|
| 1530 | - $sqlmid = 'SELECT l.rowid as ref'; |
|
| 1531 | - $sqlmid .= " FROM ".MAIN_DB_PREFIX."payment_loan as l"; |
|
| 1532 | - $sqlmid .= " WHERE l.rowid=".((int) $val["paymentloanid"]); |
|
| 1533 | - $ref = $langs->transnoentitiesnoconv("LoanPayment"); |
|
| 1534 | - } elseif ($typerecord == 'payment_various') { |
|
| 1535 | - $sqlmid = 'SELECT v.rowid as ref'; |
|
| 1536 | - $sqlmid .= " FROM ".MAIN_DB_PREFIX."payment_various as v"; |
|
| 1537 | - $sqlmid .= " WHERE v.rowid=".((int) $val["paymentvariousid"]); |
|
| 1538 | - $ref = $langs->transnoentitiesnoconv("VariousPayment"); |
|
| 1539 | - } |
|
| 1540 | - // Add warning |
|
| 1541 | - if (empty($sqlmid)) { |
|
| 1542 | - dol_syslog("Found a typerecord=".$typerecord." not supported", LOG_WARNING); |
|
| 1543 | - } |
|
| 1544 | - |
|
| 1545 | - if ($sqlmid) { |
|
| 1546 | - dol_syslog("accountancy/journal/bankjournal.php::sqlmid=".$sqlmid, LOG_DEBUG); |
|
| 1547 | - $resultmid = $db->query($sqlmid); |
|
| 1548 | - if ($resultmid) { |
|
| 1549 | - while ($objmid = $db->fetch_object($resultmid)) { |
|
| 1550 | - $ref .= ' '.$objmid->ref; |
|
| 1551 | - } |
|
| 1552 | - } else { |
|
| 1553 | - dol_print_error($db); |
|
| 1554 | - } |
|
| 1555 | - } |
|
| 1453 | + global $db, $langs; |
|
| 1454 | + |
|
| 1455 | + // Defined the docref into $ref (We start with $val['ref'] by default and we complete according to other data) |
|
| 1456 | + // WE MUST HAVE SAME REF FOR ALL LINES WE WILL RECORD INTO THE BOOKKEEPING |
|
| 1457 | + $ref = $val['ref']; |
|
| 1458 | + if ($ref == '(SupplierInvoicePayment)' || $ref == '(SupplierInvoicePaymentBack)') { |
|
| 1459 | + $ref = $langs->transnoentitiesnoconv('Supplier'); |
|
| 1460 | + } |
|
| 1461 | + if ($ref == '(CustomerInvoicePayment)' || $ref == '(CustomerInvoicePaymentBack)') { |
|
| 1462 | + $ref = $langs->transnoentitiesnoconv('Customer'); |
|
| 1463 | + } |
|
| 1464 | + if ($ref == '(SocialContributionPayment)') { |
|
| 1465 | + $ref = $langs->transnoentitiesnoconv('SocialContribution'); |
|
| 1466 | + } |
|
| 1467 | + if ($ref == '(DonationPayment)') { |
|
| 1468 | + $ref = $langs->transnoentitiesnoconv('Donation'); |
|
| 1469 | + } |
|
| 1470 | + if ($ref == '(SubscriptionPayment)') { |
|
| 1471 | + $ref = $langs->transnoentitiesnoconv('Subscription'); |
|
| 1472 | + } |
|
| 1473 | + if ($ref == '(ExpenseReportPayment)') { |
|
| 1474 | + $ref = $langs->transnoentitiesnoconv('Employee'); |
|
| 1475 | + } |
|
| 1476 | + if ($ref == '(LoanPayment)') { |
|
| 1477 | + $ref = $langs->transnoentitiesnoconv('Loan'); |
|
| 1478 | + } |
|
| 1479 | + if ($ref == '(payment_salary)') { |
|
| 1480 | + $ref = $langs->transnoentitiesnoconv('Employee'); |
|
| 1481 | + } |
|
| 1482 | + |
|
| 1483 | + $sqlmid = ''; |
|
| 1484 | + if ($typerecord == 'payment') { |
|
| 1485 | + if (getDolGlobalInt('FACTURE_DEPOSITS_ARE_JUST_PAYMENTS')) { |
|
| 1486 | + $sqlmid = "SELECT payfac.fk_facture as id, ".$db->ifsql('f1.rowid IS NULL', 'f.ref', 'f1.ref')." as ref"; |
|
| 1487 | + $sqlmid .= " FROM ".$db->prefix()."paiement_facture as payfac"; |
|
| 1488 | + $sqlmid .= " LEFT JOIN ".$db->prefix()."facture as f ON f.rowid = payfac.fk_facture"; |
|
| 1489 | + $sqlmid .= " LEFT JOIN ".$db->prefix()."societe_remise_except as sre ON sre.fk_facture_source = payfac.fk_facture"; |
|
| 1490 | + $sqlmid .= " LEFT JOIN ".$db->prefix()."facture as f1 ON f1.rowid = sre.fk_facture"; |
|
| 1491 | + $sqlmid .= " WHERE payfac.fk_paiement=".((int) $val['paymentid']); |
|
| 1492 | + } else { |
|
| 1493 | + $sqlmid = "SELECT payfac.fk_facture as id, f.ref as ref"; |
|
| 1494 | + $sqlmid .= " FROM ".$db->prefix()."paiement_facture as payfac"; |
|
| 1495 | + $sqlmid .= " INNER JOIN ".$db->prefix()."facture as f ON f.rowid = payfac.fk_facture"; |
|
| 1496 | + $sqlmid .= " WHERE payfac.fk_paiement=".((int) $val['paymentid']); |
|
| 1497 | + } |
|
| 1498 | + $ref = $langs->transnoentitiesnoconv("Invoice"); |
|
| 1499 | + } elseif ($typerecord == 'payment_supplier') { |
|
| 1500 | + $sqlmid = 'SELECT payfac.fk_facturefourn as id, f.ref'; |
|
| 1501 | + $sqlmid .= " FROM ".MAIN_DB_PREFIX."paiementfourn_facturefourn as payfac, ".MAIN_DB_PREFIX."facture_fourn as f"; |
|
| 1502 | + $sqlmid .= " WHERE payfac.fk_facturefourn = f.rowid AND payfac.fk_paiementfourn=".((int) $val["paymentsupplierid"]); |
|
| 1503 | + $ref = $langs->transnoentitiesnoconv("SupplierInvoice"); |
|
| 1504 | + } elseif ($typerecord == 'payment_expensereport') { |
|
| 1505 | + $sqlmid = 'SELECT e.rowid as id, e.ref'; |
|
| 1506 | + $sqlmid .= " FROM ".MAIN_DB_PREFIX."payment_expensereport as pe, ".MAIN_DB_PREFIX."expensereport as e"; |
|
| 1507 | + $sqlmid .= " WHERE pe.rowid=".((int) $val["paymentexpensereport"])." AND pe.fk_expensereport = e.rowid"; |
|
| 1508 | + $ref = $langs->transnoentitiesnoconv("ExpenseReport"); |
|
| 1509 | + } elseif ($typerecord == 'payment_salary') { |
|
| 1510 | + $sqlmid = 'SELECT s.rowid as ref'; |
|
| 1511 | + $sqlmid .= " FROM ".MAIN_DB_PREFIX."payment_salary as s"; |
|
| 1512 | + $sqlmid .= " WHERE s.rowid=".((int) $val["paymentsalid"]); |
|
| 1513 | + $ref = $langs->transnoentitiesnoconv("SalaryPayment"); |
|
| 1514 | + } elseif ($typerecord == 'sc') { |
|
| 1515 | + $sqlmid = 'SELECT sc.rowid as ref'; |
|
| 1516 | + $sqlmid .= " FROM ".MAIN_DB_PREFIX."paiementcharge as sc"; |
|
| 1517 | + $sqlmid .= " WHERE sc.rowid=".((int) $val["paymentscid"]); |
|
| 1518 | + $ref = $langs->transnoentitiesnoconv("SocialContribution"); |
|
| 1519 | + } elseif ($typerecord == 'payment_vat') { |
|
| 1520 | + $sqlmid = 'SELECT v.rowid as ref'; |
|
| 1521 | + $sqlmid .= " FROM ".MAIN_DB_PREFIX."tva as v"; |
|
| 1522 | + $sqlmid .= " WHERE v.rowid=".((int) $val["paymentvatid"]); |
|
| 1523 | + $ref = $langs->transnoentitiesnoconv("PaymentVat"); |
|
| 1524 | + } elseif ($typerecord == 'payment_donation') { |
|
| 1525 | + $sqlmid = 'SELECT payd.fk_donation as ref'; |
|
| 1526 | + $sqlmid .= " FROM ".MAIN_DB_PREFIX."payment_donation as payd"; |
|
| 1527 | + $sqlmid .= " WHERE payd.fk_donation=".((int) $val["paymentdonationid"]); |
|
| 1528 | + $ref = $langs->transnoentitiesnoconv("Donation"); |
|
| 1529 | + } elseif ($typerecord == 'payment_loan') { |
|
| 1530 | + $sqlmid = 'SELECT l.rowid as ref'; |
|
| 1531 | + $sqlmid .= " FROM ".MAIN_DB_PREFIX."payment_loan as l"; |
|
| 1532 | + $sqlmid .= " WHERE l.rowid=".((int) $val["paymentloanid"]); |
|
| 1533 | + $ref = $langs->transnoentitiesnoconv("LoanPayment"); |
|
| 1534 | + } elseif ($typerecord == 'payment_various') { |
|
| 1535 | + $sqlmid = 'SELECT v.rowid as ref'; |
|
| 1536 | + $sqlmid .= " FROM ".MAIN_DB_PREFIX."payment_various as v"; |
|
| 1537 | + $sqlmid .= " WHERE v.rowid=".((int) $val["paymentvariousid"]); |
|
| 1538 | + $ref = $langs->transnoentitiesnoconv("VariousPayment"); |
|
| 1539 | + } |
|
| 1540 | + // Add warning |
|
| 1541 | + if (empty($sqlmid)) { |
|
| 1542 | + dol_syslog("Found a typerecord=".$typerecord." not supported", LOG_WARNING); |
|
| 1543 | + } |
|
| 1544 | + |
|
| 1545 | + if ($sqlmid) { |
|
| 1546 | + dol_syslog("accountancy/journal/bankjournal.php::sqlmid=".$sqlmid, LOG_DEBUG); |
|
| 1547 | + $resultmid = $db->query($sqlmid); |
|
| 1548 | + if ($resultmid) { |
|
| 1549 | + while ($objmid = $db->fetch_object($resultmid)) { |
|
| 1550 | + $ref .= ' '.$objmid->ref; |
|
| 1551 | + } |
|
| 1552 | + } else { |
|
| 1553 | + dol_print_error($db); |
|
| 1554 | + } |
|
| 1555 | + } |
|
| 1556 | 1556 | |
| 1557 | - $ref = dol_trunc($langs->transnoentitiesnoconv("BankId").' '.$val['fk_bank'].' - '.$ref, 295); // 295 + 3 dots (...) is < than max size of 300 |
|
| 1558 | - return $ref; |
|
| 1557 | + $ref = dol_trunc($langs->transnoentitiesnoconv("BankId").' '.$val['fk_bank'].' - '.$ref, 295); // 295 + 3 dots (...) is < than max size of 300 |
|
| 1558 | + return $ref; |
|
| 1559 | 1559 | } |
@@ -369,12 +369,12 @@ discard block |
||
| 369 | 369 | if ($links[$key]['type'] == 'payment') { |
| 370 | 370 | $paymentstatic->id = $links[$key]['url_id']; |
| 371 | 371 | $paymentstatic->ref = $links[$key]['url_id']; |
| 372 | - $tabpay[$obj->rowid]["lib"] .= ' '.$paymentstatic->getNomUrl(2, '', ''); // TODO Do not include list of invoice in tooltip, the dol_string_nohtmltag is ko with this |
|
| 372 | + $tabpay[$obj->rowid]["lib"] .= ' ' . $paymentstatic->getNomUrl(2, '', ''); // TODO Do not include list of invoice in tooltip, the dol_string_nohtmltag is ko with this |
|
| 373 | 373 | $tabpay[$obj->rowid]["paymentid"] = $paymentstatic->id; |
| 374 | 374 | } elseif ($links[$key]['type'] == 'payment_supplier') { |
| 375 | 375 | $paymentsupplierstatic->id = $links[$key]['url_id']; |
| 376 | 376 | $paymentsupplierstatic->ref = $links[$key]['url_id']; |
| 377 | - $tabpay[$obj->rowid]["lib"] .= ' '.$paymentsupplierstatic->getNomUrl(2); |
|
| 377 | + $tabpay[$obj->rowid]["lib"] .= ' ' . $paymentsupplierstatic->getNomUrl(2); |
|
| 378 | 378 | $tabpay[$obj->rowid]["paymentsupplierid"] = $paymentsupplierstatic->id; |
| 379 | 379 | } elseif ($links[$key]['type'] == 'company') { |
| 380 | 380 | $societestatic->id = $links[$key]['url_id']; |
@@ -409,7 +409,7 @@ discard block |
||
| 409 | 409 | $chargestatic->id = $links[$key]['url_id']; |
| 410 | 410 | $chargestatic->ref = $links[$key]['url_id']; |
| 411 | 411 | |
| 412 | - $tabpay[$obj->rowid]["lib"] .= ' '.$chargestatic->getNomUrl(2); |
|
| 412 | + $tabpay[$obj->rowid]["lib"] .= ' ' . $chargestatic->getNomUrl(2); |
|
| 413 | 413 | $reg = array(); |
| 414 | 414 | if (preg_match('/^\((.*)\)$/i', $links[$key]['label'], $reg)) { |
| 415 | 415 | if ($reg[1] == 'socialcontribution') { |
@@ -426,13 +426,13 @@ discard block |
||
| 426 | 426 | // Retrieve the accounting code of the social contribution of the payment from link of payment. |
| 427 | 427 | // Note: We have the social contribution id, it can be faster to get accounting code from social contribution id. |
| 428 | 428 | $sqlmid = "SELECT cchgsoc.accountancy_code"; |
| 429 | - $sqlmid .= " FROM ".MAIN_DB_PREFIX."c_chargesociales cchgsoc"; |
|
| 430 | - $sqlmid .= " INNER JOIN ".MAIN_DB_PREFIX."chargesociales as chgsoc ON chgsoc.fk_type = cchgsoc.id"; |
|
| 431 | - $sqlmid .= " INNER JOIN ".MAIN_DB_PREFIX."paiementcharge as paycharg ON paycharg.fk_charge = chgsoc.rowid"; |
|
| 432 | - $sqlmid .= " INNER JOIN ".MAIN_DB_PREFIX."bank_url as bkurl ON bkurl.url_id=paycharg.rowid AND bkurl.type = 'payment_sc'"; |
|
| 433 | - $sqlmid .= " WHERE bkurl.fk_bank = ".((int) $obj->rowid); |
|
| 429 | + $sqlmid .= " FROM " . MAIN_DB_PREFIX . "c_chargesociales cchgsoc"; |
|
| 430 | + $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "chargesociales as chgsoc ON chgsoc.fk_type = cchgsoc.id"; |
|
| 431 | + $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiementcharge as paycharg ON paycharg.fk_charge = chgsoc.rowid"; |
|
| 432 | + $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "bank_url as bkurl ON bkurl.url_id=paycharg.rowid AND bkurl.type = 'payment_sc'"; |
|
| 433 | + $sqlmid .= " WHERE bkurl.fk_bank = " . ((int) $obj->rowid); |
|
| 434 | 434 | |
| 435 | - dol_syslog("accountancy/journal/bankjournal.php:: sqlmid=".$sqlmid, LOG_DEBUG); |
|
| 435 | + dol_syslog("accountancy/journal/bankjournal.php:: sqlmid=" . $sqlmid, LOG_DEBUG); |
|
| 436 | 436 | $resultmid = $db->query($sqlmid); |
| 437 | 437 | if ($resultmid) { |
| 438 | 438 | $objmid = $db->fetch_object($resultmid); |
@@ -442,14 +442,14 @@ discard block |
||
| 442 | 442 | $paymentdonstatic->id = $links[$key]['url_id']; |
| 443 | 443 | $paymentdonstatic->ref = $links[$key]['url_id']; |
| 444 | 444 | $paymentdonstatic->fk_donation = $links[$key]['url_id']; |
| 445 | - $tabpay[$obj->rowid]["lib"] .= ' '.$paymentdonstatic->getNomUrl(2); |
|
| 445 | + $tabpay[$obj->rowid]["lib"] .= ' ' . $paymentdonstatic->getNomUrl(2); |
|
| 446 | 446 | $tabpay[$obj->rowid]["paymentdonationid"] = $paymentdonstatic->id; |
| 447 | 447 | $tabtp[$obj->rowid][$account_pay_donation] += $amounttouse; |
| 448 | 448 | } elseif ($links[$key]['type'] == 'member') { |
| 449 | 449 | $paymentsubscriptionstatic->id = $links[$key]['url_id']; |
| 450 | 450 | $paymentsubscriptionstatic->ref = $links[$key]['url_id']; |
| 451 | 451 | $paymentsubscriptionstatic->label = $links[$key]['label']; |
| 452 | - $tabpay[$obj->rowid]["lib"] .= ' '.$paymentsubscriptionstatic->getNomUrl(2); |
|
| 452 | + $tabpay[$obj->rowid]["lib"] .= ' ' . $paymentsubscriptionstatic->getNomUrl(2); |
|
| 453 | 453 | $tabpay[$obj->rowid]["paymentsubscriptionid"] = $paymentsubscriptionstatic->id; |
| 454 | 454 | $paymentsubscriptionstatic->fetch($paymentsubscriptionstatic->id); |
| 455 | 455 | $tabtp[$obj->rowid][$account_pay_subscription] += $amounttouse; |
@@ -457,14 +457,14 @@ discard block |
||
| 457 | 457 | $paymentvatstatic->id = $links[$key]['url_id']; |
| 458 | 458 | $paymentvatstatic->ref = $links[$key]['url_id']; |
| 459 | 459 | $paymentvatstatic->label = $links[$key]['label']; |
| 460 | - $tabpay[$obj->rowid]["lib"] .= ' '.$paymentvatstatic->getNomUrl(2); |
|
| 460 | + $tabpay[$obj->rowid]["lib"] .= ' ' . $paymentvatstatic->getNomUrl(2); |
|
| 461 | 461 | $tabpay[$obj->rowid]["paymentvatid"] = $paymentvatstatic->id; |
| 462 | 462 | $tabtp[$obj->rowid][$account_pay_vat] += $amounttouse; |
| 463 | 463 | } elseif ($links[$key]['type'] == 'payment_salary') { |
| 464 | 464 | $paymentsalstatic->id = $links[$key]['url_id']; |
| 465 | 465 | $paymentsalstatic->ref = $links[$key]['url_id']; |
| 466 | 466 | $paymentsalstatic->label = $links[$key]['label']; |
| 467 | - $tabpay[$obj->rowid]["lib"] .= ' '.$paymentsalstatic->getNomUrl(2); |
|
| 467 | + $tabpay[$obj->rowid]["lib"] .= ' ' . $paymentsalstatic->getNomUrl(2); |
|
| 468 | 468 | $tabpay[$obj->rowid]["paymentsalid"] = $paymentsalstatic->id; |
| 469 | 469 | |
| 470 | 470 | // 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. |
@@ -512,7 +512,7 @@ discard block |
||
| 512 | 512 | $paymentvariousstatic->id = $links[$key]['url_id']; |
| 513 | 513 | $paymentvariousstatic->ref = $links[$key]['url_id']; |
| 514 | 514 | $paymentvariousstatic->label = $links[$key]['label']; |
| 515 | - $tabpay[$obj->rowid]["lib"] .= ' '.$paymentvariousstatic->getNomUrl(2); |
|
| 515 | + $tabpay[$obj->rowid]["lib"] .= ' ' . $paymentvariousstatic->getNomUrl(2); |
|
| 516 | 516 | $tabpay[$obj->rowid]["paymentvariousid"] = $paymentvariousstatic->id; |
| 517 | 517 | $paymentvariousstatic->fetch($paymentvariousstatic->id); |
| 518 | 518 | $account_various = (!empty($paymentvariousstatic->accountancy_code) ? $paymentvariousstatic->accountancy_code : 'NotDefined'); // NotDefined is a reserved word |
@@ -523,14 +523,14 @@ discard block |
||
| 523 | 523 | $paymentloanstatic->id = $links[$key]['url_id']; |
| 524 | 524 | $paymentloanstatic->ref = $links[$key]['url_id']; |
| 525 | 525 | $paymentloanstatic->fk_loan = $links[$key]['url_id']; |
| 526 | - $tabpay[$obj->rowid]["lib"] .= ' '.$paymentloanstatic->getNomUrl(2); |
|
| 526 | + $tabpay[$obj->rowid]["lib"] .= ' ' . $paymentloanstatic->getNomUrl(2); |
|
| 527 | 527 | $tabpay[$obj->rowid]["paymentloanid"] = $paymentloanstatic->id; |
| 528 | 528 | //$tabtp[$obj->rowid][$account_pay_loan] += $amounttouse; |
| 529 | 529 | $sqlmid = 'SELECT pl.amount_capital, pl.amount_insurance, pl.amount_interest, l.accountancy_account_capital, l.accountancy_account_insurance, l.accountancy_account_interest'; |
| 530 | - $sqlmid .= ' FROM '.MAIN_DB_PREFIX.'payment_loan as pl, '.MAIN_DB_PREFIX.'loan as l'; |
|
| 531 | - $sqlmid .= ' WHERE l.rowid = pl.fk_loan AND pl.fk_bank = '.((int) $obj->rowid); |
|
| 530 | + $sqlmid .= ' FROM ' . MAIN_DB_PREFIX . 'payment_loan as pl, ' . MAIN_DB_PREFIX . 'loan as l'; |
|
| 531 | + $sqlmid .= ' WHERE l.rowid = pl.fk_loan AND pl.fk_bank = ' . ((int) $obj->rowid); |
|
| 532 | 532 | |
| 533 | - dol_syslog("accountancy/journal/bankjournal.php:: sqlmid=".$sqlmid, LOG_DEBUG); |
|
| 533 | + dol_syslog("accountancy/journal/bankjournal.php:: sqlmid=" . $sqlmid, LOG_DEBUG); |
|
| 534 | 534 | $resultmid = $db->query($sqlmid); |
| 535 | 535 | if ($resultmid) { |
| 536 | 536 | $objmid = $db->fetch_object($resultmid); |
@@ -540,7 +540,7 @@ discard block |
||
| 540 | 540 | } |
| 541 | 541 | } elseif ($links[$key]['type'] == 'banktransfert') { |
| 542 | 542 | $accountLinestatic->fetch($links[$key]['url_id']); |
| 543 | - $tabpay[$obj->rowid]["lib"] .= ' '.$langs->trans("BankTransfer").'- '.$accountLinestatic ->getNomUrl(1); |
|
| 543 | + $tabpay[$obj->rowid]["lib"] .= ' ' . $langs->trans("BankTransfer") . '- ' . $accountLinestatic ->getNomUrl(1); |
|
| 544 | 544 | $tabtp[$obj->rowid][$account_transfer] += $amounttouse; |
| 545 | 545 | $bankaccountstatic->fetch($tabpay[$obj->rowid]['fk_bank_account']); |
| 546 | 546 | $tabpay[$obj->rowid]["soclib"] = $bankaccountstatic->getNomUrl(2); |
@@ -653,16 +653,16 @@ discard block |
||
| 653 | 653 | // Line into bank account |
| 654 | 654 | foreach ($tabbq[$key] as $k => $mt) { |
| 655 | 655 | if ($mt) { |
| 656 | - $accountingaccount->fetch(null, $k, true); // $k is accounting bank account. TODO We should use a cache here to avoid this fetch |
|
| 656 | + $accountingaccount->fetch(null, $k, true); // $k is accounting bank account. TODO We should use a cache here to avoid this fetch |
|
| 657 | 657 | $account_label = $accountingaccount->label; |
| 658 | 658 | |
| 659 | 659 | $reflabel = ''; |
| 660 | 660 | if (!empty($val['lib'])) { |
| 661 | - $reflabel .= dol_string_nohtmltag($val['lib'])." - "; |
|
| 661 | + $reflabel .= dol_string_nohtmltag($val['lib']) . " - "; |
|
| 662 | 662 | } |
| 663 | - $reflabel .= $langs->trans("Bank").' '.dol_string_nohtmltag($val['bank_account_ref']); |
|
| 663 | + $reflabel .= $langs->trans("Bank") . ' ' . dol_string_nohtmltag($val['bank_account_ref']); |
|
| 664 | 664 | if (!empty($val['soclib'])) { |
| 665 | - $reflabel .= " - ".dol_string_nohtmltag($val['soclib']); |
|
| 665 | + $reflabel .= " - " . dol_string_nohtmltag($val['soclib']); |
|
| 666 | 666 | } |
| 667 | 667 | |
| 668 | 668 | $bookkeeping = new BookKeeping($db); |
@@ -698,7 +698,7 @@ discard block |
||
| 698 | 698 | if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') { // Already exists |
| 699 | 699 | $error++; |
| 700 | 700 | $errorforline++; |
| 701 | - setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings'); |
|
| 701 | + setEventMessages('Transaction for (' . $bookkeeping->doc_type . ', ' . $bookkeeping->fk_doc . ', ' . $bookkeeping->fk_docdet . ') were already recorded', null, 'warnings'); |
|
| 702 | 702 | } else { |
| 703 | 703 | $error++; |
| 704 | 704 | $errorforline++; |
@@ -719,10 +719,10 @@ discard block |
||
| 719 | 719 | |
| 720 | 720 | $reflabel = ''; |
| 721 | 721 | if (!empty($val['lib'])) { |
| 722 | - $reflabel .= dol_string_nohtmltag($val['lib']).($val['soclib'] ? " - " : ""); |
|
| 722 | + $reflabel .= dol_string_nohtmltag($val['lib']) . ($val['soclib'] ? " - " : ""); |
|
| 723 | 723 | } |
| 724 | 724 | if ($tabtype[$key] == 'banktransfert') { |
| 725 | - $reflabel .= dol_string_nohtmltag($langs->transnoentitiesnoconv('TransitionalAccount').' '.$account_transfer); |
|
| 725 | + $reflabel .= dol_string_nohtmltag($langs->transnoentitiesnoconv('TransitionalAccount') . ' ' . $account_transfer); |
|
| 726 | 726 | } else { |
| 727 | 727 | $reflabel .= dol_string_nohtmltag($val['soclib']); |
| 728 | 728 | } |
@@ -769,43 +769,43 @@ discard block |
||
| 769 | 769 | } elseif (in_array($tabtype[$key], array('sc', 'payment_sc'))) { // If payment is payment of social contribution |
| 770 | 770 | $bookkeeping->subledger_account = ''; |
| 771 | 771 | $bookkeeping->subledger_label = ''; |
| 772 | - $accountingaccount->fetch(null, $k, true); // TODO Use a cache |
|
| 772 | + $accountingaccount->fetch(null, $k, true); // TODO Use a cache |
|
| 773 | 773 | $bookkeeping->numero_compte = $k; |
| 774 | 774 | $bookkeeping->label_compte = $accountingaccount->label; |
| 775 | 775 | } elseif ($tabtype[$key] == 'payment_vat') { |
| 776 | 776 | $bookkeeping->subledger_account = ''; |
| 777 | 777 | $bookkeeping->subledger_label = ''; |
| 778 | - $accountingaccount->fetch(null, $k, true); // TODO Use a cache |
|
| 778 | + $accountingaccount->fetch(null, $k, true); // TODO Use a cache |
|
| 779 | 779 | $bookkeeping->numero_compte = $k; |
| 780 | 780 | $bookkeeping->label_compte = $accountingaccount->label; |
| 781 | 781 | } elseif ($tabtype[$key] == 'payment_donation') { |
| 782 | 782 | $bookkeeping->subledger_account = ''; |
| 783 | 783 | $bookkeeping->subledger_label = ''; |
| 784 | - $accountingaccount->fetch(null, $k, true); // TODO Use a cache |
|
| 784 | + $accountingaccount->fetch(null, $k, true); // TODO Use a cache |
|
| 785 | 785 | $bookkeeping->numero_compte = $k; |
| 786 | 786 | $bookkeeping->label_compte = $accountingaccount->label; |
| 787 | 787 | } elseif ($tabtype[$key] == 'member') { |
| 788 | 788 | $bookkeeping->subledger_account = ''; |
| 789 | 789 | $bookkeeping->subledger_label = ''; |
| 790 | - $accountingaccount->fetch(null, $k, true); // TODO Use a cache |
|
| 790 | + $accountingaccount->fetch(null, $k, true); // TODO Use a cache |
|
| 791 | 791 | $bookkeeping->numero_compte = $k; |
| 792 | 792 | $bookkeeping->label_compte = $accountingaccount->label; |
| 793 | 793 | } elseif ($tabtype[$key] == 'payment_loan') { |
| 794 | 794 | $bookkeeping->subledger_account = ''; |
| 795 | 795 | $bookkeeping->subledger_label = ''; |
| 796 | - $accountingaccount->fetch(null, $k, true); // TODO Use a cache |
|
| 796 | + $accountingaccount->fetch(null, $k, true); // TODO Use a cache |
|
| 797 | 797 | $bookkeeping->numero_compte = $k; |
| 798 | 798 | $bookkeeping->label_compte = $accountingaccount->label; |
| 799 | 799 | } elseif ($tabtype[$key] == 'payment_various') { |
| 800 | 800 | $bookkeeping->subledger_account = $k; |
| 801 | 801 | $bookkeeping->subledger_label = $tabcompany[$key]['name']; |
| 802 | - $accountingaccount->fetch(null, $tabpay[$key]["account_various"], true); // TODO Use a cache |
|
| 802 | + $accountingaccount->fetch(null, $tabpay[$key]["account_various"], true); // TODO Use a cache |
|
| 803 | 803 | $bookkeeping->numero_compte = $tabpay[$key]["account_various"]; |
| 804 | 804 | $bookkeeping->label_compte = $accountingaccount->label; |
| 805 | 805 | } elseif ($tabtype[$key] == 'banktransfert') { |
| 806 | 806 | $bookkeeping->subledger_account = ''; |
| 807 | 807 | $bookkeeping->subledger_label = ''; |
| 808 | - $accountingaccount->fetch(null, $k, true); // TODO Use a cache |
|
| 808 | + $accountingaccount->fetch(null, $k, true); // TODO Use a cache |
|
| 809 | 809 | $bookkeeping->numero_compte = $k; |
| 810 | 810 | $bookkeeping->label_compte = $accountingaccount->label; |
| 811 | 811 | } else { |
@@ -828,7 +828,7 @@ discard block |
||
| 828 | 828 | if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') { // Already exists |
| 829 | 829 | $error++; |
| 830 | 830 | $errorforline++; |
| 831 | - setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings'); |
|
| 831 | + setEventMessages('Transaction for (' . $bookkeeping->doc_type . ', ' . $bookkeeping->fk_doc . ', ' . $bookkeeping->fk_docdet . ') were already recorded', null, 'warnings'); |
|
| 832 | 832 | } else { |
| 833 | 833 | $error++; |
| 834 | 834 | $errorforline++; |
@@ -848,7 +848,7 @@ discard block |
||
| 848 | 848 | if ($mt) { |
| 849 | 849 | $reflabel = ''; |
| 850 | 850 | if (!empty($val['lib'])) { |
| 851 | - $reflabel .= dol_string_nohtmltag($val['lib'])." - "; |
|
| 851 | + $reflabel .= dol_string_nohtmltag($val['lib']) . " - "; |
|
| 852 | 852 | } |
| 853 | 853 | $reflabel .= dol_string_nohtmltag('WaitingAccount'); |
| 854 | 854 | |
@@ -879,7 +879,7 @@ discard block |
||
| 879 | 879 | if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') { // Already exists |
| 880 | 880 | $error++; |
| 881 | 881 | $errorforline++; |
| 882 | - setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings'); |
|
| 882 | + setEventMessages('Transaction for (' . $bookkeeping->doc_type . ', ' . $bookkeeping->fk_doc . ', ' . $bookkeeping->fk_docdet . ') were already recorded', null, 'warnings'); |
|
| 883 | 883 | } else { |
| 884 | 884 | $error++; |
| 885 | 885 | $errorforline++; |
@@ -894,7 +894,7 @@ discard block |
||
| 894 | 894 | if (price2num($totaldebit, 'MT') != price2num($totalcredit, 'MT')) { |
| 895 | 895 | $error++; |
| 896 | 896 | $errorforline++; |
| 897 | - setEventMessages('We tried to insert a non balanced transaction in book for '.$ref.'. Canceled. Surely a bug.', null, 'errors'); |
|
| 897 | + setEventMessages('We tried to insert a non balanced transaction in book for ' . $ref . '. Canceled. Surely a bug.', null, 'errors'); |
|
| 898 | 898 | } |
| 899 | 899 | |
| 900 | 900 | if (!$errorforline) { |
@@ -905,7 +905,7 @@ discard block |
||
| 905 | 905 | |
| 906 | 906 | $MAXNBERRORS = 5; |
| 907 | 907 | if ($error >= $MAXNBERRORS) { |
| 908 | - setEventMessages($langs->trans("ErrorTooManyErrorsProcessStopped").' (>'.$MAXNBERRORS.')', null, 'errors'); |
|
| 908 | + setEventMessages($langs->trans("ErrorTooManyErrorsProcessStopped") . ' (>' . $MAXNBERRORS . ')', null, 'errors'); |
|
| 909 | 909 | break; // Break in the foreach |
| 910 | 910 | } |
| 911 | 911 | } |
@@ -923,15 +923,15 @@ discard block |
||
| 923 | 923 | |
| 924 | 924 | // Must reload data, so we make a redirect |
| 925 | 925 | if (count($tabpay) != $error) { |
| 926 | - $param = 'id_journal='.$id_journal; |
|
| 927 | - $param .= '&date_startday='.$date_startday; |
|
| 928 | - $param .= '&date_startmonth='.$date_startmonth; |
|
| 929 | - $param .= '&date_startyear='.$date_startyear; |
|
| 930 | - $param .= '&date_endday='.$date_endday; |
|
| 931 | - $param .= '&date_endmonth='.$date_endmonth; |
|
| 932 | - $param .= '&date_endyear='.$date_endyear; |
|
| 933 | - $param .= '&in_bookkeeping='.$in_bookkeeping; |
|
| 934 | - header("Location: ".$_SERVER['PHP_SELF'].($param ? '?'.$param : '')); |
|
| 926 | + $param = 'id_journal=' . $id_journal; |
|
| 927 | + $param .= '&date_startday=' . $date_startday; |
|
| 928 | + $param .= '&date_startmonth=' . $date_startmonth; |
|
| 929 | + $param .= '&date_startyear=' . $date_startyear; |
|
| 930 | + $param .= '&date_endday=' . $date_endday; |
|
| 931 | + $param .= '&date_endmonth=' . $date_endmonth; |
|
| 932 | + $param .= '&date_endyear=' . $date_endyear; |
|
| 933 | + $param .= '&in_bookkeeping=' . $in_bookkeeping; |
|
| 934 | + header("Location: " . $_SERVER['PHP_SELF'] . ($param ? '?' . $param : '')); |
|
| 935 | 935 | exit; |
| 936 | 936 | } |
| 937 | 937 | } |
@@ -944,20 +944,20 @@ discard block |
||
| 944 | 944 | |
| 945 | 945 | $filename = 'journal'; |
| 946 | 946 | $type_export = 'journal'; |
| 947 | - include DOL_DOCUMENT_ROOT.'/accountancy/tpl/export_journal.tpl.php'; |
|
| 947 | + include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php'; |
|
| 948 | 948 | |
| 949 | 949 | // CSV header line |
| 950 | - print '"'.$langs->transnoentitiesnoconv("BankId").'"'.$sep; |
|
| 951 | - print '"'.$langs->transnoentitiesnoconv("Date").'"'.$sep; |
|
| 952 | - print '"'.$langs->transnoentitiesnoconv("PaymentMode").'"'.$sep; |
|
| 953 | - print '"'.$langs->transnoentitiesnoconv("AccountAccounting").'"'.$sep; |
|
| 954 | - print '"'.$langs->transnoentitiesnoconv("LedgerAccount").'"'.$sep; |
|
| 955 | - print '"'.$langs->transnoentitiesnoconv("SubledgerAccount").'"'.$sep; |
|
| 956 | - print '"'.$langs->transnoentitiesnoconv("Label").'"'.$sep; |
|
| 957 | - print '"'.$langs->transnoentitiesnoconv("AccountingDebit").'"'.$sep; |
|
| 958 | - print '"'.$langs->transnoentitiesnoconv("AccountingCredit").'"'.$sep; |
|
| 959 | - print '"'.$langs->transnoentitiesnoconv("Journal").'"'.$sep; |
|
| 960 | - print '"'.$langs->transnoentitiesnoconv("Note").'"'.$sep; |
|
| 950 | + print '"' . $langs->transnoentitiesnoconv("BankId") . '"' . $sep; |
|
| 951 | + print '"' . $langs->transnoentitiesnoconv("Date") . '"' . $sep; |
|
| 952 | + print '"' . $langs->transnoentitiesnoconv("PaymentMode") . '"' . $sep; |
|
| 953 | + print '"' . $langs->transnoentitiesnoconv("AccountAccounting") . '"' . $sep; |
|
| 954 | + print '"' . $langs->transnoentitiesnoconv("LedgerAccount") . '"' . $sep; |
|
| 955 | + print '"' . $langs->transnoentitiesnoconv("SubledgerAccount") . '"' . $sep; |
|
| 956 | + print '"' . $langs->transnoentitiesnoconv("Label") . '"' . $sep; |
|
| 957 | + print '"' . $langs->transnoentitiesnoconv("AccountingDebit") . '"' . $sep; |
|
| 958 | + print '"' . $langs->transnoentitiesnoconv("AccountingCredit") . '"' . $sep; |
|
| 959 | + print '"' . $langs->transnoentitiesnoconv("Journal") . '"' . $sep; |
|
| 960 | + print '"' . $langs->transnoentitiesnoconv("Note") . '"' . $sep; |
|
| 961 | 961 | print "\n"; |
| 962 | 962 | |
| 963 | 963 | foreach ($tabpay as $key => $val) { |
@@ -970,24 +970,24 @@ discard block |
||
| 970 | 970 | if ($mt) { |
| 971 | 971 | $reflabel = ''; |
| 972 | 972 | if (!empty($val['lib'])) { |
| 973 | - $reflabel .= dol_string_nohtmltag($val['lib'])." - "; |
|
| 973 | + $reflabel .= dol_string_nohtmltag($val['lib']) . " - "; |
|
| 974 | 974 | } |
| 975 | - $reflabel .= $langs->trans("Bank").' '.dol_string_nohtmltag($val['bank_account_ref']); |
|
| 975 | + $reflabel .= $langs->trans("Bank") . ' ' . dol_string_nohtmltag($val['bank_account_ref']); |
|
| 976 | 976 | if (!empty($val['soclib'])) { |
| 977 | - $reflabel .= " - ".dol_string_nohtmltag($val['soclib']); |
|
| 977 | + $reflabel .= " - " . dol_string_nohtmltag($val['soclib']); |
|
| 978 | 978 | } |
| 979 | 979 | |
| 980 | - print '"'.$key.'"'.$sep; |
|
| 981 | - print '"'.$date.'"'.$sep; |
|
| 982 | - print '"'.$val["type_payment"].'"'.$sep; |
|
| 983 | - print '"'.length_accountg(html_entity_decode($k)).'"'.$sep; |
|
| 984 | - print '"'.length_accounta(html_entity_decode($k)).'"'.$sep; |
|
| 985 | - print " ".$sep; |
|
| 986 | - print '"'.$reflabel.'"'.$sep; |
|
| 987 | - print '"'.($mt >= 0 ? price($mt) : '').'"'.$sep; |
|
| 988 | - print '"'.($mt < 0 ? price(-$mt) : '').'"'.$sep; |
|
| 989 | - print '"'.$journal.'"'.$sep; |
|
| 990 | - print '"'.dol_string_nohtmltag($ref).'"'.$sep; |
|
| 980 | + print '"' . $key . '"' . $sep; |
|
| 981 | + print '"' . $date . '"' . $sep; |
|
| 982 | + print '"' . $val["type_payment"] . '"' . $sep; |
|
| 983 | + print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep; |
|
| 984 | + print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep; |
|
| 985 | + print " " . $sep; |
|
| 986 | + print '"' . $reflabel . '"' . $sep; |
|
| 987 | + print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep; |
|
| 988 | + print '"' . ($mt < 0 ? price(-$mt) : '') . '"' . $sep; |
|
| 989 | + print '"' . $journal . '"' . $sep; |
|
| 990 | + print '"' . dol_string_nohtmltag($ref) . '"' . $sep; |
|
| 991 | 991 | print "\n"; |
| 992 | 992 | } |
| 993 | 993 | } |
@@ -998,35 +998,35 @@ discard block |
||
| 998 | 998 | if ($mt) { |
| 999 | 999 | $reflabel = ''; |
| 1000 | 1000 | if (!empty($val['lib'])) { |
| 1001 | - $reflabel .= dol_string_nohtmltag($val['lib']).($val['soclib'] ? " - " : ""); |
|
| 1001 | + $reflabel .= dol_string_nohtmltag($val['lib']) . ($val['soclib'] ? " - " : ""); |
|
| 1002 | 1002 | } |
| 1003 | 1003 | if ($tabtype[$key] == 'banktransfert') { |
| 1004 | - $reflabel .= dol_string_nohtmltag($langs->transnoentitiesnoconv('TransitionalAccount').' '.$account_transfer); |
|
| 1004 | + $reflabel .= dol_string_nohtmltag($langs->transnoentitiesnoconv('TransitionalAccount') . ' ' . $account_transfer); |
|
| 1005 | 1005 | } else { |
| 1006 | 1006 | $reflabel .= dol_string_nohtmltag($val['soclib']); |
| 1007 | 1007 | } |
| 1008 | 1008 | |
| 1009 | - print '"'.$key.'"'.$sep; |
|
| 1010 | - print '"'.$date.'"'.$sep; |
|
| 1011 | - print '"'.$val["type_payment"].'"'.$sep; |
|
| 1012 | - print '"'.length_accountg(html_entity_decode($k)).'"'.$sep; |
|
| 1009 | + print '"' . $key . '"' . $sep; |
|
| 1010 | + print '"' . $date . '"' . $sep; |
|
| 1011 | + print '"' . $val["type_payment"] . '"' . $sep; |
|
| 1012 | + print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep; |
|
| 1013 | 1013 | if ($tabtype[$key] == 'payment_supplier') { |
| 1014 | - print '"'.getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER').'"'.$sep; |
|
| 1014 | + print '"' . getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER') . '"' . $sep; |
|
| 1015 | 1015 | } elseif ($tabtype[$key] == 'payment') { |
| 1016 | - print '"'.getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER').'"'.$sep; |
|
| 1016 | + print '"' . getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER') . '"' . $sep; |
|
| 1017 | 1017 | } elseif ($tabtype[$key] == 'payment_expensereport') { |
| 1018 | - print '"'.getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT').'"'.$sep; |
|
| 1018 | + print '"' . getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT') . '"' . $sep; |
|
| 1019 | 1019 | } elseif ($tabtype[$key] == 'payment_salary') { |
| 1020 | - print '"'.getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT').'"'.$sep; |
|
| 1020 | + print '"' . getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT') . '"' . $sep; |
|
| 1021 | 1021 | } else { |
| 1022 | - print '"'.length_accountg(html_entity_decode($k)).'"'.$sep; |
|
| 1022 | + print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep; |
|
| 1023 | 1023 | } |
| 1024 | - print '"'.length_accounta(html_entity_decode($k)).'"'.$sep; |
|
| 1025 | - print '"'.$reflabel.'"'.$sep; |
|
| 1026 | - print '"'.($mt < 0 ? price(-$mt) : '').'"'.$sep; |
|
| 1027 | - print '"'.($mt >= 0 ? price($mt) : '').'"'.$sep; |
|
| 1028 | - print '"'.$journal.'"'.$sep; |
|
| 1029 | - print '"'.dol_string_nohtmltag($ref).'"'.$sep; |
|
| 1024 | + print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep; |
|
| 1025 | + print '"' . $reflabel . '"' . $sep; |
|
| 1026 | + print '"' . ($mt < 0 ? price(-$mt) : '') . '"' . $sep; |
|
| 1027 | + print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep; |
|
| 1028 | + print '"' . $journal . '"' . $sep; |
|
| 1029 | + print '"' . dol_string_nohtmltag($ref) . '"' . $sep; |
|
| 1030 | 1030 | print "\n"; |
| 1031 | 1031 | } |
| 1032 | 1032 | } |
@@ -1035,21 +1035,21 @@ discard block |
||
| 1035 | 1035 | if ($mt) { |
| 1036 | 1036 | $reflabel = ''; |
| 1037 | 1037 | if (!empty($val['lib'])) { |
| 1038 | - $reflabel .= dol_string_nohtmltag($val['lib'])." - "; |
|
| 1038 | + $reflabel .= dol_string_nohtmltag($val['lib']) . " - "; |
|
| 1039 | 1039 | } |
| 1040 | 1040 | $reflabel .= dol_string_nohtmltag('WaitingAccount'); |
| 1041 | 1041 | |
| 1042 | - print '"'.$key.'"'.$sep; |
|
| 1043 | - print '"'.$date.'"'.$sep; |
|
| 1044 | - print '"'.$val["type_payment"].'"'.$sep; |
|
| 1045 | - print '"'.length_accountg(getDolGlobalString('ACCOUNTING_ACCOUNT_SUSPENSE')).'"'.$sep; |
|
| 1046 | - print '"'.length_accounta(getDolGlobalString('ACCOUNTING_ACCOUNT_SUSPENSE')).'"'.$sep; |
|
| 1042 | + print '"' . $key . '"' . $sep; |
|
| 1043 | + print '"' . $date . '"' . $sep; |
|
| 1044 | + print '"' . $val["type_payment"] . '"' . $sep; |
|
| 1045 | + print '"' . length_accountg(getDolGlobalString('ACCOUNTING_ACCOUNT_SUSPENSE')) . '"' . $sep; |
|
| 1046 | + print '"' . length_accounta(getDolGlobalString('ACCOUNTING_ACCOUNT_SUSPENSE')) . '"' . $sep; |
|
| 1047 | 1047 | print $sep; |
| 1048 | - print '"'.$reflabel.'"'.$sep; |
|
| 1049 | - print '"'.($mt < 0 ? price(-$mt) : '').'"'.$sep; |
|
| 1050 | - print '"'.($mt >= 0 ? price($mt) : '').'"'.$sep; |
|
| 1051 | - print '"'.$journal.'"'.$sep; |
|
| 1052 | - print '"'.dol_string_nohtmltag($ref).'"'.$sep; |
|
| 1048 | + print '"' . $reflabel . '"' . $sep; |
|
| 1049 | + print '"' . ($mt < 0 ? price(-$mt) : '') . '"' . $sep; |
|
| 1050 | + print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep; |
|
| 1051 | + print '"' . $journal . '"' . $sep; |
|
| 1052 | + print '"' . dol_string_nohtmltag($ref) . '"' . $sep; |
|
| 1053 | 1053 | print "\n"; |
| 1054 | 1054 | } |
| 1055 | 1055 | } |
@@ -1074,23 +1074,23 @@ discard block |
||
| 1074 | 1074 | $salarystatic = new Salary($db); |
| 1075 | 1075 | $variousstatic = new PaymentVarious($db); |
| 1076 | 1076 | |
| 1077 | - $title = $langs->trans("GenerationOfAccountingEntries").' - '.$accountingjournalstatic->getNomUrl(0, 2, 1, '', 1); |
|
| 1077 | + $title = $langs->trans("GenerationOfAccountingEntries") . ' - ' . $accountingjournalstatic->getNomUrl(0, 2, 1, '', 1); |
|
| 1078 | 1078 | |
| 1079 | 1079 | llxHeader('', dol_string_nohtmltag($title)); |
| 1080 | 1080 | |
| 1081 | 1081 | $nom = $title; |
| 1082 | 1082 | $builddate = dol_now(); |
| 1083 | 1083 | //$description = $langs->trans("DescFinanceJournal") . '<br>'; |
| 1084 | - $description = $langs->trans("DescJournalOnlyBindedVisible").'<br>'; |
|
| 1084 | + $description = $langs->trans("DescJournalOnlyBindedVisible") . '<br>'; |
|
| 1085 | 1085 | |
| 1086 | 1086 | $listofchoices = array( |
| 1087 | 1087 | 'notyet' => $langs->trans("NotYetInGeneralLedger"), |
| 1088 | 1088 | 'already' => $langs->trans("AlreadyInGeneralLedger") |
| 1089 | 1089 | ); |
| 1090 | - $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); |
|
| 1091 | - $period .= ' - '.$langs->trans("JournalizationInLedgerStatus").' '.$form->selectarray('in_bookkeeping', $listofchoices, $in_bookkeeping, 1); |
|
| 1090 | + $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); |
|
| 1091 | + $period .= ' - ' . $langs->trans("JournalizationInLedgerStatus") . ' ' . $form->selectarray('in_bookkeeping', $listofchoices, $in_bookkeeping, 1); |
|
| 1092 | 1092 | |
| 1093 | - $varlink = 'id_journal='.$id_journal; |
|
| 1093 | + $varlink = 'id_journal=' . $id_journal; |
|
| 1094 | 1094 | $periodlink = ''; |
| 1095 | 1095 | $exportlink = ''; |
| 1096 | 1096 | |
@@ -1101,14 +1101,14 @@ discard block |
||
| 1101 | 1101 | if (getDolGlobalString('ACCOUNTANCY_FISCAL_PERIOD_MODE') != 'blockedonclosed') { |
| 1102 | 1102 | // Test that setup is complete (we are in accounting, so test on entity is always on $conf->entity only, no sharing allowed) |
| 1103 | 1103 | // Fiscal period test |
| 1104 | - $sql = "SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX."accounting_fiscalyear WHERE entity = ".((int) $conf->entity); |
|
| 1104 | + $sql = "SELECT COUNT(rowid) as nb FROM " . MAIN_DB_PREFIX . "accounting_fiscalyear WHERE entity = " . ((int) $conf->entity); |
|
| 1105 | 1105 | $resql = $db->query($sql); |
| 1106 | 1106 | if ($resql) { |
| 1107 | 1107 | $obj = $db->fetch_object($resql); |
| 1108 | 1108 | if ($obj->nb == 0) { |
| 1109 | - print '<br><div class="warning">'.img_warning().' '.$langs->trans("TheFiscalPeriodIsNotDefined"); |
|
| 1110 | - $desc = ' : '.$langs->trans("AccountancyAreaDescFiscalPeriod", 4, '{link}'); |
|
| 1111 | - $desc = str_replace('{link}', '<strong>'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("FiscalPeriod").'</strong>', $desc); |
|
| 1109 | + print '<br><div class="warning">' . img_warning() . ' ' . $langs->trans("TheFiscalPeriodIsNotDefined"); |
|
| 1110 | + $desc = ' : ' . $langs->trans("AccountancyAreaDescFiscalPeriod", 4, '{link}'); |
|
| 1111 | + $desc = str_replace('{link}', '<strong>' . $langs->transnoentitiesnoconv("MenuAccountancy") . '-' . $langs->transnoentitiesnoconv("Setup") . "-" . $langs->transnoentitiesnoconv("FiscalPeriod") . '</strong>', $desc); |
|
| 1112 | 1112 | print $desc; |
| 1113 | 1113 | print '</div>'; |
| 1114 | 1114 | } |
@@ -1118,14 +1118,14 @@ discard block |
||
| 1118 | 1118 | } |
| 1119 | 1119 | |
| 1120 | 1120 | // Bank test |
| 1121 | - $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"; |
|
| 1121 | + $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"; |
|
| 1122 | 1122 | $resql = $db->query($sql); |
| 1123 | 1123 | if ($resql) { |
| 1124 | 1124 | $obj = $db->fetch_object($resql); |
| 1125 | 1125 | if ($obj->nb > 0) { |
| 1126 | - print '<br><div class="warning">'.img_warning().' '.$langs->trans("TheJournalCodeIsNotDefinedOnSomeBankAccount"); |
|
| 1127 | - $desc = ' : '.$langs->trans("AccountancyAreaDescBank", 6, '{link}'); |
|
| 1128 | - $desc = str_replace('{link}', '<strong>'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("BankAccounts").'</strong>', $desc); |
|
| 1126 | + print '<br><div class="warning">' . img_warning() . ' ' . $langs->trans("TheJournalCodeIsNotDefinedOnSomeBankAccount"); |
|
| 1127 | + $desc = ' : ' . $langs->trans("AccountancyAreaDescBank", 6, '{link}'); |
|
| 1128 | + $desc = str_replace('{link}', '<strong>' . $langs->transnoentitiesnoconv("MenuAccountancy") . '-' . $langs->transnoentitiesnoconv("Setup") . "-" . $langs->transnoentitiesnoconv("BankAccounts") . '</strong>', $desc); |
|
| 1129 | 1129 | print $desc; |
| 1130 | 1130 | print '</div>'; |
| 1131 | 1131 | } |
@@ -1138,9 +1138,9 @@ discard block |
||
| 1138 | 1138 | if (getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER') == "" || getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER') == '-1' |
| 1139 | 1139 | || getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER') == "" || getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER') == '-1' |
| 1140 | 1140 | || getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT') == "" || getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT') == '-1') { |
| 1141 | - print($desc ? '' : '<br>').'<div class="warning">'.img_warning().' '.$langs->trans("SomeMandatoryStepsOfSetupWereNotDone"); |
|
| 1142 | - $desc = ' : '.$langs->trans("AccountancyAreaDescMisc", 4, '{link}'); |
|
| 1143 | - $desc = str_replace('{link}', '<strong>'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("MenuDefaultAccounts").'</strong>', $desc); |
|
| 1141 | + print($desc ? '' : '<br>') . '<div class="warning">' . img_warning() . ' ' . $langs->trans("SomeMandatoryStepsOfSetupWereNotDone"); |
|
| 1142 | + $desc = ' : ' . $langs->trans("AccountancyAreaDescMisc", 4, '{link}'); |
|
| 1143 | + $desc = str_replace('{link}', '<strong>' . $langs->transnoentitiesnoconv("MenuAccountancy") . '-' . $langs->transnoentitiesnoconv("Setup") . "-" . $langs->transnoentitiesnoconv("MenuDefaultAccounts") . '</strong>', $desc); |
|
| 1144 | 1144 | print $desc; |
| 1145 | 1145 | print '</div>'; |
| 1146 | 1146 | } |
@@ -1149,17 +1149,17 @@ discard block |
||
| 1149 | 1149 | print '<br><div class="tabsAction tabsActionNoBottom centerimp">'; |
| 1150 | 1150 | |
| 1151 | 1151 | if (getDolGlobalString('ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL') && $in_bookkeeping == 'notyet') { |
| 1152 | - print '<input type="button" class="butAction" name="exportcsv" value="'.$langs->trans("ExportDraftJournal").'" onclick="launch_export();" />'; |
|
| 1152 | + print '<input type="button" class="butAction" name="exportcsv" value="' . $langs->trans("ExportDraftJournal") . '" onclick="launch_export();" />'; |
|
| 1153 | 1153 | } |
| 1154 | 1154 | |
| 1155 | 1155 | if (getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER') == "" || getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER') == '-1' |
| 1156 | 1156 | || getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER') == "" || getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER') == '-1') { |
| 1157 | - print '<input type="button" class="butActionRefused classfortooltip" title="'.dol_escape_htmltag($langs->trans("SomeMandatoryStepsOfSetupWereNotDone")).'" value="'.$langs->trans("WriteBookKeeping").'" />'; |
|
| 1157 | + print '<input type="button" class="butActionRefused classfortooltip" title="' . dol_escape_htmltag($langs->trans("SomeMandatoryStepsOfSetupWereNotDone")) . '" value="' . $langs->trans("WriteBookKeeping") . '" />'; |
|
| 1158 | 1158 | } else { |
| 1159 | 1159 | if ($in_bookkeeping == 'notyet') { |
| 1160 | - print '<input type="button" class="butAction" name="writebookkeeping" value="'.$langs->trans("WriteBookKeeping").'" onclick="writebookkeeping();" />'; |
|
| 1160 | + print '<input type="button" class="butAction" name="writebookkeeping" value="' . $langs->trans("WriteBookKeeping") . '" onclick="writebookkeeping();" />'; |
|
| 1161 | 1161 | } else { |
| 1162 | - print '<a class="butActionRefused classfortooltip" name="writebookkeeping">'.$langs->trans("WriteBookKeeping").'</a>'; |
|
| 1162 | + print '<a class="butActionRefused classfortooltip" name="writebookkeeping">' . $langs->trans("WriteBookKeeping") . '</a>'; |
|
| 1163 | 1163 | } |
| 1164 | 1164 | } |
| 1165 | 1165 | |
@@ -1191,14 +1191,14 @@ discard block |
||
| 1191 | 1191 | print '<div class="div-table-responsive">'; |
| 1192 | 1192 | print '<table class="noborder centpercent">'; |
| 1193 | 1193 | print '<tr class="liste_titre">'; |
| 1194 | - print "<td>".$langs->trans("Date")."</td>"; |
|
| 1195 | - print "<td>".$langs->trans("Piece").' ('.$langs->trans("ObjectsRef").")</td>"; |
|
| 1196 | - print "<td>".$langs->trans("AccountAccounting")."</td>"; |
|
| 1197 | - print "<td>".$langs->trans("SubledgerAccount")."</td>"; |
|
| 1198 | - print "<td>".$langs->trans("LabelOperation")."</td>"; |
|
| 1199 | - print '<td class="center">'.$langs->trans("PaymentMode")."</td>"; |
|
| 1200 | - print '<td class="right">'.$langs->trans("AccountingDebit")."</td>"; |
|
| 1201 | - print '<td class="right">'.$langs->trans("AccountingCredit")."</td>"; |
|
| 1194 | + print "<td>" . $langs->trans("Date") . "</td>"; |
|
| 1195 | + print "<td>" . $langs->trans("Piece") . ' (' . $langs->trans("ObjectsRef") . ")</td>"; |
|
| 1196 | + print "<td>" . $langs->trans("AccountAccounting") . "</td>"; |
|
| 1197 | + print "<td>" . $langs->trans("SubledgerAccount") . "</td>"; |
|
| 1198 | + print "<td>" . $langs->trans("LabelOperation") . "</td>"; |
|
| 1199 | + print '<td class="center">' . $langs->trans("PaymentMode") . "</td>"; |
|
| 1200 | + print '<td class="right">' . $langs->trans("AccountingDebit") . "</td>"; |
|
| 1201 | + print '<td class="right">' . $langs->trans("AccountingCredit") . "</td>"; |
|
| 1202 | 1202 | print "</tr>\n"; |
| 1203 | 1203 | |
| 1204 | 1204 | $r = ''; |
@@ -1213,29 +1213,29 @@ discard block |
||
| 1213 | 1213 | if ($mt) { |
| 1214 | 1214 | $reflabel = ''; |
| 1215 | 1215 | if (!empty($val['lib'])) { |
| 1216 | - $reflabel .= $val['lib']." - "; |
|
| 1216 | + $reflabel .= $val['lib'] . " - "; |
|
| 1217 | 1217 | } |
| 1218 | - $reflabel .= $langs->trans("Bank").' '.$val['bank_account_ref']; |
|
| 1218 | + $reflabel .= $langs->trans("Bank") . ' ' . $val['bank_account_ref']; |
|
| 1219 | 1219 | if (!empty($val['soclib'])) { |
| 1220 | - $reflabel .= " - ".$val['soclib']; |
|
| 1220 | + $reflabel .= " - " . $val['soclib']; |
|
| 1221 | 1221 | } |
| 1222 | 1222 | |
| 1223 | 1223 | //var_dump($tabpay[$key]); |
| 1224 | - print '<!-- Bank bank.rowid='.$key.' type='.$tabpay[$key]['type'].' ref='.$tabpay[$key]['ref'].'-->'; |
|
| 1224 | + print '<!-- Bank bank.rowid=' . $key . ' type=' . $tabpay[$key]['type'] . ' ref=' . $tabpay[$key]['ref'] . '-->'; |
|
| 1225 | 1225 | print '<tr class="oddeven">'; |
| 1226 | 1226 | |
| 1227 | 1227 | // Date |
| 1228 | - print "<td>".$date."</td>"; |
|
| 1228 | + print "<td>" . $date . "</td>"; |
|
| 1229 | 1229 | |
| 1230 | 1230 | // Ref |
| 1231 | - print "<td>".dol_escape_htmltag($ref)."</td>"; |
|
| 1231 | + print "<td>" . dol_escape_htmltag($ref) . "</td>"; |
|
| 1232 | 1232 | |
| 1233 | 1233 | // Ledger account |
| 1234 | 1234 | $accounttoshow = length_accountg($k); |
| 1235 | 1235 | if (empty($accounttoshow) || $accounttoshow == 'NotDefined') { |
| 1236 | - $accounttoshow = '<span class="error">'.$langs->trans("BankAccountNotDefined").'</span>'; |
|
| 1236 | + $accounttoshow = '<span class="error">' . $langs->trans("BankAccountNotDefined") . '</span>'; |
|
| 1237 | 1237 | } |
| 1238 | - print '<td class="maxwidth300" title="'.dol_escape_htmltag(dol_string_nohtmltag($accounttoshow)).'">'; |
|
| 1238 | + print '<td class="maxwidth300" title="' . dol_escape_htmltag(dol_string_nohtmltag($accounttoshow)) . '">'; |
|
| 1239 | 1239 | print $accounttoshow; |
| 1240 | 1240 | print "</td>"; |
| 1241 | 1241 | |
@@ -1251,12 +1251,12 @@ discard block |
||
| 1251 | 1251 | |
| 1252 | 1252 | // Label operation |
| 1253 | 1253 | print '<td>'; |
| 1254 | - print $reflabel; // This is already html escaped content |
|
| 1254 | + print $reflabel; // This is already html escaped content |
|
| 1255 | 1255 | print "</td>"; |
| 1256 | 1256 | |
| 1257 | - print '<td class="center">'.$val["type_payment"]."</td>"; |
|
| 1258 | - print '<td class="right nowraponall amount">'.($mt >= 0 ? price($mt) : '')."</td>"; |
|
| 1259 | - print '<td class="right nowraponall amount">'.($mt < 0 ? price(-$mt) : '')."</td>"; |
|
| 1257 | + print '<td class="center">' . $val["type_payment"] . "</td>"; |
|
| 1258 | + print '<td class="right nowraponall amount">' . ($mt >= 0 ? price($mt) : '') . "</td>"; |
|
| 1259 | + print '<td class="right nowraponall amount">' . ($mt < 0 ? price(-$mt) : '') . "</td>"; |
|
| 1260 | 1260 | print "</tr>"; |
| 1261 | 1261 | |
| 1262 | 1262 | $i++; |
@@ -1269,22 +1269,22 @@ discard block |
||
| 1269 | 1269 | if ($mt) { |
| 1270 | 1270 | $reflabel = ''; |
| 1271 | 1271 | if (!empty($val['lib'])) { |
| 1272 | - $reflabel .= $val['lib'].($val['soclib'] ? " - " : ""); |
|
| 1272 | + $reflabel .= $val['lib'] . ($val['soclib'] ? " - " : ""); |
|
| 1273 | 1273 | } |
| 1274 | 1274 | if ($tabtype[$key] == 'banktransfert') { |
| 1275 | - $reflabel .= $langs->trans('TransitionalAccount').' '.$account_transfer; |
|
| 1275 | + $reflabel .= $langs->trans('TransitionalAccount') . ' ' . $account_transfer; |
|
| 1276 | 1276 | } else { |
| 1277 | 1277 | $reflabel .= $val['soclib']; |
| 1278 | 1278 | } |
| 1279 | 1279 | |
| 1280 | - print '<!-- Thirdparty bank.rowid='.$key.' -->'; |
|
| 1280 | + print '<!-- Thirdparty bank.rowid=' . $key . ' -->'; |
|
| 1281 | 1281 | print '<tr class="oddeven">'; |
| 1282 | 1282 | |
| 1283 | 1283 | // Date |
| 1284 | - print "<td>".$date."</td>"; |
|
| 1284 | + print "<td>" . $date . "</td>"; |
|
| 1285 | 1285 | |
| 1286 | 1286 | // Ref |
| 1287 | - print "<td>".dol_escape_htmltag($ref)."</td>"; |
|
| 1287 | + print "<td>" . dol_escape_htmltag($ref) . "</td>"; |
|
| 1288 | 1288 | |
| 1289 | 1289 | // Ledger account |
| 1290 | 1290 | $account_ledger = $k; |
@@ -1315,9 +1315,9 @@ discard block |
||
| 1315 | 1315 | if ($tabtype[$key] == 'unknown') { |
| 1316 | 1316 | // We will accept writing, but into a waiting account |
| 1317 | 1317 | if (!getDolGlobalString('ACCOUNTING_ACCOUNT_SUSPENSE') || getDolGlobalString('ACCOUNTING_ACCOUNT_SUSPENSE') == '-1') { |
| 1318 | - $accounttoshow = '<span class="error small">'.$langs->trans('UnknownAccountForThirdpartyAndWaitingAccountNotDefinedBlocking').'</span>'; |
|
| 1318 | + $accounttoshow = '<span class="error small">' . $langs->trans('UnknownAccountForThirdpartyAndWaitingAccountNotDefinedBlocking') . '</span>'; |
|
| 1319 | 1319 | } else { |
| 1320 | - $accounttoshow = '<span class="warning small">'.$langs->trans('UnknownAccountForThirdparty', length_accountg(getDolGlobalString('ACCOUNTING_ACCOUNT_SUSPENSE'))).'</span>'; // We will use a waiting account |
|
| 1320 | + $accounttoshow = '<span class="warning small">' . $langs->trans('UnknownAccountForThirdparty', length_accountg(getDolGlobalString('ACCOUNTING_ACCOUNT_SUSPENSE'))) . '</span>'; // We will use a waiting account |
|
| 1321 | 1321 | } |
| 1322 | 1322 | } else { |
| 1323 | 1323 | // We will refuse writing |
@@ -1340,11 +1340,11 @@ discard block |
||
| 1340 | 1340 | if ($tabtype[$key] == 'member') { |
| 1341 | 1341 | $errorstring = 'MainAccountForSubscriptionPaymentNotDefined'; |
| 1342 | 1342 | } |
| 1343 | - $accounttoshow = '<span class="error small">'.$langs->trans($errorstring).'</span>'; |
|
| 1343 | + $accounttoshow = '<span class="error small">' . $langs->trans($errorstring) . '</span>'; |
|
| 1344 | 1344 | } |
| 1345 | 1345 | } |
| 1346 | - print '<td class="maxwidth300" title="'.dol_escape_htmltag(dol_string_nohtmltag($accounttoshow)).'">'; |
|
| 1347 | - print $accounttoshow; // This is a HTML string |
|
| 1346 | + print '<td class="maxwidth300" title="' . dol_escape_htmltag(dol_string_nohtmltag($accounttoshow)) . '">'; |
|
| 1347 | + print $accounttoshow; // This is a HTML string |
|
| 1348 | 1348 | print "</td>"; |
| 1349 | 1349 | |
| 1350 | 1350 | // Subledger account |
@@ -1360,12 +1360,12 @@ discard block |
||
| 1360 | 1360 | if (!empty($tabcompany[$key]['code_compta'])) { |
| 1361 | 1361 | if (in_array($tabtype[$key], array('payment_various', 'payment_salary'))) { |
| 1362 | 1362 | // For such case, if subledger is not defined, we won't use subledger accounts. |
| 1363 | - $accounttoshowsubledger = '<span class="warning small">'.$langs->trans("ThirdpartyAccountNotDefinedOrThirdPartyUnknownSubledgerIgnored").'</span>'; |
|
| 1363 | + $accounttoshowsubledger = '<span class="warning small">' . $langs->trans("ThirdpartyAccountNotDefinedOrThirdPartyUnknownSubledgerIgnored") . '</span>'; |
|
| 1364 | 1364 | } else { |
| 1365 | - $accounttoshowsubledger = '<span class="warning small">'.$langs->trans("ThirdpartyAccountNotDefinedOrThirdPartyUnknown", $tabcompany[$key]['code_compta']).'</span>'; |
|
| 1365 | + $accounttoshowsubledger = '<span class="warning small">' . $langs->trans("ThirdpartyAccountNotDefinedOrThirdPartyUnknown", $tabcompany[$key]['code_compta']) . '</span>'; |
|
| 1366 | 1366 | } |
| 1367 | 1367 | } else { |
| 1368 | - $accounttoshowsubledger = '<span class="error small">'.$langs->trans("ThirdpartyAccountNotDefinedOrThirdPartyUnknownBlocking").'</span>'; |
|
| 1368 | + $accounttoshowsubledger = '<span class="error small">' . $langs->trans("ThirdpartyAccountNotDefinedOrThirdPartyUnknownBlocking") . '</span>'; |
|
| 1369 | 1369 | } |
| 1370 | 1370 | } |
| 1371 | 1371 | } else { |
@@ -1373,16 +1373,16 @@ discard block |
||
| 1373 | 1373 | } |
| 1374 | 1374 | } |
| 1375 | 1375 | print '<td class="maxwidth300">'; |
| 1376 | - print $accounttoshowsubledger; // This is a html string |
|
| 1376 | + print $accounttoshowsubledger; // This is a html string |
|
| 1377 | 1377 | print "</td>"; |
| 1378 | 1378 | |
| 1379 | - print "<td>".$reflabel."</td>"; |
|
| 1379 | + print "<td>" . $reflabel . "</td>"; |
|
| 1380 | 1380 | |
| 1381 | - print '<td class="center">'.$val["type_payment"]."</td>"; |
|
| 1381 | + print '<td class="center">' . $val["type_payment"] . "</td>"; |
|
| 1382 | 1382 | |
| 1383 | - print '<td class="right nowraponall amount">'.($mt < 0 ? price(-$mt) : '')."</td>"; |
|
| 1383 | + print '<td class="right nowraponall amount">' . ($mt < 0 ? price(-$mt) : '') . "</td>"; |
|
| 1384 | 1384 | |
| 1385 | - print '<td class="right nowraponall amount">'.($mt >= 0 ? price($mt) : '')."</td>"; |
|
| 1385 | + print '<td class="right nowraponall amount">' . ($mt >= 0 ? price($mt) : '') . "</td>"; |
|
| 1386 | 1386 | |
| 1387 | 1387 | print "</tr>"; |
| 1388 | 1388 | |
@@ -1394,14 +1394,14 @@ discard block |
||
| 1394 | 1394 | if ($mt) { |
| 1395 | 1395 | $reflabel = ''; |
| 1396 | 1396 | if (!empty($val['lib'])) { |
| 1397 | - $reflabel .= $val['lib']." - "; |
|
| 1397 | + $reflabel .= $val['lib'] . " - "; |
|
| 1398 | 1398 | } |
| 1399 | 1399 | $reflabel .= 'WaitingAccount'; |
| 1400 | 1400 | |
| 1401 | - print '<!-- Wait bank.rowid='.$key.' -->'; |
|
| 1401 | + print '<!-- Wait bank.rowid=' . $key . ' -->'; |
|
| 1402 | 1402 | print '<tr class="oddeven">'; |
| 1403 | - print "<td>".$date."</td>"; |
|
| 1404 | - print "<td>".$ref."</td>"; |
|
| 1403 | + print "<td>" . $date . "</td>"; |
|
| 1404 | + print "<td>" . $ref . "</td>"; |
|
| 1405 | 1405 | // Ledger account |
| 1406 | 1406 | print "<td>"; |
| 1407 | 1407 | /*if (empty($accounttoshow) || $accounttoshow == 'NotDefined') |
@@ -1414,10 +1414,10 @@ discard block |
||
| 1414 | 1414 | // Subledger account |
| 1415 | 1415 | print "<td>"; |
| 1416 | 1416 | print "</td>"; |
| 1417 | - print "<td>".dol_escape_htmltag($reflabel)."</td>"; |
|
| 1418 | - print '<td class="center">'.$val["type_payment"]."</td>"; |
|
| 1419 | - print '<td class="right nowraponall amount">'.($mt < 0 ? price(-$mt) : '')."</td>"; |
|
| 1420 | - print '<td class="right nowraponall amount">'.($mt >= 0 ? price($mt) : '')."</td>"; |
|
| 1417 | + print "<td>" . dol_escape_htmltag($reflabel) . "</td>"; |
|
| 1418 | + print '<td class="center">' . $val["type_payment"] . "</td>"; |
|
| 1419 | + print '<td class="right nowraponall amount">' . ($mt < 0 ? price(-$mt) : '') . "</td>"; |
|
| 1420 | + print '<td class="right nowraponall amount">' . ($mt >= 0 ? price($mt) : '') . "</td>"; |
|
| 1421 | 1421 | print "</tr>"; |
| 1422 | 1422 | |
| 1423 | 1423 | $i++; |
@@ -1428,7 +1428,7 @@ discard block |
||
| 1428 | 1428 | |
| 1429 | 1429 | if (!$i) { |
| 1430 | 1430 | $colspan = 8; |
| 1431 | - print '<tr class="oddeven"><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>'; |
|
| 1431 | + print '<tr class="oddeven"><td colspan="' . $colspan . '"><span class="opacitymedium">' . $langs->trans("NoRecordFound") . '</span></td></tr>'; |
|
| 1432 | 1432 | } |
| 1433 | 1433 | |
| 1434 | 1434 | print "</table>"; |
@@ -1483,77 +1483,77 @@ discard block |
||
| 1483 | 1483 | $sqlmid = ''; |
| 1484 | 1484 | if ($typerecord == 'payment') { |
| 1485 | 1485 | if (getDolGlobalInt('FACTURE_DEPOSITS_ARE_JUST_PAYMENTS')) { |
| 1486 | - $sqlmid = "SELECT payfac.fk_facture as id, ".$db->ifsql('f1.rowid IS NULL', 'f.ref', 'f1.ref')." as ref"; |
|
| 1487 | - $sqlmid .= " FROM ".$db->prefix()."paiement_facture as payfac"; |
|
| 1488 | - $sqlmid .= " LEFT JOIN ".$db->prefix()."facture as f ON f.rowid = payfac.fk_facture"; |
|
| 1489 | - $sqlmid .= " LEFT JOIN ".$db->prefix()."societe_remise_except as sre ON sre.fk_facture_source = payfac.fk_facture"; |
|
| 1490 | - $sqlmid .= " LEFT JOIN ".$db->prefix()."facture as f1 ON f1.rowid = sre.fk_facture"; |
|
| 1491 | - $sqlmid .= " WHERE payfac.fk_paiement=".((int) $val['paymentid']); |
|
| 1486 | + $sqlmid = "SELECT payfac.fk_facture as id, " . $db->ifsql('f1.rowid IS NULL', 'f.ref', 'f1.ref') . " as ref"; |
|
| 1487 | + $sqlmid .= " FROM " . $db->prefix() . "paiement_facture as payfac"; |
|
| 1488 | + $sqlmid .= " LEFT JOIN " . $db->prefix() . "facture as f ON f.rowid = payfac.fk_facture"; |
|
| 1489 | + $sqlmid .= " LEFT JOIN " . $db->prefix() . "societe_remise_except as sre ON sre.fk_facture_source = payfac.fk_facture"; |
|
| 1490 | + $sqlmid .= " LEFT JOIN " . $db->prefix() . "facture as f1 ON f1.rowid = sre.fk_facture"; |
|
| 1491 | + $sqlmid .= " WHERE payfac.fk_paiement=" . ((int) $val['paymentid']); |
|
| 1492 | 1492 | } else { |
| 1493 | 1493 | $sqlmid = "SELECT payfac.fk_facture as id, f.ref as ref"; |
| 1494 | - $sqlmid .= " FROM ".$db->prefix()."paiement_facture as payfac"; |
|
| 1495 | - $sqlmid .= " INNER JOIN ".$db->prefix()."facture as f ON f.rowid = payfac.fk_facture"; |
|
| 1496 | - $sqlmid .= " WHERE payfac.fk_paiement=".((int) $val['paymentid']); |
|
| 1494 | + $sqlmid .= " FROM " . $db->prefix() . "paiement_facture as payfac"; |
|
| 1495 | + $sqlmid .= " INNER JOIN " . $db->prefix() . "facture as f ON f.rowid = payfac.fk_facture"; |
|
| 1496 | + $sqlmid .= " WHERE payfac.fk_paiement=" . ((int) $val['paymentid']); |
|
| 1497 | 1497 | } |
| 1498 | 1498 | $ref = $langs->transnoentitiesnoconv("Invoice"); |
| 1499 | 1499 | } elseif ($typerecord == 'payment_supplier') { |
| 1500 | 1500 | $sqlmid = 'SELECT payfac.fk_facturefourn as id, f.ref'; |
| 1501 | - $sqlmid .= " FROM ".MAIN_DB_PREFIX."paiementfourn_facturefourn as payfac, ".MAIN_DB_PREFIX."facture_fourn as f"; |
|
| 1502 | - $sqlmid .= " WHERE payfac.fk_facturefourn = f.rowid AND payfac.fk_paiementfourn=".((int) $val["paymentsupplierid"]); |
|
| 1501 | + $sqlmid .= " FROM " . MAIN_DB_PREFIX . "paiementfourn_facturefourn as payfac, " . MAIN_DB_PREFIX . "facture_fourn as f"; |
|
| 1502 | + $sqlmid .= " WHERE payfac.fk_facturefourn = f.rowid AND payfac.fk_paiementfourn=" . ((int) $val["paymentsupplierid"]); |
|
| 1503 | 1503 | $ref = $langs->transnoentitiesnoconv("SupplierInvoice"); |
| 1504 | 1504 | } elseif ($typerecord == 'payment_expensereport') { |
| 1505 | 1505 | $sqlmid = 'SELECT e.rowid as id, e.ref'; |
| 1506 | - $sqlmid .= " FROM ".MAIN_DB_PREFIX."payment_expensereport as pe, ".MAIN_DB_PREFIX."expensereport as e"; |
|
| 1507 | - $sqlmid .= " WHERE pe.rowid=".((int) $val["paymentexpensereport"])." AND pe.fk_expensereport = e.rowid"; |
|
| 1506 | + $sqlmid .= " FROM " . MAIN_DB_PREFIX . "payment_expensereport as pe, " . MAIN_DB_PREFIX . "expensereport as e"; |
|
| 1507 | + $sqlmid .= " WHERE pe.rowid=" . ((int) $val["paymentexpensereport"]) . " AND pe.fk_expensereport = e.rowid"; |
|
| 1508 | 1508 | $ref = $langs->transnoentitiesnoconv("ExpenseReport"); |
| 1509 | 1509 | } elseif ($typerecord == 'payment_salary') { |
| 1510 | 1510 | $sqlmid = 'SELECT s.rowid as ref'; |
| 1511 | - $sqlmid .= " FROM ".MAIN_DB_PREFIX."payment_salary as s"; |
|
| 1512 | - $sqlmid .= " WHERE s.rowid=".((int) $val["paymentsalid"]); |
|
| 1511 | + $sqlmid .= " FROM " . MAIN_DB_PREFIX . "payment_salary as s"; |
|
| 1512 | + $sqlmid .= " WHERE s.rowid=" . ((int) $val["paymentsalid"]); |
|
| 1513 | 1513 | $ref = $langs->transnoentitiesnoconv("SalaryPayment"); |
| 1514 | 1514 | } elseif ($typerecord == 'sc') { |
| 1515 | 1515 | $sqlmid = 'SELECT sc.rowid as ref'; |
| 1516 | - $sqlmid .= " FROM ".MAIN_DB_PREFIX."paiementcharge as sc"; |
|
| 1517 | - $sqlmid .= " WHERE sc.rowid=".((int) $val["paymentscid"]); |
|
| 1516 | + $sqlmid .= " FROM " . MAIN_DB_PREFIX . "paiementcharge as sc"; |
|
| 1517 | + $sqlmid .= " WHERE sc.rowid=" . ((int) $val["paymentscid"]); |
|
| 1518 | 1518 | $ref = $langs->transnoentitiesnoconv("SocialContribution"); |
| 1519 | 1519 | } elseif ($typerecord == 'payment_vat') { |
| 1520 | 1520 | $sqlmid = 'SELECT v.rowid as ref'; |
| 1521 | - $sqlmid .= " FROM ".MAIN_DB_PREFIX."tva as v"; |
|
| 1522 | - $sqlmid .= " WHERE v.rowid=".((int) $val["paymentvatid"]); |
|
| 1521 | + $sqlmid .= " FROM " . MAIN_DB_PREFIX . "tva as v"; |
|
| 1522 | + $sqlmid .= " WHERE v.rowid=" . ((int) $val["paymentvatid"]); |
|
| 1523 | 1523 | $ref = $langs->transnoentitiesnoconv("PaymentVat"); |
| 1524 | 1524 | } elseif ($typerecord == 'payment_donation') { |
| 1525 | 1525 | $sqlmid = 'SELECT payd.fk_donation as ref'; |
| 1526 | - $sqlmid .= " FROM ".MAIN_DB_PREFIX."payment_donation as payd"; |
|
| 1527 | - $sqlmid .= " WHERE payd.fk_donation=".((int) $val["paymentdonationid"]); |
|
| 1526 | + $sqlmid .= " FROM " . MAIN_DB_PREFIX . "payment_donation as payd"; |
|
| 1527 | + $sqlmid .= " WHERE payd.fk_donation=" . ((int) $val["paymentdonationid"]); |
|
| 1528 | 1528 | $ref = $langs->transnoentitiesnoconv("Donation"); |
| 1529 | 1529 | } elseif ($typerecord == 'payment_loan') { |
| 1530 | 1530 | $sqlmid = 'SELECT l.rowid as ref'; |
| 1531 | - $sqlmid .= " FROM ".MAIN_DB_PREFIX."payment_loan as l"; |
|
| 1532 | - $sqlmid .= " WHERE l.rowid=".((int) $val["paymentloanid"]); |
|
| 1531 | + $sqlmid .= " FROM " . MAIN_DB_PREFIX . "payment_loan as l"; |
|
| 1532 | + $sqlmid .= " WHERE l.rowid=" . ((int) $val["paymentloanid"]); |
|
| 1533 | 1533 | $ref = $langs->transnoentitiesnoconv("LoanPayment"); |
| 1534 | 1534 | } elseif ($typerecord == 'payment_various') { |
| 1535 | 1535 | $sqlmid = 'SELECT v.rowid as ref'; |
| 1536 | - $sqlmid .= " FROM ".MAIN_DB_PREFIX."payment_various as v"; |
|
| 1537 | - $sqlmid .= " WHERE v.rowid=".((int) $val["paymentvariousid"]); |
|
| 1536 | + $sqlmid .= " FROM " . MAIN_DB_PREFIX . "payment_various as v"; |
|
| 1537 | + $sqlmid .= " WHERE v.rowid=" . ((int) $val["paymentvariousid"]); |
|
| 1538 | 1538 | $ref = $langs->transnoentitiesnoconv("VariousPayment"); |
| 1539 | 1539 | } |
| 1540 | 1540 | // Add warning |
| 1541 | 1541 | if (empty($sqlmid)) { |
| 1542 | - dol_syslog("Found a typerecord=".$typerecord." not supported", LOG_WARNING); |
|
| 1542 | + dol_syslog("Found a typerecord=" . $typerecord . " not supported", LOG_WARNING); |
|
| 1543 | 1543 | } |
| 1544 | 1544 | |
| 1545 | 1545 | if ($sqlmid) { |
| 1546 | - dol_syslog("accountancy/journal/bankjournal.php::sqlmid=".$sqlmid, LOG_DEBUG); |
|
| 1546 | + dol_syslog("accountancy/journal/bankjournal.php::sqlmid=" . $sqlmid, LOG_DEBUG); |
|
| 1547 | 1547 | $resultmid = $db->query($sqlmid); |
| 1548 | 1548 | if ($resultmid) { |
| 1549 | 1549 | while ($objmid = $db->fetch_object($resultmid)) { |
| 1550 | - $ref .= ' '.$objmid->ref; |
|
| 1550 | + $ref .= ' ' . $objmid->ref; |
|
| 1551 | 1551 | } |
| 1552 | 1552 | } else { |
| 1553 | 1553 | dol_print_error($db); |
| 1554 | 1554 | } |
| 1555 | 1555 | } |
| 1556 | 1556 | |
| 1557 | - $ref = dol_trunc($langs->transnoentitiesnoconv("BankId").' '.$val['fk_bank'].' - '.$ref, 295); // 295 + 3 dots (...) is < than max size of 300 |
|
| 1557 | + $ref = dol_trunc($langs->transnoentitiesnoconv("BankId") . ' ' . $val['fk_bank'] . ' - ' . $ref, 295); // 295 + 3 dots (...) is < than max size of 300 |
|
| 1558 | 1558 | return $ref; |
| 1559 | 1559 | } |