trim trailing

This commit is contained in:
Frédéric FRANCE 2018-07-26 19:26:03 +02:00
parent 6cb0fb10d6
commit 526ea496ee
No known key found for this signature in database
GPG Key ID: 06809324E4B2ABC1
5 changed files with 69 additions and 72 deletions

View File

@ -53,7 +53,7 @@ abstract class CommonObjectLine extends CommonObject
/** /**
* Returns the translation key from units dictionary. * Returns the translation key from units dictionary.
* A langs->trans() must be called on result to get translated value. * A langs->trans() must be called on result to get translated value.
* *
* @param string $type Label type (long or short) * @param string $type Label type (long or short)
* @return string|int <0 if ko, label if ok * @return string|int <0 if ko, label if ok
*/ */
@ -94,4 +94,3 @@ abstract class CommonObjectLine extends CommonObject
// For the moment we use the extends on CommonObject until PHP min is 5.4 so use Traits. // For the moment we use the extends on CommonObject until PHP min is 5.4 so use Traits.
} }

View File

@ -155,7 +155,7 @@ class vCard
* @return void * @return void
*/ */
function setBirthday($date) function setBirthday($date)
{ {
// $date format is YYYY-MM-DD - RFC 2425 and RFC 2426 // $date format is YYYY-MM-DD - RFC 2425 and RFC 2426
$this->properties["BDAY"] = dol_print_date($date, 'dayrfc'); $this->properties["BDAY"] = dol_print_date($date, 'dayrfc');
} }

View File

@ -22,7 +22,7 @@
/* Enable jcrop plugin onto id cropbox */ /* Enable jcrop plugin onto id cropbox */
jQuery(function() { jQuery(function() {
jQuery('#cropbox').Jcrop({ jQuery('#cropbox').Jcrop({
onSelect: updateCoords, onSelect: updateCoords,
onChange: updateCoords onChange: updateCoords
}); });
}); });

View File

@ -22,28 +22,28 @@ var Listview_include = true;
function Listview_OrderDown(idListe, column) { function Listview_OrderDown(idListe, column) {
var base_url = document.location.href; var base_url = document.location.href;
base_url = Listview_recup_form_param(idListe,base_url); base_url = Listview_recup_form_param(idListe,base_url);
base_url = Listview_removeParam(base_url,'Listview['+encodeURIComponent(idListe)+'][orderBy]'); base_url = Listview_removeParam(base_url,'Listview['+encodeURIComponent(idListe)+'][orderBy]');
base_url = Listview_removeParam(base_url,'get-all-for-export'); base_url = Listview_removeParam(base_url,'get-all-for-export');
document.location.href=Listview_modifyUrl(base_url,"Listview["+encodeURIComponent(idListe)+"][orderBy]["+encodeURIComponent(column)+"]","DESC"); document.location.href=Listview_modifyUrl(base_url,"Listview["+encodeURIComponent(idListe)+"][orderBy]["+encodeURIComponent(column)+"]","DESC");
} }
function Listview_OrderUp(idListe, column) { function Listview_OrderUp(idListe, column) {
var base_url = document.location.href; var base_url = document.location.href;
base_url = Listview_recup_form_param(idListe,base_url); base_url = Listview_recup_form_param(idListe,base_url);
base_url = Listview_removeParam(base_url,'Listview['+encodeURIComponent(idListe)+'][orderBy]'); base_url = Listview_removeParam(base_url,'Listview['+encodeURIComponent(idListe)+'][orderBy]');
base_url = Listview_removeParam(base_url,'get-all-for-export'); base_url = Listview_removeParam(base_url,'get-all-for-export');
document.location.href=Listview_modifyUrl(base_url,"Listview["+encodeURIComponent(idListe)+"][orderBy]["+encodeURIComponent(column)+"]","ASC"); document.location.href=Listview_modifyUrl(base_url,"Listview["+encodeURIComponent(idListe)+"][orderBy]["+encodeURIComponent(column)+"]","ASC");
} }
function Listview_modifyUrl(strURL,paramName,paramNewValue){ function Listview_modifyUrl(strURL,paramName,paramNewValue){
if (strURL.indexOf(paramName+'=')!=-1){ if (strURL.indexOf(paramName+'=')!=-1){
var strFirstPart=strURL.substring(0,strURL.indexOf(paramName+'=',0))+paramName+'='; var strFirstPart=strURL.substring(0,strURL.indexOf(paramName+'=',0))+paramName+'=';
var strLastPart=""; var strLastPart="";
if (strURL.indexOf('&',strFirstPart.length-1)>0) if (strURL.indexOf('&',strFirstPart.length-1)>0)
@ -56,55 +56,55 @@ function Listview_modifyUrl(strURL,paramName,paramNewValue){
else else
strURL+='?'+paramName+'='+paramNewValue; strURL+='?'+paramName+'='+paramNewValue;
} }
return strURL; return strURL;
} }
function Listview_removeParam(strURL, paramMask) { function Listview_removeParam(strURL, paramMask) {
var cpt=0; var cpt=0;
var url = ''; var url = '';
while(strURL.indexOf(paramMask)!=-1 && cpt++ <50){ while(strURL.indexOf(paramMask)!=-1 && cpt++ <50){
var strFirstPart= strURL.substring(0,strURL.indexOf(paramMask)-1); var strFirstPart= strURL.substring(0,strURL.indexOf(paramMask)-1);
var strLastPart=''; var strLastPart='';
if (strURL.indexOf('&',strFirstPart.length+1)>0) { if (strURL.indexOf('&',strFirstPart.length+1)>0) {
strLastPart = strURL.substring(strURL.indexOf('&',strFirstPart.length+1),strURL.length); strLastPart = strURL.substring(strURL.indexOf('&',strFirstPart.length+1),strURL.length);
} }
url = strFirstPart+strLastPart; url = strFirstPart+strLastPart;
} }
if(url=='')url = strURL; if(url=='')url = strURL;
return url; return url;
} }
function Listview_recup_form_param(idListe,base_url) { function Listview_recup_form_param(idListe,base_url) {
$('#'+idListe+' tr.barre-recherche [listviewtbs],#'+idListe+' tr.barre-recherche-head input,#'+idListe+' tr.barre-recherche-head select,#'+idListe+' div.tabsAction input[listviewtbs]').each(function(i,item) { $('#'+idListe+' tr.barre-recherche [listviewtbs],#'+idListe+' tr.barre-recherche-head input,#'+idListe+' tr.barre-recherche-head select,#'+idListe+' div.tabsAction input[listviewtbs]').each(function(i,item) {
if($(item).attr("name")) { if($(item).attr("name")) {
base_url = Listview_modifyUrl(base_url, $(item).attr("name") , $(item).val()); base_url = Listview_modifyUrl(base_url, $(item).attr("name") , $(item).val());
} }
}); });
return base_url; return base_url;
} }
function Listview_GoToPage(idListe,pageNumber){ function Listview_GoToPage(idListe,pageNumber){
var base_url = document.location.href; var base_url = document.location.href;
base_url = Listview_recup_form_param(idListe,base_url); base_url = Listview_recup_form_param(idListe,base_url);
base_url =Listview_modifyUrl(base_url,"Listview["+encodeURIComponent(idListe)+"][page]",pageNumber); base_url =Listview_modifyUrl(base_url,"Listview["+encodeURIComponent(idListe)+"][page]",pageNumber);
base_url = Listview_removeParam(base_url,'get-all-for-export'); base_url = Listview_removeParam(base_url,'get-all-for-export');
document.location.href=base_url; document.location.href=base_url;
} }
function Listview_submitSearch(obj) { function Listview_submitSearch(obj) {
$form = $(obj).closest('form'); $form = $(obj).closest('form');
console.log($form); console.log($form);
if($form.length>0){ if($form.length>0){
@ -113,20 +113,20 @@ function Listview_submitSearch(obj) {
} }
function Listview_launch_downloadAs(mode,url,token,session_name) { function Listview_launch_downloadAs(mode,url,token,session_name) {
$('#listviewdAS_export_form').remove(); $('#listviewdAS_export_form').remove();
$form = $('<form action="'+url+'" method="post" name="listviewdAS_export_form" id="listTBSdAS_export_form"></form>'); $form = $('<form action="'+url+'" method="post" name="listviewdAS_export_form" id="listTBSdAS_export_form"></form>');
$form.append('<input type="hidden" name="mode" value="'+mode+'" />'); $form.append('<input type="hidden" name="mode" value="'+mode+'" />');
$form.append('<input type="hidden" name="token" value="'+token+'" />'); $form.append('<input type="hidden" name="token" value="'+token+'" />');
$form.append('<input type="hidden" name="session_name" value="'+session_name+'" />'); $form.append('<input type="hidden" name="session_name" value="'+session_name+'" />');
$('body').append($form); $('body').append($form);
$('#listviewdAS_export_form').submit(); $('#listviewdAS_export_form').submit();
} }
function Listview_downloadAs(obj, mode,url,token,session_name) { function Listview_downloadAs(obj, mode,url,token,session_name) {
$form = $(obj).closest('form'); $form = $(obj).closest('form');
$div = $form.find('div.tabsAction'); $div = $form.find('div.tabsAction');
$div.append('<input type="hidden" listviewtbs="hidden" name="token" value="'+token+'" />'); $div.append('<input type="hidden" listviewtbs="hidden" name="token" value="'+token+'" />');
@ -134,33 +134,33 @@ function Listview_downloadAs(obj, mode,url,token,session_name) {
$div.append('<input type="hidden" listviewtbs="hidden" name="url" value="'+url+'" />'); $div.append('<input type="hidden" listviewtbs="hidden" name="url" value="'+url+'" />');
$div.append('<input type="hidden" listviewtbs="hidden" name="session_name" value="'+session_name+'" />'); $div.append('<input type="hidden" listviewtbs="hidden" name="session_name" value="'+session_name+'" />');
$div.append('<input type="hidden" listviewtbs="hidden" name="get-all-for-export" value="1" />'); $div.append('<input type="hidden" listviewtbs="hidden" name="get-all-for-export" value="1" />');
Listview_submitSearch(obj); Listview_submitSearch(obj);
} }
$(document).ready(function() { $(document).ready(function() {
$('tr.barre-recherche input').keypress(function(e) { $('tr.barre-recherche input').keypress(function(e) {
if(e.which == 13) { if(e.which == 13) {
var id_list = $(this).closest('table').attr('id'); var id_list = $(this).closest('table').attr('id');
$('#'+id_list+' .list-search-link').click(); $('#'+id_list+' .list-search-link').click();
} }
}); });
var $_GET = {}; var $_GET = {};
document.location.search.replace(/\??(?:([^=]+)=([^&]*)&?)/g, function () { document.location.search.replace(/\??(?:([^=]+)=([^&]*)&?)/g, function () {
function decode(s) { function decode(s) {
return decodeURIComponent(s.split("+").join(" ")); return decodeURIComponent(s.split("+").join(" "));
} }
$_GET[decode(arguments[1])] = decode(arguments[2]); $_GET[decode(arguments[1])] = decode(arguments[2]);
}); });
if(typeof $_GET["get-all-for-export"] != "undefined") { if(typeof $_GET["get-all-for-export"] != "undefined") {
Listview_launch_downloadAs($_GET['mode'],$_GET['url'],$_GET['token'],$_GET['session_name']); Listview_launch_downloadAs($_GET['mode'],$_GET['url'],$_GET['token'],$_GET['session_name']);
} }
}); });

View File

@ -24,9 +24,9 @@ function regexEvent(objet,evt,type)
{ {
case 'days': case 'days':
var regex= /^[0-9]{1}([.,]{1}[0-9]{1})?$/; var regex= /^[0-9]{1}([.,]{1}[0-9]{1})?$/;
if(regex.test(objet.value) ) if(regex.test(objet.value) )
{ {
var tmp=objet.value.replace(',','.'); var tmp=objet.value.replace(',','.');
if(tmp<=1.5){ if(tmp<=1.5){
var tmpint=parseInt(tmp); var tmpint=parseInt(tmp);
@ -41,13 +41,13 @@ function regexEvent(objet,evt,type)
}else{ }else{
objet.value= '0'; objet.value= '0';
} }
break; break;
case 'hours': case 'hours':
var regex= /^[0-9]{1,2}:[0-9]{2}$/; var regex= /^[0-9]{1,2}:[0-9]{2}$/;
var regex2=/^[0-9]{1,2}$/; var regex2=/^[0-9]{1,2}$/;
var regex3= /^[0-9]{1}([.,]{1}[0-9]{1,2})?$/; var regex3= /^[0-9]{1}([.,]{1}[0-9]{1,2})?$/;
if(!regex.test(objet.value)) if(!regex.test(objet.value))
{ {
if(regex2.test(objet.value)) if(regex2.test(objet.value))
objet.value=objet.value+':00'; objet.value=objet.value+':00';
else if(regex3.test(objet.value)) { else if(regex3.test(objet.value)) {
@ -63,25 +63,25 @@ function regexEvent(objet,evt,type)
//var regex= /^[0-9:]{1}$/; //var regex= /^[0-9:]{1}$/;
//alert(event.charCode); //alert(event.charCode);
var charCode = (evt.which) ? evt.which : event.keyCode; var charCode = (evt.which) ? evt.which : event.keyCode;
if(((charCode >= 48) && (charCode <= 57)) || //num if(((charCode >= 48) && (charCode <= 57)) || //num
(charCode===46) || (charCode===8)||// comma & periode (charCode===46) || (charCode===8)||// comma & periode
(charCode === 58) || (charCode==44) )// : & all charcode (charCode === 58) || (charCode==44) )// : & all charcode
{ {
// ((charCode>=96) && (charCode<=105)) || //numpad // ((charCode>=96) && (charCode<=105)) || //numpad
return true; return true;
}else }else
{ {
return false; return false;
} }
break; break;
default: default:
break; break;
} }
} }
function pad(n) { function pad(n) {
return (n < 10) ? ("0" + n) : n; return (n < 10) ? ("0" + n) : n;
@ -95,7 +95,7 @@ function parseTime(timeStr, dt)
if (!dt) { if (!dt) {
dt = new Date(); dt = new Date();
} }
var time = timeStr.match(/(\d+)(?::(\d\d))?\s*(p?)/i); var time = timeStr.match(/(\d+)(?::(\d\d))?\s*(p?)/i);
if (!time) { if (!time) {
return -1; return -1;
@ -107,7 +107,7 @@ function parseTime(timeStr, dt)
else { else {
hours += (hours < 12 && time[3]) ? 12 : 0; hours += (hours < 12 && time[3]) ? 12 : 0;
} }
dt.setHours(hours); dt.setHours(hours);
dt.setMinutes(parseInt(time[2], 10) || 0); dt.setMinutes(parseInt(time[2], 10) || 0);
dt.setSeconds(0, 0); dt.setSeconds(0, 0);
@ -122,10 +122,10 @@ function updateTotal(days,mode)
{ {
var total = new Date(0); var total = new Date(0);
total.setHours(0); total.setHours(0);
total.setMinutes(0); total.setMinutes(0);
var nbline = document.getElementById('numberOfLines').value; var nbline = document.getElementById('numberOfLines').value;
for (var i=-1; i<nbline; i++) for (var i=-1; i<nbline; i++)
{ {
var id='timespent['+i+']['+days+']'; var id='timespent['+i+']['+days+']';
var taskTime= new Date(0); var taskTime= new Date(0);
var element=document.getElementById(id); var element=document.getElementById(id);
@ -133,7 +133,7 @@ function updateTotal(days,mode)
{ {
/* alert(element.value);*/ /* alert(element.value);*/
if (element.value) if (element.value)
{ {
result=parseTime(element.value,taskTime); result=parseTime(element.value,taskTime);
} }
else else
@ -147,14 +147,14 @@ function updateTotal(days,mode)
} }
} }
var id='timeadded['+i+']['+days+']'; var id='timeadded['+i+']['+days+']';
var taskTime= new Date(0); var taskTime= new Date(0);
var element=document.getElementById(id); var element=document.getElementById(id);
if(element) if(element)
{ {
/* alert(element.value);*/ /* alert(element.value);*/
if (element.value) if (element.value)
{ {
result=parseTime(element.value,taskTime); result=parseTime(element.value,taskTime);
} }
else else
@ -178,7 +178,7 @@ function updateTotal(days,mode)
console.log(this.value) console.log(this.value)
alert(element.value);*/ alert(element.value);*/
if (this.value) if (this.value)
{ {
console.log(this.value+':00') console.log(this.value+':00')
result=parseTime(this.value+':00',taskTime); result=parseTime(this.value+':00',taskTime);
} }
@ -202,7 +202,7 @@ function updateTotal(days,mode)
console.log(this.value) console.log(this.value)
alert(element.value);*/ alert(element.value);*/
if (this.value) if (this.value)
{ {
console.log('00:'+this.value) console.log('00:'+this.value)
result=parseTime('00:'+"00".substring(0, 2 - this.value.length) + this.value,taskTime); result=parseTime('00:'+"00".substring(0, 2 - this.value.length) + this.value,taskTime);
} }
@ -217,14 +217,14 @@ function updateTotal(days,mode)
console.log(total.getMinutes()) console.log(total.getMinutes())
} }
}); });
if (total.getHours() || total.getMinutes()) jQuery('.totalDay'+days).addClass("bold"); if (total.getHours() || total.getMinutes()) jQuery('.totalDay'+days).addClass("bold");
else jQuery('.totalDay'+days).removeClass("bold"); else jQuery('.totalDay'+days).removeClass("bold");
jQuery('.totalDay'+days).text(pad(total.getHours())+':'+pad(total.getMinutes())); jQuery('.totalDay'+days).text(pad(total.getHours())+':'+pad(total.getMinutes()));
var total = new Date(0); var total = new Date(0);
total.setHours(0); total.setHours(0);
total.setMinutes(0); total.setMinutes(0);
for (var i=0; i<7; i++) for (var i=0; i<7; i++)
{ {
var taskTime= new Date(0); var taskTime= new Date(0);
@ -242,14 +242,14 @@ function updateTotal(days,mode)
var total =0; var total =0;
var nbline = document.getElementById('numberOfLines').value; var nbline = document.getElementById('numberOfLines').value;
for (var i=-1; i<nbline; i++) for (var i=-1; i<nbline; i++)
{ {
var id='timespent['+i+']['+days+']'; var id='timespent['+i+']['+days+']';
var taskTime= new Date(0); var taskTime= new Date(0);
var element=document.getElementById(id); var element=document.getElementById(id);
if(element) if(element)
{ {
if (element.value) if (element.value)
{ {
total+=parseInt(element.value); total+=parseInt(element.value);
} }
@ -259,13 +259,13 @@ function updateTotal(days,mode)
} }
} }
var id='timeadded['+i+']['+days+']'; var id='timeadded['+i+']['+days+']';
var taskTime= new Date(0); var taskTime= new Date(0);
var element=document.getElementById(id); var element=document.getElementById(id);
if(element) if(element)
{ {
if (element.value) if (element.value)
{ {
total+=parseInt(element.value); total+=parseInt(element.value);
} }
@ -275,11 +275,9 @@ function updateTotal(days,mode)
} }
} }
} }
if (total) jQuery('.totalDay'+days).addClass("bold"); if (total) jQuery('.totalDay'+days).addClass("bold");
else jQuery('.totalDay'+days).removeClass("bold"); else jQuery('.totalDay'+days).removeClass("bold");
jQuery('.totalDay'+days).text(total); jQuery('.totalDay'+days).text(total);
} }
} }