Exemple #1
0
 public function index_onDelete()
 {
     if (($checkedIds = post('checked')) && is_array($checkedIds) && count($checkedIds)) {
         foreach ($checkedIds as $postId) {
             if (!($post = Campus::find($postId))) {
                 continue;
             }
             $post->delete();
         }
         Flash::success('Successfully deleted those campus.');
     }
     return $this->listRefresh();
 }
Exemple #2
0
include_once dirname(__FILE__) . '/../inc/helper.inc.php';
include_once dirname(__FILE__) . '/../model/Participante.class.php';
include_once dirname(__FILE__) . '/../model/Atividade.class.php';
include_once dirname(__FILE__) . '/../model/Inscricao.class.php';
include_once dirname(__FILE__) . '/../model/TipoParticipante.class.php';
include_once dirname(__FILE__) . '/../model/Campus.class.php';
$nome = $_POST['nome'];
$nome_mae = $_POST['nome_mae'];
$identidade = $_POST['identidade'];
$cpf = $_POST['cpf'];
$data_nascimento = $_POST['data_nascimento'];
$email = $_POST['email'];
$tipo = TipoParticipante::find($_POST['tipo_id']);
$quantidade_alunos = $_POST['quantidade_alunos'];
if ($_POST['tipo_id'] == 1 || $_POST['tipo_id'] == 2) {
    $campus = Campus::find($_POST['campus_id']);
}
$escola = $_POST['escola'];
$participante = Participante::find_by_cpf($cpf);
if (isset($participante)) {
    header("location: /" . $config['PATH'] . "/inscricoes/form_login.php?syserror=CPF_JA_INSCRITO");
    exit;
}
$participante = new Participante();
$participante->nome = $nome;
$participante->nome_mae = $nome_mae;
$participante->identidade = $identidade;
$participante->cpf = $cpf;
$participante->data_nascimento = $data_nascimento;
$participante->email = $email;
$participante->tipo = $tipo;
 public function campus()
 {
     //return 'We Are Working';
     //Changed
     $data['date'] = $this->getBaseDateTime();
     $campus = UserCampus::whereUserId(Auth::user()->id)->first();
     if ($campus) {
         Session::put('campus', $campus->campus_id);
     } else {
         Session::put('campus', 1);
     }
     /*19-May-2015 Ehsan*/
     $user = User::find(Auth::user()->id);
     $url = Picture::find($user->picture);
     $data['self'] = $url;
     /*!!!!19-May-2015 Ehsan*/
     // Everyday Question Generation
     $data['question'] = null;
     $data['prev_question'] = null;
     $question = Question::orderBy('id', 'desc')->first();
     $prev_question = Question::orderBy('id', 'desc')->skip(1)->first();
     if ($question) {
         $data['question'] = $question;
         $data['options_of_question'] = QuestionOption::whereQuestionId($question->id)->get();
         //$get_count_of_the_answers = DB::table('users_answers')->select(DB::raw('option_number,count(*) as count'))->join('question_options','users_answers.option_id', '=', 'question_options.id')->whereQuestionId($question->id)->groupBy('option_id')->groupBy('option_number')->orderBy('option_number')->get();
         $data['answered'] = UsersAnswer::whereUserId(Auth::user()->id)->whereQuestionId($question->id)->first();
     }
     if ($prev_question) {
         $data['prev_question'] = $prev_question;
         $options_of_question = QuestionOption::whereQuestionId($prev_question->id)->get();
         $total_answer = 0;
         foreach ($options_of_question as $key) {
             $current_answer = DB::table('users_answers')->select(DB::raw('count(*) as count'))->whereOptionId($key->id)->first()->count;
             $total_answer += $current_answer;
             $answers_count[$key->option_number] = array('option_details' => $key->option_details, 'total_answer' => $current_answer);
         }
         try {
             foreach ($options_of_question as $key) {
                 $cur = $answers_count[$key->option_number]['total_answer'] * 1.0;
                 $percentage = $cur / $total_answer * 100.0;
                 $answers_count[$key->option_number]['total_answer'] = number_format((double) $percentage, 2, '.', '');
             }
         } catch (Exception $e) {
             $answers_count[1]['total_answer'] = 33;
             $answers_count[2]['total_answer'] = 33;
             $answers_count[3]['total_answer'] = 33;
         }
         $data['total_votes'] = $total_answer;
         $data['answers'] = $answers_count;
     }
     // ENd of Question Related Code
     // Top And Flop Post Generation
     //return json_encode($data);
     $posts = Post::select('posts.*')->join('users', 'users.id', '=', 'posts.user_id')->where('users.disable', '0')->whereType('2')->whereCampusId(Session::get('campus'))->orderBy('posts.id', 'desc')->take(30)->lists('id');
     $top_post = DB::table('likes')->select(DB::raw('count(*) as like_count, post_id'))->whereIn('post_id', $posts)->orderBy('like_count', 'desc')->groupBy('post_id')->first();
     // return json_encode($top_post);
     $flop_post = DB::table('dislikes')->select(DB::raw('count(*) as dislike_count, post_id'))->whereIn('post_id', $posts)->orderBy('dislike_count', 'desc')->groupBy('post_id')->first();
     $data['flop_post'] = null;
     $data['top_post'] = null;
     if ($top_post) {
         $post = Post::whereId($top_post->post_id)->first();
         /*19-May-2015 Ehsan*/
         $user = User::find($post->user_id);
         $url = Picture::find($user->picture);
         $url = $url->url;
         /*!!!!19-May-2015 Ehsan*/
         $text = htmlentities($post->post);
         /*Eve-26-May-Ehsan*/
         /*!!!!Eve-26-May-Ehsan*/
         $text = preg_replace('@(https?://([-\\w\\.]+)+(:\\d+)?(/([\\w/_\\.]*(\\?\\S+)?)?)?)@', '<a target="_blank" href="$1">$1</a>', $text);
         $text = preg_replace('/#([a-zA-Z0-9\\x{0980}-\\x{09FF}_])+/u', '<a href="#" class="tags">$0</a>', $text);
         $text = nl2br($text);
         $text = Emojione::shortnameToImage($text);
         $now = Carbon::parse($post->created_at);
         $data['top_post'] = array('id' => $post->id, 'post' => $text, 'user_id' => $post->user_id, 'img' => asset($url), 'like' => Like::wherePostId($post->id)->get()->count(), 'dislike' => Dislike::wherePostId($post->id)->get()->count(), 'liked' => Like::wherePostId($post->id)->whereUserId(Auth::user()->id)->get()->count(), 'disliked' => Dislike::wherePostId($post->id)->whereUserId(Auth::user()->id)->get()->count(), 'comment' => Comment::wherePostId($post->id)->get()->count(), 'ago' => $now->diffForHumans());
     } else {
         $data['top_post'] = null;
     }
     if ($flop_post) {
         $post = Post::whereId($flop_post->post_id)->first();
         /*19-May-2015 Ehsan*/
         $user = User::find($post->user_id);
         $url = Picture::find($user->picture);
         $url = $url->url;
         /*!!!!19-May-2015 Ehsan*/
         $text = htmlentities($post->post);
         /*Eve-26-May-Ehsan*/
         /*!!!!Eve-26-May-Ehsan*/
         $text = preg_replace('@(https?://([-\\w\\.]+)+(:\\d+)?(/([\\w/_\\.]*(\\?\\S+)?)?)?)@', '<a target="_blank" href="$1">$1</a>', $text);
         $text = preg_replace('/#([a-zA-Z0-9\\x{0980}-\\x{09FF}_])+/u', '<a href="#" class="tags">$0</a>', $text);
         $text = nl2br($text);
         $text = Emojione::shortnameToImage($text);
         $now = Carbon::parse($post->created_at);
         $data['flop_post'] = array('id' => $post->id, 'post' => $text, 'user_id' => $post->user_id, 'img' => asset($url), 'like' => Like::wherePostId($post->id)->get()->count(), 'dislike' => Dislike::wherePostId($post->id)->get()->count(), 'liked' => Like::wherePostId($post->id)->whereUserId(Auth::user()->id)->get()->count(), 'disliked' => Dislike::wherePostId($post->id)->whereUserId(Auth::user()->id)->get()->count(), 'comment' => Comment::wherePostId($post->id)->get()->count(), 'ago' => $now->diffForHumans());
     } else {
         $data['flop_post'] = null;
     }
     // Top And Flop Post Generation end
     // Get All Available Reports and Feelings
     $data['feelings'] = Feeling::get();
     $data['reports'] = Report::get();
     //
     $data['notifications'] = $this->getNotification();
     //Get Current Trends
     $now = Carbon::now();
     $before_12hours = Carbon::now()->subHours(12);
     $data['tags'] = DB::table('hash_tagged_posts')->select('tag_id', 'tag', DB::raw('count(*) as  count'))->join('hashtags', 'hashtags.id', '=', 'hash_tagged_posts.tag_id')->whereIn('hash_tagged_posts.post_id', function ($query) {
         $query->select('id')->from('posts')->whereType('2')->where('campus_id', Session::get('campus'));
     })->whereBetween('hash_tagged_posts.created_at', array($before_12hours, $now))->groupBy(['tag_id', 'tag'])->orderBy('count', 'desc')->take(3)->get();
     //Get Current Trends End
     $data['page'] = "campus";
     $campus = UserCampus::whereUserId(Auth::user()->id)->first();
     if ($campus == null || $campus->campus_id == '1') {
         $data['page'] = "campus";
         $data['top_post'] = null;
         $data['flop_post'] = null;
         $data['posts'] = null;
         $data['isValid'] = "0";
         $data['campuses'] = Campus::all();
         return View::make('campus')->with('data', $data);
     }
     $data['isValid'] = "1";
     $data['campus'] = Campus::find(Session::get('campus'))->name;
     return View::make('campus')->with('data', $data);
 }
 private static function convert($row)
 {
     $participante = new Participante();
     $participante->id = $row['id'];
     $participante->nome = $row['nome'];
     $participante->matricula = $row['matricula'];
     $participante->email = $row['email'];
     $participante->cpf = $row['cpf'];
     $participante->nome_mae = $row['nome_mae'];
     $participante->identidade = $row['identidade'];
     $participante->tipo = TipoParticipante::find($row['tipo_id']);
     if ($participante->tipo->id == 3) {
         $participante->quantidade_alunos = $row['quantidade_alunos'];
     }
     if ($row['data_nascimento'] != "") {
         $participante->data_nascimento = date("d/m/Y", strtotime($row['data_nascimento']));
     }
     if (isset($row['campus_id'])) {
         $participante->campus = Campus::find($row['campus_id']);
     }
     $participante->escola = $row['escola'];
     return $participante;
 }