From 9f9b7554ed47bc38571b3eea68acd41d0c4febf7 Mon Sep 17 00:00:00 2001 From: atm-lena Date: Wed, 17 Feb 2021 11:00:14 +0100 Subject: [PATCH 1/5] FIX error commit : only type user --- htdocs/compta/bank/bankentries_list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/bank/bankentries_list.php b/htdocs/compta/bank/bankentries_list.php index a1cc5b5b121..99e6750101d 100644 --- a/htdocs/compta/bank/bankentries_list.php +++ b/htdocs/compta/bank/bankentries_list.php @@ -1406,7 +1406,7 @@ if ($resql) if($links[$key]['type'] == 'payment_salary') $type_link = 'payment_salary'; } - $sqlu = "SELECT url_id FROM ".MAIN_DB_PREFIX."bank_url WHERE fk_bank=".$objp->rowid." AND (type='user' OR type='salary')"; + $sqlu = "SELECT url_id FROM ".MAIN_DB_PREFIX."bank_url WHERE fk_bank=".$objp->rowid." AND type='user'"; $resqlu = $db->query($sqlu); if($resqlu) { From 9cdb6ce31c9002a34cf37eed8137c4a182b1462c Mon Sep 17 00:00:00 2001 From: atm-lena Date: Thu, 18 Feb 2021 17:35:09 +0100 Subject: [PATCH 2/5] WIP --- htdocs/compta/bank/bankentries_list.php | 28 +++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/htdocs/compta/bank/bankentries_list.php b/htdocs/compta/bank/bankentries_list.php index 99e6750101d..2b531634d37 100644 --- a/htdocs/compta/bank/bankentries_list.php +++ b/htdocs/compta/bank/bankentries_list.php @@ -476,9 +476,7 @@ else $sql = "SELECT b.rowid, b.dateo as do, b.datev as dv, b.amount, b.label, b.rappro as conciliated, b.num_releve, b.num_chq,"; $sql .= " b.fk_account, b.fk_type,"; -$sql .= " ba.rowid as bankid, ba.ref as bankref,"; -$sql .= " bu.url_id, bu.type as type_url,"; -$sql .= " s.nom, s.name_alias, s.client, s.fournisseur, s.email, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur"; +$sql .= " ba.rowid as bankid, ba.ref as bankref"; // Add fields from extrafields if (!empty($extrafields->attributes[$object->table_element]['label'])) { foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); @@ -492,8 +490,6 @@ if ($search_bid > 0) $sql .= MAIN_DB_PREFIX."bank_class as l,"; $sql .= " ".MAIN_DB_PREFIX."bank_account as ba,"; $sql .= " ".MAIN_DB_PREFIX."bank as b"; if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (b.rowid = ef.fk_object)"; -$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_url as bu ON bu.fk_bank = b.rowid AND type = 'company'"; -$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON bu.url_id = s.rowid"; $sql .= " WHERE b.fk_account = ba.rowid"; $sql .= " AND ba.entity IN (".getEntity('bank_account').")"; if ($search_account > 0) $sql .= " AND b.fk_account = ".$search_account; @@ -507,7 +503,22 @@ if ($search_ref) $sql .= natural_search("b.rowid", $search_ref, 1); if ($search_req_nb) $sql .= natural_search("b.num_chq", $search_req_nb); if ($search_num_releve) $sql .= natural_search("b.num_releve", $search_num_releve); if ($search_conciliated != '' && $search_conciliated != '-1') $sql .= " AND b.rappro = ".$search_conciliated; -if ($search_thirdparty_user) $sql .= natural_search(array("s.nom", "u.firstname", "u.lastname"), $search_thirdparty_user); +if ($search_thirdparty_user) { + + $sql.= " AND (b.rowid IN "; + $sql.= " ( SELECT bu.fk_bank FROM ".MAIN_DB_PREFIX."bank_url AS bu"; + $sql.= " JOIN ".MAIN_DB_PREFIX."bank AS b2 ON b2.rowid = bu.fk_bank"; + $sql.= " JOIN ".MAIN_DB_PREFIX."user AS subUser ON (bu.type = 'user' AND bu.url_id = subUser.rowid)"; + $sql.= " WHERE ". natural_search(array("subUser.firstname", "subUser.lastname"), $search_thirdparty_user, '', 1)."))"; + + $sql.= " OR b.rowid IN "; + $sql.= " ( SELECT bu.fk_bank FROM ".MAIN_DB_PREFIX."bank_url AS bu"; + $sql.= " JOIN ".MAIN_DB_PREFIX."bank AS b2 ON b2.rowid = bu.fk_bank"; + $sql.= " JOIN ".MAIN_DB_PREFIX."societe AS subSoc ON (bu.type = 'company' AND bu.url_id = subSoc.rowid)"; + $sql.= " WHERE ". natural_search(array("subSoc.nom"), $search_thirdparty_user, '', 1); + $sql.= ")"; + +} if ($search_description) { $search_description_to_use = $search_description; @@ -1009,6 +1020,11 @@ if ($resql) $objp = $db->fetch_object($resql); $links = $bankaccountstatic->get_url($objp->rowid); + $sqlbu = "SELECT url_id, 'type' FROM ".MAIN_DB_PREFIX."bank_url WHERE fk_bank =".$objp->rowid; + $resqlbu = $db->query($sqlbu); + + //TODO : récupérer les informations sur la société et le url_id et url_type : apparemment c'est que pour la société alors voir dans la partie "ThirdParty" !! + // If we are in a situation where we need/can show balance, we calculate the start of balance if (!$balancecalculated && (!empty($arrayfields['balancebefore']['checked']) || !empty($arrayfields['balance']['checked'])) && $mode_balance_ok) { From a4d9e3b9d35492336797ec03a2236edba81f0a99 Mon Sep 17 00:00:00 2001 From: atm-lena Date: Fri, 19 Feb 2021 09:33:28 +0100 Subject: [PATCH 3/5] WIP final --- htdocs/compta/bank/bankentries_list.php | 62 +++++++++---------------- 1 file changed, 21 insertions(+), 41 deletions(-) diff --git a/htdocs/compta/bank/bankentries_list.php b/htdocs/compta/bank/bankentries_list.php index 2b531634d37..92ca025a56c 100644 --- a/htdocs/compta/bank/bankentries_list.php +++ b/htdocs/compta/bank/bankentries_list.php @@ -1398,55 +1398,35 @@ if ($resql) if (!empty($arrayfields['bu.label']['checked'])) { print ''; - if ($objp->url_id) //display company - { - if($objp->type_url == 'company') { - $companystatic->id = $objp->url_id; - $companystatic->name = $objp->nom; - $companystatic->name_alias = $objp->name_alias; - $companystatic->client = $objp->client; - $companystatic->email = $objp->email; - $companystatic->fournisseur = $objp->fournisseur; - $companystatic->code_client = $objp->code_client; - $companystatic->code_fournisseur = $objp->code_fournisseur; - $companystatic->code_compta = $objp->code_compta; - $companystatic->code_compta_fournisseur = $objp->code_compta_fournisseur; - print $companystatic->getNomUrl(1); - } - } - else //display user or nothing - { + + $companylinked = 0; + $userlinked = 0; + //payment line type to define user display foreach($links as $key=>$value){ if($links[$key]['type'] == 'payment_sc') $type_link = 'payment_sc'; if($links[$key]['type'] == 'payment_salary') $type_link = 'payment_salary'; + + if($links[$key]['type'] == 'company') { + $companylinked = $links[$key]['url_id']; + } + if($links[$key]['type'] == 'user') { + $userlinked = $links[$key]['url_id']; + } } - $sqlu = "SELECT url_id FROM ".MAIN_DB_PREFIX."bank_url WHERE fk_bank=".$objp->rowid." AND type='user'"; - $resqlu = $db->query($sqlu); - - if($resqlu) { - - if($db->num_rows($resqlu) > 0 && - (($type_link == 'payment_salary' && !empty($user->rights->salaries->read)) - || ($type_link == 'payment_sc' && !empty($user->rights->tax->charges->lire)))) { - - $obj = $db->fetch_object($resqlu); - $userstatic->fetch($obj->url_id); - print $userstatic->getNomUrl(1); - - } - - else { - print ' '; - } - - } else - { - dol_print_error($db); + if($companylinked) { + $companystatic->fetch($companylinked); + print $companystatic->getNomUrl(1); + } elseif($userlinked && + (($type_link == 'payment_salary' && !empty($user->rights->salaries->read)) + || ($type_link == 'payment_sc' && !empty($user->rights->tax->charges->lire)))){ + $userstatic->fetch($userlinked); + print $userstatic->getNomUrl(1); + } else { + print ' '; } - } print ''; if (!$i) $totalarray['nbfield']++; } From d7c59edd117550c428b17c98f54aef93f9e6f532 Mon Sep 17 00:00:00 2001 From: atm-lena Date: Fri, 19 Feb 2021 09:36:15 +0100 Subject: [PATCH 4/5] Clean code --- htdocs/compta/bank/bankentries_list.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/htdocs/compta/bank/bankentries_list.php b/htdocs/compta/bank/bankentries_list.php index 92ca025a56c..2cca6f3de40 100644 --- a/htdocs/compta/bank/bankentries_list.php +++ b/htdocs/compta/bank/bankentries_list.php @@ -1399,8 +1399,8 @@ if ($resql) { print ''; - $companylinked = 0; - $userlinked = 0; + $companylinked_id = 0; + $userlinked_id = 0; //payment line type to define user display foreach($links as $key=>$value){ @@ -1408,20 +1408,20 @@ if ($resql) if($links[$key]['type'] == 'payment_salary') $type_link = 'payment_salary'; if($links[$key]['type'] == 'company') { - $companylinked = $links[$key]['url_id']; + $companylinked_id = $links[$key]['url_id']; } if($links[$key]['type'] == 'user') { - $userlinked = $links[$key]['url_id']; + $userlinked_id = $links[$key]['url_id']; } } - if($companylinked) { - $companystatic->fetch($companylinked); + if($companylinked_id) { + $companystatic->fetch($companylinked_id); print $companystatic->getNomUrl(1); - } elseif($userlinked && + } elseif($userlinked_id && (($type_link == 'payment_salary' && !empty($user->rights->salaries->read)) || ($type_link == 'payment_sc' && !empty($user->rights->tax->charges->lire)))){ - $userstatic->fetch($userlinked); + $userstatic->fetch($userlinked_id); print $userstatic->getNomUrl(1); } else { print ' '; From 687d0556aa07f60a2a5beb6f351e00cd101f26cc Mon Sep 17 00:00:00 2001 From: atm-lena Date: Fri, 19 Feb 2021 09:39:06 +0100 Subject: [PATCH 5/5] Clean code --- htdocs/compta/bank/bankentries_list.php | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/htdocs/compta/bank/bankentries_list.php b/htdocs/compta/bank/bankentries_list.php index 2cca6f3de40..374fbf85fcc 100644 --- a/htdocs/compta/bank/bankentries_list.php +++ b/htdocs/compta/bank/bankentries_list.php @@ -1020,11 +1020,6 @@ if ($resql) $objp = $db->fetch_object($resql); $links = $bankaccountstatic->get_url($objp->rowid); - $sqlbu = "SELECT url_id, 'type' FROM ".MAIN_DB_PREFIX."bank_url WHERE fk_bank =".$objp->rowid; - $resqlbu = $db->query($sqlbu); - - //TODO : récupérer les informations sur la société et le url_id et url_type : apparemment c'est que pour la société alors voir dans la partie "ThirdParty" !! - // If we are in a situation where we need/can show balance, we calculate the start of balance if (!$balancecalculated && (!empty($arrayfields['balancebefore']['checked']) || !empty($arrayfields['balance']['checked'])) && $mode_balance_ok) { @@ -1402,7 +1397,7 @@ if ($resql) $companylinked_id = 0; $userlinked_id = 0; - //payment line type to define user display + //payment line type to define user display and user or company linked foreach($links as $key=>$value){ if($links[$key]['type'] == 'payment_sc') $type_link = 'payment_sc'; if($links[$key]['type'] == 'payment_salary') $type_link = 'payment_salary';