function do_save_new_schedules($f3, $args) { $allData = json_decode(f3()->get('SESSION.uploadPrograms'), true); db()->begin(); foreach ($allData['schedules'] as $prog) { $program = Program::get_program_by_codename($prog['c']); if (empty($program)) { $program['title'] = $prog['c']; $program['uri'] = ''; $program['id'] = 0; } db()->exec("INSERT INTO `" . tpf() . "schedules`(`title`, `uri`, `program_id`, `start_date`, `end_date`, `status`, `last_ts`, " . "`last_user`, `insert_user`, `insert_ts`) VALUES ('" . $program['title'] . "', '" . $program['uri'] . "', '" . $program['id'] . "', '" . $prog['d'] . " " . $prog['s'] . ":00', '" . $prog['d'] . " " . $prog['e'] . ":00', 'Yes', '" . date('Y-m-d H:i:s') . "', '" . rStaff::_CStaff('id') . "', '" . rStaff::_CStaff('id') . "', '" . date('Y-m-d H:i:s') . "')"); } db()->commit(); return parent::_return(1, $allData['schedules']); }
static function insert($req) { $now = date('Y-m-d H:i:s'); $obj = self::map(); $obj->insert_ts = $now; $obj->insert_user = rStaff::_CStaff('id'); $obj->last_ts = $now; $obj->last_user = rStaff::_CStaff('id'); $obj->status = self::ST_ON; $obj->title = $title; $obj->pic = $filename; $obj->slug = '/' . parent::_slugify($title); $obj->save(); return $obj->id; }