/** * lrs/{id}/reporting/create * * This test case create new reporting and run report * * It is ensure reporting work correctly. * */ public function testRouterReportCreate() { for ($i = 0; $i < 7; $i++) { $vs = $this->defaultStatment(); $this->statements[] = $this->createStatement($vs, $this->lrs); } $data = array('description' => \app\locker\helpers\Helpers::getRandomValue(), 'name' => '', 'lrs' => $this->lrs->_id, 'query' => array('statement.actor.mbox' => array("mailto:duy.nguyen@go1.com.au"), 'statement.verb.id' => array("http://adlnet.gov/expapi/verbs/experienced"))); //lrs input validation $rules['name'] = 'required|alpha_spaces'; $rules['description'] = 'alpha_spaces'; $validator = Validator::make($data, $rules); $this->assertTrue($validator->fails()); $data['name'] = 'reportabcd'; $data['description'] = 'reportabcd description'; $validator = Validator::make($data, $rules); $this->assertTrue($validator->passes()); // create report. $report = new Report(); $report->lrs = $data['lrs']; $report->query = $data['query']; $report->name = $data['name']; $report->description = $data['description']; $save = $report->save(); $this->assertTrue($save); // Ensure report show in reporting page. $crawler = $this->client->request('GET', "/lrs/{$this->lrs->_id}/reporting"); $this->assertGreaterThan(0, $crawler->filter('html:contains("reportabcd")')->count()); $this->assertGreaterThan(0, $crawler->filter('html:contains("reportabcd description")')->count()); $crawler = $this->client->request('GET', "/lrs/{$this->lrs->_id}/reporting/show/{$report->_id}"); $this->assertGreaterThan(0, $crawler->filter('html:contains("Number of statements")')->count()); $this->assertGreaterThan(0, $crawler->filter('html:contains("7")')->count()); // Delete report by router. $crawler = $this->client->request('DELETE', "/lrs/{$this->lrs->_id}/reporting/delete/{$report->_id}"); $this->assertEquals(Report::find($report->_id), NULL); }
/** * Store a newly created resource in storage. * * @return Response */ public function store() { $imageurl = ''; if (Request::get('image') != '') { $imageurl = "/images/report/trafficjam_" . time() . ".jpg"; $base = Request::get('image'); $binary = base64_decode($base); $ifp = fopen($imageurl, "wb"); fwrite($ifp, $binary); fclose($ifp); $imageurl = 'http://125.62.200.54/traffic/' . $imageurl; } $trafficJam = TrafficJam::create(array('user' => Request::get('user'), 'latitude' => Request::get('lat'), 'longitude' => Request::get('lng'), 'clear_by' => RestApi::clearBy(Request::get('status')), 'time' => date('g:iA', time()), 'date' => date('M j', time()), 'status' => Request::get('status'), 'reason' => Request::get('reason'), 'image_url' => $imageurl)); $report = new Report(); $report->traffic_jam_id = $trafficJam->id; $report->user = Request::get('user'); $report->latitude = Request::get('lat'); $report->longitude = Request::get('lng'); $report->time = date('g:i A', time()); $report->date = date('M j', time()); $report->clear_by = RestApi::clearBy(Request::get('status')); $report->description = "There is a " . Request::get('status') . " traffic jam at " . RestApi::getaddress(Request::get('lat'), Request::get('lng')) . " due to " . Request::get('reason'); $report->image_url = $imageurl; $report->type = 'Traffic Jam'; $report->title = RestApi::getaddress(Request::get('lat'), Request::get('lng')); $report->save(); $values = array(Request::get('lat'), Request::get('lng'), '12'); return RestApi::sendNotification('TJ', $values); /*return Response::json(array( 'error' => false), 200 ); */ }
/** * Store a newly created resource in storage. * * @return Response */ public function store() { $imageurl = ''; if (Request::get('image') != '') { $imageurl = "public/images/report/trafficjam_" . time() . ".jpg"; $base = Request::get('image'); $binary = base64_decode($base); $ifp = fopen($imageurl, "wb"); fwrite($ifp, $binary); fclose($ifp); $imageurl = 'http://125.62.200.54/traffic/' . $imageurl; } $roadblock = RoadBlock::create(array('user' => Request::get('user'), 'latitude' => Request::get('lat'), 'longitude' => Request::get('lng'), 'time' => date('g:iA', time()), 'date' => date('M j', time()), 'status' => Request::get('status'), 'reason' => Request::get('reason'), 'image_url' => $imageurl)); $report = new Report(); $report->user = Request::get('user'); $report->latitude = Request::get('lat'); $report->longitude = Request::get('lng'); $report->time = date('g:i A', time()); $report->date = date('M j', time()); $report->description = "The road is blocked at " . RestApi::getaddress(Request::get('lat'), Request::get('lng')) . " due to " . Request::get('reason'); $report->image_url = $imageurl; $report->type = 'Road Block'; $report->title = RestApi::getaddress(Request::get('lat'), Request::get('lng')); $report->save(); return RestApi::sendNotification('RB', Request::get('lat'), Request::get('lng'), RestApi::getaddress(Request::get('lat'), Request::get('lng')), '12'); }
/** * Store a newly created resource in storage. * * @return Response */ public function store() { $imageurl = ''; if (Request::get('image') != '') { $imageurl = "/images/report/accident_" . time() . ".jpg"; $base = Request::get('image'); $binary = base64_decode($base); $ifp = fopen($imageurl, "wb"); fwrite($ifp, $binary); fclose($ifp); $imageurl = 'http://125.62.200.54/traffic/' . $imageurl; } $accident = Accident::create(array('user' => Request::get('user'), 'latitude' => Request::get('lat'), 'longitude' => Request::get('lng'), 'time' => date('g:i A', time()), 'date' => date('M j', time()), 'details' => Request::get('details'), 'image_url' => $imageurl)); $report = new Report(); $report->traffic_jam_id = $accident->id; $report->user = Request::get('user'); $report->latitude = Request::get('lat'); $report->longitude = Request::get('lng'); $report->time = date('g:i A', time()); $report->date = date('M j', time()); $report->description = "There has been an accident. " . Request::get('details'); $report->image_url = $imageurl; $report->type = 'Accident'; $report->title = RestApi::getaddress(Request::get('lat'), Request::get('lng')); $report->save(); //RestApi::sendNotification() return Response::json(array('error' => false), 200); }
public function createMultiple($gameModel, $gameInputs) { foreach ($gameInputs as $player) { $report = new Report(); $report->game = $gameModel->id; $report->player = $player; $report->save(); } }
public function action_do_create() { $v = Report::validate(Input::all()); if ($v->fails()) { return Redirect::to_route('create_report')->with('user', Auth::user())->with_errors($v)->with_input(); } $new_report = array('date' => Input::get('date'), 'description' => Input::get('description'), 'time_spent' => Input::get('time_spent'), 'todo_id' => Input::get('todo_id'), 'project_id' => Input::get('project_id'), 'user_id' => Auth::user()->id, 'organization_id' => Auth::user()->organization->id); $report = new Report($new_report); $report->save(); return Redirect::to_route('read_customer', array(Input::get('customer_id'))); }
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new Report(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Report'])) { $model->attributes = $_POST['Report']; if ($model->save()) { $this->redirect(array('view', 'id' => $model->id)); } } $this->render('create', array('model' => $model)); }
/** * Handles User Report * * @return Response */ public function report() { $r = new Report(); if ($r->save()) { $user = new User(); $user->email = '*****@*****.**'; $target = User::find($r->user); $m = new Mailer(); $m->send($user, 'emails.report', array('report' => $r, 'target' => $target), array('subject' => 'Music Equity Account Report', 'from' => '*****@*****.**')); return Response::json(['success' => true]); } else { return Response::json($r->errors()); } }
/** * Store a newly created report in storage. * * @return Response */ public function store() { $data = Input::all(); Report::setRules('store'); if (!Report::canCreate()) { return $this->_access_denied(); } $report = new Report(); $report->fill($data); if (!$report->save()) { return $this->_validation_error($report); } if (Request::ajax()) { return Response::json($report, 201); } return Redirect::action('ReportsController@index')->with('notification:success', $this->created_message); }
public static function createReport($input) { $rules = array('message' => 'required|min:10', 'subject_code' => 'required', 'type_name' => 'required', 'type_id' => 'required'); $validator = Validator::make($input, $rules); if ($validator->fails()) { return $validator->errors()->all(); } else { try { $report = new Report(); $report->fill($input); $report->save(); return "ok"; } catch (Exception $e) { return "no"; } } }
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate($id, $iduser) { $model = new Report(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Report'])) { $model->attributes = $_POST['Report']; if ($model->save()) { $this->redirect(array('site/index')); } } $criteria = new CDbCriteria(); $criteria->compare('author_id', $iduser); $criteria->compare('status', '1'); $criteria = Post::model()->findAll($criteria); $this->render('create', array('model' => $model, 'id' => $id, 'criteria' => $criteria)); }
public function reporting() { // $pet_ad_id = Input::get('petad-id'); $subject = Input::get('subject'); $name = Input::get('name'); $email = Input::get('email'); $message = Input::get('message'); $viewmore_id = Input::get('viewmore_id'); $reason = Input::get('reason'); $report = new Report(); $report->petad_id = $viewmore_id; $report->name = $name; $report->email = $email; $report->message = $message; $report->reason = $message; $report->save(); return Redirect::to('/viewmore?id=' . $viewmore_id)->with(array('welcome_back' => 'Thanks for reporting, we will look into this issue.')); }
private function addReport($options, $connection) { $report = new Report(); $report->setDescription(self::generateDescription()); $report->setTitle(implode(', ', array_keys($options['queries']))); $report->save(); foreach ($options['queries'] as $key => $value) { $query = new Query(); $query->setQuery($key); $query->save(); $report_query = new ReportQuery(); $report_query->setQuery($query); $report_query->setTitle($key); $report_query->setReport($report); $report_query->save(); $date_start = strtotime($options['start_date']); $date_end = strtotime($options['end_date']); $start = $value['rand_start']; while ($date_start < $date_end) { if (rand(0, 100) > $value['rand']) { $query_result = new QueryResultBulk(); $query_result->setQuery($query); $start += rand($value['rand_min'], $value['rand_max']) * $value['rand_diff']; $query_result->setResultSize($start); $query_result->setCreatedAt($date_start); $query_result->save(); } $date_start = strtotime(date('Y-m-d', $date_start) . ' +1 days'); } $sql = "DELETE FROM %s where date(%s) = '%s' and %s = %s"; $sql = sprintf($sql, QueryResultPeer::TABLE_NAME, QueryResultPeer::RESULT_DATE, date('Y-m-d'), QueryResultPeer::QUERY_ID, $query->getId()); $statement = $connection->prepareStatement($sql); $statement->executeQuery(); } $tags = self::generateTags(); foreach ($tags as $tag) { $tag->setReport($report); $tag->save(); } }
public function testDelete() { $rep = new Report(); $now = date("Y-m-d H:i:s"); $rep->setDescription("tester"); $rep->setInvolvementKindID(2); $rep->setReportKindID(1); $rep->setLocationID(1); $rep->setPersonID(1); $rep->setDepartmentID(2); $rep->setDateTime($now); $rep->setStatusID(2); $rep->setActionTaken("nothing"); $rep->save(); $this->assertTrue(Report::reportExists($rep->getPersonID(), $rep->getDateTime()) != false); $rep->delete(); $this->assertTrue(!Report::reportExists($rep->getPersonID(), $rep->getDateTime())); }
function add_custom_report() { if (logged_user()->isGuest()) { flash_error(lang('no access permissions')); ajx_current("empty"); return; } tpl_assign('url', get_url('reporting', 'add_custom_report')); $report_data = array_var($_POST, 'report'); if (is_array($report_data)) { tpl_assign('report_data', $report_data); $conditions = array_var($_POST, 'conditions'); if (!is_array($conditions)) { $conditions = array(); } tpl_assign('conditions', $conditions); $columns = array_var($_POST, 'columns'); if (is_array($columns) && count($columns) > 0) { tpl_assign('columns', $columns); $newReport = new Report(); $member_ids = json_decode(array_var($_POST, 'members')); if (!is_array($member_ids) || count($member_ids) == 0) { flash_error(lang('must choose at least one member')); ajx_current("empty"); return; } $members = Members::findAll(array("conditions" => array("`id` IN(?)", $member_ids))); if (!$newReport->canAdd(logged_user(), $members)) { flash_error(lang('no access permissions')); ajx_current("empty"); return; } // if $newReport->setObjectName($report_data['name']); $newReport->setDescription($report_data['description']); $newReport->setReportObjectTypeId($report_data['report_object_type_id']); $newReport->setOrderBy($report_data['order_by']); $newReport->setIsOrderByAsc($report_data['order_by_asc'] == 'asc'); try { DB::beginWork(); $newReport->save(); $allowed_columns = $this->get_allowed_columns($report_data['report_object_type_id'], true); foreach ($conditions as $condition) { if ($condition['deleted'] == "1") { continue; } foreach ($allowed_columns as $ac) { if ($condition['field_name'] == $ac['id']) { $newCondition = new ReportCondition(); $newCondition->setReportId($newReport->getId()); $newCondition->setCustomPropertyId($condition['custom_property_id']); $newCondition->setFieldName($condition['field_name']); $newCondition->setCondition($condition['condition']); $condValue = array_key_exists('value', $condition) ? $condition['value'] : ''; if ($condition['field_type'] == 'boolean') { $newCondition->setValue(array_key_exists('value', $condition)); } else { if ($condition['field_type'] == 'date') { if ($condValue != '') { $dtFromWidget = DateTimeValueLib::dateFromFormatAndString(user_config_option('date_format'), $condValue); $newCondition->setValue(date("m/d/Y", $dtFromWidget->getTimestamp())); } } else { $newCondition->setValue($condValue); } } $newCondition->setIsParametrizable(isset($condition['is_parametrizable'])); $newCondition->save(); } } } asort($columns); //sort the array by column order foreach ($columns as $column => $order) { if ($order > 0) { $newColumn = new ReportColumn(); $newColumn->setReportId($newReport->getId()); if (is_numeric($column)) { $newColumn->setCustomPropertyId($column); } else { $newColumn->setFieldName($column); } $newColumn->save(); } } $object_controller = new ObjectController(); $object_controller->add_to_members($newReport, $member_ids); DB::commit(); flash_success(lang('custom report created')); ajx_current('back'); } catch (Exception $e) { DB::rollback(); flash_error($e->getMessage()); ajx_current("empty"); } } } $selected_type = array_var($_GET, 'type', ''); $types = array(array("", lang("select one"))); $object_types = ObjectTypes::getAvailableObjectTypes(); foreach ($object_types as $ot) { $types[] = array($ot->getId(), lang($ot->getName())); } if ($selected_type != '') { tpl_assign('allowed_columns', $this->get_allowed_columns($selected_type)); } tpl_assign('object_types', $types); tpl_assign('selected_type', $selected_type); $new_report = new Report(); tpl_assign('object', $new_report); }
/** * Saves a report * @param <type> $reportName * @param <type> $reportGroupId * @param <type> $useFilterField * @param <type> $type * @return Report */ public function saveReport($reportName, $reportGroupId, $useFilterField, $type) { try { $report = new Report(); $report->setName($reportName); $report->setReportGroupId($reportGroupId); $report->setUseFilterField($useFilterField); $report->setType($type); $report->save(); return $report; } catch (Exception $ex) { throw new DaoException($ex->getMessage()); } }
/** * Import a report * */ public static function importFile($filename, $showMessage = true, $removeExistingReport = false) { $localErrors = array(); $allAccounts = array(); $dom = new domDocument(); if (!$dom->load($filename)) { if ($showMessage) { throw new CException(Yii::t('lazy8', 'input file could not be xml parsed')); } else { throw new CException('input file could not be xml parsed'); } } $root = $dom->documentElement; if ($root->nodeName != "lazy8webportreport") { if ($showMessage) { $localErrors = array(array(Yii::t('lazy8', 'Upload failed. This is not a valid file.'), Yii::t('lazy8', 'Select a file and try again'))); } return $localErrors; } if ($root->getAttribute('version') > 1.0) { if ($showMessage) { $localErrors = array(array(Yii::t('lazy8', 'There maybe problems because this is a file version greater then this programs version'), Yii::t('lazy8', 'Select a file and try again'))); } } $nodeReports = $root->getElementsByTagName('report'); unset($root); unset($dom); foreach ($nodeReports as $nodeReport) { if ($removeExistingReport) { $deleteReports = Report::model()->findAll(array('condition' => 'name=\'' . $nodeReport->getAttribute('name') . '\'')); if ($deleteReports != null) { foreach ($deleteReports as $deleteReport) { $deleteReport->delete(); } } } $report = new Report(); $report->name = $nodeReport->getAttribute('name'); $report->desc = ReportController::getNodeText($nodeReport, "desc"); $report->selectSql = ReportController::getNodeText($nodeReport, "selectsql"); $report->sortOrder = ReportController::getNodeText($nodeReport, "sortOrder"); $report->cssColorFileName = ReportController::getNodeText($nodeReport, "csscolorfilename"); $report->cssBwFileName = ReportController::getNodeText($nodeReport, "cssbwfilename"); $nodeParams = $nodeReport->getElementsByTagName('parameter'); if (!$report->save()) { if ($showMessage) { $localErrors = $report->getErrors(); } return $localErrors; } foreach ($nodeParams as $nodeParam) { $reportParam = new ReportParameters(); $reportParam->reportId = $report->id; $reportParam->sortOrder = $nodeParam->getAttribute('sortorder'); $reportParam->name = $nodeParam->getAttribute('name'); $reportParam->alias = $nodeParam->getAttribute('alias'); $reportParam->dataType = $nodeParam->getAttribute('datatype'); $reportParam->isDefaultPhp = $nodeParam->getAttribute('isdefaultphp') == 'true' ? 1 : 0; $reportParam->isDate = $nodeParam->getAttribute('isdate') == 'true' ? 1 : 0; $reportParam->isDecimal = $nodeParam->getAttribute('isdecimal') == 'true' ? 1 : 0; $reportParam->desc = ReportController::getNodeText($nodeParam, "desc"); $reportParam->phpSecondaryInfo = ReportController::getNodeText($nodeParam, "phpsecondaryinfo"); $reportParam->defaultValue = ReportController::getNodeText($nodeParam, "defaultvalue"); if (!$reportParam->save()) { if ($showMessage) { $localErrors = $reportParam->getErrors(); } } } unset($nodeParams); $nodeGroups = $nodeReport->getElementsByTagName('group'); foreach ($nodeGroups as $nodeGroup) { $reportGroup = new ReportGroups(); $reportGroup->reportId = $report->id; $reportGroup->sortOrder = $nodeGroup->getAttribute('sortorder'); $reportGroup->breakingField = $nodeGroup->getAttribute('breakingfield'); $reportGroup->pageBreak = $nodeGroup->getAttribute('pagebreak') == 'true' ? 1 : 0; $reportGroup->showGrid = $nodeGroup->getAttribute('showgrid') == 'true' ? 1 : 0; $reportGroup->showHeader = $nodeGroup->getAttribute('showheader') == 'true' ? 1 : 0; $reportGroup->continueSumsOverGroup = $nodeGroup->getAttribute('continuesumsovergroup') == 'true' ? 1 : 0; if (!$reportGroup->save()) { if ($showMessage) { $localErrors = $reportGroup->getErrors(); } } $nodeGroupFields = $nodeGroup->getElementsByTagName('field'); foreach ($nodeGroupFields as $nodeGroupField) { $reportGroupField = new ReportGroupFields(); $reportGroupField->reportGroupId = $reportGroup->id; $reportGroupField->sortOrder = $nodeGroupField->getAttribute('sortorder'); $reportGroupField->fieldName = $nodeGroupField->getAttribute('fieldname'); $reportGroupField->fieldWidth = $nodeGroupField->getAttribute('fieldwidth'); $reportGroupField->row = $nodeGroupField->getAttribute('row'); $reportGroupField->isDate = $nodeGroupField->getAttribute('isdate') == 'true' ? 1 : 0; $reportGroupField->isDecimal = $nodeGroupField->getAttribute('isdecimal') == 'true' ? 1 : 0; $reportGroupField->fieldCalc = ReportController::getNodeText($nodeGroupField, "fieldcalc"); if (!$reportGroupField->save()) { if ($showMessage) { $localErrors = $reportGroupField->getErrors(); } } } unset($nodeGroupFields); } unset($nodeGroups); $nodeReportRows = $nodeReport->getElementsByTagName('rows'); foreach ($nodeReportRows as $nodeReportRow) { $reportRow = new ReportRows(); $reportRow->reportId = $report->id; $reportRow->sortOrder = $nodeReportRow->getAttribute('sortorder'); $reportRow->fieldName = $nodeReportRow->getAttribute('fieldname'); $reportRow->fieldWidth = $nodeReportRow->getAttribute('fieldwidth'); $reportRow->row = $nodeReportRow->getAttribute('row'); $reportRow->isSummed = $nodeReportRow->getAttribute('issummed') == 'true' ? 1 : 0; $reportRow->isAlignRight = $nodeReportRow->getAttribute('isalignright') == 'true' ? 1 : 0; $reportRow->isDate = $nodeReportRow->getAttribute('isdate') == 'true' ? 1 : 0; $reportRow->isDecimal = $nodeReportRow->getAttribute('isdecimal') == 'true' ? 1 : 0; $reportRow->fieldCalc = ReportController::getNodeText($nodeReportRow, "fieldcalc"); if (!$reportRow->save()) { if ($showMessage) { $localErrors = $reportRow->getErrors(); } } } } return $localErrors; }
public function actionReports() { $report = new Report(); if ($postReport = Yii::app()->request->getParam('Report')) { $report->setAttributes($postReport); $emails = array(); if (count($emails = explode(PHP_EOL, $postReport['email'])) <= 1) { $emails = array($postReport['email']); } foreach ($emails as $e) { if (strlen($e) <= 0) { continue; } $newReport = new Report(); $newReport->email = $e; $newReport->period = $postReport['period']; if (!$newReport->save()) { throw new Exception(print_r($newReport->getErrors(), true)); } } $this->refresh(); } $this->render('reports', array('report' => $report)); }
function add_custom_report() { if (logged_user()->isGuest()) { flash_error(lang('no access permissions')); ajx_current("empty"); return; } tpl_assign('url', get_url('reporting', 'add_custom_report')); $report_data = array_var($_POST, 'report'); if (is_array($report_data)) { tpl_assign('report_data', $report_data); $conditions = array_var($_POST, 'conditions'); if (!is_array($conditions)) { $conditions = array(); } tpl_assign('conditions', $conditions); $columns = array_var($_POST, 'columns'); if (is_array($columns) && count($columns) > 0) { tpl_assign('columns', $columns); $newReport = new Report(); if (!$newReport->canAdd(logged_user())) { flash_error(lang('no access permissions')); ajx_current("empty"); return; } // if $newReport->setName($report_data['name']); $newReport->setDescription($report_data['description']); $newReport->setObjectType($report_data['object_type']); $newReport->setOrderBy($report_data['order_by']); $newReport->setIsOrderByAsc($report_data['order_by_asc'] == 'asc'); try { DB::beginWork(); $newReport->save(); $allowed_columns = $this->get_allowed_columns($report_data['object_type'], true); foreach ($conditions as $condition) { if ($condition['deleted'] == "1") { continue; } foreach ($allowed_columns as $ac) { if ($condition['field_name'] == $ac['id']) { $newCondition = new ReportCondition(); $newCondition->setReportId($newReport->getId()); $newCondition->setCustomPropertyId($condition['custom_property_id']); $newCondition->setFieldName($condition['field_name']); $newCondition->setCondition($condition['condition']); $condValue = array_key_exists('value', $condition) ? $condition['value'] : ''; if ($condition['field_type'] == 'boolean') { $newCondition->setValue(array_key_exists('value', $condition)); } else { if ($condition['field_type'] == 'date') { if ($condValue != '') { $dtFromWidget = DateTimeValueLib::dateFromFormatAndString(user_config_option('date_format'), $condValue); $newCondition->setValue(date("m/d/Y", $dtFromWidget->getTimestamp())); } } else { $newCondition->setValue($condValue); } } $newCondition->setIsParametrizable(isset($condition['is_parametrizable'])); $newCondition->save(); } } } asort($columns); //sort the array by column order foreach ($columns as $column => $order) { if ($order > 0) { $newColumn = new ReportColumn(); $newColumn->setReportId($newReport->getId()); if (is_numeric($column)) { $newColumn->setCustomPropertyId($column); } else { $newColumn->setFieldName($column); } $newColumn->save(); } } DB::commit(); flash_success(lang('custom report created')); ajx_current('back'); } catch (Exception $e) { DB::rollback(); flash_error($e->getMessage()); ajx_current("empty"); } } } $selected_type = array_var($_GET, 'type', ''); $types = array(array("", lang("select one")), array("Companies", lang("companies")), array("Contacts", lang("contacts")), array("MailContents", lang("email type")), array("ProjectEvents", lang("events")), array("ProjectFiles", lang("file")), array("ProjectMilestones", lang("milestone")), array("ProjectMessages", lang("message")), array("ProjectTasks", lang("task")), array("Users", lang("user")), array("ProjectWebpages", lang("webpage")), array("Projects", lang("workspace"))); if ($selected_type != '') { tpl_assign('allowed_columns', $this->get_allowed_columns($selected_type)); } tpl_assign('object_types', $types); tpl_assign('selected_type', $selected_type); }
public function report($params = array()) { extract($params); if (isset($user_id) && isset($to_report) && $to_report) { $report_arr = array('user_id' => $user_id, 'to_report' => $to_report); if (isset($content) && $content) { $report_arr['content'] = $content; } if (isset($type) && $type) { $report_arr['type'] = $type; } if (isset($style) && $style) { $report_arr['style'] = $style; } $model = new Report(); $model->attributes = $report_arr; if ($model->validate() && $model->save()) { $id = $model->getPrimaryKey(); $ret = $this->notice('OK', 0, '成功', ['id' => $id]); } else { $ret = $this->notice('ERR', 307, '数据插入失败', $model->getErrors()); } } else { $ret = $this->notice('OK', 301, '缺少参数', []); } return $ret; }
private function reportPost() { $message = new Message($_POST['message_id']); $message->reported = 1; $result = $message->save(); if (!\PHPWS_Error::isError($result)) { $report = new Report(); $report->setMessageId($message->id); $report->setReporterId($message->to_user_id); $report->setOffenderId($message->from_user_id); $report->setReason($_POST['reason']); $report->save(); } else { return $result; } }
$t = new lime_test(20, new lime_output_color()); $t->diag('getNumVehicles() - One entry'); $vehicles_query = Doctrine_Core::getTable('Vehicle')->createQuery('v')->leftJoin('v.User u')->andWhere('u.username = ?', 'user_gs')->limit(1); $report = new Report(); $report->setName('report_test_1'); $report->setUserId($ut->getUserId('user_gs')); $report->setVehicles($vehicles_query->execute()); $report->save(); $t->cmp_ok($report->getNumVehicles(), '===', 1); $t->diag('getNumVehicles() - Many entries'); $vehicles_query = Doctrine_Core::getTable('Vehicle')->createQuery('v')->leftJoin('v.User u')->andWhere('u.username = ?', 'user_gs'); $report = new Report(); $report->setName('report_test_2'); $report->setUserId($ut->getUserId('user_gs')); $report->setVehicles($vehicles_query->execute()); $report->save(); $t->cmp_ok($report->getNumVehicles(), '===', 4); $t->diag('getPdfFileName()'); $pdfname = $report->getHash() . '.pdf'; $t->cmp_ok($report->getPdfFileName(), '===', $pdfname, 'Pdf filename is built from hash'); $t->diag('getPdfWebPath()'); $webpath = sfConfig::get('app_report_dir_name'); $t->cmp_ok($report->getPdfWebPath(), '===', $webpath, 'getPdfWebPath() returns the relative url of the pdf files root'); $t->diag('getPdfFileWebPath()'); $filewebpath = $report->getPdfWebPath() . '/' . $pdfname; $t->cmp_ok($report->getPdfFileWebPath(), '===', $filewebpath, 'getPdfFileWebPath() returns the relative url of the pdf file'); $t->diag('getPdfSystemPath()'); $systempath = sfConfig::get('sf_web_dir') . DIRECTORY_SEPARATOR . str_replace('/', DIRECTORY_SEPARATOR, $webpath); $t->cmp_ok($report->getPdfSystemPath(), '===', $systempath, 'getPdfSystemPath() returns the root path of the pdf files'); $t->ok(file_exists(str_replace($pdfname, '', $systempath)), 'The folder storing the pdf reports exist'); $t->diag('getPdfFileFullPath()');
public function report() { $recordId = Input::get('record'); $reason = Input::get('reason'); if (!$reason) { Session::flash('error', 'Please enter a report reason!'); return Redirect::back(); } $count = Report::where('path_record_id', '=', $recordId)->count(); if ($count > 0) { Session::flash('error', 'This path has already been reported'); return Redirect::back(); } // load record $record = PathRecord::findOrFail($recordId); if ($record->locked) { Session::flash('error', 'You cannot report this directory!'); return Redirect::back(); } $report = new Report(); $report->path_record_id = $record->id; $report->path = $record->path; $report->reason = $reason; $user = Auth::user(); if ($user) { $report->user_id = $user->id; } $report->save(); Session::flash('success', 'Report submitted'); return Redirect::back(); }
public function onReport($param) { $username = TSession::getValue("username"); $r = new Report(); $font = $r->createFont("Arial", 8, "000000", "FFFFFF"); $font->setBold(); $r->setFont($font); $r->write('Tribunal Regional Eleitoral do Rio Grande do Norte'); $r->write('Secretaria de Administração e Orçamento'); $r->write('Planejamento e Gestão Orçamentária do TRE/RN'); $r->write(' '); $r->centerText(); $r->write("Solicitações de materiais permanentes [{$username}]"); $r->write(' '); $r->createTable(array(4, 4.8, 4.8, 1.7, 1.7)); $r->addTableRow(array("Tipo do material", "Descrição", "Justificativa", "Quantidade", "Custo"), array("L", "L", "L", "R", "R")); $r->setFont($r->createFont("Arial", 8, "000000", "FFFFFF")); TTransaction::open('app'); $repositorio = new TRepository('MaterialPermanente'); $criterios = new TCriteria(); //$criterios->setProperty('order', 'nome'); $criterios->add(new TFilter("system_user_id", "=", TSession::getValue("userid"))); $materiais = $repositorio->load($criterios); foreach ($materiais as $solicitacao) { $r->addTableRow(array($solicitacao->tipo_material_permanente_nome, $solicitacao->descricao, $solicitacao->justificativa, $solicitacao->quantidade, $solicitacao->custo), array("L", "L", "L", "R", "R")); } TTransaction::close(); $md5_userid = md5(TSession::getValue("userid")); $r->save("./app/output/tipo_material_permanente_{$md5_userid}.rtf"); parent::openFile("./app/output/tipo_material_permanente_{$md5_userid}.rtf"); }
public function onReport($param) { $r = new Report(); $fonteCabecalho = $r->createFont("Arial", 8, "000000", "FFFFFF"); $fonteCabecalho->setBold(); $fonte = $r->createFont("Arial", 8, "000000", "FFFFFF"); $r->setFont($fonteCabecalho); $r->write('Tribunal Regional Eleitoral do Rio Grande do Norte'); $r->write('Secretaria de Administração e Orçamento'); $r->write('Planejamento e Gestão Orçamentária do TRE/RN'); $r->write(' '); $r->centerText(); $r->write("Solicitações de materiais permanentes por unidade"); TTransaction::open('app'); $conexao = TTransaction::get(); $sql = "SELECT\n system_user.name unidade,\n tipo_material_permanente.nome tipo_material_permanente_nome,\n material_permanente.descricao,\n material_permanente.justificativa,\n material_permanente.quantidade,\n material_permanente.custo\nFROM \n material_permanente, tipo_material_permanente, system_user\nWHERE\n tipo_material_permanente_id= tipo_material_permanente.id AND\n system_user_id = system_user.id\nORDER BY\n system_user.name, tipo_material_permanente.nome"; $solicitacoes = $conexao->query($sql); $ultima_unidade = ""; foreach ($solicitacoes as $solicitacao) { if ($ultima_unidade != $solicitacao["unidade"]) { $ultima_unidade = $solicitacao["unidade"]; $r->setFont($fonteCabecalho); $r->leftText(); $r->write(' '); $r->write($ultima_unidade); $r->createTable(array(4, 4.8, 4.8, 1.7, 1.7)); $r->addTableRow(array("Tipo do material", "Descrição", "Justificativa", "Quantidade", "Custo"), array("L", "L", "L", "R", "R")); $r->setFont($fonte); } $r->addTableRow(array($solicitacao["tipo_material_permanente_nome"], $solicitacao["descricao"], $solicitacao["justificativa"], $solicitacao["quantidade"], $solicitacao["custo"]), array("L", "L", "L", "R", "R")); } TTransaction::close(); $md5_userid = md5(TSession::getValue("userid")); $r->save("./app/output/tipo_material_permanente_{$md5_userid}.rtf"); parent::openFile("./app/output/tipo_material_permanente_{$md5_userid}.rtf"); }
private function reportPhotoPost() { if (!$this->validatePhoto()) { return 'error: photo upload failed'; } $report = new Report(); //fetch and check for valid report $report->fetch($this->args[0]); if ($report->getID() == null) { $this->response['message'] = 'error: failed to load report with id ' . $this->args[0]; $this->response['code'] = 405; } //report id $reportID = $this->args[0]; $photo = $this->files['photo']; $upload_dir = Path::uploads() . $reportID . '/'; //make the directory if it doesn't already exist if (!file_exists($upload_dir)) { mkdir($upload_dir, 0755, true); } //make sure there wasnt an error with the upload if ($photo['error'] !== UPLOAD_ERR_OK) { $this->response['message'] = 'error: photo upload error'; $this->response['code'] = 400; } //make sure filename is safe $name = preg_replace("/[^A-Z0-9._-]/i", "_", $photo['name']); //different dir for each report $i = 0; $parts = pathinfo($name); while (file_exists($upload_dir . $name)) { //myfile-1.png $name = $parts['filename'] . '-' . $i . '.' . $parts['extension']; } //move file from temp directory $success = move_uploaded_file($photo['tmp_name'], $upload_dir . $name); if (!$success) { $this->response['message'] = 'error: unable to save file'; $this->response['code'] = 500; } //set proper file permissions on new file chmod($upload_dir . $name, 0644); //update the report in DB with file location $report->setPhotoPath($upload_dir . $name); $report->save(); return $report->toArray(); }
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new Report(); if (isset($_POST['Report'])) { $model->attributes = $_POST['Report']; $report_name = $model->name; $description = $model->description; //txt_field_commodity : selected column field names //field_commodity : selected row ids; //commodity : item_ids $attributeArray = []; $fromTables = []; $whereClauses = []; /*************COMMODITY*****************/ if (isset($_POST['txt_field_commodity'])) { $table = 'commodity'; $fromTables[] = '`commodity`'; $attributes = $_POST['txt_field_commodity']; foreach ($attributes as $attr) { $attributeArray[] = $table . '.' . $attr; } $rows = isset($_POST['commodity']) ? $_POST['commodity'] : []; $whereArray1 = []; foreach ($rows as $item) { $whereArray1[] = $item; } $whereText1 = implode(',', $whereArray1); if ($whereText1 != 'all') { $whereClauses[] = "commodity.id IN ({$whereText1})"; } } /*******COMMODITY CATEGORY********/ if (isset($_POST['txt_field_category'])) { $table = 'commodity_category'; $fromTables[] = '`commodity_category`'; $attributes = $_POST['txt_field_category']; foreach ($attributes as $attribute) { $attributeArray[] = $table . '.' . $attribute; } $rows = isset($_POST['category']) ? $_POST['category'] : []; $whereArray2 = []; foreach ($rows as $item) { $whereArray2[] = $item; } $whereText2 = implode(',', $whereArray2); $whereClauses[] = "commodity.id = commodity_category.commodity_id"; if ($whereText2 != 'all') { $whereClauses[] = "commodity_category.id IN ({$whereText2})"; } } /*******ITEMS********/ if (isset($_POST['txt_field_consumable'])) { $table = 'consumable'; $fromTables[] = '`consumable`'; $attributes = $_POST['txt_field_consumable']; foreach ($attributes as $attribute) { $attributeArray[] = $table . '.' . $attribute; } $rows = isset($_POST['consumable']) ? $_POST['consumable'] : []; $whereArray3 = []; foreach ($rows as $item) { $whereArray3[] = $item; } $whereText3 = implode(',', $whereArray3); $whereClauses[] = "commodity.id = consumable.commodity_id AND commodity_category.path = consumable.category_id"; if ($whereText3 != 'all') { $whereClauses[] = "consumable.id IN ({$whereText3})"; } } //blocked if (isset($_POST['total'])) { $whereClauses[] = "consumable.available_on_loan = 'Yes'"; } //on loan if (isset($_POST['new_stock'])) { $whereClauses[] = "consumable.available_on_loan = 'Yes'"; } /*******threshold********/ if (isset($_POST['threshold'])) { //print_r ($_POST['consumable']);die; $rows = isset($_POST['consumable']) ? $_POST['consumable'] : []; $itemId = implode(',', $rows); $connection = Yii::app()->db; if ($itemId == 'all') { $sql = "\n\t\t\t\t\tselect *\n\t\t\t\t\tfrom consumable"; } else { //$itemId = $_POST['consumable'][0]; $sql = "\n\t\t\t\t\tselect *\n\t\t\t\t\tfrom consumable \n\t\t\t\t\twhere id IN ({$itemId})"; } $command = $connection->createCommand($sql); $dataReader = $command->queryAll(); $id = $dataReader[0]['id']; $allocates = Allocate::model()->findAll('commodity_id=:commodity_id AND cons_id=:cons_id', array('commodity_id' => 3, 'cons_id' => $id)); $numUnitsLeft = count($allocates); //echo $numUnitsLeft;die; $whereClauses[] = "consumable.threshold < {$numUnitsLeft} "; } $attributeText = implode(',', $attributeArray); $fromTableText = implode(',', $fromTables); $whereClauseText = implode(' AND ', $whereClauses); if ($whereClauses == NULL) { $whereClauseText = 1; } $model->query = "SELECT {$attributeText} FROM {$fromTableText} WHERE {$whereClauseText}"; //echo $model->query;die; if ($model->save()) { $this->redirect(array('view', 'id' => $model->rid)); } } $this->render('create', array('model' => $model)); }
private function blockPost() { \PHPWS_Core::initModClass('properties', 'Report.php'); \PHPWS_Core::initModClass('properties', 'Message.php'); $report = new Report($_POST['report_id']); $report->setBlockReason($_POST['block_reason']); $report->block = 1; $report->save(); $message = new Message($report->message_id); $message->setHidden(1); $message->save(); }
protected function createReport() { $model = new \Report(['name' => 'Test report', 'description' => 'Test report description', 'query' => ['statement.actor.mbox' => ['mailto:test@example.com']], 'lrs_id' => new \MongoId($this->lrs->_id)]); $model->save(); return $model; }
/** * Gets the weather from Yahoo!, which is more reliable. */ public function getYahooWeatherInfo() { echo "<pre>\n"; $manualSearch = new Collection(); foreach (Structure::get() as $structure) { if (strlen($structure->postal_code) > 0 && strlen($structure->country_code) > 0) { // find City in database? /** @var City $city */ $city = City::firstOrCreate(['postal_code' => $structure->postal_code, 'country_code' => $structure->country_code]); } else { // Fall back to Utrecht, the netherlands (central station area): $city = City::firstOrCreate(['postal_code' => '3511CE', 'country_code' => 'NL']); } $manualSearch->push($city); } $manualSearch = $manualSearch->unique(); // Yahoo weather is always per city. /** @var City $manualEntry */ foreach ($manualSearch as $city) { // function wont do stuff when its already filled. $this->_helper->getGeoFromYahoo($city); $weatherObject = $this->_helper->getYahooWeatherForCity($city); echo 'Now searching for city #' . $city->id . ', [postal code: ' . $city->postal_code . ', country code: ' . $city->country_code . ']' . "\n"; echo 'City has timezone ' . $city->time_zone . ' and woe-id ' . $city->woeid . "\n"; // try to get as many results from this as possible if (isset($weatherObject->query->results)) { $channel = $weatherObject->query->results->channel; // create report entry first: $report = new Report(); $report->city()->associate($city); $report->time = new Carbon(); $report->save(); // start saving data: // sunrise: $sysSunrise = new Carbon($channel->astronomy->sunrise, $city->time_zone); $sysSunrise->setTimezone('UTC'); $entry = new ReportValue(); $entry->report()->associate($report); $entry->name = 'sys.sunrise'; $entry->value = $sysSunrise->format('U'); $entry->save(); // sunset: $sysSunset = new Carbon($channel->astronomy->sunset, $city->time_zone); $sysSunset->setTimezone('UTC'); $entry = new ReportValue(); $entry->report()->associate($report); $entry->name = 'sys.sunset'; $entry->value = $sysSunset->format('U'); $entry->save(); // current temperature: $entry = new ReportValue(); $entry->report()->associate($report); $entry->name = 'main.temp'; $entry->value = floatval($channel->item->condition->temp); $entry->save(); // current humidity: $entry = new ReportValue(); $entry->report()->associate($report); $entry->name = 'main.humidity'; $entry->value = floatval($channel->atmosphere->humidity); $entry->save(); // current pressure: $entry = new ReportValue(); $entry->report()->associate($report); $entry->name = 'main.pressure'; $entry->value = floatval($channel->atmosphere->pressure); $entry->save(); // max predicted for today. $entry = new ReportValue(); $entry->report()->associate($report); $entry->name = 'main.temp_max'; $entry->value = floatval($channel->item->forecast[0]->high); $entry->save(); // min predicted for today. $entry = new ReportValue(); $entry->report()->associate($report); $entry->name = 'main.temp_min'; $entry->value = floatval($channel->item->forecast[0]->low); $entry->save(); // wind speed $entry = new ReportValue(); $entry->report()->associate($report); $entry->name = 'wind.speed'; $entry->value = floatval($channel->wind->speed); $entry->save(); // wind degrees $entry = new ReportValue(); $entry->report()->associate($report); $entry->name = 'wind.deg'; $entry->value = floatval($channel->wind->direction); $entry->save(); // rain 1h? SKIPPED // weather.main $entry = new ReportValue(); $entry->report()->associate($report); $entry->name = 'weather.main'; $entry->value = trim($channel->item->condition->text); $entry->save(); // weather.description $entry = new ReportValue(); $entry->report()->associate($report); $entry->name = 'weather.description'; $entry->value = trim($channel->item->description); $entry->save(); echo 'Saved ' . $report->reportValues()->count() . ' weather reports for city #' . $city->id . "\n\n"; } else { echo 'No results for city [' . $city->postal_code . ', ' . $city->country_code . ']' . "\n\n"; } } }