FIX regression + add $forceentity parameter

This commit is contained in:
Regis Houssin 2022-07-18 19:26:13 +02:00
parent ade854a469
commit 7db5f7eb1c
3 changed files with 14 additions and 11 deletions

View File

@ -1445,15 +1445,14 @@ class Propal extends CommonObject
/**
* Load a proposal from database. Get also lines.
*
* @param int $rowid id of object to load
* @param string $ref Ref of proposal
* @param string $ref_ext Ref ext of proposal
* @return int >0 if OK, <0 if KO
* @param int $rowid id of object to load
* @param string $ref Ref of proposal
* @param string $ref_ext Ref ext of proposal
* @param int $forceentity Entity id to force
* @return int >0 if OK, <0 if KO
*/
public function fetch($rowid, $ref = '', $ref_ext = '')
public function fetch($rowid, $ref = '', $ref_ext = '', $forceentity = 0)
{
global $conf;
$sql = "SELECT p.rowid, p.ref, p.entity, p.remise, p.remise_percent, p.remise_absolue, p.fk_soc";
$sql .= ", p.total_ttc, p.total_tva, p.localtax1, p.localtax2, p.total_ht";
$sql .= ", p.datec";
@ -1491,8 +1490,12 @@ class Propal extends CommonObject
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_input_reason as dr ON p.fk_input_reason = dr.rowid';
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON p.fk_incoterms = i.rowid';
if ($ref) {
$sql .= " WHERE p.entity = ".(int) $conf->entity; // Check only the current entity because we may have the same reference in several entities
if (!empty($ref)) {
if (!empty($forceentity)) {
$sql .= " WHERE p.entity = ".(int) $forceentity; // Check only the current entity because we may have the same reference in several entities
} else {
$sql .= " WHERE p.entity IN (".getEntity('propal').")";
}
$sql .= " AND p.ref='".$this->db->escape($ref)."'";
} else {
// Dont't use entity if you use rowid

View File

@ -26,7 +26,7 @@
*/
function showOnlineSignatureUrl($type, $ref)
{
global $conf, $langs;
global $langs;
// Load translation files required by the page
$langs->loadLangs(array("payment", "paybox"));

View File

@ -126,7 +126,7 @@ $creditor = $mysoc->name;
$type = $source;
if ($source == 'proposal') {
$object = new Propal($db);
$object->fetch(0, $ref);
$object->fetch(0, $ref, '', $entity);
} else {
accessforbidden('Bad value for source');
exit;