Exemple #1
0
 public function updateSchedule($id, App_PeopleSchedule_Dm $dm)
 {
     return $this->_loadPeopleScheduleDao()->update($id, $dm->getData());
 }
 public function changeScheduleAction()
 {
     $changeShopId = $this->getInput("changeShopId", "post");
     $changeScheduleId = $this->getInput("changeScheduleId", "post");
     $orderChangefor = $this->getInput("orderChangefor", "post");
     $splitTime = $this->getInput("splitTime", "post");
     $returnData = array("success" => true, "data" => "更新成功");
     $schoolId = $this->getCurrentSchoolId();
     if (empty($splitTime)) {
         $returnData['success'] = false;
         $returnData['data'] = '分割时间请进行更改';
         print_r(json_encode($returnData));
         die;
     }
     if (empty($changeScheduleId)) {
         $returnData['success'] = false;
         $returnData['data'] = '无效的计划号';
         print_r(json_encode($returnData));
         die;
     }
     if (empty($orderChangefor)) {
         $returnData['success'] = false;
         $returnData['data'] = '请选择人员';
         print_r(json_encode($returnData));
         die;
     }
     //get schedule time
     $scheduleInfo = $this->_getSchoolPeopleDS()->getPeopleScheduleById($changeScheduleId);
     if (empty($scheduleInfo)) {
         $returnData['success'] = false;
         $returnData['data'] = $changeScheduleId;
         //'查不到相关的计划';
         print_r(json_encode($returnData));
         die;
     }
     //加上日期
     $fromDateArray = getdate(strtotime($scheduleInfo['datetimeBegin']));
     $theday = $fromDateArray['year'] . "-" . $fromDateArray['mon'] . "-" . $fromDateArray['mday'];
     $splitTime = $theday . " " . $splitTime;
     if (strtotime($scheduleInfo['datetimeBegin']) > strtotime($splitTime) || strtotime($scheduleInfo['datetimeEnd']) < strtotime($splitTime)) {
         $returnData['success'] = false;
         $returnData['data'] = "填写的分割时间需要在被分割的中间";
         // '填写的分割时间需要在被分割的中间';
         print_r(json_encode($returnData));
         die;
     }
     Wind::import('EXT:4tschool.service.schoolpeople.dm.App_PeopleSchedule_Dm');
     $dmitem = new App_PeopleSchedule_Dm();
     $dmitem->setSchool($schoolId)->setUserid($orderChangefor)->setType(1)->setActionBy($this->loginUser->uid)->setShopId($changeShopId)->setDateTimeBegin($splitTime)->setDateTimeEnd($scheduleInfo['datetimeEnd']);
     $generatedId = $this->_getSchoolPeopleDS()->saveSchedule($dmitem);
     if ($generatedId > 0) {
         Wind::import('EXT:4tschool.service.schoolpeople.dm.App_PeopleSchedule_Dm');
         $dmupdateitem = new App_PeopleSchedule_Dm();
         $dmupdateitem->setDateTimeBegin($scheduleInfo['datetimeBegin'])->setDateTimeEnd($splitTime);
         $this->_getSchoolPeopleDS()->updateSchedule($changeScheduleId, $dmupdateitem);
     }
     print_r(json_encode($returnData));
     die;
 }