New: First add of js graph

This commit is contained in:
Laurent Destailleur 2011-05-13 18:08:55 +00:00
parent 10ff957206
commit 227c5d662b
5 changed files with 120 additions and 39 deletions

View File

@ -16,6 +16,7 @@ ArtiChow 1.07 Public Domain Yes Graphics
CKEditor 3.5.3 GPL or LGPL 2.1 or MPL 1.1 Yes Editor WYSIWYG
EFC/XFSS 1.0.1 LGPL 3.0 Yes Enhanced File Crypt/Extended File Stealth System
FCKEditor 2.6.6 LGPL 2.1 or Mozilla PL 1.0 Yes Editor WYSIWYG
Flot 0.7 MIT Licence Yes JS library to build graph
FPDF 1.6 Public domain Yes PDF generation (original code is modified)
FPDF_TPL 1.1.5 Apache Software License 2.0 No GPL3 only PDF templates management
FPDI 1.3.4 Apache Software License 2.0 No GPL3 only PDF templates management
@ -47,17 +48,23 @@ http://www.fsf.org/licensing/licenses/index_html
Copyright
---------
Copyright (C) 2011
- Laurent Destailleur <eldy@users.sourceforge.net>
- Regis Houssin <regis@dolibarr.fr>
- Juanjo Menent
- Philippe Grand
Copyright (C) 2010
- Laurent Destailleur <eldy@users.sourceforge.net>
- Regis Houssin <regis@dolibarr.fr>
- simnandez
- Juanjo Menent
- r2gnl
- meos
Copyright (C) 2009
- Laurent Destailleur <eldy@users.sourceforge.net>
- Regis Houssin <regis@dolibarr.fr>
- simnandez
- Juanjo Menent
Copyright (C) 2008
- Laurent Destailleur <eldy@users.sourceforge.net>

View File

@ -13,6 +13,7 @@ For users:
- Reduce a step into supplier order workflow to save time. If user
has permission to approve, order is approved when order is validated.
(Save 2 clicks).
- New: First graph using javascripts.
- New: Can add a discount for third party, during invoice edition (and we
saved clicks again).
- New: Add status for third parties.
@ -41,7 +42,7 @@ For users:
or credit note invoice.
- New: task #10885: Add a week view for calendar
- New: task #11018 : Add a status "not applicable" on event
- New: Add region/country statistics for member module.
- New: Add country/region/town statistics for member module.
- New: Can define a proxy for external web access.
- New: task #11003: checkbox on checks to deposit
- New: Numbering module for invoice use same number for invoice

View File

@ -1227,15 +1227,90 @@ function dolibarr_trunc($string,$size=40,$trunc='right',$stringencoding='')
return dol_trunc($string,$size,$trunc,$stringencoding);
}
/**
* \brief Truncate a string to a particular length adding '...' if string larger than length.
* If length = max length+1, we do no truncate to avoid having just 1 char replaced with '...'.
* \param string String to truncate
* \param size Max string size. 0 for no limit.
* \param trunc Where to trunc: right, left, middle, wrap
* \param stringencoding Tell what is source string encoding
* \return string Truncated string
* \remarks MAIN_DISABLE_TRUNC=1 can disable all truncings
* Show a javascript graph
* @param htmlid Html id name
* @param width Width in pixel
* @param height Height in pixel
* @param data Data array
* @param type Type of graph
*/
function dol_print_graph($htmlid,$width,$height,$data,$showlegend=0,$type='pie')
{
global $conf,$langs;
if (empty($conf->use_javascript_ajax)) return;
$jsgraphlib='flot';
print '<div id="'.$htmlid.'" style="width:'.$width.'px;height:'.$height.'px;"></div>';
// We use Flot js lib
if ($jsgraphlib == 'flot')
{
print '<script type="text/javascript">
jQuery(function () {
// data
/*var data = [
{ label: "Series1<br>aa", data: 10},
{ label: "Series2", data: 30},
{ label: "Series3", data: 90}
];
var data = [
{ label: "Series1", data: [[1,10]]},
{ label: "Series2", data: [[1,30]]},
{ label: "Series3", data: [[1,90]]}
];*/
';
if ($type == 'pie')
{
print 'var data = ['."\n";
$i=0;
foreach($data as $serie)
{
//print '{ label: "'.($showlegend?$serie['values'][0]:$serie['label'].'<br>'.$serie['values'][0]).'", data: '.$serie['values'][0].' }';
print '{ label: "'.($showlegend?$serie['label'].'<br>'.$serie['values'][0]:$serie['label'].'<br>'.$serie['values'][0]).'", data: '.$serie['values'][0].' }';
if ($i < sizeof($serie)) print ',';
print "\n";
$i++;
}
print '];
jQuery.plot(jQuery("#'.$htmlid.'"), data,
{
series: {pie: {
show: true,
radius: 3/4,
label: {
show: true,
radius: 3/4,
formatter: function(label, series){
return \'<div style="font-size:8pt;text-align:center;padding:2px;color:white;">\'+label
/* +\'<br/>\'+Math.round(series.percent)*/
+\'</div>\';
},
background: {
opacity: 0.5,
color: \'#000\'
}
}
} },
legend: {show: '.($showlegend?'true':'false').'}
});
});
</script>';
}
}
}
/**
* Truncate a string to a particular length adding '...' if string larger than length.
* If length = max length+1, we do no truncate to avoid having just 1 char replaced with '...'.
* MAIN_DISABLE_TRUNC=1 can disable all truncings
* @param string String to truncate
* @param size Max string size. 0 for no limit.
* @param trunc Where to trunc: right, left, middle, wrap
* @param stringencoding Tell what is source string encoding
* @return string Truncated string
*/
function dol_trunc($string,$size=40,$trunc='right',$stringencoding='UTF-8')
{

View File

@ -890,10 +890,9 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs
print '<!-- Includes for JQuery (Ajax library) -->'."\n";
$jquerytheme = 'smoothness';
if (!empty($conf->global->MAIN_USE_JQUERY_THEME)) $jquerytheme = $conf->global->MAIN_USE_JQUERY_THEME;
print '<link rel="stylesheet" href="'.DOL_URL_ROOT.'/includes/jquery/css/'.$jquerytheme.'/jquery-ui-latest.custom.css" type="text/css" />'."\n";
print '<link rel="stylesheet" href="'.DOL_URL_ROOT.'/includes/jquery/plugins/tooltip/jquery.tooltip.css" type="text/css" />'."\n";
// jQuery jnotify
if (!empty($conf->global->MAIN_USE_JQUERY_JNOTIFY)) print '<link rel="stylesheet" href="'.DOL_URL_ROOT.'/includes/jquery/plugins/jnotify/jquery.jnotify.min.css" type="text/css" />'."\n";
print '<link rel="stylesheet" href="'.DOL_URL_ROOT.'/includes/jquery/css/'.$jquerytheme.'/jquery-ui-latest.custom.css" type="text/css" />'."\n"; // JQuery
print '<link rel="stylesheet" href="'.DOL_URL_ROOT.'/includes/jquery/plugins/tooltip/jquery.tooltip.css" type="text/css" />'."\n"; // Tooltip
print '<link rel="stylesheet" href="'.DOL_URL_ROOT.'/includes/jquery/plugins/jnotify/jquery.jnotify.min.css" type="text/css" />'."\n"; // JNotify
}
print '<!-- Includes for Dolibarr, modules or specific pages-->'."\n";
@ -944,7 +943,11 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs
}
// jQuery jnotify
if (!empty($conf->global->MAIN_USE_JQUERY_JNOTIFY)) print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/jnotify/jquery.jnotify.min.js"></script>'."\n";
// CKEditor
// Flot
print '<!--[if lte IE 8]><script language="javascript" type="text/javascript" src="'.DOL_URL_ROOT.'/includes/flot/excanvas.min.js"></script><![endif]-->'."\n";
print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/flot/jquery.flot.min.js"></script>'."\n";
print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/flot/jquery.flot.pie.min.js"></script>'."\n";
// CKEditor
if (!empty($conf->global->FCKEDITOR_EDITORNAME) && $conf->global->FCKEDITOR_EDITORNAME == 'ckeditor')
{
print '<!-- Includes JS for CKEditor -->'."\n";
@ -991,7 +994,7 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs
print '<script type="text/javascript">';
print 'var tradMonths = '.json_encode($tradMonths).';';
print '</script>'."\n";
// Define tradMonthsMin javascript array (we define this in datapicker AND in parent page to avoid errors with IE8)
$tradMonthsMin=array($langs->trans("JanuaryMin"),
$langs->trans("FebruaryMin"),
@ -1009,7 +1012,7 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs
print '<script type="text/javascript">';
print 'var tradMonthsMin = '.json_encode($tradMonthsMin).';';
print '</script>'."\n";
// Define tradDays javascript array (we define this in datapicker AND in parent page to avoid errors with IE8)
$tradDays=array($langs->trans("Monday"),
$langs->trans("Tuesday"),
@ -1022,7 +1025,7 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs
print '<script type="text/javascript">';
print 'var tradDays = '.json_encode($tradDays).';';
print '</script>'."\n";
// Define tradDaysMin javascript array (we define this in datapicker AND in parent page to avoid errors with IE8)
$tradDaysMin=array($langs->trans("MondayMin"),
$langs->trans("TuesdayMin"),

View File

@ -100,34 +100,29 @@ else dol_print_error($db);
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("Statistics").'</td></tr>';
if ($conf->use_javascript_ajax && $conf->societe->enabled && $conf->fournisseur->enabled
&& empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS))
if ($conf->use_javascript_ajax)
{
print '<tr><td align="center">';
$data=array(
array('label'=>$langs->trans("Prospects"),'values'=>array(round($third['prospect']))),
array('label'=>$langs->trans("Customers"),'values'=>array(round($third['customer']))),
array('label'=>$langs->trans("Suppliers"),'values'=>array(round($third['supplier'])))
);
$data=array();
if ($conf->societe->enabled && empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) $data[]=array('label'=>$langs->trans("Prospects"),'values'=>array(round($third['prospect'])));
if ($conf->societe->enabled && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) $data[]=array('label'=>$langs->trans("Customers"),'values'=>array(round($third['customer'])));
if ($conf->fournisseur->enabled) $data[]=array('label'=>$langs->trans("Suppliers"),'values'=>array(round($third['supplier'])));
dol_print_graph('stats',300,180,$data,0,'pie');
print '</td></tr>';
}
else
{
if ($conf->societe->enabled)
if ($conf->societe->enabled && empty($conf->global->SOCIETE_DISABLE_PROSPECTS))
{
if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS))
{
$statstring = "<tr $bc[0]>";
$statstring.= '<td><a href="'.DOL_URL_ROOT.'/comm/prospect/prospects.php">'.$langs->trans("Prospects").'</a></td><td align="right">'.round($third['prospect']).'</td>';
$statstring.= "</tr>";
}
if (empty($conf->global->SOCIETE_DISABLE_CUSTOMERS))
{
$statstring.= "<tr $bc[1]>";
$statstring.= '<td><a href="'.DOL_URL_ROOT.'/comm/clients.php">'.$langs->trans("Customers").'</a></td><td align="right">'.round($third['customer']).'</td>';
$statstring.= "</tr>";
}
$statstring = "<tr $bc[0]>";
$statstring.= '<td><a href="'.DOL_URL_ROOT.'/comm/prospect/prospects.php">'.$langs->trans("Prospects").'</a></td><td align="right">'.round($third['prospect']).'</td>';
$statstring.= "</tr>";
}
if ($conf->societe->enabled && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS))
{
$statstring.= "<tr $bc[1]>";
$statstring.= '<td><a href="'.DOL_URL_ROOT.'/comm/clients.php">'.$langs->trans("Customers").'</a></td><td align="right">'.round($third['customer']).'</td>';
$statstring.= "</tr>";
}
if ($conf->fournisseur->enabled)
{