Start to work on using the jquery date selector.
This commit is contained in:
parent
a8d9dff506
commit
ba221650cf
@ -4727,6 +4727,7 @@ class Form
|
||||
$smin = !isset($conf->global->MAIN_DEFAULT_DATE_MIN) ? '' : $conf->global->MAIN_DEFAULT_DATE_MIN;
|
||||
}
|
||||
|
||||
// You can set MAIN_POPUP_CALENDAR to 'eldy' or 'jquery'
|
||||
$usecalendar='combo';
|
||||
if (! empty($conf->use_javascript_ajax) && (empty($conf->global->MAIN_POPUP_CALENDAR) || $conf->global->MAIN_POPUP_CALENDAR != "none")) $usecalendar=empty($conf->global->MAIN_POPUP_CALENDAR)?'eldy':$conf->global->MAIN_POPUP_CALENDAR;
|
||||
if ($conf->browser->phone) $usecalendar='combo';
|
||||
@ -4758,7 +4759,8 @@ class Form
|
||||
{
|
||||
$retstring.='<button id="'.$prefix.'Button" type="button" class="dpInvisibleButtons"';
|
||||
$base=DOL_URL_ROOT.'/core/';
|
||||
$retstring.=' onClick="showDP(\''.$base.'\',\''.$prefix.'\',\''.$langs->trans("FormatDateShortJavaInput").'\',\''.$langs->defaultlang.'\');">'.img_object($langs->trans("SelectDate"),'calendarday','class="datecallink"').'</button>';
|
||||
$retstring.=' onClick="showDP(\''.$base.'\',\''.$prefix.'\',\''.$langs->trans("FormatDateShortJavaInput").'\',\''.$langs->defaultlang.'\');"';
|
||||
$retstring.='>'.img_object($langs->trans("SelectDate"),'calendarday','class="datecallink"').'</button>';
|
||||
}
|
||||
else $retstring.='<button id="'.$prefix.'Button" type="button" class="dpInvisibleButtons">'.img_object($langs->trans("Disabled"),'calendarday','class="datecallink"').'</button>';
|
||||
|
||||
@ -4766,6 +4768,37 @@ class Form
|
||||
$retstring.='<input type="hidden" id="'.$prefix.'month" name="'.$prefix.'month" value="'.$smonth.'">'."\n";
|
||||
$retstring.='<input type="hidden" id="'.$prefix.'year" name="'.$prefix.'year" value="'.$syear.'">'."\n";
|
||||
}
|
||||
elseif ($usecalendar == 'jquery')
|
||||
{
|
||||
if (! $disabled)
|
||||
{
|
||||
print "<script type='text/javascript'>";
|
||||
print "$(function(){ $('#".$prefix."').datepicker({ dateFormat: '".$langs->trans("FormatDateShortJQueryInput")."', autoclose: true, todayHighlight: true }) });";
|
||||
print "</script>";
|
||||
}
|
||||
|
||||
// Zone de saisie manuelle de la date
|
||||
$retstring.='<input id="'.$prefix.'" name="'.$prefix.'" type="text" class="maxwidth75" maxlength="11" value="'.$formated_date.'"';
|
||||
$retstring.=($disabled?' disabled':'');
|
||||
$retstring.=' onChange="dpChangeDay(\''.$prefix.'\',\''.$langs->trans("FormatDateShortJavaInput").'\'); "'; // FormatDateShortInput for dol_print_date / FormatDateShortJavaInput that is same for javascript
|
||||
$retstring.='>';
|
||||
|
||||
// Icone calendrier
|
||||
if (! $disabled)
|
||||
{
|
||||
//$retstring.='<button id="'.$prefix.'Button" type="button" class="dpInvisibleButtons"';
|
||||
//$base=DOL_URL_ROOT.'/core/';
|
||||
//$retstring.=' onClick="showDP(\''.$base.'\',\''.$prefix.'\',\''.$langs->trans("FormatDateShortJavaInput").'\',\''.$langs->defaultlang.'\');"';
|
||||
//$retstring.='>';
|
||||
$retstring.=img_object($langs->trans("SelectDate"),'calendarday','class="datecallink"');
|
||||
//$retstring.='</button>';
|
||||
}
|
||||
else $retstring.='<button id="'.$prefix.'Button" type="button" class="dpInvisibleButtons">'.img_object($langs->trans("Disabled"),'calendarday','class="datecallink"').'</button>';
|
||||
|
||||
$retstring.='<input type="hidden" id="'.$prefix.'day" name="'.$prefix.'day" value="'.$sday.'">'."\n";
|
||||
$retstring.='<input type="hidden" id="'.$prefix.'month" name="'.$prefix.'month" value="'.$smonth.'">'."\n";
|
||||
$retstring.='<input type="hidden" id="'.$prefix.'year" name="'.$prefix.'year" value="'.$syear.'">'."\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
print "Bad value of MAIN_POPUP_CALENDAR";
|
||||
@ -6325,40 +6358,40 @@ class Form
|
||||
}
|
||||
return $out;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return HTML to show the select categories of expense category
|
||||
*
|
||||
*
|
||||
* @param string $selected preselected category
|
||||
* @param string $htmlname name of HTML select list
|
||||
* @param integer $useempty 1=Add empty line
|
||||
* @param array $excludeid id to exclude
|
||||
* @param string $target htmlname of target select to bind event
|
||||
* @param int $default_selected default category to select if fk_c_type_fees change = EX_KME
|
||||
* @param array $params param to give
|
||||
* @param array $params param to give
|
||||
* @return string
|
||||
*/
|
||||
function selectExpenseCategories($selected='', $htmlname='fk_c_exp_tax_cat', $useempty=0, $excludeid=array(), $target='', $default_selected=0, $params=array())
|
||||
{
|
||||
global $db,$conf,$langs;
|
||||
|
||||
|
||||
$sql = 'SELECT rowid, label FROM '.MAIN_DB_PREFIX.'c_exp_tax_cat WHERE active = 1';
|
||||
$sql.= ' AND entity IN (0,'.getEntity('').')';
|
||||
if (!empty($excludeid)) $sql.= ' AND rowid NOT IN ('.implode(',', $excludeid).')';
|
||||
$sql.= ' ORDER BY label';
|
||||
|
||||
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$out = '<select name="'.$htmlname.'" class="'.$htmlname.' flat minwidth75imp">';
|
||||
if ($useempty) $out.= '<option value="0"></option>';
|
||||
|
||||
|
||||
while ($obj = $db->fetch_object($resql))
|
||||
{
|
||||
$out.= '<option '.($selected == $obj->rowid ? 'selected="selected"' : '').' value="'.$obj->rowid.'">'.$langs->trans($obj->label).'</option>';
|
||||
}
|
||||
$out.= '</select>';
|
||||
|
||||
|
||||
if (!empty($target))
|
||||
{
|
||||
$sql = "SELECT c.id FROM ".MAIN_DB_PREFIX."c_type_fees as c WHERE c.code = 'EX_KME' AND c.active = 1";
|
||||
@ -6374,19 +6407,19 @@ class Form
|
||||
var current_val = $(this).val();
|
||||
if (current_val == '.$obj->id.') {';
|
||||
if (!empty($default_selected) || !empty($selected)) $out.= '$("select[name='.$htmlname.']").val("'.($default_selected > 0 ? $default_selected : $selected).'");';
|
||||
|
||||
|
||||
$out.= '
|
||||
$("select[name='.$htmlname.']").change();
|
||||
}
|
||||
});
|
||||
|
||||
$("select[name='.$htmlname.']").change(function() {
|
||||
|
||||
|
||||
if ($("select[name='.$target.']").val() == '.$obj->id.') {
|
||||
// get price of kilometer to fill the unit price
|
||||
var data = '.json_encode($params).';
|
||||
data.fk_c_exp_tax_cat = $(this).val();
|
||||
|
||||
|
||||
$.ajax({
|
||||
method: "POST",
|
||||
dataType: "json",
|
||||
@ -6407,20 +6440,20 @@ class Form
|
||||
});
|
||||
</script>';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_print_error($db);
|
||||
}
|
||||
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return HTML to show the select ranges of expense range
|
||||
*
|
||||
*
|
||||
* @param string $selected preselected category
|
||||
* @param string $htmlname name of HTML select list
|
||||
* @param integer $useempty 1=Add empty line
|
||||
@ -6429,16 +6462,16 @@ class Form
|
||||
function selectExpenseRanges($selected='', $htmlname='fk_range', $useempty=0)
|
||||
{
|
||||
global $db,$conf,$langs;
|
||||
|
||||
|
||||
$sql = 'SELECT rowid, range_ik FROM '.MAIN_DB_PREFIX.'c_exp_tax_range';
|
||||
$sql.= ' WHERE entity = '.$conf->entity.' AND active = 1';
|
||||
|
||||
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$out = '<select name="'.$htmlname.'" class="'.$htmlname.' flat minwidth75imp">';
|
||||
if ($useempty) $out.= '<option value="0"></option>';
|
||||
|
||||
|
||||
while ($obj = $db->fetch_object($resql))
|
||||
{
|
||||
$out.= '<option '.($selected == $obj->rowid ? 'selected="selected"' : '').' value="'.$obj->rowid.'">'.price($obj->range_ik, 0, $langs, 1, 0).'</option>';
|
||||
@ -6449,13 +6482,13 @@ class Form
|
||||
{
|
||||
dol_print_error($db);
|
||||
}
|
||||
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return HTML to show a select of expense
|
||||
*
|
||||
*
|
||||
* @param string $selected preselected category
|
||||
* @param string $htmlname name of HTML select list
|
||||
* @param integer $useempty 1=Add empty choice
|
||||
@ -6466,20 +6499,20 @@ class Form
|
||||
function selectExpense($selected='', $htmlname='fk_c_type_fees', $useempty=0, $allchoice=1, $useid=0)
|
||||
{
|
||||
global $db,$langs;
|
||||
|
||||
|
||||
$sql = 'SELECT id, code, label FROM '.MAIN_DB_PREFIX.'c_type_fees';
|
||||
$sql.= ' WHERE active = 1';
|
||||
|
||||
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$out = '<select name="'.$htmlname.'" class="'.$htmlname.' flat minwidth75imp">';
|
||||
if ($useempty) $out.= '<option value="0"></option>';
|
||||
if ($allchoice) $out.= '<option value="-1">'.$langs->trans('AllExpenseReport').'</option>';
|
||||
|
||||
|
||||
$field = 'code';
|
||||
if ($useid) $field = 'id';
|
||||
|
||||
|
||||
while ($obj = $db->fetch_object($resql))
|
||||
{
|
||||
$key = $langs->trans($obj->code);
|
||||
@ -6491,9 +6524,9 @@ class Form
|
||||
{
|
||||
dol_print_error($db);
|
||||
}
|
||||
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user