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 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 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 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 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 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 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
--------- ---------
Copyright (C) 2011
- Laurent Destailleur <eldy@users.sourceforge.net>
- Regis Houssin <regis@dolibarr.fr>
- Juanjo Menent
- Philippe Grand
Copyright (C) 2010 Copyright (C) 2010
- Laurent Destailleur <eldy@users.sourceforge.net> - Laurent Destailleur <eldy@users.sourceforge.net>
- Regis Houssin <regis@dolibarr.fr> - Regis Houssin <regis@dolibarr.fr>
- simnandez - Juanjo Menent
- r2gnl - r2gnl
- meos - meos
Copyright (C) 2009 Copyright (C) 2009
- Laurent Destailleur <eldy@users.sourceforge.net> - Laurent Destailleur <eldy@users.sourceforge.net>
- Regis Houssin <regis@dolibarr.fr> - Regis Houssin <regis@dolibarr.fr>
- simnandez - Juanjo Menent
Copyright (C) 2008 Copyright (C) 2008
- Laurent Destailleur <eldy@users.sourceforge.net> - 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 - Reduce a step into supplier order workflow to save time. If user
has permission to approve, order is approved when order is validated. has permission to approve, order is approved when order is validated.
(Save 2 clicks). (Save 2 clicks).
- New: First graph using javascripts.
- New: Can add a discount for third party, during invoice edition (and we - New: Can add a discount for third party, during invoice edition (and we
saved clicks again). saved clicks again).
- New: Add status for third parties. - New: Add status for third parties.
@ -41,7 +42,7 @@ For users:
or credit note invoice. or credit note invoice.
- New: task #10885: Add a week view for calendar - New: task #10885: Add a week view for calendar
- New: task #11018 : Add a status "not applicable" on event - 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: Can define a proxy for external web access.
- New: task #11003: checkbox on checks to deposit - New: task #11003: checkbox on checks to deposit
- New: Numbering module for invoice use same number for invoice - 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); return dol_trunc($string,$size,$trunc,$stringencoding);
} }
/** /**
* \brief Truncate a string to a particular length adding '...' if string larger than length. * Show a javascript graph
* If length = max length+1, we do no truncate to avoid having just 1 char replaced with '...'. * @param htmlid Html id name
* \param string String to truncate * @param width Width in pixel
* \param size Max string size. 0 for no limit. * @param height Height in pixel
* \param trunc Where to trunc: right, left, middle, wrap * @param data Data array
* \param stringencoding Tell what is source string encoding * @param type Type of graph
* \return string Truncated string */
* \remarks MAIN_DISABLE_TRUNC=1 can disable all truncings 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') 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"; print '<!-- Includes for JQuery (Ajax library) -->'."\n";
$jquerytheme = 'smoothness'; $jquerytheme = 'smoothness';
if (!empty($conf->global->MAIN_USE_JQUERY_THEME)) $jquerytheme = $conf->global->MAIN_USE_JQUERY_THEME; 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/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"; print '<link rel="stylesheet" href="'.DOL_URL_ROOT.'/includes/jquery/plugins/tooltip/jquery.tooltip.css" type="text/css" />'."\n"; // Tooltip
// jQuery jnotify print '<link rel="stylesheet" href="'.DOL_URL_ROOT.'/includes/jquery/plugins/jnotify/jquery.jnotify.min.css" type="text/css" />'."\n"; // 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 '<!-- Includes for Dolibarr, modules or specific pages-->'."\n"; 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 // 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"; 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') if (!empty($conf->global->FCKEDITOR_EDITORNAME) && $conf->global->FCKEDITOR_EDITORNAME == 'ckeditor')
{ {
print '<!-- Includes JS for CKEditor -->'."\n"; 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 '<script type="text/javascript">';
print 'var tradMonths = '.json_encode($tradMonths).';'; print 'var tradMonths = '.json_encode($tradMonths).';';
print '</script>'."\n"; print '</script>'."\n";
// Define tradMonthsMin javascript array (we define this in datapicker AND in parent page to avoid errors with IE8) // Define tradMonthsMin javascript array (we define this in datapicker AND in parent page to avoid errors with IE8)
$tradMonthsMin=array($langs->trans("JanuaryMin"), $tradMonthsMin=array($langs->trans("JanuaryMin"),
$langs->trans("FebruaryMin"), $langs->trans("FebruaryMin"),
@ -1009,7 +1012,7 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs
print '<script type="text/javascript">'; print '<script type="text/javascript">';
print 'var tradMonthsMin = '.json_encode($tradMonthsMin).';'; print 'var tradMonthsMin = '.json_encode($tradMonthsMin).';';
print '</script>'."\n"; print '</script>'."\n";
// Define tradDays javascript array (we define this in datapicker AND in parent page to avoid errors with IE8) // Define tradDays javascript array (we define this in datapicker AND in parent page to avoid errors with IE8)
$tradDays=array($langs->trans("Monday"), $tradDays=array($langs->trans("Monday"),
$langs->trans("Tuesday"), $langs->trans("Tuesday"),
@ -1022,7 +1025,7 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs
print '<script type="text/javascript">'; print '<script type="text/javascript">';
print 'var tradDays = '.json_encode($tradDays).';'; print 'var tradDays = '.json_encode($tradDays).';';
print '</script>'."\n"; print '</script>'."\n";
// Define tradDaysMin javascript array (we define this in datapicker AND in parent page to avoid errors with IE8) // Define tradDaysMin javascript array (we define this in datapicker AND in parent page to avoid errors with IE8)
$tradDaysMin=array($langs->trans("MondayMin"), $tradDaysMin=array($langs->trans("MondayMin"),
$langs->trans("TuesdayMin"), $langs->trans("TuesdayMin"),

View File

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