public function addPlans($plans, $repid, $begindate, $enddate, $uid, $type, $exedetail = "") { foreach ($plans as $plan) { $remindDate = empty($plan["reminddate"]) ? 0 : strtotime($plan["reminddate"]); $record = array("repid" => $repid, "content" => StringUtil::filterCleanHtml($plan["content"]), "uid" => $uid, "flag" => isset($plan["process"]) && $plan["process"] == 10 ? 1 : 0, "planflag" => $type, "process" => isset($plan["process"]) ? $plan["process"] : 0, "exedetail" => StringUtil::filterCleanHtml($exedetail), "begindate" => $begindate, "enddate" => $enddate, "reminddate" => $remindDate); $rid = $this->add($record, true); $isInstallCalendar = ModuleUtil::getIsEnabled("calendar"); if ($isInstallCalendar && $remindDate) { $calendar = array("subject" => $record["content"], "starttime" => $remindDate, "endtime" => $remindDate, "uid" => $uid, "upuid" => $uid, "lock" => 1, "category" => 4, "isalldayevent" => 1); $cid = Calendars::model()->add($calendar, true); CalendarRepRecord::model()->add(array("rid" => $rid, "cid" => $cid, "repid" => $repid)); } } }
private function loadNewSchedules() { $uid = Yii::app()->user->uid; $st = time(); $schedules = Calendars::model()->fetchNewSchedule($uid, $st); if (!empty($schedules)) { foreach ($schedules as $k => $schedule) { $schedules[$k]["dateAndWeekDay"] = CalendarUtil::getDateAndWeekDay(date("Y-m-d", $schedule["starttime"])); $schedules[$k]["category"] = Calendars::model()->handleColor($schedule["category"]); $schedules[$k]["cutSubject"] = StringUtil::cutStr($schedule["subject"], 30); } } return $schedules; }
public function addRecord($plan, $diaryId, $planTime, $uid, $type) { foreach ($plan as $value) { $diaryRecord = array("diaryid" => $diaryId, "content" => htmlspecialchars($value["content"]), "planflag" => $type == "outside" ? 0 : 1, "schedule" => isset($value["schedule"]) ? $value["schedule"] : 0, "plantime" => $planTime, "flag" => isset($value["schedule"]) && $value["schedule"] == 10 ? 1 : 0, "uid" => $uid, "timeremind" => isset($value["timeremind"]) ? $value["timeremind"] : ""); $rid = $this->add($diaryRecord, true); $isInstallCalendar = ModuleUtil::getIsEnabled("calendar"); if ($isInstallCalendar && isset($value["timeremind"]) && !empty($value["timeremind"])) { $timeArr = explode(",", $value["timeremind"]); $st = $planTime + $timeArr[0] * 60 * 60; $et = $planTime + $timeArr[1] * 60 * 60; $calendar = array("subject" => $diaryRecord["content"], "starttime" => $st, "endtime" => $et, "uid" => $uid, "upuid" => $uid, "lock" => 1, "category" => 3, "isfromdiary" => 1); $cid = Calendars::model()->add($calendar, true); CalendarRecord::model()->add(array("rid" => $rid, "cid" => $cid, "did" => $diaryId)); } } }
protected function remind($assignmentId) { if (EnvUtil::submitCheck("remindsubmit")) { if ($this->getIsInstallCalendar()) { $uid = Ibos::app()->user->uid; $remindTime = strtotime(EnvUtil::getRequest("remindTime")); $remindContent = EnvUtil::getRequest("remindContent"); $calendar = array("subject" => $remindContent, "starttime" => $remindTime, "endtime" => $remindTime + 1800, "uid" => $uid, "upuid" => $uid, "lock" => 1, "category" => 5); $oldCalendarids = AssignmentRemind::model()->fetchCalendarids($assignmentId, $uid); Calendars::model()->deleteAll(sprintf("uid = %d AND FIND_IN_SET(`calendarid`, '%s')", $uid, implode(",", $oldCalendarids))); $cid = Calendars::model()->add($calendar, true); AssignmentRemind::model()->deleteAll("assignmentid = {$assignmentId} AND uid = {$uid}"); AssignmentRemind::model()->add(array("assignmentid" => $assignmentId, "calendarid" => $cid, "remindtime" => $remindTime, "uid" => $uid, "content" => $remindContent)); $this->ajaxReturn(array("isSuccess" => true, "msg" => Ibos::lang("Operation succeed", "message"))); } else { $this->ajaxReturn(array("isSuccess" => false, "msg" => Ibos::lang("Not installed calendar to support remind"))); } } else { $remind = AssignmentRemind::model()->fetch(sprintf("uid = %d AND assignmentid = %d", Ibos::app()->user->uid, $assignmentId)); $remindtime = empty($remind) ? TIMESTAMP : $remind["remindtime"]; $params = array("reminddate" => date("Y-m-d", $remindtime), "remindtime" => date("H:i", $remindtime), "content" => empty($remind) ? "" : $remind["content"], "lang" => Ibos::getLangSource("assignment.default")); $remindAlias = "application.modules.assignment.views.default.remind"; $editView = $this->renderPartial($remindAlias, $params, true); echo $editView; } }
public function actionDel() { if (Ibos::app()->request->isAjaxRequest) { $repids = EnvUtil::getRequest("repids"); $uid = Ibos::app()->user->uid; if (empty($repids)) { $this->error(Ibos::lang("Parameters error", "error"), $this->createUrl("default/index")); } $pk = ""; if (strpos($repids, ",")) { $repids = trim($repids, ","); $pk = explode(",", $repids); } else { $pk = array($repids); } $reports = Report::model()->fetchAllByPk($pk); foreach ($reports as $report) { if ($report["uid"] != $uid) { $this->ajaxReturn(array("isSuccess" => false, "msg" => Ibos::lang("You do not have permission to delete the report"))); } } $aids = Report::model()->fetchAllAidByRepids($pk); if ($aids) { AttachUtil::delAttach($aids); } $isInstallCalendar = ModuleUtil::getIsEnabled("calendar"); if ($isInstallCalendar) { Calendars::model()->deleteALL("`calendarid` IN(select `cid` from {{calendar_rep_record}} where FIND_IN_SET(`repid`, '{$repids}')) "); CalendarRepRecord::model()->deleteAll("repid IN ({$repids})"); } $delSuccess = Report::model()->deleteByPk($pk); if ($delSuccess) { ReportRecord::model()->deleteAll("repid IN('{$repids}')"); ReportStats::model()->deleteAll("repid IN ({$repids})"); $this->ajaxReturn(array("isSuccess" => true, "msg" => Ibos::lang("Del succeed", "message"))); } else { $this->ajaxReturn(array("isSuccess" => false, "msg" => Ibos::lang("Del failed", "message"))); } } }
private function delCalendarByTaskid($taskid) { $schedule = Calendars::model()->fetchByAttributes(array("taskid" => $taskid)); if (!empty($schedule)) { Calendars::model()->remove($schedule["calendarid"]); } }
private function checkEqLoop($calendarid) { $subrow = Calendars::model()->fetchByPk($calendarid); if ($subrow["masterid"] != 0) { $mstrow = Calendars::model()->fetchByPk($subrow["masterid"]); if ($mstrow) { $subject = $subrow["subject"] == $mstrow["subject"] ? true : false; $category = $subrow["category"] == $mstrow["category"] ? true : false; $location = $subrow["location"] == $mstrow["location"] ? true : false; $status = $subrow["status"] == $mstrow["status"] ? true : false; $starttimeed = $subrow["starttime"] == strtotime($subrow["mastertime"] . " " . date("H:i:s", $mstrow["starttime"])) ? true : false; $endtimeed = $subrow["endtime"] == strtotime($subrow["mastertime"] . " " . date("H:i:s", $mstrow["endtime"])) ? true : false; if ($subject && $category && $location && $status && $starttimeed && $endtimeed) { Calendars::model()->remove($calendarid); return "-" . strtotime($subrow["mastertime"] . " " . date("H:i:s", $mstrow["starttime"])) . $subrow["masterid"]; } else { return false; } } } }
private function planFromSchedule() { if (Ibos::app()->request->isAjaxRequest) { $uid = Ibos::app()->user->uid; $todayDate = $_GET["todayDate"]; $st = intval(strtotime($todayDate)); $et = $st + 24 * 60 * 60 - 1; $calendars = Calendars::model()->listCalendarByRange($st, $et, $uid); $plans = $calendars["events"]; foreach ($plans as $k => $v) { $plans[$k]["schedule"] = $v["status"] ? self::COMPLETE_FALG : 0; if ($v["isfromdiary"]) { unset($plans[$k]); } } $this->ajaxReturn(array_values($plans)); } }
public function actionDel() { if (!Yii::app()->request->getIsAjaxRequest()) { $this->error(IBos::lang("Parameters error", "error"), $this->createUrl("schedule/index")); } $delCalendarid = EnvUtil::getRequest("delCalendarid"); if (empty($delCalendarid)) { $this->error(Ibos::lang("Parameters error", "error")); } $delArr = explode(",", $delCalendarid); foreach ($delArr as $calendarid) { Calendars::model()->remove($calendarid); } $ret["isSuccess"] = true; $this->ajaxReturn($ret); }
protected function removeLoopCalendar($id, $type, $doption, $starttime) { $ret = array(); $isSuccess = ""; switch ($type) { case "1": switch ($doption) { case "only": $sid = $this->createSubCalendar($id, $starttime, $starttime, time(), "", -1, 3); if ($sid) { $ret["isSuccess"] = true; } else { $ret["isSuccess"] = false; } return $ret; case "after": $endday = explode(" ", $starttime); $endday = strtotime($endday[0]) - 24 * 60 * 60; $isSuccess = Calendars::model()->modify($id, array("recurringend" => $endday)); if ($isSuccess) { Calendars::model()->deleteAll(array("condition" => "masterid = :masterid AND starttime > :starttime", "params" => array(":masterid" => $id, ":starttime" => strtotime($starttime)))); } break; case "all": $isSuccess = Calendars::model()->remove($id); if ($isSuccess) { Calendars::model()->deleteAll(array("condition" => "masterid = :masterid", "params" => array(":masterid" => $id))); } break; } break; case "2": $isSuccess = Calendars::model()->modify($id, array("status" => 3)); break; } if ($isSuccess) { $ret["isSuccess"] = true; } else { $ret["isSuccess"] = false; } return $ret; }
public function updateCalendar($id, $complete) { $schedule = Calendars::model()->fetchByAttributes(array("taskid" => $id)); if ($complete) { $st = TIMESTAMP - 3600; $et = TIMESTAMP; if (!empty($schedule)) { Calendars::model()->modify($schedule["calendarid"], array("status" => 1, "starttime" => $st, "endtime" => $et, "isalldayevent" => 0)); } else { $calendar = $this->handleCompTaskCalendar($id, $st, $et); Calendars::model()->add($calendar); } } elseif (!empty($schedule)) { Calendars::model()->modify($schedule["calendarid"], array("status" => 3)); } }
<?php $row = cron::model()->fetch(array("select" => "`lastrun`,`nextrun`", "condition" => "filename = :filename", "params" => array(":filename" => basename(__FILE__)))); $clist = Calendars::model()->listCalendarByRange($row["lastrun"], $row["nextrun"] + 86400 * 3); foreach ($clist["events"] as $calendar) { if ($calendar["isalldayevent"] == 1) { $start_date = date("Y-m-d", $calendar["starttime"]); $remind_date_min = $start_date . " 07:59:00"; $remind_date_max = $start_date . " 10:01:00"; $remind_time_min = strtotime($remind_date_min); $remind_time_max = strtotime($remind_date_max); if ($remind_time_min < time() && time() < $remind_time_max) { $stime = date("m-d", $calendar["starttime"]); $title = $stime . "全天日程"; $subject = StringUtil::cutStr($calendar["subject"], 20); $config = array("{subject}" => $subject, "{url}" => Ibos::app()->urlManager->createUrl("calendar/schedule/index")); Notify::model()->sendNotify($calendar["uid"], "calendar_message", $config); } } elseif ($calendar["starttime"] <= $row["nextrun"]) { $stime = date("m-d H:i", $calendar["starttime"]); $etime = date("m-d H:i", $calendar["endtime"]); $title = $stime . " 至 " . $etime . "日程"; $subject = StringUtil::cutStr($calendar["subject"], 20); $config = array("{subject}" => $subject, "{url}" => Ibos::app()->urlManager->createUrl("calendar/schedule/index")); Notify::model()->sendNotify($calendar["uid"], "calendar_message", $config); } }
public function actionDel() { if (Ibos::app()->request->isAjaxRequest) { $assignmentId = intval(EnvUtil::getRequest("id")); $checkRes = $this->checkAvailableById($assignmentId); if (!$checkRes["isSuccess"]) { $this->ajaxReturn($checkRes); } $assignment = Assignment::model()->fetchByPk($assignmentId); $uid = Ibos::app()->user->uid; if ($uid != $assignment["designeeuid"]) { $this->ajaxReturn(array("isSuccess" => false, "msg" => Ibos::lang("You donot have permission to delete"))); } if (!empty($assignment["attachmentid"])) { AttachUtil::delAttach($assignment["attachmentid"]); } if ($this->getIsInstallCalendar() && !empty($assignment["remindtime"])) { Calendars::model()->deleteALL("`calendarid` IN(select `calendarid` from {{assignment_remind}} where assignmentid = {$assignmentId}) "); AssignmentRemind::model()->deleteAll("assignmentid = {$assignmentId}"); } AssignmentLog::model()->addLog($assignmentId, "del", Ibos::lang("Delete the assignment")); Assignment::model()->deleteByPk($assignmentId); AssignmentApply::model()->deleteAll("assignmentid = {$assignmentId}"); $this->ajaxReturn(array("isSuccess" => true, "msg" => Ibos::lang("Del succeed", "message"))); } }