diff --git a/module/execution/control.php b/module/execution/control.php index 253c136057..82d5967aeb 100644 --- a/module/execution/control.php +++ b/module/execution/control.php @@ -1389,6 +1389,7 @@ class execution extends control if(date("Y-m-d", strtotime("-3 months", strtotime($end))) > $begin) return $this->sendError($this->lang->execution->charts->cfd->errorDateRange); $this->execution->computeCFD($executionID); + $this->execution->checkCFDData($executionID, $begin); return print(js::locate($this->createLink('execution', 'cfd', "executionID=$executionID&type=$type&withWeekend=$withWeekend&begin=" . helper::safe64Encode(urlencode($begin)) . "&end=" . helper::safe64Encode(urlencode($end))), 'parent')); } diff --git a/module/execution/js/cfd.js b/module/execution/js/cfd.js index 6e660db934..a15f5c8b2a 100644 --- a/module/execution/js/cfd.js +++ b/module/execution/js/cfd.js @@ -138,5 +138,5 @@ $(function() }); $("#end, #begin").datetimepicker('setEndDate', today) - $('.datetimepicker-days table tfoot tr th').html(dateRangeTip).removeClass('today'); + $('.datetimepicker-days table tfoot').append('' + dateRangeTip + ''); }); diff --git a/module/execution/model.php b/module/execution/model.php index 6d8dff648e..c628c87878 100644 --- a/module/execution/model.php +++ b/module/execution/model.php @@ -3072,6 +3072,42 @@ class executionModel extends model } } + /** + * Check whether there is data on the specified date of execution, and there is no data with the latest date added. + * + * @param int $executionID + * @param string $date + * @access public + * @return void + */ + public function checkCFDData($executionID, $date) + { + $today = helper::today(); + if($date >= $today) return; + + $checkData = $this->dao->select("date, `count` AS value, `name`")->from(TABLE_CFD) + ->where('execution')->eq((int)$executionID) + ->andWhere('date')->eq($date) + ->orderBy('date DESC, id asc')->fetchGroup('name', 'date'); + if(!$checkData) + { + $closetoDate = $this->dao->select("max(date) as date")->from(TABLE_CFD)->where('execution')->eq((int)$executionID)->andWhere('date')->lt($date)->fetch('date'); + if($closetoDate) + { + $copyData = $this->dao->select("*")->from(TABLE_CFD) + ->where('execution')->eq((int)$executionID) + ->andWhere('date')->eq($closetoDate) + ->fetchAll(); + foreach($copyData as $data) + { + unset($data->id); + $data->date = $date; + $this->dao->replace(TABLE_CFD)->data($data)->exec(); + } + } + } + } + /** * Fix burn for first day. *