* code for task#1534.

This commit is contained in:
chencongzhi520@gmail.com
2013-07-15 08:43:26 +00:00
parent 348e0577c8
commit 5c29ce162a
2 changed files with 28 additions and 11 deletions
+26 -9
View File
@@ -24,9 +24,7 @@ function switchGroup(projectID, groupBy)
function convertStringToDate(dateString)
{
dateString = dateString.split('-');
dateString = dateString[1] + '/' + dateString[2] + '/' + dateString[0];
return Date.parse(dateString);
return new Date(dateString[0], dateString[1] - 1, dateString[2]);
}
/**
@@ -60,17 +58,36 @@ function computeDaysDelta(date1, date2)
* @access public
* @return void
*/
function computeWorkDays()
function computeWorkDays(currentID)
{
beginDate = $('#begin').val();
endDate = $('#end').val();
isBactchEdit = false;
if(currentID)
{
index = currentID.replace('begins[', '');
index = index.replace('ends[', '');
index = index.replace(']', '');
if(!isNaN(index)) isBactchEdit = true;
}
if(isBactchEdit)
{
beginDate = $('#begins\\[' + index + '\\]').val();
endDate = $('#ends\\[' + index + '\\]').val();
}
else
{
beginDate = $('#begin').val();
endDate = $('#end').val();
}
if(beginDate && endDate)
{
$('#days').val(computeDaysDelta(beginDate, endDate));
if(isBactchEdit) $('#dayses\\[' + index + '\\]').val(computeDaysDelta(beginDate, endDate));
if(!isBactchEdit) $('#days').val(computeDaysDelta(beginDate, endDate));
}
else if($('input[checked="true"]').val())
{
computeEndDate();
computeEndDate();
}
}
@@ -98,6 +115,6 @@ $(function()
setModal4List('iframe', 'taskList');
$(".date").bind('dateSelected', function()
{
computeWorkDays();
computeWorkDays(this.id);
})
});
+2 -2
View File
@@ -31,8 +31,8 @@
<td><?php echo html::input("codes[$projectID]", $projects[$projectID]->code, "class='text-1'");?></td>
<td><?php echo html::select("PMs[$projectID]", $pmUsers, $projects[$projectID]->PM, 'class=text-1');?></td>
<td><?php echo html::select("statuses[$projectID]", $lang->project->statusList, $projects[$projectID]->status, 'class=text-1');?></td>
<td><?php echo html::input("begins[$projectID]", $projects[$projectID]->begin, "class='text-1 date'");?></td>
<td><?php echo html::input("ends[$projectID]", $projects[$projectID]->end, "class='text-1 date'");?></td>
<td><?php echo html::input("begins[$projectID]", $projects[$projectID]->begin, "class='text-1 date' onchange='computeWorkDays(this.id)'");?></td>
<td><?php echo html::input("ends[$projectID]", $projects[$projectID]->end, "class='text-1 date' onchange='computeWorkDays(this.id)'");?></td>
<td><?php echo html::input("dayses[$projectID]", $projects[$projectID]->days, "class='w-100px'") . $lang->project->day;?></td>
</tr>
<?php endforeach;?>