public function add() { //ProjectId,Memo,CreateTime,UserId,Hours1,Ratio,Hours2 $res = array(); $hours = new Hours(); $hours->ProjectId = $this->ProjectId; $hours->Memo = $this->Memo; $hours->Hours1 = $this->Hours1; $hours->CreateTime = date('Y-m-d H:i:s'); $hours->WorkDate = $this->WorkDate; $hours->UserId = $this->UserId; $hours->Ratio = 0; $hours->Hours2 = 0; $result = $hours->add(); if ($result > 0) { if ($this->Schedule > 0) { $project = new Project(); $project->setValue($this->ProjectId); $project->Schedule = $this->Schedule; $project->update(); } $res['Success'] = true; $res['Message'] = "工时登记成功"; $res['NewId'] = $result; } else { $res['Success'] = false; $res['Message'] = "工时登记失败,请联系技术部"; } echo json_encode($res); exit; }