Beispiel #1
0
 public function set($message, $params = array())
 {
     $browser = new Browser();
     $model = new Timeline();
     $model->user_id = Yii::app()->user->id;
     $model->message = Yii::t('timeline', $message, $params);
     $model->user_agent = $browser->getUserAgent();
     $model->ip = CMS::getip();
     $model->user_platform = $browser->getPlatform();
     $model->save(false, false, false);
 }
 public function store()
 {
     // Get StudentID
     // From student_id or Create New
     // Create Registration
     // Create Issue
     // Create Education
     // Create Placement
     // Create Receivables
     // Reductions
     // Create Installment
     try {
         //DB::beginTransaction();
         if (Input::get('student_id') == 0) {
             // Create New Student
             $student = new Student();
             $student->name = Input::get('name');
             $student->sex = Input::get('sex');
             $student->birthplace = Input::get('birthplace');
             $student->birthdate = date('Y-m-d', strtotime(Input::get('birthdate')));
             $student->religion = Input::get('religion');
             $student->address = Input::get('address');
             $student->contact = Input::get('contact');
             $student->email = Input::get('email');
             if (Input::get('sex') == 'L') {
                 $student->photo = 'boy.png';
             } else {
                 $student->photo = 'girl.png';
             }
             $student->father_name = Input::get('father_name');
             $student->father_occupation = Input::get('father_occupation');
             $student->father_address = Input::get('father_address');
             $student->father_contact = Input::get('father_contact');
             $student->father_email = Input::get('father_email');
             $student->mother_name = Input::get('mother_name');
             $student->mother_occupation = Input::get('mother_occupation');
             $student->mother_address = Input::get('mother_address');
             $student->mother_contact = Input::get('mother_contact');
             $student->mother_email = Input::get('mother_email');
             $student->save();
             $id = $student->id;
         } else {
             $student = Student::find(Input::get('student_id'));
             $student->name = Input::get('name');
             $student->sex = Input::get('sex');
             $student->birthplace = Input::get('birthplace');
             $student->birthdate = date('Y-m-d', strtotime(Input::get('birthdate')));
             $student->religion = Input::get('religion');
             $student->address = Input::get('address');
             $student->contact = Input::get('contact');
             $student->email = Input::get('email');
             if (Input::get('sex') == 'L') {
                 $student->photo = 'boy.png';
             } else {
                 $student->photo = 'girl.png';
             }
             $student->father_name = Input::get('father_name');
             $student->father_occupation = Input::get('father_occupation');
             $student->father_address = Input::get('father_address');
             $student->father_contact = Input::get('father_contact');
             $student->father_email = Input::get('father_email');
             $student->mother_name = Input::get('mother_name');
             $student->mother_occupation = Input::get('mother_occupation');
             $student->mother_address = Input::get('mother_address');
             $student->mother_contact = Input::get('mother_contact');
             $student->mother_email = Input::get('mother_email');
             $student->save();
             $id = $student->id;
         }
         // Create Registration Data
         $registration = new Registration();
         $registration->project_id = Auth::user()->curr_project_id;
         $registration->location_id = Auth::user()->location_id;
         $registration->student_id = $id;
         $registration->classification_id = Input::get('classification');
         $registration->base_id = Input::get('location');
         $registration->registration_date = date('Y-m-d', strtotime(Input::get('registration_date')));
         $registration->registration_cost = Input::get('fee');
         $registration->recommender_type = Input::get('recommender_type');
         $registration->recommender_id = Input::get('recommender_id');
         $registration->employee_id = Input::get('employee');
         $registration->save();
         // Create Issue
         $issue = new Issue();
         $issue->project_id = Auth::user()->curr_project_id;
         $issue->location_id = Auth::user()->location_id;
         $issue->registration_id = $registration->id;
         $issue->generation_id = Input::get('generation');
         $issue->student_id = $id;
         $issue->issue = Input::get('issue');
         $issue->save();
         //Create Education Data
         if (Input::get('school') != '0') {
             $education = new Education();
             $education->project_id = Auth::user()->curr_project_id;
             $education->issue_id = $issue->id;
             $education->school_id = Input::get('school');
             $education->generation_id = Input::get('generation');
             $education->save();
         }
         // Receivables - Registration Costs
         $receivable = new Receivable();
         $receivable->project_id = Auth::user()->curr_project_id;
         $receivable->location_id = Auth::user()->location_id;
         $receivable->issue_id = $issue->id;
         $receivable->registration_id = $registration->id;
         $receivable->total = Input::get('total');
         $receivable->billable = Input::get('billable');
         $receivable->receivable = Input::get('receivables');
         $receivable->balance = Input::get('billable');
         if (Input::get('payment') == 0) {
             $receivable->payment = 'Cash';
         } else {
             $receivable->payment = 'Installment';
         }
         $receivable->save();
         $billable = Input::get('billable');
         $payment = Input::get('payment');
         if ((int) $payment > 0) {
             // First Installment
             $installment = new Installment();
             $installment->project_id = Auth::user()->curr_project_id;
             $installment->location_id = Auth::user()->location_id;
             $installment->receivable_id = $receivable->id;
             $installment->schedule = Input::get('registration_date');
             $installment->total = $billable / $payment;
             $installment->balance = $billable / $payment;
             $installment->paid = 0;
             $installment->save();
             // Extracting Date
             $dd = (int) substr(Input::get('registration_date'), 8, 2);
             $mm = (int) substr(Input::get('registration_date'), 5, 2);
             $yy = (int) substr(Input::get('registration_date'), 0, 4);
             if ($dd > 25) {
                 $mm += 2;
                 if ($mm > 12) {
                     $new_mm = $mm - 12;
                     $yy += 1;
                 } else {
                     $new_mm = $mm;
                 }
             } else {
                 $mm += 1;
                 if ($mm > 12) {
                     $new_mm = $mm - 12;
                     $yy += 1;
                 } else {
                     $new_mm = $mm;
                 }
             }
             for ($i = 2; $i <= $payment; $i++) {
                 $installment_date = $yy . '-' . str_pad($new_mm, 2, "0", STR_PAD_LEFT) . '-' . '05';
                 $installment = new Installment();
                 $installment->project_id = Auth::user()->curr_project_id;
                 $installment->location_id = Auth::user()->location_id;
                 $installment->receivable_id = $receivable->id;
                 $installment->schedule = date('Y-m-d', strtotime($installment_date));
                 $installment->total = $billable / $payment;
                 $installment->balance = $billable / $payment;
                 $installment->paid = 0;
                 $installment->save();
                 $new_mm += 1;
                 if ($new_mm > 12) {
                     $new_mm = $new_mm - 12;
                     $yy += 1;
                 }
             }
         }
         // Placements
         $courses = Input::get('course');
         foreach ($courses as $key => $value) {
             $course = explode("#", $value);
             $placement = new Placement();
             $placement->project_id = Auth::user()->curr_project_id;
             $placement->location_id = Auth::user()->location_id;
             $placement->registration_id = $registration->id;
             $placement->issue_id = $issue->id;
             $placement->course_id = $course[0];
             $placement->save();
         }
         // Reductions - Discounts
         $discounts = Input::get('discounts');
         if ($discounts) {
             foreach ($discounts as $key => $value) {
                 $discount = explode("#", $value);
                 $reduction = new Reduction();
                 $reduction->project_id = Auth::user()->curr_project_id;
                 $reduction->location_id = Auth::user()->location_id;
                 $reduction->registration_id = $registration->id;
                 $reduction->receivable_id = $receivable->id;
                 $reduction->reductable_type = 'Discount';
                 $reduction->reductable_id = $discount[0];
                 $reduction->save();
             }
         }
         // Reductions - Promotions
         $promotions = Input::get('promotions');
         if ($promotions) {
             foreach ($promotions as $key => $value) {
                 $promotion = explode("#", $value);
                 $reduction = new Reduction();
                 $reduction->project_id = Auth::user()->curr_project_id;
                 $reduction->location_id = Auth::user()->location_id;
                 $reduction->registration_id = $registration->id;
                 $reduction->receivable_id = $receivable->id;
                 $reduction->reductable_type = 'Promotion';
                 $reduction->reductable_id = $promotion[0];
                 $reduction->save();
             }
         }
         // Reductions - Vouchers
         $vouchers = Input::get('vouchers');
         if ($vouchers) {
             foreach ($vouchers as $key => $value) {
                 $voucher = explode("#", $value);
                 $reduction = new Reduction();
                 $reduction->project_id = Auth::user()->curr_project_id;
                 $reduction->location_id = Auth::user()->location_id;
                 $reduction->registration_id = $registration->id;
                 $reduction->receivable_id = $receivable->id;
                 $reduction->reductable_type = 'Voucher';
                 $reduction->reductable_id = $voucher[0];
                 $reduction->save();
             }
         }
         // Reductions - Charges
         $charges = Input::get('charges');
         if ($charges) {
             foreach ($charges as $key => $value) {
                 $charger = explode("#", $value);
                 $reduction = new Reduction();
                 $reduction->project_id = Auth::user()->curr_project_id;
                 $reduction->location_id = Auth::user()->location_id;
                 $reduction->registration_id = $registration->id;
                 $reduction->receivable_id = $receivable->id;
                 $reduction->reductable_type = 'Charge';
                 $reduction->reductable_id = $charger[0];
                 $reduction->save();
             }
         }
         // Updating Student Timelines
         $content = 'Bergabung menjadi Siswa One School ' . Auth::user()->location->name . 'untuk periode ' . Auth::user()->curr_project->name;
         $timeline = new Timeline();
         $timeline->project_id = Auth::user()->curr_project_id;
         $timeline->location_id = Auth::user()->location_id;
         $timeline->informable_type = 'Issue';
         $timeline->informable_id = $issue->id;
         $timeline->content = $content;
         $timeline->save();
         // Updating Employee Timeline
         $content = 'Menerima Pendaftaran Siswa untuk periode ' . Auth::user()->curr_project->name;
         $timeline = new Timeline();
         $timeline->project_id = Auth::user()->curr_project_id;
         $timeline->location_id = Auth::user()->location_id;
         $timeline->informable_type = 'Employee';
         $timeline->informable_id = Input::get('employee');
         $timeline->content = $content;
         $timeline->save();
         //DB::commit();
         return Response::json(array('status' => 'Succeed', 'registration_id' => $registration->id, 'issue_id' => $issue->id));
     } catch (Exception $e) {
         DB::rollback();
         return Response::json(array('status' => 'Failed', 'error' => $e));
     }
 }
Beispiel #3
0
});
</script>';
$timeline = new Timeline();
// Action handling: Add
switch ($action) {
    case 'add':
        if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) {
            api_not_allowed();
        }
        $url = api_get_self() . '?action=' . Security::remove_XSS($_GET['action']);
        $form = $timeline->return_form($url, 'add');
        // The validation or display
        if ($form->validate()) {
            if ($check) {
                $values = $form->exportValues();
                $res = $timeline->save($values);
                if ($res) {
                    $message = Display::return_message(get_lang('ItemAdded'), 'success');
                }
            }
            $content = $timeline->listing();
        } else {
            $actions .= '<a href="' . api_get_self() . '">' . Display::return_icon('back.png', get_lang('Back'), '', ICON_SIZE_MEDIUM) . '</a>';
            $form->addElement('hidden', 'sec_token');
            $form->setConstants(array('sec_token' => $token));
            $content = $form->return_form();
        }
        break;
    case 'edit':
        // Action handling: Editing
        $url = api_get_self() . '?action=' . Security::remove_XSS($_GET['action']) . '&id=' . intval($_GET['id']);
 /**
  * Resource create action
  * POST        /resource
  * @return Response
  */
 public function store($id)
 {
     // Get all form data.
     $data = Input::all();
     // Create validation rules
     $unique = $this->unique();
     $rules = array('title' => 'required|' . $unique, 'content' => 'required', 'category' => 'exists:job_categories,id', 'location' => 'required');
     $slug = Input::input('title');
     $hashslug = date('H.i.s') . '-' . md5($slug) . '.html';
     // Custom validation message
     $messages = $this->validatorMessages;
     // Begin verification
     $validator = Validator::make($data, $rules, $messages);
     if ($validator->passes()) {
         // Verification success
         // Add resource
         $model = $this->model->find($id);
         $model->category_id = $data['category'];
         $model->title = e($data['title']);
         $model->location = e($data['location']);
         $model->slug = $hashslug;
         $model->content = e($data['content']);
         $model->meta_title = e($data['title']);
         $model->meta_description = e($data['title']);
         $model->meta_keywords = e($data['title']);
         $model->post_status = 'open';
         $timeline = new Timeline();
         $timeline->slug = $hashslug;
         $timeline->model = 'Job';
         $timeline->user_id = Auth::user()->id;
         if ($model->save() && $timeline->save()) {
             // Add success
             return Redirect::route($this->resource . '.edit', $model->id)->with('success', '<strong>' . $this->resourceName . '添加成功:</strong>您可以继续编辑' . $this->resourceName . ',或返回' . $this->resourceName . '列表。');
         } else {
             // Add fail
             return Redirect::back()->withInput()->with('error', '<strong>' . $this->resourceName . '添加失败。</strong>');
         }
     } else {
         // Verification fail
         return Redirect::back()->withInput()->withErrors($validator);
     }
 }
Beispiel #5
0
 public function postRecommendShare()
 {
     $rules = array('shareEmail' => 'required|email');
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->fails()) {
         $data['status'] = 'error';
         $data['errors'] = $validator->messages()->toArray();
     } else {
         $data['status'] = 'success';
         $to = Input::get('shareEmail');
         $request = Pdf::find(Input::get('request_id'));
         define('BUDGETS_DIR', public_path('uploads'));
         // I define this in a constants.php file
         if (!is_dir(BUDGETS_DIR)) {
             mkdir(BUDGETS_DIR, 0755, true);
         }
         $outputName = str_random(10);
         // str_random is a [Laravel helper](http://laravel.com/docs/helpers#strings)
         $pdfPath = BUDGETS_DIR . '/' . $outputName . '.pdf';
         $link = Input::get('pdf');
         Mail::send('emails.form.ocr_share', compact('link'), function ($message) use($pdfPath, $to) {
             $message->from('*****@*****.**', 'REFERECOM');
             $message->to($to)->subject('Letter from Referecom');
             $message->attach($pdfPath);
         });
         $data['status'] = 'success';
         $user = Sentry::getUser()->id;
         $timeline = new Timeline();
         $timeline->activity_type = 'share-Form';
         $timeline->form_ops = $request->id;
         $timeline->user_id = $user;
         $timeline->shared_email = Input::get('shareEmail');
         $timeline->save();
     }
     return Response::json($data);
 }
Beispiel #6
0
| cross-site request forgery attacks. If this special token in a user
| session does not match the one given in this request, we'll bail.
|
*/
Route::filter('csrf', function () {
    if (Session::token() != Input::get('_token')) {
        throw new Illuminate\Session\TokenMismatchException();
    }
});
Route::filter('flatten.flight', function ($route, $request, $response) {
    $flight = $route->getParameter('flight');
    if ($flight->state == 2 && $flight->processed && $flight->pilot->processing == 1) {
        Flatten::end($response);
    }
});
Route::filter('flatten.atc', function ($route, $request, $response) {
    $atc = $route->getParameter('atc');
    if (!is_null($atc->end) && $atc->processed && $atc->pilot->processing == 1) {
        Flatten::end($response);
    }
});
Route::filter('admin', function () {
    if (!Auth::user()->isAdmin()) {
        $timeline = new Timeline();
        $timeline->type = 'unauthorised-access';
        $timeline->user_id = Auth::id();
        $timeline->activity = array('name' => Auth::user()->name);
        $timeline->save();
        return App::abort(404);
    }
});