Add rowid/ref in response

This commit is contained in:
Laurent Destailleur 2021-06-28 16:45:29 +02:00
parent 813440bd16
commit d7fbddb8e1

View File

@ -4383,21 +4383,24 @@ class Societe extends CommonObject
$table = 'supplier_proposal';
}
$sql = "SELECT rowid, total_ht, total_ttc, fk_statut as status FROM ".MAIN_DB_PREFIX.$table." as f";
$sql .= " WHERE fk_soc = ".$this->id;
$sql = "SELECT rowid, ref, total_ht, total_ttc, fk_statut as status FROM ".MAIN_DB_PREFIX.$table." as f";
$sql .= " WHERE fk_soc = ".((int) $this->id);
if ($mode == 'supplier') {
$sql .= " AND entity IN (".getEntity('supplier_proposal').")";
} else {
$sql .= " AND entity IN (".getEntity('propal').")";
}
dol_syslog("getOutstandingProposals", LOG_DEBUG);
dol_syslog("getOutstandingProposals for fk_soc = ".((int) $this->id), LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql) {
$outstandingOpened = 0;
$outstandingTotal = 0;
$outstandingTotalIncTax = 0;
$arrayofref = array();
while ($obj = $this->db->fetch_object($resql)) {
$arrayofref[$obj->rowid] = $obj->ref;
$outstandingTotal += $obj->total_ht;
$outstandingTotalIncTax += $obj->total_ttc;
if ($obj->status != 0) {
@ -4405,7 +4408,7 @@ class Societe extends CommonObject
$outstandingOpened += $obj->total_ttc;
}
}
return array('opened'=>$outstandingOpened, 'total_ht'=>$outstandingTotal, 'total_ttc'=>$outstandingTotalIncTax); // 'opened' is 'incl taxes'
return array('opened'=>$outstandingOpened, 'total_ht'=>$outstandingTotal, 'total_ttc'=>$outstandingTotalIncTax, 'refs'=>$arrayofref); // 'opened' is 'incl taxes'
} else {
return array();
}
@ -4424,8 +4427,8 @@ class Societe extends CommonObject
$table = 'commande_fournisseur';
}
$sql = "SELECT rowid, total_ht, total_ttc, fk_statut as status FROM ".MAIN_DB_PREFIX.$table." as f";
$sql .= " WHERE fk_soc = ".$this->id;
$sql = "SELECT rowid, ref, total_ht, total_ttc, fk_statut as status FROM ".MAIN_DB_PREFIX.$table." as f";
$sql .= " WHERE fk_soc = ".((int) $this->id);
if ($mode == 'supplier') {
$sql .= " AND entity IN (".getEntity('supplier_order').")";
} else {
@ -4438,7 +4441,9 @@ class Societe extends CommonObject
$outstandingOpened = 0;
$outstandingTotal = 0;
$outstandingTotalIncTax = 0;
$arrayofref = array();
while ($obj = $this->db->fetch_object($resql)) {
$arrayofref[$obj->rowid] = $obj->ref;
$outstandingTotal += $obj->total_ht;
$outstandingTotalIncTax += $obj->total_ttc;
if ($obj->status != 0) {
@ -4446,7 +4451,7 @@ class Societe extends CommonObject
$outstandingOpened += $obj->total_ttc;
}
}
return array('opened'=>$outstandingOpened, 'total_ht'=>$outstandingTotal, 'total_ttc'=>$outstandingTotalIncTax); // 'opened' is 'incl taxes'
return array('opened'=>$outstandingOpened, 'total_ht'=>$outstandingTotal, 'total_ttc'=>$outstandingTotalIncTax, 'refs'=>$arrayofref); // 'opened' is 'incl taxes'
} else {
return array();
}
@ -4473,7 +4478,7 @@ class Societe extends CommonObject
$alreadypayed=price2num($paiement + $creditnotes + $deposits,'MT');
$remaintopay=price2num($invoice->total_ttc - $paiement - $creditnotes - $deposits,'MT');
*/
$sql = "SELECT rowid, total_ht, total_ttc, paye, type, fk_statut as status, close_code FROM ".MAIN_DB_PREFIX.$table." as f";
$sql = "SELECT rowid, ref, total_ht, total_ttc, paye, type, fk_statut as status, close_code FROM ".MAIN_DB_PREFIX.$table." as f";
$sql .= " WHERE fk_soc = ".((int) $this->id);
if (!empty($late)) {
$sql .= " AND date_lim_reglement < '".$this->db->idate(dol_now())."'";
@ -4490,6 +4495,7 @@ class Societe extends CommonObject
$outstandingOpened = 0;
$outstandingTotal = 0;
$outstandingTotalIncTax = 0;
$arrayofref = array();
if ($mode == 'supplier') {
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
$tmpobject = new FactureFournisseur($this->db);
@ -4498,6 +4504,7 @@ class Societe extends CommonObject
$tmpobject = new Facture($this->db);
}
while ($obj = $this->db->fetch_object($resql)) {
$arrayofref[$obj->rowid] = $obj->ref;
$tmpobject->id = $obj->rowid;
if ($obj->status != $tmpobject::STATUS_DRAFT // Not a draft
@ -4524,7 +4531,7 @@ class Societe extends CommonObject
$outstandingOpened -= $tmpobject->getSumFromThisCreditNotesNotUsed();
}
}
return array('opened'=>$outstandingOpened, 'total_ht'=>$outstandingTotal, 'total_ttc'=>$outstandingTotalIncTax); // 'opened' is 'incl taxes'
return array('opened'=>$outstandingOpened, 'total_ht'=>$outstandingTotal, 'total_ttc'=>$outstandingTotalIncTax, 'refs'=>$arrayofref); // 'opened' is 'incl taxes'
} else {
dol_syslog("Sql error ".$this->db->lasterror, LOG_ERR);
return array();