Exemplo n.º 1
0
 public function add_announcement()
 {
     if (!Auth::user() || Auth::user()->role != 1) {
         return redirect('/');
     }
     $fields = Field::orderBy('name')->lists('name', 'id');
     $terms = Term::lists('name', 'id');
     $municipalities = Municipality::all();
     $municipality_regions = array();
     foreach ($municipalities as $m) {
         $municipality_regions[] = array('municipality' => $m, 'region' => $m->region);
     }
     $regions = Region::lists('name', 'id');
     $type = array(0 => 'ვატარებ', 1 => 'ვეძებ');
     $quarter = Quarter::all()->lists('name', 'id');
     $month = Month::all()->lists('name', 'id');
     return view('add_forms.add_announcement', ['fields' => $fields, 'terms' => $terms, 'regions' => $regions, 'municipality_regions' => $municipality_regions, 'quarter' => $quarter, 'month' => $month, 'type' => $type]);
 }
Exemplo n.º 2
0
 public function edit_announcement($id)
 {
     $fields = Field::orderBy('name')->lists('name', 'id');
     $terms = Term::lists('name', 'id');
     $municipalities = Municipality::lists('name', 'id');
     $regions = Region::lists('name', 'id');
     $type = array(0 => 'ვატარებ', 1 => 'ვეძებ');
     $quarter = Quarter::all()->lists('name', 'id');
     $months = Month::all()->lists('name', 'id');
     $select = DB::select(' SELECT trainings.id, field_training.field_id, term_training.term_id, municipality_training.municipality_id, month_training.month_id
                             FROM trainings
                             JOIN field_training ON trainings.id = field_training.training_id
                             JOIN term_training ON trainings.id = term_training.training_id
                             JOIN municipality_training ON trainings.id = municipality_training.training_id
                             JOIN month_training ON trainings.id = month_training.training_id
                             where trainings.id = ' . $id . '
                             group by trainings.id
                ');
     $select = $select[0];
     $training_filtered = new \stdClass();
     $training_instance = Training::find($select->id);
     $training_field = Field::find($select->field_id);
     $training_municipality = Municipality::find($select->municipality_id);
     $training_months = DB::select('SELECT months.name FROM month_training JOIN months ON months.id = month_training.month_id WHERE training_id = ' . $training_instance->id);
     $training_terms = DB::select('SELECT terms.name FROM term_training JOIN terms ON terms.id = term_training.term_id WHERE training_id = ' . $training_instance->id);
     foreach ($training_months as $month) {
         $training_months_array[] = $month->name;
     }
     foreach ($training_terms as $term) {
         $training_terms_array[] = $term->name;
     }
     $training_filtered->id = $training_instance->id;
     $training_filtered->header = $training_instance->name;
     $training_filtered->description = $training_instance->description;
     $training_filtered->file = $training_instance->file;
     $training_filtered->link = $training_instance->link;
     $training_filtered->field['name'] = $training_field->name;
     $training_filtered->field['id'] = $training_field->id;
     $training_filtered->months = $training_months_array;
     $training_filtered->terms = $training_terms_array;
     $training_filtered->municipality['name'] = $training_municipality->name;
     $training_filtered->municipality['id'] = $training_municipality->id;
     $training_filtered->region = $training_municipality->region_id;
     $training_filtered->isAdmin = Auth::check();
     return view('edit.edit_announcement', ['fields' => $fields, 'terms' => $terms, 'regions' => $regions, 'municipalities' => $municipalities, 'quarter' => $quarter, 'month' => $months, 'type' => $type, 'training' => $training_filtered]);
 }
Exemplo n.º 3
0
 public function render_form_data()
 {
     $fields = Field::orderBy('name')->lists('name', 'id');
     $terms = Term::lists('name', 'id');
     $municipalities = Municipality::all();
     $municipality_regions = array();
     foreach ($municipalities as $m) {
         $municipality_regions[] = array('municipality' => $m, 'region' => $m->region);
     }
     $regions = Region::lists('name', 'id');
     $type = array(0 => 'ვატარებ', 1 => 'ვეძებ');
     $quarter = Quarter::all()->lists('name', 'id');
     $month = Month::all()->lists('name', 'id');
     return view('search_forms.search', ['fields' => $fields, 'terms' => $terms, 'regions' => $regions, 'municipality_regions' => $municipality_regions, 'quarter' => $quarter, 'month' => $month, 'type' => $type]);
 }