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