Пример #1
0
 public function dashboard()
 {
     $user = Auth::user();
     $publicnotes = Note::where('user_id', '=', Auth::user()->id)->where('public_or_private', '=', 'public')->get();
     $privatenotes = Note::where('user_id', '=', Auth::user()->id)->where('public_or_private', '=', 'private')->get();
     $publicsheets = Sheet::where('user_id', '=', Auth::user()->id)->where('public_or_private', '=', 'public')->get();
     $privatesheets = Sheet::where('user_id', '=', Auth::user()->id)->where('public_or_private', '=', 'private')->get();
     $publicmeetups = Meetup::where('admin_id', '=', Auth::user()->id)->get();
     $yournotes = Note::where('user_id', '=', Auth::user()->id)->take(5)->get();
     $yoursheets = Sheet::where('user_id', '=', Auth::user()->id)->take(5)->get();
     $yourmeetups = Meetup::where('admin_id', '=', Auth::user()->id)->take(5)->get();
     $userlists = DB::table('sheets')->where('user_id', Auth::user()->id)->orderBy('created_at', 'desc')->paginate(5);
     $usernotes = DB::table('notes')->where('user_id', Auth::user()->id)->orderBy('created_at', 'desc')->paginate(5);
     $alladmin = DB::table('meetups')->where('admin_id', Auth::user()->id)->orderBy('created_at', 'desc')->paginate(5);
     $allmeetups = DB::table('attendees')->where('attendee_id', Auth::user()->id)->orderBy('created_at', 'desc')->paginate(5);
     $meetupsyouarepartof = [];
     if ($allmeetups != null) {
         foreach ($allmeetups as $individualmeetups) {
             $meetup = Meetup::find($individualmeetups->meetup_id);
             array_push($meetupsyouarepartof, $meetup->title);
         }
     } else {
         array_push($meetupsyouarepartof, 'You are not attending any meetups, or you are admin of all of them!');
     }
     return View::make('/users/dashboard')->with('user', $user)->with('userlists', $userlists)->with('usernotes', $usernotes)->with('alladmin', $alladmin)->with('meetupsyouarepartof', $meetupsyouarepartof)->with('publicnotes', $publicnotes)->with('privatenotes', $privatenotes)->with('publicsheets', $publicsheets)->with('privatesheets', $privatesheets)->with('publicmeetups', $publicmeetups)->with('yournotes', $yournotes)->with('yoursheets', $yoursheets)->with('yourmeetups', $yourmeetups);
 }
Пример #2
0
 public function search()
 {
     if ($this->params()->query) {
         $query = '%' . implode('%', array_filter(explode(' ', $this->params()->query))) . '%';
         $this->notes = Note::where("body LIKE ?", $query)->order("id asc")->paginate($this->page_number(), 25);
         $this->respond_to_list("notes");
     } else {
         $this->notes = new Rails\ActiveRecord\Collection();
     }
 }
Пример #3
0
 public function edit($idOrTitle)
 {
     if (is_numeric($idOrTitle)) {
         $note = Note::find($idOrTitle);
     } else {
         $note = Note::where('slug', '=', $idOrTitle)->first();
     }
     if (Auth::user()->id != $note->user_id) {
         Session::flash('errorMessage', 'You are not authorized to edit this note.');
         return Redirect::action('NotesController@index');
     }
     return View::make('notes.edit')->with('note', $note);
 }
 public function destroy($id)
 {
     $classe = $this->model->findOrFail($id);
     $classe->tps()->detach();
     $classe->delete();
     // Détruit les notes associées à cette classes
     //TODO mettre un observer sur le delete afin que tous les dépendants se mettre à jour
     $notes = Note::where('classe_id', '=', $id)->get();
     //TODO:: injecter Note
     foreach ($notes as $note) {
         $note->delete();
     }
     return true;
 }
Пример #5
0
 public function deleteCategory($userId, $categoryId)
 {
     $date = date('Y-m-d H:i:s');
     $cate = Category::where('categoryId', $categoryId)->where('userId', $userId)->first();
     $categoryName = $cate->categoryName . (string) $date;
     if (Category::where('categoryId', $categoryId)->where('userId', $userId)->update(array('categoryName' => $categoryName, 'status' => -1, 'updated_at' => $date))) {
         // Delete all note in cate
         Note::where('cateId', $categoryId)->update(array('status' => -1, 'updated_at' => $date));
         // Update lasted_update of user table
         User::updateLastest($userId, $date);
         return array('status' => 200, 'lastedUpdate' => $date);
     } else {
         return array('status' => 304);
     }
 }
Пример #6
0
 /**
  * function nextRow()
  * Used by both next() and prev()
  * Search database to find the same systemName
  * Sort the search in ticketNumber order which gives the index a sequence
  * Use the index to find the next number in row
  * Passes content, ticketNumber and systemName to the view (ticket.blade.php)
  * @param $nextRow		- increments to find the next / prev row
  * @param $checkIndex	- not in use
  */
 public function nextRow($nextRow, $checkIndex)
 {
     $data = array();
     $systemName = $_POST['systemName'];
     $ticketNumber = $_POST['ticketNumber'];
     //Getting all the same system number and stores the tickets in an array to find the max ticketNumber
     $getAllModel = Document::where('systemName', '=', $systemName)->orderBy('documents_id', 'asc')->get();
     // $index variable to store the location of the current ticketNumber
     // Using this variable to locate the next ticketNumber in row
     $index = 0;
     $allIndex = [];
     //Store all index in an array
     if (sizeof($getAllModel) > 0) {
         foreach ($getAllModel as $key => $value) {
             if ($value->ticketNumber == $ticketNumber) {
                 $index = $key;
             }
             $allIndex[] = $key;
         }
     }
     $maxIndex = max($allIndex);
     //Check the max index
     $minIndex = min($allIndex);
     //Check the min index usually 0
     $nextIndex = $index + $nextRow;
     //Next index = next row or previous row
     if ($nextIndex == $maxIndex || $nextIndex == $minIndex) {
         $data['disable'] = 'disable';
     }
     $nextModel = $getAllModel[$nextIndex];
     $data['content'] = $nextModel->fileContent;
     $data['ticketNumber'] = $nextModel->ticketNumber;
     $data['systemName'] = $nextModel->systemName;
     $data['dateOfFile'] = $nextModel->dateOfFile;
     $data['paxName'] = $nextModel->paxName;
     $data['airlineName'] = $nextModel->airlineName;
     //Use next ticketNumber to find the notes in the notes table and put them into an array
     $comments = array();
     $notes = Note::where('ticketNumber', '=', $nextModel->ticketNumber)->get();
     foreach ($notes as $key => $value) {
         $comments[$key]['time'] = $value->created_at->toDateTimeString();
         $comments[$key]['content'] = $value->note;
     }
     $data['comments'] = $comments;
     if (sizeof($comments) > 0) {
         $data['hasComment'] = "<span class='has-comment'>*R*</span>";
     } else {
         $data['hasComment'] = "";
     }
     echo json_encode($data);
 }
Пример #7
0
 protected function checkExistNote($noteName, $cateId)
 {
     $note = Note::where('noteName', $noteName)->where('cateId', $cateId)->first();
     if (is_null($note)) {
         return true;
     }
     return false;
 }