New: showrefnav can be used with tables without prefix.
This commit is contained in:
parent
30dae3def2
commit
13929bc46f
@ -816,9 +816,10 @@ abstract class CommonObject
|
||||
*
|
||||
* @param string $filter Optional filter
|
||||
* @param int $fieldid Name of field to use for the select MAX and MIN
|
||||
* @param int $nodbprefix Do not include DB prefix to forge table name
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function load_previous_next_ref($filter,$fieldid)
|
||||
function load_previous_next_ref($filter,$fieldid,$nodbprefix=0)
|
||||
{
|
||||
global $conf, $user;
|
||||
|
||||
@ -834,7 +835,7 @@ abstract class CommonObject
|
||||
if ($this->element == 'societe') $alias = 'te';
|
||||
|
||||
$sql = "SELECT MAX(te.".$fieldid.")";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX.$this->table_element." as te";
|
||||
$sql.= " FROM ".(empty($nodbprefix)?MAIN_DB_PREFIX:'').$this->table_element." as te";
|
||||
if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 2 || ($this->element != 'societe' && empty($this->isnolinkedbythird) && empty($user->rights->societe->client->voir))) $sql.= ", ".MAIN_DB_PREFIX."societe as s"; // If we need to link to societe to limit select to entity
|
||||
if (empty($this->isnolinkedbythird) && !$user->rights->societe->client->voir) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON ".$alias.".rowid = sc.fk_soc";
|
||||
$sql.= " WHERE te.".$fieldid." < '".$this->db->escape($this->ref)."'";
|
||||
@ -847,7 +848,7 @@ abstract class CommonObject
|
||||
$result = $this->db->query($sql);
|
||||
if (! $result)
|
||||
{
|
||||
$this->error=$this->db->error();
|
||||
$this->error=$this->db->lasterror();
|
||||
return -1;
|
||||
}
|
||||
$row = $this->db->fetch_row($result);
|
||||
@ -855,7 +856,7 @@ abstract class CommonObject
|
||||
|
||||
|
||||
$sql = "SELECT MIN(te.".$fieldid.")";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX.$this->table_element." as te";
|
||||
$sql.= " FROM ".(empty($nodbprefix)?MAIN_DB_PREFIX:'').$this->table_element." as te";
|
||||
if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 2 || ($this->element != 'societe' && empty($this->isnolinkedbythird) && !$user->rights->societe->client->voir)) $sql.= ", ".MAIN_DB_PREFIX."societe as s"; // If we need to link to societe to limit select to entity
|
||||
if (empty($this->isnolinkedbythird) && !$user->rights->societe->client->voir) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON ".$alias.".rowid = sc.fk_soc";
|
||||
$sql.= " WHERE te.".$fieldid." > '".$this->db->escape($this->ref)."'";
|
||||
@ -869,7 +870,7 @@ abstract class CommonObject
|
||||
$result = $this->db->query($sql);
|
||||
if (! $result)
|
||||
{
|
||||
$this->error=$this->db->error();
|
||||
$this->error=$this->db->lasterror();
|
||||
return -2;
|
||||
}
|
||||
$row = $this->db->fetch_row($result);
|
||||
|
||||
@ -4023,9 +4023,10 @@ class Form
|
||||
* @param string $fieldref Nom du champ objet ref (object->ref) a utiliser pour select next et previous
|
||||
* @param string $morehtmlref Code html supplementaire a afficher apres ref
|
||||
* @param string $moreparam More param to add in nav link url.
|
||||
* @param int $nodbprefix Do not include DB prefix to forge table name
|
||||
* @return tring Portion HTML avec ref + boutons nav
|
||||
*/
|
||||
function showrefnav($object,$paramid,$morehtml='',$shownav=1,$fieldid='rowid',$fieldref='ref',$morehtmlref='',$moreparam='')
|
||||
function showrefnav($object,$paramid,$morehtml='',$shownav=1,$fieldid='rowid',$fieldref='ref',$morehtmlref='',$moreparam='',$nodbprefix=0)
|
||||
{
|
||||
global $langs,$conf;
|
||||
|
||||
@ -4034,7 +4035,8 @@ class Form
|
||||
if (empty($fieldref)) $fieldref='ref';
|
||||
|
||||
//print "paramid=$paramid,morehtml=$morehtml,shownav=$shownav,$fieldid,$fieldref,$morehtmlref,$moreparam";
|
||||
$object->load_previous_next_ref((isset($object->next_prev_filter)?$object->next_prev_filter:''),$fieldid);
|
||||
$object->load_previous_next_ref((isset($object->next_prev_filter)?$object->next_prev_filter:''),$fieldid,$nodbprefix);
|
||||
|
||||
$previous_ref = $object->ref_previous?'<a data-role="button" data-icon="arrow-l" data-iconpos="left" href="'.$_SERVER["PHP_SELF"].'?'.$paramid.'='.urlencode($object->ref_previous).$moreparam.'">'.(empty($conf->dol_use_jmobile)?img_picto($langs->trans("Previous"),'previous.png'):' ').'</a>':'';
|
||||
$next_ref = $object->ref_next?'<a data-role="button" data-icon="arrow-r" data-iconpos="right" href="'.$_SERVER["PHP_SELF"].'?'.$paramid.'='.urlencode($object->ref_next).$moreparam.'">'.(empty($conf->dol_use_jmobile)?img_picto($langs->trans("Next"),'next.png'):' ').'</a>':'';
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user