Esempio n. 1
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int $id
  * @return \Illuminate\Contracts\View\Factory
  */
 public function edit($id)
 {
     $paper = Paper::findOrFail($id);
     $subjects = Subject::all();
     $questions = $paper->questions;
     return view('paper.edit', compact('paper', 'subjects', 'questions'));
 }
 public function index()
 {
     $courses = Centre::with('courses')->get();
     $papers = Paper::with('courses')->get();
     $levels = Level::with('levels')->get();
     $courseNum = Course::all();
     return view('acca.base')->withCentres($courses)->withPapers($papers)->withLevels($levels)->with('courseNum', $courseNum);
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, $id)
 {
     //
     $input = $request->all();
     $validator = Validator::make($input, ['price' => 'required', 'job_type' => 'required', 'job_id' => 'required', 'paper_id' => 'required']);
     if ($validator->fails()) {
         return \Redirect::back()->withErrors($validator)->withInput();
     }
     array_forget($request, "_token");
     $all_request = $request->all();
     $price = Price::find($id);
     $papers = Paper::all();
     $jobs = Job::all();
     foreach ($all_request as $key => $value) {
         $price->{$key} = $value;
     }
     $price->update();
     $prices = Price::all();
     if ($request->ajax()) {
         if ($prices) {
             foreach ($prices as $price) {
                 echo "\n                        <tr>\n                            <td>{$price->id}</td>\n                            <td>";
                 foreach ($papers as $paper) {
                     if ($paper->id == $price->paper_id) {
                         $paperid = $paper->name;
                         echo $paper->name . ", " . $paper->size;
                     }
                 }
                 echo " </td>\n                            <td>";
                 foreach ($jobs as $job) {
                     if ($job->id == $price->job_id) {
                         $jobid = $job->name;
                         echo $job->name;
                     }
                 }
                 echo "</td>\n                            <td>{$price->job_type}</td>\n                            <td>{$price->price}</td>\n                            <td><button class='edtPriceLink btn-primary' cpaperid='{$paperid}' cjobtype='{$price->job_type}' cid='{$price->id}' cjobid='{$price->job_id}' cprice='{$price->price}'><span  class='glyphicon glyphicon-pencil'></span></button></td>\n                            <td><button class='btn-danger'  data-target='#myModalPaperEdit' data-toggle='modal'><span  class='glyphicon glyphicon-trash'></span></button></td>\n                        </tr>\n                        ";
             }
         }
         exit;
     } else {
         try {
             if ($price->update()) {
                 \Session::flash("success_message", "New Price Record Updated Successfully");
                 return \Redirect::back();
             }
         } catch (\Illuminate\Database\QueryException $e) {
             \Session::flash("error_message", $e->getMessage());
             return \Redirect::back();
         } catch (\PDOException $e) {
             \Session::flash("error_message", $e->getMessage());
             return \Redirect::back();
         } catch (\Exception $e) {
             \Session::flash("error_message", $e->getMessage());
             return \Redirect::back();
         }
     }
     return View("settings.priceedit", ['jobs' => $jobs, 'papers' => $papers, 'title' => 'Job Setting']);
 }
Esempio n. 4
0
 public function paper(Request $request)
 {
     $this->validate($request, ['id' => 'required', 'type' => 'required|in:1,-1']);
     $user = Auth::user();
     $id = $request->input('id');
     $value = $request->input('type');
     $paper = Paper::find($id);
     $isLiked = $this->commit($user, $paper, $id, $value);
     return ['hasCallback' => 1, 'callback' => 'paper_liked', 'hasMsg' => 0, 'msg' => '', 'msgType' => '', 'returns' => ['num_like' => $paper->num_like, 'num_dislike' => $paper->num_dislike, 'is_liked' => $isLiked]];
 }
Esempio n. 5
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $paper = Paper::findOrFail($request->segment(4));
     $params = [];
     if ($paper->archive_id) {
         session(['error' => 'access-denied']);
         if ($request->segment(2) == 'admin') {
             $route = 'admin-home';
         } else {
             $route = 'department::index';
             $params = [$request->segment(2)];
         }
         return redirect()->route($route, $params);
     }
     return $next($request);
 }
Esempio n. 6
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  Request $request
  * @return Response
  */
 public function store(Request $request)
 {
     $paper = Paper::findOrFail($request->get("paper_id"));
     $question = new Question();
     $question->question = $request->get('question');
     $question->language = "en";
     $question->paper()->associate($paper);
     $question->save();
     foreach ($request->get('choice') as $key => $choice) {
         $answer = new Answer();
         $answer->type = "string";
         $answer->textual = $choice;
         $answer->correct = in_array($key + 1, $request->get('answer')) <=> 0;
         $answer->question()->associate($question);
         $answer->save();
     }
     return redirect()->to(route("paper.edit", $paper->id));
 }
Esempio n. 7
0
 /**
  * @param int paper
  * save reviewer evaluation
  * @return \Illuminate\Http\Response
  */
 public function postEvaluate($paper)
 {
     $paper = Paper::findOrFail($paper);
     if ($paper->department_id != auth()->user()->department_id || !systemAccess(2)) {
         if (!$this->systemAdmin) {
             return redirect()->action('Admin\\PaperController@index')->with('error', 'access-denied');
         }
     }
     $criteriaPaper = $rules = $params = $errors = [];
     $criteria = Criteria::where('department_id', $paper->department_id)->with(['langs' => function ($query) {
         $query->lang();
     }])->get();
     foreach ($criteria as $value) {
         $errors[$value->id] = $value->langs->first()->title;
         if (request()->has($value->id)) {
             $params[$value->id] = request($value->id);
             $criteriaPaper[$value->id] = ['value' => request($value->id)];
         }
         if ($value->required) {
             $rules[$value->id] = 'required';
         }
         if ($value->type_id == 1) {
             $max = 'max:1500';
             if (isset($rules[$value->id])) {
                 $rules[$value->id] .= '|' . $max;
             } else {
                 $rules[$value->id] = $max;
             }
         }
     }
     $validator = Validator::make($params, $rules);
     $validator->setAttributeNames($errors);
     if ($validator->fails()) {
         return redirect()->back()->withErrors($validator)->withInput();
     }
     DB::transaction(function () use($criteriaPaper, $paper) {
         $paper->update(['status_id' => 4, 'reviewed_at' => Carbon::now()]);
         $paper->criteria()->sync($criteriaPaper);
     });
     if (request()->get('email')) {
         event(new PaperWasFinished($paper));
     }
     return redirect()->action('Admin\\PaperController@index')->with('success', 'paper-evaluated');
 }
Esempio n. 8
0
 public function postPrice(Request $request)
 {
     array_forget($request, "_token");
     $all_request = $request->all();
     $price = new Price();
     foreach ($all_request as $key => $value) {
         $price->{$key} = $value;
     }
     $price->save();
     $prices = Price::all();
     if ($request->ajax()) {
         if ($prices) {
             foreach ($prices as $price) {
                 echo "\n                       <tr>\n                            <td>{$price->id}</td>\n                            <td>{$price->name}</td>\n\n                            <td>{$price->description}</td>\n                            <td>{$price->created_at}</td>\n                            <td>{$price->updated_at}</td>\n                            <td></td>\n                            <td></td>\n                        </tr>\n                        ";
             }
         }
         exit;
     }
     return View("settings.price", ['prices' => $prices, 'papers' => Paper::all(), 'jobs' => Job::all(), 'title' => 'Job Price Setting']);
 }
Esempio n. 9
0
 public function paper($user, $paper)
 {
     $user = User::findOrFail($user);
     $paper = Paper::findOrFail($paper);
     if (count($user->requests()->where('paper_id', $paper->id)->get())) {
         $data = ['reviewer_id' => $user->id];
         if ($paper->status_id < 2) {
             $data['status_id'] = 2;
         }
         $paper->update($data);
         event(new ReviewerPaperSet($paper));
         return redirect()->action('Admin\\PaperController@index')->with('success', 'reviewer-set');
     }
     return redirect()->action('Admin\\UsersController@index')->with('error', 'access-denied');
 }
Esempio n. 10
0
 /**
  * Execute the job.
  *
  *
  * @return void
  */
 public function handle(Paper $model)
 {
     $model->create($this->request->only(['name', 'description', 'year', 'subject_id']));
 }
Esempio n. 11
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int $id
  * @return Response
  */
 public function edit($id)
 {
     $category = Paper::findOrFail($id);
     return view('paper.edit', compact('category'));
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(Request $request)
 {
     $inputs = Request::all();
     Paper::create($inputs);
     return redirect()->route('admin_papers_index')->with('status', 'Paper created');
 }
Esempio n. 13
0
 public function updatePaper(Request $request)
 {
     Paper::find($request->input('pk'))->update([$request->input('name') => $request->input('value')]);
 }
Esempio n. 14
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $paper = Paper::find($id);
     $invoice = \DB::table("invoicing")->where("job_paper_size", "=", $paper->name)->get();
     if (count($invoice) > 0) {
         return response()->json("This Record cannot be deleted!<br>Bill Transactions is already existing against this site");
         exit;
     }
     if ($paper->delete()) {
         Session::flash("success_message", "Record Successfully deleted");
         echo "Paper Successfully Deleted";
         exit;
     }
 }
Esempio n. 15
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  Paper $paper
  * @return Response
  */
 public function destroy($paper)
 {
     $paper->delete();
 }
 public function compose(View $view)
 {
     $examList = array('' => 'Select a exam date') + DB::table('sittings')->select(DB::raw('concat (month," / ",year) as sitting,id'))->lists('sitting', 'id');
     $view->with('methodList', \App\Method::all())->with('levelList', \App\Level::all())->with('paperList', \App\Paper::all())->with('centreList', \App\Centre::all())->with('elementList', \App\Element::all())->with('examList', $examList);
 }
Esempio n. 17
0
 public function request(Department $department, $paper)
 {
     if (!systemAccess(13)) {
         return redirect()->action('PaperController@index', [$department->keyword])->with('error', 'access-denied');
     }
     $paper = Paper::findOrFail($paper);
     $paper->requests()->attach(auth()->user()->id);
     return redirect()->action('PaperController@index', [$department->keyword])->with('success', 'request-send');
 }