From 02af7ca25eaeaae0f56acb88e02e7ec257cbb86f Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Sat, 18 May 2019 12:11:28 +0200 Subject: [PATCH 1/6] fix pb with multicompny payment dictionnary on faxcture card --- htdocs/commande/class/commande.class.php | 2 +- htdocs/compta/facture/card.php | 2 +- htdocs/core/class/html.form.class.php | 5 ++--- htdocs/projet/class/project.class.php | 10 ++++++++-- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 38a38d45b12..d2012870a31 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -1685,7 +1685,7 @@ class Commande extends CommonOrder $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_payment_term as cr ON c.fk_cond_reglement = cr.rowid'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as p ON c.fk_mode_reglement = p.id'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_availability as ca ON c.fk_availability = ca.rowid'; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_input_reason as dr ON c.fk_input_reason = ca.rowid'; + $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_input_reason as dr ON c.fk_input_reason = dr.rowid'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON c.fk_incoterms = i.rowid'; if ($id) $sql.= " WHERE c.rowid=".$id; diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 85b4e3bb728..b7da8efec87 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -4251,7 +4251,7 @@ elseif ($id > 0 || ! empty($ref)) $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'bank as b ON p.fk_bank = b.rowid'; $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'bank_account as ba ON b.fk_account = ba.rowid'; $sql .= ' WHERE pf.fk_facture = ' . $object->id . ' AND pf.fk_paiement = p.rowid'; - $sql .= ' AND p.entity IN (' . getEntity('invoice').')'; + $sql .= ' AND p.entity IN (' . getEntity('invoice').') AND c.entity IN (' . getEntity('invoice').')'; $sql .= ' ORDER BY p.datep, p.tms'; $result = $db->query($sql); diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index c86874cdde9..810a2a87ca9 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -102,8 +102,7 @@ class Form * @param string $paramid Key of parameter for id ('id', 'socid') * @return string HTML edit field */ - public function editfieldkey($text, $htmlname, $preselected, $object, $perm, $typeofdata = 'string', $moreparam = '', $fieldrequired = 0, $notabletag = 0, $paramid = 'id') - { + public function editfieldkey($text, $htmlname, $preselected, $object, $perm, $typeofdata = 'string', $moreparam = '', $fieldrequired = 0, $notabletag = 0, $paramid = 'id') { global $conf,$langs; $ret=''; @@ -144,7 +143,7 @@ class Form } return $ret; - } + } /** * Output value of a field for an editable field diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index 8ebe6f71425..5a5e3139d27 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -1229,12 +1229,18 @@ class Project extends CommonObject else dol_print_error($this->db); if (count($listofprojectcontacttype) == 0) $listofprojectcontacttype[0]='0'; // To avoid syntax error if not found + + if (!empty($user->contactid)) { + $userid=$user->contactid; + } else { + $userid=$user->id; + } if ($mode == 0) { $sql.= " AND ec.element_id = p.rowid"; $sql.= " AND ( p.public = 1"; $sql.= " OR ( ec.fk_c_type_contact IN (".join(',', array_keys($listofprojectcontacttype)).")"; - $sql.= " AND ec.fk_socpeople = ".$user->id.")"; + $sql.= " AND ec.fk_socpeople = ".$userid.")"; $sql.= " )"; } if ($mode == 1) @@ -1242,7 +1248,7 @@ class Project extends CommonObject $sql.= " AND ec.element_id = p.rowid"; $sql.= " AND ("; $sql.= " ( ec.fk_c_type_contact IN (".join(',', array_keys($listofprojectcontacttype)).")"; - $sql.= " AND ec.fk_socpeople = ".$user->id.")"; + $sql.= " AND ec.fk_socpeople = ".$userid.")"; $sql.= " )"; } if ($mode == 2) From c2b1c8d4392bea85e4ad394d6e0a10b6c127d5a4 Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Sat, 18 May 2019 12:26:36 +0200 Subject: [PATCH 2/6] remove bad fix --- htdocs/projet/class/project.class.php | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index 5a5e3139d27..8ebe6f71425 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -1229,18 +1229,12 @@ class Project extends CommonObject else dol_print_error($this->db); if (count($listofprojectcontacttype) == 0) $listofprojectcontacttype[0]='0'; // To avoid syntax error if not found - - if (!empty($user->contactid)) { - $userid=$user->contactid; - } else { - $userid=$user->id; - } if ($mode == 0) { $sql.= " AND ec.element_id = p.rowid"; $sql.= " AND ( p.public = 1"; $sql.= " OR ( ec.fk_c_type_contact IN (".join(',', array_keys($listofprojectcontacttype)).")"; - $sql.= " AND ec.fk_socpeople = ".$userid.")"; + $sql.= " AND ec.fk_socpeople = ".$user->id.")"; $sql.= " )"; } if ($mode == 1) @@ -1248,7 +1242,7 @@ class Project extends CommonObject $sql.= " AND ec.element_id = p.rowid"; $sql.= " AND ("; $sql.= " ( ec.fk_c_type_contact IN (".join(',', array_keys($listofprojectcontacttype)).")"; - $sql.= " AND ec.fk_socpeople = ".$userid.")"; + $sql.= " AND ec.fk_socpeople = ".$user->id.")"; $sql.= " )"; } if ($mode == 2) From 9ef5767fd558a84864750171aec3a68c87cafc33 Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Sat, 18 May 2019 12:28:39 +0200 Subject: [PATCH 3/6] phpcs --- htdocs/core/class/html.form.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 810a2a87ca9..e7d8742a3f5 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -102,7 +102,8 @@ class Form * @param string $paramid Key of parameter for id ('id', 'socid') * @return string HTML edit field */ - public function editfieldkey($text, $htmlname, $preselected, $object, $perm, $typeofdata = 'string', $moreparam = '', $fieldrequired = 0, $notabletag = 0, $paramid = 'id') { + public function editfieldkey($text, $htmlname, $preselected, $object, $perm, $typeofdata = 'string', $moreparam = '', $fieldrequired = 0, $notabletag = 0, $paramid = 'id') + { global $conf,$langs; $ret=''; From f3315bb8f59125c2b5f4fd84cd125766b8adddca Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Sat, 18 May 2019 15:09:03 +0200 Subject: [PATCH 4/6] fix: bad sql request --- htdocs/compta/facture/card.php | 2 +- htdocs/projet/class/project.class.php | 1 + htdocs/projet/index.php | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index b7da8efec87..85b4e3bb728 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -4251,7 +4251,7 @@ elseif ($id > 0 || ! empty($ref)) $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'bank as b ON p.fk_bank = b.rowid'; $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'bank_account as ba ON b.fk_account = ba.rowid'; $sql .= ' WHERE pf.fk_facture = ' . $object->id . ' AND pf.fk_paiement = p.rowid'; - $sql .= ' AND p.entity IN (' . getEntity('invoice').') AND c.entity IN (' . getEntity('invoice').')'; + $sql .= ' AND p.entity IN (' . getEntity('invoice').')'; $sql .= ' ORDER BY p.datep, p.tms'; $result = $db->query($sql); diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index 8ebe6f71425..31cd94e7bcf 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -1229,6 +1229,7 @@ class Project extends CommonObject else dol_print_error($this->db); if (count($listofprojectcontacttype) == 0) $listofprojectcontacttype[0]='0'; // To avoid syntax error if not found + var_dump($mode); if ($mode == 0) { $sql.= " AND ec.element_id = p.rowid"; diff --git a/htdocs/projet/index.php b/htdocs/projet/index.php index 0e15403e9cf..0cbc7e283c6 100644 --- a/htdocs/projet/index.php +++ b/htdocs/projet/index.php @@ -61,7 +61,7 @@ $formfile=new FormFile($db); $projectset = ($mine?$mine:(empty($user->rights->projet->all->lire)?0:2)); $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, $projetset, 1); -//var_dump($projectsListId); +var_dump($projectsListId); llxHeader("", $langs->trans("Projects"), "EN:Module_Projects|FR:Module_Projets|ES:Módulo_Proyectos"); From f1aad766ca5e2905409ef7016c576711a32288b2 Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Sat, 18 May 2019 15:11:12 +0200 Subject: [PATCH 5/6] fix: bad sql request --- htdocs/projet/class/project.class.php | 1 - htdocs/projet/index.php | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index 31cd94e7bcf..8ebe6f71425 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -1229,7 +1229,6 @@ class Project extends CommonObject else dol_print_error($this->db); if (count($listofprojectcontacttype) == 0) $listofprojectcontacttype[0]='0'; // To avoid syntax error if not found - var_dump($mode); if ($mode == 0) { $sql.= " AND ec.element_id = p.rowid"; diff --git a/htdocs/projet/index.php b/htdocs/projet/index.php index 0cbc7e283c6..fa77cb4b52c 100644 --- a/htdocs/projet/index.php +++ b/htdocs/projet/index.php @@ -61,8 +61,7 @@ $formfile=new FormFile($db); $projectset = ($mine?$mine:(empty($user->rights->projet->all->lire)?0:2)); $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, $projetset, 1); -var_dump($projectsListId); - +//var_dump($projectsListId); llxHeader("", $langs->trans("Projects"), "EN:Module_Projects|FR:Module_Projets|ES:Módulo_Proyectos"); From c519906c9e9b9a5a4cd7549f510eeea2eac90721 Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Sat, 18 May 2019 15:46:49 +0200 Subject: [PATCH 6/6] fix scrunitizer --- htdocs/resource/class/dolresource.class.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/resource/class/dolresource.class.php b/htdocs/resource/class/dolresource.class.php index 591a57f59f3..7adec8e6009 100644 --- a/htdocs/resource/class/dolresource.class.php +++ b/htdocs/resource/class/dolresource.class.php @@ -842,6 +842,8 @@ class Dolresource extends CommonObject */ public function getElementResources($element, $element_id, $resource_type = '') { + $resources=array(); + // Links beetween objects are stored in this table $sql = 'SELECT rowid, resource_id, resource_type, busy, mandatory'; $sql.= ' FROM '.MAIN_DB_PREFIX.'element_resources';