forked from Wavyzz/dolibarr
Dbut ajout de l'autocompltion ajax sur la liste droulante des pays
This commit is contained in:
@@ -398,61 +398,61 @@ document.onmousemove=positiontip;
|
||||
|
||||
|
||||
/*=================================================================
|
||||
Function: formatDate (javascript object Date(), format)
|
||||
Function: formatDate (javascript object Date(), format)
|
||||
Purpose: Returns a date in the output format specified.
|
||||
The format string can use the following tags:
|
||||
Field | Tags
|
||||
-------------+-------------------------------
|
||||
Year | yyyy (4 digits), yy (2 digits)
|
||||
Month | MM (2 digits)
|
||||
Day of Month | dd (2 digits)
|
||||
Hour (1-12) | hh (2 digits)
|
||||
Hour (0-23) | HH (2 digits)
|
||||
Minute | mm (2 digits)
|
||||
Second | ss (2 digits)
|
||||
Field | Tags
|
||||
-------------+-------------------------------
|
||||
Year | yyyy (4 digits), yy (2 digits)
|
||||
Month | MM (2 digits)
|
||||
Day of Month | dd (2 digits)
|
||||
Hour (1-12) | hh (2 digits)
|
||||
Hour (0-23) | HH (2 digits)
|
||||
Minute | mm (2 digits)
|
||||
Second | ss (2 digits)
|
||||
Author: Laurent Destailleur
|
||||
Licence: GPL
|
||||
==================================================================*/
|
||||
function formatDate(date,format)
|
||||
{
|
||||
{
|
||||
//alert('formatDate date='+date+' format='+format);
|
||||
|
||||
// Force parametres en chaine
|
||||
format=format+"";
|
||||
format=format+"";
|
||||
|
||||
var result="";
|
||||
|
||||
var year=date.getYear()+""; if (year.length < 4) { year=""+(year-0+1900); }
|
||||
var month=date.getMonth()+1;
|
||||
var day=date.getDate();
|
||||
var hour=date.getHours();
|
||||
var min=date.getMinutes();
|
||||
var seconde=date.getSeconds();
|
||||
var year=date.getYear()+""; if (year.length < 4) { year=""+(year-0+1900); }
|
||||
var month=date.getMonth()+1;
|
||||
var day=date.getDate();
|
||||
var hour=date.getHours();
|
||||
var min=date.getMinutes();
|
||||
var seconde=date.getSeconds();
|
||||
|
||||
var i=0;
|
||||
while (i < format.length)
|
||||
{
|
||||
c=format.charAt(i); // Recupere char du format
|
||||
substr="";
|
||||
{
|
||||
c=format.charAt(i); // Recupere char du format
|
||||
substr="";
|
||||
j=i;
|
||||
while ((format.charAt(j)==c) && (j < format.length)) // Recupere char successif identiques
|
||||
{
|
||||
substr += format.charAt(j++);
|
||||
}
|
||||
{
|
||||
substr += format.charAt(j++);
|
||||
}
|
||||
|
||||
//alert('substr='+substr);
|
||||
if (substr == 'yyyy') { result=result+year; }
|
||||
else if (substr == 'yy') { result=result+year.substring(2,4); }
|
||||
else if (substr == 'MM') { result=result+(month<1||month>9?"":"0")+month; }
|
||||
else if (substr == 'd') { result=result+day; }
|
||||
else if (substr == 'dd') { result=result+(day<1||day>9?"":"0")+day; }
|
||||
else if (substr == 'hh') { if (hour > 12) hour-=12; result=result+(hour<1||hour>9?"":"0")+hour; }
|
||||
else if (substr == 'HH') { result=result+(hour<1||hour>9?"":"0")+hour; }
|
||||
else if (substr == 'mm') { result=result+(minute<1||minute>9?"":"0")+minute; }
|
||||
else if (substr == 'ss') { result=result+(seconde<1||seconde>9?"":"0")+seconde; }
|
||||
if (substr == 'yyyy') { result=result+year; }
|
||||
else if (substr == 'yy') { result=result+year.substring(2,4); }
|
||||
else if (substr == 'MM') { result=result+(month<1||month>9?"":"0")+month; }
|
||||
else if (substr == 'd') { result=result+day; }
|
||||
else if (substr == 'dd') { result=result+(day<1||day>9?"":"0")+day; }
|
||||
else if (substr == 'hh') { if (hour > 12) hour-=12; result=result+(hour<1||hour>9?"":"0")+hour; }
|
||||
else if (substr == 'HH') { result=result+(hour<1||hour>9?"":"0")+hour; }
|
||||
else if (substr == 'mm') { result=result+(minute<1||minute>9?"":"0")+minute; }
|
||||
else if (substr == 'ss') { result=result+(seconde<1||seconde>9?"":"0")+seconde; }
|
||||
else { result=result+substr; }
|
||||
|
||||
i+=substr.length;
|
||||
i+=substr.length;
|
||||
}
|
||||
|
||||
//alert(result);
|
||||
@@ -461,50 +461,50 @@ function formatDate(date,format)
|
||||
|
||||
|
||||
/*=================================================================
|
||||
Function: getDateFromFormat(date_string, format_string)
|
||||
Function: getDateFromFormat(date_string, format_string)
|
||||
Purpose: This function takes a date string and a format string.
|
||||
It parses the date string with format and it returns
|
||||
the date as a javascript Date() object.
|
||||
If date does not match format, it returns 0.
|
||||
the date as a javascript Date() object.
|
||||
If date does not match format, it returns 0.
|
||||
The format string can use the following tags:
|
||||
Field | Tags
|
||||
-------------+-------------------------------
|
||||
Year | yyyy (4 digits), yy (2 digits)
|
||||
Month | MM (2 digits)
|
||||
Day of Month | dd (2 digits)
|
||||
Hour (1-12) | hh (2 digits)
|
||||
Hour (0-23) | HH (2 digits)
|
||||
Minute | mm (2 digits)
|
||||
Second | ss (2 digits)
|
||||
Field | Tags
|
||||
-------------+-------------------------------
|
||||
Year | yyyy (4 digits), yy (2 digits)
|
||||
Month | MM (2 digits)
|
||||
Day of Month | dd (2 digits)
|
||||
Hour (1-12) | hh (2 digits)
|
||||
Hour (0-23) | HH (2 digits)
|
||||
Minute | mm (2 digits)
|
||||
Second | ss (2 digits)
|
||||
Author: Laurent Destailleur
|
||||
Licence: GPL
|
||||
==================================================================*/
|
||||
function getDateFromFormat(val,format)
|
||||
{
|
||||
{
|
||||
//alert('getDateFromFormat val='+val+' format='+format);
|
||||
|
||||
// Force parametres en chaine
|
||||
val=val+"";
|
||||
val=val+"";
|
||||
format=format+"";
|
||||
|
||||
var now=new Date();
|
||||
var now=new Date();
|
||||
var year=now.getYear(); if (year.length < 4) { year=""+(year-0+1900); }
|
||||
var month=now.getMonth()+1;
|
||||
var day=now.getDate();
|
||||
var hour=now.getHours();
|
||||
var minute=now.getMinutes();
|
||||
var seconde=now.getSeconds();
|
||||
var month=now.getMonth()+1;
|
||||
var day=now.getDate();
|
||||
var hour=now.getHours();
|
||||
var minute=now.getMinutes();
|
||||
var seconde=now.getSeconds();
|
||||
|
||||
var i=0;
|
||||
while (i < format.length)
|
||||
{
|
||||
c=format.charAt(i); // Recupere char du format
|
||||
{
|
||||
c=format.charAt(i); // Recupere char du format
|
||||
substr="";
|
||||
j=i;
|
||||
j=i;
|
||||
while ((format.charAt(j)==c) && (j < format.length)) // Recupere char successif identiques
|
||||
{
|
||||
substr += format.charAt(j++);
|
||||
}
|
||||
{
|
||||
substr += format.charAt(j++);
|
||||
}
|
||||
|
||||
//alert('substr='+substr);
|
||||
if (substr == "yyyy") year=getIntegerInString(val,i,4,4);
|
||||
@@ -521,49 +521,49 @@ function getDateFromFormat(val,format)
|
||||
}
|
||||
|
||||
// Check if format param are ok
|
||||
if (year==null||year<1) { return 0; }
|
||||
if (month==null||(month<1)||(month>12)) { return 0; }
|
||||
if (day==null||(day<1)||(day>31)) { return 0; }
|
||||
if (hour==null||(hour<0)||(hour>24)) { return 0; }
|
||||
if (minute==null||(minute<0)||(minute>60)) { return 0; }
|
||||
if (seconde==null||(seconde<0)||(seconde>60)) { return 0; }
|
||||
if (year==null||year<1) { return 0; }
|
||||
if (month==null||(month<1)||(month>12)) { return 0; }
|
||||
if (day==null||(day<1)||(day>31)) { return 0; }
|
||||
if (hour==null||(hour<0)||(hour>24)) { return 0; }
|
||||
if (minute==null||(minute<0)||(minute>60)) { return 0; }
|
||||
if (seconde==null||(seconde<0)||(seconde>60)) { return 0; }
|
||||
|
||||
//alert(year+' '+month+' '+day+' '+hour+' '+minute+' '+seconde);
|
||||
var newdate=new Date(year,month-1,day,hour,minute,seconde);
|
||||
//alert(year+' '+month+' '+day+' '+hour+' '+minute+' '+seconde);
|
||||
var newdate=new Date(year,month-1,day,hour,minute,seconde);
|
||||
|
||||
return newdate;
|
||||
}
|
||||
|
||||
/*=================================================================
|
||||
Function: stringIsInteger(string)
|
||||
Function: stringIsInteger(string)
|
||||
Purpose: Return true if string is an integer
|
||||
==================================================================*/
|
||||
function stringIsInteger(str)
|
||||
{
|
||||
var digits="1234567890";
|
||||
{
|
||||
var digits="1234567890";
|
||||
for (var i=0; i < str.length; i++)
|
||||
{
|
||||
{
|
||||
if (digits.indexOf(str.charAt(i))==-1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/*=================================================================
|
||||
Function: getIntegerInString(string,pos,minlength,maxlength)
|
||||
Function: getIntegerInString(string,pos,minlength,maxlength)
|
||||
Purpose: Return part of string from position i that is integer
|
||||
==================================================================*/
|
||||
function getIntegerInString(str,i,minlength,maxlength)
|
||||
{
|
||||
{
|
||||
for (var x=maxlength; x>=minlength; x--)
|
||||
{
|
||||
var substr=str.substring(i,i+x);
|
||||
if (substr.length < minlength) { return null; }
|
||||
if (stringIsInteger(substr)) { return substr; }
|
||||
}
|
||||
return null;
|
||||
{
|
||||
var substr=str.substring(i,i+x);
|
||||
if (substr.length < minlength) { return null; }
|
||||
if (stringIsInteger(substr)) { return substr; }
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -592,3 +592,21 @@ function newpopup(url,title) {
|
||||
fen=window.open(tmp,title,wfeatures);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/*=================================================================
|
||||
Purpose: R<>cup<75>re l'id d'une autcompletion Ajax
|
||||
Input: field,item
|
||||
Author: Regis Houssin
|
||||
Licence: GPL
|
||||
==================================================================*/
|
||||
function ac_return(field, item){
|
||||
// on met en place l'expression r<>guli<6C>re
|
||||
var regex = new RegExp('[0123456789]*-idcache', 'i');
|
||||
// on l'applique au contenu
|
||||
var idCache = regex.exec($(item).innerHTML);
|
||||
//on r<>cup<75>re l'id
|
||||
id = idCache[0].replace('-idcache', '');
|
||||
// et on l'affecte au champ cach<63>
|
||||
$(field.name+'_id').value = id;
|
||||
}
|
||||
Reference in New Issue
Block a user