mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-02-20 13:46:52 +01:00
Fix join into left join
This commit is contained in:
parent
cb1e5954f6
commit
83090629fe
|
|
@ -382,15 +382,16 @@ class FormOther
|
|||
/**
|
||||
* Return select list for categories (to use in form search selectors)
|
||||
*
|
||||
* @param string $selected Preselected value
|
||||
* @param string $htmlname Name of combo list (example: 'search_sale')
|
||||
* @param User $user Object user
|
||||
* @param int $showstatus 0=show user status only if status is disabled, 1=always show user status into label, -1=never show user status
|
||||
* @param int $showempty 1=show also an empty value
|
||||
* @param string $morecss More CSS
|
||||
* @return string Html combo list code
|
||||
* @param string $selected Preselected value
|
||||
* @param string $htmlname Name of combo list (example: 'search_sale')
|
||||
* @param User $user Object user
|
||||
* @param int $showstatus 0=show user status only if status is disabled, 1=always show user status into label, -1=never show user status
|
||||
* @param int $showempty 1=show also an empty value
|
||||
* @param string $morecss More CSS
|
||||
* @param int $norepresentative Show also an entry "Not categorized"
|
||||
* @return string Html combo list code
|
||||
*/
|
||||
public function select_salesrepresentatives($selected, $htmlname, $user, $showstatus = 0, $showempty = 1, $morecss = '')
|
||||
public function select_salesrepresentatives($selected, $htmlname, $user, $showstatus = 0, $showempty = 1, $morecss = '', $norepresentative = 0)
|
||||
{
|
||||
// phpcs:enable
|
||||
global $conf, $langs;
|
||||
|
|
@ -498,6 +499,13 @@ class FormOther
|
|||
{
|
||||
dol_print_error($this->db);
|
||||
}
|
||||
|
||||
if ($norepresentative)
|
||||
{
|
||||
$langs->load("companies");
|
||||
$out.='<option value="-2"'.($selected == -2 ? ' selected':'').'>- '.$langs->trans("NoSalesRepresentativeAffected").' -</option>';
|
||||
}
|
||||
|
||||
$out.='</select>';
|
||||
|
||||
return $out;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004-2016 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2004-2019 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2019 Regis Houssin <regis.houssin@inodbox.com>
|
||||
* Copyright (C) 2012 Marcos García <marcosgdf@gmail.com>
|
||||
* Copyright (C) 2013-2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
|
||||
|
|
@ -409,13 +409,15 @@ if (! empty($search_categ_cus)) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_s
|
|||
if (! empty($search_categ_sup)) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_fournisseur as cs ON s.rowid = cs.fk_soc"; // We'll need this table joined to the select in order to filter by categ
|
||||
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX."c_stcomm as st ON s.fk_stcomm = st.id";
|
||||
// We'll need this table joined to the select in order to filter by sale
|
||||
if ($search_sale || (!$user->rights->societe->client->voir && !$socid)) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
if ($search_sale == -2) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON sc.fk_soc = s.rowid";
|
||||
elseif ($search_sale || (!$user->rights->societe->client->voir && !$socid)) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
$sql.= " WHERE s.entity IN (".getEntity('societe').")";
|
||||
if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||
if ($socid) $sql.= " AND s.rowid = ".$socid;
|
||||
if ($search_sale) $sql.= " AND s.rowid = sc.fk_soc"; // Join for the needed table to filter by sale
|
||||
if ($search_sale != -2) $sql.= " AND s.rowid = sc.fk_soc"; // Join for the needed table to filter by sale
|
||||
if (! $user->rights->fournisseur->lire) $sql.=" AND (s.fournisseur <> 1 OR s.client <> 0)"; // client=0, fournisseur=0 must be visible
|
||||
if ($search_sale) $sql.= " AND sc.fk_user = ".$db->escape($search_sale);
|
||||
if ($search_sale == -2) $sql.= " AND sc.fk_user IS NULL";
|
||||
elseif ($search_sale) $sql.= " AND sc.fk_user = ".$db->escape($search_sale);
|
||||
if ($search_categ_cus > 0) $sql.= " AND cc.fk_categorie = ".$db->escape($search_categ_cus);
|
||||
if ($search_categ_sup > 0) $sql.= " AND cs.fk_categorie = ".$db->escape($search_categ_sup);
|
||||
if ($search_categ_cus == -2) $sql.= " AND cc.fk_categorie IS NULL";
|
||||
|
|
@ -659,7 +661,7 @@ if ($user->rights->societe->client->voir || $socid)
|
|||
{
|
||||
$moreforfilter.='<div class="divsearchfield">';
|
||||
$moreforfilter.=$langs->trans('SalesRepresentatives'). ': ';
|
||||
$moreforfilter.=$formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, 1, 'maxwidth300');
|
||||
$moreforfilter.=$formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, 1, 'maxwidth300', 1);
|
||||
$moreforfilter.='</div>';
|
||||
}
|
||||
if ($moreforfilter)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user