function savereport_POST(Web &$w) { $w->Report->navigation($w, "Create Report"); // get type of statement: select/insert/update/delete $_POST['sqltype'] = $w->Report->getSQLStatementType($_POST['report_code']); // insert report into database $report = new Report($w); $report->fill($_POST); $report->insert(); // if insert successful, make creator a MEMBER of this report if ($report->id) { $arr['report_id'] = $report->id; $arr['user_id'] = $w->session('user_id'); $mem = new ReportMember($w); $mem->fill($arr); $mem->insert(); } $w->msg("Report created", "/report/index/"); }
public function addAction() { if ($_POST['sToken'] != Helper::getStoken()) { return $this->alert('sToken 錯誤', '/'); } try { $this->_checkReportData($_POST); } catch (Exception $e) { return $this->alert($e->getMessage(), '/'); } if ($report = Report::find_by_news_link($_POST['news_link'])) { return $this->alert('這個連結已經被人回報過了,將會把您導向該回報去', '/index/log/' . $report->id); } if ($normaled_news_link = URLNormalizer::query($_POST['news_link']) and $report = Report::find_by_news_link_unique($normaled_news_link->normalized_id)) { return $this->alert('這個連結已經被人回報過了,將會把您導向該回報去', '/index/log/' . $report->id); } $now = time(); $report = Report::insert(array('news_title' => strval($_POST['news_title']), 'news_link' => strval($_POST['news_link']), 'news_link_unique' => $normaled_news_link ? $normaled_news_link->normalized_id : '', 'report_title' => strval($_POST['report_title']), 'report_link' => strval($_POST['report_link']), 'created_at' => $now, 'updated_at' => $now)); ReportChangeLog::insert(array('report_id' => $report->id, 'updated_at' => $now, 'updated_from' => intval(ip2long($_SERVER['REMOTE_ADDR'])), 'updated_by' => strval($this->view->user->user_id), 'old_values' => '', 'new_values' => json_encode($report->toArray()))); return $this->alert('新增成功', '/index/log/' . $report->id); }
function insertMultipeReports() { // This creates multiple reports and saves them global $tool, $form, $report_types; $from = $_POST['date1']; $to = $_POST['date2']; $name = $_POST['name']; if ($name == '') { $form->warning("Invalid Name, can not be empty"); return false; } // Check From date if (is_numeric($from) && date($from)) { $start_stamp = date($from); } elseif ($from != '' && strtotime($from)) { $start_stamp = strtotime($from); } else { $form->warning("Invalid start date {$from}"); return false; } // Check To date if (is_numeric($to) && date($to)) { $end_stamp = date($to); } elseif ($to != '' && strtotime($to)) { $end_stamp = strtotime($to); } else { $form->warning("Invalid End date {$to}"); return false; } flush(); $i = 1; $total = count($_POST[profile_id]); print "<p><b>Creating {$total} reports for {$name}, please be patient as this may take a few minutes<br></p></b>"; flush(); foreach ($_POST[profile_id] as $profile_id) { $profile = new CheckReportProfile($profile_id); print "creating report {$i} of {$total}: " . $profile->get_name() . " Type (" . $profile->get_report_type() . ").<br>"; flush(); $report_checks = array(); foreach ($profile->get_checks() as $check_id => $check_name) { array_push($report_checks, $check_id); } $report_type = $profile->get_report_type(); $timers = get_report_data($start_stamp, $end_stamp, $report_type, $report_checks); $report = new Report(); $report->set_name($name); $report->set_profile_id($profile_id); $report->set_report_type($profile->get_report_type()); $report->set_start_time($from); $report->set_end_time($to); $report->set_ok_secs($timers[ok]); $report->set_warning_secs($timers[warning]); $report->set_critical_secs($timers[critical]); $report->set_unknown_secs($timers[unknown]); $report->set_other_secs($timers[other]); $report->set_no_data_secs($timers[no_data]); $new_id = $report->insert(); if (is_numeric($new_id)) { //print "new is is $new_id<br>"; } else { print "insert failed! reason: " . $report->get_error() . "<br>"; } $i++; } print "<br><br>Done! You're reports are available here: <a href='" . $_SERVER['PHP_SELF'] . "?action=display_reports_by_name&name={$name}'> Availability Report {$name}</a><br>"; }