Example #1
0
 /**
  * Execute the job.
  *
  * @return bool
  */
 public function handle()
 {
     $this->workRequest->subject = $this->request->input('subject', $this->workRequest->subject);
     $this->workRequest->best_time = $this->request->input('best_time', $this->workRequest->best_time);
     $this->workRequest->description = $this->request->clean($this->request->input('description', $this->workRequest->description));
     return $this->workRequest->save();
 }
Example #2
0
 /**
  * Execute the job.
  *
  * @return bool
  */
 public function handle()
 {
     $this->workRequest->user_id = auth()->id();
     $this->workRequest->subject = $this->request->input('subject');
     $this->workRequest->best_time = $this->request->input('best_time');
     $this->workRequest->description = $this->request->clean($this->request->input('description'));
     return $this->workRequest->save();
 }
Example #3
0
 /**
  * Update the specified resource in storage.
  *
  * @param WorkRequest $request
  * @param int         $id
  *
  * @return \Illuminate\Http\RedirectResponse
  */
 public function update(WorkRequest $request, $id)
 {
     $this->saveWork($request->all(), $id);
     return redirect()->route('admin.works.index');
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request $request
  * @return \Illuminate\Http\Response
  */
 public function store(WorkRequest $request)
 {
     $work = $this->permissionSection(function () use($request) {
         $newWork = DB::transaction(function () use($request) {
             $newWork = new Work();
             $newWork->slug = CommonController::uniqueSlugFunc($request->title, 'works');
             $newWork->title = $request->title;
             $newWork->description = $request->description;
             $newWork->deadline = strtotime(str_replace('/', '-', $request->deadline));
             $newWork->importance = $request->importance;
             $newWork->created_by = $this->currentUser->getId();
             $newWork->save();
             $departmentWork = new DepartmentWork();
             $departmentWork->department_id = $request->department;
             $departmentWork->assign_date = time();
             //@todo DATE HATASI !!! BURALAR REVİZE EDİLMELİ
             $departmentWork->accepted = 0;
             $departmentWork->save();
             $newWork->last_department_work_id = $departmentWork->id;
             $newWork->save();
             if ($request->hasFile('file')) {
                 $file = $request->file('file');
                 $fileName = CommonController::fileUpload($file, 'uploads/works-files');
                 $newWork->file = $fileName;
                 $newWork->save();
             }
             if ($request->is_senior == 1 && $request->has('department_worker')) {
                 $userWork = new UserWork();
                 $userWork->department_id = $request->department;
                 $userWork->assign_date = time();
                 //@todo DATE HATASI !!! BURALAR REVİZE EDİLMELİ
                 $userWork->assigned_to = $request->department_worker;
                 $userWork->accepted = 0;
                 $userWork->save();
                 $departmentWork->accepted = 1;
                 $departmentWork->last_user_work_id = $userWork->id;
                 $departmentWork->save();
                 /**
                  * İŞ AÇILAN KİŞİYE MAİL ATMA
                  */
                 $user = User::where('id', '=', $request->department_worker)->first();
                 $username = $user->first_name . " " . $user->last_name;
                 $username = mb_convert_case($username, MB_CASE_TITLE, 'utf-8');
                 $workCreator = User::where('id', '=', $newWork->created_by)->first();
                 $creatorusername = $workCreator->first_name . " " . $workCreator->last_name;
                 $creatorusername = mb_convert_case($creatorusername, MB_CASE_TITLE, 'utf-8');
                 CommonController::mailSendNotQueue('IS TAKIP SISTEMI', [$user->email], ['fullname' => $username, 'work' => $newWork, 'message' => 'Departman lideriniz ' . $creatorusername . ' tarafından size , "' . $newWork->title . '" başlıklı yeni bir iş açıldı. Detaylar için lütfen
                     sisteme gidiniz.'], 'emails.work-mail-template');
                 CommonController::sendSms('RHPOZTFYAY', $user->phone, 'Merhaba ' . $username . ', departman lideriniz ' . $creatorusername . ' tarafından size yeni bir iş açıldı
                 lütfen sistem üzerinden ayrıntıları inceleyin');
                 /**
                  * İŞİ OLUŞTURAN KİŞİYE BİLGİLENDİRME
                  */
                 $departmentWithSenior = Department::where('id', '=', $request->department)->with('senior')->first();
                 $seniorUser = $departmentWithSenior->senior[0];
                 $seniorUsername = $seniorUser->first_name . " " . $seniorUser->last_name;
                 $seniorUsername = mb_convert_case($seniorUsername, MB_CASE_TITLE, 'utf-8');
                 CommonController::mailSendNotQueue('IS TAKIP SISTEMI', [$seniorUser->email], ['fullname' => $seniorUsername, 'message' => 'Departmanınıza "' . $newWork->title . '" başlıklı yeni bir iş açılmış ve bu
                      iş ' . $username . ' kişisine atanmıştır. İşin detayları ve işi atamak için lütfen sisteme gidiniz.'], 'emails.work-mail-template');
                 CommonController::sendSms('RHPOZTFYAY', $seniorUser->phone, 'Merhaba ' . $seniorUsername . ', departmanınıza "' . $newWork->title . '" başlıklı yeni
                 bir iş açılmış ve bu iş ' . $username . ' kişisine atanmıştır . İşin detayları ve işi atamak için lütfen sisteme gidiniz.');
             } else {
                 $departmentWithSenior = Department::where('id', '=', $request->department)->with('senior')->first();
                 $user = $departmentWithSenior->senior[0];
                 $username = $user->first_name . " " . $user->last_name;
                 $username = mb_convert_case($username, MB_CASE_TITLE, 'utf-8');
                 $workCreator = User::where('id', '=', $newWork->created_by)->first();
                 $creatorusername = $workCreator->first_name . " " . $workCreator->last_name;
                 $creatorusername = mb_convert_case($creatorusername, MB_CASE_TITLE, 'utf-8');
                 CommonController::mailSendNotQueue('IS TAKIP SISTEMI', [$user->email], ['fullname' => $username, 'message' => 'Departmanınıza  ' . $creatorusername . ' tarafından , "' . $newWork->title . '" başlıklı yeni bir iş açılmıştır. İşin detayları ve
                     işi atamak için lütfen sisteme gidiniz.'], 'emails.work-mail-template');
                 CommonController::sendSms('RHPOZTFYAY', $user->phone, 'Merhaba ' . $username . ', departmanınıza 
                 "' . $newWork->title . '" başlıklı yeni bir iş açılmıştır. İşin detayları ve işi atamak için lütfen sisteme gidiniz.');
             }
             return $newWork;
         });
         return $newWork;
     }, 'wts.work.create');
     $departmentDetail = Department::where('id', '=', $request->department)->first();
     $work->deadline = date("d-m-y H:i", $work->deadline);
     if ($request->is_senior == 1 && $request->has('department_worker')) {
         return response()->json(['success' => true, 'messages' => 'Kayıt İşlemi Başarılı', 'work' => ['data' => $work, 'department_name' => $departmentDetail->name, 'assigned_to' => $request->department_worker]]);
     } else {
         return response()->json(['success' => true, 'messages' => 'Kayıt İşlemi Başarılı', 'work' => ['data' => $work, 'department_name' => $departmentDetail->name]]);
     }
 }