mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-02-20 13:46:52 +01:00
Uniformize code
This commit is contained in:
parent
eb37c72513
commit
b15535c1f1
|
|
@ -1615,9 +1615,11 @@ class Form
|
|||
* @param int $hidelabel Hide label (0=no, 1=yes, 2=show search icon (before) and placeholder, 3 search icon after)
|
||||
* @param array $ajaxoptions Options for ajax_autocompleter
|
||||
* @param int $socid Thirdparty Id (to get also price dedicated to this customer)
|
||||
* @param string $showempty '' to not show empty line. Translation key to show an empty line. '1' show empty line with no text.
|
||||
* @param int $forcecombo Force to use combo box
|
||||
* @return void
|
||||
*/
|
||||
function select_produits($selected='', $htmlname='productid', $filtertype='', $limit=20, $price_level=0, $status=1, $finished=2, $selected_input_value='', $hidelabel=0, $ajaxoptions=array(), $socid=0)
|
||||
function select_produits($selected='', $htmlname='productid', $filtertype='', $limit=20, $price_level=0, $status=1, $finished=2, $selected_input_value='', $hidelabel=0, $ajaxoptions=array(), $socid=0, $showempty='1', $forcecombo=0)
|
||||
{
|
||||
global $langs,$conf;
|
||||
|
||||
|
|
@ -1650,14 +1652,14 @@ class Form
|
|||
print img_picto($langs->trans("Search"), 'search');
|
||||
}
|
||||
}
|
||||
print '<input type="text" size="20" name="search_'.$htmlname.'" id="search_'.$htmlname.'" value="'.$selected_input_value.'"'.$placeholder.' '.(!empty($conf->global->PRODUCT_SEARCH_AUTOFOCUS) ? 'autofocus' : '').' />';
|
||||
print '<input type="text" class="minwidth100" name="search_'.$htmlname.'" id="search_'.$htmlname.'" value="'.$selected_input_value.'"'.$placeholder.' '.(!empty($conf->global->PRODUCT_SEARCH_AUTOFOCUS) ? 'autofocus' : '').' />';
|
||||
if ($hidelabel == 3) {
|
||||
print img_picto($langs->trans("Search"), 'search');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print $this->select_produits_list($selected,$htmlname,$filtertype,$limit,$price_level,'',$status,$finished,0,$socid);
|
||||
print $this->select_produits_list($selected,$htmlname,$filtertype,$limit,$price_level,'',$status,$finished,0,$socid,$showempty,$forcecombo);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1674,9 +1676,11 @@ class Form
|
|||
* @param int $finished Filter on finished field: 2=No filter
|
||||
* @param int $outputmode 0=HTML select string, 1=Array
|
||||
* @param int $socid Thirdparty Id (to get also price dedicated to this customer)
|
||||
* @param string $showempty '' to not show empty line. Translation key to show an empty line. '1' show empty line with no text.
|
||||
* @param int $forcecombo Force to use combo box
|
||||
* @return array Array of keys for json
|
||||
*/
|
||||
function select_produits_list($selected='',$htmlname='productid',$filtertype='',$limit=20,$price_level=0,$filterkey='',$status=1,$finished=2,$outputmode=0,$socid=0)
|
||||
function select_produits_list($selected='',$htmlname='productid',$filtertype='',$limit=20,$price_level=0,$filterkey='',$status=1,$finished=2,$outputmode=0,$socid=0,$showempty='1',$forcecombo=0)
|
||||
{
|
||||
global $langs,$conf,$user,$db;
|
||||
|
||||
|
|
@ -1767,8 +1771,27 @@ class Form
|
|||
require_once DOL_DOCUMENT_ROOT.'/product/dynamic_price/class/price_parser.class.php';
|
||||
$num = $this->db->num_rows($result);
|
||||
|
||||
$out.='<select class="flat" name="'.$htmlname.'" id="'.$htmlname.'">';
|
||||
$out.='<option value="0" selected> </option>';
|
||||
$events=null;
|
||||
|
||||
if ($conf->use_javascript_ajax && ! $forcecombo)
|
||||
{
|
||||
include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php';
|
||||
$comboenhancement =ajax_combobox($htmlname, $events, $conf->global->PRODUIT_USE_SEARCH_TO_SELECT);
|
||||
$out.= $comboenhancement;
|
||||
$nodatarole=($comboenhancement?' data-role="none"':'');
|
||||
}
|
||||
|
||||
$out.='<select class="flat" name="'.$htmlname.'" id="'.$htmlname.'"'.$nodatarole.'>';
|
||||
|
||||
$textifempty='';
|
||||
// Do not use textifempty = ' ' or ' ' here, or search on key will search on ' key'.
|
||||
//if (! empty($conf->use_javascript_ajax) || $forcecombo) $textifempty='';
|
||||
if (! empty($conf->global->PRODUIT_USE_SEARCH_TO_SELECT))
|
||||
{
|
||||
if ($showempty && ! is_numeric($showempty)) $textifempty=$langs->trans($showempty);
|
||||
else $textifempty.=$langs->trans("All");
|
||||
}
|
||||
if ($showempty) $out.='<option value="0" selected>'.$textifempty.'</option>';
|
||||
|
||||
$i = 0;
|
||||
while ($num && $i < $num)
|
||||
|
|
|
|||
|
|
@ -58,8 +58,8 @@ ErrorCodeCantContainZero=Code can't contain value 0
|
|||
DisableJavascript=Disable JavaScript and Ajax functions (Recommended for blind person or text browsers)
|
||||
UseSearchToSelectCompanyTooltip=Also if you have a large number of third parties (> 100 000), you can increase speed by setting constant COMPANY_DONOTSEARCH_ANYWHERE to 1 in Setup->Other. Search will then be limited to start of string.
|
||||
UseSearchToSelectContactTooltip=Also if you have a large number of third parties (> 100 000), you can increase speed by setting constant CONTACT_DONOTSEARCH_ANYWHERE to 1 in Setup->Other. Search will then be limited to start of string.
|
||||
DelaiedFullListToSelectCompany=Wait you press a key before loading content of thirdparties combo list (This may increase performance if you have a large number of thirdparties)
|
||||
DelaiedFullListToSelectContact=Wait you press a key before loading content of contact combo list (This may increase performance if you have a large number of contact)
|
||||
DelaiedFullListToSelectCompany=Wait you press a key before loading content of thirdparties combo list (This may increase performance if you have a large number of thirdparties, but it is less convenient)
|
||||
DelaiedFullListToSelectContact=Wait you press a key before loading content of contact combo list (This may increase performance if you have a large number of contact, but it is less convenient)
|
||||
NumberOfKeyToSearch=Nbr of characters to trigger search: %s
|
||||
NotAvailableWhenAjaxDisabled=Not available when Ajax disabled
|
||||
AllowToSelectProjectFromOtherCompany=On document of a third party, can choose a project linked to another third party
|
||||
|
|
@ -1320,7 +1320,7 @@ ViewProductDescInFormAbility=Visualization of product descriptions in the forms
|
|||
MergePropalProductCard=Activate in product/service Attached Files tab an option to merge product PDF document to proposal PDF azur if product/service is in the proposal
|
||||
ViewProductDescInThirdpartyLanguageAbility=Visualization of products descriptions in the third party language
|
||||
UseSearchToSelectProductTooltip=Also if you have a large number of product (> 100 000), you can increase speed by setting constant PRODUCT_DONOTSEARCH_ANYWHERE to 1 in Setup->Other. Search will then be limited to start of string.
|
||||
UseSearchToSelectProduct=Use a search form to choose a product (rather than a drop-down list).
|
||||
UseSearchToSelectProduct=Wait you press a key before loading content of product combo list (This may increase performance if you have a large number of products, but it is less convenient)
|
||||
SetDefaultBarcodeTypeProducts=Default barcode type to use for products
|
||||
SetDefaultBarcodeTypeThirdParties=Default barcode type to use for third parties
|
||||
UseUnits=Define a unit of measure for Quantity during order, proposal or invoice lines edition
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ dol_fiche_head($head, 'agentMargins', $titre, 0, $picto);
|
|||
print '<table class="border" width="100%">';
|
||||
|
||||
print '<tr><td class="titlefield">'.$langs->trans('SalesRepresentative').'</td>';
|
||||
print '<td colspan="4">';
|
||||
print '<td class="maxwidthonsmartphone" colspan="4">';
|
||||
print $form->select_dolusers($agentid, 'agentid', 1, '', $user->rights->margins->read->all ? 0 : 1, '', '', 0, 0, 0, '', 0, '', 'maxwidth300');
|
||||
print '</td></tr>';
|
||||
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ if ($socid > 0) {
|
|||
if ($soc->client)
|
||||
{
|
||||
print '<tr><td class="titlefield">'.$langs->trans('ThirdPartyName').'</td>';
|
||||
print '<td colspan="4">';
|
||||
print '<td class="maxwidthonsmartphone" colspan="4">';
|
||||
print $form->select_company($socid, 'socid', 'client=1 OR client=3', 1, 0, 0);
|
||||
//$form->form_thirdparty($_SERVER['PHP_SELF'].'?socid='.$socid,$socid,'socid','client=1 OR client=3',1,0,1);
|
||||
print '</td></tr>';
|
||||
|
|
@ -102,7 +102,7 @@ if ($socid > 0) {
|
|||
}
|
||||
else {
|
||||
print '<tr><td class="titlefield">'.$langs->trans('ThirdPartyName').'</td>';
|
||||
print '<td colspan="4">';
|
||||
print '<td class="maxwidthonsmartphone" colspan="4">';
|
||||
print $form->select_company(null, 'socid', 'client=1 OR client=3', 1, 0, 0);
|
||||
//$form->form_thirdparty($_SERVER['PHP_SELF'],null,'socid','client=1 OR client=3',1,0,1);
|
||||
print '</td></tr>';
|
||||
|
|
|
|||
|
|
@ -105,20 +105,17 @@ print '<table class="border" width="100%">';
|
|||
if ($id > 0) {
|
||||
|
||||
print '<tr><td class="titlefield">'.$langs->trans('ChooseProduct/Service').'</td>';
|
||||
print '<td colspan="4">';
|
||||
print $form->select_produits($id,'id','',20,0,1,2,'',1);
|
||||
print '<td class="maxwidthonsmartpone" colspan="4">';
|
||||
print $form->select_produits($id,'id','',20,0,1,2,'',1, array(), 0, 'All');
|
||||
print '</td></tr>';
|
||||
|
||||
print '<tr><td>'.$langs->trans('AllProducts').'</td>';
|
||||
print '<td colspan="4"><input type="checkbox" id="all" /></td></tr>';
|
||||
|
||||
if (! $sortorder) $sortorder="DESC";
|
||||
if (! $sortfield) $sortfield="f.datef";
|
||||
}
|
||||
else {
|
||||
print '<tr><td class="titlefield">'.$langs->trans('ChooseProduct/Service').'</td>';
|
||||
print '<td colspan="4">';
|
||||
print $form->select_produits('','id','',20,0,1,2,'',1);
|
||||
print '<td class="maxwidthonsmartphone" colspan="4">';
|
||||
print $form->select_produits('','id','',20,0,1,2,'',1, array(), 0, 'All');
|
||||
print '</td></tr>';
|
||||
|
||||
}
|
||||
|
|
@ -339,10 +336,6 @@ print '
|
|||
<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
|
||||
$("#all").change(function() {
|
||||
$("#id").val(\'\').change();
|
||||
});
|
||||
|
||||
$("#id").change(function() {
|
||||
$("div.fiche form").submit();
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user