forked from Wavyzz/dolibarr
Merge branch 'review' of https://github.com/GPCsolutions/dolibarr into
GPCsolutions-review Conflicts: htdocs/accountancy/journal/bankjournal.php htdocs/accountancy/journal/cashjournal.php htdocs/accountancy/journal/purchasesjournal.php htdocs/comm/action/peruser.php htdocs/core/class/html.form.class.php htdocs/core/lib/accounting.lib.php htdocs/core/lib/report.lib.php
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
* Copyright (C) 2010-2014 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.fr>
|
||||
* Copyright (C) 2013 Alexandre Spangaro <alexandre.spangaro@gmail.com>
|
||||
* Copyright (C) 2014 Marcos García <marcosgdf@gmail.com>
|
||||
* Copyright (C) 2014 Marcos García <marcosgdf@gmail.com>
|
||||
* Copyright (C) 2014 Cédric GROSS <c.gross@kreiz-it.fr>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -44,14 +44,31 @@ include_once DOL_DOCUMENT_ROOT .'/core/lib/json.lib.php';
|
||||
* @param string $class Class name
|
||||
* @param string $member Name of property
|
||||
* @return mixed Return value of static property
|
||||
* @deprecated PHP 5.3 is now the minimum requirement, this is no longer necessary
|
||||
*/
|
||||
function getStaticMember($class, $member)
|
||||
{
|
||||
if (isset($class::$member)) {
|
||||
return $class::$member;
|
||||
}
|
||||
// This part is deprecated. Uncomment if for php 5.2.*, and comment next isset class::member
|
||||
/*if (version_compare(phpversion(), '5.3.0', '<'))
|
||||
{
|
||||
if (is_object($class)) $class = get_class($class);
|
||||
$classObj = new ReflectionClass($class);
|
||||
$result = null;
|
||||
|
||||
$found=0;
|
||||
foreach($classObj->getStaticProperties() as $prop => $value)
|
||||
{
|
||||
if ($prop == $member)
|
||||
{
|
||||
$result = $value;
|
||||
$found++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($found) return $result;
|
||||
}*/
|
||||
|
||||
if (isset($class::$member)) return $class::$member;
|
||||
dol_print_error('','Try to get a static member "'.$member.'" in class "'.$class.'" that does not exists or is not static.');
|
||||
return null;
|
||||
}
|
||||
@@ -148,6 +165,7 @@ function getBrowserInfo()
|
||||
$detectmobile=new MobileDetect();
|
||||
$phone=$detectmobile->isMobile();
|
||||
$tablet=$detectmobile->isTablet();
|
||||
unset($detectmobile); // free memory
|
||||
|
||||
return array('browsername'=>$name, 'browserversion'=>$version, 'browseros'=>$os, 'browserfirefox'=>$firefox, 'layout'=> ($tablet?'tablet':($phone?'phone':'classic')), 'phone'=>$phone, 'tablet'=>$tablet);
|
||||
}
|
||||
@@ -170,11 +188,11 @@ function dol_shutdown()
|
||||
* Return value of a param into GET or POST supervariable
|
||||
*
|
||||
* @param string $paramname Name of parameter to found
|
||||
* @param string $check Type of check (''=no check, 'int'=check it's numeric, 'alpha'=check it's text and sign, 'aZ'=check it's a-z only, 'array'=check it's array, 'san_alpha'= Use filter_var with FILTER_SANITIZE_STRING, 'custom'= custom filter specify $filter and $options)
|
||||
* @param string $check Type of check (''=no check, 'int'=check it's numeric, 'alpha'=check it's text and sign, 'aZ'=check it's a-z only, 'array'=check it's array, 'san_alpha'= Use filter_var with FILTER_SANITIZE_STRING (do not use this for free text string), 'custom'= custom filter specify $filter and $options)
|
||||
* @param int $method Type of method (0 = get then post, 1 = only get, 2 = only post, 3 = post then get, 4 = post then get then cookie)
|
||||
* @param int $filter Filter to apply when $check is set to custom. (See http://php.net/manual/en/filter.filters.php for détails)
|
||||
* @param mixed $options Options to pass to filter_var when $check is set to custom
|
||||
* @return string||string[] Value found, or '' if check fails
|
||||
* @return string||string[] Value found (string or array), or '' if check fails
|
||||
*/
|
||||
function GETPOST($paramname,$check='',$method=0,$filter=NULL,$options=NULL)
|
||||
{
|
||||
@@ -453,6 +471,18 @@ function dol_string_nospecial($str,$newstr='_',$badchars='')
|
||||
return str_replace($forbidden_chars_to_replace,$newstr,str_replace($forbidden_chars_to_remove,"",$str));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Encode string for xml usage
|
||||
*
|
||||
* @param string $string String to encode
|
||||
* @return string String encoded
|
||||
*/
|
||||
function dolEscapeXML($string)
|
||||
{
|
||||
return strtr($string, array('\''=>''','"'=>'"','&'=>'&','<'=>'<','>'=>'>'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns text escaped for inclusion into javascript code
|
||||
*
|
||||
@@ -629,7 +659,7 @@ function dol_fiche_head($links=array(), $active='0', $title='', $notab=0, $picto
|
||||
*/
|
||||
function dol_get_fiche_head($links=array(), $active='0', $title='', $notab=0, $picto='', $pictoisfullpath=0)
|
||||
{
|
||||
global $conf;
|
||||
global $conf,$langs;
|
||||
|
||||
$out="\n".'<div class="tabs" data-role="controlgroup" data-type="horizontal">'."\n";
|
||||
|
||||
@@ -654,35 +684,82 @@ function dol_get_fiche_head($links=array(), $active='0', $title='', $notab=0, $p
|
||||
}
|
||||
|
||||
// Show tabs
|
||||
$bactive=false;
|
||||
// if =0 we don't use the feature
|
||||
$limittoshow=($conf->global->MAXTABS_IN_CARD?$conf->global->MAXTABS_IN_CARD:99);
|
||||
$displaytab=0;
|
||||
|
||||
for ($i = 0 ; $i <= $maxkey ; $i++)
|
||||
{
|
||||
$isactive=(is_numeric($active) && $i == $active) || (! is_numeric($active) && $active == $links[$i][2]);
|
||||
|
||||
$out.='<div class="inline-block tabsElem'.((! $isactive && ! empty($conf->global->MAIN_HIDE_INACTIVETAB_ON_PRINT))?' hideonprint':'').'">';
|
||||
if (isset($links[$i][2]) && $links[$i][2] == 'image')
|
||||
if ((is_numeric($active) && $i == $active) || (! is_numeric($active) && $active == $links[$i][2]))
|
||||
{
|
||||
if (!empty($links[$i][0]))
|
||||
{
|
||||
$out.='<a data-role="button" class="tabimage" href="'.$links[$i][0].'">'.$links[$i][1].'</a>'."\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
$out.='<span data-role="button" class="tabspan">'.$links[$i][1].'</span>'."\n";
|
||||
}
|
||||
$isactive=true;
|
||||
$bactive=true;
|
||||
if ($i <=$limittoshow)
|
||||
$limittoshow++;
|
||||
}
|
||||
else if (! empty($links[$i][1]))
|
||||
else
|
||||
$isactive=false;
|
||||
|
||||
if ($i <=$limittoshow || $isactive )
|
||||
{
|
||||
//print "x $i $active ".$links[$i][2]." z";
|
||||
if ($isactive)
|
||||
$out.='<div class="inline-block tabsElem'.($isactive ? ' tabsElemActive' : '').((! $isactive && ! empty($conf->global->MAIN_HIDE_INACTIVETAB_ON_PRINT))?' hideonprint':'').'">';
|
||||
if (isset($links[$i][2]) && $links[$i][2] == 'image')
|
||||
{
|
||||
$out.='<a data-role="button"'.(! empty($links[$i][2])?' id="'.$links[$i][2].'"':'').' class="tabactive tab inline-block" href="'.$links[$i][0].'">'.$links[$i][1].'</a>'."\n";
|
||||
if (!empty($links[$i][0]))
|
||||
{
|
||||
$out.='<a data-role="button" class="tabimage" href="'.$links[$i][0].'">'.$links[$i][1].'</a>'."\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
$out.='<span data-role="button" class="tabspan">'.$links[$i][1].'</span>'."\n";
|
||||
}
|
||||
}
|
||||
else
|
||||
else if (! empty($links[$i][1]))
|
||||
{
|
||||
$out.='<a data-role="button"'.(! empty($links[$i][2])?' id="'.$links[$i][2].'"':'').' class="tab inline-block" href="'.$links[$i][0].'">'.$links[$i][1].'</a>'."\n";
|
||||
//print "x $i $active ".$links[$i][2]." z";
|
||||
if ($isactive)
|
||||
{
|
||||
$out.='<a data-role="button"'.(! empty($links[$i][2])?' id="'.$links[$i][2].'"':'').' class="tabactive tab inline-block" href="'.$links[$i][0].'">'.$links[$i][1].'</a>'."\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
$out.='<a data-role="button"'.(! empty($links[$i][2])?' id="'.$links[$i][2].'"':'').' class="tab inline-block" href="'.$links[$i][0].'">'.$links[$i][1].'</a>'."\n";
|
||||
}
|
||||
}
|
||||
$out.='</div>';
|
||||
}
|
||||
$out.='</div>';
|
||||
else
|
||||
{
|
||||
$outmore.='<div class="" style="display:inherit; background-color:#f9f9f9; padding-top:5px; padding-right:15px; padding-left:12px;">';
|
||||
if (isset($links[$i][2]) && $links[$i][2] == 'image')
|
||||
{
|
||||
if (!empty($links[$i][0]))
|
||||
$outmore.='<a class="tabimage" href="'.$links[$i][0].'">'.$links[$i][1].'</a>'."\n";
|
||||
else
|
||||
$outmore.='<span class="tabspan">'.$links[$i][1].'</span>'."\n";
|
||||
|
||||
}
|
||||
else if (! empty($links[$i][1]))
|
||||
$outmore.='<a "'.(! empty($links[$i][2])?' id="'.$links[$i][2].'"':'').' class="inline-block" href="'.$links[$i][0].'">'.$links[$i][1].'</a>'."\n";
|
||||
|
||||
$outmore.='</div>';
|
||||
}
|
||||
$displaytab=$i;
|
||||
}
|
||||
|
||||
if ($displaytab > $limittoshow)
|
||||
{
|
||||
$out.='<div id="moretabs" class="inline-block tabsElem">';
|
||||
$out.='<a href="" data-role="button" style="background-color: #f0f0f0;" class="tab inline-block">'.$langs->trans("More").'...</a>';
|
||||
$out.='<div id="moretabsList" style="position: absolute; left: -999em;text-align: left;margin:0px;padding:2px">'.$outmore.'</div>';
|
||||
$out.="</div>\n";
|
||||
|
||||
$out.="<script>";
|
||||
$out.="$('#moretabs').mouseenter( function() { $('#moretabsList').css('left','auto');});";
|
||||
$out.="$('#moretabs').mouseleave( function() { $('#moretabsList').css('left','-999em');});";
|
||||
$out.="</script>";
|
||||
}
|
||||
|
||||
$out.="</div>\n";
|
||||
@@ -736,11 +813,12 @@ function dol_bc($var,$moreclass='')
|
||||
* @param Object $object A company or contact object
|
||||
* @param int $withcountry 1=Add country into address string
|
||||
* @param string $sep Separator to use to build string
|
||||
* @param Tranlsate $outputlangs Object lang that contains language for text translation.
|
||||
* @return string Formated string
|
||||
*/
|
||||
function dol_format_address($object,$withcountry=0,$sep="\n")
|
||||
function dol_format_address($object,$withcountry=0,$sep="\n",$outputlangs='')
|
||||
{
|
||||
global $conf;
|
||||
global $conf,$langs;
|
||||
|
||||
$ret='';
|
||||
$countriesusingstate=array('AU','US','IN','GB','ES','UK','TR');
|
||||
@@ -769,7 +847,7 @@ function dol_format_address($object,$withcountry=0,$sep="\n")
|
||||
else if (in_array($object->country_code,array('ES','TR'))) // ES: title firstname name \n address lines \n zip town \n state \n country
|
||||
{
|
||||
$ret .= ($ret ? $sep : '' ).$object->zip;
|
||||
$ret .= ' '.$object->town;
|
||||
$ret .= ($object->town?' '.$object->town:'');
|
||||
if ($object->state && in_array($object->country_code,$countriesusingstate))
|
||||
{
|
||||
$ret.="\n".$object->state;
|
||||
@@ -779,14 +857,14 @@ function dol_format_address($object,$withcountry=0,$sep="\n")
|
||||
else // Other: title firstname name \n address lines \n zip town \n country
|
||||
{
|
||||
$ret .= ($ret ? $sep : '' ).$object->zip;
|
||||
$ret .= ' '.$object->town;
|
||||
$ret .= ($object->town?' '.$object->town:'');
|
||||
if ($object->state && in_array($object->country_code,$countriesusingstate))
|
||||
{
|
||||
$ret.=", ".$object->state;
|
||||
}
|
||||
}
|
||||
|
||||
if ($withcountry) $ret.=($object->country?$sep.$object->country:'');
|
||||
if (! is_object($outputlangs)) $outputlangs=$langs;
|
||||
if ($withcountry) $ret.=($object->country_code?($ret?$sep:'').$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv("Country".$object->country_code)):'');
|
||||
|
||||
return $ret;
|
||||
}
|
||||
@@ -997,6 +1075,8 @@ function dol_print_date($time,$format='',$tzoutput='tzserver',$outputlangs='',$e
|
||||
*/
|
||||
function dol_getdate($timestamp,$fast=false)
|
||||
{
|
||||
global $conf;
|
||||
|
||||
$usealternatemethod=false;
|
||||
if ($timestamp <= 0) $usealternatemethod=true; // <= 1970
|
||||
if ($timestamp >= 2145913200) $usealternatemethod=true; // >= 2038
|
||||
@@ -1008,6 +1088,19 @@ function dol_getdate($timestamp,$fast=false)
|
||||
else
|
||||
{
|
||||
$arrayinfo=getdate($timestamp);
|
||||
|
||||
$startday=isset($conf->global->MAIN_START_WEEK)?$conf->global->MAIN_START_WEEK:1;
|
||||
if($startday==1)
|
||||
{
|
||||
if ($arrayinfo["wday"]==0)
|
||||
{
|
||||
$arrayinfo["wday"]=6;
|
||||
}
|
||||
else
|
||||
{
|
||||
$arrayinfo["wday"]=$arrayinfo["wday"]-1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $arrayinfo;
|
||||
@@ -1026,7 +1119,7 @@ function dol_getdate($timestamp,$fast=false)
|
||||
* @param int $year Year
|
||||
* @param mixed $gm True or 1 or 'gmt'=Input informations are GMT values, False or 0 or 'server' = local to server TZ, 'user' = local to user TZ
|
||||
* @param int $check 0=No check on parameters (Can use day 32, etc...)
|
||||
* @return int Date as a timestamp, '' if error
|
||||
* @return timestamp|string Date as a timestamp, '' if error
|
||||
* @see dol_print_date, dol_stringtotime, dol_getdate
|
||||
*/
|
||||
function dol_mktime($hour,$minute,$second,$month,$day,$year,$gm=false,$check=1)
|
||||
@@ -1070,11 +1163,16 @@ function dol_mktime($hour,$minute,$second,$month,$day,$year,$gm=false,$check=1)
|
||||
$default_timezone=@date_default_timezone_get();
|
||||
}
|
||||
}
|
||||
else $localtz = new DateTimeZone('UTC');
|
||||
|
||||
if (empty($localtz)) {
|
||||
$localtz = new DateTimeZone('UTC');
|
||||
}
|
||||
|
||||
$dt = new DateTime(null,$localtz);
|
||||
$dt->setDate($year,$month,$day);
|
||||
$dt->setTime((int) $hour, (int) $minute, (int) $second);
|
||||
$date=$dt->getTimestamp(); // should include daylight saving time
|
||||
return $date;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1092,8 +1190,8 @@ function dol_mktime($hour,$minute,$second,$month,$day,$year,$gm=false,$check=1)
|
||||
{
|
||||
$date=mktime($hour,$minute,$second,$month,$day,$year);
|
||||
}*/
|
||||
return '';
|
||||
}
|
||||
return $date;
|
||||
}
|
||||
|
||||
|
||||
@@ -1200,9 +1298,10 @@ function dol_print_url($url,$target='_blank',$max=32)
|
||||
* @param int $addlink 0=no link, 1=email has a html email link (+ link to create action if constant AGENDA_ADDACTIONFOREMAIL is on)
|
||||
* @param int $max Max number of characters to show
|
||||
* @param int $showinvalid Show warning if syntax email is wrong
|
||||
* @param int $withpicto Show picto
|
||||
* @return string HTML Link
|
||||
*/
|
||||
function dol_print_email($email,$cid=0,$socid=0,$addlink=0,$max=64,$showinvalid=1)
|
||||
function dol_print_email($email,$cid=0,$socid=0,$addlink=0,$max=64,$showinvalid=1,$withpicto=0)
|
||||
{
|
||||
global $conf,$user,$langs;
|
||||
|
||||
@@ -1227,8 +1326,8 @@ function dol_print_email($email,$cid=0,$socid=0,$addlink=0,$max=64,$showinvalid=
|
||||
if (($cid || $socid) && ! empty($conf->agenda->enabled) && $user->rights->agenda->myactions->create)
|
||||
{
|
||||
$type='AC_EMAIL'; $link='';
|
||||
if (! empty($conf->global->AGENDA_ADDACTIONFOREMAIL)) $link='<a href="'.DOL_URL_ROOT.'/comm/action/fiche.php?action=create&backtopage=1&actioncode='.$type.'&contactid='.$cid.'&socid='.$socid.'">'.img_object($langs->trans("AddAction"),"calendar").'</a>';
|
||||
$newemail='<table class="nobordernopadding"><tr><td>'.$newemail.' </td><td> '.$link.'</td></tr></table>';
|
||||
if (! empty($conf->global->AGENDA_ADDACTIONFOREMAIL)) $link='<a href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create&backtopage=1&actioncode='.$type.'&contactid='.$cid.'&socid='.$socid.'">'.img_object($langs->trans("AddAction"),"calendar").'</a>';
|
||||
if ($link) $newemail='<div>'.$newemail.' '.$link.'</div>';
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -1239,18 +1338,18 @@ function dol_print_email($email,$cid=0,$socid=0,$addlink=0,$max=64,$showinvalid=
|
||||
$newemail.=img_warning($langs->trans("ErrorBadEMail",$email));
|
||||
}
|
||||
}
|
||||
return $newemail;
|
||||
return '<div class="nospan float" style="margin-right: 10px">'.($withpicto?img_picto($langs->trans("EMail"), 'object_email.png').' ':'').$newemail.'</div>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Show Skype link
|
||||
*
|
||||
* @param string $skype Skype to show (only skype, without 'Name of recipient' before)
|
||||
* @param int $cid Id of contact if known
|
||||
* @param int $socid Id of third party if known
|
||||
* @param int $addlink 0=no link to create action
|
||||
* @param int $max Max number of characters to show
|
||||
* @return string HTML Link
|
||||
* @param int $cid Id of contact if known
|
||||
* @param int $socid Id of third party if known
|
||||
* @param int $addlink 0=no link to create action
|
||||
* @param int $max Max number of characters to show
|
||||
* @return string HTML Link
|
||||
*/
|
||||
function dol_print_skype($skype,$cid=0,$socid=0,$addlink=0,$max=64)
|
||||
{
|
||||
@@ -1265,18 +1364,18 @@ function dol_print_skype($skype,$cid=0,$socid=0,$addlink=0,$max=64)
|
||||
$newskype='<a href="skype:';
|
||||
$newskype.=dol_trunc($skype,$max);
|
||||
$newskype.='?call" alt="'.$langs->trans("Call").' '.$skype.'" title="'.$langs->trans("Call").' '.$skype.'">';
|
||||
$newskype.='<img src="../theme/common/skype_callbutton.png" border="0"> ';
|
||||
$newskype.='</a> <a href="skype:';
|
||||
$newskype.='<img src="../theme/common/skype_callbutton.png" border="0">';
|
||||
$newskype.='</a> <a href="skype:';
|
||||
$newskype.=dol_trunc($skype,$max);
|
||||
$newskype.='?chat" alt="'.$langs->trans("Chat").' '.$skype.'" title="'.$langs->trans("Chat").' '.$skype.'">';
|
||||
$newskype.='<img src="../theme/common/skype_chatbutton.png" border="0"> ';
|
||||
$newskype.='<img src="../theme/common/skype_chatbutton.png" border="0">';
|
||||
$newskype.='</a>';
|
||||
|
||||
if (($cid || $socid) && ! empty($conf->agenda->enabled) && $user->rights->agenda->myactions->create)
|
||||
{
|
||||
$type='AC_SKYPE'; $link='';
|
||||
if (! empty($conf->global->AGENDA_ADDACTIONFORSKYPE)) $link='<a href="'.DOL_URL_ROOT.'/comm/action/fiche.php?action=create&backtopage=1&actioncode='.$type.'&contactid='.$cid.'&socid='.$socid.'">'.img_object($langs->trans("AddAction"),"calendar").'</a>';
|
||||
$newskype='<table class="nobordernopadding"><tr><td>'.$newskype.' </td><td> '.$link.'</td></tr></table>';
|
||||
if (! empty($conf->global->AGENDA_ADDACTIONFORSKYPE)) $link='<a href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create&backtopage=1&actioncode='.$type.'&contactid='.$cid.'&socid='.$socid.'">'.img_object($langs->trans("AddAction"),"calendar").'</a>';
|
||||
$newskype='<div class="divskype nowrap">'.$newskype.($link?' '.$link:'').'</div>';
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -1296,9 +1395,10 @@ function dol_print_skype($skype,$cid=0,$socid=0,$addlink=0,$max=64)
|
||||
* @param int $socid Id of third party if known
|
||||
* @param int $addlink ''=no link to create action, 'AC_TEL'=add link to clicktodial (if module enabled) and add link to create event (if conf->global->AGENDA_ADDACTIONFORPHONE set)
|
||||
* @param string $separ Separation between numbers for a better visibility example : xx.xx.xx.xx.xx
|
||||
* @param string $withpicto Show picto
|
||||
* @return string Formated phone number
|
||||
*/
|
||||
function dol_print_phone($phone,$country='',$cid=0,$socid=0,$addlink='',$separ=" ")
|
||||
function dol_print_phone($phone,$country='',$cid=0,$socid=0,$addlink='',$separ=" ",$withpicto='')
|
||||
{
|
||||
global $conf,$user,$langs,$mysoc;
|
||||
|
||||
@@ -1373,12 +1473,12 @@ function dol_print_phone($phone,$country='',$cid=0,$socid=0,$addlink='',$separ="
|
||||
{
|
||||
$type='AC_TEL'; $link='';
|
||||
if ($addlink == 'AC_FAX') $type='AC_FAX';
|
||||
if (! empty($conf->global->AGENDA_ADDACTIONFORPHONE)) $link='<a href="'.DOL_URL_ROOT.'/comm/action/fiche.php?action=create&backtopage=1&actioncode='.$type.($cid?'&contactid='.$cid:'').($socid?'&socid='.$socid:'').'">'.img_object($langs->trans("AddAction"),"calendar").'</a>';
|
||||
if ($link) $newphone='<table class="nobordernopadding"><tr><td>'.$newphone.' </td><td> '.$link.'</td></tr></table>';
|
||||
if (! empty($conf->global->AGENDA_ADDACTIONFORPHONE)) $link='<a href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create&backtopage=1&actioncode='.$type.($cid?'&contactid='.$cid:'').($socid?'&socid='.$socid:'').'">'.img_object($langs->trans("AddAction"),"calendar").'</a>';
|
||||
if ($link) $newphone='<div>'.$newphone.' '.$link.'</div>';
|
||||
}
|
||||
}
|
||||
|
||||
return $newphone;
|
||||
return '<div class="nospan float" style="margin-right: 10px">'.($withpicto?img_picto(($withpicto=='fax'?$langs->trans("Fax"):$langs->trans("Phone")), 'object_'.($withpicto=='fax'?'phoning_fax':'phoning').'.png').' ':'').$newphone.'</div>';
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1731,14 +1831,18 @@ function dol_print_graph($htmlid,$width,$height,$data,$showlegend=0,$type='pie',
|
||||
* @param string $trunc Where to trunc: right, left, middle (size must be a 2 power), wrap
|
||||
* @param string $stringencoding Tell what is source string encoding
|
||||
* @param int $nodot Truncation do not add ... after truncation. So it's an exact truncation.
|
||||
* @param int $display Trunc is use to display and can be changed for small screen
|
||||
* @return string Truncated string
|
||||
*/
|
||||
function dol_trunc($string,$size=40,$trunc='right',$stringencoding='UTF-8',$nodot=0)
|
||||
function dol_trunc($string,$size=40,$trunc='right',$stringencoding='UTF-8',$nodot=0, $display=0)
|
||||
{
|
||||
global $conf;
|
||||
|
||||
if ($size==0 || ! empty($conf->global->MAIN_DISABLE_TRUNC)) return $string;
|
||||
if (empty($stringencoding)) $stringencoding='UTF-8';
|
||||
|
||||
if ($size==0 || ! empty($conf->global->MAIN_DISABLE_TRUNC)) return $string;
|
||||
// reduce for small screen
|
||||
if ($conf->dol_optimize_smallscreen==1 && $display==1) $size = round($size/3);
|
||||
// We go always here
|
||||
if ($trunc == 'right')
|
||||
{
|
||||
@@ -1808,13 +1912,15 @@ function img_picto($titlealt, $picto, $options = '', $pictoisfullpath = false, $
|
||||
}
|
||||
else
|
||||
{
|
||||
// By default, we search $url/theme/$theme/img/$picto
|
||||
// We forge fullpathpicto for image to $path/img/$picto. By default, we take DOL_URL_ROOT/theme/$conf->theme/img/$picto
|
||||
$url = DOL_URL_ROOT;
|
||||
$theme = $conf->theme;
|
||||
|
||||
$path = 'theme/'.$theme;
|
||||
if (! empty($conf->global->MAIN_OVERWRITE_THEME_RES)) $path = $conf->global->MAIN_OVERWRITE_THEME_RES.'/theme/'.$conf->global->MAIN_OVERWRITE_THEME_RES;
|
||||
//if (! empty($conf->global->MAIN_FORCETHEMEDIR)) $path = preg_replace('/^\//', '', $conf->global->MAIN_FORCETHEMEDIR).'/'.$path; // TODO What if there is both FORCETHEMDIR and OVERWRITE_THEM_RES
|
||||
if (! empty($conf->global->MAIN_OVERWRITE_THEME_PATH)) $path = $conf->global->MAIN_OVERWRITE_THEME_PATH.'/theme/'.$theme; // If the theme does not have the same name as the module
|
||||
else if (! empty($conf->global->MAIN_OVERWRITE_THEME_RES)) $path = $conf->global->MAIN_OVERWRITE_THEME_RES.'/theme/'.$conf->global->MAIN_OVERWRITE_THEME_RES; // To allow an external module to overwrite image resources whatever is activated theme
|
||||
else if (! empty($conf->modules_parts['theme']) && array_key_exists($theme, $conf->modules_parts['theme'])) $path = $theme.'/theme/'.$theme; // If the theme have the same name as the module
|
||||
|
||||
// If we ask an image into $url/$mymodule/img (instead of default path)
|
||||
if (preg_match('/^([^@]+)@([^@]+)$/i',$picto,$regs))
|
||||
{
|
||||
@@ -1824,10 +1930,10 @@ function img_picto($titlealt, $picto, $options = '', $pictoisfullpath = false, $
|
||||
// Clean parameters
|
||||
if (! preg_match('/(\.png|\.gif)$/i',$picto)) $picto .= '.png';
|
||||
// If alt path are defined, define url where img file is, according to physical path
|
||||
foreach ($conf->file->dol_document_root as $type => $dirroot) // ex: array(["main"]=>"/home/maindir/htdocs", ["alt0"]=>"/home/moddir/htdocs", ...)
|
||||
foreach ($conf->file->dol_document_root as $type => $dirroot) // ex: array(["main"]=>"/home/maindir/htdocs", ["alt0"]=>"/home/moddir0/htdocs", ...)
|
||||
{
|
||||
if ($type == 'main') continue;
|
||||
if (file_exists($dirroot.'/'.$path.'/img/'.$picto))
|
||||
if (file_exists($dirroot.'/'.$path.'/img/'.$picto)) // This need a lot of time, that's why enabling alternative dir like "custom" dir is not recommanded
|
||||
{
|
||||
$url=DOL_URL_ROOT.$conf->file->dol_url_root[$type];
|
||||
break;
|
||||
@@ -1940,29 +2046,31 @@ function img_pdf($titlealt = 'default', $size = 3)
|
||||
* Show logo +
|
||||
*
|
||||
* @param string $titlealt Text on alt and title of image. Alt only if param notitle is set to 1. If text is "TextA:TextB", use Text A on alt and Text B on title.
|
||||
* @param string $other Add more attributes on img
|
||||
* @return string Return tag img
|
||||
*/
|
||||
function img_edit_add($titlealt = 'default')
|
||||
function img_edit_add($titlealt = 'default', $other = '')
|
||||
{
|
||||
global $conf, $langs;
|
||||
|
||||
if ($titlealt == 'default') $titlealt = $langs->trans('Add');
|
||||
|
||||
return img_picto($titlealt, 'edit_add.png');
|
||||
return img_picto($titlealt, 'edit_add.png', $other);
|
||||
}
|
||||
/**
|
||||
* Show logo -
|
||||
*
|
||||
* @param string $titlealt Text on alt and title of image. Alt only if param notitle is set to 1. If text is "TextA:TextB", use Text A on alt and Text B on title.
|
||||
* @param string $other Add more attributes on img
|
||||
* @return string Return tag img
|
||||
*/
|
||||
function img_edit_remove($titlealt = 'default')
|
||||
function img_edit_remove($titlealt = 'default', $other='')
|
||||
{
|
||||
global $conf, $langs;
|
||||
|
||||
if ($titlealt == 'default') $titlealt = $langs->trans('Remove');
|
||||
|
||||
return img_picto($titlealt, 'edit_remove.png');
|
||||
return img_picto($titlealt, 'edit_remove.png', $other);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2265,9 +2373,9 @@ function img_search($titlealt = 'default', $other = '')
|
||||
global $conf, $langs;
|
||||
|
||||
if ($titlealt == 'default') $titlealt = $langs->trans('Search');
|
||||
|
||||
|
||||
$img = img_picto($titlealt, 'search.png', $other, false, 1);
|
||||
|
||||
|
||||
$input = '<input type="image" class="liste_titre" name="button_search" src="'.$img.'" ';
|
||||
$input.= 'value="'.dol_escape_htmltag($titlealt).'" title="'.dol_escape_htmltag($titlealt).'" >';
|
||||
|
||||
@@ -2286,9 +2394,9 @@ function img_searchclear($titlealt = 'default', $other = '')
|
||||
global $conf, $langs;
|
||||
|
||||
if ($titlealt == 'default') $titlealt = $langs->trans('Search');
|
||||
|
||||
|
||||
$img = img_picto($titlealt, 'searchclear.png', $other, false, 1);
|
||||
|
||||
|
||||
$input = '<input type="image" class="liste_titre" name="button_removefilter" src="'.$img.'" ';
|
||||
$input.= 'value="'.dol_escape_htmltag($titlealt).'" title="'.dol_escape_htmltag($titlealt).'" >';
|
||||
|
||||
@@ -2550,10 +2658,11 @@ function getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $m
|
||||
}
|
||||
|
||||
/**
|
||||
* Show a title (deprecated. use print_fiche_titre instead)
|
||||
* Show a title.
|
||||
*
|
||||
* @param string $title Title to show
|
||||
* @return string Title to show
|
||||
* @deprecated Use print_fiche_titre instead
|
||||
*/
|
||||
function print_titre($title)
|
||||
{
|
||||
@@ -2622,10 +2731,11 @@ function load_fiche_titre($titre, $mesg='', $picto='title.png', $pictoisfullpath
|
||||
* @param int $num number of records found by select with limit+1
|
||||
* @param int $totalnboflines Total number of records/lines for all pages (if known)
|
||||
* @param string $picto Icon to use before title (should be a 32x32 transparent png file)
|
||||
* @param int $pictoisfullpath 1=Icon name is a full absolute url of image
|
||||
* @param int $pictoisfullpath 1=Icon name is a full absolute url of image
|
||||
* @param string $morehtml More html to show
|
||||
* @return void
|
||||
*/
|
||||
function print_barre_liste($titre, $page, $file, $options='', $sortfield='', $sortorder='', $center='', $num=-1, $totalnboflines=0, $picto='title.png', $pictoisfullpath=0)
|
||||
function print_barre_liste($titre, $page, $file, $options='', $sortfield='', $sortorder='', $center='', $num=-1, $totalnboflines=0, $picto='title.png', $pictoisfullpath=0, $morehtml='')
|
||||
{
|
||||
global $conf,$langs;
|
||||
|
||||
@@ -2701,6 +2811,7 @@ function print_barre_liste($titre, $page, $file, $options='', $sortfield='', $so
|
||||
}
|
||||
}
|
||||
print_fleche_navigation($page,$file,$options,$nextpage,$pagelist);
|
||||
if ($morehtml) print $morehtml;
|
||||
print '</td>';
|
||||
|
||||
print '</tr></table>'."\n";
|
||||
@@ -2840,9 +2951,13 @@ function price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerou
|
||||
{
|
||||
if ($currency_code == 'auto') $currency_code=$conf->currency;
|
||||
|
||||
$listofcurrenciesbefore=array('USD');
|
||||
$listofcurrenciesbefore=array('USD','GBP','AUD');
|
||||
if (in_array($currency_code,$listofcurrenciesbefore)) $cursymbolbefore.=$outlangs->getCurrencySymbol($currency_code);
|
||||
else $cursymbolafter.=$outlangs->getCurrencySymbol($currency_code);
|
||||
else
|
||||
{
|
||||
$tmpcur=$outlangs->getCurrencySymbol($currency_code);
|
||||
$cursymbolafter.=($tmpcur == $currency_code ? ' '.$tmpcur : $tmpcur);
|
||||
}
|
||||
}
|
||||
$output=$cursymbolbefore.$output.$end.$cursymbolafter;
|
||||
|
||||
@@ -2860,7 +2975,7 @@ function price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerou
|
||||
* 'MT'=Round to Max for totals with Tax (MAIN_MAX_DECIMALS_TOT)
|
||||
* 'MS'=Round to Max Shown (MAIN_MAX_DECIMALS_SHOWN)
|
||||
* @param int $alreadysqlnb Put 1 if you know that content is already universal format number
|
||||
* @return string Amount with universal numeric format (Example: '99.99999')
|
||||
* @return string Amount with universal numeric format (Example: '99.99999') or unchanged text if conversion fails.
|
||||
*
|
||||
* @see price Opposite function of price2num
|
||||
*/
|
||||
@@ -3534,7 +3649,7 @@ function get_default_localtax($thirdparty_seller, $thirdparty_buyer, $local, $id
|
||||
* Return yes or no in current language
|
||||
*
|
||||
* @param string $yesno Value to test (1, 'yes', 'true' or 0, 'no', 'false')
|
||||
* @param string $case 1=Yes/No, 0=yes/no
|
||||
* @param string $case 1=Yes/No, 0=yes/no, 2=Disabled checkbox, 3=Disabled checkbox + Yes/No
|
||||
* @param int $color 0=texte only, 1=Text is formated with a color font style ('ok' or 'error'), 2=Text is formated with 'ok' color.
|
||||
* @return string HTML string
|
||||
*/
|
||||
@@ -3544,12 +3659,20 @@ function yn($yesno, $case=1, $color=0)
|
||||
$result='unknown';
|
||||
if ($yesno == 1 || strtolower($yesno) == 'yes' || strtolower($yesno) == 'true') // A mettre avant test sur no a cause du == 0
|
||||
{
|
||||
$result=($case?$langs->trans("Yes"):$langs->trans("yes"));
|
||||
$result=$langs->trans('yes');
|
||||
if ($case == 1 || $case == 3) $result=$langs->trans("Yes");
|
||||
if ($case == 2) $result='<input type="checkbox" value="1" checked="checked" disabled="disabled">';
|
||||
if ($case == 3) $result='<input type="checkbox" value="1" checked="checked" disabled="disabled"> '.$result;
|
||||
|
||||
$classname='ok';
|
||||
}
|
||||
elseif ($yesno == 0 || strtolower($yesno) == 'no' || strtolower($yesno) == 'false')
|
||||
{
|
||||
$result=($case?$langs->trans("No"):$langs->trans("no"));
|
||||
$result=$langs->trans("no");
|
||||
if ($case == 1 || $case == 3) $result=$langs->trans("No");
|
||||
if ($case == 2) $result='<input type="checkbox" value="0" disabled="disabled">';
|
||||
if ($case == 3) $result='<input type="checkbox" value="0" disabled="disabled"> '.$result;
|
||||
|
||||
if ($color == 2) $classname='ok';
|
||||
else $classname='error';
|
||||
}
|
||||
@@ -3710,6 +3833,7 @@ function dol_nl2br($stringtoencode,$nl2brmode=0,$forxml=false)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This function is called to encode a string into a HTML string but differs from htmlentities because
|
||||
* all entities but &,<,> are converted. This permits to encode special chars to entities with no double
|
||||
@@ -3795,13 +3919,14 @@ function dol_html_entity_decode($a,$b,$c='UTF-8')
|
||||
/**
|
||||
* Replace htmlentities functions to manage errors
|
||||
* http://php.net/manual/en/function.htmlentities.php
|
||||
* TODO Remove this function to replace it with direct htmlentities.
|
||||
*
|
||||
* @param string $string The input string.
|
||||
* @param int $flags Flags(see PHP doc above)
|
||||
* @param string $encoding Encoding
|
||||
* @param bool $double_encode When double_encode is turned off PHP will not encode existing html entities
|
||||
* @return string $ret Encoded string
|
||||
* @deprecated Since PHP4 support is no longer available, this function does not make sense
|
||||
* @deprecated Since PHP4 support is no longer available, this function does not make sense.
|
||||
*/
|
||||
function dol_htmlentities($string, $flags=null, $encoding='UTF-8', $double_encode=false)
|
||||
{
|
||||
@@ -3838,6 +3963,7 @@ function dol_string_is_good_iso($s)
|
||||
* @param string $s String to check
|
||||
* @param int $maxchar Not yet used
|
||||
* @return int Number of lines
|
||||
* @see dol_nboflines_bis
|
||||
*/
|
||||
function dol_nboflines($s,$maxchar=0)
|
||||
{
|
||||
@@ -3856,6 +3982,7 @@ function dol_nboflines($s,$maxchar=0)
|
||||
* @param int $maxlinesize Largeur de ligne en caracteres (ou 0 si pas de limite - defaut)
|
||||
* @param string $charset Give the charset used to encode the $text variable in memory.
|
||||
* @return int Number of lines
|
||||
* @see dol_nboflines
|
||||
*/
|
||||
function dol_nboflines_bis($text,$maxlinesize=0,$charset='UTF-8')
|
||||
{
|
||||
@@ -3954,10 +4081,7 @@ function dol_concatdesc($text1,$text2,$forxml=false)
|
||||
}
|
||||
|
||||
/**
|
||||
* Make substition into a string
|
||||
* There is two type of substitions:
|
||||
* - From $substitutionarray (oldval=>newval)
|
||||
* - From special constants (__XXX__=>f(objet->xxx)) by substitutions modules
|
||||
* Make substition into a string replacing key with vals from $substitutionarray (oldval=>newval)
|
||||
*
|
||||
* @param string $chaine Source string in which we must do substitution
|
||||
* @param array $substitutionarray Array with key->val to substitute
|
||||
@@ -3983,7 +4107,7 @@ function make_substitutions($chaine,$substitutionarray)
|
||||
/**
|
||||
* Complete the $substitutionarray with more entries
|
||||
*
|
||||
* @param array &$substitutionarray Array substitution old value => new value value
|
||||
* @param array $substitutionarray Array substitution old value => new value value
|
||||
* @param Translate $outputlangs If we want substitution from special constants, we provide a language
|
||||
* @param Object $object If we want substitution from special constants, we provide data in a source object
|
||||
* @param Mixed $parameters Add more parameters (useful to pass product lines)
|
||||
@@ -4142,7 +4266,11 @@ function setEventMessages($mesg, $mesgs, $style='mesgs')
|
||||
{
|
||||
if (! in_array((string) $style, array('mesgs','warnings','errors'))) dol_print_error('','Bad parameter for setEventMessage');
|
||||
if (empty($mesgs)) setEventMessage($mesg, $style);
|
||||
else setEventMessage($mesgs, $style);
|
||||
else
|
||||
{
|
||||
if (! empty($mesg) && ! in_array($mesg, $mesgs)) setEventMessage($mesg, $style); // Add message string if not already into array
|
||||
setEventMessage($mesgs, $style);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -4342,7 +4470,7 @@ function dol_htmloutput_errors($mesgstring='', $mesgarray='', $keepembedded=0)
|
||||
* or descending output and uses optionally natural case insensitive sorting (which
|
||||
* can be optionally case sensitive as well).
|
||||
*
|
||||
* @param array &$array Array to sort (array of array('key','otherkey1','otherkey2'...))
|
||||
* @param array $array Array to sort (array of array('key','otherkey1','otherkey2'...))
|
||||
* @param string $index Key in array to use for sorting criteria
|
||||
* @param int $order Sort order
|
||||
* @param int $natsort 1=use "natural" sort (natsort), 0=use "standard" sort (asort)
|
||||
@@ -4505,6 +4633,7 @@ function dol_eval($s,$returnvalue=0)
|
||||
global $leftmenu;
|
||||
global $rights;
|
||||
global $object;
|
||||
global $soc;
|
||||
|
||||
//print $s."<br>\n";
|
||||
if ($returnvalue) return @eval('return '.$s.';');
|
||||
@@ -4532,6 +4661,8 @@ function picto_from_langcode($codelang)
|
||||
{
|
||||
global $langs;
|
||||
|
||||
if (empty($codelang)) return '';
|
||||
|
||||
if ($codelang == 'auto')
|
||||
{
|
||||
return img_picto_common($langs->trans('AutoDetectLang'), 'flags/int.png');
|
||||
@@ -4559,26 +4690,26 @@ function picto_from_langcode($codelang)
|
||||
* Complete or removed entries into a head array (used to build tabs) with value added by external modules.
|
||||
* Such values are declared into $conf->modules_parts['tab'].
|
||||
*
|
||||
* @param Conf $conf Object conf
|
||||
* @param Translate $langs Object langs
|
||||
* @param Object $object Object object
|
||||
* @param array &$head Object head
|
||||
* @param int &$h New position to fill
|
||||
* @param string $type Value for object where objectvalue can be
|
||||
* 'thirdparty' to add a tab in third party view
|
||||
* 'intervention' to add a tab in intervention view
|
||||
* 'supplier_order' to add a tab in supplier order view
|
||||
* 'supplier_invoice' to add a tab in supplier invoice view
|
||||
* 'invoice' to add a tab in customer invoice view
|
||||
* 'order' to add a tab in customer order view
|
||||
* 'product' to add a tab in product view
|
||||
* 'propal' to add a tab in propal view
|
||||
* 'user' to add a tab in user view
|
||||
* 'group' to add a tab in group view
|
||||
* 'member' to add a tab in fundation member view
|
||||
* 'categories_x' to add a tab in category view ('x': type of category (0=product, 1=supplier, 2=customer, 3=member)
|
||||
* 'ecm' to add a tab for another ecm view
|
||||
* @param string $mode 'add' to complete head, 'remove' to remove entries
|
||||
* @param Conf $conf Object conf
|
||||
* @param Translate $langs Object langs
|
||||
* @param Object|null $object Object object
|
||||
* @param array $head Object head
|
||||
* @param int $h New position to fill
|
||||
* @param string $type Value for object where objectvalue can be
|
||||
* 'thirdparty' to add a tab in third party view
|
||||
* 'intervention' to add a tab in intervention view
|
||||
* 'supplier_order' to add a tab in supplier order view
|
||||
* 'supplier_invoice' to add a tab in supplier invoice view
|
||||
* 'invoice' to add a tab in customer invoice view
|
||||
* 'order' to add a tab in customer order view
|
||||
* 'product' to add a tab in product view
|
||||
* 'propal' to add a tab in propal view
|
||||
* 'user' to add a tab in user view
|
||||
* 'group' to add a tab in group view
|
||||
* 'member' to add a tab in fundation member view
|
||||
* 'categories_x' to add a tab in category view ('x': type of category (0=product, 1=supplier, 2=customer, 3=member)
|
||||
* 'ecm' to add a tab for another ecm view
|
||||
* @param string $mode 'add' to complete head, 'remove' to remove entries
|
||||
* @return void
|
||||
*/
|
||||
function complete_head_from_modules($conf,$langs,$object,&$head,&$h,$type,$mode='add')
|
||||
@@ -4767,19 +4898,6 @@ function dolExplodeIntoArray($string, $delimiter = ';', $kv = '=')
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Convert an array with RGB value into hex RGB value
|
||||
*
|
||||
* @param array $arraycolor Array
|
||||
* @param string $colorifnotfound Color code to return if entry not defined
|
||||
* @return string RGB hex value (without # before). For example: FF00FF
|
||||
*/
|
||||
function colorArrayToHex($arraycolor,$colorifnotfound='888888')
|
||||
{
|
||||
if (! is_array($arraycolor)) return $colorifnotfound;
|
||||
return dechex($arraycolor[0]).dechex($arraycolor[1]).dechex($arraycolor[2]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set focus onto field with selector
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user