dolibarr  7.0.0-beta
Functions
ajax.lib.php File Reference

Page called by Ajax request for produts. More...

Go to the source code of this file.

Functions

 ajax_autocompleter ($selected, $htmlname, $url, $urloption='', $minLength=2, $autoselect=0, $ajaxoptions=array())
 Generic function that return javascript to add to a page to transform a common input field into an autocomplete field by calling an Ajax page (ex: /societe/ajaxcompanies.php). More...
 
 ajax_multiautocompleter ($htmlname, $fields, $url, $option='', $minLength=2, $autoselect=0)
 Generic function that return javascript to add to a page to transform a common input field into an autocomplete field by calling an Ajax page (ex: core/ajax/ziptown.php). More...
 
 ajax_dialog ($title, $message, $w=350, $h=150)
 Show an ajax dialog. More...
 
 ajax_autoselect ($htmlname, $addlink='')
 Make content of an input box selected when we click into input field. More...
 
 ajax_combobox ($htmlname, $events=array(), $minLengthToAutocomplete=0, $forcefocus=0, $widthTypeOfAutocomplete='resolve')
 Convert a html select field into an ajax combobox. More...
 
 ajax_constantonoff ($code, $input=array(), $entity=null, $revertonoff=0, $strict=0)
 On/off button for constant. More...
 
 ajax_object_onoff ($object, $code, $field, $text_on, $text_off, $input=array())
 On/off button for object. More...
 

Detailed Description

Page called by Ajax request for produts.

Definition in file ajax.lib.php.

Function Documentation

ajax_autocompleter (   $selected,
  $htmlname,
  $url,
  $urloption = '',
  $minLength = 2,
  $autoselect = 0,
  $ajaxoptions = array() 
)

Generic function that return javascript to add to a page to transform a common input field into an autocomplete field by calling an Ajax page (ex: /societe/ajaxcompanies.php).

The HTML field must be an input text with id=search_$htmlname. This use the jQuery "autocomplete" function. If we want to use the select2, we must also convert the input into select on funcntions that call this method.

Parameters
string$selectedPreselected value
string$htmlnameHTML name of input field
string$urlUrl for request: /path/page.php. Must return a json array ('key'=>id, 'value'=>String shown into input field once selected, 'label'=>String shown into combo list)
string$urloptionMore parameters on URL request
int$minLengthMinimum number of chars to trigger that Ajax search
int$autoselectAutomatic selection if just one value
array$ajaxoptionsMultiple options array Ex: array('update'=>array('field1','field2'...)) will reset field1 and field2 once select done Ex: array('disabled'=> ) Ex: array('show'=> ) Ex: array('update_textarea'=> ) Ex: array('option_disabled'=> id to disable and warning to show if we select a disabled value (this is possible when using autocomplete ajax)
Returns
string Script

Definition at line 46 of file ajax.lib.php.

Referenced by Form\select_company(), Form\select_produits(), Form\select_produits_fournisseurs(), FormProjets\select_projects(), and FormCompany\selectCompaniesForNewContact().

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

Definition at line 367 of file ajax.lib.php.

Referenced by showDirectDownloadLink(), showPaypalPaymentUrl(), and showStripePaymentUrl().

ajax_combobox (   $htmlname,
  $events = array(),
  $minLengthToAutocomplete = 0,
  $forcefocus = 0,
  $widthTypeOfAutocomplete = 'resolve' 
)

Convert a html select field into an ajax combobox.

Use ajax_combobox() only for small combo list! If not, use instead ajax_autocompleter(). TODO: It is used when COMPANY_USE_SEARCH_TO_SELECT and CONTACT_USE_SEARCH_TO_SELECT are set by html.formcompany.class.php. Should use ajax_autocompleter instead like done by html.form.class.php for select_produits.

Parameters
string$htmlnameName of html select field ('myid' or '.myclass')
array$eventsMore events option. Example: array(array('method'=>'getContacts', 'url'=>dol_buildpath('/core/ajax/contacts.php',1), 'htmlname'=>'contactid', 'params'=>array('add-customer-contact'=>'disabled')))
int$minLengthToAutocompleteMinimum length of input string to start autocomplete
int$forcefocusForce focus on field
string$widthTypeOfAutocomplete'resolve' or 'off'
Returns
string Return html string to convert a select field into a combo, or '' if feature has been disabled for some reason.
See also
selectArrayAjax of html.form.class

Definition at line 392 of file ajax.lib.php.

References select2arrayoflanguage.

Referenced by FormOther\getBoxesArea(), printBookmarksList(), BookKeeping\select_account(), FormAccounting\select_accounting_category(), FormBarCode\select_barcode_type(), FormOther\select_categories(), FormContract\select_contract(), Form\select_country(), Form\select_dolgroups(), Form\select_dolusers(), Form\select_incoterms(), FormCompany\select_juridicalstatus(), FormAdmin\select_language(), Form\select_produits_fournisseurs_list(), Form\select_produits_list(), FormProjets\select_projects_list(), FormResource\select_resource_list(), FormOther\select_salesrepresentatives(), FormCompany\select_state(), Form\select_thirdparty_list(), FormSocialContrib\select_type_socialcontrib(), FormEcm\selectAllSections(), Form\selectcontacts(), Form\selectCurrency(), FormProduct\selectLotStock(), Form\selectMultiCurrency(), FormOther\selectProjectTasks(), FormProjets\selectTasks(), FormProduct\selectWarehouses(), FormFile\showdocuments(), and ExtraFields\showInputField().

ajax_constantonoff (   $code,
  $input = array(),
  $entity = null,
  $revertonoff = 0,
  $strict = 0 
)

On/off button for constant.

Parameters
string$codeName of constant
array$inputArray of type->list of CSS element to switch. Example: array('disabled'=>array(0=>'cssid'))
int$entityEntity to set
int$revertonoffRevert on/off
bool$strictUse only "disabled" with delConstant and "enabled" with setConstant
Returns
string

Definition at line 500 of file ajax.lib.php.

References img_picto(), and print.

ajax_dialog (   $title,
  $message,
  $w = 350,
  $h = 150 
)

Show an ajax dialog.

Parameters
string$titleTitle of dialog box
string$messageMessage of dialog box
int$wWidth of dialog box
int$hheight of dialog box
Returns
void

Definition at line 331 of file ajax.lib.php.

References $title, dol_string_nohtmltag(), and dol_textishtml().

ajax_multiautocompleter (   $htmlname,
  $fields,
  $url,
  $option = '',
  $minLength = 2,
  $autoselect = 0 
)

Generic function that return javascript to add to a page to transform a common input field into an autocomplete field by calling an Ajax page (ex: core/ajax/ziptown.php).

The Ajax page can also returns several values (json format) to fill several input fields. The HTML field must be an input text with id=$htmlname. This use the jQuery "autocomplete" function.

Parameters
string$htmlnameHTML name of input field
string$fieldsOther fields to autocomplete
string$urlURL for ajax request : /chemin/fichier.php
string$optionMore parameters on URL request
int$minLengthMinimum number of chars to trigger that Ajax search
int$autoselectAutomatic selection if just one value
Returns
string Script

Definition at line 224 of file ajax.lib.php.

Referenced by FormCompany\select_ziptown().

ajax_object_onoff (   $object,
  $code,
  $field,
  $text_on,
  $text_off,
  $input = array() 
)

On/off button for object.

Parameters
int$objectId product to set
string$codeName of constant : status or status_buy for product by example
string$fieldName of database field : tosell or tobuy for product by example
string$text_onText if on
string$text_offText if off
array$inputArray of type->list of CSS element to switch. Example: array('disabled'=>array(0=>'cssid'))
Returns
void

Definition at line 568 of file ajax.lib.php.

Referenced by dol_banner_tab().