New: Add new graphical boxes (customer invoices per month).
This commit is contained in:
parent
1afef513b1
commit
d8883dba7f
20
ChangeLog
20
ChangeLog
@ -6,8 +6,8 @@ English Dolibarr ChangeLog
|
|||||||
For users:
|
For users:
|
||||||
- New: [ task #877 ] Reorganize menus.
|
- New: [ task #877 ] Reorganize menus.
|
||||||
- New: [ task #858 ] Holiday module: note on manual holiday assignation.
|
- New: [ task #858 ] Holiday module: note on manual holiday assignation.
|
||||||
- New: [ task #892 ] Add option in thirdparty customer/supplier admin to hide non active
|
- New: [ task #892 ] Add hidden option in thirdparty customer/supplier module to
|
||||||
companies in select_company method.
|
hide non active companies in select_company method.
|
||||||
- New: [ task #531 ] Add a workload field on tasks.
|
- New: [ task #531 ] Add a workload field on tasks.
|
||||||
- New: Add graph of bank account input/output into input-output report page.
|
- New: Add graph of bank account input/output into input-output report page.
|
||||||
- New: Add script export-bank-receipts.php
|
- New: Add script export-bank-receipts.php
|
||||||
@ -16,28 +16,30 @@ For users:
|
|||||||
- New: [ task #901 ] Add Extrafeild on Fiche Inter.
|
- New: [ task #901 ] Add Extrafeild on Fiche Inter.
|
||||||
- New: Show process id in all command line scripts.
|
- New: Show process id in all command line scripts.
|
||||||
- New: Module mailman can subscribe/unsubscribe to ML according to categories or type of member.
|
- New: Module mailman can subscribe/unsubscribe to ML according to categories or type of member.
|
||||||
- New: Add object_hour as substitution tag for opendocument generation.
|
- New: Add object_hour and object_date_rfc as substitution tag for opendocument generation.
|
||||||
- New: Add option to send email when paypal or paybox payment is done.
|
- New: Add options to send an email when paypal or paybox payment is done.
|
||||||
- New: Implement same rule for return value of all command line scripts (0 when success, <>0 if error).
|
|
||||||
- New: Clone product/service composition.
|
- New: Clone product/service composition.
|
||||||
- New: [ task #926 ] Add extrafield feature on order lines.
|
- New: [ task #926 ] Add extrafield feature on order lines.
|
||||||
- New: [ task #927 ] Add extrafield feature on Proposal lines.
|
- New: [ task #927 ] Add extrafield feature on Proposal lines.
|
||||||
- New: [ task #928 ] Add extrafield feature on invoice lines.
|
- New: [ task #928 ] Add extrafield feature on invoice lines.
|
||||||
- New: Add option ADHERENT_LOGIN_NOT_REQUIRED.
|
- New: Add option ADHERENT_LOGIN_NOT_REQUIRED.
|
||||||
- New: Add a cron module.
|
- New: Add a cron module to define scheduled jobs.
|
||||||
|
- New: Add new graphical boxes (customer invoices per month).
|
||||||
|
- Qual: Implement same rule for return value of all command line scripts (0 when success, <>0 if error).
|
||||||
|
|
||||||
For translators:
|
For translators:
|
||||||
- Normalized sort order of all languages files with english reference files.
|
- Normalized sort order of all languages files with english reference files.
|
||||||
|
|
||||||
For developers:
|
For developers:
|
||||||
- New: DolGraph can build graph with three lines.
|
- New: DolGraph can build graph with three lines.
|
||||||
- New: Can enable tuning info from option MAIN_SHOW_TUNING_INFO.
|
- New: DolGraph accept a parameter to cache data of graph getNbByMonthWithPrevYear.
|
||||||
|
- New: Can enable tuning info with option MAIN_SHOW_TUNING_INFO.
|
||||||
- New: Show version of client lib used by mysql drivers.
|
- New: Show version of client lib used by mysql drivers.
|
||||||
- New: Add function to get content of an url (using all dolibarr setup like timeout, proxies...)
|
- New: Add function to get content of an url (using all dolibarr setup like timeout, proxies...)
|
||||||
- New: Upgrade lib of TCPDF to 6.0
|
- New: Upgrade lib of TCPDF to 6.0
|
||||||
- New: Add property hidden into module descriptor to allow to hide a module according to
|
- New: Add property "hidden" into module descriptors to allow to hide a module according to
|
||||||
some dynamic conditions.
|
some dynamic conditions.
|
||||||
|
|
||||||
|
|
||||||
***** ChangeLog for 3.4 compared to 3.3.2 *****
|
***** ChangeLog for 3.4 compared to 3.3.2 *****
|
||||||
For users:
|
For users:
|
||||||
|
|||||||
@ -28,8 +28,7 @@ include_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php';
|
|||||||
include_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
|
include_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \class FactureStats
|
* Class to manage stats for invoices (customer and supplier)
|
||||||
* \brief Classe permettant la gestion des stats des factures
|
|
||||||
*/
|
*/
|
||||||
class FactureStats extends Stats
|
class FactureStats extends Stats
|
||||||
{
|
{
|
||||||
@ -47,7 +46,7 @@ class FactureStats extends Stats
|
|||||||
*
|
*
|
||||||
* @param DoliDB $db Database handler
|
* @param DoliDB $db Database handler
|
||||||
* @param int $socid Id third party
|
* @param int $socid Id third party
|
||||||
* @param string $mode Option
|
* @param string $mode Option ('customer', 'supplier')
|
||||||
* @param int $userid Id user for filter (creation user)
|
* @param int $userid Id user for filter (creation user)
|
||||||
* @return FactureStats
|
* @return FactureStats
|
||||||
*/
|
*/
|
||||||
@ -87,8 +86,8 @@ class FactureStats extends Stats
|
|||||||
/**
|
/**
|
||||||
* Renvoie le nombre de facture par mois pour une annee donnee
|
* Renvoie le nombre de facture par mois pour une annee donnee
|
||||||
*
|
*
|
||||||
* @param int $year Year to scan
|
* @param int $year Year to scan
|
||||||
* @return array Array of values
|
* @return array Array of values
|
||||||
*/
|
*/
|
||||||
function getNbByMonth($year)
|
function getNbByMonth($year)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -64,7 +64,9 @@ class box_graph_invoices_permonth extends ModeleBoxes
|
|||||||
global $conf, $user, $langs, $db;
|
global $conf, $user, $langs, $db;
|
||||||
|
|
||||||
$this->max=$max;
|
$this->max=$max;
|
||||||
|
|
||||||
|
$refreshaction='refresh_'.$this->boxcode;
|
||||||
|
|
||||||
include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
|
include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
|
||||||
$facturestatic=new Facture($db);
|
$facturestatic=new Facture($db);
|
||||||
|
|
||||||
@ -72,58 +74,73 @@ class box_graph_invoices_permonth extends ModeleBoxes
|
|||||||
$this->info_box_head = array(
|
$this->info_box_head = array(
|
||||||
'text' => $text,
|
'text' => $text,
|
||||||
'limit'=> dol_strlen($text),
|
'limit'=> dol_strlen($text),
|
||||||
'graph'=> 1
|
'graph'=> 1,
|
||||||
|
'sublink'=>$_SERVER["PHP_SELF"].'?action='.$refreshaction,
|
||||||
|
'subtext'=>$langs->trans("Refresh"),
|
||||||
|
'subpicto'=>'refresh.png',
|
||||||
|
'target'=>'none'
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($user->rights->facture->lire)
|
if ($user->rights->facture->lire)
|
||||||
{
|
{
|
||||||
$sql = "SELECT f.rowid as facid, f.facnumber, f.type, f.amount, f.datef as df";
|
require_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
|
||||||
$sql.= ", f.paye, f.fk_statut, f.datec, f.tms";
|
include_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facturestats.class.php';
|
||||||
$sql.= ", s.nom, s.rowid as socid";
|
|
||||||
$sql.= ", f.date_lim_reglement as datelimite";
|
$nowarray=dol_getdate(dol_now(),true);
|
||||||
$sql.= " FROM (".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f";
|
$endyear=$nowarray['year'];
|
||||||
if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
$startyear=$endyear-1;
|
||||||
$sql.= ")";
|
$mode='customer';
|
||||||
$sql.= " WHERE f.fk_soc = s.rowid";
|
$userid=0;
|
||||||
$sql.= " AND f.entity = ".$conf->entity;
|
$WIDTH='256';
|
||||||
if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
|
$HEIGHT='192';
|
||||||
if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id;
|
|
||||||
$sql.= " ORDER BY f.tms DESC";
|
$stats = new FactureStats($this->db, 0, $mode, ($userid>0?$userid:0));
|
||||||
$sql.= $db->plimit($max, 0);
|
|
||||||
|
// Build graphic number of object
|
||||||
$result = $db->query($sql);
|
// $data = array(array('Lib',val1,val2,val3),...)
|
||||||
if ($result)
|
$data = $stats->getNbByMonthWithPrevYear($endyear,$startyear,(GETPOST('action')==$refreshaction?-1:(3600*24)));
|
||||||
|
//var_dump($data);
|
||||||
|
|
||||||
|
$filenamenb = $dir."/invoicesnbinyear-".$year.".png";
|
||||||
|
if ($mode == 'customer') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=billstats&file=invoicesnbinyear-'.$year.'.png';
|
||||||
|
if ($mode == 'supplier') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=billstatssupplier&file=invoicesnbinyear-'.$year.'.png';
|
||||||
|
|
||||||
|
$px1 = new DolGraph();
|
||||||
|
$mesg = $px1->isGraphKo();
|
||||||
|
if (! $mesg)
|
||||||
{
|
{
|
||||||
$num = $db->num_rows($result);
|
$px1->SetData($data);
|
||||||
$now=dol_now();
|
$px1->SetPrecisionY(0);
|
||||||
|
$i=$startyear;$legend=array();
|
||||||
|
while ($i <= $endyear)
|
||||||
|
{
|
||||||
|
$legend[]=$i;
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
$px1->SetLegend($legend);
|
||||||
|
$px1->SetMaxValue($px1->GetCeilMaxValue());
|
||||||
|
$px1->SetWidth($WIDTH);
|
||||||
|
$px1->SetHeight($HEIGHT);
|
||||||
|
$px1->SetYLabel($langs->trans("NumberOfBills"));
|
||||||
|
$px1->SetShading(3);
|
||||||
|
$px1->SetHorizTickIncrement(1);
|
||||||
|
$px1->SetPrecisionY(0);
|
||||||
|
$px1->mode='depth';
|
||||||
|
//$px1->SetTitle($langs->trans("NumberOfBillsByMonth"));
|
||||||
|
|
||||||
|
$px1->draw($filenamenb,$fileurlnb);
|
||||||
|
}
|
||||||
|
|
||||||
$i = 0;
|
|
||||||
$l_due_date = $langs->trans('Late').' ('.strtolower($langs->trans('DateEcheance')).': %s)';
|
if (! $mesg)
|
||||||
|
{
|
||||||
while ($i < $num)
|
$this->info_box_contents[0][0] = array('td' => 'align="center"','textnoformat'=>$px1->show());
|
||||||
{
|
|
||||||
$objp = $db->fetch_object($result);
|
|
||||||
$datelimite=$db->jdate($objp->datelimite);
|
|
||||||
$datec=$db->jdate($objp->datec);
|
|
||||||
|
|
||||||
$picto='bill';
|
|
||||||
if ($objp->type == 1) $picto.='r';
|
|
||||||
if ($objp->type == 2) $picto.='a';
|
|
||||||
$late = '';
|
|
||||||
if ($objp->paye == 0 && ($objp->fk_statut != 2 && $objp->fk_statut != 3) && $datelimite < ($now - $conf->facture->client->warning_delay)) { $late = img_warning(sprintf($l_due_date,dol_print_date($datelimite,'day')));}
|
|
||||||
|
|
||||||
$i++;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->info_box_contents[0][0] = array('td' => 'align="center"','text2'=>'xxxxxxx');
|
|
||||||
|
|
||||||
$db->free($result);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->info_box_contents[0][0] = array( 'td' => 'align="left"',
|
$this->info_box_contents[0][0] = array( 'td' => 'align="left"',
|
||||||
'maxlength'=>500,
|
'maxlength'=>500,
|
||||||
'text' => ($db->error().' sql='.$sql));
|
'text' => $mesg);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -160,7 +160,7 @@ class ModeleBoxes // Can't be abtract as it is instanciated to build "empty"
|
|||||||
}
|
}
|
||||||
if (! empty($head['sublink']))
|
if (! empty($head['sublink']))
|
||||||
{
|
{
|
||||||
print ' <a href="'.$head['sublink'].'" target="_blank">'.img_picto($head['subtext'],$head['subpicto']).'</a>';
|
print ' <a href="'.$head['sublink'].'"'.(empty($head['target'])?' target="_blank"':'').'>'.img_picto($head['subtext'],$head['subpicto']).'</a>';
|
||||||
}
|
}
|
||||||
if ($conf->use_javascript_ajax)
|
if ($conf->use_javascript_ajax)
|
||||||
{
|
{
|
||||||
@ -203,19 +203,20 @@ class ModeleBoxes // Can't be abtract as it is instanciated to build "empty"
|
|||||||
if (isset($contents[$i][$j]['td'])) $tdparam.=' '.$contents[$i][$j]['td'];
|
if (isset($contents[$i][$j]['td'])) $tdparam.=' '.$contents[$i][$j]['td'];
|
||||||
|
|
||||||
if (empty($contents[$i][$j]['text'])) $contents[$i][$j]['text']="";
|
if (empty($contents[$i][$j]['text'])) $contents[$i][$j]['text']="";
|
||||||
$texte=isset($contents[$i][$j]['text'])?$contents[$i][$j]['text']:'';
|
$text=isset($contents[$i][$j]['text'])?$contents[$i][$j]['text']:'';
|
||||||
$textewithnotags=preg_replace('/<([^>]+)>/i','',$texte);
|
$textwithnotags=preg_replace('/<([^>]+)>/i','',$text);
|
||||||
$texte2=isset($contents[$i][$j]['text2'])?$contents[$i][$j]['text2']:'';
|
$text2=isset($contents[$i][$j]['text2'])?$contents[$i][$j]['text2']:'';
|
||||||
$texte2withnotags=preg_replace('/<([^>]+)>/i','',$texte2);
|
$text2withnotags=preg_replace('/<([^>]+)>/i','',$text2);
|
||||||
//print "xxx $textewithnotags y";
|
$textnoformat=isset($contents[$i][$j]['textnoformat'])?$contents[$i][$j]['textnoformat']:'';
|
||||||
|
//print "xxx $textwithnotags y";
|
||||||
|
|
||||||
print '<td'.$tdparam.'>';
|
print '<td'.$tdparam.'>';
|
||||||
|
|
||||||
// Url
|
// Url
|
||||||
if (! empty($contents[$i][$j]['url']))
|
if (! empty($contents[$i][$j]['url']))
|
||||||
{
|
{
|
||||||
print '<a href="'.$contents[$i][$j]['url'].'" title="'.$textewithnotags.'"';
|
print '<a href="'.$contents[$i][$j]['url'].'" title="'.$textwithnotags.'"';
|
||||||
//print ' alt="'.$textewithnotags.'"'; // Pas de alt sur un "<a href>"
|
//print ' alt="'.$textwithnotags.'"'; // Pas de alt sur un "<a href>"
|
||||||
print isset($contents[$i][$j]['target'])?' target="'.$contents[$i][$j]['target'].'"':'';
|
print isset($contents[$i][$j]['target'])?' target="'.$contents[$i][$j]['target'].'"':'';
|
||||||
print '>';
|
print '>';
|
||||||
}
|
}
|
||||||
@ -230,16 +231,18 @@ class ModeleBoxes // Can't be abtract as it is instanciated to build "empty"
|
|||||||
$maxlength=$MAXLENGTHBOX;
|
$maxlength=$MAXLENGTHBOX;
|
||||||
if (! empty($contents[$i][$j]['maxlength'])) $maxlength=$contents[$i][$j]['maxlength'];
|
if (! empty($contents[$i][$j]['maxlength'])) $maxlength=$contents[$i][$j]['maxlength'];
|
||||||
|
|
||||||
if ($maxlength) $textewithnotags=dol_trunc($textewithnotags,$maxlength);
|
if ($maxlength) $textwithnotags=dol_trunc($textwithnotags,$maxlength);
|
||||||
if (preg_match('/^<img/i',$texte) || ! empty($contents[$i][$j]['asis'])) print $texte; // show text with no html cleaning
|
if (preg_match('/^<img/i',$text) || ! empty($contents[$i][$j]['asis'])) print $text; // show text with no html cleaning
|
||||||
else print $textewithnotags; // show text with html cleaning
|
else print $textwithnotags; // show text with html cleaning
|
||||||
|
|
||||||
// End Url
|
// End Url
|
||||||
if (! empty($contents[$i][$j]['url'])) print '</a>';
|
if (! empty($contents[$i][$j]['url'])) print '</a>';
|
||||||
|
|
||||||
if (preg_match('/^<img/i',$texte2) || ! empty($contents[$i][$j]['asis2'])) print $texte2; // show text with no html cleaning
|
if (preg_match('/^<img/i',$text2) || ! empty($contents[$i][$j]['asis2'])) print $text2; // show text with no html cleaning
|
||||||
else print $texte2withnotags; // show text with html cleaning
|
else print $text2withnotags; // show text with html cleaning
|
||||||
|
|
||||||
|
if (! empty($textnoformat)) print "\n".$textnoformat."\n";
|
||||||
|
|
||||||
print "</td>";
|
print "</td>";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -785,7 +785,7 @@ class DolGraph
|
|||||||
$tag=dol_escape_htmltag(dol_string_unaccent(dol_string_nospecial(basename($file),'_',array('-','.'))));
|
$tag=dol_escape_htmltag(dol_string_unaccent(dol_string_nospecial(basename($file),'_',array('-','.'))));
|
||||||
|
|
||||||
$this->_stringtoshow ='<!-- Build using '.$this->_library.' -->'."\n";
|
$this->_stringtoshow ='<!-- Build using '.$this->_library.' -->'."\n";
|
||||||
$this->_stringtoshow.='<br><div align="center">'.$this->title.'</div><br>';
|
if (! empty($this->title)) $this->_stringtoshow.='<br><div align="center">'.$this->title.'</div><br>';
|
||||||
$this->_stringtoshow.='<div id="placeholder_'.$tag.'" style="width:'.$this->width.'px;height:'.$this->height.'px;" class="dolgraph"></div>'."\n";
|
$this->_stringtoshow.='<div id="placeholder_'.$tag.'" style="width:'.$this->width.'px;height:'.$this->height.'px;" class="dolgraph"></div>'."\n";
|
||||||
$this->_stringtoshow.='<script id="'.$tag.'">'."\n";
|
$this->_stringtoshow.='<script id="'.$tag.'">'."\n";
|
||||||
$this->_stringtoshow.='$(function () {'."\n";
|
$this->_stringtoshow.='$(function () {'."\n";
|
||||||
|
|||||||
@ -30,47 +30,103 @@
|
|||||||
abstract class Stats
|
abstract class Stats
|
||||||
{
|
{
|
||||||
protected $db;
|
protected $db;
|
||||||
|
var $_lastfetchdategetNbByMonthWithPrevYear; // Date of cache file read by getNbByMonthWithPrevYear
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return nb of entity by month for several years
|
* Return nb of elements by month for several years
|
||||||
*
|
*
|
||||||
* @param int $endyear Start year
|
* @param int $endyear Start year
|
||||||
* @param int $startyear End year
|
* @param int $startyear End year
|
||||||
* @return array Array of values
|
* @param int $cachedelay Delay we accept for cache file (0=No read, no save of cache, -1=No read but save)
|
||||||
|
* @return array Array of values
|
||||||
*/
|
*/
|
||||||
function getNbByMonthWithPrevYear($endyear,$startyear)
|
function getNbByMonthWithPrevYear($endyear,$startyear,$cachedelay=0)
|
||||||
{
|
{
|
||||||
|
global $conf,$user,$langs;
|
||||||
|
|
||||||
if ($startyear > $endyear) return -1;
|
if ($startyear > $endyear) return -1;
|
||||||
|
|
||||||
|
if (! empty($cachedelay))
|
||||||
|
{
|
||||||
|
include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||||
|
include_once DOL_DOCUMENT_ROOT.'/core/lib/json.lib.php';
|
||||||
|
}
|
||||||
|
|
||||||
$datay=array();
|
$datay=array();
|
||||||
|
|
||||||
$year=$startyear;
|
$newpathofdestfile=$conf->user->dir_temp.'/'.get_class($this).'_'.$langs->defaultlang.'_user'.$user->id.'.cache';
|
||||||
while ($year <= $endyear)
|
$newmask='0644';
|
||||||
{
|
|
||||||
$datay[$year] = $this->getNbByMonth($year);
|
|
||||||
$year++;
|
|
||||||
}
|
|
||||||
|
|
||||||
$data = array();
|
$nowgmt = dol_now();
|
||||||
|
|
||||||
for ($i = 0 ; $i < 12 ; $i++)
|
// Search into cache
|
||||||
|
$foundintocache=0;
|
||||||
|
if ($cachedelay > 0)
|
||||||
|
{
|
||||||
|
$filedate=dol_filemtime($newpathofdestfile);
|
||||||
|
if ($filedate >= ($nowgmt - $cachedelay))
|
||||||
|
{
|
||||||
|
$foundintocache=1;
|
||||||
|
|
||||||
|
$this->_lastfetchdategetNbByMonthWithPrevYear=$filedate;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dol_syslog(get_class($this)."::getNbByMonthWithPrevYear cache file ".$newpathofdestfile." is not found or older than now - cachedelay (".$nowgmt." - ".$cachedelay.") so we can't use it.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Load file into $data
|
||||||
|
if ($foundintocache) // Cache file found and is not too old
|
||||||
|
{
|
||||||
|
dol_syslog(get_class($this)."::getNbByMonthWithPrevYear read data from cache file ".$newpathofdestfile." ".$filedate.".");
|
||||||
|
$data = dol_json_decode(file_get_contents($newpathofdestfile), true);
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
$data[$i][]=$datay[$endyear][$i][0];
|
|
||||||
$year=$startyear;
|
$year=$startyear;
|
||||||
while($year <= $endyear)
|
while ($year <= $endyear)
|
||||||
{
|
{
|
||||||
$data[$i][]=$datay[$year][$i][1];
|
$datay[$year] = $this->getNbByMonth($year);
|
||||||
$year++;
|
$year++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$data = array();
|
||||||
|
|
||||||
|
for ($i = 0 ; $i < 12 ; $i++)
|
||||||
|
{
|
||||||
|
$data[$i][]=$datay[$endyear][$i][0];
|
||||||
|
$year=$startyear;
|
||||||
|
while($year <= $endyear)
|
||||||
|
{
|
||||||
|
$data[$i][]=$datay[$year][$i][1];
|
||||||
|
$year++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Save cache file
|
||||||
|
if (empty($foundintocache) && ($cachedelay > 0 || $cachedelay == -1))
|
||||||
|
{
|
||||||
|
dol_syslog(get_class($this)."::getNbByMonthWithPrevYear save cache file ".$newpathofdestfile." onto disk.");
|
||||||
|
if (! dol_is_dir($conf->user->dir_temp)) dol_mkdir($conf->user->dir_temp);
|
||||||
|
$fp = fopen($newpathofdestfile, 'w');
|
||||||
|
fwrite($fp, dol_json_encode($data));
|
||||||
|
fclose($fp);
|
||||||
|
if (! empty($conf->global->MAIN_UMASK)) $newmask=$conf->global->MAIN_UMASK;
|
||||||
|
@chmod($newpathofdestfile, octdec($newmask));
|
||||||
|
|
||||||
|
$this->_lastfetchdategetNbByMonthWithPrevYear=$nowgmt;
|
||||||
|
}
|
||||||
|
|
||||||
// return array(array('Month',val1,val2,val3),...)
|
// return array(array('Month',val1,val2,val3),...)
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return amount of entity by month for several years
|
* Return amount of elements by month for several years
|
||||||
*
|
*
|
||||||
* @param int $endyear Start year
|
* @param int $endyear Start year
|
||||||
* @param int $startyear End year
|
* @param int $startyear End year
|
||||||
@ -210,9 +266,10 @@ abstract class Stats
|
|||||||
*
|
*
|
||||||
* @param int $year Year
|
* @param int $year Year
|
||||||
* @param string $sql SQL
|
* @param string $sql SQL
|
||||||
|
* @param int $format 0=Label of absiss is a translated text, 1=Label of absiss is a number
|
||||||
* @return array Array of nb each month
|
* @return array Array of nb each month
|
||||||
*/
|
*/
|
||||||
function _getNbByMonth($year, $sql)
|
function _getNbByMonth($year, $sql, $format=0)
|
||||||
{
|
{
|
||||||
$result=array();
|
$result=array();
|
||||||
$res=array();
|
$res=array();
|
||||||
@ -246,9 +303,9 @@ abstract class Stats
|
|||||||
|
|
||||||
for ($i = 1 ; $i < 13 ; $i++)
|
for ($i = 1 ; $i < 13 ; $i++)
|
||||||
{
|
{
|
||||||
$month=dol_print_date(dol_mktime(12,0,0,$i,1,$year),"%b");
|
$month=dol_print_date(dol_mktime(12,0,0,$i,1,$year),($format?"%m":"%b"));
|
||||||
$month=dol_substr($month,0,3);
|
$month=dol_substr($month,0,3);
|
||||||
$data[$i-1] = array(ucfirst($month), $res[$i]);
|
$data[$i-1] = array($month, $res[$i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
@ -258,11 +315,12 @@ abstract class Stats
|
|||||||
/**
|
/**
|
||||||
* Renvoie le nombre d'element par mois pour une annee donnee
|
* Renvoie le nombre d'element par mois pour une annee donnee
|
||||||
*
|
*
|
||||||
* @param int $year Year
|
* @param int $year Year
|
||||||
* @param string $sql SQL
|
* @param string $sql SQL
|
||||||
|
* @param int $format 0=Label of absiss is a translated text, 1=Label of absiss is a number
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
function _getAmountByMonth($year, $sql)
|
function _getAmountByMonth($year, $sql, $format=0)
|
||||||
{
|
{
|
||||||
$result=array();
|
$result=array();
|
||||||
$res=array();
|
$res=array();
|
||||||
@ -294,20 +352,21 @@ abstract class Stats
|
|||||||
|
|
||||||
for ($i = 1 ; $i < 13 ; $i++)
|
for ($i = 1 ; $i < 13 ; $i++)
|
||||||
{
|
{
|
||||||
$month=dol_print_date(dol_mktime(12,0,0,$i,1,$year),"%b");
|
$month=dol_print_date(dol_mktime(12,0,0,$i,1,$year),($format?"%m":"%b"));
|
||||||
$month=dol_substr($month,0,3);
|
$month=dol_substr($month,0,3);
|
||||||
$data[$i-1] = array(ucfirst($month), $res[$i]);
|
$data[$i-1] = array($month, $res[$i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Renvoie le montant moyen par mois pour une annee donnee
|
* Renvoie le montant moyen par mois pour une annee donnee
|
||||||
*
|
*
|
||||||
* @param int $year Year
|
* @param int $year Year
|
||||||
* @param string $sql SQL
|
* @param string $sql SQL
|
||||||
* @return array
|
* @param int $format 0=Label of absiss is a translated text, 1=Label of absiss is a number
|
||||||
|
* @return array
|
||||||
*/
|
*/
|
||||||
function _getAverageByMonth($year, $sql)
|
function _getAverageByMonth($year, $sql)
|
||||||
{
|
{
|
||||||
@ -340,9 +399,9 @@ abstract class Stats
|
|||||||
|
|
||||||
for ($i = 1 ; $i < 13 ; $i++)
|
for ($i = 1 ; $i < 13 ; $i++)
|
||||||
{
|
{
|
||||||
$month=dol_print_date(dol_mktime(12,0,0,$i,1,$year),"%b");
|
$month=dol_print_date(dol_mktime(12,0,0,$i,1,$year),($format?"%m":"%b"));
|
||||||
$month=dol_substr($month,0,3);
|
$month=dol_substr($month,0,3);
|
||||||
$data[$i-1] = array(ucfirst($month), $res[$i]);
|
$data[$i-1] = array($month, $res[$i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user