Id()) { // Saving a report that failed to load would insert a new row ZM\Warning('Report '.$_REQUEST['id'].' not found'); $redirect = '?view=reports'; return; } if ($report->Id() and !$report->canEdit()) { ZM\Warning('You do not have permission to edit report '.$report->Id()); $redirect = '?view=reports'; return; } if ($action == 'save') { $changes = $report->changes(isset($_REQUEST['Report']) && is_array($_REQUEST['Report']) ? $_REQUEST['Report'] : array()); if (!$report->Id()) { $changes['CreatedBy'] = $user->Id(); } if (count($changes)) { if (!$report->save($changes)) { $error_message .= "Error saving report: " . $report->get_last_error().'
'; } else { $redirect = '?view=report&id='.$report->Id(); } } } else if ($action == 'delete') { $report->delete(); $redirect = '?view=reports'; } else { ZM\Error("Unknown action $action in saving Report"); } ?>