mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2026-01-05 16:42:53 +01:00
Merge remote-tracking branch 'origin/3.7' into develop
Conflicts: build/makepack-dolibarr.pl htdocs/adherents/type.php htdocs/core/boxes/box_task.php htdocs/core/class/commonobject.class.php htdocs/core/class/html.form.class.php htdocs/core/js/lib_batch.js htdocs/core/modules/modUser.class.php htdocs/fichinter/card.php htdocs/fourn/commande/card.php htdocs/societe/consumption.php htdocs/user/info.php htdocs/user/note.php htdocs/user/param_ihm.php htdocs/user/perms.php
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
// Copyright (C) 2011-2014 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
// Copyright (C) 2011-2012 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
// Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
@@ -23,7 +24,10 @@
|
||||
//
|
||||
|
||||
$(document).ready(function () {
|
||||
// Detect and save TZ and DST
|
||||
|
||||
var timezone = jstz.determine();
|
||||
|
||||
// Detect and save TZ and DST
|
||||
var rightNow = new Date();
|
||||
var jan1 = new Date(rightNow.getFullYear(), 0, 1, 0, 0, 0, 0);
|
||||
var temp = jan1.toGMTString();
|
||||
@@ -40,16 +44,12 @@ $(document).ready(function () {
|
||||
dst = "1"; // daylight savings time is observed
|
||||
}
|
||||
var now=new Date();
|
||||
var tz=now.toTimeString().match(/\(.*\)/); // now.toTimeString may return "12:39:59 GMT+0200 (CEST)"
|
||||
//alert('date=' + now + ' string=' + now.toTimeString());
|
||||
var dst_first=DisplayDstSwitchDates('first');
|
||||
var dst_second=DisplayDstSwitchDates('second');
|
||||
//alert(dst);
|
||||
$('#tz').val(std_time_offset); // returns TZ
|
||||
// tz is null with IE
|
||||
if (tz != null) {
|
||||
$('#tz_string').val(tz[0].replace('(','').replace(')','')); // returns TZ string
|
||||
}
|
||||
$('#tz_string').val(timezone.name()); // returns TZ string
|
||||
$('#dst_observed').val(dst); // returns if DST is observed on summer
|
||||
$('#dst_first').val(dst_first); // returns DST first switch in year
|
||||
$('#dst_second').val(dst_second); // returns DST second switch in year
|
||||
|
||||
@@ -19,11 +19,17 @@
|
||||
// \brief File that include javascript functions used when dispatching batch-enabled product
|
||||
//
|
||||
|
||||
function addLineBatch(index) {
|
||||
/**
|
||||
* addLineBatch
|
||||
*
|
||||
* @param index int number of produt. 0 = first product line
|
||||
*/
|
||||
function addLineBatch(index)
|
||||
{
|
||||
var nme = 'dluo_0_'+index;
|
||||
$row=$("tr[name='"+nme+"']").clone(true);
|
||||
$row.find("input[name^='qty']").val('');
|
||||
var trs = $("tr[name^='dluo_'][name$='_"+index+"']");
|
||||
var trs = $("tr[name^='dluo_'][name$='_"+index+"']"); /* trs.length = position of line for batch */
|
||||
var newrow=$row.html().replace(/_0_/g,"_"+(trs.length)+"_");
|
||||
$row.html(newrow);
|
||||
//clear value
|
||||
@@ -31,4 +37,13 @@ function addLineBatch(index) {
|
||||
//change name of row
|
||||
$row.attr('name','dluo_'+trs.length+'_'+index);
|
||||
$("tr[name^='dluo_'][name$='_"+index+"']:last").after($row);
|
||||
}
|
||||
|
||||
/* Suffix of lines are: _ trs.length _ index */
|
||||
jQuery("#lot_number_"+trs.length+"_"+index).focus();
|
||||
nb = jQuery("#qty_"+(trs.length - 1)+"_"+index).val();
|
||||
if (nb > 0)
|
||||
{
|
||||
jQuery("#qty_"+(trs.length - 1)+"_"+index).val(1);
|
||||
jQuery("#qty_"+trs.length+"_"+index).val(nb - 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -854,7 +854,7 @@ function confirmConstantAction(action, url, code, input, box, entity, yesButton,
|
||||
// remove invalid value, as it didnt match anything
|
||||
$( this ).val( "" );
|
||||
select.val( "" );
|
||||
input.data( "autocomplete" ).term = "";
|
||||
input.data("ui-autocomplete").term = "";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -862,8 +862,8 @@ function confirmConstantAction(action, url, code, input, box, entity, yesButton,
|
||||
})
|
||||
.addClass( "ui-widget ui-widget-content ui-corner-left dolibarrcombobox" );
|
||||
|
||||
input.data( "autocomplete" )._renderItem = function( ul, item ) {
|
||||
return $( "<li></li>" )
|
||||
input.data("ui-autocomplete")._renderItem = function( ul, item ) {
|
||||
return $("<li></li>")
|
||||
.data( "item.autocomplete", item )
|
||||
.append( "<a>" + item.label + "</a>" )
|
||||
.appendTo( ul );
|
||||
|
||||
@@ -40,11 +40,3 @@ function updateCoords(c)
|
||||
jQuery('#w').val(Math.ceil(c.w * ratio));
|
||||
jQuery('#h').val(Math.ceil(c.h * ratio));
|
||||
};
|
||||
|
||||
/* checkCoords */
|
||||
function checkCoords()
|
||||
{
|
||||
if (parseInt(jQuery('#w').val())) return true;
|
||||
alert('Please select a crop region then press submit.');
|
||||
return false;
|
||||
};
|
||||
|
||||
212
htdocs/core/js/timesheet.js
Normal file
212
htdocs/core/js/timesheet.js
Normal file
@@ -0,0 +1,212 @@
|
||||
/* Copyright (C) 2014 delcroip <delcroip@gmail.com>
|
||||
* Laurent Destailleur 2015 <eldy@users.sourceforge.net>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
/* Parse en input data for time entry into timesheet */
|
||||
function regexEvent(objet,evt,type)
|
||||
{
|
||||
console.log('regexEvent type='+type);
|
||||
switch(type)
|
||||
{
|
||||
case 'days':
|
||||
var regex= /^[0-9]{1}([.,]{1}[0-9]{1})?$/;
|
||||
|
||||
if(regex.test(objet.value) )
|
||||
{
|
||||
var tmp=objet.value.replace(',','.');
|
||||
if(tmp<=1.5){
|
||||
var tmpint=parseInt(tmp);
|
||||
if(tmp-tmpint>=0.5){
|
||||
objet.value= tmpint+0.5;
|
||||
}else{
|
||||
objet.value= tmpint;
|
||||
}
|
||||
}else{
|
||||
objet.value= '1.5';
|
||||
}
|
||||
}else{
|
||||
objet.value= '0';
|
||||
}
|
||||
break;
|
||||
case 'hours':
|
||||
var regex= /^[0-9]{1,2}:[0-9]{2}$/;
|
||||
var regex2=/^[0-9]{1,2}$/;
|
||||
if(!regex.test(objet.value))
|
||||
{
|
||||
if(regex2.test(objet.value))
|
||||
objet.value=objet.value+':00';
|
||||
else
|
||||
objet.value='';
|
||||
}
|
||||
/* alert(jQuery("#"+id).val()); */
|
||||
break;
|
||||
case 'timeChar':
|
||||
//var regex= /^[0-9:]{1}$/;
|
||||
//alert(event.charCode);
|
||||
var charCode = (evt.which) ? evt.which : event.keyCode;
|
||||
|
||||
if(((charCode >= 48) && (charCode <= 57)) || //num
|
||||
(charCode===46) || (charCode===8)||// comma & periode
|
||||
(charCode === 58) || (charCode==44) )// : & all charcode
|
||||
{
|
||||
// ((charCode>=96) && (charCode<=105)) || //numpad
|
||||
return true;
|
||||
|
||||
}else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function pad(n) {
|
||||
return (n < 10) ? ("0" + n) : n;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* function from http://www.timlabonne.com/2013/07/parsing-a-time-string-with-javascript/ */
|
||||
function parseTime(timeStr, dt)
|
||||
{
|
||||
if (!dt) {
|
||||
dt = new Date();
|
||||
}
|
||||
|
||||
var time = timeStr.match(/(\d+)(?::(\d\d))?\s*(p?)/i);
|
||||
if (!time) {
|
||||
return -1;
|
||||
}
|
||||
var hours = parseInt(time[1], 10);
|
||||
if (hours == 12 && !time[3]) {
|
||||
hours = 0;
|
||||
}
|
||||
else {
|
||||
hours += (hours < 12 && time[3]) ? 12 : 0;
|
||||
}
|
||||
|
||||
dt.setHours(hours);
|
||||
dt.setMinutes(parseInt(time[2], 10) || 0);
|
||||
dt.setSeconds(0, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Update total. days = column nb staring from 0 */
|
||||
function updateTotal(days,mode)
|
||||
{
|
||||
console.log('updateTotal days='+days+' mode='+mode);
|
||||
if(mode=="hours")
|
||||
{
|
||||
var total = new Date(0);
|
||||
total.setHours(0);
|
||||
total.setMinutes(0);
|
||||
var nbline = document.getElementById('numberOfLines').value;
|
||||
for (var i=0;i<nbline;i++)
|
||||
{
|
||||
var id='timespent['+i+']['+days+']';
|
||||
var taskTime= new Date(0);
|
||||
var element=document.getElementById(id);
|
||||
if(element)
|
||||
{
|
||||
/* alert(element.value);*/
|
||||
if (element.value)
|
||||
{
|
||||
result=parseTime(element.value,taskTime);
|
||||
}
|
||||
else
|
||||
{
|
||||
result=parseTime(element.innerHTML,taskTime);
|
||||
}
|
||||
if (result >= 0)
|
||||
{
|
||||
total.setHours(total.getHours()+taskTime.getHours());
|
||||
total.setMinutes(total.getMinutes()+taskTime.getMinutes());
|
||||
}
|
||||
}
|
||||
|
||||
var id='timeadded['+i+']['+days+']';
|
||||
var taskTime= new Date(0);
|
||||
var element=document.getElementById(id);
|
||||
if(element)
|
||||
{
|
||||
/* alert(element.value);*/
|
||||
if (element.value)
|
||||
{
|
||||
result=parseTime(element.value,taskTime);
|
||||
}
|
||||
else
|
||||
{
|
||||
result=parseTime(element.innerHTML,taskTime);
|
||||
}
|
||||
if (result >= 0)
|
||||
{
|
||||
total.setHours(total.getHours()+taskTime.getHours());
|
||||
total.setMinutes(total.getMinutes()+taskTime.getMinutes());
|
||||
}
|
||||
}
|
||||
}
|
||||
document.getElementById('totalDay['+days+']').innerHTML = pad(total.getHours())+':'+pad(total.getMinutes());
|
||||
//addText(,total.getHours()+':'+total.getMinutes());
|
||||
}
|
||||
else
|
||||
{
|
||||
var total =0;
|
||||
var nbline = document.getElementById('numberOfLines').value;
|
||||
for (var i=0;i<nbline;i++)
|
||||
{
|
||||
var id='timespent['+i+']['+days+']';
|
||||
var taskTime= new Date(0);
|
||||
var element=document.getElementById(id);
|
||||
if(element)
|
||||
{
|
||||
if (element.value)
|
||||
{
|
||||
total+=parseInt(element.value);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
total+=parseInt(element.innerHTML);
|
||||
}
|
||||
}
|
||||
|
||||
var id='timeadded['+i+']['+days+']';
|
||||
var taskTime= new Date(0);
|
||||
var element=document.getElementById(id);
|
||||
if(element)
|
||||
{
|
||||
if (element.value)
|
||||
{
|
||||
total+=parseInt(element.value);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
total+=parseInt(element.innerHTML);
|
||||
}
|
||||
}
|
||||
}
|
||||
document.getElementById('totalDay['+days+']').innerHTML = total;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user