dolibarr  9.0.0
Functions
functions.lib.php File Reference

A set of functions for Dolibarr This file contains all frequently used functions. More...

Go to the source code of this file.

Functions

 getStaticMember ($class, $member)
 Function to return value of a static property when class name is dynamically defined (not hard coded). More...
 
 getDoliDBInstance ($type, $host, $user, $pass, $name, $port)
 Return a DoliDB instance (database handler). More...
 
 getEntity ($element, $shared=1, $currentobject=null)
 Get list of entity id to use. More...
 
 getBrowserInfo ($user_agent)
 Return information about user browser. More...
 
 dol_shutdown ()
 Function called at end of web php process. More...
 
 GETPOSTISSET ($paramname)
 Return true if we are in a context of submitting a parameter. More...
 
 GETPOST ($paramname, $check='none', $method=0, $filter=null, $options=null, $noreplace=0)
 Return value of a param into GET or POST supervariable. More...
 
if(! function_exists('dol_getprefix')) dol_include_once ($relpath, $classname='')
 Make an include_once using default root and alternate root if it fails. More...
 
 dol_buildpath ($path, $type=0, $returnemptyifnotfound=0)
 Return path of url or filesystem. More...
 
 dol_clone ($object, $native=0)
 Create a clone of instance of object (new instance with same value for properties) With native = 0: Property that are reference are also new object (true clone). More...
 
 dol_size ($size, $type='')
 Optimize a size for some browsers (phone, smarphone, ...) More...
 
 dol_sanitizeFileName ($str, $newstr='_', $unaccent=1)
 Clean a string to use it as a file name. More...
 
 dol_sanitizePathName ($str, $newstr='_', $unaccent=1)
 Clean a string to use it as a path name. More...
 
 dol_string_unaccent ($str)
 Clean a string from all accent characters to be used as ref, login or by dol_sanitizeFileName. More...
 
 dol_string_nospecial ($str, $newstr='_', $badcharstoreplace='')
 Clean a string from all punctuation characters to use it as a ref or login. More...
 
 dolEscapeXML ($string)
 Encode string for xml usage. More...
 
 dol_escape_js ($stringtoescape, $mode=0, $noescapebackslashn=0)
 Returns text escaped for inclusion into javascript code. More...
 
 dol_escape_htmltag ($stringtoescape, $keepb=0, $keepn=0)
 Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields. More...
 
 dol_strtolower ($utf8_string)
 Convert a string to lower. More...
 
 dol_strtoupper ($utf8_string)
 Convert a string to upper. More...
 
 dol_syslog ($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='')
 Write log message into outputs. More...
 
 dol_fiche_head ($links=array(), $active='0', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='')
 Show tab header of a card. More...
 
 dol_get_fiche_head ($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='')
 Show tab header of a card. More...
 
 dol_fiche_end ($notab=0)
 Show tab footer of a card. More...
 
 dol_get_fiche_end ($notab=0)
 Return tab footer of a card. More...
 
 dol_banner_tab ($object, $paramid, $morehtml='', $shownav=1, $fieldid='rowid', $fieldref='ref', $morehtmlref='', $moreparam='', $nodbprefix=0, $morehtmlleft='', $morehtmlstatus='', $onlybanner=0, $morehtmlright='')
 Show tab footer of a card. More...
 
 fieldLabel ($langkey, $fieldkey, $fieldrequired=0)
 Show a string with the label tag dedicated to the HTML edit field. More...
 
 dol_bc ($var, $moreclass='')
 Return string to add class property on html element with pair/impair. More...
 
 dol_format_address ($object, $withcountry=0, $sep="\, $outputlangs='', $mode=0)
 Return a formated address (part address/zip/town/state) according to country rules. More...
 
 dol_strftime ($fmt, $ts=false, $is_gmt=false)
 Format a string. More...
 
 dol_print_date ($time, $format='', $tzoutput='tzserver', $outputlangs='', $encodetooutput=false)
 Output date in a string format according to outputlangs (or langs if not defined). More...
 
 dol_getdate ($timestamp, $fast=false)
 Return an array with locale date info. More...
 
 dol_mktime ($hour, $minute, $second, $month, $day, $year, $gm=false, $check=1)
 Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Replace function mktime not available under Windows if year < 1970 PHP mktime is restricted to the years 1901-2038 on Unix and 1970-2038 on Windows. More...
 
 dol_now ($mode='gmt')
 Return date for now. More...
 
 dol_print_size ($size, $shortvalue=0, $shortunit=0)
 Return string with formated size. More...
 
 dol_print_url ($url, $target='_blank', $max=32, $withpicto=0)
 Show Url link. More...
 
 dol_print_email ($email, $cid=0, $socid=0, $addlink=0, $max=64, $showinvalid=1, $withpicto=0)
 Show EMail link. More...
 
 dol_print_socialnetworks ($value, $cid, $socid, $type)
 Show social network link. More...
 
 dol_print_phone ($phone, $countrycode='', $cid=0, $socid=0, $addlink='', $separ="&nbsp;", $withpicto='', $titlealt='', $adddivfloat=0)
 Format phone numbers according to country. More...
 
 dol_print_ip ($ip, $mode=0)
 Return an IP formated to be shown on screen. More...
 
 getUserRemoteIP ()
 Return the IP of remote user. More...
 
 dolGetCountryCodeFromIp ($ip)
 Return a country code from IP. More...
 
 dol_user_country ()
 Return country code for current user. More...
 
 dol_print_address ($address, $htmlid, $mode, $id, $noprint=0, $charfornl='')
 Format address string. More...
 
 isValidEmail ($address, $acceptsupervisorkey=0)
 Return true if email syntax is ok. More...
 
 isValidMXRecord ($domain)
 Return if the domain name has a valid MX record. More...
 
 isValidPhone ($phone)
 Return true if phone number syntax is ok TODO Decide what to do with this. More...
 
 dol_strlen ($string, $stringencoding='UTF-8')
 Make a strlen call. More...
 
 dol_substr ($string, $start, $length, $stringencoding='', $trunconbytes=0)
 Make a substring. More...
 
 dol_trunc ($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
 Truncate a string to a particular length adding '...' if string larger than length. More...
 
 img_picto ($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='')
 Show picto whatever it's its name (generic function) More...
 
 img_object ($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0)
 Show a picto called object_picto (generic function) More...
 
 img_weather ($titlealt, $picto, $moreatt='', $pictoisfullpath=0)
 Show weather picto. More...
 
 img_picto_common ($titlealt, $picto, $moreatt='', $pictoisfullpath=0)
 Show picto (generic function) More...
 
 img_action ($titlealt, $numaction)
 Show logo action. More...
 
 img_pdf ($titlealt='default', $size=3)
 Show pdf logo. More...
 
 img_edit_add ($titlealt='default', $other='')
 Show logo +. More...
 
 img_edit_remove ($titlealt='default', $other='')
 Show logo -. More...
 
 img_edit ($titlealt='default', $float=0, $other='class="pictoedit"')
 Show logo editer/modifier fiche. More...
 
 img_view ($titlealt='default', $float=0, $other='')
 Show logo view card. More...
 
 img_delete ($titlealt='default', $other='class="pictodelete"')
 Show delete logo. More...
 
 img_printer ($titlealt="default", $other='')
 Show printer logo. More...
 
 img_split ($titlealt='default', $other='class="pictosplit"')
 Show split logo. More...
 
 img_help ($usehelpcursor=1, $usealttitle=1)
 Show help logo with cursor "?". More...
 
 img_info ($titlealt='default')
 Show info logo. More...
 
 img_warning ($titlealt='default', $moreatt='')
 Show warning logo. More...
 
 img_error ($titlealt='default')
 Show error logo. More...
 
 img_next ($titlealt='default', $moreatt='')
 Show next logo. More...
 
 img_previous ($titlealt='default', $moreatt='')
 Show previous logo. More...
 
 img_down ($titlealt='default', $selected=0, $moreclass='')
 Show down arrow logo. More...
 
 img_up ($titlealt='default', $selected=0, $moreclass='')
 Show top arrow logo. More...
 
 img_left ($titlealt='default', $selected=0, $moreatt='')
 Show left arrow logo. More...
 
 img_right ($titlealt='default', $selected=0, $moreatt='')
 Show right arrow logo. More...
 
 img_allow ($allow, $titlealt='default')
 Show tick logo if allowed. More...
 
 img_credit_card ($brand)
 Return image of a credit card according to its brand name. More...
 
 img_mime ($file, $titlealt='', $morecss='')
 Show MIME img of a file. More...
 
 img_phone ($titlealt='default', $option=0)
 Show phone logo. More...
 
 img_search ($titlealt='default', $other='')
 Show search logo. More...
 
 img_searchclear ($titlealt='default', $other='')
 Show search logo. More...
 
 info_admin ($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='')
 Show information for admin users or standard users. More...
 
 dol_print_error ($db='', $error='', $errors=null)
 Affiche message erreur system avec toutes les informations pour faciliter le diagnostic et la remontee des bugs. More...
 
 dol_print_error_email ($prefixcode, $errormessage='', $errormessages=array(), $morecss='error', $email='')
 Show a public email and error code to contact if technical error. More...
 
 print_liste_field_titre ($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="")
 Show title line of an array. More...
 
 getTitleFieldOfList ($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip='')
 Get title line of an array. More...
 
 print_titre ($title)
 Show a title. More...
 
 print_fiche_titre ($title, $mesg='', $picto='title_generic.png', $pictoisfullpath=0, $id='')
 Show a title with picto. More...
 
 load_fiche_titre ($titre, $morehtmlright='', $picto='title_generic.png', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
 Load a title with picto. More...
 
 print_barre_liste ($titre, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='title_generic.png', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $hideselectlimit=0, $hidenavigation=0)
 Print a title with navigation controls for pagination. More...
 
 print_fleche_navigation ($page, $file, $options='', $nextpage=0, $betweenarrows='', $afterarrows='', $limit=-1, $totalnboflines=0, $hideselectlimit=0)
 Function to show navigation arrows into lists. More...
 
 vatrate ($rate, $addpercent=false, $info_bits=0, $usestarfornpr=0)
 Return a string with VAT rate label formated for view output Used into pdf and HTML pages. More...
 
 price ($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
 Function to format a value into an amount for visual output Function used into PDF and HTML pages. More...
 
 price2num ($amount, $rounding='', $alreadysqlnb=0)
 Function that return a number with universal decimal format (decimal separator is '. More...
 
 showDimensionInBestUnit ($dimension, $unit, $type, $outputlangs, $round=-1, $forceunitoutput='no')
 Output a dimension with best unit. More...
 
 get_localtax ($vatrate, $local, $thirdparty_buyer="", $thirdparty_seller="", $vatnpr=0)
 Return localtax rate for a particular vat, when selling a product with vat $vatrate, from a $thirdparty_buyer to a $thirdparty_seller Note: This function applies same rules than get_default_tva. More...
 
 isOnlyOneLocalTax ($local)
 Return true if LocalTax (1 or 2) is unique. More...
 
 get_localtax_by_third ($local)
 Get values of localtaxes (1 or 2) for company country for the common vat with the highest value. More...
 
 getTaxesFromId ($vatrate, $buyer=null, $seller=null, $firstparamisid=1)
 Get vat main information from Id. More...
 
 getLocalTaxesFromRate ($vatrate, $local, $buyer, $seller, $firstparamisid=0)
 Get type and rate of localtaxes for a particular vat rate/country of a thirdparty. More...
 
 get_product_vat_for_country ($idprod, $thirdparty_seller, $idprodfournprice=0)
 Return vat rate of a product in a particular selling country or default country vat if product is unknown Function called by get_default_tva. More...
 
 get_product_localtax_for_country ($idprod, $local, $thirdparty_seller)
 Return localtax vat rate of a product in a particular selling country or default country vat if product is unknown. More...
 
 get_default_tva (Societe $thirdparty_seller, Societe $thirdparty_buyer, $idprod=0, $idprodfournprice=0)
 Function that return vat rate of a product line (according to seller, buyer and product vat rate) Si vendeur non assujeti a TVA, TVA par defaut=0. More...
 
 get_default_npr (Societe $thirdparty_seller, Societe $thirdparty_buyer, $idprod=0, $idprodfournprice=0)
 Fonction qui renvoie si tva doit etre tva percue recuperable. More...
 
 get_default_localtax ($thirdparty_seller, $thirdparty_buyer, $local, $idprod=0)
 Function that return localtax of a product line (according to seller, buyer and product vat rate) Si vendeur non assujeti a TVA, TVA par defaut=0. More...
 
 yn ($yesno, $case=1, $color=0)
 Return yes or no in current language. More...
 
 get_exdir ($num, $level, $alpha, $withoutslash, $object, $modulepart)
 Return a path to have a the directory according to object where files are stored. More...
 
 dol_mkdir ($dir, $dataroot='', $newmask=null)
 Creation of a directory (this can create recursive subdir) More...
 
 picto_required ()
 Return picto saying a field is required. More...
 
 dol_string_nohtmltag ($stringtoclean, $removelinefeed=1, $pagecodeto='UTF-8', $strip_tags=0)
 Clean a string from all HTML tags and entities. More...
 
 dol_string_onlythesehtmltags ($stringtoclean)
 Clean a string to keep only desirable HTML tags. More...
 
 dol_string_neverthesehtmltags ($stringtoclean, $disallowed_tags=array('textarea'))
 Clean a string from some undesirable HTML tags. More...
 
 dolGetFirstLineOfText ($text, $nboflines=1)
 Return first line of text. More...
 
 dol_nl2br ($stringtoencode, $nl2brmode=0, $forxml=false)
 Replace CRLF in string with a HTML BR tag. More...
 
 dol_htmlentitiesbr ($stringtoencode, $nl2brmode=0, $pagecodefrom='UTF-8', $removelasteolbr=1)
 This function is called to encode a string into a HTML string but differs from htmlentities because a detection is done before to see if text is already HTML or not. More...
 
 dol_htmlentitiesbr_decode ($stringtodecode, $pagecodeto='UTF-8')
 This function is called to decode a HTML string (it decodes entities and br tags) More...
 
 dol_htmlcleanlastbr ($stringtodecode)
 This function remove all ending
and br at end. More...
 
 dol_html_entity_decode ($a, $b, $c='UTF-8')
 Replace html_entity_decode functions to manage errors. More...
 
 dol_htmlentities ($string, $flags=null, $encoding='UTF-8', $double_encode=false)
 Replace htmlentities functions. More...
 
 dol_string_is_good_iso ($s)
 Check if a string is a correct iso string If not, it will we considered not HTML encoded even if it is by FPDF. More...
 
 dol_nboflines ($s, $maxchar=0)
 Return nb of lines of a clear text. More...
 
 dol_nboflines_bis ($text, $maxlinesize=0, $charset='UTF-8')
 Return nb of lines of a formated text with
and
(WARNING: string must not have mixed
and br separators) More...
 
 dol_microtime_float ()
 Same function than microtime in PHP 5 but compatible with PHP4. More...
 
 dol_textishtml ($msg, $option=0)
 Return if a text is a html content. More...
 
 dol_concatdesc ($text1, $text2, $forxml=false)
 Concat 2 descriptions with a new line between them (second operand after first one with appropriate new line separator) text1 html + text2 html => text1 + '
' + text2 text1 html + text2 txt => text1 + '
' + dol_nl2br(text2) text1 txt + text2 html => dol_nl2br(text1) + '
' + text2 text1 txt + text2 txt => text1 + '
' + text2. More...
 
 getCommonSubstitutionArray ($outputlangs, $onlykey=0, $exclude=null, $object=null)
 Return array of possible common substitutions. More...
 
 make_substitutions ($text, $substitutionarray, $outputlangs=null)
 Make substitution into a text string, replacing keys with vals from $substitutionarray (oldval=>newval), and texts like __(TranslationKey|langfile)__ and [ConstantKey] are also replaced. More...
 
 complete_substitutions_array (&$substitutionarray, $outputlangs, $object=null, $parameters=null, $callfunc="completesubstitutionarray")
 Complete the $substitutionarray with more entries coming from external module that had set the "substitutions=1" into module_part array. More...
 
 print_date_range ($date_start, $date_end, $format='', $outputlangs='')
 Format output for start and end date. More...
 
 get_date_range ($date_start, $date_end, $format='', $outputlangs='', $withparenthesis=1)
 Format output for start and end date. More...
 
 dolGetFirstLastname ($firstname, $lastname, $nameorder=-1)
 Return firstname and lastname in correct order. More...
 
 setEventMessage ($mesgs, $style='mesgs')
 Set event message in dol_events session object. More...
 
 setEventMessages ($mesg, $mesgs, $style='mesgs')
 Set event messages in dol_events session object. More...
 
 dol_htmloutput_events ($disabledoutputofmessages=0)
 Print formated messages to output (Used to show messages on html output). More...
 
 get_htmloutput_mesg ($mesgstring='', $mesgarray='', $style='ok', $keepembedded=0)
 Get formated messages to output (Used to show messages on html output). More...
 
 get_htmloutput_errors ($mesgstring='', $mesgarray=array(), $keepembedded=0)
 Get formated error messages to output (Used to show messages on html output). More...
 
 dol_htmloutput_mesg ($mesgstring='', $mesgarray=array(), $style='ok', $keepembedded=0)
 Print formated messages to output (Used to show messages on html output). More...
 
 dol_htmloutput_errors ($mesgstring='', $mesgarray=array(), $keepembedded=0)
 Print formated error messages to output (Used to show messages on html output). More...
 
 dol_sort_array (&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
 Advanced sort array by second index function, which produces ascending (default) or descending output and uses optionally natural case insensitive sorting (which can be optionally case sensitive as well). More...
 
 utf8_check ($str)
 Check if a string is in UTF8. More...
 
 dol_osencode ($str)
 Return a string encoded into OS filesystem encoding. More...
 
 dol_getIdFromCode ($db, $key, $tablename, $fieldkey='code', $fieldid='id', $entityfilter=0)
 Return an id or code from a code or id. More...
 
 verifCond ($strRights)
 Verify if condition in string is ok or not. More...
 
 dol_eval ($s, $returnvalue=0, $hideerrors=1)
 Replace eval function to add more security. More...
 
 dol_validElement ($element)
 Return if var element is ok. More...
 
 picto_from_langcode ($codelang, $moreatt='')
 Return img flag of country for a language code or country code. More...
 
 getLanguageCodeFromCountryCode ($countrycode)
 Return default language from country code. More...
 
 complete_head_from_modules ($conf, $langs, $object, &$head, &$h, $type, $mode='add')
 Complete or removed entries into a head array (used to build tabs). More...
 
 printCommonFooter ($zone='private')
 Print common footer : conf->global->MAIN_HTML_FOOTER js for switch of menu hider js for conf->global->MAIN_GOOGLE_AN_ID js for conf->global->MAIN_SHOW_TUNING_INFO or $_SERVER["MAIN_SHOW_TUNING_INFO"] js for conf->logbuffer. More...
 
 dolExplodeIntoArray ($string, $delimiter=';', $kv='=')
 Split a string with 2 keys into key array. More...
 
 dol_set_focus ($selector)
 Set focus onto field with selector (similar behaviour of 'autofocus' HTML5 tag) More...
 
 dol_getmypid ()
 Return getmypid() or random PID when function is disabled Some web hosts disable this php function for security reasons and sometimes we can't redeclare function. More...
 
 natural_search ($fields, $value, $mode=0, $nofirstand=0)
 Generate natural SQL search string for a criteria (this criteria can be tested on one or several fields) More...
 
 showDirectDownloadLink ($object)
 Return string with full Url. More...
 
 getImageFileNameForSize ($file, $extName, $extImgTarget='')
 Return the filename of file to get the thumbs. More...
 
 getAdvancedPreviewUrl ($modulepart, $relativepath, $alldata=0, $param='')
 Return URL we can use for advanced preview links. More...
 
 ajax_autoselect ($htmlname, $addlink='')
 Make content of an input box selected when we click into input field. More...
 
 dol_mimetype ($file, $default='application/octet-stream', $mode=0)
 Return mime type of a file. More...
 
 getDictvalue ($tablename, $field, $id, $checkentity=false, $rowidfield='rowid')
 Return value from dictionary. More...
 
 colorIsLight ($stringcolor)
 Return true if the color is light. More...
 
 isVisibleToUserType ($type_user, &$menuentry, &$listofmodulesforexternal)
 Function to test if an entry is enabled or not. More...
 
 roundUpToNextMultiple ($n, $x=5)
 Round to next multiple. More...
 

Detailed Description

A set of functions for Dolibarr This file contains all frequently used functions.

Definition in file functions.lib.php.

Function Documentation

◆ ajax_autoselect()

ajax_autoselect (   $htmlname,
  $addlink = '' 
)

Make content of an input box selected when we click into input field.

Parameters
string$htmlnameId of html object
string$addlinkAdd a 'link to' after
Returns
string

Definition at line 7670 of file functions.lib.php.

◆ colorIsLight()

colorIsLight (   $stringcolor)

Return true if the color is light.

Parameters
string$stringcolorString with hex (FFFFFF) or comma RGB ('255,255,255')
Returns
int -1 : Error with argument passed |0 : color is dark | 1 : color is light

Definition at line 7846 of file functions.lib.php.

◆ complete_head_from_modules()

complete_head_from_modules (   $conf,
  $langs,
  $object,
$head,
$h,
  $type,
  $mode = 'add' 
)

Complete or removed entries into a head array (used to build tabs).

For example, with value added by external modules. Such values are declared into $conf->modules_parts['tab']. Or by change using hook completeTabsHead

Parameters
Conf$confObject conf
Translate$langsObject langs
object | null$objectObject object
array$headObject head
int$hNew position to fill
string$typeValue 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 'contract' to add a tabl in contract 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 'stock' to add a tab for warehouse view
string$mode'add' to complete head, 'remove' to remove entries
Returns
void

Definition at line 7069 of file functions.lib.php.

◆ complete_substitutions_array()

complete_substitutions_array ( $substitutionarray,
  $outputlangs,
  $object = null,
  $parameters = null,
  $callfunc = "completesubstitutionarray" 
)

Complete the $substitutionarray with more entries coming from external module that had set the "substitutions=1" into module_part array.

In this case, method completesubstitutionarray provided by module is called.

Parameters
array$substitutionarrayArray substitution old value => new value value
Translate$outputlangsOutput language
Object$objectSource object
mixed$parametersAdd more parameters (useful to pass product lines)
string$callfuncWhat is the name of the custom function that will be called? (default: completesubstitutionarray)
Returns
void
See also
make_substitutions

Definition at line 6202 of file functions.lib.php.

◆ dol_banner_tab()

dol_banner_tab (   $object,
  $paramid,
  $morehtml = '',
  $shownav = 1,
  $fieldid = 'rowid',
  $fieldref = 'ref',
  $morehtmlref = '',
  $moreparam = '',
  $nodbprefix = 0,
  $morehtmlleft = '',
  $morehtmlstatus = '',
  $onlybanner = 0,
  $morehtmlright = '' 
)

Show tab footer of a card.

Note: $object->next_prev_filter can be set to restrict select to find next or previous record by $form->showrefnav.

Parameters
Object$objectObject to show
string$paramidName of parameter to use to name the id into the URL next/previous link
string$morehtmlMore html content to output just before the nav bar
int$shownavShow Condition (navigation is shown if value is 1)
string$fieldidNom du champ en base a utiliser pour select next et previous (we make the select max and min on this field). Use 'none' for no prev/next search.
string$fieldrefNom du champ objet ref (object->ref) a utiliser pour select next et previous
string$morehtmlrefMore html to show after ref
string$moreparamMore param to add in nav link url.
int$nodbprefixDo not include DB prefix to forge table name
string$morehtmlleftMore html code to show before ref
string$morehtmlstatusMore html code to show under navigation arrows
int$onlybannerPut this to 1, if the card will contains only a banner (this add css 'arearefnobottom' on div)
string$morehtmlrightMore html code to show before navigation arrows
Returns
void

Definition at line 1331 of file functions.lib.php.

◆ dol_bc()

dol_bc (   $var,
  $moreclass = '' 
)

Return string to add class property on html element with pair/impair.

Parameters
string$var0 or 1
string$moreclassMore class to add
Returns
string String to add class onto HTML element

Definition at line 1632 of file functions.lib.php.

◆ dol_buildpath()

dol_buildpath (   $path,
  $type = 0,
  $returnemptyifnotfound = 0 
)

Return path of url or filesystem.

Can check into alternate dir or alternate dir + main dir depending on value of $returnemptyifnotfound.

Parameters
string$pathRelative path to file (if mode=0) or relative url (if mode=1). Ie: mydir/myfile, ../myfile
int$type0=Used for a Filesystem path, 1=Used for an URL path (output relative), 2=Used for an URL path (output full path using same host that current url), 3=Used for an URL path (output full path using host defined into $dolibarr_main_url_root of conf file)
int$returnemptyifnotfound0:If $type==0 and if file was not found into alternate dir, return default path into main dir (no test on it) 1:If $type==0 and if file was not found into alternate dir, return empty string 2:If $type==0 and if file was not found into alternate dir, test into main dir, return default path if found, empty string if not found
Returns
string Full filesystem path (if path=0), Full url path (if mode=1)

Definition at line 689 of file functions.lib.php.

◆ dol_clone()

dol_clone (   $object,
  $native = 0 
)

Create a clone of instance of object (new instance with same value for properties) With native = 0: Property that are reference are also new object (true clone).

This means $this->db is not valid. With native = 1: Use PHP clone. Property that are reference are same pointer. This means $this->db is still valid.

Parameters
object$objectObject to clone
int$nativeNative method or true method
Returns
object Object clone
See also
https://php.net/manual/language.oop5.cloning.php

Definition at line 787 of file functions.lib.php.

◆ dol_concatdesc()

dol_concatdesc (   $text1,
  $text2,
  $forxml = false 
)

Concat 2 descriptions with a new line between them (second operand after first one with appropriate new line separator) text1 html + text2 html => text1 + '
' + text2 text1 html + text2 txt => text1 + '
' + dol_nl2br(text2) text1 txt + text2 html => dol_nl2br(text1) + '
' + text2 text1 txt + text2 txt => text1 + '
' + text2.

Parameters
string$text1Text 1
string$text2Text 2
bool$forxmlfalse=Use
instead of
if html content detected, true=Use
instead of
if html content detected
Returns
string Text 1 + new line + Text2
See also
dol_textishtml

Definition at line 5781 of file functions.lib.php.

◆ dol_escape_htmltag()

dol_escape_htmltag (   $stringtoescape,
  $keepb = 0,
  $keepn = 0 
)

Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields.

Parameters
string$stringtoescapeString to escape
int$keepb1=Preserve b tags (otherwise, remove them)
int$keepn1=Preserve
strings (otherwise, replace them with escaped value)
Returns
string Escaped string
See also
dol_string_nohtmltag, dol_string_nospecial, dol_string_unaccent

Definition at line 972 of file functions.lib.php.

◆ dol_escape_js()

dol_escape_js (   $stringtoescape,
  $mode = 0,
  $noescapebackslashn = 0 
)

Returns text escaped for inclusion into javascript code.

Parameters
string$stringtoescapeString to escape
int$mode0=Escape also ' and " into ', 1=Escape ' but not " for usage into 'string', 2=Escape " but not ' for usage into "string", 3=Escape ' and " with \
int$noescapebackslashn0=Escape also
. 1=Do not escape
.
Returns
string Escaped string. Both ' and " are escaped into ' if they are escaped.

Definition at line 949 of file functions.lib.php.

◆ dol_eval()

dol_eval (   $s,
  $returnvalue = 0,
  $hideerrors = 1 
)

Replace eval function to add more security.

This function is called by verifCond() or trans() and transnoentitiesnoconv().

Parameters
string$sString to evaluate
int$returnvalue0=No return (used to execute eval($a=something)). 1=Value of eval is returned (used to eval($something)).
int$hideerrors1=Hide errors
Returns
mixed Nothing or return of eval

Definition at line 6759 of file functions.lib.php.

◆ dol_fiche_end()

dol_fiche_end (   $notab = 0)

Show tab footer of a card.

Parameters
int$notab-1 or 0=Add tab footer, 1=no tab footer
Returns
void

Definition at line 1295 of file functions.lib.php.

References dol_get_fiche_end(), and print.

◆ dol_fiche_head()

dol_fiche_head (   $links = array(),
  $active = '0',
  $title = '',
  $notab = 0,
  $picto = '',
  $pictoisfullpath = 0,
  $morehtmlright = '',
  $morecss = '' 
)

Show tab header of a card.

Parameters
array$linksArray of tabs. Currently initialized by calling a function xxx_admin_prepare_head
string$activeActive tab name (document', 'info', 'ldap', ....)
string$titleTitle
int$notab-1 or 0=Add tab header, 1=no tab header. If you set this to 1, using dol_fiche_end() to close tab is not required.
string$pictoAdd a picto on tab title
int$pictoisfullpathIf 1, image path is a full path. If you set this to 1, you can use url returned by dol_buildpath('/mymodyle/img/myimg.png',1) for $picto.
string$morehtmlrightAdd more html content on right of tabs title
string$morecssMore Css
Returns
void

Definition at line 1117 of file functions.lib.php.

◆ dol_format_address()

dol_format_address (   $object,
  $withcountry = 0,
  $sep = "\n",
  $outputlangs = '',
  $mode = 0 
)

Return a formated address (part address/zip/town/state) according to country rules.

Parameters
Object$objectA company or contact object
int$withcountry1=Add country into address string
string$sepSeparator to use to build string
Translate$outputlangsObject lang that contains language for text translation.
int$mode0=Standard output, 1=Remove address
Returns
string Formated string
See also
dol_print_address

Definition at line 1651 of file functions.lib.php.

◆ dol_get_fiche_end()

dol_get_fiche_end (   $notab = 0)

Return tab footer of a card.

Parameters
int$notab-1 or 0=Add tab footer, 1=no tab footer
Returns
string

Definition at line 1306 of file functions.lib.php.

Referenced by dol_fiche_end().

◆ dol_get_fiche_head()

dol_get_fiche_head (   $links = array(),
  $active = '',
  $title = '',
  $notab = 0,
  $picto = '',
  $pictoisfullpath = 0,
  $morehtmlright = '',
  $morecss = '' 
)

Show tab header of a card.

Parameters
array$linksArray of tabs
string$activeActive tab name
string$titleTitle
int$notab-1 or 0=Add tab header, 1=no tab header. If you set this to 1, using dol_fiche_end() to close tab is not required.
string$pictoAdd a picto on tab title
int$pictoisfullpathIf 1, image path is a full path. If you set this to 1, you can use url returned by dol_buildpath('/mymodyle/img/myimg.png',1) for $picto.
string$morehtmlrightAdd more html content on right of tabs title
string$morecssMore Css
Returns
string

Definition at line 1135 of file functions.lib.php.

◆ dol_getdate()

dol_getdate (   $timestamp,
  $fast = false 
)

Return an array with locale date info.

PHP getdate is restricted to the years 1901-2038 on Unix and 1970-2038 on Windows WARNING: This function always use PHP server timezone to return locale informations !!! Usage must be avoid. FIXME: Replace this with PHP date function and a parameter $gm

Parameters
int$timestampTimestamp
boolean$fastFast mode
Returns
array Array of informations If no fast mode: 'seconds' => $secs, 'minutes' => $min, 'hours' => $hour, 'mday' => $day, 'wday' => $dow, 0=sunday, 6=saturday 'mon' => $month, 'year' => $year, 'yday' => floor($secsInYear/$_day_power), 'weekday' => gmdate('l',$_day_power*(3+$dow)), 'month' => gmdate('F',mktime(0,0,0,$month,2,1971)), If fast mode: 'seconds' => $secs, 'minutes' => $min, 'hours' => $hour, 'mday' => $day, 'mon' => $month, 'year' => $year, 'yday' => floor($secsInYear/$_day_power), 'leap' => $leaf, 'ndays' => $ndays
See also
dol_print_date, dol_stringtotime, dol_mktime

Definition at line 1931 of file functions.lib.php.

◆ dol_getIdFromCode()

dol_getIdFromCode (   $db,
  $key,
  $tablename,
  $fieldkey = 'code',
  $fieldid = 'id',
  $entityfilter = 0 
)

Return an id or code from a code or id.

Store also Code-Id into a cache to speed up next request on same key.

Parameters
DoliDB$dbDatabase handler
string$keyCode or Id to get Id or Code
string$tablenameTable name without prefix
string$fieldkeyField to search the key into
string$fieldidField to get
int$entityfilterFilter by entity
Returns
int <0 if KO, Id of code if OK
See also
$langs->getLabelFromKey

Definition at line 6692 of file functions.lib.php.

◆ dol_getmypid()

dol_getmypid ( )

Return getmypid() or random PID when function is disabled Some web hosts disable this php function for security reasons and sometimes we can't redeclare function.

Returns
int

Definition at line 7399 of file functions.lib.php.

◆ dol_html_entity_decode()

dol_html_entity_decode (   $a,
  $b,
  $c = 'UTF-8' 
)

Replace html_entity_decode functions to manage errors.

Parameters
string$aOperand a
string$bOperand b (ENT_QUOTES=convert simple and double quotes)
string$cOperand c
Returns
string String decoded

Definition at line 5615 of file functions.lib.php.

Referenced by dol_string_nohtmltag().

◆ dol_htmlcleanlastbr()

dol_htmlcleanlastbr (   $stringtodecode)

This function remove all ending
and br at end.

Parameters
string$stringtodecodeString to decode
Returns
string String decoded

Definition at line 5601 of file functions.lib.php.

◆ dol_htmlentities()

dol_htmlentities (   $string,
  $flags = null,
  $encoding = 'UTF-8',
  $double_encode = false 
)

Replace htmlentities functions.

Goal of this function is to be sure to have default values of htmlentities that match what we need.

Parameters
string$stringThe input string to encode
int$flagsFlags (see PHP doc above)
string$encodingEncoding page code
bool$double_encodeWhen double_encode is turned off, PHP will not encode existing html entities
Returns
string $ret Encoded string

Definition at line 5630 of file functions.lib.php.

Referenced by dol_htmlentitiesbr().

◆ dol_htmlentitiesbr()

dol_htmlentitiesbr (   $stringtoencode,
  $nl2brmode = 0,
  $pagecodefrom = 'UTF-8',
  $removelasteolbr = 1 
)

This function is called to encode a string into a HTML string but differs from htmlentities because a detection is done before to see if text is already HTML or not.

Also, all entities but &,<,> are converted. This permits to encode special chars to entities with no double encoding for already encoded HTML strings. This function also remove last EOL or BR if $removelasteolbr=1 (default). For PDF usage, you can show text by 2 ways:

  • writeHTMLCell -> param must be encoded into HTML.
  • MultiCell -> param must not be encoded into HTML. Because writeHTMLCell convert also
    into
    , if function is used to build PDF, nl2brmode must be 1.
Parameters
string$stringtoencodeString to encode
int$nl2brmode0=Adding br before
, 1=Replacing
by br (for use with FPDF writeHTMLCell function for example)
string$pagecodefromPagecode stringtoencode is encoded
int$removelasteolbr1=Remove last br or lasts
(default), 0=Do nothing
Returns
string String encoded

Definition at line 5557 of file functions.lib.php.

References dol_htmlentities(), dol_nl2br(), and dol_textishtml().

◆ dol_htmlentitiesbr_decode()

dol_htmlentitiesbr_decode (   $stringtodecode,
  $pagecodeto = 'UTF-8' 
)

This function is called to decode a HTML string (it decodes entities and br tags)

Parameters
string$stringtodecodeString to decode
string$pagecodetoPage code for result
Returns
string String decoded

Definition at line 5585 of file functions.lib.php.

◆ dol_htmloutput_errors()

dol_htmloutput_errors (   $mesgstring = '',
  $mesgarray = array(),
  $keepembedded = 0 
)

Print formated error messages to output (Used to show messages on html output).

Parameters
string$mesgstringError message
array$mesgarrayError messages array
int$keepembeddedSet to 1 in error message must be kept embedded into its html place (this disable jnotify)
Returns
void
See also
dol_print_error
dol_htmloutput_mesg

Definition at line 6578 of file functions.lib.php.

References dol_htmloutput_mesg().

◆ dol_htmloutput_events()

dol_htmloutput_events (   $disabledoutputofmessages = 0)

Print formated messages to output (Used to show messages on html output).

Note: Calling dol_htmloutput_events is done into pages by standard llxFooter() function, so there is no need to call it explicitely.

Parameters
int$disabledoutputofmessagesClear all messages stored into session without diplaying them
Returns
void
See also
dol_htmloutput_mesg

Definition at line 6395 of file functions.lib.php.

Referenced by llxFooterSurvey().

◆ dol_htmloutput_mesg()

dol_htmloutput_mesg (   $mesgstring = '',
  $mesgarray = array(),
  $style = 'ok',
  $keepembedded = 0 
)

Print formated messages to output (Used to show messages on html output).

Parameters
string$mesgstringMessage string or message key
string[]$mesgarray Array of message strings or message keys
string$styleWhich style to use ('ok', 'warning', 'error')
int$keepembeddedSet to 1 if message must be kept embedded into its html place (this disable jnotify)
Returns
void
See also
dol_print_error
dol_htmloutput_errors
setEventMessages

Definition at line 6524 of file functions.lib.php.

Referenced by dol_htmloutput_errors().

◆ dol_include_once()

if (! function_exists( 'dol_getprefix')) dol_include_once (   $relpath,
  $classname = '' 
)

Make an include_once using default root and alternate root if it fails.

To link to a core file, use include(DOL_DOCUMENT_ROOT.'/pathtofile') To link to a module file from a module file, use include './mymodulefile'; To link to a module file from a core file, then this function can be used (call by hook / trigger / speciales pages)

Parameters
string$relpathRelative path to file (Ie: mydir/myfile, ../myfile, ...)
string$classnameClass name (deprecated)
Returns
bool True if load is a success, False if it fails

Definition at line 660 of file functions.lib.php.

◆ dol_microtime_float()

dol_microtime_float ( )

Same function than microtime in PHP 5 but compatible with PHP4.

Returns
float Time (millisecondes) with microsecondes in decimal part
Deprecated:
Dolibarr does not support PHP4, you should use native function
See also
microtime()

Definition at line 5725 of file functions.lib.php.

References dol_syslog().

◆ dol_mimetype()

dol_mimetype (   $file,
  $default = 'application/octet-stream',
  $mode = 0 
)

Return mime type of a file.

Parameters
string$fileFilename we looking for MIME type
string$defaultDefault mime type if extension not found in known list
int$mode0=Return full mime, 1=otherwise short mime string, 2=image for mime type, 3=source language, 4=css of font fa
Returns
string Return a mime type family (text/xxx, application/xxx, image/xxx, audio, video, archive)
See also
image_format_supported (images.lib.php)

Definition at line 7692 of file functions.lib.php.

◆ dol_mkdir()

dol_mkdir (   $dir,
  $dataroot = '',
  $newmask = null 
)

Creation of a directory (this can create recursive subdir)

Parameters
string$dirDirectory to create (Separator must be '/'. Example: '/mydir/mysubdir')
string$datarootData root directory (To avoid having the data root in the loop. Using this will also lost the warning on first dir PHP has no permission when open_basedir is used)
int$newmaskMask for new file (Defaults to $conf->global->MAIN_UMASK or 0755 if unavailable). Example: '0444'
Returns
int < 0 if KO, 0 = already exists, > 0 if OK

Definition at line 5296 of file functions.lib.php.

◆ dol_mktime()

dol_mktime (   $hour,
  $minute,
  $second,
  $month,
  $day,
  $year,
  $gm = false,
  $check = 1 
)

Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Replace function mktime not available under Windows if year < 1970 PHP mktime is restricted to the years 1901-2038 on Unix and 1970-2038 on Windows.

Parameters
int$hourHour (can be -1 for undefined)
int$minuteMinute (can be -1 for undefined)
int$secondSecond (can be -1 for undefined)
int$monthMonth (1 to 12)
int$dayDay (1 to 31)
int$yearYear
mixed$gmTrue or 1 or 'gmt'=Input informations are GMT values False or 0 or 'server' = local to server TZ 'user' = local to user TZ 'tz,TimeZone' = use specified timezone
int$check0=No check on parameters (Can use day 32, etc...)
Returns
int|string Date as a timestamp, '' or false if error
See also
dol_print_date, dol_stringtotime, dol_getdate

Definition at line 1970 of file functions.lib.php.

◆ dol_nboflines()

dol_nboflines (   $s,
  $maxchar = 0 
)

Return nb of lines of a clear text.

Parameters
string$sString to check
int$maxcharNot yet used
Returns
int Number of lines
See also
dol_nboflines_bis, dolGetFirstLineOfText

Definition at line 5666 of file functions.lib.php.

◆ dol_nboflines_bis()

dol_nboflines_bis (   $text,
  $maxlinesize = 0,
  $charset = 'UTF-8' 
)

Return nb of lines of a formated text with
and
(WARNING: string must not have mixed
and br separators)

Parameters
string$textText
int$maxlinesizeLargeur de ligne en caracteres (ou 0 si pas de limite - defaut)
string$charsetGive the charset used to encode the $text variable in memory.
Returns
int Number of lines
See also
dol_nboflines, dolGetFirstLineOfText

Definition at line 5685 of file functions.lib.php.

◆ dol_nl2br()

dol_nl2br (   $stringtoencode,
  $nl2brmode = 0,
  $forxml = false 
)

Replace CRLF in string with a HTML BR tag.

Parameters
string$stringtoencodeString to encode
int$nl2brmode0=Adding br before
, 1=Replacing
by br
bool$forxmlfalse=Use
, true=Use
Returns
string String encoded
See also
dol_nboflines, dolGetFirstLineOfText

Definition at line 5529 of file functions.lib.php.

Referenced by dol_htmlentitiesbr().

◆ dol_now()

dol_now (   $mode = 'gmt')

Return date for now.

In most cases, we use this function without parameters (that means GMT time).

Parameters
string$mode'gmt' => we return GMT timestamp, 'tzserver' => we add the PHP server timezone 'tzref' => we add the company timezone 'tzuser' => we add the user timezone
Returns
int $date Timestamp

Definition at line 2053 of file functions.lib.php.

Referenced by Opensurveysondage\initAsSpecimen().

◆ dol_osencode()

dol_osencode (   $str)

Return a string encoded into OS filesystem encoding.

This function is used to define value to pass to filesystem PHP functions.

Parameters
string$strString to encode (UTF-8)
Returns
string Encoded string (UTF-8, ISO-8859-1)

Definition at line 6665 of file functions.lib.php.

Referenced by CMailFile\_encode_file(), dol_dir_is_emtpy(), dol_filemtime(), dol_filesize(), dol_is_dir(), dol_is_file(), and dol_is_link().

◆ dol_print_address()

dol_print_address (   $address,
  $htmlid,
  $mode,
  $id,
  $noprint = 0,
  $charfornl = '' 
)

Format address string.

Parameters
string$addressAddress
int$htmlidHtml ID (for example 'gmap')
int$modethirdparty|contact|member|other
int$idId of object
int$noprintNo output. Result is the function return
string$charfornlChar to use instead of nl2br. '' means we use a standad nl2br.
Returns
string|void Nothing if noprint is 0, formatted address if noprint is 1
See also
dol_format_address

Definition at line 2755 of file functions.lib.php.

◆ dol_print_date()

dol_print_date (   $time,
  $format = '',
  $tzoutput = 'tzserver',
  $outputlangs = '',
  $encodetooutput = false 
)

Output date in a string format according to outputlangs (or langs if not defined).

Return charset is always UTF-8, except if encodetoouput is defined. In this case charset is output charset

Parameters
int$timeGM Timestamps date
string$formatOutput date format (tag of strftime function) "%d %b %Y", "%d/%m/%Y %H:%M", "%d/%m/%Y %H:%M:%S", "%B"=Long text of month, "%A"=Long text of day, "%b"=Short text of month, "%a"=Short text of day "day", "daytext", "dayhour", "dayhourldap", "dayhourtext", "dayrfc", "dayhourrfc", "...reduceformat"
string$tzoutputtrue or 'gmt' => string is for Greenwich location false or 'tzserver' => output string is for local PHP server TZ usage 'tzuser' => output string is for user TZ (current browser TZ with current dst) => In a future, we should have same behaviour than 'tzuserrel' 'tzuserrel' => output string is for user TZ (current browser TZ with dst or not, depending on date position) (TODO not implemented yet)
Translate$outputlangsObject lang that contains language for text translation.
boolean$encodetooutputfalse=no convert into output pagecode
Returns
string Formated date or '' if time is null
See also
dol_mktime, dol_stringtotime, dol_getdate

Definition at line 1754 of file functions.lib.php.

Referenced by AccountancyExport\exportFEC().

◆ dol_print_email()

dol_print_email (   $email,
  $cid = 0,
  $socid = 0,
  $addlink = 0,
  $max = 64,
  $showinvalid = 1,
  $withpicto = 0 
)

Show EMail link.

Parameters
string$emailEMail to show (only email, without 'Name of recipient' before)
int$cidId of contact if known
int$socidId of third party if known
int$addlink0=no link, 1=email has a html email link (+ link to create action if constant AGENDA_ADDACTIONFOREMAIL is on)
int$maxMax number of characters to show
int$showinvalidShow warning if syntax email is wrong
int$withpictoShow picto
Returns
string HTML Link

Definition at line 2158 of file functions.lib.php.

◆ dol_print_error()

dol_print_error (   $db = '',
  $error = '',
  $errors = null 
)

Affiche message erreur system avec toutes les informations pour faciliter le diagnostic et la remontee des bugs.

On doit appeler cette fonction quand une erreur technique bloquante est rencontree. Toutefois, il faut essayer de ne l'appeler qu'au sein de pages php, les classes devant renvoyer leur erreur par l'intermediaire de leur propriete "error".

Parameters
DoliDB$dbDatabase handler
mixed$errorString or array of errors strings to show
array$errorsArray of errors
Returns
void
See also
dol_htmloutput_errors

Definition at line 3731 of file functions.lib.php.

Referenced by Holiday\verifDateHolidayCP().

◆ dol_print_error_email()

dol_print_error_email (   $prefixcode,
  $errormessage = '',
  $errormessages = array(),
  $morecss = 'error',
  $email = '' 
)

Show a public email and error code to contact if technical error.

Parameters
string$prefixcodePrefix of public error code
string$errormessageComplete error message
array$errormessagesArray of error messages
string$morecssMore css
string$emailEmail
Returns
void

Definition at line 3859 of file functions.lib.php.

◆ dol_print_ip()

dol_print_ip (   $ip,
  $mode = 0 
)

Return an IP formated to be shown on screen.

Parameters
string$ipIP
int$mode0=return IP + country/flag, 1=return only country/flag, 2=return only IP
Returns
string Formated IP, with country if GeoIP module is enabled

Definition at line 2650 of file functions.lib.php.

◆ dol_print_phone()

dol_print_phone (   $phone,
  $countrycode = '',
  $cid = 0,
  $socid = 0,
  $addlink = '',
  $separ = "&nbsp;",
  $withpicto = '',
  $titlealt = '',
  $adddivfloat = 0 
)

Format phone numbers according to country.

Parameters
string$phonePhone number to format
string$countrycodeCountry code to use for formatting
int$cidId of contact if known
int$socidId of third party if known
string$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)
string$separSeparation between numbers for a better visibility example : xx.xx.xx.xx.xx
string$withpictoShow picto
string$titlealtText to show on alt
int$adddivfloatAdd div float around phone.
Returns
string Formated phone number

Definition at line 2271 of file functions.lib.php.

◆ dol_print_size()

dol_print_size (   $size,
  $shortvalue = 0,
  $shortunit = 0 
)

Return string with formated size.

Parameters
int$sizeSize to print
int$shortvalueTell if we want long value to use another unit (Ex: 1.5Kb instead of 1500b)
int$shortunitUse short label of size unit (for example 'b' instead of 'bytes')
Returns
string Link

Definition at line 2092 of file functions.lib.php.

◆ dol_print_socialnetworks()

dol_print_socialnetworks (   $value,
  $cid,
  $socid,
  $type 
)

Show social network link.

Parameters
string$valueSkype to show (only skype, without 'Name of recipient' before)
int$cidId of contact if known
int$socidId of third party if known
string$type'skype','facebook',...
Returns
string HTML Link

Definition at line 2215 of file functions.lib.php.

◆ dol_print_url()

dol_print_url (   $url,
  $target = '_blank',
  $max = 32,
  $withpicto = 0 
)

Show Url link.

Parameters
string$urlUrl to show
string$targetTarget for link
int$maxMax number of characters to show
int$withpictoWith picto
Returns
string HTML Link

Definition at line 2128 of file functions.lib.php.

◆ dol_sanitizeFileName()

dol_sanitizeFileName (   $str,
  $newstr = '_',
  $unaccent = 1 
)

Clean a string to use it as a file name.

Parameters
string$strString to clean
string$newstrString to replace bad chars with
int$unaccent1=Remove also accent (default), 0 do not remove them
Returns
string String cleaned (a-zA-Z_)
See also
dol_string_nospecial, dol_string_unaccent, dol_sanitizePathName

Definition at line 831 of file functions.lib.php.

References dol_string_nospecial(), and dol_string_unaccent().

◆ dol_sanitizePathName()

dol_sanitizePathName (   $str,
  $newstr = '_',
  $unaccent = 1 
)

Clean a string to use it as a path name.

Parameters
string$strString to clean
string$newstrString to replace bad chars with
int$unaccent1=Remove also accent (default), 0 do not remove them
Returns
string String cleaned (a-zA-Z_)
See also
dol_string_nospecial, dol_string_unaccent, dol_sanitizeFileName

Definition at line 847 of file functions.lib.php.

References dol_string_nospecial(), and dol_string_unaccent().

◆ dol_set_focus()

dol_set_focus (   $selector)

Set focus onto field with selector (similar behaviour of 'autofocus' HTML5 tag)

Parameters
string$selectorSelector ('#id' or 'input[name="ref"]') to use to find the HTML input field that must get the autofocus. You must use a CSS selector, so unique id preceding with the '#' char.
Returns
string HTML code to set focus

Definition at line 7385 of file functions.lib.php.

◆ dol_shutdown()

dol_shutdown ( )

Function called at end of web php process.

Returns
void

Definition at line 233 of file functions.lib.php.

◆ dol_size()

dol_size (   $size,
  $type = '' 
)

Optimize a size for some browsers (phone, smarphone, ...)

Parameters
int$sizeSize we want
string$typeType of optimizing: '' = function used to define a size for truncation 'width' = function is used to define a width
Returns
int New size after optimizing

Definition at line 812 of file functions.lib.php.

◆ dol_sort_array()

dol_sort_array ( $array,
  $index,
  $order = 'asc',
  $natsort = 0,
  $case_sensitive = 0,
  $keepindex = 0 
)

Advanced sort array by second index function, which produces ascending (default) or descending output and uses optionally natural case insensitive sorting (which can be optionally case sensitive as well).

Parameters
array$arrayArray to sort (array of array('key','otherkey1','otherkey2'...))
string$indexKey in array to use for sorting criteria
int$orderSort order ('asc' or 'desc')
int$natsort1=use "natural" sort (natsort), 0=use "standard" sort (asort)
int$case_sensitive1=sort is case sensitive, 0=not case sensitive
int$keepindexIf 0 and index key of array to sort is a numeric, than index will be rewrote. If 1 or index key is not numeric, key for index is kept after sorting.
Returns
array Sorted array

Definition at line 6596 of file functions.lib.php.

◆ dol_strftime()

dol_strftime (   $fmt,
  $ts = false,
  $is_gmt = false 
)

Format a string.

Parameters
string$fmtFormat of strftime function (http://php.net/manual/fr/function.strftime.php)
int$tsTimesamp (If is_gmt is true, timestamp is already includes timezone and daylight saving offset, if is_gmt is false, timestamp is a GMT timestamp and we must compensate with server PHP TZ)
int$is_gmtSee comment of timestamp parameter
Returns
string A formatted string

Definition at line 1725 of file functions.lib.php.

◆ dol_string_is_good_iso()

dol_string_is_good_iso (   $s)

Check if a string is a correct iso string If not, it will we considered not HTML encoded even if it is by FPDF.

Example, if string contains euro symbol that has ascii code 128

Parameters
string$sString to check
Returns
int 0 if bad iso, 1 if good iso

Definition at line 5643 of file functions.lib.php.

◆ dol_string_neverthesehtmltags()

dol_string_neverthesehtmltags (   $stringtoclean,
  $disallowed_tags = array('textarea') 
)

Clean a string from some undesirable HTML tags.

Parameters
string$stringtocleanString to clean
array$disallowed_tagsArray of tags not allowed
Returns
string String cleaned
See also
dol_escape_htmltag strip_tags dol_string_nohtmltag dol_string_onlythesehtmltags

Definition at line 5451 of file functions.lib.php.

◆ dol_string_nohtmltag()

dol_string_nohtmltag (   $stringtoclean,
  $removelinefeed = 1,
  $pagecodeto = 'UTF-8',
  $strip_tags = 0 
)

Clean a string from all HTML tags and entities.

This function differs from strip_tags because:


  • are replaced with
    if removelinefeed=0 or 1
  • if entities are found, they are decoded BEFORE the strip
  • you can decide to convert line feed into a space
Parameters
string$stringtocleanString to clean
integer$removelinefeed1=Replace all new lines by 1 space, 0=Only ending new lines are removed others are replaced with
, 2=Ending new lines are removed but others are kept with a same number of
than nb of
when there is both "...<br>\n..."
string$pagecodetoEncoding of input/output string
integer$strip_tags0=Use internal strip, 1=Use strip_tags() php function (bugged when text contains a < char that is not for a html tag)
Returns
string String cleaned
See also
dol_escape_htmltag strip_tags dol_string_onlythesehtmltags dol_string_neverthesehtmltags

Definition at line 5387 of file functions.lib.php.

References dol_html_entity_decode().

Referenced by ExportExcel\excel_clean(), and ExportTsv\tsv_clean().

◆ dol_string_nospecial()

dol_string_nospecial (   $str,
  $newstr = '_',
  $badcharstoreplace = '' 
)

Clean a string from all punctuation characters to use it as a ref or login.

This is a more complete function than dol_sanitizeFileName.

Parameters
string$strString to clean
string$newstrString to replace forbidden chars with
array$badcharstoreplaceList of forbidden characters
Returns
string Cleaned string
See also
dol_sanitizeFilename, dol_string_unaccent

Definition at line 919 of file functions.lib.php.

Referenced by dol_sanitizeFileName(), and dol_sanitizePathName().

◆ dol_string_onlythesehtmltags()

dol_string_onlythesehtmltags (   $stringtoclean)

Clean a string to keep only desirable HTML tags.

Parameters
string$stringtocleanString to clean
Returns
string String cleaned
See also
dol_escape_htmltag strip_tags dol_string_nohtmltag dol_string_neverthesehtmltags

Definition at line 5425 of file functions.lib.php.

◆ dol_string_unaccent()

dol_string_unaccent (   $str)

Clean a string from all accent characters to be used as ref, login or by dol_sanitizeFileName.

Parameters
string$strString to clean
Returns
string Cleaned string
See also
dol_sanitizeFilename, dol_string_nospecial

Definition at line 861 of file functions.lib.php.

References utf8_check().

Referenced by dol_sanitizeFileName(), and dol_sanitizePathName().

◆ dol_strlen()

dol_strlen (   $string,
  $stringencoding = 'UTF-8' 
)

Make a strlen call.

Works even if mbstring module not enabled

Parameters
string$stringString to calculate length
string$stringencodingEncoding of string
Returns
int Length of string

Definition at line 2864 of file functions.lib.php.

Referenced by binhex(), dol_ch_controle_bvrb(), Ldap\littleEndian(), Fichinter\update(), and utf8_check().

◆ dol_strtolower()

dol_strtolower (   $utf8_string)

Convert a string to lower.

Never use strtolower because it does not works with UTF8 strings.

Parameters
string$utf8_stringString to encode
Returns
string String converted

Definition at line 988 of file functions.lib.php.

◆ dol_strtoupper()

dol_strtoupper (   $utf8_string)

Convert a string to upper.

Never use strtolower because it does not works with UTF8 strings.

Parameters
string$utf8_stringString to encode
Returns
string String converted

Definition at line 999 of file functions.lib.php.

◆ dol_substr()

dol_substr (   $string,
  $start,
  $length,
  $stringencoding = '',
  $trunconbytes = 0 
)

Make a substring.

Works even if mbstring module is not enabled for better compatibility.

Parameters
string$stringString to scan
string$startStart position
int$lengthLength (in nb of characters or nb of bytes depending on trunconbytes param)
string$stringencodingPage code used for input string encoding
int$trunconbytes1=Length is max of bytes instead of max of characters
Returns
string substring

Definition at line 2880 of file functions.lib.php.

◆ dol_syslog()

dol_syslog (   $message,
  $level = LOG_INFO,
  $ident = 0,
  $suffixinfilename = '',
  $restricttologhandler = '' 
)

Write log message into outputs.

Possible outputs can be: SYSLOG_HANDLERS = ["mod_syslog_file"] file name is then defined by SYSLOG_FILE SYSLOG_HANDLERS = ["mod_syslog_syslog"] facility is then defined by SYSLOG_FACILITY Warning, syslog functions are bugged on Windows, generating memory protection faults. To solve this, use logging to files instead of syslog (see setup of module). Note: If constant 'SYSLOG_FILE_NO_ERROR' defined, we never output any error message when writing to log fails. Note: You can get log message into html sources by adding parameter &logtohtml=1 (constant MAIN_LOGTOHTML must be set) This function works only if syslog module is enabled. This must not use any call to other function calling dol_syslog (avoid infinite loop).

Parameters
string$messageLine to log. ''=Show nothing
int$levelLog level On Windows LOG_ERR=4, LOG_WARNING=5, LOG_NOTICE=LOG_INFO=6, LOG_DEBUG=6 si define_syslog_variables ou PHP 5.3+, 7 si dolibarr On Linux LOG_ERR=3, LOG_WARNING=4, LOG_INFO=6, LOG_DEBUG=7
int$ident1=Increase ident of 1, -1=Decrease ident of 1
string$suffixinfilenameWhen output is a file, append this suffix into default log filename.
string$restricttologhandlerOutput log only for this log handler
Returns
void

Definition at line 1025 of file functions.lib.php.

Referenced by mailing_pomme\add_to_target(), mailing_fraise\add_to_target(), Categorie\build_path_from_id_categ(), User\build_path_from_id_user(), CommonInvoice\calculate_date_lim_reglement(), check_user_password_http(), User\clearrights(), MailmanSpip\connectSpip(), ProductStockEntrepot\create(), Cchargesociales\createFromClone(), Ctyperesource\createFromClone(), ProductStockEntrepot\createFromClone(), Productlot\createFromClone(), EcmFiles\createFromClone(), BookKeeping\createFromClone(), ProductStockEntrepot\delete(), Productlot\delete(), Address\delete(), Website\delete(), EcmFiles\delete(), Product\delete(), dol_json_decode(), dol_json_encode(), dol_microtime_float(), ProductStockEntrepot\fetch(), MultiCurrency\fetch(), Website\fetch(), MouvementStock\fetch(), CurrencyRate\fetch(), getStaticMember(), DiscountAbsolute\getSumCreditNotesUsed(), DiscountAbsolute\getSumDepositsUsed(), Categorie\initAsSpecimen(), ModeleExports\liste_modeles(), ModeleImports\liste_modeles(), Societe\replaceThirdparty(), DoliDBMysqli\select_db(), DoliDBSqlite3\select_db(), Facture\set_canceled(), CompanyBankAccount\setAsDefault(), CompanyPaymentMode\setAsDefault(), FactureRec\setAutoValidate(), Ticket\setContract(), FactureRec\setFrequencyAndUnit(), FactureRec\setGeneratePdf(), FactureRec\setNextDate(), Productlot\update(), ProductStockEntrepot\update(), Website\update(), Contrat\update_statut(), Lettering\updateLettering(), and Holiday\verifNbUsers().

◆ dol_textishtml()

dol_textishtml (   $msg,
  $option = 0 
)

Return if a text is a html content.

Parameters
string$msgContent to check
int$option0=Full detection, 1=Fast check
Returns
boolean true/false
See also
dol_concatdesc

Definition at line 5740 of file functions.lib.php.

Referenced by dol_htmlentitiesbr().

◆ dol_trunc()

dol_trunc (   $string,
  $size = 40,
  $trunc = 'right',
  $stringencoding = 'UTF-8',
  $nodot = 0,
  $display = 0 
)

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

Parameters
string$stringString to truncate
int$sizeMax string size visible (excluding ...). 0 for no limit. WARNING: Final string size can have 3 more chars (if we added ..., or if size was max+1 or max+2 or max+3 so it does not worse to replace with ...)
string$truncWhere to trunc: right, left, middle (size must be a 2 power), wrap
string$stringencodingTell what is source string encoding
int$nodotTruncation do not add ... after truncation. So it's an exact truncation.
int$displayTrunc is used to display data and can be changed for small screen. TODO Remove this param (must be dealt with CSS)
Returns
string Truncated string. WARNING: length is never higher than $size if $nodot is set, but can be 3 chars higher otherwise.

Definition at line 2926 of file functions.lib.php.

Referenced by WebsitePage\create(), AccountancyExport\trunc(), and WebsitePage\update().

◆ dol_user_country()

dol_user_country ( )

Return country code for current user.

If software is used inside a local network, detection may fails (we need a public ip)

Returns
string Country code (fr, es, it, us, ...)

Definition at line 2723 of file functions.lib.php.

◆ dol_validElement()

dol_validElement (   $element)

Return if var element is ok.

Parameters
string$elementVariable to check
Returns
boolean Return true of variable is not empty

Definition at line 6790 of file functions.lib.php.

◆ dolEscapeXML()

dolEscapeXML (   $string)

Encode string for xml usage.

Parameters
string$stringString to encode
Returns
string String encoded

Definition at line 936 of file functions.lib.php.

◆ dolExplodeIntoArray()

dolExplodeIntoArray (   $string,
  $delimiter = ';',
  $kv = '=' 
)

Split a string with 2 keys into key array.

For example: "A=1;B=2;C=2" is exploded into array('A'=>1,'B'=>2,'C'=>3)

Parameters
string$stringString to explode
string$delimiterDelimiter between each couple of data
string$kvDelimiter between key and value
Returns
array Array of data exploded

Definition at line 7359 of file functions.lib.php.

◆ dolGetCountryCodeFromIp()

dolGetCountryCodeFromIp (   $ip)

Return a country code from IP.

Empty string if not found.

Parameters
string$ipIP
Returns
string Country code ('us', 'fr', ...)

Definition at line 2694 of file functions.lib.php.

◆ dolGetFirstLastname()

dolGetFirstLastname (   $firstname,
  $lastname,
  $nameorder = -1 
)

Return firstname and lastname in correct order.

Parameters
string$firstnameFirstname
string$lastnameLastname
int$nameorder-1=Auto, 0=Lastname+Firstname, 1=Firstname+Lastname, 2=Firstname
Returns
string Firstname + lastname or Lastname + firstname

Definition at line 6305 of file functions.lib.php.

◆ dolGetFirstLineOfText()

dolGetFirstLineOfText (   $text,
  $nboflines = 1 
)

Return first line of text.

Cut will depends if content is HTML or not.

Parameters
string$textInput text
int$nboflinesNb of lines to get (default is 1 = first line only)
Returns
string Output text
See also
dol_nboflines_bis, dol_string_nohtmltag, dol_escape_htmltag

Definition at line 5471 of file functions.lib.php.

◆ fieldLabel()

fieldLabel (   $langkey,
  $fieldkey,
  $fieldrequired = 0 
)

Show a string with the label tag dedicated to the HTML edit field.

Parameters
string$langkeyTranslation key
string$fieldkeyKey of the html select field the text refers to
int$fieldrequired1=Field is mandatory
Returns
string
Deprecated:
Form::editfieldkey

Definition at line 1613 of file functions.lib.php.

◆ get_date_range()

get_date_range (   $date_start,
  $date_end,
  $format = '',
  $outputlangs = '',
  $withparenthesis = 1 
)

Format output for start and end date.

Parameters
int$date_startStart date
int$date_endEnd date
string$formatOutput format
Translate$outputlangsOutput language
integer$withparenthesis1=Add parenthesis, 0=non parenthesis
Returns
string String

Definition at line 6273 of file functions.lib.php.

◆ get_default_localtax()

get_default_localtax (   $thirdparty_seller,
  $thirdparty_buyer,
  $local,
  $idprod = 0 
)

Function that return localtax of a product line (according to seller, buyer and product vat rate) Si vendeur non assujeti a TVA, TVA par defaut=0.

Fin de regle. Si le (pays vendeur = pays acheteur) alors TVA par defaut=TVA du produit vendu. Fin de regle. Sinon TVA proposee par defaut=0. Fin de regle.

Parameters
Societe$thirdparty_sellerThirdparty seller
Societe$thirdparty_buyerThirdparty buyer
int$localLocaltax to process (1 or 2)
int$idprodId product
Returns
integer localtax, -1 si ne peut etre determine
See also
get_default_tva, get_default_npr

Definition at line 5166 of file functions.lib.php.

◆ get_default_npr()

get_default_npr ( Societe  $thirdparty_seller,
Societe  $thirdparty_buyer,
  $idprod = 0,
  $idprodfournprice = 0 
)

Fonction qui renvoie si tva doit etre tva percue recuperable.

Parameters
Societe$thirdparty_sellerThirdparty seller
Societe$thirdparty_buyerThirdparty buyer
int$idprodId product
int$idprodfournpriceId supplier price for product
Returns
float 0 or 1
See also
get_default_tva, get_default_localtax

Definition at line 5129 of file functions.lib.php.

◆ get_default_tva()

get_default_tva ( Societe  $thirdparty_seller,
Societe  $thirdparty_buyer,
  $idprod = 0,
  $idprodfournprice = 0 
)

Function that return vat rate of a product line (according to seller, buyer and product vat rate) Si vendeur non assujeti a TVA, TVA par defaut=0.

Fin de regle. Si le (pays vendeur = pays acheteur) alors TVA par defaut=TVA du produit vendu. Fin de regle. Si (vendeur et acheteur dans Communaute europeenne) et (bien vendu = moyen de transports neuf comme auto, bateau, avion) alors TVA par defaut=0 (La TVA doit etre paye par acheteur au centre d'impots de son pays et non au vendeur). Fin de regle. Si (vendeur et acheteur dans Communaute europeenne) et (acheteur = particulier ou entreprise sans num TVA intra) alors TVA par defaut=TVA du produit vendu. Fin de regle Si (vendeur et acheteur dans Communaute europeenne) et (acheteur = entreprise avec num TVA) intra alors TVA par defaut=0. Fin de regle Sinon TVA proposee par defaut=0. Fin de regle.

Parameters
Societe$thirdparty_sellerObjet societe vendeuse
Societe$thirdparty_buyerObjet societe acheteuse
int$idprodId product
int$idprodfournpriceId product_fournisseur_price (for supplier order/invoice)
Returns
float|string Vat rate to use with format 5.0 or '5.0 (XXX)', -1 if we can't guess it
See also
get_default_npr, get_default_localtax

Definition at line 5042 of file functions.lib.php.

◆ get_exdir()

get_exdir (   $num,
  $level,
  $alpha,
  $withoutslash,
  $object,
  $modulepart 
)

Return a path to have a the directory according to object where files are stored.

New usage: $conf->module->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 1, $object, $modulepart) or: $conf->module->dir_output.'/'.get_exdir(0, 0, 0, 1, $object, $modulepart) if multidir_output not defined. Example our with new usage: $object is invoice -> 'INYYMM-ABCD' Example our with old usage: '015' with level 3->"0/1/5/", '015' with level 1->"5/", 'ABC-1' with level 3 ->"0/0/1/"

Parameters
string$numId of object (deprecated, $object will be used in future)
int$levelLevel of subdirs to return (1, 2 or 3 levels). (deprecated, global option will be used in future)
int$alpha0=Keep number only to forge path, 1=Use alpha part afer the - (By default, use 0). (deprecated, global option will be used in future)
int$withoutslash0=With slash at end (except if '/', we return ''), 1=without slash at end
Object$objectObject
string$modulepartType of object ('invoice_supplier, 'donation', 'invoice', ...')
Returns
string Dir to use ending. Example '' or '1/' or '1/2/'

Definition at line 5252 of file functions.lib.php.

◆ get_htmloutput_errors()

get_htmloutput_errors (   $mesgstring = '',
  $mesgarray = array(),
  $keepembedded = 0 
)

Get formated error messages to output (Used to show messages on html output).

Parameters
string$mesgstringError message
array$mesgarrayError messages array
int$keepembeddedSet to 1 in error message must be kept embedded into its html place (this disable jnotify)
Returns
string Return html output
See also
dol_print_error
dol_htmloutput_mesg

Definition at line 6506 of file functions.lib.php.

References get_htmloutput_mesg().

◆ get_htmloutput_mesg()

get_htmloutput_mesg (   $mesgstring = '',
  $mesgarray = '',
  $style = 'ok',
  $keepembedded = 0 
)

Get formated messages to output (Used to show messages on html output).

This include also the translation of the message key.

Parameters
string$mesgstringMessage string or message key
string[]$mesgarray Array of message strings or message keys
string$styleStyle of message output ('ok' or 'error')
int$keepembeddedSet to 1 in error message must be kept embedded into its html place (this disable jnotify)
Returns
string Return html output
See also
dol_print_error
dol_htmloutput_errors
setEventMessages

Definition at line 6430 of file functions.lib.php.

Referenced by get_htmloutput_errors().

◆ get_localtax()

get_localtax (   $vatrate,
  $local,
  $thirdparty_buyer = "",
  $thirdparty_seller = "",
  $vatnpr = 0 
)

Return localtax rate for a particular vat, when selling a product with vat $vatrate, from a $thirdparty_buyer to a $thirdparty_seller Note: This function applies same rules than get_default_tva.

Parameters
float$vatrateVat rate. Can be '8.5' or '8.5 (VATCODEX)' for example
int$localLocal tax to search and return (1 or 2 return only tax rate 1 or tax rate 2)
Societe$thirdparty_buyerObject of buying third party
Societe$thirdparty_sellerObject of selling third party ($mysoc if not defined)
int$vatnprIf vat rate is NPR or not
Returns
mixed 0 if not found, localtax rate if found
See also
get_default_tva

Definition at line 4588 of file functions.lib.php.

◆ get_localtax_by_third()

get_localtax_by_third (   $local)

Get values of localtaxes (1 or 2) for company country for the common vat with the highest value.

Parameters
int$localLocalTax to get
Returns
number Values of localtax

Definition at line 4745 of file functions.lib.php.

◆ get_product_localtax_for_country()

get_product_localtax_for_country (   $idprod,
  $local,
  $thirdparty_seller 
)

Return localtax vat rate of a product in a particular selling country or default country vat if product is unknown.

Parameters
int$idprodId of product
int$local1 for localtax1, 2 for localtax 2
Societe$thirdparty_sellerThirdparty with a ->country_code defined (FR, US, IT, ...)
Returns
int <0 if KO, Vat rate if OK
See also
get_product_vat_for_country

Definition at line 4969 of file functions.lib.php.

◆ get_product_vat_for_country()

get_product_vat_for_country (   $idprod,
  $thirdparty_seller,
  $idprodfournprice = 0 
)

Return vat rate of a product in a particular selling country or default country vat if product is unknown Function called by get_default_tva.

Parameters
int$idprodId of product or 0 if not a predefined product
Societe$thirdparty_sellerThirdparty with a ->country_code defined (FR, US, IT, ...)
int$idprodfournpriceId product_fournisseur_price (for "supplier" proposal/order/invoice)
Returns
float|string Vat rate to use with format 5.0 or '5.0 (XXX)'
See also
get_product_localtax_for_country

Definition at line 4892 of file functions.lib.php.

◆ getAdvancedPreviewUrl()

getAdvancedPreviewUrl (   $modulepart,
  $relativepath,
  $alldata = 0,
  $param = '' 
)

Return URL we can use for advanced preview links.

Parameters
string$modulepartpropal, facture, facture_fourn, ...
string$relativepathRelative path of docs.
int$alldataReturn array with all components (1 is recommended, then use a simple a href link with the class, target and mime attribute added. 'documentpreview' css class is handled by jquery code into main.inc.php)
string$paramMore param on http links
Returns
string|array Output string with href link or array with all components of link

Definition at line 7640 of file functions.lib.php.

◆ getBrowserInfo()

getBrowserInfo (   $user_agent)

Return information about user browser.

Returns array with the following format: array( 'browsername' => Browser name (firefox|chrome|iceweasel|epiphany|safari|opera|ie|unknown) 'browserversion' => Browser version. Empty if unknown 'browseros' => Set with mobile OS (android|blackberry|ios|palm|symbian|webos|maemo|windows|unknown) 'layout' => (tablet|phone|classic) 'phone' => empty if not mobile, (android|blackberry|ios|palm|unknown) if mobile 'tablet' => true/false )

Parameters
string$user_agentContent of $_SERVER["HTTP_USER_AGENT"] variable
Returns
array Check function documentation

Definition at line 155 of file functions.lib.php.

◆ getCommonSubstitutionArray()

getCommonSubstitutionArray (   $outputlangs,
  $onlykey = 0,
  $exclude = null,
  $object = null 
)

Return array of possible common substitutions.

This includes several families like: 'system', 'mycompany', 'object', 'objectamount', 'date', 'user'

Parameters
Translate$outputlangsOutput language
int$onlykey1=Do not calculate some heavy values of keys (performance enhancement when we need only the keys), 2=Values are trunc and html sanitized (to use for help tooltip)
array$excludeArray of family keys we want to exclude. For example array('system', 'mycompany', 'object', 'objectamount', 'date', 'user', ...)
Object$objectObject for keys on object
Returns
array Array of substitutions
See also
setSubstitFromObject

Definition at line 5801 of file functions.lib.php.

◆ getDictvalue()

getDictvalue (   $tablename,
  $field,
  $id,
  $checkentity = false,
  $rowidfield = 'rowid' 
)

Return value from dictionary.

Parameters
string$tablenamename of dictionary
string$fieldthe value to return
int$idid of line
bool$checkentityadd filter on entity
string$rowidfieldname of the column rowid
Returns
string

Definition at line 7808 of file functions.lib.php.

◆ getDoliDBInstance()

getDoliDBInstance (   $type,
  $host,
  $user,
  $pass,
  $name,
  $port 
)

Return a DoliDB instance (database handler).

Parameters
string$typeType of database (mysql, pgsql...)
string$hostAddress of database server
string$userNom de l'utilisateur autorise
string$passMot de passe
string$nameNom de la database
int$portPort of database server
Returns
DoliDB A DoliDB instance

Definition at line 95 of file functions.lib.php.

Referenced by MailmanSpip\connectSpip().

◆ getEntity()

getEntity (   $element,
  $shared = 1,
  $currentobject = null 
)

Get list of entity id to use.

Parameters
string$elementCurrent element 'societe', 'socpeople', 'actioncomm', 'agenda', 'resource', 'product', 'productprice', 'stock', 'propal', 'supplier_proposal', 'facture', 'facture_fourn', 'payment_various', 'categorie', 'bank_account', 'bank_account', 'adherent', 'user', 'commande', 'commande_fournisseur', 'expedition', 'intervention', 'survey', 'contract', 'tax', 'expensereport', 'holiday', 'multicurrency', 'project', 'email_template', 'event', 'donation' 'c_paiement', 'c_payment_term', ...
int$shared0=Return id of current entity only, 1=Return id of current entity + shared entities (default)
object$currentobjectCurrent object if needed
Returns
mixed Entity id(s) to use

Definition at line 121 of file functions.lib.php.

◆ getImageFileNameForSize()

getImageFileNameForSize (   $file,
  $extName,
  $extImgTarget = '' 
)

Return the filename of file to get the thumbs.

Parameters
string$fileOriginal filename (full or relative path)
string$extNameExtension to differenciate thumb file name ('', '_small', '_mini')
string$extImgTargetForce image extension for thumbs. Use '' to keep same extension than original image (default).
Returns
string New file name (full or relative path, including the thumbs/)

Definition at line 7608 of file functions.lib.php.

◆ getLanguageCodeFromCountryCode()

getLanguageCodeFromCountryCode (   $countrycode)

Return default language from country code.

Parameters
string$countrycodeCountry code like 'US', 'FR', 'CA', ...
Returns
string Value of locale like 'en_US', 'fr_FR', ...

Definition at line 6837 of file functions.lib.php.

◆ getLocalTaxesFromRate()

getLocalTaxesFromRate (   $vatrate,
  $local,
  $buyer,
  $seller,
  $firstparamisid = 0 
)

Get type and rate of localtaxes for a particular vat rate/country of a thirdparty.

This does not take into account the seller setup if subject to vat or not, only country. TODO This function is ALSO called to retrieve type for building PDF. Such call of function must be removed. Instead this function must be called when adding a line to get the array of localtax and type, and then provide it to the function calcul_price_total.

Parameters
int | string$vatrateVAT ID or Rate+Code. Value can be value or the string with code into parenthesis or rowid if $firstparamisid is 1. Example: '8.5' or '8.5 (8.5NPR)' or 123.
int$localNumber of localtax (1 or 2, or 0 to return 1 & 2)
Societe$buyerCompany object
Societe$sellerCompany object
int$firstparamisid1 if first param is ID into table instead of Rate+code (use this if you can)
Returns
array array(localtax_type1(1-6/0 if not found), rate localtax1, localtax_type2, rate localtax2, accountancycodecust, accountancycodesupp)
See also
getTaxesFromId

Definition at line 4834 of file functions.lib.php.

◆ GETPOST()

GETPOST (   $paramname,
  $check = 'none',
  $method = 0,
  $filter = null,
  $options = null,
  $noreplace = 0 
)

Return value of a param into GET or POST supervariable.

Use the property $user->default_values[path]['creatform'] and/or $user->default_values[path]['filters'] and/or $user->default_values[path]['sortorder'] Note: The property $user->default_values is loaded by main.php when loading the user.

Parameters
string$paramnameName of parameter to found
string$checkType of check ''=no check (deprecated) 'none'=no check (only for param that should have very rich content) 'int'=check it's numeric (integer or float) 'intcomma'=check it's integer+comma ('1,2,3,4...') 'alpha'=check it's text and sign 'aZ'=check it's a-z only 'aZ09'=check it's simple alpha string (recommended for keys) 'array'=check it's array 'san_alpha'=Use filter_var with FILTER_SANITIZE_STRING (do not use this for free text string) 'nohtml', 'alphanohtml'=check there is no html content 'custom'= custom filter specify $filter and $options)
int$methodType of method (0 = get then post, 1 = only get, 2 = only post, 3 = post then get, 4 = post then get then cookie)
int$filterFilter to apply when $check is set to 'custom'. (See http://php.net/manual/en/filter.filters.php for d├ętails)
mixed$optionsOptions to pass to filter_var when $check is set to 'custom'
string$noreplaceForce disable of replacement of xxx strings.
Returns
string|string[] Value found (string or array), or '' if check fails

Return a prefix to use for this Dolibarr instance, for session/cookie names or email id. The prefix for session is unique in a web context only and is unique for instance and avoid conflict between multi-instances, even when having two instances with same root dir or two instances in same virtual servers. The prefix for email is unique if MAIL_PREFIX_FOR_EMAIL_ID is set to a value, otherwise value may be same than other instance.

Parameters
string$mode'' (prefix for session name) or 'email' (prefix for email id)
Returns
string A calculated prefix

Definition at line 276 of file functions.lib.php.

◆ GETPOSTISSET()

GETPOSTISSET (   $paramname)

Return true if we are in a context of submitting a parameter.

Parameters
string$paramnameName or parameter to test
Returns
boolean True if we have just submit a POST or GET request with the parameter provided (even if param is empty)

Definition at line 247 of file functions.lib.php.

◆ getStaticMember()

getStaticMember (   $class,
  $member 
)

Function to return value of a static property when class name is dynamically defined (not hard coded).

This is because $myclass::$myvar works from PHP 5.3.0+ only

Parameters
string$classClass name
string$memberName of property
Returns
mixed Return value of static property
Deprecated:
Dolibarr now requires 5.3.0+, use

$class::$property syntax

See also
https://php.net/manual/language.oop5.static.php

Definition at line 53 of file functions.lib.php.

References dol_syslog().

◆ getTaxesFromId()

getTaxesFromId (   $vatrate,
  $buyer = null,
  $seller = null,
  $firstparamisid = 1 
)

Get vat main information from Id.

You can call getLocalTaxesFromRate after to get other fields.

Parameters
int | string$vatrateVAT ID or Rate. Value can be value or the string with code into parenthesis or rowid if $firstparamisid is 1. Example: '8.5' or '8.5 (8.5NPR)' or 123.
Societe$buyerCompany object
Societe$sellerCompany object
int$firstparamisid1 if first param is id into table (use this if you can)
Returns
array array('rowid'=> , 'code'=> ...)
See also
getLocalTaxesFromRate

Definition at line 4778 of file functions.lib.php.

◆ getTitleFieldOfList()

getTitleFieldOfList (   $name,
  $thead = 0,
  $file = "",
  $field = "",
  $begin = "",
  $moreparam = "",
  $moreattrib = "",
  $sortfield = "",
  $sortorder = "",
  $prefix = "",
  $disablesortlink = 0,
  $tooltip = '' 
)

Get title line of an array.

Parameters
string$nameTranslation key of field
int$thead0=To use with standard table format, 1=To use inside <thead>

, 2=To use with

Parameters
string$fileUrl used when we click on sort picto
string$fieldField to use for new sorting. Empty if this field is not sortable. Example "t.abc" or "t.abc,t.def"
string$begin("" by defaut)
string$moreparamAdd more parameters on sort url links ("" by default)
string$moreattribAdd more attributes on th ("" by defaut, example: 'align="center"'). To add more css class, use param $prefix.
string$sortfieldCurrent field used to sort (Ex: 'd.datep,d.id')
string$sortorderCurrent sort order (Ex: 'asc,desc')
string$prefixPrefix for css. Use space after prefix to add your own CSS tag, for example 'mycss '.
string$disablesortlink1=Disable sort link
string$tooltipTooltip
Returns
string

Definition at line 3918 of file functions.lib.php.

◆ getUserRemoteIP()

getUserRemoteIP ( )

Return the IP of remote user.

Take HTTP_X_FORWARDED_FOR (defined when using proxy) Then HTTP_CLIENT_IP if defined (rare) Then REMOTE_ADDR (not way to be modified by user but may be wrong if using proxy)

Returns
string Ip of remote user.

Definition at line 2682 of file functions.lib.php.

◆ img_action()

img_action (   $titlealt,
  $numaction 
)

Show logo action.

Parameters
string$titlealtText 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.
string$numactionAction id or code to show
Returns
string Return an img tag

Definition at line 3253 of file functions.lib.php.

◆ img_allow()

img_allow (   $allow,
  $titlealt = 'default' 
)

Show tick logo if allowed.

Parameters
string$allowAllow
string$titlealtText 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.
Returns
string Return img tag

Definition at line 3577 of file functions.lib.php.

◆ img_credit_card()

img_credit_card (   $brand)

Return image of a credit card according to its brand name.

Parameters
string$brandBrand name of credit card
Returns
string Return img tag

Definition at line 3594 of file functions.lib.php.

◆ img_delete()

img_delete (   $titlealt = 'default',
  $other = 'class="pictodelete"' 
)

Show delete logo.

Parameters
string$titlealtText 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.
string$otherAdd more attributes on img
Returns
string Retourne tag img

Definition at line 3361 of file functions.lib.php.

◆ img_down()

img_down (   $titlealt = 'default',
  $selected = 0,
  $moreclass = '' 
)

Show down arrow logo.

Parameters
string$titlealtText 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.
int$selectedSelected
string$moreclassAdd more CSS classes
Returns
string Return img tag

Definition at line 3510 of file functions.lib.php.

◆ img_edit()

img_edit (   $titlealt = 'default',
  $float = 0,
  $other = 'class="pictoedit"' 
)

Show logo editer/modifier fiche.

Parameters
string$titlealtText 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.
integer$floatSi il faut y mettre le style "float: right"
string$otherAdd more attributes on img
Returns
string Return tag img

Definition at line 3326 of file functions.lib.php.

◆ img_edit_add()

img_edit_add (   $titlealt = 'default',
  $other = '' 
)

Show logo +.

Parameters
string$titlealtText 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.
string$otherAdd more attributes on img
Returns
string Return tag img

Definition at line 3294 of file functions.lib.php.

◆ img_edit_remove()

img_edit_remove (   $titlealt = 'default',
  $other = '' 
)

Show logo -.

Parameters
string$titlealtText 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.
string$otherAdd more attributes on img
Returns
string Return tag img

Definition at line 3309 of file functions.lib.php.

◆ img_error()

img_error (   $titlealt = 'default')

Show error logo.

Parameters
string$titlealtText 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.
Returns
string Return img tag

Definition at line 3459 of file functions.lib.php.

◆ img_help()

img_help (   $usehelpcursor = 1,
  $usealttitle = 1 
)

Show help logo with cursor "?".

Parameters
int$usehelpcursor1=Use help cursor, 2=Use click pointer cursor, 0=No specific cursor
int | string$usealttitleText to use as alt title
Returns
string Return tag img

Definition at line 3408 of file functions.lib.php.

◆ img_info()

img_info (   $titlealt = 'default')

Show info logo.

Parameters
string$titlealtText 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.
Returns
string Return img tag

Definition at line 3427 of file functions.lib.php.

◆ img_left()

img_left (   $titlealt = 'default',
  $selected = 0,
  $moreatt = '' 
)

Show left arrow logo.

Parameters
string$titlealtText 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.
int$selectedSelected
string$moreattAdd more attribute on img tag (For example 'style="float: right"')
Returns
string Return img tag

Definition at line 3544 of file functions.lib.php.

◆ img_mime()

img_mime (   $file,
  $titlealt = '',
  $morecss = '' 
)

Show MIME img of a file.

Parameters
string$fileFilename
string$titlealtText 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.
string$morecssMore css
Returns
string Return img tag

Definition at line 3615 of file functions.lib.php.

◆ img_next()

img_next (   $titlealt = 'default',
  $moreatt = '' 
)

Show next logo.

Parameters
string$titlealtText 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.
string$moreattAdd more attribute on img tag (For example 'style="float: right"')
Returns
string Return img tag

Definition at line 3475 of file functions.lib.php.

◆ img_object()

img_object (   $titlealt,
  $picto,
  $moreatt = '',
  $pictoisfullpath = false,
  $srconly = 0,
  $notitle = 0 
)

Show a picto called object_picto (generic function)

Parameters
string$titlealtText 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.
string$pictoName of image to show object_picto (example: user, group, action, bill, contract, propal, product, ...) For external modules use imagename to search into directory "img" of module.
string$moreattAdd more attribute on img tag (ie: class="datecallink")
int$pictoisfullpathIf 1, image path is a full path
int$srconlyReturn only content of the src attribute of img.
int$notitle1=Disable tag title. Use it if you add js tooltip, to avoid duplicate tooltip.
Returns
string Return img tag
See also
img_picto, img_picto_common

Definition at line 3188 of file functions.lib.php.

◆ img_pdf()

img_pdf (   $titlealt = 'default',
  $size = 3 
)

Show pdf logo.

Parameters
string$titlealtText 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.
int$sizeTaille de l'icone : 3 = 16x16px , 2 = 14x14px
Returns
string Retourne tag img

Definition at line 3278 of file functions.lib.php.

◆ img_phone()

img_phone (   $titlealt = 'default',
  $option = 0 
)

Show phone logo.

Use img_picto instead.

Parameters
string$titlealtText 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.
int$optionOption
Returns
string Return img tag
Deprecated:
See also
img_picto

Definition at line 3640 of file functions.lib.php.

◆ img_picto()

img_picto (   $titlealt,
  $picto,
  $moreatt = '',
  $pictoisfullpath = false,
  $srconly = 0,
  $notitle = 0,
  $alt = '',
  $morecss = '' 
)

Show picto whatever it's its name (generic function)

Parameters
string$titlealtText on title tag for tooltip. Not used if param notitle is set to 1.
string$pictoName of image file to show ('filenew', ...) If no extension provided, we use '.png'. Image must be stored into theme/xxx/img directory. Example: picto.png if picto.png is stored into htdocs/theme/mytheme/img Example: picto.png if picto.png is stored into htdocs/mymodule/img Example: /mydir/mysubdir/picto.png if picto.png is stored into htdocs/mydir/mysubdir (pictoisfullpath must be set to 1)
string$moreattAdd more attribute on img tag (For example 'style="float: right"')
boolean | int$pictoisfullpathIf true or 1, image path is a full path
int$srconlyReturn only content of the src attribute of img.
int$notitle1=Disable tag title. Use it if you add js tooltip, to avoid duplicate tooltip.
string$altForce alt for bind people
string$morecssAdd more class css on img tag (For example 'myclascss'). Work only if $moreatt is empty.
Returns
string Return img tag
See also
img_object, img_picto_common

Definition at line 2995 of file functions.lib.php.

◆ img_picto_common()

img_picto_common (   $titlealt,
  $picto,
  $moreatt = '',
  $pictoisfullpath = 0 
)

Show picto (generic function)

Parameters
string$titlealtText 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.
string$pictoName of image file to show (If no extension provided, we use '.png'). Image must be stored into htdocs/theme/common directory.
string$moreattAdd more attribute on img tag
int$pictoisfullpathIf 1, image path is a full path
Returns
string Return img tag
See also
img_object, img_picto

Definition at line 3224 of file functions.lib.php.

◆ img_previous()

img_previous (   $titlealt = 'default',
  $moreatt = '' 
)

Show previous logo.

Parameters
string$titlealtText 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.
string$moreattAdd more attribute on img tag (For example 'style="float: right"')
Returns
string Return img tag

Definition at line 3492 of file functions.lib.php.

◆ img_printer()

img_printer (   $titlealt = "default",
  $other = '' 
)

Show printer logo.

Parameters
string$titlealtText 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.
string$otherAdd more attributes on img
Returns
string Retourne tag img

Definition at line 3378 of file functions.lib.php.

◆ img_right()

img_right (   $titlealt = 'default',
  $selected = 0,
  $moreatt = '' 
)

Show right arrow logo.

Parameters
string$titlealtText 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.
int$selectedSelected
string$moreattAdd more attribute on img tag (For example 'style="float: right"')
Returns
string Return img tag

Definition at line 3561 of file functions.lib.php.

◆ img_search()

img_search (   $titlealt = 'default',
  $other = '' 
)

Show search logo.

Parameters
string$titlealtText 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.
string$otherAdd more attributes on img
Returns
string Retourne tag img

Definition at line 3661 of file functions.lib.php.

◆ img_searchclear()

img_searchclear (   $titlealt = 'default',
  $other = '' 
)

Show search logo.

Parameters
string$titlealtText 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.
string$otherAdd more attributes on img
Returns
string Retourne tag img

Definition at line 3682 of file functions.lib.php.

◆ img_split()

img_split (   $titlealt = 'default',
  $other = 'class="pictosplit"' 
)

Show split logo.

Parameters
string$titlealtText 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.
string$otherAdd more attributes on img
Returns
string Retourne tag img

Definition at line 3392 of file functions.lib.php.

◆ img_up()

img_up (   $titlealt = 'default',
  $selected = 0,
  $moreclass = '' 
)

Show top arrow logo.

Parameters
string$titlealtText 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.
int$selectedSelected
string$moreclassAdd more CSS classes
Returns
string Return img tag

Definition at line 3527 of file functions.lib.php.

◆ img_view()

img_view (   $titlealt = 'default',
  $float = 0,
  $other = '' 
)

Show logo view card.

Parameters
string$titlealtText 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.
integer$floatSi il faut y mettre le style "float: right"
string$otherAdd more attributes on img
Returns
string Return tag img

Definition at line 3343 of file functions.lib.php.

◆ img_warning()

img_warning (   $titlealt = 'default',
  $moreatt = '' 
)

Show warning logo.

Parameters
string$titlealtText 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.
string$moreattAdd more attribute on img tag (For example 'style="float: right"'). If 1, add float: right. Can't be "class" attribute.
Returns
string Return img tag

Definition at line 3443 of file functions.lib.php.

◆ img_weather()

img_weather (   $titlealt,
  $picto,
  $moreatt = '',
  $pictoisfullpath = 0 
)

Show weather picto.

Parameters
string$titlealtText 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.
string$pictoName of image file to show (If no extension provided, we use '.png'). Image must be stored into htdocs/theme/common directory.
string$moreattAdd more attribute on img tag
int$pictoisfullpathIf 1, image path is a full path
Returns
string Return img tag
See also
img_object, img_picto

Definition at line 3203 of file functions.lib.php.

◆ info_admin()

info_admin (   $text,
  $infoonimgalt = 0,
  $nodiv = 0,
  $admin = '1',
  $morecss = '' 
)

Show information for admin users or standard users.

Parameters
string$textText info
integer$infoonimgaltInfo is shown only on alt of star picto, otherwise it is show on output after the star picto
int$nodivNo div
string$admin'1'=Info for admin users. '0'=Info for standard users (change only the look), 'xxx'=Other
string$morecssMore CSS
Returns
string String with info text

Definition at line 3706 of file functions.lib.php.

◆ isOnlyOneLocalTax()

isOnlyOneLocalTax (   $local)

Return true if LocalTax (1 or 2) is unique.

Example: If localtax1 is 5 on line with highest common vat rate, return true Example: If localtax1 is 5:8:15 on line with highest common vat rate, return false

Parameters
int$localLocal tax to test (1 or 2)
Returns
boolean True if LocalTax have multiple values, False if not

Definition at line 4723 of file functions.lib.php.

◆ isValidEmail()

isValidEmail (   $address,
  $acceptsupervisorkey = 0 
)

Return true if email syntax is ok.

Parameters
string$addressemail (Ex: "toto@examle.com", "John Do <johndo@example.com>")
int$acceptsupervisorkeyIf 1, the special string 'SUPERVISOREMAIL' is also accepted as valid
Returns
boolean true if email syntax is OK, false if KO or empty string

Definition at line 2807 of file functions.lib.php.

Referenced by dolObfuscateEmail().

◆ isValidMXRecord()

isValidMXRecord (   $domain)

Return if the domain name has a valid MX record.

WARNING: This need function idn_to_ascii, checkdnsrr and getmxrr

Parameters
string$domainDomain name (Ex: "yahoo.com", "yhaoo.com", "dolibarr.fr")
Returns
int -1 if error (function not available), 0=Not valid, 1=Valid

Definition at line 2822 of file functions.lib.php.

◆ isValidPhone()

isValidPhone (   $phone)

Return true if phone number syntax is ok TODO Decide what to do with this.

Parameters
string$phonephone (Ex: "0601010101")
Returns
boolean true if phone syntax is OK, false if KO or empty string

Definition at line 2851 of file functions.lib.php.

◆ isVisibleToUserType()

isVisibleToUserType (   $type_user,
$menuentry,
$listofmodulesforexternal 
)

Function to test if an entry is enabled or not.

Parameters
string$type_user0=We test for internal user, 1=We test for external user
array$menuentryArray for feature entry to test
array$listofmodulesforexternalArray with list of modules allowed to external users
Returns
int 0=Hide, 1=Show, 2=Show gray

Definition at line 7882 of file functions.lib.php.

◆ load_fiche_titre()

load_fiche_titre (   $titre,
  $morehtmlright = '',
  $picto = 'title_generic.png',
  $pictoisfullpath = 0,
  $id = '',
  $morecssontable = '',
  $morehtmlcenter = '' 
)

Load a title with picto.

Parameters
string$titreTitle to show
string$morehtmlrightAdded message to show on right
string$pictoIcon to use before title (should be a 32x32 transparent png file)
int$pictoisfullpath1=Icon name is a full absolute url of image
string$idTo force an id on html objects
string$morecssontableMore css on table
string$morehtmlcenterAdded message to show on center
Returns
string
See also
print_barre_liste

Definition at line 4061 of file functions.lib.php.

◆ make_substitutions()

make_substitutions (   $text,
  $substitutionarray,
  $outputlangs = null 
)

Make substitution into a text string, replacing keys with vals from $substitutionarray (oldval=>newval), and texts like __(TranslationKey|langfile)__ and [ConstantKey] are also replaced.

Example of usage: $substitutionarray = getCommonSubstitutionArray($langs, 0, null, $thirdparty); complete_substitutions_array($substitutionarray, $langs, $thirdparty); $mesg = make_substitutions($mesg, $substitutionarray, $langs);

Parameters
string$textSource string in which we must do substitution
array$substitutionarrayArray with key->val to substitute. Example: array('MYKEY' => 'MyVal', ...)
Translate$outputlangsOutput language
Returns
string Output string after substitutions
See also
complete_substitutions_array, getCommonSubstitutionArray

Definition at line 6139 of file functions.lib.php.

◆ natural_search()

natural_search (   $fields,
  $value,
  $mode = 0,
  $nofirstand = 0 
)

Generate natural SQL search string for a criteria (this criteria can be tested on one or several fields)

Parameters
string|string[]$fields String or array of strings, filled with the name of all fields in the SQL query we must check (combined with a OR). Example: array("p.field1","p.field2")
string$valueThe value to look for. If param $mode is 0, can contains several keywords separated with a space or | like "keyword1 keyword2" = We want record field like keyword1 AND field like keyword2 or like "keyword1|keyword2" = We want record field like keyword1 OR field like keyword2 If param $mode is 1, can contains an operator <, > or = like "<10" or ">=100.5 < 1000" If param $mode is 2, can contains a list of int id separated by comma like "1,3,4" If param $mode is 3, can contains a list of string separated by comma like "a,b,c"
integer$mode0=value is list of keyword strings, 1=value is a numeric test (Example ">5.5 <10"), 2=value is a list of ID separated with comma (Example '1,3,4') 3=value is list of string separated with comma (Example 'text 1,text 2'), 4=value is a list of ID separated with comma (Example '1,3,4') for search into a multiselect string ('1,2')
integer$nofirstand1=Do not output the first 'AND'
Returns
string $res The statement to append to the SQL query

Definition at line 7425 of file functions.lib.php.

◆ picto_from_langcode()

picto_from_langcode (   $codelang,
  $moreatt = '' 
)

Return img flag of country for a language code or country code.

Parameters
string$codelangLanguage code (en_IN, fr_CA...) or Country code (IN, FR)
string$moreattAdd more attribute on img tag (For example 'style="float: right"')
Returns
string HTML img string with flag.

Definition at line 6802 of file functions.lib.php.

◆ picto_required()

picto_required ( )

Return picto saying a field is required.

Returns
string Chaine avec picto obligatoire

Definition at line 5366 of file functions.lib.php.

◆ price()

price (   $amount,
  $form = 0,
  $outlangs = '',
  $trunc = 1,
  $rounding = -1,
  $forcerounding = -1,
  $currency_code = '' 
)

Function to format a value into an amount for visual output Function used into PDF and HTML pages.

Parameters
float$amountAmount to format
integer$formType of format, HTML or not (not by default)
Translate$outlangsObject langs for output
int$trunc1=Truncate if there is more decimals than MAIN_MAX_DECIMALS_SHOWN (default), 0=Does not truncate. Deprecated because amount are rounded (to unit or total amount accurancy) before beeing inserted into database or after a computation, so this parameter should be useless.
int$roundingMinimum number of decimal to show. If 0, no change, if -1, we use min($conf->global->MAIN_MAX_DECIMALS_UNIT,$conf->global->MAIN_MAX_DECIMALS_TOT)
int$forceroundingForce the number of decimal to forcerounding decimal (-1=do not force)
string$currency_codeTo add currency symbol (''=add nothing, 'auto'=Use default currency, 'XXX'=add currency symbols for XXX currency)
Returns
string Chaine avec montant formate
See also
price2num() Revert function of price

Definition at line 4355 of file functions.lib.php.

◆ price2num()

price2num (   $amount,
  $rounding = '',
  $alreadysqlnb = 0 
)

Function that return a number with universal decimal format (decimal separator is '.

') from an amount typed by a user. Function to use on each input amount before any numeric test or database insert

Parameters
float$amountAmount to convert/clean
string$rounding''=No rounding 'MU'=Round to Max unit price (MAIN_MAX_DECIMALS_UNIT) 'MT'=Round to Max for totals with Tax (MAIN_MAX_DECIMALS_TOT) 'MS'=Round to Max for stock quantity (MAIN_MAX_DECIMALS_STOCK) Numeric = Nb of digits for rounding
int$alreadysqlnbPut 1 if you know that content is already universal format number
Returns
string Amount with universal numeric format (Example: '99.99999') or unchanged text if conversion fails. If amount is null or '', it returns ''.
See also
price Opposite function of price2num

Definition at line 4447 of file functions.lib.php.

Referenced by ChargeSociales\check(), AccountancyExport\exportFEC(), Facture\set_remise(), SupplierProposal\set_remise_absolue(), Propal\set_remise_absolue(), SupplierProposal\set_remise_percent(), and Propal\set_remise_percent().

◆ print_barre_liste()

print_barre_liste (   $titre,
  $page,
  $file,
  $options = '',
  $sortfield = '',
  $sortorder = '',
  $morehtmlcenter = '',
  $num = -1,
  $totalnboflines = '',
  $picto = 'title_generic.png',
  $pictoisfullpath = 0,
  $morehtmlright = '',
  $morecss = '',
  $limit = -1,
  $hideselectlimit = 0,
  $hidenavigation = 0 
)

Print a title with navigation controls for pagination.

Parameters
string$titreTitle to show (required)
int$pageNumero of page to show in navigation links (required)
string$fileUrl of page (required)
string$optionsMore parameters for links ('' by default, does not include sortfield neither sortorder). Value must be 'urlencoded' before calling function.
string$sortfieldField to sort on ('' by default)
string$sortorderOrder to sort ('' by default)
string$morehtmlcenterString in the middle ('' by default). We often find here string $massaction comming from $form->selectMassAction()
int$numNumber of records found by select with limit+1
int | string$totalnboflinesTotal number of records/lines for all pages (if known). Use a negative value of number to not show number. Use '' if unknown.
string$pictoIcon to use before title (should be a 32x32 transparent png file)
int$pictoisfullpath1=Icon name is a full absolute url of image
string$morehtmlrightMore html to show
string$morecssMore css to the table
int$limitMax number of lines (-1 = use default, 0 = no limit, > 0 = limit).
int$hideselectlimitForce to hide select limit
int$hidenavigationForce to hide all navigation tools
Returns
void

Definition at line 4109 of file functions.lib.php.

◆ print_date_range()

print_date_range (   $date_start,
  $date_end,
  $format = '',
  $outputlangs = '' 
)

Format output for start and end date.

Parameters
int$date_startStart date
int$date_endEnd date
string$formatOutput format
Translate$outputlangsOutput language
Returns
void

Definition at line 6258 of file functions.lib.php.

◆ print_fiche_titre()

print_fiche_titre (   $title,
  $mesg = '',
  $picto = 'title_generic.png',
  $pictoisfullpath = 0,
  $id = '' 
)

Show a title with picto.

Parameters
string$titleTitle to show
string$mesgAdded message to show on right
string$pictoIcon to use before title (should be a 32x32 transparent png file)
int$pictoisfullpath1=Icon name is a full absolute url of image
int$idTo force an id on html objects
Returns
void
Deprecated:
Use print load_fiche_titre instead

Definition at line 4043 of file functions.lib.php.

◆ print_fleche_navigation()

print_fleche_navigation (   $page,
  $file,
  $options = '',
  $nextpage = 0,
  $betweenarrows = '',
  $afterarrows = '',
  $limit = -1,
  $totalnboflines = 0,
  $hideselectlimit = 0 
)

Function to show navigation arrows into lists.

Parameters
int$pageNumber of page
string$filePage URL (in most cases provided with $_SERVER["PHP_SELF"])
string$optionsOther url paramaters to propagate ("" by default, may include sortfield and sortorder)
integer$nextpageDo we show a next page button
string$betweenarrowsHTML content to show between arrows. MUST contains ' ' tags or ' '.
string$afterarrowsHTML content to show after arrows. Must NOT contains ' ' tags.
int$limitMax nb of record to show (-1 = no combo with limit, 0 = no limit, > 0 = limit)
int$totalnboflinesTotal number of records/lines for all pages (if known)
int$hideselectlimitForce to hide select limit
Returns
void

Definition at line 4222 of file functions.lib.php.

◆ print_liste_field_titre()

print_liste_field_titre (   $name,
  $file = "",
  $field = "",
  $begin = "",
  $moreparam = "",
  $moreattrib = "",
  $sortfield = "",
  $sortorder = "",
  $prefix = "",
  $tooltip = "" 
)

Show title line of an array.

Parameters
string$nameLabel of field
string$fileUrl used when we click on sort picto
string$fieldField to use for new sorting
string$begin("" by defaut)
string$moreparamAdd more parameters on sort url links ("" by default)
string$moreattribOptions of attribute td ("" by defaut, example: 'align="center"')
string$sortfieldCurrent field used to sort
string$sortorderCurrent sort order
string$prefixPrefix for css. Use space after prefix to add your own CSS tag.
string$tooltipTooltip
Returns
void

Definition at line 3896 of file functions.lib.php.

◆ print_titre()

print_titre (   $title)

Show a title.

Parameters
string$titleTitle to show
Returns
string Title to show
Deprecated:
Use load_fiche_titre instead
See also
load_fiche_titre

Definition at line 4025 of file functions.lib.php.

◆ printCommonFooter()

printCommonFooter (   $zone = 'private')

Print common footer : conf->global->MAIN_HTML_FOOTER js for switch of menu hider js for conf->global->MAIN_GOOGLE_AN_ID js for conf->global->MAIN_SHOW_TUNING_INFO or $_SERVER["MAIN_SHOW_TUNING_INFO"] js for conf->logbuffer.

Parameters
string$zone'private' (for private pages) or 'public' (for public pages)
Returns
void

Definition at line 7164 of file functions.lib.php.

Referenced by llxFooterSurvey(), and llxFooterVierge().

◆ roundUpToNextMultiple()

roundUpToNextMultiple (   $n,
  $x = 5 
)

Round to next multiple.

Parameters
double$nNumber to round up
integer$xMultiple. For example 60 to round up to nearest exact minute for a date with seconds.
Returns
integer Value rounded.

Definition at line 7914 of file functions.lib.php.

◆ setEventMessage()

setEventMessage (   $mesgs,
  $style = 'mesgs' 
)

Set event message in dol_events session object.

Will be output by calling dol_htmloutput_events. Note: Calling dol_htmloutput_events is done into pages by standard llxFooter() function. Note: Prefer to use setEventMessages instead.

Parameters
mixed$mesgsMessage string or array
string$styleWhich style to use ('mesgs' by default, 'warnings', 'errors')
Returns
void
See also
dol_htmloutput_events

Definition at line 6342 of file functions.lib.php.

◆ setEventMessages()

setEventMessages (   $mesg,
  $mesgs,
  $style = 'mesgs' 
)

Set event messages in dol_events session object.

Will be output by calling dol_htmloutput_events. Note: Calling dol_htmloutput_events is done into pages by standard llxFooter() function.

Parameters
string$mesgMessage string
array$mesgsMessage array
string$styleWhich style to use ('mesgs' by default, 'warnings', 'errors')
Returns
void
See also
dol_htmloutput_events

Definition at line 6368 of file functions.lib.php.

◆ showDimensionInBestUnit()

showDimensionInBestUnit (   $dimension,
  $unit,
  $type,
  $outputlangs,
  $round = -1,
  $forceunitoutput = 'no' 
)

Output a dimension with best unit.

Parameters
float$dimensionDimension
int$unitUnit of dimension (Example: 0=kg, -3=g, 98=ounce, 99=pound, ...)
string$type'weight', 'volume', ...
Translate$outputlangsTranslate language object
int$round-1 = non rounding, x = number of decimal
string$forceunitoutput'no' or numeric (-3, -6, ...) compared to $unit (In most case, this value is value defined into $conf->global->MAIN_WEIGHT_DEFAULT_UNIT)
Returns
string String to show dimensions

Definition at line 4533 of file functions.lib.php.

◆ showDirectDownloadLink()

showDirectDownloadLink (   $object)

Return string with full Url.

The file qualified is the one defined by relative path in $object->last_main_doc

Parameters
Object$objectObject
Returns
string Url string

Definition at line 7584 of file functions.lib.php.

◆ utf8_check()

utf8_check (   $str)

Check if a string is in UTF8.

Parameters
string$strString to check
Returns
boolean True if string is UTF8 or ISO compatible with UTF8, False if not (ISO with special char or Binary)

Definition at line 6636 of file functions.lib.php.

References dol_strlen().

Referenced by dol_string_unaccent().

◆ vatrate()

vatrate (   $rate,
  $addpercent = false,
  $info_bits = 0,
  $usestarfornpr = 0 
)

Return a string with VAT rate label formated for view output Used into pdf and HTML pages.

Parameters
string$rateRate value to format ('19.6', '19,6', '19.6', '19,6', '19.6 (CODEX)', ...)
boolean$addpercentAdd a percent % sign in output
int$info_bitsMiscellaneous information on vat (0=Default, 1=French NPR vat)
int$usestarfornpr-1=Never show, 0 or 1=Use '*' for NPR vat rates
Returns
string String with formated amounts ('19,6' or '19,6' or '8.5% (NPR)' or '8.5% *' or '19,6 (CODEX)')

Definition at line 4307 of file functions.lib.php.

◆ verifCond()

verifCond (   $strRights)

Verify if condition in string is ok or not.

Parameters
string$strRightsString with condition to check
Returns
boolean True or False. Return True if strRights is ''

Definition at line 6734 of file functions.lib.php.

◆ yn()

yn (   $yesno,
  $case = 1,
  $color = 0 
)

Return yes or no in current language.

Parameters
string$yesnoValue to test (1, 'yes', 'true' or 0, 'no', 'false')
integer$case1=Yes/No, 0=yes/no, 2=Disabled checkbox, 3=Disabled checkbox + Yes/No
int$color0=texte only, 1=Text is formated with a color font style ('ok' or 'error'), 2=Text is formated with 'ok' color.
Returns
string HTML string

Definition at line 5209 of file functions.lib.php.