forked from Wavyzz/dolibarr
Merge branch 'develop' of github.com:Dolibarr/dolibarr into theme_sidebarr_toggle
This commit is contained in:
@@ -784,7 +784,7 @@ function dol_size($size, $type = '')
|
||||
* @param int $unaccent 1=Remove also accent (default), 0 do not remove them
|
||||
* @return string String cleaned (a-zA-Z_)
|
||||
*
|
||||
* @see dol_string_nospecial, dol_string_unaccent, dol_sanitizePathName
|
||||
* @see dol_string_nospecial(), dol_string_unaccent(), dol_sanitizePathName()
|
||||
*/
|
||||
function dol_sanitizeFileName($str, $newstr = '_', $unaccent = 1)
|
||||
{
|
||||
@@ -800,7 +800,7 @@ function dol_sanitizeFileName($str, $newstr = '_', $unaccent = 1)
|
||||
* @param int $unaccent 1=Remove also accent (default), 0 do not remove them
|
||||
* @return string String cleaned (a-zA-Z_)
|
||||
*
|
||||
* @see dol_string_nospecial, dol_string_unaccent, dol_sanitizeFileName
|
||||
* @see dol_string_nospecial(), dol_string_unaccent(), dol_sanitizeFileName()
|
||||
*/
|
||||
function dol_sanitizePathName($str, $newstr = '_', $unaccent = 1)
|
||||
{
|
||||
@@ -814,7 +814,7 @@ function dol_sanitizePathName($str, $newstr = '_', $unaccent = 1)
|
||||
* @param string $str String to clean
|
||||
* @return string Cleaned string
|
||||
*
|
||||
* @see dol_sanitizeFilename, dol_string_nospecial
|
||||
* @see dol_sanitizeFilename(), dol_string_nospecial()
|
||||
*/
|
||||
function dol_string_unaccent($str)
|
||||
{
|
||||
@@ -872,7 +872,7 @@ $string = strtr(
|
||||
* @param array $badcharstoreplace List of forbidden characters
|
||||
* @return string Cleaned string
|
||||
*
|
||||
* @see dol_sanitizeFilename, dol_string_unaccent
|
||||
* @see dol_sanitizeFilename(), dol_string_unaccent()
|
||||
*/
|
||||
function dol_string_nospecial($str, $newstr = '_', $badcharstoreplace = '')
|
||||
{
|
||||
@@ -925,7 +925,7 @@ function dol_escape_js($stringtoescape, $mode = 0, $noescapebackslashn = 0)
|
||||
* @param int $keepb 1=Preserve b tags (otherwise, remove them)
|
||||
* @param int $keepn 1=Preserve \r\n strings (otherwise, replace them with escaped value)
|
||||
* @return string Escaped string
|
||||
* @see dol_string_nohtmltag, dol_string_nospecial, dol_string_unaccent
|
||||
* @see dol_string_nohtmltag(), dol_string_nospecial(), dol_string_unaccent()
|
||||
*/
|
||||
function dol_escape_htmltag($stringtoescape, $keepb = 0, $keepn = 0)
|
||||
{
|
||||
@@ -1604,7 +1604,7 @@ function dol_bc($var, $moreclass = '')
|
||||
* @param Translate $outputlangs Object lang that contains language for text translation.
|
||||
* @param int $mode 0=Standard output, 1=Remove address
|
||||
* @return string Formated string
|
||||
* @see dol_print_address
|
||||
* @see dol_print_address()
|
||||
*/
|
||||
function dol_format_address($object, $withcountry = 0, $sep = "\n", $outputlangs = '', $mode = 0)
|
||||
{
|
||||
@@ -1707,7 +1707,7 @@ function dol_strftime($fmt, $ts = false, $is_gmt = false)
|
||||
* @param boolean $encodetooutput false=no convert into output pagecode
|
||||
* @return string Formated date or '' if time is null
|
||||
*
|
||||
* @see dol_mktime, dol_stringtotime, dol_getdate
|
||||
* @see dol_mktime(), dol_stringtotime(), dol_getdate()
|
||||
*/
|
||||
function dol_print_date($time, $format = '', $tzoutput = 'tzserver', $outputlangs = '', $encodetooutput = false)
|
||||
{
|
||||
@@ -1884,7 +1884,7 @@ function dol_print_date($time, $format = '', $tzoutput = 'tzserver', $outputlang
|
||||
* 'yday' => floor($secsInYear/$_day_power),
|
||||
* 'leap' => $leaf,
|
||||
* 'ndays' => $ndays
|
||||
* @see dol_print_date, dol_stringtotime, dol_mktime
|
||||
* @see dol_print_date(), dol_stringtotime(), dol_mktime()
|
||||
*/
|
||||
function dol_getdate($timestamp, $fast = false)
|
||||
{
|
||||
@@ -1923,7 +1923,7 @@ function dol_getdate($timestamp, $fast = false)
|
||||
* 'tz,TimeZone' = use specified timezone
|
||||
* @param int $check 0=No check on parameters (Can use day 32, etc...)
|
||||
* @return int|string Date as a timestamp, '' or false if error
|
||||
* @see dol_print_date, dol_stringtotime, dol_getdate
|
||||
* @see dol_print_date(), dol_stringtotime(), dol_getdate()
|
||||
*/
|
||||
function dol_mktime($hour, $minute, $second, $month, $day, $year, $gm = false, $check = 1)
|
||||
{
|
||||
@@ -2711,7 +2711,7 @@ function dol_user_country()
|
||||
* @param int $noprint No output. Result is the function return
|
||||
* @param string $charfornl Char to use instead of nl2br. '' means we use a standad nl2br.
|
||||
* @return string|void Nothing if noprint is 0, formatted address if noprint is 1
|
||||
* @see dol_format_address
|
||||
* @see dol_format_address()
|
||||
*/
|
||||
function dol_print_address($address, $htmlid, $mode, $id, $noprint = 0, $charfornl = '')
|
||||
{
|
||||
@@ -3614,30 +3614,6 @@ function img_mime($file, $titlealt = '', $morecss = '')
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Show phone logo.
|
||||
* Use img_picto instead.
|
||||
*
|
||||
* @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 int $option Option
|
||||
* @return string Return img tag
|
||||
* @deprecated
|
||||
* @see img_picto
|
||||
*/
|
||||
function img_phone($titlealt = 'default', $option = 0)
|
||||
{
|
||||
dol_syslog(__FUNCTION__ . " is deprecated", LOG_WARNING);
|
||||
|
||||
global $conf,$langs;
|
||||
|
||||
if ($titlealt == 'default') $titlealt = $langs->trans('Call');
|
||||
|
||||
if ($option == 1) $img = 'call';
|
||||
else $img = 'call_out';
|
||||
|
||||
return img_picto($titlealt, $img);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show search logo
|
||||
*
|
||||
@@ -3713,7 +3689,7 @@ function info_admin($text, $infoonimgalt = 0, $nodiv = 0, $admin = '1', $morecss
|
||||
* @param mixed $error String or array of errors strings to show
|
||||
* @param array $errors Array of errors
|
||||
* @return void
|
||||
* @see dol_htmloutput_errors
|
||||
* @see dol_htmloutput_errors()
|
||||
*/
|
||||
function dol_print_error($db = '', $error = '', $errors = null)
|
||||
{
|
||||
@@ -4009,7 +3985,7 @@ function getTitleFieldOfList($name, $thead = 0, $file = "", $field = "", $begin
|
||||
* @param string $title Title to show
|
||||
* @return string Title to show
|
||||
* @deprecated Use load_fiche_titre instead
|
||||
* @see load_fiche_titre
|
||||
* @see load_fiche_titre()
|
||||
*/
|
||||
function print_titre($title)
|
||||
{
|
||||
@@ -4045,7 +4021,7 @@ function print_fiche_titre($title, $mesg = '', $picto = 'title_generic.png', $pi
|
||||
* @param string $morecssontable More css on table
|
||||
* @param string $morehtmlcenter Added message to show on center
|
||||
* @return string
|
||||
* @see print_barre_liste
|
||||
* @see print_barre_liste()
|
||||
*/
|
||||
function load_fiche_titre($titre, $morehtmlright = '', $picto = 'title_generic.png', $pictoisfullpath = 0, $id = '', $morecssontable = '', $morehtmlcenter = '')
|
||||
{
|
||||
@@ -4431,7 +4407,7 @@ function price($amount, $form = 0, $outlangs = '', $trunc = 1, $rounding = -1, $
|
||||
* @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') or unchanged text if conversion fails. If amount is null or '', it returns ''.
|
||||
*
|
||||
* @see price Opposite function of price2num
|
||||
* @see price() Opposite function of price2num
|
||||
*/
|
||||
function price2num($amount, $rounding = '', $alreadysqlnb = 0)
|
||||
{
|
||||
@@ -4572,7 +4548,7 @@ function showDimensionInBestUnit($dimension, $unit, $type, $outputlangs, $round
|
||||
* @param Societe $thirdparty_seller Object of selling third party ($mysoc if not defined)
|
||||
* @param int $vatnpr If vat rate is NPR or not
|
||||
* @return mixed 0 if not found, localtax rate if found
|
||||
* @see get_default_tva
|
||||
* @see get_default_tva()
|
||||
*/
|
||||
function get_localtax($vatrate, $local, $thirdparty_buyer = "", $thirdparty_seller = "", $vatnpr = 0)
|
||||
{
|
||||
@@ -4762,7 +4738,7 @@ function get_localtax_by_third($local)
|
||||
* @param Societe $seller Company object
|
||||
* @param int $firstparamisid 1 if first param is id into table (use this if you can)
|
||||
* @return array array('rowid'=> , 'code'=> ...)
|
||||
* @see getLocalTaxesFromRate
|
||||
* @see getLocalTaxesFromRate()
|
||||
*/
|
||||
function getTaxesFromId($vatrate, $buyer = null, $seller = null, $firstparamisid = 1)
|
||||
{
|
||||
@@ -4818,7 +4794,7 @@ function getTaxesFromId($vatrate, $buyer = null, $seller = null, $firstparamisid
|
||||
* @param Societe $seller Company object
|
||||
* @param int $firstparamisid 1 if first param is ID into table instead of Rate+code (use this if you can)
|
||||
* @return array array(localtax_type1(1-6/0 if not found), rate localtax1, localtax_type2, rate localtax2, accountancycodecust, accountancycodesupp)
|
||||
* @see getTaxesFromId
|
||||
* @see getTaxesFromId()
|
||||
*/
|
||||
function getLocalTaxesFromRate($vatrate, $local, $buyer, $seller, $firstparamisid = 0)
|
||||
{
|
||||
@@ -4876,7 +4852,7 @@ function getLocalTaxesFromRate($vatrate, $local, $buyer, $seller, $firstparamisi
|
||||
* @param Societe $thirdparty_seller Thirdparty with a ->country_code defined (FR, US, IT, ...)
|
||||
* @param int $idprodfournprice Id product_fournisseur_price (for "supplier" proposal/order/invoice)
|
||||
* @return float|string Vat rate to use with format 5.0 or '5.0 (XXX)'
|
||||
* @see get_product_localtax_for_country
|
||||
* @see get_product_localtax_for_country()
|
||||
*/
|
||||
function get_product_vat_for_country($idprod, $thirdparty_seller, $idprodfournprice = 0)
|
||||
{
|
||||
@@ -4953,7 +4929,7 @@ function get_product_vat_for_country($idprod, $thirdparty_seller, $idprodfournpr
|
||||
* @param int $local 1 for localtax1, 2 for localtax 2
|
||||
* @param Societe $thirdparty_seller Thirdparty with a ->country_code defined (FR, US, IT, ...)
|
||||
* @return int <0 if KO, Vat rate if OK
|
||||
* @see get_product_vat_for_country
|
||||
* @see get_product_vat_for_country()
|
||||
*/
|
||||
function get_product_localtax_for_country($idprod, $local, $thirdparty_seller)
|
||||
{
|
||||
@@ -5026,7 +5002,7 @@ function get_product_localtax_for_country($idprod, $local, $thirdparty_seller)
|
||||
* @param int $idprod Id product
|
||||
* @param int $idprodfournprice Id product_fournisseur_price (for supplier order/invoice)
|
||||
* @return float|string Vat rate to use with format 5.0 or '5.0 (XXX)', -1 if we can't guess it
|
||||
* @see get_default_npr, get_default_localtax
|
||||
* @see get_default_npr(), get_default_localtax()
|
||||
*/
|
||||
function get_default_tva(Societe $thirdparty_seller, Societe $thirdparty_buyer, $idprod = 0, $idprodfournprice = 0)
|
||||
{
|
||||
@@ -5113,7 +5089,7 @@ function get_default_tva(Societe $thirdparty_seller, Societe $thirdparty_buyer,
|
||||
* @param int $idprod Id product
|
||||
* @param int $idprodfournprice Id supplier price for product
|
||||
* @return float 0 or 1
|
||||
* @see get_default_tva, get_default_localtax
|
||||
* @see get_default_tva(), get_default_localtax()
|
||||
*/
|
||||
function get_default_npr(Societe $thirdparty_seller, Societe $thirdparty_buyer, $idprod = 0, $idprodfournprice = 0)
|
||||
{
|
||||
@@ -5150,7 +5126,7 @@ function get_default_npr(Societe $thirdparty_seller, Societe $thirdparty_buyer,
|
||||
* @param int $local Localtax to process (1 or 2)
|
||||
* @param int $idprod Id product
|
||||
* @return integer localtax, -1 si ne peut etre determine
|
||||
* @see get_default_tva, get_default_npr
|
||||
* @see get_default_tva(), get_default_npr()
|
||||
*/
|
||||
function get_default_localtax($thirdparty_seller, $thirdparty_buyer, $local, $idprod = 0)
|
||||
{
|
||||
@@ -5371,7 +5347,7 @@ function picto_required()
|
||||
* @param integer $strip_tags 0=Use internal strip, 1=Use strip_tags() php function (bugged when text contains a < char that is not for a html tag)
|
||||
* @return string String cleaned
|
||||
*
|
||||
* @see dol_escape_htmltag strip_tags dol_string_onlythesehtmltags dol_string_neverthesehtmltags
|
||||
* @see dol_escape_htmltag() strip_tags() dol_string_onlythesehtmltags() dol_string_neverthesehtmltags()
|
||||
*/
|
||||
function dol_string_nohtmltag($stringtoclean, $removelinefeed = 1, $pagecodeto = 'UTF-8', $strip_tags = 0)
|
||||
{
|
||||
@@ -5409,7 +5385,7 @@ function dol_string_nohtmltag($stringtoclean, $removelinefeed = 1, $pagecodeto =
|
||||
* @param string $stringtoclean String to clean
|
||||
* @return string String cleaned
|
||||
*
|
||||
* @see dol_escape_htmltag strip_tags dol_string_nohtmltag dol_string_neverthesehtmltags
|
||||
* @see dol_escape_htmltag() strip_tags() dol_string_nohtmltag() dol_string_neverthesehtmltags()
|
||||
*/
|
||||
function dol_string_onlythesehtmltags($stringtoclean)
|
||||
{
|
||||
@@ -5435,7 +5411,7 @@ function dol_string_onlythesehtmltags($stringtoclean)
|
||||
* @param array $disallowed_tags Array of tags not allowed
|
||||
* @return string String cleaned
|
||||
*
|
||||
* @see dol_escape_htmltag strip_tags dol_string_nohtmltag dol_string_onlythesehtmltags
|
||||
* @see dol_escape_htmltag() strip_tags() dol_string_nohtmltag() dol_string_onlythesehtmltags()
|
||||
*/
|
||||
function dol_string_neverthesehtmltags($stringtoclean, $disallowed_tags = array('textarea'))
|
||||
{
|
||||
@@ -5454,10 +5430,11 @@ function dol_string_neverthesehtmltags($stringtoclean, $disallowed_tags = array(
|
||||
*
|
||||
* @param string $text Input text
|
||||
* @param int $nboflines Nb of lines to get (default is 1 = first line only)
|
||||
* @param string $charset Charset of $text string (UTF-8 by default)
|
||||
* @return string Output text
|
||||
* @see dol_nboflines_bis, dol_string_nohtmltag, dol_escape_htmltag
|
||||
* @see dol_nboflines_bis(), dol_string_nohtmltag(), dol_escape_htmltag()
|
||||
*/
|
||||
function dolGetFirstLineOfText($text, $nboflines = 1)
|
||||
function dolGetFirstLineOfText($text, $nboflines = 1, $charset = 'UTF-8')
|
||||
{
|
||||
if ($nboflines == 1)
|
||||
{
|
||||
@@ -5513,7 +5490,7 @@ function dolGetFirstLineOfText($text, $nboflines = 1)
|
||||
* @param int $nl2brmode 0=Adding br before \n, 1=Replacing \n by br
|
||||
* @param bool $forxml false=Use <br>, true=Use <br />
|
||||
* @return string String encoded
|
||||
* @see dol_nboflines, dolGetFirstLineOfText
|
||||
* @see dol_nboflines(), dolGetFirstLineOfText()
|
||||
*/
|
||||
function dol_nl2br($stringtoencode, $nl2brmode = 0, $forxml = false)
|
||||
{
|
||||
@@ -5650,7 +5627,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, dolGetFirstLineOfText
|
||||
* @see dol_nboflines_bis(), dolGetFirstLineOfText()
|
||||
*/
|
||||
function dol_nboflines($s, $maxchar = 0)
|
||||
{
|
||||
@@ -5669,7 +5646,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, dolGetFirstLineOfText
|
||||
* @see dol_nboflines(), dolGetFirstLineOfText()
|
||||
*/
|
||||
function dol_nboflines_bis($text, $maxlinesize = 0, $charset = 'UTF-8')
|
||||
{
|
||||
@@ -5724,7 +5701,7 @@ function dol_microtime_float()
|
||||
* @param string $msg Content to check
|
||||
* @param int $option 0=Full detection, 1=Fast check
|
||||
* @return boolean true/false
|
||||
* @see dol_concatdesc
|
||||
* @see dol_concatdesc()
|
||||
*/
|
||||
function dol_textishtml($msg, $option = 0)
|
||||
{
|
||||
@@ -5766,22 +5743,22 @@ function dol_textishtml($msg, $option = 0)
|
||||
* @param bool $forxml false=Use <br>instead of \n if html content detected, true=Use <br /> instead of \n if html content detected
|
||||
* @param bool $invert invert order of description lines if CONF CHANGE_ORDER_CONCAT_DESCRIPTION is active
|
||||
* @return string Text 1 + new line + Text2
|
||||
* @see dol_textishtml
|
||||
* @see dol_textishtml()
|
||||
*/
|
||||
function dol_concatdesc($text1, $text2, $forxml = false, $invert = false)
|
||||
{
|
||||
if (!empty($invert))
|
||||
{
|
||||
$tmp = $text1;
|
||||
$text1 = $text2;
|
||||
$text2 = $tmp;
|
||||
}
|
||||
if (!empty($invert))
|
||||
{
|
||||
$tmp = $text1;
|
||||
$text1 = $text2;
|
||||
$text2 = $tmp;
|
||||
}
|
||||
|
||||
$ret='';
|
||||
$ret.= (! dol_textishtml($text1) && dol_textishtml($text2))?dol_nl2br($text1, 0, $forxml):$text1;
|
||||
$ret.= (! empty($text1) && ! empty($text2)) ? ((dol_textishtml($text1) || dol_textishtml($text2))?($forxml?"<br \>\n":"<br>\n") : "\n") : "";
|
||||
$ret.= (dol_textishtml($text1) && ! dol_textishtml($text2))?dol_nl2br($text2, 0, $forxml):$text2;
|
||||
return $ret;
|
||||
$ret='';
|
||||
$ret.= (! dol_textishtml($text1) && dol_textishtml($text2))?dol_nl2br($text1, 0, $forxml):$text1;
|
||||
$ret.= (! empty($text1) && ! empty($text2)) ? ((dol_textishtml($text1) || dol_textishtml($text2))?($forxml?"<br \>\n":"<br>\n") : "\n") : "";
|
||||
$ret.= (dol_textishtml($text1) && ! dol_textishtml($text2))?dol_nl2br($text2, 0, $forxml):$text2;
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
||||
@@ -5794,7 +5771,7 @@ function dol_concatdesc($text1, $text2, $forxml = false, $invert = false)
|
||||
* @param array $exclude Array of family keys we want to exclude. For example array('system', 'mycompany', 'object', 'objectamount', 'date', 'user', ...)
|
||||
* @param Object $object Object for keys on object
|
||||
* @return array Array of substitutions
|
||||
* @see setSubstitFromObject
|
||||
* @see setSubstitFromObject()
|
||||
*/
|
||||
function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, $object = null)
|
||||
{
|
||||
@@ -6087,7 +6064,7 @@ $substitutionarray=array_merge($substitutionarray, array(
|
||||
$tmp4=dol_get_next_day($tmp['mday'], $tmp['mon'], $tmp['year']);
|
||||
$tmp5=dol_get_next_month($tmp['mon'], $tmp['year']);
|
||||
|
||||
$substitutionarray=array_merge($substitutionarray, array(
|
||||
$substitutionarray=array_merge($substitutionarray, array(
|
||||
'__DAY__' => (string) $tmp['mday'],
|
||||
'__DAY_TEXT__' => $outputlangs->trans('Day'.$tmp['wday']), // Monday
|
||||
'__DAY_TEXT_SHORT__' => $outputlangs->trans($tmp['weekday'].'Min'), // Mon
|
||||
@@ -6132,7 +6109,7 @@ $substitutionarray=array_merge($substitutionarray, array(
|
||||
* @param array $substitutionarray Array with key->val to substitute. Example: array('__MYKEY__' => 'MyVal', ...)
|
||||
* @param Translate $outputlangs Output language
|
||||
* @return string Output string after substitutions
|
||||
* @see complete_substitutions_array, getCommonSubstitutionArray
|
||||
* @see complete_substitutions_array(), getCommonSubstitutionArray()
|
||||
*/
|
||||
function make_substitutions($text, $substitutionarray, $outputlangs = null)
|
||||
{
|
||||
@@ -6195,7 +6172,7 @@ function make_substitutions($text, $substitutionarray, $outputlangs = null)
|
||||
* @param mixed $parameters Add more parameters (useful to pass product lines)
|
||||
* @param string $callfunc What is the name of the custom function that will be called? (default: completesubstitutionarray)
|
||||
* @return void
|
||||
* @see make_substitutions
|
||||
* @see make_substitutions()
|
||||
*/
|
||||
function complete_substitutions_array(&$substitutionarray, $outputlangs, $object = null, $parameters = null, $callfunc = "completesubstitutionarray")
|
||||
{
|
||||
@@ -6339,7 +6316,7 @@ function dolGetFirstLastname($firstname, $lastname, $nameorder = -1)
|
||||
* @param mixed $mesgs Message string or array
|
||||
* @param string $style Which style to use ('mesgs' by default, 'warnings', 'errors')
|
||||
* @return void
|
||||
* @see dol_htmloutput_events
|
||||
* @see dol_htmloutput_events()
|
||||
*/
|
||||
function setEventMessage($mesgs, $style = 'mesgs')
|
||||
{
|
||||
@@ -6365,7 +6342,7 @@ function setEventMessage($mesgs, $style = 'mesgs')
|
||||
* @param array $mesgs Message array
|
||||
* @param string $style Which style to use ('mesgs' by default, 'warnings', 'errors')
|
||||
* @return void
|
||||
* @see dol_htmloutput_events
|
||||
* @see dol_htmloutput_events()
|
||||
*/
|
||||
function setEventMessages($mesg, $mesgs, $style = 'mesgs')
|
||||
{
|
||||
@@ -6392,7 +6369,7 @@ function setEventMessages($mesg, $mesgs, $style = 'mesgs')
|
||||
*
|
||||
* @param int $disabledoutputofmessages Clear all messages stored into session without diplaying them
|
||||
* @return void
|
||||
* @see dol_htmloutput_mesg
|
||||
* @see dol_htmloutput_mesg()
|
||||
*/
|
||||
function dol_htmloutput_events($disabledoutputofmessages = 0)
|
||||
{
|
||||
@@ -6425,9 +6402,9 @@ function dol_htmloutput_events($disabledoutputofmessages = 0)
|
||||
* @param int $keepembedded Set to 1 in error message must be kept embedded into its html place (this disable jnotify)
|
||||
* @return string Return html output
|
||||
*
|
||||
* @see dol_print_error
|
||||
* @see dol_htmloutput_errors
|
||||
* @see setEventMessages
|
||||
* @see dol_print_error()
|
||||
* @see dol_htmloutput_errors()
|
||||
* @see setEventMessages()
|
||||
*/
|
||||
function get_htmloutput_mesg($mesgstring = '', $mesgarray = '', $style = 'ok', $keepembedded = 0)
|
||||
{
|
||||
@@ -6502,8 +6479,8 @@ function get_htmloutput_mesg($mesgstring = '', $mesgarray = '', $style = 'ok', $
|
||||
* @param int $keepembedded Set to 1 in error message must be kept embedded into its html place (this disable jnotify)
|
||||
* @return string Return html output
|
||||
*
|
||||
* @see dol_print_error
|
||||
* @see dol_htmloutput_mesg
|
||||
* @see dol_print_error()
|
||||
* @see dol_htmloutput_mesg()
|
||||
*/
|
||||
function get_htmloutput_errors($mesgstring = '', $mesgarray = array(), $keepembedded = 0)
|
||||
{
|
||||
@@ -6519,9 +6496,9 @@ function get_htmloutput_errors($mesgstring = '', $mesgarray = array(), $keepembe
|
||||
* @param int $keepembedded Set to 1 if message must be kept embedded into its html place (this disable jnotify)
|
||||
* @return void
|
||||
*
|
||||
* @see dol_print_error
|
||||
* @see dol_htmloutput_errors
|
||||
* @see setEventMessages
|
||||
* @see dol_print_error()
|
||||
* @see dol_htmloutput_errors()
|
||||
* @see setEventMessages()
|
||||
*/
|
||||
function dol_htmloutput_mesg($mesgstring = '', $mesgarray = array(), $style = 'ok', $keepembedded = 0)
|
||||
{
|
||||
@@ -6574,8 +6551,8 @@ function dol_htmloutput_mesg($mesgstring = '', $mesgarray = array(), $style = 'o
|
||||
* @param int $keepembedded Set to 1 in error message must be kept embedded into its html place (this disable jnotify)
|
||||
* @return void
|
||||
*
|
||||
* @see dol_print_error
|
||||
* @see dol_htmloutput_mesg
|
||||
* @see dol_print_error()
|
||||
* @see dol_htmloutput_mesg()
|
||||
*/
|
||||
function dol_htmloutput_errors($mesgstring = '', $mesgarray = array(), $keepembedded = 0)
|
||||
{
|
||||
@@ -7691,7 +7668,7 @@ function ajax_autoselect($htmlname, $addlink = '')
|
||||
* @param string $default Default mime type if extension not found in known list
|
||||
* @param int $mode 0=Return full mime, 1=otherwise short mime string, 2=image for mime type, 3=source language, 4=css of font fa
|
||||
* @return string Return a mime type family (text/xxx, application/xxx, image/xxx, audio, video, archive)
|
||||
* @see image_format_supported (images.lib.php)
|
||||
* @see image_format_supported() from images.lib.php
|
||||
*/
|
||||
function dol_mimetype($file, $default = 'application/octet-stream', $mode = 0)
|
||||
{
|
||||
@@ -7849,6 +7826,7 @@ function getDictvalue($tablename, $field, $id, $checkentity = false, $rowidfield
|
||||
*/
|
||||
function colorIsLight($stringcolor)
|
||||
{
|
||||
$stringcolor = str_replace('#', '', $stringcolor);
|
||||
$res = -1;
|
||||
if (!empty($stringcolor))
|
||||
{
|
||||
@@ -7919,3 +7897,215 @@ function roundUpToNextMultiple($n, $x = 5)
|
||||
{
|
||||
return (ceil($n)%$x === 0) ? ceil($n) : round(($n+$x/2)/$x)*$x;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function dolGetBadge
|
||||
*
|
||||
* @param string $label label of badge no html : use in alt attribute for accessibility
|
||||
* @param string $html optional : label of badge with html
|
||||
* @param string $type type of badge : Primary Secondary Success Danger Warning Info Light Dark status0 status1 status2 status3 status4 status5 status6 status7 status8 status9
|
||||
* @param string $mode default '' , pill, dot
|
||||
* @param string $url the url for link
|
||||
* @param array $params various params for future : recommended rather than adding more fuction arguments
|
||||
* @return string Html badge
|
||||
*/
|
||||
function dolGetBadge($label, $html = '', $type = 'primary', $mode = '', $url = '', $params = array())
|
||||
{
|
||||
|
||||
$attr=array(
|
||||
'class'=>'badge'.(!empty($mode)?' badge-'.$mode:'').(!empty($type)?' badge-'.$type:'')
|
||||
);
|
||||
|
||||
if(empty($html)){
|
||||
$html = $label;
|
||||
}
|
||||
|
||||
if(!empty($url)){
|
||||
$attr['href'] = $url;
|
||||
}
|
||||
|
||||
if($mode==='dot')
|
||||
{
|
||||
$attr['class'].= ' classfortooltip';
|
||||
$attr['title'] = $html;
|
||||
$attr['aria-label'] = $label;
|
||||
$html='';
|
||||
}
|
||||
|
||||
// Override attr
|
||||
if(!empty($params['attr']) && is_array($params['attr'])){
|
||||
foreach($params['attr']as $key => $value){
|
||||
$attr[$key] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: add hook
|
||||
|
||||
// escape all attribute
|
||||
$attr = array_map('dol_escape_htmltag', $attr);
|
||||
|
||||
$TCompiledAttr = array();
|
||||
foreach($attr as $key => $value){
|
||||
$TCompiledAttr[] = $key.'="'.$value.'"';
|
||||
}
|
||||
|
||||
$compiledAttributes = !empty($TCompiledAttr)?implode(' ', $TCompiledAttr):'';
|
||||
|
||||
$tag = !empty($url)?'a':'span';
|
||||
|
||||
return '<'.$tag.' '.$compiledAttributes.'>'.$html.'</'.$tag.'>';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Function dolGetStatus
|
||||
*
|
||||
* @param string $statusLabel Label of badge no html : use in alt attribute for accessibility
|
||||
* @param string $statusLabelShort Short label of badge no html
|
||||
* @param string $html Optional : label of badge with html
|
||||
* @param string $statusType status0 status1 status2 status3 status4 status5 status6 status7 status8 status9 : image name or badge name
|
||||
* @param int $displayMode 0=Long label, 1=Short label, 2=Picto + Short label, 3=Picto, 4=Picto + Long label, 5=Short label + Picto, 6=Long label + Picto
|
||||
* @param string $url The url for link
|
||||
* @param array $params Various params for future : recommended rather than adding more function arguments
|
||||
* @return string Html status string
|
||||
*/
|
||||
function dolGetStatus($statusLabel = '', $statusLabelShort = '', $html = '', $statusType = 'status0', $displayMode = 0, $url = '', $params = array())
|
||||
{
|
||||
global $conf;
|
||||
|
||||
// image's filename are still in French
|
||||
$statusImg=array(
|
||||
'status0' => 'statut0'
|
||||
,'status1' => 'statut1'
|
||||
,'status2' => 'statut2'
|
||||
,'status3' => 'statut3'
|
||||
,'status4' => 'statut4'
|
||||
,'status5' => 'statut5'
|
||||
,'status6' => 'statut6'
|
||||
,'status7' => 'statut7'
|
||||
,'status8' => 'statut8'
|
||||
,'status9' => 'statut9'
|
||||
);
|
||||
|
||||
// TODO : add a hook
|
||||
|
||||
if ($displayMode == 0) {
|
||||
$return = !empty($html)?$html:$statusLabel;
|
||||
}
|
||||
elseif ($displayMode == 1) {
|
||||
$return = !empty($html)?$html:(!empty($statusLabelShort)?$statusLabelShort:$statusLabel);
|
||||
}
|
||||
// use status with images
|
||||
elseif (empty($conf->global->MAIN_STATUS_USES_CSS)){
|
||||
$return = '';
|
||||
$htmlLabel = '<span class="hideonsmartphone">'.(!empty($html)?$html:$statusLabel).'</span>';
|
||||
$htmlLabelShort = '<span class="hideonsmartphone">'.(!empty($html)?$html:(!empty($statusLabelShort)?$statusLabelShort:$statusLabel)).'</span>';
|
||||
|
||||
if(!empty($statusImg[$statusType])){
|
||||
$htmlImg = img_picto($statusLabel, $statusImg[$statusType]);
|
||||
}else{
|
||||
$htmlImg = img_picto($statusLabel, $statusType);
|
||||
}
|
||||
|
||||
if ($displayMode === 2) {
|
||||
$return = $htmlImg .' '. $htmlLabel;
|
||||
}
|
||||
elseif ($displayMode === 3) {
|
||||
$return = $htmlImg;
|
||||
}
|
||||
elseif ($displayMode === 4) {
|
||||
$return = $htmlImg .' '. $htmlLabel;
|
||||
}
|
||||
elseif ($displayMode === 5) {
|
||||
$return = $htmlLabelShort .' '. $htmlImg;
|
||||
}
|
||||
else { // $displayMode >= 6
|
||||
$return = $htmlLabel .' '. $htmlImg;
|
||||
}
|
||||
}
|
||||
// Use new badge
|
||||
elseif (!empty($conf->global->MAIN_STATUS_USES_CSS) && !empty($displayMode)) {
|
||||
$statusLabelShort = !empty($statusLabelShort)?$statusLabelShort:$statusLabel;
|
||||
|
||||
if($displayMode == 3){
|
||||
$return = dolGetBadge($statusLabel, '', $statusType, 'dot');
|
||||
}
|
||||
elseif($displayMode === 5){
|
||||
$return = dolGetBadge($statusLabelShort, $html, $statusType);
|
||||
}
|
||||
else{
|
||||
$return = dolGetBadge($statusLabel, $html, $statusType);
|
||||
}
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Function dolGetButtonAction
|
||||
*
|
||||
* @param string $label label of button no html : use in alt attribute for accessibility $html is not empty
|
||||
* @param string $html optional : content with html
|
||||
* @param string $actionType default, delete, danger
|
||||
* @param string $url the url for link
|
||||
* @param string $id attribute id of button
|
||||
* @param int $userRight user action right
|
||||
* @param array $params various params for future : recommended rather than adding more function arguments
|
||||
* @return string html button
|
||||
*/
|
||||
function dolGetButtonAction($label, $html = '', $actionType = 'default', $url = '', $id = '', $userRight = 1, $params = array())
|
||||
{
|
||||
$class = 'butAction' ;
|
||||
if($actionType == 'danger' || $actionType == 'delete'){
|
||||
$class = 'butActionDelete' ;
|
||||
}
|
||||
|
||||
$attr=array(
|
||||
'class' => $class
|
||||
,'href' => empty($url)?'':$url
|
||||
);
|
||||
|
||||
if(empty($html)){
|
||||
$html = $label;
|
||||
}else{
|
||||
$attr['aria-label'] = $label;
|
||||
}
|
||||
|
||||
|
||||
if(empty($userRight)){
|
||||
$attr['class'] = 'butActionRefused';
|
||||
$attr['href'] = '';
|
||||
}
|
||||
|
||||
if(empty($id)){
|
||||
$attr['id'] = $id;
|
||||
}
|
||||
|
||||
// Override attr
|
||||
if(!empty($params['attr']) && is_array($params['attr'])){
|
||||
foreach($params['attr'] as $key => $value){
|
||||
$attr[$key] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($attr['href']) && empty($attr['href'])){
|
||||
unset($attr['href']);
|
||||
}
|
||||
|
||||
// TODO : add a hook
|
||||
|
||||
// escape all attribute
|
||||
$attr = array_map('dol_escape_htmltag', $attr);
|
||||
|
||||
$TCompiledAttr = array();
|
||||
foreach($attr as $key => $value){
|
||||
$TCompiledAttr[] = $key.'="'.$value.'"';
|
||||
}
|
||||
|
||||
$compiledAttributes = !empty($TCompiledAttr)?implode(' ', $TCompiledAttr):'';
|
||||
|
||||
$tag = !empty($attr['href'])?'a':'span';
|
||||
|
||||
return '<div class="inline-block divButAction"><'.$tag.' '.$compiledAttributes.'>'.$html.'</'.$tag.'></div>';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user