public function postGeneral($id)
 {
     $id = Crypt::decrypt($id);
     $request = RRequest::find($id);
     if (Input::has('save')) {
         if (Input::get('employee') == 0 || Input::get('organization') == 0 || Input::get('r_plan') == 0 || Input::get('specialist') == 0 || strlen(Input::get('title')) < 2 || strlen(Input::get('description')) < 2) {
             Session::flash('sms_warn', trans('sta.require_field'));
         } else {
             $request->request_by_id = Input::get('employee');
             $request->for_organization_id = Input::get('organization');
             $request->for_planning_id = Input::get('r_plan');
             $request->to_department_id = Input::get('specialist');
             $request->request_title = Input::get('title');
             $request->description = Input::get('description');
             $request->request_date = date('Y-m-d');
             $request->created_by = Auth::user()->employee_id;
             if ($request->save()) {
                 Session::flash('sms_success', trans('sta.save_data_success'));
                 //return Redirect::to('branch_request/general/' . Crypt::encrypt($request->id));
             }
         }
     }
     $organizations = $this->array_list(Organization::list_item());
     $employees = $this->array_list(Employee::list_item());
     $department = $this->array_list(Department::list_item());
     $r_plans = $this->array_list(Rplan::list_item());
     return View::make('branch_request.edit_general', array('id' => $id, 'organizations' => $organizations, 'employees' => $employees, 'specialist' => $department, 'r_plans' => $r_plans, 'request' => $request));
 }
Beispiel #2
0
 public function postNew()
 {
     $employee = $this->array_list(Employee::list_item());
     $user_roll = $this->array_list(UserRoll::list_item());
     if (strlen(Input::get('user_name')) < 4) {
         Session::flash('sms_warn', trans('sta.user_min_5'));
     } elseif (strlen(Input::get('password')) < 4) {
         Session::flash('sms_warn', trans('sta.password_min_5'));
     } elseif (Input::get('password') != Input::get('confirm')) {
         Session::flash('sms_warn', trans('sta.password_confirm_invalid'));
     } elseif (Input::get('employee') <= 0) {
         Session::flash('sms_warn', trans('sta.user_need_employee'));
     } elseif (input::get('user_roll') <= 0) {
         Session::flash('sms_warn', trans('sta.user_need_user_roll'));
     } elseif ($this->is_employee_exist(Input::get('employee'))) {
         Session::flash('sms_warn', trans('sta.employee_already_in_user'));
     } elseif ($this->is_user_exist(Input::get('user_name'))) {
         Session::flash('sms_warn', trans('sta.user_already_exist'));
     } else {
         $user = new User();
         $user->user = Input::get('user_name');
         $user->password = Hash::make(Input::get('password'));
         $user->employee_id = Input::get('employee');
         $user->user_roll_id = Input::get('user_roll');
         $user->created_by = Auth::user()->id;
         $user->save();
         $manage_organize = new ManageOrganization();
         $manage_organize->user_id = $user->id;
         $manage_organize->organization_id = Auth::user()->employee->organization_id;
         $manage_organize->created_by = Auth::user()->id;
         $manage_organize->save();
         return Redirect::to('user/edit/' . Crypt::encrypt($user->id));
     }
     return View::make('user.new', array('employee' => $employee, 'user_roll' => $user_roll));
 }
 public function getNew()
 {
     $employees = $this->array_list(Employee::list_item());
     return View::make('request_staff.new', array('employees' => $employees));
 }