Can fetch a companypaymentmode of a thirdparty
This commit is contained in:
parent
0dea2b08c2
commit
f181719769
@ -6792,14 +6792,16 @@ abstract class CommonObject
|
|||||||
*/
|
*/
|
||||||
public function fetchCommon($id, $ref = null, $morewhere = '')
|
public function fetchCommon($id, $ref = null, $morewhere = '')
|
||||||
{
|
{
|
||||||
if (empty($id) && empty($ref)) return false;
|
if (empty($id) && empty($ref) && empty($morewhere)) return -1;
|
||||||
|
|
||||||
$sql = 'SELECT '.$this->getFieldList();
|
$sql = 'SELECT '.$this->getFieldList();
|
||||||
$sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element;
|
$sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element;
|
||||||
|
|
||||||
if (!empty($id)) $sql.= ' WHERE rowid = '.$id;
|
if (!empty($id)) $sql.= ' WHERE rowid = '.$id;
|
||||||
else $sql.= " WHERE ref = ".$this->quote($ref, $this->fields['ref']);
|
elseif (!empty($ref)) $sql.= " WHERE ref = ".$this->quote($ref, $this->fields['ref']);
|
||||||
|
else $sql.=' WHERE 1 = 1'; // usage with empty id and empty ref is very rare
|
||||||
if ($morewhere) $sql.= $morewhere;
|
if ($morewhere) $sql.= $morewhere;
|
||||||
|
$sql.=' LIMIT 1'; // This is a fetch, to be sure to get only one record
|
||||||
|
|
||||||
$res = $this->db->query($sql);
|
$res = $this->db->query($sql);
|
||||||
if ($res)
|
if ($res)
|
||||||
|
|||||||
@ -268,8 +268,9 @@ class CompanyPaymentMode extends CommonObject
|
|||||||
*/
|
*/
|
||||||
public function fetch($id, $ref = null, $socid = 0, $type = '')
|
public function fetch($id, $ref = null, $socid = 0, $type = '')
|
||||||
{
|
{
|
||||||
if ($socid) $sql.= " AND fk_soc = ".$this->db->escape($socid)." AND default_rib = 1";
|
$morewhere = '';
|
||||||
if ($type) $sql.= " AND type = '".$this->db->escape($type)."'";
|
if ($socid) $morewhere.= " AND fk_soc = ".$this->db->escape($socid)." AND default_rib = 1";
|
||||||
|
if ($type) $morewhere.= " AND type = '".$this->db->escape($type)."'";
|
||||||
|
|
||||||
$result = $this->fetchCommon($id, $ref, $morewhere);
|
$result = $this->fetchCommon($id, $ref, $morewhere);
|
||||||
if ($result > 0 && ! empty($this->table_element_line)) $this->fetchLines();
|
if ($result > 0 && ! empty($this->table_element_line)) $this->fetchLines();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user