NEW Add statistics on supplier tab.
This commit is contained in:
parent
7622d3b2fb
commit
1878647d26
@ -579,7 +579,7 @@ if ($id > 0)
|
||||
$warn = '';
|
||||
if ($object->outstanding_limit != '' && $object->outstanding_limit < $outstandingOpened)
|
||||
{
|
||||
$warn = img_warning($langs->trans("OutstandingBillReached"));
|
||||
$warn = ' '.img_warning($langs->trans("OutstandingBillReached"));
|
||||
}
|
||||
$text=$langs->trans("CurrentOutstandingBill");
|
||||
$link=DOL_URL_ROOT.'/compta/recap-compta.php?socid='.$object->id;
|
||||
@ -587,7 +587,7 @@ if ($id > 0)
|
||||
if ($link) $boxstat.='<a href="'.$link.'" class="boxstatsindicator thumbstat nobold nounderline">';
|
||||
$boxstat.='<div class="boxstats">';
|
||||
$boxstat.='<span class="boxstatstext">'.img_object("",$icon).' '.$text.'</span><br>';
|
||||
$boxstat.='<span class="boxstatsindicator'.($outstandingOpened>0?' amountremaintopay':'').'">'.price($outstandingOpened).$warn.'</span>';
|
||||
$boxstat.='<span class="boxstatsindicator'.($outstandingOpened>0?' amountremaintopay':'').'">'.price($outstandingOpened, 1, $langs, 1, -1, -1, $conf->currency).$warn.'</span>';
|
||||
$boxstat.='</div>';
|
||||
if ($link) $boxstat.='</a>';
|
||||
}
|
||||
|
||||
@ -3120,52 +3120,6 @@ class Facture extends CommonInvoice
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return amount (with tax) of all credit notes and deposits invoices used by invoice
|
||||
*
|
||||
* @param int $multicurrency Return multicurrency_amount instead of amount
|
||||
* @return int <0 if KO, Sum of credit notes and deposits amount otherwise
|
||||
*/
|
||||
function getSumCreditNotesUsed($multicurrency=0)
|
||||
{
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php';
|
||||
|
||||
$discountstatic=new DiscountAbsolute($this->db);
|
||||
$result=$discountstatic->getSumCreditNotesUsed($this, $multicurrency);
|
||||
if ($result >= 0)
|
||||
{
|
||||
return $result;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error=$discountstatic->error;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return amount (with tax) of all deposits invoices used by invoice
|
||||
*
|
||||
* @param int $multicurrency Return multicurrency_amount instead of amount
|
||||
* @return int <0 if KO, Sum of deposits amount otherwise
|
||||
*/
|
||||
function getSumDepositsUsed($multicurrency=0)
|
||||
{
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php';
|
||||
|
||||
$discountstatic=new DiscountAbsolute($this->db);
|
||||
$result=$discountstatic->getSumDepositsUsed($this, $multicurrency);
|
||||
if ($result >= 0)
|
||||
{
|
||||
return $result;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error=$discountstatic->error;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return next reference of customer invoice not already used (or last reference)
|
||||
* according to numbering module defined into constant FACTURE_ADDON
|
||||
|
||||
@ -88,6 +88,7 @@ abstract class CommonInvoice extends CommonObject
|
||||
*/
|
||||
const STATUS_ABANDONED = 3;
|
||||
|
||||
|
||||
/**
|
||||
* Return amount of payments already done
|
||||
*
|
||||
@ -124,6 +125,65 @@ abstract class CommonInvoice extends CommonObject
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return amount (with tax) of all credit notes and deposits invoices used by invoice
|
||||
*
|
||||
* @param int $multicurrency Return multicurrency_amount instead of amount
|
||||
* @return int <0 if KO, Sum of credit notes and deposits amount otherwise
|
||||
*/
|
||||
function getSumCreditNotesUsed($multicurrency=0)
|
||||
{
|
||||
if ($this->element == 'facture_fourn' || $this->element == 'invoice_supplier')
|
||||
{
|
||||
// TODO
|
||||
return 0;
|
||||
}
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php';
|
||||
|
||||
$discountstatic=new DiscountAbsolute($this->db);
|
||||
$result=$discountstatic->getSumCreditNotesUsed($this, $multicurrency);
|
||||
if ($result >= 0)
|
||||
{
|
||||
return $result;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error=$discountstatic->error;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return amount (with tax) of all deposits invoices used by invoice
|
||||
*
|
||||
* @param int $multicurrency Return multicurrency_amount instead of amount
|
||||
* @return int <0 if KO, Sum of deposits amount otherwise
|
||||
*/
|
||||
function getSumDepositsUsed($multicurrency=0)
|
||||
{
|
||||
if ($this->element == 'facture_fourn' || $this->element == 'invoice_supplier')
|
||||
{
|
||||
// TODO
|
||||
return 0;
|
||||
}
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php';
|
||||
|
||||
$discountstatic=new DiscountAbsolute($this->db);
|
||||
$result=$discountstatic->getSumDepositsUsed($this, $multicurrency);
|
||||
if ($result >= 0)
|
||||
{
|
||||
return $result;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error=$discountstatic->error;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Renvoie tableau des ids de facture avoir issus de la facture
|
||||
*
|
||||
|
||||
@ -277,12 +277,94 @@ if ($object->id > 0)
|
||||
|
||||
print '</div><div class="fichehalfright"><div class="ficheaddleft">';
|
||||
|
||||
|
||||
$boxstat = '';
|
||||
|
||||
// Nbre max d'elements des petites listes
|
||||
$MAXLIST=$conf->global->MAIN_SIZE_SHORTLIST_LIMIT;
|
||||
|
||||
// Lien recap
|
||||
$boxstat.='<div class="box">';
|
||||
$boxstat.='<table summary="'.dol_escape_htmltag($langs->trans("DolibarrStateBoard")).'" class="noborder boxtable" width="100%">';
|
||||
$boxstat.='<tr class="impair"><td colspan="2" class="tdboxstats nohover">';
|
||||
|
||||
if ($conf->supplier_proposal->enabled)
|
||||
{
|
||||
// Box proposals
|
||||
$tmp = $object->getOutstandingProposals('supplier');
|
||||
$outstandingOpened=$tmp['opened'];
|
||||
$outstandingTotal=$tmp['total_ht'];
|
||||
$outstandingTotalIncTax=$tmp['total_ttc'];
|
||||
$text=$langs->trans("OverAllSupplierProposals");
|
||||
$link='';
|
||||
$icon='bill';
|
||||
if ($link) $boxstat.='<a href="'.$link.'" class="boxstatsindicator thumbstat nobold nounderline">';
|
||||
$boxstat.='<div class="boxstats">';
|
||||
$boxstat.='<span class="boxstatstext">'.img_object("",$icon).' '.$text.'</span><br>';
|
||||
$boxstat.='<span class="boxstatsindicator">'.price($outstandingTotal, 1, $langs, 1, -1, -1, $conf->currency).'</span>';
|
||||
$boxstat.='</div>';
|
||||
if ($link) $boxstat.='</a>';
|
||||
}
|
||||
|
||||
if ($conf->fournisseur->enabled)
|
||||
{
|
||||
// Box proposals
|
||||
$tmp = $object->getOutstandingOrders('supplier');
|
||||
$outstandingOpened=$tmp['opened'];
|
||||
$outstandingTotal=$tmp['total_ht'];
|
||||
$outstandingTotalIncTax=$tmp['total_ttc'];
|
||||
$text=$langs->trans("OverAllOrders");
|
||||
$link='';
|
||||
$icon='bill';
|
||||
if ($link) $boxstat.='<a href="'.$link.'" class="boxstatsindicator thumbstat nobold nounderline">';
|
||||
$boxstat.='<div class="boxstats">';
|
||||
$boxstat.='<span class="boxstatstext">'.img_object("",$icon).' '.$text.'</span><br>';
|
||||
$boxstat.='<span class="boxstatsindicator">'.price($outstandingTotal, 1, $langs, 1, -1, -1, $conf->currency).'</span>';
|
||||
$boxstat.='</div>';
|
||||
if ($link) $boxstat.='</a>';
|
||||
}
|
||||
|
||||
if ($conf->fournisseur->enabled)
|
||||
{
|
||||
$tmp = $object->getOutstandingBills('supplier');
|
||||
$outstandingOpened=$tmp['opened'];
|
||||
$outstandingTotal=$tmp['total_ht'];
|
||||
$outstandingTotalIncTax=$tmp['total_ttc'];
|
||||
|
||||
$text=$langs->trans("OverAllInvoices");
|
||||
$link='';
|
||||
$icon='bill';
|
||||
if ($link) $boxstat.='<a href="'.$link.'" class="boxstatsindicator thumbstat nobold nounderline">';
|
||||
$boxstat.='<div class="boxstats">';
|
||||
$boxstat.='<span class="boxstatstext">'.img_object("",$icon).' '.$text.'</span><br>';
|
||||
$boxstat.='<span class="boxstatsindicator">'.price($outstandingTotal, 1, $langs, 1, -1, -1, $conf->currency).'</span>';
|
||||
$boxstat.='</div>';
|
||||
if ($link) $boxstat.='</a>';
|
||||
|
||||
// Box outstanding bill
|
||||
$text=$langs->trans("CurrentOutstandingBill");
|
||||
$link=DOL_URL_ROOT.'/fourn/recap-fourn.php?socid='.$object->id;
|
||||
$icon='bill';
|
||||
if ($link) $boxstat.='<a href="'.$link.'" class="boxstatsindicator thumbstat nobold nounderline">';
|
||||
$boxstat.='<div class="boxstats">';
|
||||
$boxstat.='<span class="boxstatstext">'.img_object("",$icon).' '.$text.'</span><br>';
|
||||
$boxstat.='<span class="boxstatsindicator'.($outstandingOpened>0?' amountremaintopay':'').'">'.price($outstandingOpened, 1, $langs, 1, -1, -1, $conf->currency).$warn.'</span>';
|
||||
$boxstat.='</div>';
|
||||
if ($link) $boxstat.='</a>';
|
||||
}
|
||||
|
||||
$boxstat.='</td></tr>';
|
||||
$boxstat.='</table>';
|
||||
$boxstat.='</div>';
|
||||
|
||||
print $boxstat;
|
||||
|
||||
|
||||
$var=true;
|
||||
|
||||
$MAXLIST=$conf->global->MAIN_SIZE_SHORTLIST_LIMIT;
|
||||
|
||||
// Lien recap
|
||||
/*
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td colspan="4"><table width="100%" class="nobordernopadding"><tr><td>'.$langs->trans("Summary").'</td>';
|
||||
@ -290,7 +372,7 @@ if ($object->id > 0)
|
||||
print '</tr>';
|
||||
print '</table>';
|
||||
print '<br>';
|
||||
|
||||
*/
|
||||
|
||||
/*
|
||||
* List of products
|
||||
|
||||
@ -81,6 +81,7 @@ PaymentBankAccount=Payment bank account
|
||||
OverAllProposals=Total proposals
|
||||
OverAllOrders=Total orders
|
||||
OverAllInvoices=Total invoices
|
||||
OverAllSupplierProposals=Total price requests
|
||||
##### Local Taxes #####
|
||||
LocalTax1IsUsed=Use second tax
|
||||
LocalTax1IsUsedES= RE is used
|
||||
|
||||
@ -3341,11 +3341,15 @@ class Societe extends CommonObject
|
||||
/**
|
||||
* Return amount of order not paid and total
|
||||
*
|
||||
* @return array array('opened'=>Amount, 'total'=>Total amount)
|
||||
* @param string $mode 'customer' or 'supplier'
|
||||
* @return array array('opened'=>Amount, 'total'=>Total amount)
|
||||
*/
|
||||
function getOutstandingProposals()
|
||||
function getOutstandingProposals($mode='customer')
|
||||
{
|
||||
$sql = "SELECT rowid, total_ht, total as total_ttc, fk_statut FROM ".MAIN_DB_PREFIX."propal as f";
|
||||
$table='propal';
|
||||
if ($mode == 'supplier') $table = 'supplier_proposal';
|
||||
|
||||
$sql = "SELECT rowid, total_ht, total as total_ttc, fk_statut FROM ".MAIN_DB_PREFIX.$table." as f";
|
||||
$sql .= " WHERE fk_soc = ". $this->id;
|
||||
|
||||
dol_syslog("getOutstandingProposals", LOG_DEBUG);
|
||||
@ -3372,11 +3376,15 @@ class Societe extends CommonObject
|
||||
/**
|
||||
* Return amount of order not paid and total
|
||||
*
|
||||
* @param string $mode 'customer' or 'supplier'
|
||||
* @return array array('opened'=>Amount, 'total'=>Total amount)
|
||||
*/
|
||||
function getOutstandingOrders()
|
||||
function getOutstandingOrders($mode='customer')
|
||||
{
|
||||
$sql = "SELECT rowid, total_ht, total_ttc, fk_statut FROM ".MAIN_DB_PREFIX."commande as f";
|
||||
$table='commande';
|
||||
if ($mode == 'supplier') $table = 'commande_fournisseur';
|
||||
|
||||
$sql = "SELECT rowid, total_ht, total_ttc, fk_statut FROM ".MAIN_DB_PREFIX.$table." as f";
|
||||
$sql .= " WHERE fk_soc = ". $this->id;
|
||||
|
||||
dol_syslog("getOutstandingOrders", LOG_DEBUG);
|
||||
@ -3403,10 +3411,14 @@ class Societe extends CommonObject
|
||||
/**
|
||||
* Return amount of bill not paid and total
|
||||
*
|
||||
* @param string $mode 'customer' or 'supplier'
|
||||
* @return array array('opened'=>Amount, 'total'=>Total amount)
|
||||
*/
|
||||
function getOutstandingBills()
|
||||
function getOutstandingBills($mode='customer')
|
||||
{
|
||||
$table='facture';
|
||||
if ($mode == 'supplier') $table = 'facture_fourn';
|
||||
|
||||
/* Accurate value of remain to pay is to sum remaintopay for each invoice
|
||||
$paiement = $invoice->getSommePaiement();
|
||||
$creditnotes=$invoice->getSumCreditNotesUsed();
|
||||
@ -3414,7 +3426,8 @@ class Societe extends CommonObject
|
||||
$alreadypayed=price2num($paiement + $creditnotes + $deposits,'MT');
|
||||
$remaintopay=price2num($invoice->total_ttc - $paiement - $creditnotes - $deposits,'MT');
|
||||
*/
|
||||
$sql = "SELECT rowid, total as total_ht, total_ttc, paye, fk_statut, close_code FROM ".MAIN_DB_PREFIX."facture as f";
|
||||
if ($mode == 'supplier') $sql = "SELECT rowid, total_ht as total_ht, total_ttc, paye, fk_statut, close_code FROM ".MAIN_DB_PREFIX.$table." as f";
|
||||
else $sql = "SELECT rowid, total as total_ht, total_ttc, paye, fk_statut, close_code FROM ".MAIN_DB_PREFIX.$table." as f";
|
||||
$sql .= " WHERE fk_soc = ". $this->id;
|
||||
|
||||
dol_syslog("getOutstandingBills", LOG_DEBUG);
|
||||
@ -3424,8 +3437,16 @@ class Societe extends CommonObject
|
||||
$outstandingOpened = 0;
|
||||
$outstandingTotal = 0;
|
||||
$outstandingTotalIncTax = 0;
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
|
||||
$tmpobject=new Facture($this->db);
|
||||
if ($mode == 'supplier')
|
||||
{
|
||||
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
|
||||
$tmpobject=new FactureFournisseur($this->db);
|
||||
}
|
||||
else
|
||||
{
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
|
||||
$tmpobject=new Facture($this->db);
|
||||
}
|
||||
while($obj=$this->db->fetch_object($resql)) {
|
||||
$tmpobject->id=$obj->rowid;
|
||||
if ($obj->fk_statut != 0 // Not a draft
|
||||
|
||||
Loading…
Reference in New Issue
Block a user