コード例 #1
0
ファイル: DetailsController.php プロジェクト: quenti77/easyhq
 private function getBooks($project_id, $page = 1)
 {
     if (!Session::exists('member')) {
         Router::redirect('home.index');
     }
     $nb = self::NUMBER_ITEM_PER_PAGE;
     $member = Session::get('member');
     $user = $this->checkUser($member['id'], $member['nickname']);
     $search = Helper::post('research');
     $project = Projects::select()->where('id', $project_id)->andWhere('id_leader', $member['id'])->get(0, 1);
     if (empty($project)) {
         Router::url('home.index');
     }
     $project = $project[0];
     $book = UsersBook::select()->addFields(['users_book.status' => 'status', 'F.id' => 'id_from', 'F.nickname' => 'nickname_from', 'T.id' => 'id_to', 'T.nickname' => 'nickname_to'])->innerJoin('users', 'F')->onJoin('F.id', '=', 'users_book.id_user_from')->innerJoin('users', 'T')->onJoin('T.id', '=', 'users_book.id_user_to')->where('status', 2)->andGroup([new Condition('WHERE', '', 'users_book.id_user_from', '!=', $project->id_client, false), new Condition('WHERE', 'AND', 'users_book.id_user_to', '!=', $project->id_client, false)])->andGroup([new Condition('WHERE', '', 'F.nickname', 'LIKE', '%' . $search . '%', false), new Condition('WHERE', 'OR', 'F.mail', 'LIKE', '%' . $search . '%', false), new Condition('WHERE', 'OR', 'T.nickname', 'LIKE', '%' . $search . '%', false), new Condition('WHERE', 'OR', 'T.mail', 'LIKE', '%' . $search . '%', false)])->andGroup([new Condition('WHERE', '', 'id_user_from', '=', $member['id'], false), new Condition('WHERE', 'OR', 'id_user_to', '=', $member['id'], false)])->get(($page - 1) * $nb, $nb);
     $count = UsersBook::select()->addFields(['COUNT(*)' => 'nb_row'])->innerJoin('users', 'F')->onJoin('F.id', '=', 'users_book.id_user_from')->innerJoin('users', 'T')->onJoin('T.id', '=', 'users_book.id_user_to')->where('status', 2)->andGroup([new Condition('WHERE', '', 'F.nickname', 'LIKE', '%' . $search . '%', false), new Condition('WHERE', 'OR', 'F.mail', 'LIKE', '%' . $search . '%', false), new Condition('WHERE', 'OR', 'T.nickname', 'LIKE', '%' . $search . '%', false), new Condition('WHERE', 'OR', 'T.mail', 'LIKE', '%' . $search . '%', false)])->andGroup([new Condition('WHERE', '', 'id_user_from', '=', $member['id'], false), new Condition('WHERE', 'OR', 'id_user_to', '=', $member['id'], false)])->get(0, 1)[0];
     $max_page = ceil($count->nb_row / $nb);
     if ($max_page == 0) {
         $max_page = 1;
     }
     $this->set('books', $book);
     $this->set('max_page', $max_page);
     $this->set('project', $project);
     $this->set('user', $user);
     $this->render('task/detail_user');
 }
コード例 #2
0
ファイル: HomeController.php プロジェクト: quenti77/easyhq
 public function index()
 {
     if (Session::exists('member')) {
         $member = Session::get('member');
         $projects = Projects::select('P')->addFields(['TIMESTAMPDIFF(DAY, NOW(), P.deadline)' => 'nb_day', 'P.id' => 'project_id', 'P.name', 'P.price', 'P.deadline', 'U.id' => 'id_user_leader', 'U.nickname' => 'nickname_user_leader', 'UC.id' => 'id_user_client', 'UC.nickname' => 'nickname_user_client'])->innerJoin('users', 'U')->onJoin('U.id', 'P.id_leader')->leftJoin('tasks', 'T')->onJoin('T.id_project', 'P.id')->leftJoin('task_users', 'task_users')->onJoin('task_users.id_task', 'T.id')->leftJoin('users', 'UC')->onJoin('UC.id', 'P.id_client')->where('id_client', $member['id'])->orWhere('id_leader', $member['id'])->orWhere('task_users.id_user', $member['id'])->groupBy('project_id')->get();
         $this->set('projects', $projects);
     }
     $this->script('projects');
     $this->render('task/home', 'home.task.title');
 }
コード例 #3
0
ファイル: ProjectController.php プロジェクト: quenti77/easyhq
 public function update($id)
 {
     Users::redirectIf(false);
     $member = Session::get('member');
     $project = Projects::select()->where('id', $id)->andWhere('id_leader', $member['id'])->get(0, 1);
     if (empty($project)) {
         Session::setFlash('danger', '', 'Vous n\'avez pas l\'autorisation de modifier ce projet !');
         Router::redirect('task:home.index');
     }
     $project = $project[0];
     $modified = false;
     $name = Helper::post('name');
     if (!empty($name) && $project->name != $name) {
         $project->name = $name;
         $modified = true;
     }
     $description = Helper::post('description');
     if (!empty($description) && $project->description != $description) {
         $project->description = $description;
         $modified = true;
     }
     $price = Helper::post('price');
     if (!empty($price) && $project->price != $price) {
         $project->price = $price;
         $modified = true;
     }
     $date = Helper::post('date');
     $hour = Helper::post('hour');
     $deadline = $project->deadline;
     if (!empty($date) && !empty($hour)) {
         try {
             $dl = new \DateTime($date . ' ' . $hour);
             $now = new \DateTime();
             if ($now < $dl) {
                 $deadline = $dl->format('Y-m-d H:i:s');
             }
         } catch (\Exception $e) {
             // Nothing do
         }
     }
     if ($deadline != $project->deadline) {
         $project->deadline = $deadline;
         $modified = true;
     }
     if ($modified) {
         $project->save();
         Session::setFlash('success', '', 'Vos modifications ont été prise en compte !');
     }
     Router::redirect('task:home.index');
 }