/** * 串联单生成节目单 * $channel_id 频道id * $dates 日期 * $theme 节目 * $id 串联单id * Enter description here ... */ public function schedule2program() { $channel_id = intval($this->input['channel_id']); $dates = trim($this->input['dates']); $id = $this->input['ids']; $theme = $this->input['theme']; if (!$channel_id) { $this->errorOutput('未传入频道id'); } if (!$dates) { $this->errorOutput('未传入日期'); } if (empty($id)) { $this->errorOutput('未传入串联单id'); } foreach ($id as $k => $v) { if (!$v) { $this->errorOutput('串联单id不能为空'); } } $schedule_field = 'id, start_time, toff'; $schedule = $this->mSchedule->get_schedule_info_by_id(implode(',', $id), $schedule_field); if (empty($schedule)) { $this->errorOutput($dates . '串联单不存在或已删除'); } $schdeule_info = array(); foreach ($schedule as $v) { $schdeule_info[$v['id']] = $v; } require_once ROOT_PATH . 'lib/class/program.class.php'; $mProgram = new program(); if (!$mProgram) { $this->errorOutput('节目单应用没有安装'); } if (!$this->settings['App_program']) { $this->errorOutput('节目单应用没有安装'); } $delete_data = array('channel_id' => $channel_id, 'dates' => $dates); $ret_delete = $mProgram->delete_by_channel_id($delete_data); if (!$ret_delete) { $this->errorOutput('删除已有的节目单失败'); } $start_time = $end_time = $_theme = array(); $tmp_toff = 0; $i = 0; foreach ($id as $k => $v) { $tmp_toff += $schdeule_info[$v]['toff']; if ($tmp_toff >= $this->settings['schedule2program_min_toff'] * 60) { $start_time[$i] = strtotime(date('Y-m-d H:i', $schdeule_info[$v]['start_time'])); $end_time[$i] = strtotime(date('Y-m-d H:i', $schdeule_info[$v]['start_time'])) + $schdeule_info[$v]['toff']; $_theme[$i] = $theme[$k]; $tmp_toff = 0; $i++; } } $program_data = array('channel_id' => $channel_id, 'dates' => $dates, 'schedule_id' => implode(',|', $id), 'start_time' => implode(',|', $start_time), 'end_time' => implode(',|', $end_time), 'theme' => implode(',|', $_theme)); $return = $mProgram->schedule2program($program_data); $this->addItem($return); $this->output(); }