* finish task #2284.

This commit is contained in:
wangyidong
2015-09-02 13:33:03 +08:00
parent bf21838118
commit fd11ead66a
2 changed files with 36 additions and 1 deletions

View File

@@ -0,0 +1,31 @@
/**
* Convert a date string like 2011-11-11 to date object in js.
*
* @param string $date
* @access public
* @return date
*/
function convertStringToDate(dateString)
{
dateString = dateString.split('-');
dateString = dateString[1] + '/' + dateString[2] + '/' + dateString[0];
return Date.parse(dateString);
}
/**
* Compute the end date for productplan.
*
* @param int $delta
* @access public
* @return void
*/
function computeEndDate(delta)
{
beginDate = $('#begin').val();
if(!beginDate) return;
endDate = convertStringToDate(beginDate).addDays(parseInt(delta));
endDate = endDate.toString('yyyy-M-dd');
$('#end').val(endDate);
}

View File

@@ -13,6 +13,7 @@
<?php include '../../common/view/header.html.php';?>
<?php include '../../common/view/datepicker.html.php';?>
<?php include '../../common/view/kindeditor.html.php';?>
<?php js::import($jsRoot . 'misc/date.js');?>
<div class='container mw-1400px'>
<div id='titlebar'>
<div class='heading'>
@@ -33,11 +34,14 @@
</tr>
<tr>
<th><?php echo $lang->productplan->begin;?></th>
<td><?php echo html::input('begin', $plan->begin, 'class="form-control form-date"');?></td>
<td><?php echo html::input('begin', $plan->begin, "class='form-control form-date'");?></td>
</tr>
<tr>
<th><?php echo $lang->productplan->end;?></th>
<td><?php echo html::input('end', $plan->end, 'class="form-control form-date"');?></td>
<td>
&nbsp; &nbsp; <?php echo html::radio('delta', $lang->productplan->endList , '', "onclick='computeEndDate(this.value)'");?>
</td>
</tr>
<tr>
<th><?php echo $lang->productplan->desc;?></th>