public function store() { $request = $this->request->request; // dump($request); // die; if (!$request->has('point')) { App::$instance->MQ->setMessage('bad params given', 'danger'); ST::redirect("back"); } $result = array(); foreach ($request->get('point') as $point) { $this->validator->validate(['Имя' => [$point['name'], 'required|max(160)'], 'Тип' => [$point['container'], 'between(0,1)'], 'Родитель' => [$point['parent_id'], 'int']]); //if no passes if (!$this->validator->passes()) { $this->putUserDataAtBackPack($this->request); App::$instance->MQ->setMessage($this->validator->errors()->all()); ST::redirect("back"); } $att = new Attendance(); $att->fill($point); $att->active = isset($point['active']) ? 1 : 0; $att->check = isset($point['check']) && !$att->container ? 1 : 0; $att->tech_supportable = isset($point['tech_supportable']) && !$att->container ? 1 : 0; $att->save(); $result[] = "{$att->name} создана успешно"; } App::$instance->MQ->setMessage($result); ST::redirect("?route=AttendanceNew/show/" . $att->parent_id); }
function checkinAction() { $session = SessionWrapper::getInstance(); $this->_helper->layout->disableLayout(); $this->_helper->viewRenderer->setNoRender(TRUE); $formvalues = $this->_getAllParams(); debugMessage('test'); $testarray = array("userid" => 15, 'datein' => 'Jan 27, 2015', 'timein' => '08:00 AM', 'dateout' => '', 'timeout' => '', 'reason' => '', 'createdby' => 15); $attendance = new Attendance(); debugMessage($attendance->toArray()); $attendance->processPost($testarray); debugMessage($attendance->toArray()); debugMessage('errors are ' . $attendance->getErrorStackAsString()); try { $attendance->save(); debugMessage('saved successfully'); debugMessage($attendance->toArray()); } catch (Exception $e) { debugMessage('error: ' . $e->getMessage()); } }
public function saveAttendance($attendance, $students) { $present = 0; $absent = 0; $legal = 0; foreach ($students as $student) { switch ($attendance['Status_' . $student->Code]) { case "1": $present++; break; case "2": $absent++; break; case "3": $legal++; break; } } $model = new Attendance(); $model->Session = $_SESSION['idSession']; $model->Present = $present; $model->Absent = $absent; $model->Legal = $legal; $model->ID_Teacher = Yii::app()->user->getState('idUser'); $model->ID_Class_Subject = $this->getIdClassSubject($_SESSION['idClass'], $_SESSION['idSubject'], Yii::app()->user->getState('idUser')); $model->Date_create = date('Y-m-d'); if ($model->validate() && $model->save()) { return $model->ID; } }
/** * Show the form for creating a new resource. * * @return Response */ public function create() { $rules = ['class' => 'required', 'section' => 'required', 'shift' => 'required', 'session' => 'required', 'regiNo' => 'required', 'date' => 'required', 'subject' => 'required']; $validator = \Validator::make(Input::all(), $rules); if ($validator->fails()) { return Redirect::to('/attendance/create')->withInput(Input::all())->withErrors($validator); } else { $exits = Attendance::select('date')->where('class', Input::get('class'))->where('section', Input::get('section'))->where('shift', Input::get('shift'))->where('session', trim(Input::get('session')))->where('subject', Input::get('subject'))->where('date', $this->parseAppDate(Input::get('date')))->get(); if (count($exits) > 0) { $errorMessages = new Illuminate\Support\MessageBag(); $errorMessages->add('Duplicate', 'Attendance already saved!!'); return Redirect::to('/attendance/create')->withErrors($errorMessages); } else { $absentStudents = array(); $students = Input::get('regiNo'); $presents = Input::get('present'); $all = false; if ($presents == null) { $all = true; } else { $ids = array_keys($presents); } $stpresent = array(); foreach ($students as $student) { $st = array(); $st['regiNo'] = $student; if ($all) { $st['status'] = 'No'; } else { $st['status'] = $this->checkPresent($student, $ids); } if ($st['status'] == "No") { array_push($absentStudents, $student); } array_push($stpresent, $st); } foreach ($stpresent as $stp) { $attendance = new Attendance(); $attendance->class = Input::get('class'); $attendance->section = Input::get('section'); $attendance->shift = Input::get('shift'); $attendance->session = trim(Input::get('session')); $attendance->subject = Input::get('subject'); $attendance->regiNo = $stp['regiNo']; $attendance->status = $stp['status']; $attendance->date = $this->parseAppDate(Input::get('date')); $attendance->save(); } //get sms format //loop absent student and get father's no and send sms $isSendSMS = Input::get('isSendSMS'); if ($isSendSMS == null) { return Redirect::to('/attendance/create')->with("success", "Students attendance save Succesfully."); } else { if (count($absentStudents) > 0) { foreach ($absentStudents as $absst) { $student = DB::table('Student')->join('Class', 'Student.class', '=', 'Class.code')->select('Student.regiNo', 'Student.rollNo', 'Student.firstName', 'Student.middleName', 'Student.lastName', 'Student.fatherCellNo', 'Class.Name as class')->where('Student.regiNo', '=', $absst)->where('class', Input::get('class'))->first(); $msg = "Dear Parents your Child (Name-" . $student->firstName . " " . $student->middleName . " " . $student->lastName . ", Class- " . $student->class . " , Roll- " . $student->rollNo . " ) is Absent in School today."; // $fatherCellNo = Student::select('fatherCellNo','')->where('regiNo', $absst)->first(); $response = $this->sendSMS($student->fatherCellNo, "Supersoft", $msg); $smsLog = new SMSLog(); $smsLog->type = "Attendance"; $smsLog->sender = "Supersoft"; $smsLog->message = $msg; $smsLog->recipient = $student->fatherCellNo; $smsLog->regiNo = $absst; $smsLog->status = $response; $smsLog->save(); } return Redirect::to('/attendance/create')->with("success", "Students attendance saved and " . count($absentStudents) . " sms send to father numbers."); } else { return Redirect::to('/attendance/create')->with("success", "Students attendance save Succesfully."); } } } } }
public function addStudentAttendance() { $inputs = Input::all(); for ($i = 0; $i < $inputs['totalStudents']; $i++) { $isAttendanceExists = Attendance::getDaysAttendanceForStudent($inputs['student_' . $i], $inputs['batch_' . $i], $inputs['attendanceDate_' . $i]); if ($isAttendanceExists) { $isAttendanceExists->status = $inputs['attendance_for_user' . $i]; $isAttendanceExists->save(); } else { $attendanceData = new Attendance(); $attendanceData->attendance_date = $inputs['attendanceDate_' . $i]; $attendanceData->batch_id = $inputs['batch_' . $i]; $attendanceData->student_id = $inputs['student_' . $i]; $attendanceData->status = $inputs['attendance_for_user' . $i]; $attendanceData->save(); } } return Response::json(array("status" => "success")); }