Support UTF8
This commit is contained in:
parent
c7569e6316
commit
e6107ea32f
@ -82,8 +82,9 @@ class FactureStats extends Stats
|
|||||||
*/
|
*/
|
||||||
function getNbByYear()
|
function getNbByYear()
|
||||||
{
|
{
|
||||||
$sql = "SELECT date_format(datef,'%Y') as dm, count(*)";
|
$sql = "SELECT YEAR(datef) as dm, count(*)";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX.$this->table_element." GROUP BY dm DESC";
|
$sql.= " FROM ".MAIN_DB_PREFIX.$this->table_element;
|
||||||
|
$sql.= " GROUP BY dm DESC";
|
||||||
$sql.= " WHERE ".$this->where;
|
$sql.= " WHERE ".$this->where;
|
||||||
|
|
||||||
return $this->_getNbByYear($sql);
|
return $this->_getNbByYear($sql);
|
||||||
@ -97,9 +98,9 @@ class FactureStats extends Stats
|
|||||||
*/
|
*/
|
||||||
function getNbByMonth($year)
|
function getNbByMonth($year)
|
||||||
{
|
{
|
||||||
$sql = "SELECT date_format(datef,'%m') as dm, count(*)";
|
$sql = "SELECT MONTH(datef) as dm, count(*)";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX.$this->table_element;
|
$sql.= " FROM ".MAIN_DB_PREFIX.$this->table_element;
|
||||||
$sql.= " WHERE date_format(datef,'%Y') = ".$year;
|
$sql.= " WHERE YEAR(datef) = ".$year;
|
||||||
$sql.= " AND ".$this->where;
|
$sql.= " AND ".$this->where;
|
||||||
$sql.= " GROUP BY dm DESC";
|
$sql.= " GROUP BY dm DESC";
|
||||||
|
|
||||||
|
|||||||
@ -70,9 +70,9 @@ $stats = new FactureStats($db, $socid, $mode);
|
|||||||
|
|
||||||
|
|
||||||
// Build graphic number of object
|
// Build graphic number of object
|
||||||
|
// $data = array(array('Lib',val1,val2,val3),...)
|
||||||
$data = $stats->getNbByMonthWithPrevYear($endyear,$startyear);
|
$data = $stats->getNbByMonthWithPrevYear($endyear,$startyear);
|
||||||
//var_dump($data);
|
//var_dump($data);
|
||||||
// $data = array(array('Lib',val1,val2,val3),...)
|
|
||||||
|
|
||||||
$filenamenb = $dir."/invoicesnbinyear-".$year.".png";
|
$filenamenb = $dir."/invoicesnbinyear-".$year.".png";
|
||||||
if ($mode == 'customer') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=billstats&file=invoicesnbinyear-'.$year.'.png';
|
if ($mode == 'customer') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=billstats&file=invoicesnbinyear-'.$year.'.png';
|
||||||
|
|||||||
@ -16,16 +16,14 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
*
|
|
||||||
* $Id$
|
|
||||||
* $Source$
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\file htdocs/includes/boxes/box_services_vendus.php
|
* \file htdocs/includes/boxes/box_services_vendus.php
|
||||||
\ingroup produits,services
|
* \ingroup produits,services
|
||||||
\brief Module de génération de l'affichage de la box services_vendus
|
* \brief Module de génération de l'affichage de la box services_vendus
|
||||||
*/
|
* \version $Id$
|
||||||
|
*/
|
||||||
|
|
||||||
include_once(DOL_DOCUMENT_ROOT."/includes/boxes/modules_boxes.php");
|
include_once(DOL_DOCUMENT_ROOT."/includes/boxes/modules_boxes.php");
|
||||||
|
|
||||||
@ -95,7 +93,6 @@ class box_services_vendus extends ModeleBoxes {
|
|||||||
$sql.= $db->plimit($max, 0);
|
$sql.= $db->plimit($max, 0);
|
||||||
|
|
||||||
$result = $db->query($sql);
|
$result = $db->query($sql);
|
||||||
|
|
||||||
if ($result)
|
if ($result)
|
||||||
{
|
{
|
||||||
$num = $db->num_rows($result);
|
$num = $db->num_rows($result);
|
||||||
|
|||||||
@ -209,17 +209,12 @@ class ModeleBoxes
|
|||||||
$maxlength=$this->MAXLENGTHBOX;
|
$maxlength=$this->MAXLENGTHBOX;
|
||||||
if (isset($contents[$i][$j]['maxlength'])) $maxlength=$contents[$i][$j]['maxlength'];
|
if (isset($contents[$i][$j]['maxlength'])) $maxlength=$contents[$i][$j]['maxlength'];
|
||||||
|
|
||||||
if ($maxlength && strlen($textewithnotags) > $maxlength)
|
if ($maxlength) $textewithnotags=dolibarr_trunc($textewithnotags,$maxlength);
|
||||||
{
|
print $textewithnotags;
|
||||||
$texte=substr($texte,0,$maxlength)."...";
|
|
||||||
}
|
//print $texte;
|
||||||
if ($maxlength && strlen($texte2withnotags) > $maxlength)
|
|
||||||
{
|
|
||||||
$texte2=substr($texte2,0,$maxlength)."...";
|
|
||||||
}
|
|
||||||
print $texte;
|
|
||||||
if (isset($contents[$i][$j]['url'])) print '</a>';
|
if (isset($contents[$i][$j]['url'])) print '</a>';
|
||||||
print $texte2;
|
print $texte2withnotags;
|
||||||
print "</td>";
|
print "</td>";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -844,6 +844,60 @@ function dol_print_phone_link($phone,$option=0)
|
|||||||
return $link;
|
return $link;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Make a strlen call. Works even in mbstring module not enabled
|
||||||
|
*
|
||||||
|
* @param unknown_type $string
|
||||||
|
* @param unknown_type $stringencoding
|
||||||
|
* @return unknown
|
||||||
|
*/
|
||||||
|
function dol_strlen($string,$stringencoding='')
|
||||||
|
{
|
||||||
|
global $langs;
|
||||||
|
|
||||||
|
if (empty($stringencoding)) $stringencoding=$langs->charset_output;
|
||||||
|
|
||||||
|
$ret='';
|
||||||
|
if (function_exists('mb_strlen'))
|
||||||
|
{
|
||||||
|
$ret=mb_strlen($string,$stringencoding);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$ret=strlen($string);
|
||||||
|
}
|
||||||
|
return $ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Make a substring. Works even in mbstring module not enabled
|
||||||
|
*
|
||||||
|
* @param unknown_type $string
|
||||||
|
* @param unknown_type $start
|
||||||
|
* @param unknown_type $length
|
||||||
|
* @param unknown_type $stringencoding
|
||||||
|
* @return unknown
|
||||||
|
*/
|
||||||
|
function dol_substr($string,$start,$length,$stringencoding='')
|
||||||
|
{
|
||||||
|
global $langs;
|
||||||
|
|
||||||
|
if (empty($stringencoding)) $stringencoding=$langs->charset_output;
|
||||||
|
|
||||||
|
$ret='';
|
||||||
|
if (function_exists('mb_substr'))
|
||||||
|
{
|
||||||
|
$ret=mb_substr($string,$start,$length,$stringencoding);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$ret=substr($string,$start,$length);
|
||||||
|
}
|
||||||
|
return $ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Truncate a string to a particular length adding '...' if string larger than length
|
* \brief Truncate a string to a particular length adding '...' if string larger than length
|
||||||
* \param string String to truncate
|
* \param string String to truncate
|
||||||
@ -852,7 +906,7 @@ function dol_print_phone_link($phone,$option=0)
|
|||||||
* \return string Truncated string
|
* \return string Truncated string
|
||||||
* \remarks USE_SHORT_TITLE=0 can disable all truncings
|
* \remarks USE_SHORT_TITLE=0 can disable all truncings
|
||||||
*/
|
*/
|
||||||
function dolibarr_trunc($string,$size=40,$trunc='right')
|
function dolibarr_trunc($string,$size=40,$trunc='right',$stringencoding='')
|
||||||
{
|
{
|
||||||
global $conf;
|
global $conf;
|
||||||
|
|
||||||
@ -862,29 +916,26 @@ function dolibarr_trunc($string,$size=40,$trunc='right')
|
|||||||
// We go always here
|
// We go always here
|
||||||
if ($trunc == 'right')
|
if ($trunc == 'right')
|
||||||
{
|
{
|
||||||
//mb_internal_encoding("UTF-8");
|
if (dol_strlen($string,$stringencoding) > $size)
|
||||||
//print $conf->character_set_client.'-'.mb_strlen($string).'-'.strlen($string);
|
return dol_substr($string,0,$size,$stringencoding).'...';
|
||||||
//print 'ee'.$string.$size.mb_strcut($string,0,$size,'UTF-8').'rr';
|
|
||||||
if (strlen($string) > $size)
|
|
||||||
return substr($string,0,$size).'...';
|
|
||||||
else
|
else
|
||||||
return $string;
|
return $string;
|
||||||
}
|
}
|
||||||
if ($trunc == 'middle')
|
if ($trunc == 'middle')
|
||||||
{
|
{
|
||||||
if (strlen($string) > 2 && strlen($string) > $size)
|
if (dol_strlen($string,$stringencoding) > 2 && dol_strlen($string,$stringencoding) > $size)
|
||||||
{
|
{
|
||||||
$size1=round($size/2);
|
$size1=round($size/2);
|
||||||
$size2=round($size/2);
|
$size2=round($size/2);
|
||||||
return substr($string,0,$size1).'...'.substr($string,strlen($string) - $size2,$size2);
|
return dol_substr($string,0,$size1,$stringencoding).'...'.dol_substr($string,dol_strlen($string,$stringencoding) - $size2,$size2,$stringencoding);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return $string;
|
return $string;
|
||||||
}
|
}
|
||||||
if ($trunc == 'left')
|
if ($trunc == 'left')
|
||||||
{
|
{
|
||||||
if (strlen($string) > $size)
|
if (dol_strlen($string,$stringencoding) > $size)
|
||||||
return '...'.substr($string,strlen($string) - $size,$size);
|
return '...'.dol_substr($string,dol_strlen($string,$stringencoding) - $size,$size,$stringencoding);
|
||||||
else
|
else
|
||||||
return $string;
|
return $string;
|
||||||
}
|
}
|
||||||
@ -896,12 +947,12 @@ function dolibarr_trunc($string,$size=40,$trunc='right')
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\brief Compl<EFBFBD>te une chaine a une taille donn<EFBFBD>e par des espaces
|
* \brief Complete une chaine a une taille donnee par des espaces
|
||||||
\param string Chaine a compl<EFBFBD>ter
|
* \param string Chaine a completer
|
||||||
\param size Longueur de la chaine.
|
* \param size Longueur de la chaine.
|
||||||
\param side 0=Compl<EFBFBD>tion a droite, 1=Compl<EFBFBD>tion a gauche
|
* \param side 0=Completion a droite, 1=Completion a gauche
|
||||||
\param char Chaine de compl<EFBFBD>tion
|
* \param char Chaine de completion
|
||||||
\return string Chaine compl<EFBFBD>t<EFBFBD>e
|
* \return string Chaine complete
|
||||||
*/
|
*/
|
||||||
function dolibarr_pad($string,$size,$side,$char=' ')
|
function dolibarr_pad($string,$size,$side,$char=' ')
|
||||||
{
|
{
|
||||||
@ -917,10 +968,10 @@ function dolibarr_pad($string,$size,$side,$char=' ')
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\brief Affiche picto propre a une notion/module (fonction g<EFBFBD>n<EFBFBD>rique)
|
* \brief Affiche picto propre a une notion/module (fonction g<EFBFBD>n<EFBFBD>rique)
|
||||||
\param alt Texte sur le alt de l'image
|
* \param alt Texte sur le alt de l'image
|
||||||
\param object Objet pour lequel il faut afficher le logo (exemple: user, group, action, bill, contract, propal, product, ...)
|
* \param object Objet pour lequel il faut afficher le logo (exemple: user, group, action, bill, contract, propal, product, ...)
|
||||||
\return string Retourne tag img
|
* \return string Retourne tag img
|
||||||
*/
|
*/
|
||||||
function img_object($alt, $object)
|
function img_object($alt, $object)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -191,6 +191,10 @@ class Stats
|
|||||||
}
|
}
|
||||||
$this->db->free($resql);
|
$this->db->free($resql);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dolibarr_print_error($this->db);
|
||||||
|
}
|
||||||
|
|
||||||
for ($i = 1 ; $i < 13 ; $i++)
|
for ($i = 1 ; $i < 13 ; $i++)
|
||||||
{
|
{
|
||||||
@ -201,7 +205,9 @@ class Stats
|
|||||||
|
|
||||||
for ($i = 1 ; $i < 13 ; $i++)
|
for ($i = 1 ; $i < 13 ; $i++)
|
||||||
{
|
{
|
||||||
$data[$i-1] = array(ucfirst(substr(dolibarr_print_date(dolibarr_mktime(12,0,0,$i,1,$year),"%b"),0,3)), $res[$i]);
|
$month=dolibarr_print_date(dolibarr_mktime(12,0,0,$i,1,$year),"%b");
|
||||||
|
$month=dol_substr($month,0,3);
|
||||||
|
$data[$i-1] = array(ucfirst($month), $res[$i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
@ -241,14 +247,16 @@ class Stats
|
|||||||
|
|
||||||
for ($i = 1 ; $i < 13 ; $i++)
|
for ($i = 1 ; $i < 13 ; $i++)
|
||||||
{
|
{
|
||||||
$data[$i-1] = array(ucfirst(substr(dolibarr_print_date(dolibarr_mktime(12,0,0,$i,1,$year),"%b"),0,3)), $res[$i]);
|
$month=dolibarr_print_date(dolibarr_mktime(12,0,0,$i,1,$year),"%b");
|
||||||
|
$month=dol_substr($month,0,3);
|
||||||
|
$data[$i-1] = array(ucfirst($month), $res[$i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* \brief Renvoie le montant moyen par mois pour une annee donnee
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function _getAverageByMonth($year, $sql)
|
function _getAverageByMonth($year, $sql)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user