Exemplo n.º 1
0
 public function renderCategory($category_id)
 {
     $this->render();
     $this->subjects->where('ad_category', $category_id);
     $this->strict = false;
     $this->type = 'category';
 }
Exemplo n.º 2
0
 public function handleLikedSubjects()
 {
     $this->tab = 'likedSubjects';
     $res = $this->context->database->table('subject_rating')->select('subject_id, SUM(thumb_up) AS thumb_up, SUM(thumb_down) AS thumb_down')->order('thumb_up DESC, thumb_down')->group('subject_id');
     foreach ($res as $key => $row) {
         $ids[] = $row['subject_id'];
     }
     if (isset($ids)) {
         $this->subjects->where('id', $ids);
         $this->subjects->order('FIND_IN_SET(subject.id,"' . implode(",", $ids) . '")');
     } else {
         $this->subjects->where('id', '-2');
     }
     $this->refresh();
 }
Exemplo n.º 3
0
 public function renderSubjects($args = NULL)
 {
     dump($args);
     if (key_exists('shire', $args)) {
         $this->subjects->where('ad_shire', $args['shire']);
     }
     if (key_exists('locality', $args)) {
         $this->subjects->where('ad_locality', $args['locality']);
     }
     if (key_exists('category', $args)) {
         $this->subjects->where('ad_category', $args['category']);
     }
     $this->subjects->fetchAd($this->strict);
     $this->template->setFile(dirname(__FILE__) . '/subjects.latte');
     $this->render();
 }
Exemplo n.º 4
0
 public function renderDefault()
 {
     $this->template->subjects = $this->places->order('name')->where('subject.id != 1')->group('subject.id')->having('COUNT(:event.id) > 0');
     $this->template->approvedPlacesCount = $this->approvedPlacesCount;
     $this->template->subject_id = $this->subject_id;
     if ($this->subject_id != 'all') {
         $this->events->where('subject_id', $this->subject_id)->group('event.id')->having('COUNT(:event_time.id) = 0');
     }
     // vyhledavani
     if ($this->q) {
         $this->events->where("event.name LIKE ? OR subject.name LIKE ? OR user.email LIKE ?", "%" . $this->q . "%", "%" . $this->q . "%", "%" . $this->q . "%");
         $this->places->where("subject.name LIKE ?", "%" . $this->q . "%");
         $this['search']['q']->setDefaultValue($this->q);
         $this->template->search = TRUE;
     } else {
         $this->template->search = FALSE;
     }
     if ($this->order == '' && $this->user->isInRole('administrator')) {
         $this->order = 'updated DESC';
     }
     switch ($this->what) {
         case self::ANONYMOUS:
             $this->events->where('subject_id', '1');
             $this->template->what = self::ANONYMOUS;
             break;
         case self::NOTERM:
             $this->events->group('event.id')->having('COUNT(:event_time.id) = 0');
             $this->template->what = self::NOTERM;
             break;
         case self::UPDATED:
             $this->events->group('event.id')->having('DATEDIFF(NOW(), event.changed) < ' . self::TIME_UPDATED);
             $this->template->what = self::UPDATED;
             break;
         case self::RECENT:
             $this->events->group('event.id')->having('DATEDIFF(NOW(), event.created) < ' . self::TIME_RECENT);
             $this->template->what = self::UPDATED;
             break;
         case self::TOREVIEW:
             $this->events->group('event.id')->having('event.reviewed = 0');
             $this->template->what = self::TOREVIEW;
             break;
         case self::NOTAPPROVED:
             $this->events->group('event.id')->having('event.approved = 0');
             $this->template->what = self::NOTAPPROVED;
             break;
         case self::PREFERED:
             $this->events->group('event.id')->having('event.prefered = 1');
             $this->template->what = self::PREFERED;
             break;
         default:
             $this->template->what = self::ALL;
     }
     if ($this->orderBy == '' && $this->user->isInRole('administrator')) {
         $this->orderBy = self::MODIFICATION;
     }
     switch ($this->orderBy) {
         case self::MODIFICATION:
             $this->events->order('changed DESC, created DESC');
             $this->template->orderBy = self::MODIFICATION;
             break;
         case self::ALPHABET:
         default:
             $this->events->order('name');
             $this->template->orderBy = self::ALPHABET;
             break;
     }
     $this->pagerEvents->itemCount = $this->events->count();
     $this->template->events = $this->events->limit($this->pagerEvents->getLimit(), $this->pagerEvents->getOffset());
     if ($this->user->isInRole('administrator')) {
         $this->template->nonaproved = $this->context->createServiceEvents()->where('approved', '0');
     }
 }
 public function postDeleteSubjects()
 {
     $class_id = Input::get('class_id');
     $section_id = Input::get('section_id');
     $subject_id = Input::get('subject_id');
     $subject_name = Input::get('subject_name');
     $subject_code = Input::get('subject_code');
     if ($subject_id) {
         $subjects = Subjects::find($subject_id);
     } else {
         $subjects = Subjects::where('subject_name', '=', $subject_name)->where('subject_code', '=', $subject_code)->where('class_id', '=', $class_id)->where('section_id', '=', $section_id);
     }
     if ($subjects->delete()) {
         $response = array('status' => 'success', 'msg' => 'Subject deleted successfully', 'result' => array('subjects' => $subjects));
         return Response::json($response);
     } else {
         $response = array('status' => 'failed', 'msg' => 'Subject is Not deleted', 'result' => array('subjects' => $subjects));
         return Response::json($response);
     }
 }