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)); } } }
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"))); } } }