From 227c5d662b8ce288890551ac470c7011a80bd2c9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 13 May 2011 18:08:55 +0000 Subject: [PATCH] New: First add of js graph --- COPYRIGHT | 11 ++++- ChangeLog | 3 +- htdocs/lib/functions.lib.php | 91 ++++++++++++++++++++++++++++++++---- htdocs/main.inc.php | 19 ++++---- htdocs/societe/index.php | 35 ++++++-------- 5 files changed, 120 insertions(+), 39 deletions(-) diff --git a/COPYRIGHT b/COPYRIGHT index be28ed8848f..d158e188797 100644 --- a/COPYRIGHT +++ b/COPYRIGHT @@ -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 +- Regis Houssin +- Juanjo Menent +- Philippe Grand + Copyright (C) 2010 - Laurent Destailleur - Regis Houssin -- simnandez +- Juanjo Menent - r2gnl - meos Copyright (C) 2009 - Laurent Destailleur - Regis Houssin -- simnandez +- Juanjo Menent Copyright (C) 2008 - Laurent Destailleur diff --git a/ChangeLog b/ChangeLog index 6e434bdb0f8..90517b2b4d0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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 diff --git a/htdocs/lib/functions.lib.php b/htdocs/lib/functions.lib.php index 6d4f4a2c879..d58c49cc71f 100644 --- a/htdocs/lib/functions.lib.php +++ b/htdocs/lib/functions.lib.php @@ -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 '
'; + + // We use Flot js lib + if ($jsgraphlib == 'flot') + { + print ''; + } + } +} + +/** + * 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') { diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 4f202376d61..66de6ee6ef0 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -890,10 +890,9 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs print ''."\n"; $jquerytheme = 'smoothness'; if (!empty($conf->global->MAIN_USE_JQUERY_THEME)) $jquerytheme = $conf->global->MAIN_USE_JQUERY_THEME; - print ''."\n"; - print ''."\n"; - // jQuery jnotify - if (!empty($conf->global->MAIN_USE_JQUERY_JNOTIFY)) print ''."\n"; + print ''."\n"; // JQuery + print ''."\n"; // Tooltip + print ''."\n"; // JNotify } print ''."\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 ''."\n"; - // CKEditor + // Flot + print ''."\n"; + print ''."\n"; + print ''."\n"; + // CKEditor if (!empty($conf->global->FCKEDITOR_EDITORNAME) && $conf->global->FCKEDITOR_EDITORNAME == 'ckeditor') { print ''."\n"; @@ -991,7 +994,7 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs print ''."\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 ''."\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 ''."\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"), diff --git a/htdocs/societe/index.php b/htdocs/societe/index.php index 4e95ea291cd..d70b2fcb3cd 100644 --- a/htdocs/societe/index.php +++ b/htdocs/societe/index.php @@ -100,34 +100,29 @@ else dol_print_error($db); print ''; print ''; -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 ''; } else { - if ($conf->societe->enabled) + if ($conf->societe->enabled && empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) { - if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) - { - $statstring = ""; - $statstring.= ''; - $statstring.= ""; - } - if (empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) - { - $statstring.= ""; - $statstring.= ''; - $statstring.= ""; - } + $statstring = ""; + $statstring.= ''; + $statstring.= ""; + } + if ($conf->societe->enabled && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) + { + $statstring.= ""; + $statstring.= ''; + $statstring.= ""; } if ($conf->fournisseur->enabled) {
'.$langs->trans("Statistics").'
'; - $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 '
'.$langs->trans("Prospects").''.round($third['prospect']).'
'.$langs->trans("Customers").''.round($third['customer']).'
'.$langs->trans("Prospects").''.round($third['prospect']).'
'.$langs->trans("Customers").''.round($third['customer']).'